Hi I am new to the forums, and somewhat new to python. I'm trying to make a Text Based Adventure game. I don't have an error, but a bug.
This is the code:
import descriptions
inventory = []
gold = 0
acts = {"north":"hi"}
def start(acts):
print(descriptions.start)
rm_a(acts)
def rm_a(acts):
print("FOYER")
print(descriptions.foyer)
acts={"north":print("You can't go that way."),
"east":rm_b(acts),
"south":print("You can't go that way."),
"west":print("You can't go that way."),
"take book":inventory.append(descriptions.book[0])}
prompt(acts)
def rm_b(acts):
print("DINING ROOM")
print(descriptions.dining)
acts={"north":print("You can't go that way."),
"east":rm_c(acts),
"south":rm_e(acts),
"west":rm_a(acts),
"take sandwich":inventory.append(descriptions.sandwich[0])}
prompt(acts)
def rm_c(acts):
print("KITCHEN")
print(descriptions.kitchen)
acts={"north":print("You can't go that way."),
"east":print("You can't go that way."),
"south":print("You can't go that way."),
"west":rm_b(acts),
"take sandwich":inventory.append(descriptions.sandwich[0])}
prompt(acts)
def rm_d(acts):
print("YOUR ROOM")
print(descriptions.yourRoom)
acts={"north":print("You can't go that way."),
"east":rm_e(acts),
"south":print("You can't go that way."),
"west":print("You can't go that way."),
"take sandwich":inventory.append(descriptions.sandwich[0])}
prompt(acts)
def rm_e(acts):
print("NORTH HALL")
print(descriptions.northHall)
acts={"north":rm_b(acts),
"east":rm_f(acts),
"south":rm_h(acts),
"west":rm_d(acts),
"take sandwich":inventory.append(descriptions.sandwich[0])}
prompt(acts)
def rm_f(acts):
pass
def rm_g(acts):
pass
def rm_h(acts):
print("SOUTH HALL")
print(descriptions.northHall)
acts={"north":rm_e(acts),
"east":rm_i(acts),
"south":print("You can't go that way."),
"west":rm_g(acts),
"take sandwich":inventory.append(descriptions.sandwich[0])}
prompt(acts)
def rm_i(acts):
pass
def prompt(acts):
message = input(':').lower
if message == "north":
acts['north']
if message == "east":
acts['east']
if message == "south":
acts['south']
if message == "west":
acts['west']
start(acts)
This produces a bug where the program goes back and forth between rm_b() and rm_c(). I have identified where the bug is, right here:
acts={"north":print("You can't go that way."),
"east":print("You can't go that way."),
"south":print("You can't go that way."),
"west":rm_b(acts),
"take sandwich":inventory.append(descriptions.sandwich[0])}
I have that part so that I don't have to make a prompt for each one, I can just define actions in acts and pass it to the prompt. The problem is, the function aren't being assigned to a word, they're executing right then.
I don't know what to do to fix this. Can someone please help?