/
test_ah_damage_reduce.py
117 lines (94 loc) · 3.7 KB
/
test_ah_damage_reduce.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
import tester
import mod_ah
import test_ah
import fun
import arkham
_damage = 4
class ModuleProto (test_ah.ModuleProto):
def do_turn_0 (self, game, item):
assert item
inv, = game.investigators ()
inv.take_item (game, item)
assert inv.wield_item (game, item)
return inv
def heal_action_times (self):
return 1
def expected_increment (self, x):
return x
def actions (self):
yield fun.matchclass (arkham.GameplayAction_Multiple)
class TestProto:
pass
test_subject = arkham.Subject (TestProto ())
class ModuleProto1 (ModuleProto):
def turn_0 (self, game):
inv = ModuleProto.do_turn_0 \
(self, game,
self.m_common_deck.draw \
(lambda arg: arg.name () == "Food"))
arkham.HarmStamina (_damage).cause (game, inv, test_subject)
class ModuleProto2 (ModuleProto):
def turn_0 (self, game):
inv = ModuleProto.do_turn_0 \
(self, game,
self.m_common_deck.draw \
(lambda arg: arg.name () == "Whiskey"))
arkham.HarmSanity (_damage).cause (game, inv, test_subject)
class ModuleProto3 (ModuleProto):
def turn_0 (self, game):
inv = ModuleProto.do_turn_0 \
(self, game,
self.m_unique_deck.draw \
(lambda arg: arg.name () == "Enchanted Jewelry"))
arkham.HarmStamina (_damage).cause (game, inv, test_subject)
def heal_action_times (self):
return 3
class ModuleProto4 (ModuleProto):
def turn_0 (self, game):
inv = ModuleProto.do_turn_0 \
(self, game,
self.m_unique_deck.draw \
(lambda arg: arg.name () == "Obsidian Statue"))
arkham.HarmStamina (_damage).cause (game, inv, test_subject)
def expected_increment (self, x):
return _damage
class ModuleProto5 (ModuleProto):
def turn_0 (self, game):
inv = ModuleProto.do_turn_0 \
(self, game,
self.m_spell_deck.draw \
(lambda arg: arg.name () == "Flesh Ward"))
arkham.HarmStamina (_damage).cause (game, inv, test_subject)
def expected_increment (self, x):
return _damage
def actions (self):
yield fun.matchclass (arkham.GameplayAction_Multiple)
yield fun.matchclass (arkham.GameplayAction_IncurDamage)
yield fun.matchclass (arkham.GameplayAction_NormalCheckHook)
yield 5 # succeed lore check
yield fun.matchclass (arkham.GameplayAction_Stay) # the damage got reduced out
class Test (tester.Controller):
def __init__ (self, proto, aspect):
tester.Controller.__init__ (self)
self.aspect = aspect
self.module = proto ()
def setup_players (self, game):
self.inv, = self.use_investigators (game, ["\"Ashcan\" Pete"])
def add_modules (self, idx):
idx.add_module (self.module)
def actions (self):
x = self.module.heal_action_times ()
y = self.module.expected_increment (x)
h = self.inv.health (self.aspect).cur ()
for i in range (x):
for action in self.module.actions ():
yield action
if y != _damage:
yield fun.matchclass (arkham.GameplayAction_IncurDamage)
assert self.inv.health (self.aspect).cur () == h - _damage + y
raise tester.EndTest (True)
tester.run_test (test_ah.Game (Test (ModuleProto1, arkham.health_stamina)))
tester.run_test (test_ah.Game (Test (ModuleProto2, arkham.health_sanity)))
tester.run_test (test_ah.Game (Test (ModuleProto3, arkham.health_stamina)))
tester.run_test (test_ah.Game (Test (ModuleProto4, arkham.health_stamina)))
tester.run_test (test_ah.Game (Test (ModuleProto5, arkham.health_stamina)))