-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoom.py
45 lines (37 loc) · 1.44 KB
/
Room.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
import Misc
import Parser
class Room(object):
def __init__(self, ID, name = "default room", desc = "a normal looking room",
items = [], commands = {}, connections = {}):
self.ID = ID
self.name = name
self.desc = desc
self.items = items
self.connections = connections
self.commands = commands
def contains(self, itemName):
if itemName in Misc.flatten([item.names for item in self.items]):
return True
else:
return False
def printDetails(self):
print('\nRoom: ' + self.name)
pDesc = Parser.desc_block.parseString(self.desc)
# print(pDesc)
print("Description:", end=" ")
for item in pDesc:
if type(item) is str:
print(item, end=" ")
else:
if item["if_condition"]["verb"] == "has":
if not item["if_condition"]["object"] in [item.ID for item in self.items]:
print(item["if_condition"]["condition_text"], end = " ")
else:
print(item["else_condition"]["condition_text"])
# if item[0] == "without":
# if item[1] in [item.ID for item in self.items]:
# print(item[2], end = " ")
# print(item[2], end = " ")
print()
# print(pDesc)
# print('Description: ' + self.desc + '\n')