I have created a text based adventure in Python using functions and random integers. My second random integer will not work. When I run the code through the first random integer, it works fine. But the second random integer does not work, even though it is the same code as the first random integer, just different variables. I'm not sure what the problem is, and i'm looking for help.
def pathChoice():
path=""
while path != "1" and path != "2":
path=input("What will Levi do? (1 or 2): ")
return pathChoice
def checkPath(pathChoice):
print(".....................................................................")
print("Levi sneaks around the side of the castle, avoiding suspecious guards.")
time.sleep(3)
print("Levi notices a small window that he could climb into.")
time.sleep(2)
print("He must scale the wet stone wall without falling.")
time.sleep(2)
correctMovement = random.randint(1,2)
if pathChoice == str(correctMovement):
print("...............................................................")
print("He scales the wall carefully, avoiding the loose rubble and climbs into the castle")
time.sleep(2)
print("Levi sneaks behind some barrels and boxes, making his way past some guards.")
time.sleep(2)
else:
print(".................................................................")
print("The wet stone wall is too slipery, and Levi falls half way up.")
time.sleep(2)
print("The loud thud of his corpse alerts the nearby guards.")
time.sleep(2)
print("Levi is apprehended by the guards.")
def castleScene():
print("....................................................................")
print("Levi is dragged to a jail cell by two guards after trying to sneak into the castle.")
time.sleep(2)
print("He feels tired and discouraged as the guards close and lock the door.")
def secondPathChoice():
pat=""
while pat !="3" and pat !="4":
path=input("What does Levi do? (3 or 4)")
return secondPathChoice
def InsideCastlePath(secondPathChoice):
print("...................................................................")
print("Levi is put into a jail cell.")
time.sleep(2)
print("He notices some loose wall shards laying on the ground.")
time.sleep(2)
print("Levi picks up the shards and wonders if he can sharpen one of them to make a lockpick.")
time.sleep(2)
print("Through the night he works tirelessly to make a lockpick, and by morning he successfully makes one.")
time.sleep(2)
print("Levi must escape the jail cell when the guards are not paying attention.")
successfulLockpick = random.randint(3,4)
if secondPathChoice == str(successfulLockpick):
print(".................................................................")
print("Levi successfully lockpicks the jail cell door and makes his way to the kings treasure room.")
time.sleep(2)
print("")
else:
print("..................................................................")
print("The lockpick breaks off in the jail cell door and Levi never escapes.")
Restart="yes"
while Restart == "yes" or Restart =="y":
intro()
choice = pathChoice()
checkPath(choice)
castleScene()
choice2 = secondPathChoice()
InsideCastlePath(choice2)
Restart=input("Would you like to Restart Levi's Adventure? (yes or y to `restart): ")