Skip to content

Instantly share code, notes, and snippets.

@derekforeman
Last active June 15, 2018 13:40
Show Gist options
  • Save derekforeman/67a34e8bd96e65bba41ad409e88ce335 to your computer and use it in GitHub Desktop.
Save derekforeman/67a34e8bd96e65bba41ad409e88ce335 to your computer and use it in GitHub Desktop.
Refactor Treasurenite
def welcome():
print("Welcome to Treasurenite")
print("You come to a cave looking for treasure and find a split.\n ")
prYellow("Which way do you go?")
decision1()
def decision1():
d1 = promptPlayer("Do you want to : A) go left. B)go right [A/B]: ")
if d1 == "A":
playerDies("You fall off a cliff. "
"With your last breath you see your best friend stealing your girlfriend and your treasure!")
if d1 == "B":
decision2()
def decision2():
prYellow("You enter a room with two doors.")
d1 = promptPlayer("Do you want to : A) go left. B)go right [A/B]: ")
if d1 == "A":
playerDies("You died not sure how but you did.")
if d1 == "B":
decision3()
def decision3():
prYellow("You walk into a dark room")
d1 = promptPlayer("Do you want to : A) sing your favorite song. B)light a match [A/B]: ")
if d1 == "A":
decision4()
if d1 == "B":
playerDies("You lit yourself on fire!! Didn't your parants tell you to not play with fire!")
def decision4():
prYellow("Your singing unlocked a hiddin door.")
prYellow("You find a spear and an axe.")
d1 = promptPlayer("Do you want to : A) take the axe. B)take the spear [A/B]: ")
if d1 == "A":
playerDies("You trip over the spear and fall on your axe.")
if d1 == "B":
decision5()
def decision5():
prYellow("Indiana Jones is chasing you with a knife!")
d1 = promptPlayer("Do you want to : A) stab him with the spear. B)try to out run him [A/B]: ")
if d1 == "B":
playerDies("He stabs you and takes the treasure.")
if d1 == "A":
decision6()
def decision6():
prYellow('you stab him and get away')
prYellow("you find the door to the treasure ")
d1 = promptPlayer("Do you want to : A) charge it. B)find a way around [A/B]: ")
if d1 == "B":
playerDies("You bounce off the door and fall on your spear.")
if d1 == "A":
decision7()
def decision7():
prYellow("You find a club")
d1 = promptPlayer("Do you want to : A) keep your spear. B)trade your spear for it [A/B]: ")
if d1 == "A":
playerDies("You run into a wall and die...weakling.")
if d1 == "B":
decision8()
def decision8():
prYellow("A mummy starts to chase you!")
d1 = promptPlayer("Do you want to : A) hit it with your club. B)out run it [A/B]: ")
if d1 == "A":
playerDies("Mummys are already dead... it ate you.")
if d1 == "B":
decision9()
def decision9():
prYellow("you find the treasure")
d1 = promptPlayer("Do you want to : A) just grab it. B)find something to put in its place [A/B]: ")
if d1 == "B":
playerDies("You died of old age trying to find something.")
if d1 == "A":
decision10()
def decision10():
prYellow('I guess there was no sensor. :(')
prYellow("You have the treasure")
d1 = promptPlayer("Do you want to : A) run out. B)go slowly [A/B]: ")
if d1 == "B":
playerDies("You never found your way out.")
if d1 == "A":
prGreen('You made your way out')
prGreen('You win!!!')
exit(0)
def promptPlayer(prompt):
userInput = input(prompt).upper()
return userInput
def playerDies(message):
prRed(message)
prRed("Game over")
exit(0)
def prRed(message):
print("\033[91m {}\033[00m".format(message))
def prGreen(message):
print("\033[92m {}\033[00m".format(message))
def prYellow(message):
print("\033[93m {}\033[00m".format(message))
def prLightPurple(message):
print("\033[94m {}\033[00m".format(message))
def prPurple(message):
print("\033[95m {}\033[00m".format(message))
def prCyan(message):
print("\033[96m {}\033[00m".format(message))
def prLightGray(message):
print("\033[97m {}\033[00m".format(message))
def prBlack(message):
print("\033[98m {}\033[00m".format(message))
if __name__ == "__main__":
welcome()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment