In this block of code I'm using a class called class Cthulhu_room(Scene). My idea is to use a dictionary to call the second function attack(self) but I don't know how to go about this. I would like your help to this, I also get the following errors
ERRORS*
Traceback (most recent call last): File "mygame.py", line 134, in class Cthulhu_room(Scene): File "mygame.py", line 136, in Cthulhu_room 'attack': attack() NameError: name 'attack' is not defined
class Cthulhu_room(Scene):
floor = {
'attack': attack()
}
def enter(self):
print(dedent("""Here you see the great evil Cthulhu
He, it, whatever stares at you and you go insane.
Do you flee for your life or eat your head"""))
choice = input("> ")
# this is the same as if choice == "flee"
if "flee" in choice:
return "laser_weapon_armory"
elif "head" in choice:
return "death"
elif "danger" in choice:
return Cthulhu_room.floor.get('attack')
else:
print("back to the beginning")
return 'central_corridor'
def attack(self):
print("Kill this an intruder or die")
choice = input("> ")
if "kill" in choice:
print("Welcome to the next level")
return "laser_weapon_armory"
else:
return 'death'