Regions: each new town favours its gathering trades, common materials most
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ad5317e554
commit
01df1924c0
4 changed files with 102 additions and 15 deletions
|
|
@ -3607,8 +3607,8 @@ class KingdomTest(unittest.TestCase):
|
|||
city["treasury"] = 10000.0
|
||||
city["stockpile"]["provisions"] = 500
|
||||
|
||||
def found(self, name="Saltmere", now=T0):
|
||||
self.assertIsNone(game.propose_charter(self.world, self.a, name, now))
|
||||
def found(self, name="Saltmere", now=T0, region="coast"):
|
||||
self.assertIsNone(game.propose_charter(self.world, self.a, name, region, now))
|
||||
self.assertIsNone(game.sign_charter(self.world, self.b, now))
|
||||
return self.world.at(game._slug(name))
|
||||
|
||||
|
|
@ -3617,7 +3617,7 @@ class KingdomTest(unittest.TestCase):
|
|||
return now + game.TRAVEL_TIME
|
||||
|
||||
def test_a_charter_needs_a_second_founder(self):
|
||||
game.propose_charter(self.world, self.a, "Saltmere", T0)
|
||||
game.propose_charter(self.world, self.a, "Saltmere", "coast", T0)
|
||||
self.assertEqual(len(self.world.doc["cities"]), 1)
|
||||
self.assertIsNotNone(game.sign_charter(self.world, self.a, T0))
|
||||
self.assertIsNone(game.sign_charter(self.world, self.b, T0))
|
||||
|
|
@ -3634,7 +3634,7 @@ class KingdomTest(unittest.TestCase):
|
|||
|
||||
def test_only_a_full_city_can_found(self):
|
||||
self.world["city"]["tier"] = 2
|
||||
self.assertIn("city", game.propose_charter(self.world, self.a, "Saltmere", T0))
|
||||
self.assertIn("city", game.propose_charter(self.world, self.a, "Saltmere", "coast", T0))
|
||||
|
||||
def test_travel_pauses_work_and_arrives_with_the_pouch(self):
|
||||
new = self.found()
|
||||
|
|
@ -3781,6 +3781,51 @@ class KingdomTest(unittest.TestCase):
|
|||
self.assertEqual(self.a["banks"][game.HOME_CITY]["stone"], 5)
|
||||
self.assertNotIn("stone", self.a["bank"])
|
||||
|
||||
def test_every_gathering_trade_has_a_region(self):
|
||||
self.assertEqual({skill for region in game.REGIONS.values() for skill in region["skills"]}, game.GATHERING)
|
||||
|
||||
def test_one_town_to_a_region(self):
|
||||
self.found()
|
||||
self.assertIn("already", game.propose_charter(self.world, self.a, "Brine", "coast", T0))
|
||||
self.assertIsNone(game.propose_charter(self.world, self.a, "Brine", "forest", T0))
|
||||
|
||||
def test_a_region_favours_its_own_trades_and_common_stuff(self):
|
||||
hills = self.found(region="mountains")
|
||||
action = game.ACTION_BY_ID
|
||||
self.assertEqual(game.region_yield(hills, action["mine_stone"]), 1.5)
|
||||
self.assertEqual(game.region_yield(hills, action["mine_copper"]), 1.5)
|
||||
self.assertEqual(game.region_yield(hills, action["mine_runite"]), 1.05)
|
||||
self.assertEqual(game.region_yield(hills, action["cut_logs"] if "cut_logs" in action else next(a for a in game.ACTIONS if a["skill"] == "woodcutting")), 1.0)
|
||||
self.assertEqual(game.region_yield(self.world, action["mine_copper"]), 1.0)
|
||||
|
||||
def test_the_bonus_grows_with_the_town(self):
|
||||
hills = self.found(region="mountains")
|
||||
hills["city"]["tier"] = len(game.TIERS) - 1
|
||||
self.assertEqual(game.region_yield(hills, game.ACTION_BY_ID["mine_copper"]), 2.0)
|
||||
|
||||
def test_a_region_pays_more_ore_but_the_same_xp(self):
|
||||
hills = self.found(region="mountains")
|
||||
hills["city"]["tier"] = len(game.TIERS) - 1
|
||||
self.a["cls"] = "builder"
|
||||
home = game.new_player("c", "Cy", "builder", T0)
|
||||
self.world["players"]["c"] = home
|
||||
self.a["at"] = hills.here
|
||||
action = game.ACTION_BY_ID["mine_copper"]
|
||||
for player, world in ((self.a, hills), (home, self.world)):
|
||||
for _ in range(10):
|
||||
game._finish_action(world, player, action, T0, random.Random(3), game.empty_summary())
|
||||
self.assertEqual(self.a["bank"]["copper_ore"], 2 * home["bank"]["copper_ore"])
|
||||
self.assertEqual(self.a["xp"]["mining"], home["xp"]["mining"])
|
||||
|
||||
def test_a_filled_order_goes_to_your_bank_in_its_town(self):
|
||||
new = self.found()
|
||||
order = {"id": 1, "by": "a", "item": "stone", "held": 40}
|
||||
self.a["at"] = new.here
|
||||
game._hand_over(self.world, order, self.a, T0)
|
||||
self.assertEqual(order["held"], 0)
|
||||
self.assertEqual(self.a["banks"][game.HOME_CITY]["stone"], 40)
|
||||
self.assertNotIn("stone", self.a["bank"])
|
||||
|
||||
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