-
Notifications
You must be signed in to change notification settings - Fork 13
/
sample.py
55 lines (44 loc) · 1.37 KB
/
sample.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
import importlib
import traceback
import modular
import modules.logging
import modules.eval
import modules.repeat
import modules.mapper
importlib.reload(modular)
importlib.reload(modules.logging)
importlib.reload(modules.eval)
importlib.reload(modules.repeat)
importlib.reload(modules.mapper)
ALIASES={
'sc': 'score'
}
TRIGGERS={
r'^You are thirsty\.$': 'drink waterskin'
}
class Sample(modular.ModularClient):
def __init__(self, mud, name):
self.name = name
self.logfname = '{}.log'.format(name)
self.mapfname = 'sample.map'.format(name)
self.modules = {}
mods = {
'eval': (modules.eval.Eval, []),
'repeat': (modules.repeat.Repeat, []),
'logging': (modules.logging.Logging, [self.logfname]),
'mapper': (modules.mapper.Mapper, [True, self.mapfname, True]),
}
for modname, module in mods.items():
try:
constructor, args = module
args = [mud] + args
self.modules[modname] = constructor(*args)
except Exception:
traceback.print_exc()
super().__init__(mud)
self.aliases.update(ALIASES)
self.triggers.update(TRIGGERS)
def getHostPort(self):
return 'sneezy-mud.com', 7900
def getClass():
return Sample