Reputation: 23
I made this game and I want for the user to have to get a saddle before they are able to leave with the horse right now this always prints("Lose") even when I have the saddle and enter yes for the raw_input.
##Text adventure##
import time, datetime, sys, random
keepGoing = True
saddle = False
def typer(what_you_want_to_type):
for letter in what_you_want_to_type:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(random.random() * 0.1)
typer("""You are at home eating a taco when suddenly there is a
great flash of light in the sky.""")
print("")
##Places and there descriptions go here##
home = ("Home", "You are at home.")
farm = ("Farm", "You are on the farm herding sheep while eating a taco")
field = ("Field", "You are in a corn field and you dropped your taco")
ranch = ("Ranch", "You are on the ranch")
##Dictionary of were you are and were you can go based on were you are##
transitions = {
home:(farm, field),
farm:(home, ranch),
field:(home, ranch),
ranch:(farm, field)
}
##Current location##
location = home
##Main game loop##
while keepGoing:
print("")
print location[1]
time.sleep(3)
print("\nYou can go to these places:")
##Adds a number to each place##
for (i, t) in enumerate(transitions[location]):
print i + 1,t[0]
##Obviously where you choose to go##
choice = int(raw_input("\nGo to "))
location = transitions[location][choice - 1]
if location == field:
take = raw_input("Take a horse?")
if take == "yes" and saddle == True:
print("win")
keepGoing == True
else:
print("Lose")
keepGoing = False
if location == ranch:
saddle == True
print("found a saddle.")
Upvotes: 0
Views: 177
Reputation: 996
You have a typo.
saddle == True
I guess you meant:
saddle = True
So saddle is actually never changed to True
Hope that helped :) Cheers, Alex
Upvotes: 2