vendredi 29 septembre 2017

Mini boss fight game

I wrote this code which subtracts a random number from (1, 20) from a variable newhealth. But it only does this once, how can I use the new health and run it though the program again till newhealth is equal to 0?

import random

i = random.randrange(1,20)

a = input("do you want to damage the boss (y/n): ")

bosshealth = 100
newhealth = bosshealth - i


if (a == "y"):
    print("You deal {} damage, the new health is {}".format(i, newhealth))
elif (a == "n"):
    print("You do nothing..")
else:
    print("cant you ready?")

Aucun commentaire:

Enregistrer un commentaire