I have a main program that uses a function from a class from another file, in the while loop, when the function is called with the correct parameters it just doesn't return anything print anything or do anything it supposed to do, however it doesn't raise any errors and it goes back to the start of the loop.
Here is a snippet of the main loop in question:
....
elif command in ["talk","fight","hug"]:
if inhabitant is not None:
if inhabitant.event_handler(command,current_room,inventory) is False:
break
else:
continue
else:
print("There is nobody in the room")
cl()
....
and the function in question:
def event_handler(self,command,room,inv):
if command is "talk":
self.talk()
input()
print("\n"*25)
elif command is "hug":
print("You probably don't want to do that")
input()
print("\n"*25)
elif command is "fight":
itemSel = input("What item do you want to fight with?\n>")
if itemSel in inv:
if self.fight(itemSel):
room.character = None
if Character.number_of_enemies == 0:
print("Congrats! You defeated all the enemies and won the game!")
input()
return False
input()
print("\n"*25)
else:
print("You died")
input()
return False
else:
print("You don't have this item")
input()
print("\n"*25)
where all of the variables are valid and have already been assigned values at some point in the main loop, and the functions .fight() and .talk() are also in the same class as .event_handler()
.event_handler() is a method of the object stored as inhabitant
What could be the reason behind this not working? I don't really get it so if anyone could help I'd greatly appreciate it.