I am making a text adventure game:
#modules
import time
import random
#setup
class hero:
def __init__(self, name, health, attack, defence):
self.name = Hname
self.health = Hhealth
self.attack = Hattack
self.defence = Hdefence
def start():
#name
print("welcome, hero." , end='')
time.sleep(0.3)
Hname = input(" And what shall I call you? ")
print("What an amazing name", Hname+"!")
time.sleep(1)
print("Lets continue the setup...")
time.sleep(1)
#health
Hhealth = 100
#attack and defence
x = int(input("in a fight, are you more likly to run at the enemy(1), or think up a plan first(2)"))
if x == 1:
Hattack = 100
Hdefence = 75
elif x == 2:
Hattack = 75
Hdefence = 100
else:
print("Invalid selection: please type either 1 OR 2!")
x = int(input("in a fight, are you more likly to run through the enemy(1), or think up a plan first(2)"))
Hstats = [Hname, Hhealth, Hattack, Hdefence]
start()
print(start.Hstats)
At the bottom I am trying to print the stats. I tried making a list and puttion all the atributes of the class hero but another thing is how would I get a list from a function?