-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dictionary.py
132 lines (116 loc) · 4.04 KB
/
Dictionary.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
WORDS_DICT = {}
def interpret(self, string, mode):
"""
Takes any input a given player has typed and acts out the action the input
has requested.
The mode is a toggle for special events such as combat or dialogue.
"""
wordlist = "".join([char for char in string if char.isalnum() or char.isspace()]).lower().split()
fixedString = " ".join(wordlist)
keywords = []
for word in wordlist:
keywords.extend([k for k,v in WORDS_DICT.items() if word in v])
def contains(container, keywords):
return any([word in WORDS_DICT[container] for word in keywords])
if mode == "DEFAULT":
if contains("move", keywords):
if contains("up", keywords):
return self.move("UP")
if contains("down", keywords):
return self.move("DOWN")
if contains("west", keywords):
return self.move("WEST")
if contains("east", keywords):
return self.move("EAST")
if contains("south", keywords):
return self.move("SOUTH")
if contains("north", keywords):
return self.move("NORTH")
return ("Where do you want to move?")
if fixedString == "n":
return self.move("NORTH")
if fixedString == "s":
return self.move("SOUTH")
if fixedString == "e":
return self.move("EAST")
if fixedString == "w":
return self.move("WEST")
if fixedString == "u":
return self.move("UP")
if fixedString == "d":
return self.move("DOWN")
if fixedString == "where am i":
return ("You are at coordinate position " + str(self.get_position()) +
"\nYou have a zone tree of " + str(self.get_ZoneTree_string()))
if mode == "DIALOGUE":
pass
if fixedString == "save":
if self.save():
return ("Saved successfully.")
else:
return ("Couldn't save.")
if fixedString == "ping":
return ("Pong.")
return ("I don't understand what you mean by '" + string + "'.")
WORDS_DICT["move"] = ["go",
"move",
"climb",
"jump",
"hike",
"venture",
"walk",
"run",
"jog",
"fly",
"stroll",
"meander",
"tiptoe"
"skip",
"step",
"leap",
"roll",
"snake",
"creep",
"crawl",
"wriggle",
"grow",
"dash",
"drive",
"zigzag",
"slide",
"waltz",
"hop",
"climb",
"gallop",
"tumble",
"skate",
"march",
"shimmy",
"stomp",
"polka",
"shuffle",
"waddle",
"moonwalk",
"scamper",
"prance",
"slither",
"scoot",
"trot"]
WORDS_DICT["up"] = ["up", "above", "ascend"]
WORDS_DICT["down"] = ["down", "below", "descend"]
WORDS_DICT["west"] = ["west"]
WORDS_DICT["east"] = ["east"]
WORDS_DICT["north"] = ["north"]
WORDS_DICT["south"] = ["south"]
WORDS_DICT["yes"] = ["yes",
"indeed",
"okay",
"yep",
"alright",
"yea",
"affirmative",
"sure"]
WORDS_DICT["no"] = ["no",
"negative",
"nope",
"nay"]