I'm new to programming, became interested in learning a while ago and only got to it recently. I'm working on a very simple text-based adventure game using Python, and would like some tips on simplifying my code. Any other tips are also welcome. Please don't criticize the storyline though, since this is not the point of this post.
def prompt():
x = raw_input("What should you do? ")
return x
def cpuprompt1():
x = raw_input("Enter a website or [exit].")
return x
def cpuprompt2():
x = raw_input("NAME/PASSWORD please. Type [exit] to exit.")
return x
def trailerpk1():
print "You're in the trailer park."
print "You have your [door] close to you and an unknown [stoner] standing next to a car."
command3 = prompt()
if command3 == "stoner":
print "[STONER]: Hey! Want to take a hit?"
print "[YOU]: Would love to!"
print "You take a hit. Some dank shit."
print "You start seeing things... some weird things..."
print "www.plan7286.org"
trailerpk2()
command5 = prompt()
if command5 == "door":
home1()
elif command3 == "door":
home()
def trailerpk2():
print "What was that?!"
print "You have your [door] close to you."
def trailerpk3():
print "You're in the trailer park. Nothing too interesting here."
print "Your [door] is right next to you. You should probably go home."
def trailerpk4():
print "You're in the trailer park. I should probably take one more hit with that [stoner] over there."
command2 = prompt()
if command2 == "stoner":
stoner1()
def trailerpk5():
print "The stoner is gone. You should probably head to that [lake]!"
command2 = prompt()
if command2 == "lake":
lake1()
def trailerpk6():
print "You're at the trailer park. The stoner is gone."
print "You can either go to the [lake] or [home]"
command2 = prompt()
if command2 == "lake":
lake2()
elif command2 == "home":
home3()
def trailerpk7():
print "You're at the trailer park. You can either go to the [lake] or [home]"
command2 = prompt()
if command2 == "lake":
lake3()
elif command2 == "home":
home4()
def lake1():
print "You're at the lake. Beautiful. That [cottage] really is there!"
command2 = prompt()
if command2 == "cottage":
cottage1()
def lake2():
print "You're at the lake. It's so beautiful! You can either go to the [trailer park] or [downtown]"
command2 = prompt()
if command2 == "trailer park":
trailerpk6()
elif command2 == "downtown":
downtown1()
def lake3():
print "You're at the lake. It's so beautiful! You can either go to the [trailer park], [downtown], or to the [cottage]"
command2 = prompt()
if command2 == "trailer park":
trailerpk7()
elif command2 == "downtown":
downtown2()
elif command2 == "cottage":
cottage2()
def cottage1():
print "This place looks creepy."
print "You go inside. There is a [desk] and a [trash bin] nearby."
command2 = prompt()
if command2 == "desk":
print "A regular desk. There is a ripped piece of paper that reads 'go7286'"
print "Go check out that [trash bin]!"
command4 = prompt()
if command4 == "trash bin":
print "There is a ripped piece of paper that reads 'indi'"
print "Weird... Well, better [leave] this place now."
command7 = prompt()
if command7 == "leave":
lake2()
elif command2 == "trash bin":
print "There is a ripped piece of paper that reads 'indi'"
print "Go check out that [desk]!"
command6 = prompt()
if command6 == "desk":
print "A regular desk. There is a ripped piece of paper that reads 'go7286'"
print "Weird... Well, better [leave] this place now."
command8 = prompt()
if command8 == "leave":
lake2()
def cottage2():
print "You take a peek through the door..."
print "That Todd Henley guy is here! He lives here!"
lake3()
def downtown1():
print "You're downtown. There is a [bar] and a [shop]. You can also go back to the [lake]"
command2 = prompt()
if command2 == "bar":
bar1()
elif command2 == "shop":
shop1()
elif command2 == "lake":
lake2()
def downtown2():
print "You're downtown. There is a [bar] and a [shop]. You can also go back to the [lake]"
command2 = prompt()
if command2 == "bar":
bar2()
elif command2 == "shop":
shop2()
elif command2 == "lake":
lake3()
def bar1():
print "You walk inside the bar. There is a lonely [man] sitting in the counter. You can also [leave]"
command2 = prompt()
if command2 == "man":
print "[MAN]: Hey, I love your shirt! Indigo is definitely my favorite color."
print "[YOU]: Oh, thanks... I'm Hautch, what's your name?"
print "[MAN]: Todd Henley. Nice to meet you!"
print "[YOU]: So, what do you work with?"
print "[MAN]: I can't talk about that."
print "[YOU]: OK... See ya!"
downtown2()
elif command2 == "leave":
downtown1()
def bar2():
print "You walk inside the bar. That Todd Henley dude isn't here anymore..."
print "Guess he really didn't like my question."
downtown2()
def shop1():
print "OUT OF ORDER"
downtown1()
def shop2():
print "OUT OF ORDER"
downtown2()
def stoner1():
print "[STONER]: Hey dude! want another hit? Here ya go!"
print "You take another hit."
print "You start to see some things... there is a cottage."
print "It doesn't look familiar, but it sits right next to a lake nearby."
print "[STONER]: Good shit, huh? I have to go, it was nice meeting you!"
trailerpk5()
def computer():
print "Your computer. Many hours spent here."
computercmd1 = cpuprompt1()
if computercmd1 == "www.plan7286.org":
print "Welcome to the official Plan 7286 website."
computercmd2 = cpuprompt2()
if computercmd2 == "Todd Henley/indigo7286":
print "Welcome, Todd."
print "36.444890, -116.688752"
elif computercmd2 == "exit":
home()
elif computercmd1 == "exit":
home()
def computer1():
print "Your computer. Many hours spent here."
computercmd1 = cpuprompt1()
if computercmd1 == "www.plan7286.org":
print "Welcome to the official Plan 7286 website."
computercmd2 = cpuprompt2()
if computercmd2 == "Todd Henley/indigo7286":
print "Welcome, Todd."
print "36.444890, -116.688752"
elif computercmd2 == "exit":
home2()
elif computercmd1 == "exit":
home1()
def computer2():
print "Your computer. Many hours spent here."
computercmd1 = cpuprompt1()
if computercmd1 == "www.plan7286.org":
print "Welcome to the official Plan 7286 website."
computercmd2 = cpuprompt2()
if computercmd2 == "Todd Henley/indigo7286":
print "Welcome, Todd."
print "36.444890, -116.688752"
elif computercmd2 == "exit":
home3()
elif computercmd1 == "exit":
home3()
def computer3():
print "Your computer. Many hours spent here."
computercmd1 = cpuprompt1()
if computercmd1 == "www.plan7286.org":
print "Welcome to the official Plan 7286 website."
computercmd2 = cpuprompt2()
if computercmd2 == "Todd Henley/indigo7286":
print "Welcome, Todd."
print "36.444890, -116.688752"
print "Coordinates... I should probably [go] to this place."
command2 = prompt()
if command2 == "go":
desert1()
elif computercmd2 == "exit":
home4()
elif computercmd1 == "exit":
home4()
def desert1():
print "It was a long trip, but you made it here."
print "There is a [tent] in the middle of the desert..."
command2 = prompt()
if command2 == "tent":
tent1()
def tent1():
print "A tiny tent... there is no one inside, but there is some high tech equipment."
print "There is a [button]."
command2 = prompt()
if command2 == "button":
button1()
def button1():
print "You press the button."
print "Our universe is back to normal!"
print "Thanks for pressing that button, stranger. Our universe can now go back to normal life instead of living as a simulation."
def home():
print "You're home."
print "You have your [door] to the left, and your [computer] to your right."
command6 = prompt()
if command6 == "computer":
computer()
elif command6 == "door":
trailerpk1()
def home1():
print "You're home."
print "You have your [door] to the left, and your [computer] to your right."
command6 = prompt()
if command6 == "computer":
computer1()
elif command6 == "door":
trailerpk3()
command6 = prompt()
if command6 == "door":
home1()
def home2():
print "You're home."
print "You have your [door] to the left."
command2 = prompt()
if command2 == "door":
trailerpk4()
def home3():
print "You're back home. You have your [door] to the left and your [computer] to the right."
command2 = prompt()
if command2 == "door":
trailerpk6()
elif command2 == "computer":
computer2()
def home4():
print "You're back home. You have your [door] to the left and your [computer] to the right."
command2 = prompt()
if command2 == "door":
trailerpk7()
elif command2 == "computer":
computer3()
print "You're in your small trailer park home"
print "It's small, but you've grown to like it."
print "You have your [door] to the left, and your [computer] to your right."
command1 = prompt()
if command1 == "door":
trailerpk1()
elif command1 == "computer":
computer()