Skip to content

Commit

Permalink
(Aegis) model YETI worker yard as multi-booster primary
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Oct 26, 2023
1 parent 117ccc6 commit b10fbe6
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 93 deletions.
60 changes: 30 additions & 30 deletions industry/economies/firs_arctic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from industry.lib.economy import Economy, PrimaryIndustry, SecondaryIndustry, TertiaryIndustry, Town
from industry.lib.economy import Economy, PrimaryIndustry, WorkerYard, SecondaryIndustry, TertiaryIndustry, Town
from industry.cargos import (
ammonia,
china_clay,
Expand Down Expand Up @@ -93,57 +93,57 @@ def get_economy(self, parameters):

if parameters["BOOSTER"] == "UNIVERSAL":
if ammonia_plant in ret.graph:
ret.graph[ammonia_plant].booster = engineering_supplies
ret.graph[ammonia_plant].boosters = engineering_supplies
if clay_pit in ret.graph:
ret.graph[clay_pit].booster = engineering_supplies
ret.graph[peatlands].booster = engineering_supplies
ret.graph[phosphate_mine].booster = engineering_supplies
ret.graph[potash_mine].booster = engineering_supplies
ret.graph[pyrite_mine].booster = engineering_supplies
ret.graph[clay_pit].boosters = engineering_supplies
ret.graph[peatlands].boosters = engineering_supplies
ret.graph[phosphate_mine].boosters = engineering_supplies
ret.graph[potash_mine].boosters = engineering_supplies
ret.graph[pyrite_mine].boosters = engineering_supplies

ret.graph[fish_farm].booster = engineering_supplies
ret.graph[forest].booster = engineering_supplies
ret.graph[herding_coop].booster = engineering_supplies
ret.graph[fish_farm].boosters = engineering_supplies
ret.graph[forest].boosters = engineering_supplies
ret.graph[herding_coop].boosters = engineering_supplies

ret.graph[paper_mill].produces += (engineering_supplies,)
elif parameters["BOOSTER"] == "GENERIC":
if ammonia_plant in ret.graph:
ret.graph[ammonia_plant].booster = engineering_supplies
ret.graph[ammonia_plant].boosters = engineering_supplies
if clay_pit in ret.graph:
ret.graph[clay_pit].booster = engineering_supplies
ret.graph[peatlands].booster = engineering_supplies
ret.graph[phosphate_mine].booster = engineering_supplies
ret.graph[potash_mine].booster = engineering_supplies
ret.graph[pyrite_mine].booster = engineering_supplies
ret.graph[clay_pit].boosters = engineering_supplies
ret.graph[peatlands].boosters = engineering_supplies
ret.graph[phosphate_mine].boosters = engineering_supplies
ret.graph[potash_mine].boosters = engineering_supplies
ret.graph[pyrite_mine].boosters = engineering_supplies

ret.graph[fish_farm].booster = farm_supplies
ret.graph[forest].booster = farm_supplies
ret.graph[herding_coop].booster = farm_supplies
ret.graph[fish_farm].boosters = farm_supplies
ret.graph[forest].boosters = farm_supplies
ret.graph[herding_coop].boosters = farm_supplies

ret.graph[paper_mill].produces += (engineering_supplies,)
ret.graph[chemical_plant].produces += (farm_supplies,)
elif parameters["BOOSTER"] == "GENERIC_PASSENGERS":
if ammonia_plant in ret.graph:
ret.graph[ammonia_plant].booster = engineering_supplies
ret.graph[ammonia_plant].boosters = engineering_supplies
if clay_pit in ret.graph:
ret.graph[clay_pit].booster = engineering_supplies
ret.graph[peatlands].booster = engineering_supplies
ret.graph[phosphate_mine].booster = engineering_supplies
ret.graph[potash_mine].booster = engineering_supplies
ret.graph[pyrite_mine].booster = engineering_supplies
ret.graph[clay_pit].boosters = engineering_supplies
ret.graph[peatlands].boosters = engineering_supplies
ret.graph[phosphate_mine].boosters = engineering_supplies
ret.graph[potash_mine].boosters = engineering_supplies
ret.graph[pyrite_mine].boosters = engineering_supplies

ret.graph[fish_farm].booster = farm_supplies
ret.graph[forest].booster = farm_supplies
ret.graph[herding_coop].booster = farm_supplies
ret.graph[fish_farm].boosters = farm_supplies
ret.graph[forest].boosters = farm_supplies
ret.graph[herding_coop].boosters = farm_supplies

ret.graph[paper_mill].produces += (engineering_supplies,)
ret.graph[chemical_plant].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
ret.graph[worker_yard] = PrimaryIndustry(workers)
ret.graph[worker_yard] = WorkerYard(workers, boosters=(paper, zinc))

# FIXME
ret.graph[peatlands].booster = workers
ret.graph[peatlands].boosters = workers

if port in ret.graph:
if parameters["LAND_PORTS"] == "LAND_ONLY":
Expand Down
24 changes: 12 additions & 12 deletions industry/economies/firs_temperate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from industry.lib.economy import Economy, PrimaryIndustry, SecondaryIndustry, TertiaryIndustry, Town
from industry.lib.economy import Economy, PrimaryIndustry, WorkerYard, SecondaryIndustry, TertiaryIndustry, Town
from industry.cargos import (
alcohol,
chemicals,
Expand Down Expand Up @@ -88,29 +88,29 @@ def get_economy(self, parameters):
# del ret.graph[clay_pit]

if parameters["BOOSTER"] == "UNIVERSAL":
ret.graph[clay_pit].booster = engineering_supplies
ret.graph[fish_farm].booster = engineering_supplies
ret.graph[orchard_and_piggery].booster = engineering_supplies
ret.graph[clay_pit].boosters = engineering_supplies
ret.graph[fish_farm].boosters = engineering_supplies
ret.graph[orchard_and_piggery].boosters = engineering_supplies

ret.graph[cider_mill].produces += (engineering_supplies,)
elif parameters["BOOSTER"] == "GENERIC":
ret.graph[clay_pit].booster = engineering_supplies
ret.graph[fish_farm].booster = farm_supplies
ret.graph[orchard_and_piggery].booster = farm_supplies
ret.graph[clay_pit].boosters = engineering_supplies
ret.graph[fish_farm].boosters = farm_supplies
ret.graph[orchard_and_piggery].boosters = farm_supplies

ret.graph[cider_mill].produces += (engineering_supplies, farm_supplies)
elif parameters["BOOSTER"] == "GENERIC_PASSENGERS":
ret.graph[clay_pit].booster = engineering_supplies
ret.graph[fish_farm].booster = farm_supplies
ret.graph[orchard_and_piggery].booster = farm_supplies
ret.graph[clay_pit].boosters = engineering_supplies
ret.graph[fish_farm].boosters = farm_supplies
ret.graph[orchard_and_piggery].boosters = farm_supplies

ret.graph[cider_mill].produces += (engineering_supplies, farm_supplies)

if parameters["WORKFORCE"].startswith("YETI"):
ret.graph[worker_yard] = PrimaryIndustry(workers)
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, alcohol))

