~yacinechaouche/+junk/BZR

« back to all changes in this revision

Viewing changes to CODE/REDDIT/other_textadventure/game.py

  • Committer: yacinechaouche at yahoo
  • Date: 2015-01-14 22:23:03 UTC
  • Revision ID: yacinechaouche@yahoo.com-20150114222303-6gbtqqxii717vyka
Ajout de CODE et PROD. Il faudra ensuite ajouter ce qu'il y avait dan TMP

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
def prompt():
 
3
    print "What do you do?"
 
4
    
 
5
def dead(why):
 
6
    print why, "You are dead, nice work."
 
7
    exit()
 
8
    
 
9
def start():
 
10
    initialroom()
 
11
    
 
12
def enter():
 
13
    raw_input("Hit ENTER for next level.")
 
14
    
 
15
def initialroom():
 
16
    print "You wake up in a room with no doors."
 
17
    print "There are high windows dimly lighting the room, but they're way out of reach."
 
18
    print "Your ears hurt for some reason, so you won't be shouting. No CAPS or Shift letters."
 
19
    print "You should probably poke around a bit."
 
20
    shovelget = 0
 
21
    shovelcrack = 0
 
22
    roominfo = 0
 
23
    
 
24
    while True:
 
25
        prompt()
 
26
        input = raw_input("> ")
 
27
        if "look" in input or "bearings" in input or "poke" in input:
 
28
            print "You see the ceiling, the floor and four walls: one to the North, South, East, and West."
 
29
            roominfo = 1
 
30
        elif "north" in input and roominfo == 1:
 
31
            print "There is a small crack in the north wall. Daylight streams through."
 
32
        elif "south" in input and roominfo == 1:
 
33
            print "There's nothing there."
 
34
        elif "east" in input and shovelget == 0 and roominfo == 1:
 
35
            print "You see a shovel. You take it."
 
36
            shovelget = 1
 
37
        elif "east" in input and shovelget == 1 and roominfo == 1:
 
38
            print "There's nothing there. You've already taken the shovel."
 
39
        elif "west" in input  and roominfo == 1:
 
40
            print "There's nothing there."
 
41
        elif "dig" in input and shovelget == 1 and roominfo == 1:
 
42
            print "You begin digging into the soft dirt floor."
 
43
            enter()
 
44
            moleroom(0)
 
45
        elif "dig" in input and  shovelget == 0 and roominfo == 1:
 
46
            print "You try digging, but your hands soon grow tired."
 
47
        elif "crack" in input and shovelget == 0 and roominfo == 1:
 
48
            print "Your soft puny fingers do nothing to the crack in the wall."
 
49
        elif "crack" in input and shovelget ==1 and shovelcrack == 0 and roominfo == 1:
 
50
            print "You pry the shovel into the crack, hoping to widen it."
 
51
            print "Instead, your shovel begins to splinter under the strain. You better not do that again."
 
52
            shovelcrack = 1
 
53
        elif "crack" in input and shovelget ==1 and shovelcrack == 1 and roominfo == 1:
 
54
            print "You foolishly try again, and your shovel breaks into several pieces."
 
55
            dead("Your only tool rendered useless, you slowly starve to death in the room.")
 
56
        elif "floor" in input and roominfo == 1:
 
57
            print "The floor is made of dirt. It looks soft."
 
58
        elif "ceiling" in input and roominfo == 1:
 
59
            print "Man, that's high."
 
60
        else:
 
61
            print "You waste some time doing that. No help."
 
62
 
 
63
def moleroom(kills):
 
64
    kills = kills
 
65
    print "You continue digging down until you feel the dirt begin to give way underneath you."
 
66
    print "The ground collapses and you end up in an underground lair of some sort."
 
67
    print "It's dark, but you can see enough to make out dim shapes."
 
68
    
 
69
    molesalive = 10
 
70
    moleinfo = 0
 
71
    molesleep = 1
 
72
    
 
73
    while True:
 
74
        prompt()
 
