Prayer: bones, prayer points, combat prayers, temple offerings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
568e61799d
commit
278c5f4283
6 changed files with 296 additions and 25 deletions
|
|
@ -409,12 +409,12 @@ class CombatTest(unittest.TestCase):
|
|||
|
||||
def test_fights_hurt_and_food_heals(self):
|
||||
world, p = self.fighter()
|
||||
p["bank"] = {"bread": 50}
|
||||
p["bank"] = {"bread": 100}
|
||||
game.start_action(world, p, "fight_scouts", T0)
|
||||
summary = game.process_player(world, p, T0 + 60 * 60, random.Random(4))
|
||||
self.assertGreater(summary["damage"], 0)
|
||||
self.assertGreater(summary["eaten"].get("bread", 0), 0)
|
||||
self.assertEqual(p["bank"]["bread"], 50 - summary["eaten"]["bread"])
|
||||
self.assertEqual(p["bank"]["bread"], 100 - summary["eaten"]["bread"])
|
||||
self.assertGreaterEqual(p["hp"], 1)
|
||||
|
||||
def test_out_of_food_means_retreat_and_nothing_lost(self):
|
||||
|
|
@ -606,5 +606,86 @@ class TierTest(unittest.TestCase):
|
|||
self.assertGreater(p["bank"].get("green_dragonhide", 0), 30)
|
||||
|
||||
|
||||
|
||||
class PrayerTest(unittest.TestCase):
|
||||
def priest(self, level=1, combat=10):
|
||||
world = world_with(("pat", "warrior"))
|
||||
p = world["players"]["pat"]
|
||||
p["xp"]["prayer"] = game.XP_TABLE[level]
|
||||
p["xp"]["combat"] = game.XP_TABLE[combat]
|
||||
p["hp"] = game.max_hp(p)
|
||||
return world, p
|
||||
|
||||
def test_burying_bones_gives_points_and_xp(self):
|
||||
world, p = self.priest()
|
||||
p["bank"] = {"bones": 5}
|
||||
game.start_action(world, p, "bury_bones", T0)
|
||||
game.process_player(world, p, T0 + 100, random.Random(1))
|
||||
self.assertEqual(p["pp"], 10)
|
||||
self.assertEqual(p["xp"]["prayer"], game.XP_TABLE[1] + 20)
|
||||
world["city"]["buildings"]["temple"]["level"] = 2
|
||||
self.assertEqual(game.bone_points(world, game.ACTION_BY_ID["bury_bones"]), 4)
|
||||
|
||||
def test_choosing_prayers(self):
|
||||
world, p = self.priest(level=10)
|
||||
self.assertEqual(game.set_prayers(p, ["steel_skin"]), "Steel Skin needs prayer level 20")
|
||||
self.assertEqual(game.set_prayers(p, ["thick_skin", "burst_of_strength", "rapid_heal"]), "At most 2 prayers at once")
|
||||
self.assertIsNone(game.set_prayers(p, ["thick_skin", "burst_of_strength"]))
|
||||
|
||||
def test_prayers_cost_points_cut_damage_and_train_prayer(self):
|
||||
world, p = self.priest(level=10)
|
||||
scouts = game.ACTION_BY_ID["fight_scouts"]
|
||||
plain = game.fight_damage(p, scouts)
|
||||
game.set_prayers(p, ["thick_skin", "burst_of_strength"])
|
||||
p["pp"] = 4
|
||||
blessed = game.blessing(p)
|
||||
self.assertEqual(blessed["cost"], 2)
|
||||
self.assertLess(game.fight_damage(p, scouts, blessed), plain * 0.9)
|
||||
p["bank"] = {"bread": 200}
|
||||
game.start_action(world, p, "fight_scouts", T0)
|
||||
summary = game.process_player(world, p, T0 + 600, random.Random(1))
|
||||
self.assertEqual(p["pp"], 0)
|
||||
self.assertEqual(summary["pp_spent"], 4)
|
||||
self.assertTrue(summary["prayer_out"])
|
||||
self.assertEqual(p["xp"]["prayer"], game.XP_TABLE[10] + 4 * game.PRAYER_XP_PER_POINT)
|
||||
|
||||
def test_second_wind_saves_one_retreat(self):
|
||||
world, p = self.priest(level=40, combat=10)
|
||||
game.set_prayers(p, ["second_wind"])
|
||||
p["pp"] = 1000
|
||||
game.start_action(world, p, "fight_scouts", T0)
|
||||
summary = game.process_player(world, p, T0 + 6 * 3600, random.Random(1))
|
||||
self.assertEqual(summary["second_wind"], 1)
|
||||
self.assertTrue(summary["stopped"].startswith("Retreated"))
|
||||
|
||||
def test_offerings_ward_the_city_until_the_raid(self):
|
||||
world, p = self.priest(level=15)
|
||||
world["city"]["buildings"]["temple"]["level"] = 1
|
||||
p["bank"] = {"big_bones": 10}
|
||||
game.start_action(world, p, "offer_big_bones", T0)
|
||||
game.process_player(world, p, T0 + 1000, random.Random(1))
|
||||
self.assertEqual(world["city"]["devotion"], 10 * 6 * 1.25)
|
||||
self.assertEqual(game.defence(world)["parts"]["ward"], min(75 / 4, 15))
|
||||
world["next_event_at"] = T0
|
||||
game.tick(world, T0 + 1000, random.Random(2))
|
||||
game.tick(world, game.upcoming_raid(world)["fire_at"], random.Random(1))
|
||||
self.assertEqual(world["city"]["devotion"], 0)
|
||||
|
||||
def test_offering_needs_a_temple(self):
|
||||
world, p = self.priest()
|
||||
p["bank"] = {"bones": 1}
|
||||
self.assertEqual(game.start_action(world, p, "offer_bones", T0), "Needs Temple level 1")
|
||||
|
||||
def test_v4_worlds_get_prayer(self):
|
||||
world = world_with(("fred", "pioneer"))
|
||||
world["version"] = 4
|
||||
p = world["players"]["fred"]
|
||||
del p["pp"], p["prayers"], p["xp"]["prayer"]
|
||||
del world["city"]["buildings"]["temple"]
|
||||
game.migrate(world, T0)
|
||||
self.assertEqual((p["pp"], p["prayers"], p["xp"]["prayer"]), (0, [], 0))
|
||||
self.assertEqual(world["city"]["buildings"]["temple"]["level"], 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue