Favour per town; bank slot prices restart in each town
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
22635504e8
commit
a4c9977e5c
4 changed files with 146 additions and 28 deletions
|
|
@ -2156,13 +2156,13 @@ class GoldTest(unittest.TestCase):
|
|||
|
||||
def test_rented_slots_cost_more_each_time(self):
|
||||
before = game.bank_slots(self.world, self.ann)
|
||||
self.assertEqual([game.rent_cost({"rented": n}) for n in range(4)], [1000, 1350, 1800, 2450])
|
||||
self.assertIsNone(game.rent_slot(self.ann))
|
||||
self.assertIsNone(game.rent_slot(self.ann))
|
||||
self.assertEqual([game.rent_cost(self.world, {"rented": n, "town_rented": {}}) for n in range(4)], [1000, 1350, 1800, 2450])
|
||||
self.assertIsNone(game.rent_slot(self.world, self.ann))
|
||||
self.assertIsNone(game.rent_slot(self.world, self.ann))
|
||||
self.assertEqual(game.bank_slots(self.world, self.ann), before + 2)
|
||||
self.assertEqual(self.ann["gold"], 200_000 - 2350)
|
||||
self.ann["gold"] = 0
|
||||
self.assertEqual(game.rent_slot(self.ann), "Needs 1,800 gold")
|
||||
self.assertEqual(game.rent_slot(self.world, self.ann), "Needs 1,800 gold")
|
||||
|
||||
def test_caravan_comes_on_the_prep_day_and_sells_once_per_visit(self):
|
||||
self.world["next_event_at"] = T0
|
||||
|
|
@ -4041,6 +4041,91 @@ class KingdomTest(unittest.TestCase):
|
|||
threat["recon"] = 10**6
|
||||
self.assertIn("main", game.event_view(world, threat, threat["fire_at"] - 3600))
|
||||
|
||||
def test_favour_stays_in_the_town_it_was_earned_in(self):
|
||||
new = self.found()
|
||||
self.a["favour"] = 1000
|
||||
arrive = self.go(self.a, new.here)
|
||||
self.assertEqual(self.a["favour"], 1000) # still yours until you leave the road
|
||||
game.process_player(self.world, self.a, arrive)
|
||||
self.assertEqual(self.a["favour"], 0)
|
||||
self.assertEqual(self.a["town_favour"][game.HOME_CITY], 1000)
|
||||
self.a["favour"] = 40
|
||||
back = self.go(self.a, game.HOME_CITY, now=arrive)
|
||||
game.process_player(self.world, self.a, back)
|
||||
self.assertEqual(self.a["favour"], 1000)
|
||||
self.assertEqual(self.a["town_favour"][new.here], 40)
|
||||
self.assertEqual(game.favour_saved(self.a), 1040)
|
||||
|
||||
def test_you_cant_spend_another_towns_favour(self):
|
||||
new = self.found()
|
||||
self.a["favour"], self.a["at"] = 0, new.here
|
||||
self.a["town_favour"][game.HOME_CITY] = 10**6
|
||||
self.assertIn("favour", game.buy_perk(new, self.a, "bank_slot"))
|
||||
|
||||
def test_favour_slot_prices_restart_per_town(self):
|
||||
new = self.found()
|
||||
self.a["perks"]["bank_slot"] = 8
|
||||
self.a["at"] = new.here
|
||||
self.assertEqual(game.perk_cost(self.world, self.a, "bank_slot"), 128000)
|
||||
self.assertEqual(game.perk_cost(new, self.a, "bank_slot"), 500)
|
||||
self.a["favour"] = 1500
|
||||
self.assertIsNone(game.buy_perk(new, self.a, "bank_slot"))
|
||||
self.assertEqual(game.perk_cost(new, self.a, "bank_slot"), 1000)
|
||||
self.assertEqual(self.a["favour"], 1000)
|
||||
self.assertEqual(game.perk_cost(self.world, self.a, "bank_slot"), 128000)
|
||||
|
||||
def test_new_favour_slots_work_only_in_their_town_old_ones_everywhere(self):
|
||||
new = self.found()
|
||||
self.a["perks"]["bank_slot"] = 8
|
||||
here, there = game.bank_slots(new, self.a), game.bank_slots(self.world, self.a)
|
||||
self.a["favour"], self.a["at"] = 500, new.here
|
||||
game.buy_perk(new, self.a, "bank_slot")
|
||||
self.assertEqual(game.bank_slots(new, self.a), here + 1)
|
||||
self.assertEqual(game.bank_slots(self.world, self.a), there)
|
||||
self.assertGreaterEqual(here, 8 + game.BASE_SLOTS)
|
||||
|
||||
def test_a_helper_who_moved_on_earns_favour_where_the_order_was(self):
|
||||
new = self.found()
|
||||
self.a["at"] = new.here
|
||||
order = {"item": "stone", "favour": {}}
|
||||
game._to_city(self.world, order, self.b, 5, T0, {"a": {"stone": 5}})
|
||||
self.assertGreater(self.a["town_favour"][game.HOME_CITY], 0)
|
||||
self.assertEqual(self.a["favour"], 0)
|
||||
|
||||
def test_saved_favour_counts_as_the_first_towns(self):
|
||||
new = self.found()
|
||||
doc = json.loads(json.dumps(self.world.doc))
|
||||
doc["version"] = 41
|
||||
for player in doc["players"].values():
|
||||
del player["town_favour"], player["town_slots"], player["town_rented"]
|
||||
doc["players"]["a"].update(favour=700, at=new.here)
|
||||
doc["players"]["b"].update(favour=300)
|
||||
world = game.migrate(doc, T0)
|
||||
a, b = world["players"]["a"], world["players"]["b"]
|
||||
self.assertEqual((a["favour"], a["town_favour"][game.HOME_CITY]), (0, 700))
|
||||
self.assertEqual((b["favour"], b["town_favour"]), (300, {}))
|
||||
|
||||
def test_gold_slot_prices_restart_per_town(self):
|
||||
new = self.found()
|
||||
self.a["rented"], self.a["gold"], self.a["at"] = 12, 5000, new.here
|
||||
expensive = game.rent_cost(self.world, self.a)
|
||||
self.assertEqual(game.rent_cost(new, self.a), game.RENT_BASE)
|
||||
here, there = game.bank_slots(new, self.a), game.bank_slots(self.world, self.a)
|
||||
self.assertIsNone(game.rent_slot(new, self.a))
|
||||
self.assertEqual(self.a["gold"], 4000)
|
||||
self.assertGreater(game.rent_cost(new, self.a), game.RENT_BASE)
|
||||
self.assertEqual(game.rent_cost(self.world, self.a), expensive)
|
||||
self.assertEqual(game.bank_slots(new, self.a), here + 1)
|
||||
self.assertEqual(game.bank_slots(self.world, self.a), there)
|
||||
|
||||
def test_slots_rented_in_a_town_shield_its_bank(self):
|
||||
new = self.found()
|
||||
self.a["at"] = new.here
|
||||
self.a["bank"] = {"stone": 1000}
|
||||
self.a["town_rented"][new.here] = game.bank_slots(new, self.a) # half the slots
|
||||
game._loot_banks(new, {"slot": 5}, 0.4, T0)
|
||||
self.assertEqual(self.a["bank"]["stone"], 900)
|
||||
|
||||
def test_old_saves_gain_towns(self):
|
||||
doc = json.loads(json.dumps(self.world.doc))
|
||||
doc["version"] = 39
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue