Combat: each enemy starts with fresh swing timers; show the pause after a kill
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60b7b23a05
commit
5898e2006f
4 changed files with 23 additions and 33 deletions
|
|
@ -536,14 +536,6 @@ class CombatTest(unittest.TestCase):
|
|||
self.assertAlmostEqual(p["hp"], fight["hp"], delta=0.1)
|
||||
self.assertAlmostEqual(p["action"]["start"], T0 + fight["duration"] + game.RESPAWN) # then a short pause
|
||||
|
||||
def test_a_fight_from_before_the_carry_over_still_finishes(self):
|
||||
world, p = self.fighter(level=30, weapon="iron_sword")
|
||||
game.start_action(world, p, "fight_wolves", T0)
|
||||
game.process_player(world, p, T0 + 0.1, random.Random(1))
|
||||
del p["action"]["fight"]["carry"]
|
||||
summary = game.process_player(world, p, T0 + 60, random.Random(1))
|
||||
self.assertGreater(summary["wins"], 0)
|
||||
|
||||
def test_outclassing_an_enemy_kills_faster(self):
|
||||
kills = {}
|
||||
for level in (20, 90):
|
||||
|
|
@ -552,15 +544,15 @@ class CombatTest(unittest.TestCase):
|
|||
kills[level] = game.process_player(world, p, T0 + 600, random.Random(1))["wins"]
|
||||
self.assertGreater(kills[90], kills[20] * 1.3)
|
||||
|
||||
def test_the_swing_timer_runs_on_between_enemies(self):
|
||||
def test_each_enemy_starts_with_both_swing_timers_empty(self):
|
||||
world, p = self.fighter(level=60, weapon="rune_sword")
|
||||
wolves = game.ACTION_BY_ID["fight_wolves"]
|
||||
fresh = game.simulate_fight(world, p, wolves, random.Random(1))
|
||||
carried = game.simulate_fight(world, p, wolves, random.Random(1), carry=1.0)
|
||||
first = lambda fight: next(e[0] for e in fight["events"] if e[1] == "you")
|
||||
self.assertEqual(first(fresh), 2.4)
|
||||
self.assertEqual(first(carried), 1.4) # a second already gone in the pause between wolves
|
||||
|
||||
game.start_action(world, p, "fight_wolves", T0)
|
||||
game.process_player(world, p, T0 + 0.1, random.Random(1))
|
||||
first = p["action"]["fight"]
|
||||
game.process_player(world, p, T0 + first["duration"] + 0.01, random.Random(1))
|
||||
self.assertAlmostEqual(p["action"]["start"], T0 + first["duration"] + game.RESPAWN) # the pause starts at the kill
|
||||
second = p["action"]["fight"]
|
||||
self.assertEqual(next(e[0] for e in second["events"] if e[1] == "you"), 2.4) # a full swing, from scratch
|
||||
def test_preferred_food_is_eaten_first(self):
|
||||
world, p = self.fighter()
|
||||
p["bank"] = {"bread": 5, "cooked_salmon": 5}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue