""" Text-Based Game as of yet Unnamed By Adam Hacker """ #Starting Inventory listinv = ['watch'] #All Characters and Whether or they have been encountered(1 = unencountered, 0 = encountered) chardict = {'Bear' : 1, 'Bandit' : 1, 'Andrew Fleck' : 1, 'Old Man' : 1 }; #Day/Night Cycle(Day = 1440 Minutes) minutestozero = 300 #Functions def inventory() : #Player Inventory print('You have : ') for i in range(0 , len(listinv)) : print ' ' + str(listinv[i]) def wait() : #Wait ten minutes of in-game time global minutestozero minutestozero = minutestozero - 10 print('You wait for ten minutes') if minutestozero <= 0 : minutestozero = 1440 + minutestozero def watch() : #Check the time, and get an update on teh position of the sun global minutestozero if minutestozero % 60 != 0 : print('The time is ' + str((1440 - minutestozero)/60) + ':' + str((1440 - minutestozero)%60)) elif minutestozero % 60 == 0 : print('The time is ' + str((1440 - minutestozero)/60) + ':' + str((1440 - minutestozero)%60) + '0') if minutestozero <= 300 and minutestozero > 240: print('The sun is setting.') elif minutestozero <= 240 and minutestozero > 180: print('The sun has just set. It is getting darker.') elif minutestozero <= 180 and minutestozero > 0: print('It is very dark out.') elif minutestozero <= 1440 and minutestozero > 1080: print('It is dark out.') elif minutestozero <= 1080 and minutestozero > 1020: print('The sun is rising.') elif minutestozero <= 1020 and minutestozero > 300: print('The sun is high in the sky.') def commands(x) : #Allows these to be used at any point if x.lower() == 'inventory' : inventory() elif x.lower() == 'wait' : wait() elif x.lower() == 'watch' : watch() def dead() : print('You are dead') quit() #Pre-Game Info name = raw_input('What is your name? : ') #Input Name name = name.title() #Capitalization of a Proper Noun age = raw_input('How old are you, ' + name + '? : ') while age.isdigit() == False : age = raw_input('That is not a number, try again. : ') #Check for a number print('At any point in the game, you can check your inventory by typing "inventory", ') print('check the time by typing "watch", ') print('and wait for ten minutes by typing "wait".') print('') print('') #Choice 1 print('You wake up in a forest, the sun appears to be setting') print('There is a path in front of you, going to your left and your right') c1 = raw_input('("left" or "right") : ') commands(c1) while c1.lower() != 'left' and c1.lower() != 'right' : c1 = raw_input('("left" or "right") : ') commands(c1) #Choice 2 if c1.lower() == 'left' : print('You start down the path to the left. After a while of walking you see a bear. Unfortunately, it also sees you.') c2 = raw_input('(run or stand still) : ') commands(c2) while chardict['Bear'] == 1 : while c2.lower() != 'run' and c2.lower() != 'stand still' and c2.lower != ‘wait’ : c2 = raw_input('("run" or "stand still") : ') commands(c2) if c2.lower == 'stand still' or c2.lower() == 'wait' : print('You remain still for a while, and the bear loses interest and wanders off') if c2.lower() == 'stand still' : wait() chardict['Bear'] = 0 elif c2.lower == 'run' : print('The bear takes off after you, gaining on you far too quickly') c2 = raw_input('("climb a tree" or "run")') commands(c2) while c2.lower != 'climb a tree' and c2.lower != 'run' : c2 = raw_input('("climb a tree" or "run")') commands(c2) if c2.lower() == 'climb a tree' : print('You begin climbing a nearby tree, but unfortunately bears are much better climbers than people') if age >= 14 : print('The bear catches and eviscerates you. Your lifeless body tumbles out of the tree.') elif age < 14 : print('The bear kills you, and you fall out of the tree.') chardict['Bear'] = 0 dead() if c2.lower() == 'run' : if age >= 14 : print('The bear catches and eviscerates you. You fall to the ground in a puddle of your own blood.') elif age < 14 : print('The bear kills you, and you fall to the ground.') chardict['Bear'] = 0 dead() elif c1.lower() == 'right' : print('You head off to the right. There is a solid looking rosk on the ground. The path turns left ahead.') c2 = raw_input('("continue" or "pick up rock") : ') commands(c2) while c2.lower() != 'continure' and c2.lower() != 'pick up rock' : c2 = raw_input('("continue" or "pick up rock") : ') commands(c2) wait()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question