So I have been trying to set up my ex36 game. One idea I had as an exercise was to use the modules to import different “toolkits” that could be unpacked during the game and based on which you pick at the beginning would determine the outcome of some of the rooms. I have been playing around and finally got the open_toolkit function to work. What I am now running into is that the script opens the same args variable which results in the same tool kit being opened. What I tried to set up was an if-statement that depending on what bag the person said they brought that would change the selection of argv variable that was used as the item running through the open_toolkit function (see snake_room()). I have played around with a few options, changing the defining of the variables, changing the variable names, but how can I get it to call the other toolkit. Each toolkit has different items listed in it.
from sys import argv
script, toolkit_1, toolkit_2, finish = argv
def open_toolkit(toolbag):
stuff = open(toolbag).read()
supplies = stuff.split(', ')
print(f"Looks like you have a {supplies[0]} and a {supplies[1]}.")
def snake_room():
print("""After opening up the door to the first room you realize it
is full of snakes.
The door is on the other side of the room to get out. Which supply bag did
you grab? \nBag 1 or Bag 2?""")
tool = input("> ")
if "Bag 1" or "1" in tool:
toolbag = toolkit_1
elif "Bag 2" or "2" in tool:
toolbag = toolkit_2
else:
print("You did not pick correctly. Let's try again")
snake_room()
open_toolkit(toolbag)
print("""What do you think you can use from that supply bag to get past
the snakes?""")
kill_snakes = input("> ")
if "shovel" in kill_snakes:
print("Great job! You shovelled all the snakes outta here!")
room_b()
elif "childrens book" in kill_snakes:
print("You start to read the chilrens book.")
print("Some of the snakes fall asleep and you are able to get by.")
print("""You are able to get to the closest door in the room.
Hopefully this is the right way to get through the castle......""")
room_a()
elif "flashlight" in kill_snakes or "spider hammer" in kill_snakes:
print("Too bad for you, this supply kit did not help you here.")
print("You quickly run out of the room and try a different way out.")
start()
else:
dead("Your inability cripples you and the snakes attack!")