I've been working on making a combat test for a RPG game. For whatever reason I am getting a class has no attribute error.
Any ideas how to fix this?
class Enemy: def __init__(self, name, H, STR): self.name = name self.H = H self.STR = STR def is_alive(self): return self.H > 0 enemyturn = ["1", "2"] class Goblin(Enemy): def __init__(self, name, H, STR): name = "Goblin" H = 50 STR = 5 These classes are used in the code below:
if command == "1": Goblin.H -= Player.STR print("You strike the Goblin for {0} damage.".format(Player.STR)) random.choice(enemyturn) if random.choice == "1": Player.H -= Goblin.STR print("The Goblin strikes you for {0} damage.".format(Player.STR)) if random.choice == "2": pass Combat()
Goblin.H -= Player.STR