-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim.py
70 lines (51 loc) · 1.58 KB
/
sim.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
from pymud.persist import Persistent, P
from pymud.exceptions import *
from pymud.chainedmap import ChainedMap
from pymud.scheduler import Scheduler
from pymud.rule import runRules
class Sim(Persistent):
description = "something"
detail = "maybe it's nothing"
article = "a"
attributes = []
ticksPerTurn = 0
name = 'thing'
location = P.null
locationSlot = None
fitsInSlots = []
commands = {}
rules = []
checks = []
def __init__(self):
Persistent.__init__(self)
def __repr__(self):
if self.id:
return "<" + self.__class__.__name__ + ":" + self.id + ">"
return "<" + self.__class__.__name__ + ":" + "NO ID" + ">"
def checkGet(self,getter):
raise GameException("You cannot lift it.")
def checkDrop(self,getter):
raise GameException("It's too sticky.")
def checkUse(self,getter):
raise GameException("%s does not look usable" % self.name)
def run(self,*ignore):
pass
def update(self,tick):
self.lastUpdate = tick
self.runChecks()
self.runRules()
def runChecks(self):
runRules(self,self.checks)
def runRules(self):
runRules(self,self.rules)
def reschedule(self):
Scheduler.scheduler.schedule(self)
def delete(self):
P.persist.delete(self)
self.__class__ = Deleted
def sendLocationMessage(self,*args,**kwargs):
if self.location():
self.location().sendMessage(*args,**kwargs)
def sendMessage(self,*ignore,**kwignore):
pass
class Deleted(Sim): pass