-
Notifications
You must be signed in to change notification settings - Fork 0
/
monster.py
130 lines (99 loc) · 3.98 KB
/
monster.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
import arkham
from obj import NamedObject, SubjectProto
from deck import DeckItem
class ResistanceLevel (NamedObject):
def __init__ (self, name, modifier):
NamedObject.__init__ (self, name)
self.m_modifier = modifier
def modify (self, bonus):
return arkham.Bonus (self.m_modifier (bonus.value ()), bonus.family ())
reslev_none = ResistanceLevel ("none", lambda val: val)
reslev_resistance = ResistanceLevel ("resistance", lambda val: (val + 1) / 2)
reslev_immunity = ResistanceLevel ("immunity", lambda val: 0)
class Family (NamedObject):
def __str__ (self):
return self.name ()
def __repr__ (self):
return "<Family %s>" % repr (self.name ())
family_indifferent = Family ("indifferent")
family_physical = Family ("physical")
family_magical = Family ("magical")
class MonsterSpecialAbility (NamedObject):
pass
class MonsterResistance (MonsterSpecialAbility):
def __init__ (self, family):
MonsterSpecialAbility.__init__ (self, family.name ())
self.m_family = family
def family (self):
return self.m_family
# xxx I think most of these should be module members.
monster_physical = MonsterResistance (family_physical)
monster_magical = MonsterResistance (family_magical)
monster_nightmarish = MonsterSpecialAbility ("nightmarish")
monster_overwhelming = MonsterSpecialAbility ("overwhelming")
monster_ambush = MonsterSpecialAbility ("ambush")
monster_endless = MonsterSpecialAbility ("endless")
class MonsterProto (DeckItem, SubjectProto):
def __init__ (self, name, special_abilities = {}, **attributes):
DeckItem.__init__ (self, name, **attributes)
SubjectProto.__init__ (self, special_abilities)
# Override in subclass
def movement (self, game):
raise NotImplementedError ()
# Combat phases.
def pre_combat (self, combat, investigator):
return []
def combat_turn (self, combat, investigator):
return []
# We just need those.
def evade_check (self):
raise NotImplementedError ()
def horror_check (self):
raise NotImplementedError ()
def combat_check (self):
raise NotImplementedError ()
def horror_harm (self):
raise NotImplementedError ()
def combat_harm (self):
raise NotImplementedError ()
class BasicMonster (MonsterProto):
def __init__ (self, name,
evade_check,
horror_check, horror_harm,
combat_check, combat_harm,
special_abilities = set (),
**attributes):
for fam in ("physical", "magical"):
assert fam not in attributes
MonsterProto.__init__ (self, name, special_abilities, **attributes)
self.m_evade_check = evade_check
self.m_horror_check = horror_check
self.m_horror_harm = horror_harm
self.m_combat_check = combat_check
self.m_combat_harm = combat_harm
def evade_check (self):
return self.m_evade_check
def horror_check (self):
return self.m_horror_check
def combat_check (self):
return self.m_combat_check
def horror_harm (self):
return self.m_horror_harm
def combat_harm (self):
return self.m_combat_harm
class SimpleMonster (BasicMonster):
def __init__ (self, name,
awareness,
(horror_rating, horror_damage),
toughness,
(combat_rating, combat_damage),
special_abilities = set (),
**attributes):
BasicMonster.__init__ (self, name,
arkham.evade_check (awareness),
arkham.horror_check (horror_rating),
arkham.HarmSanity (horror_damage),
arkham.combat_check (combat_rating, toughness),
arkham.HarmStamina (combat_damage),
special_abilities,
**attributes)