forked from BoofPC/ZorCK2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscience_hall.py
115 lines (102 loc) · 4.57 KB
/
science_hall.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
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
112
113
114
115
class ScienceHall:
if self.global_state["floor2_is_flooded"]:
def _init_(self,global_state,inventory):
self.global_state = global_state
self.inventory = inventory
self.set_state()
self.name = "science_hall"
self.description = """You are in the Science Hall.
It is flooded--microscopes are littered on the floor,
and lab papers are floating on the surface of the water.
To the north, the door that leads to Birkenfeld's room is open."""
print(self.description())
self.run()
def run(self):
self.route(input(">>"))
def route(self,command):
if command in ["go north","go east","go west","go south"]:
self.move(command.split(" ")[1])
else:
if command in ["take microscope","pick up microscope"]:
self.take_microscope()
elif command in ["take lab papers","take papers"]:
self.take_papers()
elif command in ["enter room","go to birkenfeld's room","birkenfeld"]:
room = Birkenfeld(self.global_state,self.inventory)
room.run()
elif command in ["look","look around","description"]:
print(self.description)
else:
print("Sorry, what was that?")
self.run()
def move(self,direction):
for key in self.state.keys():
self.global_state[self.name+"_"+key] = self.state[key]
if direction == "north":
room = Birkenfeld(self.global_state,self.inventory)
room.run()
if direction == "west":
print("All classrooms to the west seem to be locked.")
if direction == "east":
print("All classrooms to the east seem to be locked.")
if direction == "south":
room = SeniorHall(self.global_state,self.inventory)
room.run()
def set_state(self):
self.state = {}
self.state["took_microscope"] = False
self.state["took_papers"] = False
def take_microscope(self):
if not self.state["took_microscope"]:
print("Microscope taken. It's soaked and seems to be damaged.")
self.state["took_microscope"] = True
self.inventory["microscope"] = True
else:
print("You've already taken the microscope.")
def take_papers(self):
if not self.state["took_papers"]:
print("Papers taken. They are soaked and on the verge of disintegrating.")
self.state["took_papers"] = True
self.inventory["papers"] = True
else:
print("You've already taken the papers.")
else:
def __init__(self,global_state,inventory):
self.global_state = global_state
self.inventory = inventory
self.set_state()
self.name = "science_hall"
self.description = """You are in the Science Hall.
It is no longer flooded, but the carpet is wet.
To the north, the door that leads to Birkenfeld's room is open."""
print(self.description())
self.run()
def run(self):
self.route(input(">>"))
def route(self,command):
if command in ["go north","go east","go west","go south"]:
self.move(command.split(" ")[1])
else:
elif command in ["enter room","go to birkenfeld's room","birkenfeld"]:
room = Birkenfeld(self.global_state,self.inventory)
room.run()
elif command in ["look","look around","description"]:
print(self.description)
else:
print("Sorry, what was that?")
self.run()
def move(self,direction):
for key in self.state.keys():
self.global_state[self.name+"_"+key] = self.state[key]
if direction == "north":
room = Birkenfeld(self.global_state,self.inventory)
room.run()
if direction == "west":
print("All classrooms to the west seem to be locked.")
if direction == "east":
print("All classrooms to the east seem to be locked.")
if direction == "south":
room = SeniorHall(self.global_state,self.inventory)
room.run()
def set_state(self):
self.state = {}