Skip to content

Commit

Permalink
(Aegis) unify SplitDefinition format
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Nov 14, 2023
1 parent 01e712b commit bafeb7c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 36 deletions.
18 changes: 9 additions & 9 deletions industry/industries/farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@
translation_name="FARM",
override_type=0x09,
layouts=SplitDefinition(
"INDUSTRY_SIZE",
("INDUSTRY_SIZE",),
{
"ENORMOUS": transcribe(large_set, tile_map),
"HUGE": transcribe(large_set, tile_map),
"LARGE": transcribe(large_set, tile_map),
"MEDIUM": transcribe(medium_set, tile_map),
"SMALL": transcribe(small_set, tile_map),
"TINY": transcribe(tiny_set, tile_map),
"ONE_TILE": transcribe(one_tile_set, tile_map),
"ONE_TILE_FLAT": [[{"xofs": 0, "yofs": 0, "gfx": grf.NewIndustryTileID(0x23)}]],
("ENORMOUS",): transcribe(large_set, tile_map),
("HUGE",): transcribe(large_set, tile_map),
("LARGE",): transcribe(large_set, tile_map),
("MEDIUM",): transcribe(medium_set, tile_map),
("SMALL",): transcribe(small_set, tile_map),
("TINY",): transcribe(tiny_set, tile_map),
("ONE_TILE",): transcribe(one_tile_set, tile_map),
("ONE_TILE_FLAT",): [[{"xofs": 0, "yofs": 0, "gfx": grf.NewIndustryTileID(0x23)}]],
},
),
mapgen_probability=15,
Expand Down
18 changes: 9 additions & 9 deletions industry/industries/forest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
translation_name="FOREST",
override_type=0x03,
layouts=SplitDefinition(
"INDUSTRY_SIZE",
("INDUSTRY_SIZE",),
{
"ENORMOUS": transcribe(enormous_set, tile_map),
"HUGE": transcribe(huge_set, tile_map),
"LARGE": transcribe(large_set, tile_map),
"MEDIUM": transcribe(medium_set, tile_map),
"SMALL": transcribe(small_set, tile_map),
"TINY": transcribe(tiny_set, tile_map),
"ONE_TILE": transcribe(one_grid_set, tile_map),
"ONE_TILE_FLAT": transcribe(one_grid_set, tile_map),
("ENORMOUS",): transcribe(enormous_set, tile_map),
("HUGE",): transcribe(huge_set, tile_map),
("LARGE",): transcribe(large_set, tile_map),
("MEDIUM",): transcribe(medium_set, tile_map),
("SMALL",): transcribe(small_set, tile_map),
("TINY",): transcribe(tiny_set, tile_map),
("ONE_TILE",): transcribe(one_grid_set, tile_map),
("ONE_TILE_FLAT",): transcribe(one_grid_set, tile_map),
},
),
mapgen_probability=10,
Expand Down
18 changes: 9 additions & 9 deletions industry/industries/oil_wells/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
translation_name="OIL_WELLS",
override_type=0x0B,
layouts=SplitDefinition(
"INDUSTRY_SIZE",
("INDUSTRY_SIZE",),
{
"ENORMOUS": transcribe(enormous_set, tile_map),
"HUGE": transcribe(huge_set, tile_map),
"LARGE": transcribe(large_set, tile_map),
"MEDIUM": transcribe(medium_set, tile_map),
"SMALL": transcribe(small_set, tile_map),
"TINY": transcribe(tiny_set, tile_map),
"ONE_TILE": transcribe(one_tile_set, tile_map),
"ONE_TILE_FLAT": [[{"xofs": 0, "yofs": 0, "gfx": grf.NewIndustryTileID(0x23)}]],
("ENORMOUS",): transcribe(enormous_set, tile_map),
("HUGE",): transcribe(huge_set, tile_map),
("LARGE",): transcribe(large_set, tile_map),
("MEDIUM",): transcribe(medium_set, tile_map),
("SMALL",): transcribe(small_set, tile_map),
("TINY",): transcribe(tiny_set, tile_map),
("ONE_TILE",): transcribe(one_tile_set, tile_map),
("ONE_TILE_FLAT",): [[{"xofs": 0, "yofs": 0, "gfx": grf.NewIndustryTileID(0x23)}]],
},
),
mapgen_probability=6,
Expand Down
10 changes: 1 addition & 9 deletions industry/lib/industry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ def __init__(self, variables, branches):
self.branches = branches

def fixup(self):
if isinstance(self.variables, int):
# Legacy format
self.variables = (self.variables,)
self.branches = {(i,): b for i, b in self.branches.items()}
elif isinstance(self.variables, str):
idx = parameter_list.index(self.variables)
self.variables = (idx,)
self.branches = {(parameter_list.parameters[idx].enum_index(i),): b for i, b in self.branches.items()}
elif isinstance(self.variables[0], str):
if isinstance(self.variables[0], str):
self.variables = tuple(parameter_list.index(idx) for idx in self.variables)
self.branches = {
tuple(parameter_list.parameters[idx].enum_index(s) for idx, s in zip(self.variables, i)): b
Expand Down

0 comments on commit bafeb7c

Please sign in to comment.