Herblore: herbs, potions with charges, one per skill
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
278c5f4283
commit
090b202188
5 changed files with 245 additions and 19 deletions
|
|
@ -687,5 +687,79 @@ class PrayerTest(unittest.TestCase):
|
|||
self.assertEqual(world["city"]["buildings"]["temple"]["level"], 0)
|
||||
|
||||
|
||||
|
||||
class HerbloreTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = world_with(("hal", "warrior"))
|
||||
self.p = self.world["players"]["hal"]
|
||||
|
||||
def test_herbs_to_potion(self):
|
||||
world, p = self.world, self.p
|
||||
p["xp"]["farming"] = game.XP_TABLE[5]
|
||||
game.start_action(world, p, "grow_guam_leaf", T0)
|
||||
game.process_player(world, p, T0 + 450, random.Random(1))
|
||||
self.assertEqual(p["bank"]["guam_leaf"], 10)
|
||||
p["xp"]["herblore"] = game.XP_TABLE[6]
|
||||
p["bank"]["logs"] = 3
|
||||
game.start_action(world, p, "brew_lumberjacks_tonic", T0 + 450)
|
||||
game.process_player(world, p, T0 + 1000, random.Random(1))
|
||||
self.assertEqual(p["bank"]["lumberjacks_tonic"], 3)
|
||||
|
||||
def test_skill_potion_speeds_up_and_uses_charges(self):
|
||||
world, p = self.world, self.p
|
||||
plain = game.action_time(world, p, game.ACTION_BY_ID["cut_logs"])
|
||||
p["bank"] = {"lumberjacks_tonic": 1}
|
||||
self.assertIsNone(game.use_potion(p, "lumberjacks_tonic"))
|
||||
self.assertEqual(p["potions"]["woodcutting"], {"item": "lumberjacks_tonic", "charges": game.POTION_CHARGES})
|
||||
self.assertAlmostEqual(game.action_time(world, p, game.ACTION_BY_ID["cut_logs"]), plain * 0.8)
|
||||
self.assertEqual(game.action_time(world, p, game.ACTION_BY_ID["mine_stone"]), plain)
|
||||
game.start_action(world, p, "cut_logs", T0)
|
||||
summary = game.process_player(world, p, T0 + 16 * 60, random.Random(1))
|
||||
self.assertEqual(summary["potion_out"], ["lumberjacks_tonic"])
|
||||
self.assertNotIn("woodcutting", p["potions"])
|
||||
|
||||
def test_empty_potion_is_replaced_from_the_bank(self):
|
||||
world, p = self.world, self.p
|
||||
p["bank"] = {"trackers_tincture": 2}
|
||||
game.use_potion(p, "trackers_tincture")
|
||||
p["potions"]["hunting"]["charges"] = 1
|
||||
game.start_action(world, p, "hunt_birds", T0)
|
||||
summary = game.process_player(world, p, T0 + 25, random.Random(1))
|
||||
self.assertEqual(summary["potions_drunk"], {"trackers_tincture": 1})
|
||||
self.assertEqual(p["potions"]["hunting"]["charges"], game.POTION_CHARGES)
|
||||
self.assertNotIn("trackers_tincture", p["bank"])
|
||||
|
||||
def test_keep_chance_saves_materials(self):
|
||||
world, p = self.world, self.p
|
||||
p["bank"] = {"copper_ore": 100, "logs": 100, "smiths_focus": 1}
|
||||
game.use_potion(p, "smiths_focus")
|
||||
p["potions"]["smithing"]["charges"] = 1000
|
||||
game.start_action(world, p, "smith_copper_bar", T0)
|
||||
summary = game.process_player(world, p, T0 + 20 * 100, random.Random(2))
|
||||
self.assertGreater(summary["kept"], 5)
|
||||
self.assertEqual(p["bank"]["copper_ore"], 100 - (100 - summary["kept"]))
|
||||
|
||||
def test_combat_potions_add_power_and_cut_damage(self):
|
||||
world, p = self.world, self.p
|
||||
p["xp"]["combat"] = game.XP_TABLE[20]
|
||||
p["hp"] = game.max_hp(p)
|
||||
p["bank"] = {"defence_potion": 1, "bread": 500}
|
||||
game.use_potion(p, "defence_potion")
|
||||
game.start_action(world, p, "fight_scouts", T0)
|
||||
scouts = game.ACTION_BY_ID["fight_scouts"]
|
||||
brewed = game.with_potion(game.NO_BLESSING, game.potion_effect(p, "combat"))
|
||||
self.assertAlmostEqual(game.fight_damage(p, scouts, brewed), game.fight_damage(p, scouts) * 0.85)
|
||||
summary = game.process_player(world, p, T0 + 75 * 10, random.Random(1))
|
||||
self.assertEqual(p["potions"]["combat"]["charges"], game.POTION_CHARGES - summary["done"])
|
||||
|
||||
def test_v5_worlds_get_herblore(self):
|
||||
world = world_with(("fred", "pioneer"))
|
||||
world["version"] = 5
|
||||
p = world["players"]["fred"]
|
||||
del p["potions"], p["xp"]["herblore"]
|
||||
game.migrate(world, T0)
|
||||
self.assertEqual((p["potions"], p["xp"]["herblore"]), ({}, 0))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue