Combat: rewards on the kill, 1s pause, swing timer runs on between enemies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4cb6ff5ec0
commit
60b7b23a05
3 changed files with 61 additions and 15 deletions
|
|
@ -530,10 +530,36 @@ class CombatTest(unittest.TestCase):
|
|||
self.assertEqual(fight["result"], "won")
|
||||
self.assertTrue(all(e[1] in ("you", "foe") and e[2] in ("hit", "crit", "miss", "eat", "wind") for e in fight["events"]))
|
||||
self.assertEqual(fight["events"][-1][5], 0) # the last swing finished it
|
||||
self.assertAlmostEqual(fight["duration"], fight["end"] + game.RESPAWN, places=1)
|
||||
summary = game.process_player(world, p, T0 + fight["duration"] + 0.5, random.Random(2))
|
||||
self.assertAlmostEqual(fight["duration"], fight["end"], places=1) # rewards land on the kill
|
||||
summary = game.process_player(world, p, T0 + fight["duration"] + 0.01, random.Random(2))
|
||||
self.assertEqual(summary["wins"], 1)
|
||||
self.assertEqual(p["hp"], fight["hp"])
|
||||
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):
|
||||
world, p = self.fighter(level=level, weapon="rune_sword")
|
||||
game.start_action(world, p, "fight_wolves", T0)
|
||||
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):
|
||||
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
|
||||
|
||||
def test_preferred_food_is_eaten_first(self):
|
||||
world, p = self.fighter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue