Combat on the tier ladder, less combat XP, eating costs a swing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-21 07:52:01 +01:00
parent 2816ca8606
commit 0f2b29e67e
3 changed files with 63 additions and 35 deletions

View file

@ -516,6 +516,20 @@ class CombatTest(unittest.TestCase):
self.assertLess(p["hp"], game.max_hp(p) * game.TOO_HURT)
self.assertEqual(game.start_action(world, p, "fight_scouts", T0 + 6 * 3600), "Too hurt to fight. Rest, or bring food")
def test_eating_holds_back_your_swings(self):
world, p = self.fighter(level=15)
p["bank"] = {"cooked_shrimp": 100}
p["hp"] = 1
fight = game.simulate_fight(world, p, game.ACTION_BY_ID["fight_clay_golems"], random.Random(3))
mine = [event for event in fight["events"] if event[1] == "you"]
bite = next(i for i, event in enumerate(mine) if event[2] == "eat")
swing = next(event for event in mine[bite:] if event[2] != "eat")
self.assertGreaterEqual(swing[0] - mine[bite][0], game.EAT_DELAY)
scouts = game.ACTION_BY_ID["fight_scouts"]
eating = game.fight_odds(p, scouts)["kill_time"]
p["bank"] = {}
self.assertGreater(eating, game.fight_odds(p, scouts)["kill_time"])
def test_rest_heals(self):
world, p = self.fighter()
p["hp"] = 1
@ -753,10 +767,10 @@ class TierTest(unittest.TestCase):
def test_gear_needs_levels_to_wear(self):
world = world_with(("wil", "commoner"))
p = world["players"]["wil"]
self.assertEqual(game.equip_problem(p, "rune_sword"), "Needs combat level 50")
self.assertEqual(game.equip_problem(p, "rune_sword"), "Needs combat level 75")
self.assertEqual(game.equip_problem(p, "steel_pickaxe"), "Needs mining level 20")
self.assertIsNone(game.equip_problem(p, "copper_sword"))
p["xp"]["combat"] = game.XP_TABLE[50]
p["xp"]["combat"] = game.XP_TABLE[75]
self.assertIsNone(game.equip_problem(p, "rune_sword"))
def test_militia_takes_the_best_weapons_first(self):
@ -946,9 +960,10 @@ class HerbloreTest(unittest.TestCase):
game.use_potion(p, "defence_potion_6")
game.start_action(world, p, "fight_scouts", T0)
scouts = game.ACTION_BY_ID["fight_scouts"]
brewed = game.fight_odds(p, scouts)["damage"]
per_second = lambda odds: odds["damage"] / odds["kill_time"] # less eating also shortens the fight
brewed = per_second(game.fight_odds(p, scouts))
active = p["potions"].pop("combat")
self.assertAlmostEqual(brewed, game.fight_odds(p, scouts)["damage"] * 0.70, delta=0.2)
self.assertAlmostEqual(brewed, per_second(game.fight_odds(p, scouts)) * 0.70, delta=0.02)
p["potions"]["combat"] = active
summary = game.process_player(world, p, T0 + 75 * 10, random.Random(1))
self.assertEqual(p["potions"]["combat"]["charges"], game.POTION_CHARGES - summary["done"])
@ -1364,7 +1379,7 @@ class TradeSkillsTest(unittest.TestCase):
class WeaponStyleTest(unittest.TestCase):
def armed(self, cls, weapon, shield=None, level=12):
def armed(self, cls, weapon, shield=None, level=15):
world = world_with(("pat", cls))
p = world["players"]["pat"]
p["xp"]["combat"] = game.XP_TABLE[level]