75
        input = raw_input("> ")     
 
76
            
 
77
        if "look" in input or "poke" in input:
 
78
            print "You see numerous round shapes scattered around you."
 
79
        elif "shapes" in input and moleinfo == 0:
 
80
            print "Upon further investigation, you discover that the shapes are actually giant mole rats: 10 of them, at least."
 
81
            print "You realize you're in an enormous lair. There seems to be a tunnel that leads away to your left."
 
82
            print "They seem to be stirring slightly."
 
83
            print "You can leave, wake them, kill a few, destroy them all in a murderous rage, or get creative (you still have a shovel)."
 
84
            moleinfo = 1
 
85
        elif "shapes" in input and moleinfo == 1:
 
86
            print "The shapes are giant mole rats."
 
87
        elif "get" in input or "creative" in input and moleinfo == 1:
 
88
            print "You gotta walk the walk, you can't just talk the talk."
 
89
        elif "shovel" in input and moleinfo == 1:
 
90
            print "What do you want to do with it?"
 
91
        elif "dig" in input and moleinfo == 1:
 
92
            print "You try and put yourself as far away from this place as possible."
 
93
            print "Putting shovel to dirt like never done before, you continue your excavation down."
 
94
            print "You exit the lair."
 
95
            enter()
 
96
            mine(kills)
 
97
        elif ("run" in input or "leave" in input or "tunnel" in input) and moleinfo == 1 and molesalive > 0 and molesleep == 1:
 
98
            print "You carefully pick your path through the lair."
 
99
            print "Unfortunately your shovel wakes up one of the smaller ones you hadn't seen."
 
100
            print "Snarling angrily, the small mole rat confronts you."
 
101
            print "Do you kill it, or do you run?"
 
102
            input = raw_input("> ")
 
103
            if "kill" in input:
 
104
                print "You kill the mole rat with a quick smash to its head before it can wake the others."
 
105
                print "None of the other mole rats wake up, and with a sigh of relief, you exit the lair."
 
106
                kills += 1
 
107
                enter()
 
108
                forest(kills)
 
109
            elif "run" in input:
 
110
                print "You try and run. The smaller mole rat starts screaming, alerting the others to your intrusion."
 
111
                print "In the dark, you are at a severe disadvantage, slowly feeling your way through the tunnel."
 
112
                print "By now the entire lair is awake and, with the home turf advantage, quickly catch up to you."
 
113
                print "Two of the largest freaks of nature, more dog sized than rat, bring you to the ground."
 
114
                dead("You are eviscerated and consumed with agonizing inefficiency.")
 
115
            else:
 
116
                print "That doesn't help your situation."
 
117
        elif ("run" in input or "leave" in input or "tunnel" in input) and moleinfo ==1 and molesalive == 0:
 
118
            print "You walk towards the tunnel, stepping over the sad carcasses hewn apart in your rage."
 
119
            print "You are able to wipe the blood off your shovel, but you will never be able to wipe it off your soul."
 
120
            print "You exit the lair."
 
121
            enter()
 
122
            forest(kills)
 
123
        elif "kill" in input and moleinfo == 1 and molesalive > 0:
 
124
            print "You grip your shovel with tenacity. You find the biggest, meanest looking mole rat you can."
 
125
            print "With one deft stomp on your shovel, you cleanly separate the mole rat's head from the body."
 
126
            kills += 1
 
127
            molesalive = molesalive - 1
 
128
        elif ("destroy" in input or "kill" in input) and moleinfo == 1 and molesalive == 0:
 
129
            print "You've already killed them all."
 
130
        elif "destroy" in input and moleinfo == 1 and molesalive >= 2:
 
131
            print "You systematically destroy the rest of the mole rats. Males, females, adults, adolescents, infants."
 
132
            print "You murder them all."
 
133
            kills += molesalive
 
134
            molesalive = 0
 
135
        elif "wake" in input or "taunt" in input or "say" in input and moleinfo == 1 and molesleep == 1 and molesalive > 1:
 
136
            print "The moles wake up and are instantly in attack mode. They are angry, but do not move. Yet."
 
137
            molesleep = 0
 
138
        elif ("kill" in input or "destroy" in input) and moleinfo ==1 and molesleep == 0 and molesalive > 0:
 
139
            print "You bravely swing your shovel, but in the darkness, it is no good."
 
140
            print " More come from the shadows previously unseen. They easily dodge your attacks and surround you."
 
141
            dead("You are overcome by vicious mole rats.") 
 
142
        elif ("run" in input or "leave" in input or "tunnel" in input) and moleinfo == 1 and molesleep == 0 and molesalive > 0:
 
143
            print "You hear growls and snarls all around you, but, in a panic, you manage to find your way over to the edge of the lair."
 
144
            print "You slowly back away down the tunnel, constantly facing the underground monsters. They let you go."
 
145
            print "You exit the lair."
 
146
            enter()
 
147
            forest(kills)
 
148
        else:
 
149
            print "You waste some time doing that. No help."
 
150
 
 
151
def forest(kills):
 
152
 
 
153
    kills = kills
 
154
    rest = 0
 
155
    time = 0
 
156
       
 
157
    print "You stumble out into a forest grotto, blinded by the light."
 
158
    print "In your blindness, you trip over a root and crash into some sort of sticky, net-like material."
 
159
    print "You hear the sound of your shovel clattering out of reach."
 
160
    print "Your eyes adjust to the light, and you finally see what's got you caught."
 
161
    raw_input("Oh, god, WHAT...>")
 
162
    print "A king-size spider web, Shelob-style."
 
163
    raw_input("Jeebus...")
 
164
    print "Yep."
 
165
    
 
166
    while True:
 
167
                                
 
168
        if rest >= 2:
 
169
            print "You feel fully rested and have totally regained your strength."
 
170
            print "Now is your chance."
 
171
            
 
172
        if rest < 2:
 
173
            print "You're exhausted and weak, but you don't want to be around when your lovely host gets back."
 
174
            
 
175
        if time < 5:
 
176
            timelist = ['There\'s a bit of time left.', 'There\'s a bit of time left.', 'You should get a move on.', 'You should really get a move on.', 'Time\'s pretty much up.']
 
177
            print timelist[time]
 
178
        if time >= 5:
 
179
            print "You wasted too much time. Shelob has come back home, and she looks hungry."
 
180
            print "You regret every decision you've ever made."
 
181
            prompt()
 
182
            raw_input("> ")
 
183
            print "Irrelevant."
 
184
            dead("Shelob's bite injects baby spiders into your face as well as a poison that liquifies you into baby spider-food. Yum.")
 
185
     
 
186
        prompt()
 
187
        input = raw_input("> ")
 
188
        
 
189
        if ("run" in input or "escape" in input or "leave" in input or "struggle" in input) and rest < 2:
 
190
            print "You struggle in your trap with no results other than exhausting yourself further."
 
191
            print "That was not a good idea. Time is precious."
 
192
            rest = rest - 1
 
193
            time += 1
 
194
        elif ("run" in input or "escape" in input or "leave" in input or "struggle" in input) and rest == 2:
 
195
            print "Your resting has paid off. Your new found strength allows you to escape the web."
 
196
            print "With one eye ahead and one eye over your shoulder, you leave the grotto."
 
197
            enter()
 
198
            lake(kills)
 
199
        elif ("rest" in input or "wait" in input or "sleep" in input or "heal" in input) and rest < 2:
 
200
            print "You resolve to lie there for a bit longer. Over time, you feel a bit more rejuvenated."
 
201
            print "Time is precious."
 
202
            rest += 1
 
203
            time += 1
 
204
        elif ("rest" in input or "wait" in input or "sleep" in input or "heal" in input) and rest >= 2:
 
205
            print "You are already fully rested. This wasted time could cost you."
 
206
            time += 1
 
207
        else:
 