# FIXME
ret.graph[orchard_and_piggery].booster = workers
ret.graph[orchard_and_piggery].boosters = workers

if port in ret.graph:
if parameters["LAND_PORTS"] == "LAND_ONLY":
Expand Down
36 changes: 18 additions & 18 deletions industry/economies/vanilla_subarctic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from industry.lib.economy import Economy, PrimaryIndustry, SecondaryIndustry, TertiaryIndustry, Town
from industry.lib.economy import Economy, PrimaryIndustry, WorkerYard, SecondaryIndustry, TertiaryIndustry, Town
from industry.cargos import (
coal,
food,
Expand Down Expand Up @@ -72,37 +72,37 @@ def get_economy(self, parameters):
del ret.graph[paper_mill]

if parameters["BOOSTER"] == "UNIVERSAL":
ret.graph[coal_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = engineering_supplies
ret.graph[gold_mine].booster = engineering_supplies
ret.graph[farm].booster = engineering_supplies
ret.graph[forest].booster = engineering_supplies
ret.graph[coal_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = engineering_supplies
ret.graph[gold_mine].boosters = engineering_supplies
ret.graph[farm].boosters = engineering_supplies
ret.graph[forest].boosters = engineering_supplies

ret.graph[printing_works].produces += (engineering_supplies,)
elif parameters["BOOSTER"] == "GENERIC":
ret.graph[coal_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = engineering_supplies
ret.graph[gold_mine].booster = engineering_supplies
ret.graph[farm].booster = farm_supplies
ret.graph[forest].booster = farm_supplies
ret.graph[coal_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = engineering_supplies
ret.graph[gold_mine].boosters = engineering_supplies
ret.graph[farm].boosters = farm_supplies
ret.graph[forest].boosters = farm_supplies

ret.graph[printing_works].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)
elif parameters["BOOSTER"] == "GENERIC_PASSENGERS":
ret.graph[coal_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = passengers
ret.graph[gold_mine].booster = engineering_supplies
ret.graph[farm].booster = farm_supplies
ret.graph[forest].booster = farm_supplies
ret.graph[coal_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = passengers
ret.graph[gold_mine].boosters = engineering_supplies
ret.graph[farm].boosters = farm_supplies
ret.graph[forest].boosters = farm_supplies

ret.graph[printing_works].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
ret.graph[worker_yard] = PrimaryIndustry(workers)
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, gold))

# FIXME
ret.graph[coal_mine].booster = workers
ret.graph[coal_mine].boosters = workers

if port in ret.graph:
if parameters["LAND_PORTS"] == "LAND_ONLY":
Expand Down
26 changes: 13 additions & 13 deletions industry/economies/vanilla_subtropical.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from industry.lib.economy import Economy, PrimaryIndustry, SecondaryIndustry, TertiaryIndustry, Town
from industry.lib.economy import Economy, PrimaryIndustry, WorkerYard, SecondaryIndustry, TertiaryIndustry, Town
from industry.cargos import (
copper_ore,
food,
Expand Down Expand Up @@ -58,27 +58,27 @@ def get_economy(self, parameters):
parameters,
)
if parameters["BOOSTER"] == "UNIVERSAL":
ret.graph[diamond_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = engineering_supplies
ret.graph[copper_ore_mine].booster = engineering_supplies
ret.graph[farm].booster = engineering_supplies
ret.graph[lumber_mill].booster = engineering_supplies
ret.graph[diamond_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = engineering_supplies
ret.graph[copper_ore_mine].boosters = engineering_supplies
ret.graph[farm].boosters = engineering_supplies
ret.graph[lumber_mill].boosters = engineering_supplies

ret.graph[factory].produces += (engineering_supplies,)
elif parameters["BOOSTER"] == "GENERIC":
ret.graph[diamond_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = engineering_supplies
ret.graph[copper_ore_mine].booster = engineering_supplies
ret.graph[farm].booster = farm_supplies
ret.graph[lumber_mill].booster = farm_supplies
ret.graph[diamond_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = engineering_supplies
ret.graph[copper_ore_mine].boosters = engineering_supplies
ret.graph[farm].boosters = farm_supplies
ret.graph[lumber_mill].boosters = farm_supplies

ret.graph[factory].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
ret.graph[worker_yard] = PrimaryIndustry(workers)
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, diamonds))
# FIXME
ret.graph[diamond_mine].booster = workers
ret.graph[diamond_mine].boosters = workers

if parameters["TOWN_GOODS"] in ("ORGANIC", "SUBTROPICAL"):
ret.graph[water_supply] = PrimaryIndustry(water)
Expand Down
30 changes: 15 additions & 15 deletions industry/economies/vanilla_temperate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from industry.lib.economy import Economy, PrimaryIndustry, SecondaryIndustry, TertiaryIndustry, Town
from industry.lib.economy import Economy, PrimaryIndustry, WorkerYard, SecondaryIndustry, TertiaryIndustry, Town
from industry.cargos import (
valuables,
coal,
Expand Down Expand Up @@ -62,29 +62,29 @@ def get_economy(self, parameters):
parameters,
)
if parameters["BOOSTER"] == "UNIVERSAL":
ret.graph[coal_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = engineering_supplies
ret.graph[oil_rig].booster = engineering_supplies
ret.graph[iron_ore_mine].booster = engineering_supplies
ret.graph[farm].booster = engineering_supplies
ret.graph[forest].booster = engineering_supplies
ret.graph[coal_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = engineering_supplies
ret.graph[oil_rig].boosters = engineering_supplies
ret.graph[iron_ore_mine].boosters = engineering_supplies
ret.graph[farm].boosters = engineering_supplies
ret.graph[forest].boosters = engineering_supplies

ret.graph[factory].produces += (engineering_supplies,)
elif parameters["BOOSTER"] == "GENERIC":
ret.graph[coal_mine].booster = engineering_supplies
ret.graph[oil_wells].booster = engineering_supplies
ret.graph[oil_rig].booster = engineering_supplies
ret.graph[iron_ore_mine].booster = engineering_supplies
ret.graph[farm].booster = farm_supplies
ret.graph[forest].booster = farm_supplies
ret.graph[coal_mine].boosters = engineering_supplies
ret.graph[oil_wells].boosters = engineering_supplies
ret.graph[oil_rig].boosters = engineering_supplies
ret.graph[iron_ore_mine].boosters = engineering_supplies
ret.graph[farm].boosters = farm_supplies
ret.graph[forest].boosters = farm_supplies

ret.graph[factory].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
ret.graph[worker_yard] = PrimaryIndustry(workers)
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, valuables))
# FIXME
ret.graph[coal_mine].booster = workers
ret.graph[coal_mine].boosters = workers

if parameters["TOWN_GOODS"] in ("SUBARCTIC", "SUBTROPICAL"):
ret.graph[food_processing_plant] = SecondaryIndustry(
Expand Down
21 changes: 17 additions & 4 deletions industry/lib/economy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,35 @@ def translated_produces(self):


class PrimaryIndustry(Industry):
def __init__(self, produces=(), extra_accepts=(), booster=None):
def __init__(self, produces=(), extra_accepts=(), boosters=()):
self.produces = make_tuple(produces)
self.extra_accepts = make_tuple(extra_accepts)
self.booster = booster
self._boosters = make_tuple(boosters)

def copy(self):
return PrimaryIndustry(self.produces, self.extra_accepts, self.booster)
return PrimaryIndustry(self.produces, self.extra_accepts, self.boosters)

@property
def accepts(self):
return self.extra_accepts + optional_to_tuple(self.booster)
return self.extra_accepts + self.boosters

@property
def consumes(self):
return ()

@property
def boosters(self):
return self._boosters

@boosters.setter
def boosters(self, new_boosters):
self._boosters = make_tuple(new_boosters)


class WorkerYard(PrimaryIndustry):
def __init__(self, produces=(), extra_accepts=(), boosters=()):
super().__init__(produces, extra_accepts, boosters)


class SecondaryIndustry(Industry):
def __init__(self, consumes=(), produces=()):
Expand Down
12 changes: 11 additions & 1 deletion industry/lib/validator/yeti.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from industry.lib.economy import WorkerYard
from industry.industries import worker_yard


def check_yeti(economy):
if economy.parameters["WORKFORCE"] in ("YETI", "YETI_PASSENGERS", "YETI_MAIL", "YETI_TIRED"):
assert any(x.name == "Worker Yard" for x in economy.industries)
assert worker_yard in economy.industries

conf = economy.graph[worker_yard]
assert isinstance(conf, WorkerYard)

if economy.parameters["WORKFORCE"] == "YETI":
assert len(conf.boosters) == 2

0 comments on commit b10fbe6

Please sign in to comment.