-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex43.py
More file actions
111 lines (84 loc) · 2.79 KB
/
Copy pathex43.py
File metadata and controls
111 lines (84 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# See oop_process.txt
from sys import exit
from random import randint
class Scene(object):
def enter(self):
print "This scene is not yet configured. Subclass it and implement enter()."
exit(1)
class Engine(object):
def __init__(self, scene_map):
self.scene_map = scene_map
def play(self):
current_scene = self.scene_map.opening_scene()
last_scene = self.scene_map.next_scene('finished')
while current_scene != last_scene:
next_scene_name = current_scene.enter()
current_scene = self.scene_map.next_scene(next_scene_name)
# Print out the last scene
current_scene.enter()
class Death(self):
quips = [
"You died. You kinda suck at this.",
"Your mom would be proud... if she were smarter.",
"Such a loser.",
"I have a small puppy that is better at this."
]
def enter(self):
print Death.quips[randint(0, len(self.quips)-1)]
exit(1)
class CentralCorridor(Scene):
def enter(self):
print """
The Gothons of Planet Percal #25 have invaded your ship and
destroyed your entire crew. You are the last surviving member
and your last mission is to get the neutron destruct bomb from
the Weapons Armory when a Gothon jumps out, red scaly skin, dark
grimy teeth and an evil clown costume flowing around his hate
filled body. He is blocking the door to the Armory and about to
pull a weapon to blast you.
"""
action = raw_input("> ")
if action == "shoot":
print "No."
return 'death'
elif action == "dodge":
print "No."
return 'death'
elif action == "tell a joke":
print "Yes."
return 'laser_weapon_armory'
else:
print "Does not compute"
return 'central_corridor'
class LaserWeaponArmory(Scene):
def enter(self):
print "Guess the code. 3 digits."
code = "%d%d%d" % (randint(1,9), randint(1,9), randint(1,9))
guess = raw_input("[keypad]> ")
guesses = 0
while guess != code and guesses < 10:
print "Nope"
guesses += 1
guess = raw_input("[keypad]> ")
if guess == code:
print "Yes."
return 'the_bridge'
else:
print "No."
return 'death'
class TheBridge(Scene):
def enter(self):
pass
class EscapePod(Scene):
def enter(self):
pass
class Map(object):
def __init__(self, start_scene):
pass
def next_scene(self, scene_name):
pass
def opening_scene(self):
pass
a_map = Map('centras_corridor')
a_game = Engine(a_map)
a_game.play()