208
            print "That's not the thing to do here. You're wasting time."
 
209
            print "Time is precious."
 
210
            time += 1
 
211
        
 
212
def mine(kills):
 
213
    kills = kills
 
214
    
 
215
    print "Digging deeper into the earth, you eventually discover a large tunnel."
 
216
    print "An old mine. Abandoned by the looks of it."
 
217
    print "Down to your left, you hear nothing but silence. Up to your right, you hear soft muffled sounds."
 
218
       
 
219
    
 
220
    while True:
 
221
        prompt()
 
222
        input = raw_input("> ")
 
223
        
 
224
        if "left" in input:
 
225
            print "You head down to the left. The way your day has gone, silence is more promising than whatever was making those sounds."
 
226
            print "After traveling for some time, you begin to notice ambient light levels increasing." 
 
227
            print "You must be getting close to the entrance!"
 
228
            print "You come across a stone-carved bridge crossing a deep pool."
 
229
            raw_input("So...>")
 
230
            print "The bridge is just as old as the mine, and just as decrepit. A bit crumbles off into the water."
 
231
            print "The water is crystal clear, which means you should be able to see the bottom. You don't. It's unbelievably deep."
 
232
            print "You'll only have one chance to get across safely."
 
233
            
 
234
            prompt()
 
235
            input = raw_input("> ")
 
236
            
 
237
            if "bridge" in input or "stone" in input:
 
238
                print "You decide on the bridge. Step by step, you slowly make your way over the water. Deep down, you see what looks to be an eye blink."
 
239
                print "Good thing you didn't go that way."
 
240
                raw_input("No kidding...>")
 
241
                print "Just as you step off on the other side, the entire bridge crumbles into the water below."
 
242
                print "You exit the mine."
 
243
                enter()
 
244
                lake(kills)
 
245
            elif "water" in input or "pool" in input:
 
246
                print "You decide on the pool. If you were to fall off the bridge, you'd only be getting wet anyway."
 
247
                print "Better to avoid as many opportunities for injury as possible."
 
248
                raw_input("Sure...>")
 
249
                print "You slip in and begin moving to the other side. Something brushes your leg."
 
250
                print "You look down, and see nothing. Adrenaline spiking, you start thrashing to get to shore."
 
251
                print "An enormous tentacle grabs hold of you and drags you down."
 
252
                print "Struggling only hastens oxygen deprivation. In your last moments of lucidity, you stare into an eye the size of a house."
 
253
                dead("You are eaten by Cthulhu.")
 
254
            else:
 
255
                print "Not a good idea. Try again."
 
256
                
 
257
        elif "right" in input:
 
258
            print "You head up to the right. In a mine, up means out, right?"
 
259
            raw_input("Right...>")
 
260
            print "The muffled sounds are getting louder. You round the corner and discover their source."
 
261
            print "A pack of bears are slowly waking up. They seem to have just emerged from hibernation."
 
262
            print "'But bears don't hibernate in packs' you say. You're wrong. They do in 'The Adventure.'"
 
263
            print "They notice you, and boy, do they look hungry."
 
264
            
 
265
            time = 0
 
266
            
 
267
            while True:
 
268
                print "Time is short."
 
269
                prompt()
 
270
                input = raw_input("> ")
 
271
                
 
272
                if time == 2:
 
273
                    dead("The bears slaughter you.")
 
274
                
 
275
                if "run" in input or "escape" in input or "leave" in input:
 
276
                    print "You book it. Your skills at shovel-murder are utterly irrelevant here."
 
277
                    print "The bears try and pursue, but having not eaten in months and suffering the worst recorded case of the Mondays ever, they fall behind."
 
278
                    print "You exit the mine."
 
279
                    enter()
 
280
                    lake(kills)
 
281
                elif "fight" in input or "kill" in input or "shovel" in input:
 
282
                    print "Bears be damned, you just slaughtered a mountain full of mole rats with a shovel."
 
283
                    print "You decide to take them on. With a shovel."
 
