Skip to content

Commit

Permalink
(Aegis) Continue refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Nov 23, 2023
1 parent e865b65 commit 2e127b0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 80 deletions.
34 changes: 7 additions & 27 deletions industry/economies/vanilla_subarctic.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,13 @@ def get_economy(self, parameters):
ret.graph[printing_works].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, gold))
if parameters["WORKFORCE"] == "YETI":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, gold))
elif parameters["WORKFORCE"] == "YETI_PASSENGERS":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, gold, passengers))
elif parameters["WORKFORCE"] == "YETI_MAIL":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, gold, mail))
elif parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, gold, tired_workers))

# FIXME: remove PRESET
if parameters["WORKER_PARTICIPATION"] in ("PRESET", "NONE"):
ret.graph[coal_mine].boosters = workers
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[coal_mine].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("PRIMARY_INDUSTRY", "BOTH"):
for i in [coal_mine, oil_wells, gold_mine, farm, forest]:
ret.graph[i] = ret.graph[i].to_secondary(workers)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("SECONDARY_INDUSTRY", "BOTH"):
for i in [food_processing_plant, paper_mill, oil_refinery, printing_works]:
if i in ret.graph:
ret.graph[i].boosters += (workers,)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)
self.default_worker_support(
ret,
(goods, gold),
(coal_mine,),
(coal_mine, oil_wells, gold_mine, farm, forest),
(food_processing_plant, paper_mill, oil_refinery, printing_works),
)

if port in ret.graph:
if parameters["SEA_INDUSTRY"] == "LAND_ONLY":
Expand Down
32 changes: 7 additions & 25 deletions industry/economies/vanilla_subtropical.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,13 @@ def get_economy(self, parameters):
ret.graph[factory].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
if parameters["WORKFORCE"] == "YETI":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, diamonds))
elif parameters["WORKFORCE"] == "YETI_PASSENGERS":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, diamonds, passengers))
elif parameters["WORKFORCE"] == "YETI_MAIL":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, diamonds, mail))
elif parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, diamonds, tired_workers))

# FIXME: remove PRESET; support SECONDARY
if parameters["WORKER_PARTICIPATION"] in ("PRESET", "NONE"):
ret.graph[diamond_mine].boosters = workers
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[diamond_mine].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("SECONDARY_INDUSTRY", "BOTH"):
for i in [diamond_mine, oil_wells, copper_ore_mine, farm, lumber_mill]:
ret.graph[i] = ret.graph[i].to_secondary(workers)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("PRIMARY_INDUSTRY", "BOTH"):
for i in [food_processing_plant, oil_refinery, factory]:
ret.graph[i].boosters += (workers,)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)
self.default_worker_support(
ret,
(goods, diamonds),
(diamond_mine,),
(diamond_mine, oil_wells, copper_ore_mine, farm, lumber_mill),
(food_processing_plant, oil_refinery, factory),
)

if parameters["TOWN_GOODS"] in ("ORGANIC", "FOOD_AND_WATER"):
ret.graph[water_supply] = PrimaryIndustry(water)
Expand Down
32 changes: 7 additions & 25 deletions industry/economies/vanilla_temperate.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,13 @@ def get_economy(self, parameters):
ret.graph[factory].produces += (engineering_supplies,)
ret.graph[oil_refinery].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
if parameters["WORKFORCE"] == "YETI":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, valuables))
elif parameters["WORKFORCE"] == "YETI_PASSENGERS":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, valuables, passengers))
elif parameters["WORKFORCE"] == "YETI_MAIL":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, valuables, mail))
elif parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(goods, valuables, tired_workers))

# FIXME: remove PRESET
if parameters["WORKER_PARTICIPATION"] in ("PRESET", "NONE"):
ret.graph[coal_mine].boosters = workers
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[coal_mine].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("PRIMARY_INDUSTRY", "BOTH"):
for i in [coal_mine, oil_wells, oil_rig, iron_ore_mine, farm, forest]:
ret.graph[i] = ret.graph[i].to_secondary(workers)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("SECONDARY_INDUSTRY", "BOTH"):
for i in [factory, oil_refinery, sawmill, steel_mill]:
ret.graph[i].boosters += (workers,)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)
self.default_worker_support(
ret,
(goods, valuables),
(oil_wells,),
(coal_mine, oil_wells, oil_rig, iron_ore_mine, farm, forest),
(factory, oil_refinery, sawmill, steel_mill),
)

if parameters["TOWN_GOODS"] in ("FOOD", "FOOD_AND_WATER"):
ret.graph[food_processing_plant] = SecondaryIndustry((livestock, grain), food)
Expand Down
7 changes: 4 additions & 3 deletions industry/lib/economy/worker_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def default_worker_support(economy, yeti_boosters, special_destinations, primary
economy.graph[i].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("SECONDARY_INDUSTRY", "BOTH"):
for i in secondary_industries:
economy.graph[i].boosters += (workers,)
if parameters["WORKFORCE"] == "YETI_TIRED":
economy.graph[i].produces += (tired_workers,)
if i in economy.graph:
economy.graph[i].boosters += (workers,)
if parameters["WORKFORCE"] == "YETI_TIRED":
economy.graph[i].produces += (tired_workers,)

0 comments on commit 2e127b0

Please sign in to comment.