So I'm programming a rpg type game on python,
and when I type “heal” in the input, it doesn't heal the main character.
WHY???
Code:
import random
i = 0
health = random.randint(80, 120)
damage = random.randint(10, 50)
bhealth = random.randint(100, 200)
bdamage = random.randint(10, 40)
def stats(health, damage):
print(health)
print(damage)
print("You're stats are:")
print('health:', health)
print('damage:', damage)
print('')
print('Opponent stats:')
print('Health:', bhealth)
print('Damage', bdamage)
while i < 10:
i += 1
print('FIGHT/HEAL')
ac = input('> ')
if ac.upper == 'HEAL':
hp_healed = random.randint(75, 80)
health = health + hp_healed
print("You've been healed",hp_healed,"health!")
print('You have',health,'now!')
if health > 250:
health = 250
if ac.upper() == 'FIGHT':
bhealth = bhealth - damage
print('Opponent has',bhealth,'hp left!')
print(' ')
if bhealth < 0:
print('You have eliminated your opponent!')
health = health - bdamage
if health < 0:
print('You have fallen from your opponent!')
break
print("You've been hit by a -"+str(bdamage),'health hit!')
print("You have",health,'health left!')
print(' ')
Edit:
I've figured it out! I asked ChatGPT and they told me that the .upper didn't have the brackets()! I feel so stupid lol