284
                    dead("Hahahaa.")
 
285
                else:
 
286
                    print "You're wasting time. The bears get closer."
 
287
                    time += 1
 
288
        else:
 
289
            print "You literally have only two directions to go. Pick one."
 
290
 
 
291
def lake(kills):
 
292
    kills = kills
 
293
    
 
294
    print "You emerge onto the shore of a beautiful lake. You see a villa a bit down the way."
 
295
    print "Upon arriving, you see tables laden with delicious food and drink."
 
296
    print "In one room, there is nothing but gold."
 
297
    print "You have trouble fathoming this ludicrous turn of events."
 
298
    prompt()
 
299
    raw_input("> ")
 
300
    print "Before you can do anything though, you are approached by an old man."
 
301
    print "He says:"
 
302
    print '''You have made it far and overcome a great many obstacles.
 
303
    There is one last challenge you must conquer, and then
 
304
    all you see before you will be yours. To enter,
 
305
    you must answer me these questions fiv- I mean three.'''
 
306
    raw_input("Okay...>")
 
307
    
 
308
    wrong = 0
 
309
    q = 1
 
310
    
 
311
    while True:
 
312
        if wrong == 1:
 
313
            print "I was way more lenient than with the last group, and you STILL failed."
 
314
            dead('''The old man snaps his fingers and you are rocketed off into the air.
 
315
                    As you hurtle back towards the ground, you scream "Auuuuuugh!"
 
316
                    Famous last words.''')
 
317
                    
 
318
        if q == 1:
 
319
            print "1. WHAT- is your favorite color?"
 
320
            input = raw_input("? ")
 
321
            if "blue" in input:
 
322
                print "Correct!"
 
323
                q = 2
 
324
            else:
 
325
                print "Wrong... It's ok though. I'll let it slide, this time."
 
326
                q = 2
 
327
        elif q == 2:
 
328
            print "2. What is the capital of Assyria?"
 
329
            input = raw_input("? ")
 
330
            if "Assur" in input or "assur" in input:
 
331
                print "...*stunned silence*..."
 
332
                print "...you got it! No one ever gets that!"
 
333
                print "Congrats! Last question."
 
334
                q = 3
 
335
            else:
 
336
                print "*The old man sighs*"
 
337
                print "No, but no one ever gets that. Whatever, last question."
 
338
                q = 3
 
339
        elif q == 3:
 
340
            print "1. What is the air-speed of an unladen swallow?"
 
341
            input = raw_input("? ")
 
342
            if ("African" in input or "african" in input) and ("European" in input or "european" in input):
 
343
                print "'What? I don't know that!'"
 
344
                print "The old man suddenly rockets up into the air as if by magic."
 
345
                print "'AAAAUUUUuuuuugughhh....."
 
346
                print "He is gone. The house is yours!"
 
347
                win(kills)
 
348
            else:
 
349
                print "Wrong again. You were so close too..."
 
350
                wrong = 1
 
351
                
 
352
def win(kills):
 
353
    kills = kills
 
354
    print "Congratulations! You've won!"
 
355
    print "You gain access to the house and live out the rest of your days in splendor."
 
356
    print "On your journey here, you killed %d molerats." % kills
 
357
    if kills >= 5:
 
358
        print "Heartless bastard."
 
359
    elif 1 <= kills <= 4:
 
360
        print "You could've done worse."
 
361
    elif kills == 0:
 
362
        print "You've got a big heart. Or your a coward. One of the two."
 
363
    raw_input("You're done! Thanks for playing.")
 
364
    exit()
 
365
    
 
366
        
 
367
##########################################################    
 
368
    
 
369
print "Welcome to \'The Adventure.\'"
 
370
print "What is your name, traveler?"
 
371
name = raw_input("> ")
 
372
print "Welcome, %s. Are you ready to begin?" % name
 
373
raw_input()
 
374
start()
 
375
 
 
376
 
 
377
 
 
378
 
 
379