Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed Why is my HEAL not working in my python game???

+7 votes
asked Apr 1, 2023 by ANewCoder (290 points)
closed Apr 24, 2023 by Admin

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.



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("You're stats are:")

print('health:', health)
print('damage:', damage)

print('Opponent stats:')
print('Health:', bhealth)
print('Damage', bdamage)

while i < 10:
    i += 1
    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!')
    print("You've been hit by a -"+str(bdamage),'health hit!')
    print("You have",health,'health left!')
    print(' ')
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
closed with the note: solved

2 Answers

0 votes
answered Apr 1, 2023 by ANewCoder (290 points)
Do not answer, it's useless now.
0 votes
answered Apr 3, 2023 by Eidnoxon (5,270 points)
I'm happy you've figured that out! Good luck on your coding journey! :D
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.