-
Notifications
You must be signed in to change notification settings - Fork 1
/
pineapple.py
43 lines (32 loc) · 1.24 KB
/
pineapple.py
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
import sys
class StoryPiece:
def __init__(self, text):
self.text = text
self.choices = []
def add_choice(self, choice):
self.choices.append(choice)
def run(self):
print self.text
while True:
data = sys.stdin.readline().rstrip()
for choice in self.choices:
if data == choice.command:
return choice.destination
print "Nothing happened."
class Choice:
def __init__(self, command, destination):
self.command = command
self.destination = destination
door = StoryPiece("""You awake in a dungeon, your wrists are tied over your
head. You can tell you've been hanging there for hours, your fingers are numb
and your wrists are bleeding. Your feet dangle inches from the floor, directly
infront of you is a table with a lantern on it. Next to the lanter, the rope
suspending you from the ceiling is tied to a nail on the wall. What do you
do?""")
rope = StoryPiece("""You kick the lantern over, knockin it into the rope. The
lantern breaks and burns a hole in the rope. You drop to the floor and your
hands are freed.""")
door.add_choice(Choice("Kick lantern", rope))
part = door
while True:
part = part.run()