-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtile.py
60 lines (48 loc) · 1.41 KB
/
tile.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
import copy
from mobs import *
import weakref
class tile:
actor = None
#init
def __init__(self, actor):
if actor!=None:
self.actor = weakref.ref(actor)
def __str__(self):
if self.actor is not None:
return self.actor().__str__()
elif self.actor is None:
return '_'
def getActor(self):
if self.actor is not None:
return self.actor()
else:
return self.actor
def addInfection(self, level):
if self.actor is not None:
self.actor().addInfection(level)
return 1
else:
return 0
def getHealth(self):
if self.actor is not None:
return self.actor().getHealth()
def setActor(self, actor):
if self.actor is not None:
self.actor = weakref.ref(actor)
def getInfection(self):
if self.actor is not None:
return self.actor().getInfection()
else:
return 'n'
def takeDamage(self, damage):
if self.actor is not None:
self.actor().takeDamage(damage)
# target is a target tile
def infectPriest(self, target):
if self.actor is not None and target is not None:
if self.actor().getSymbol() == 'P':
self.actor().infectPriest(target.getActor())
#simplifies the attack order
def attack(self, target):
if (hasattr(target, "actor")):
target.takeDamage(self.actor().getDamage())