/
tiles.py
496 lines (370 loc) · 12.2 KB
/
tiles.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
#!/usr/bin/python
import actions, world, items, npcs
global badge
badge = False
class MapTile(object):
def __init__(self, x, y):
self.x = x
self.y = y
self.inventory =[]
self.moves = 0
def mydefault(self):
raise NotImplementedError()
def intro_text(self):
raise NotImplementedError()
def room_name(self):
raise NotImplementedError()
def list_items(self):
for item in self.inventory:
print item
def modify_player(self, player):
raise NotImplementedError()
def adjacent_moves(self):
"""Returns all move actions for adjacent tiles."""
moves = []
myroom = world.tile_exists(self.x, self.y)
if world.tile_exists(self.x + 1, self.y):
moves.append(actions.MoveEast())
if world.tile_exists(self.x - 1, self.y):
moves.append(actions.MoveWest())
if world.tile_exists(self.x, self.y - 1):
moves.append(actions.MoveNorth())
# myroom= world.tile_exists(self.x + 1, self.y)
# if type(myroom).__name__ == LockedNorth:
# pass
# else:
# moves.append(actions.MoveNorth())
if world.tile_exists(self.x, self.y + 1):
moves.append(actions.MoveSouth())
# myroom = world.tile_exists(self.x, self.y)
# if isinstance(myroom, LockedDoorRoom):
# print "door is locked"
# print myroom.door
if isinstance(myroom, LockedDoorRoom) and not myroom.solved:
for move in moves:
if isinstance(move, actions.MoveNorth) and myroom.door == "north":
moves.remove(move)
if isinstance(move, actions.MoveSouth) and myroom.door == "south":
moves.remove(move)
if isinstance(move, actions.MoveEast) and myroom.door == "east":
moves.remove(move)
if isinstance(move, actions.MoveWest) and myroom.door == "west":
moves.remove(move)
# print moves
return moves
def available_actions(self):
"""Returns all of the available actions in this room."""
moves = self.adjacent_moves()
moves.append(actions.ViewInventory())
moves.append(actions.DescribeItem())
# moves.append(actions.DescribeAnItem(item=item))
return moves
def exits_text(self):
"""Returns all move actions for adjacent tiles."""
exits = []
if world.tile_exists(self.x + 1, self.y):
exits.append("east")
if world.tile_exists(self.x - 1, self.y):
exits.append("west")
if world.tile_exists(self.x, self.y - 1):
exits.append("north")
if world.tile_exists(self.x, self.y + 1):
exits.append("south")
myroom = world.tile_exists(self.x, self.y)
# print myroom.room_name()
if isinstance(myroom, LockedDoorRoom) and not myroom.solved:
mydoor = myroom.door
exits.remove(mydoor)
if len(exits) == 1:
print "\tThere is an exit to the {}".format(exits[0])
elif len(exits) == 2:
print "\tThere are exits to the {} and {}".format(exits[0], exits[1])
elif len(exits) == 3:
print "\tThere are exits to the {}, {}, and {}".format(exits[0], exits[1], exits[2])
elif len(exits) == 4:
print "\tThere are exits to the {}, {}, {}, and {}".format(exits[0], exits[1], exits[2], exits[3])
else:
if isinstance(myroom, Elevator):
print "\tThe elevator door is closed"
else:
print "\tThere appears to be no way out"
# return exits
class NPCRoom(MapTile):
def __init__(self, x, y, npc):
self.npc = npc
super(NPCRoom, self).__init__(x, y)
def describe_npc(self):
raise NotImplementedError()
def mydefault(self):
pass
class CFOOffice(NPCRoom):
def __init__(self, x, y):
super(CFOOffice,self).__init__(x, y, npcs.CFO())
self.inventory = [items.USB()]
def intro_text(self):
return """
You are in a a CFO's office.
A CFO is here
"""
def describe_npc(self):
return """
You rudely start to examine the CFO, who is a large white rabbit wearing a top hat and waistcoat. He is muttering to himself something about being late and fretfully looking at a small gold pocket-watch.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tThe CFO's office"
class LockedDoorRoom(MapTile):
def __init__(self, x, y):
super(LockedDoorRoom, self).__init__(x, y)
self.door = ""
def return_exits(self):
raise NotImplementedError()
class Reception(LockedDoorRoom):
def __init__(self, x, y):
super(Reception, self).__init__(x, y)
self.solved = False
self.door = "north"
# print self.moves
def mydefault(self):
print ""
def intro_text(self):
if self.solved:
return """
You are at Reception.
There is a receptionist here
"""
else:
return """
You are at Reception.
There is a receptionist here.
There is locked door to the north.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tReception"
class Elevator(LockedDoorRoom):
def __init__(self, x, y):
super(Elevator,self).__init__(x, y)
self.inventory = [items.id_badge()]
self.solved = False
self.door = "north"
#self.inventory = [items.cake()]
def intro_text(self):
if self.moves == 0:
return """
You find yourself in an elevator.It is acending
"""
elif self.moves == 1:
print "\tThe elevator is ascending. You notice a screen on the wall. It says '65% of NPCs read this screen'"
elif self.moves == 2:
print "\tThe elevator is slowing."
elif self.moves == 3:
print "\tThe elevator comes to a stop and the door opens."
else:
return """
You are in an elevator. There is a button and a keyhole.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tElevator"
def mydefault(self):
if self.moves == 0:
print "\tYou are in an elevator. The elevator is ascending"
if self.moves == 1:
print "\tThe elevator is ascending. You notice a screen on the wall. It says '65% of NPCs read this screen'"
if self.moves == 2:
print "\tThe elevator is slowing."
if self.moves == 3:
self.solved=True
print "\tThe elevator comes to a stop and the door opens."
available_actions = self.available_actions()
self.exits_text()
class StartingRoom(MapTile):
def intro_text(self):
return """
You find yourself if a cave with a flickering torch on the wall.
You can make out four paths, each equally as dark and foreboding.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tStarting Room"
class ConfRoomNorth(MapTile):
def __init__(self, x, y):
super(ConfRoomNorth,self).__init__(x, y)
self.inventory = [items.cake()]
def intro_text(self):
return """
You are in a conference room. The lights flicker eerily. There is a whiteboard kere.
You wonder how do paragraphs display.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tConference Room North"
def mydefault(self):
pass
class ConfRoomNorth1(MapTile):
def intro_text(self):
return """
A conference room. the lights are flickering and there is a case of water bottles here
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tConference Room North 1"
def mydefault(self):
pass
class ConfRoomNorth2(MapTile):
def intro_text(self):
return """
An unremarkable conference room. There is a man on a screen looking at you.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tConference Romm North 2"
def mydefault(self):
pass
class ConfRoom(MapTile):
def intro_text(self):
return """
You are in another goddamn conference room
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tConference Room"
def mydefault(self):
pass
class Room(MapTile):
def intro_text(self):
return """
You are in a room. A hideous room.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tRoom"""
def mydefault(self):
pass
class OfficeManagerOffice(MapTile):
def intro_text(self):
return """
You are in the office manager's office.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tOffice Manager's office"
def mydefault(self):
pass
class StorageCloset(MapTile):
def intro_text(self):
return """
You are in a storage closet. There are stores here
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tStorage Closet"
def mydefault(self):
pass
class Hallway(MapTile):
def intro_text(self):
return """
You are in an empty beige hallway. You feel empty inside.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tHallway"
def mydefault(self):
pass
class CIOOffice(MapTile):
def intro_text(self):
return """
You are in the CIO's office
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tCIO's office"
def mydefault(self):
pass
class SmallKitchen(MapTile):
def intro_text(self):
return """
You are in a wee kitchen
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tSmall Kitchen"
def mydefault(self):
pass
class CopierRoom(MapTile):
def intro_text(self):
return """
You are in a copier room.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tCopier Room"
def mydefault(self):
pass
class MensBathroom(MapTile):
def intro_text(self):
return """
You are in a filthy mens room
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tMens Bathroom"
def mydefault(self):
pass
class MensStall(MapTile):
def intro_text(self):
return """
You are in a bathroom stall. There is graffiti on the walls.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tBathroom Stall"
def mydefault(self):
pass
class MensUrinal(MapTile):
def intro_text(self):
return """
This is a men's unrinal.
"""
def modify_player(self, player):
#Room has no action on player
pass
def room_name(self):
return "\t\tMens Urinal"
def mydefault(self):
pass