0
我試圖製作一個非常簡單的RPG戰鬥系統。變量不會在IF語句中改變
但當衛生低於0和什麼也不做有一個錯誤:
jack_battle_loop_1 = True
while jack_battle_loop_1:
battle_menu()
choise = input("> ")
if choise == "1":
#(jack_health + jack_defense) - my_damage = jack_health
jack_health = (jack_health + jack_defense) - random.randrange(20, 25)
#Processing the updated enemy health
print(deskemon + " HAVE INFLICTED " + str(random.randrange(20, 25)) + " TO CHIPHEAD")
print("CHIPHEAD HAS " + str(jack_health) + " HITPOINTS LEFT!")
time.sleep(1)
print("...")
time.sleep(1)
print("...")
time.sleep(1)
print("...")
time.sleep(1)
#(my_health + my_defense) - jack_damage = my_health
my_health = (my_health + my_defense) - jack_damage
print("CHIPHEAD HAVE INFLICTED " + str(jack_damage) + " TO " + deskemon)
print(deskemon + " HAS " + str(jack_health) + " HITPOINTS LEFT!")
jack_battle_loop = True
elif jack_health <= 0:
jack_battle_loop = False
elif my_health <= 0:
jack_battle_loop = False
elif choise == "":
jack_battle_loop = True
但是,相反,它輸出這樣的:
TIMOHA HAVE INFLICTED 23 TO CHIPHEAD
CHIPHEAD HAS -24 HITPOINTS LEFT!
(它的 「選擇」,順便說一句) –