Skip to content

Instantly share code, notes, and snippets.

@Steve-V
Created March 2, 2012 04:21
Show Gist options
  • Save Steve-V/1955602 to your computer and use it in GitHub Desktop.
Save Steve-V/1955602 to your computer and use it in GitHub Desktop.
chest
import random
#this game is a test your luck game.
#it will continue until the player dies or stops opening chests.
#every chest has a one in five chance of containing a grue because i love Zork
chest = ('gold' , 'gold' , 'gold' , 'grue' , 'gold')
print """
THE LUCKY CHEST GAME!
"""
inv=["sword","shield","armor"]
print "you are an adventurer who must decide whether he continues"
print "to open chests or stop while he is ahead"
raw_input("press enter to continue")
#this section establishes the parameters for continuing the game
continueg = 'y'
print "Your hero currently has: "
print inv
while continueg == 'y':
print "your hero finds himself in a forest clearing."
print "\nThere is a chest in the center"
opchest = raw_input("\nWill you risk opening the chest? \nIt may contain treasures, or it will contain death (y/n): ")
if opchest == 'y':
inchest=random.choice(chest)
if inchest == 'grue':
print "The chest contained a grue and you are devoured. \n\n Thank you for playing"
continueg = 'n'
else:
print "\n the chest contained gold which your hero pockets"
inv += inchest
print "his current inventory is:\n"
print inv
else:
print "Your hero, content with his current posessions, "
print "leaves the chest in its current location."
print "As he leaves, he is killed by a grue."
print "\nThank you for playing!"
continueg = 'n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment