From 6d15aef88a64983d2f6fc1a0398a92d6500ac0f4 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 10 Apr 2021 18:45:11 +0200 Subject: [PATCH] Factorio: align tech tree sections in growing ingredient requirements --- BaseClasses.py | 1 + WebHostLib/customserver.py | 2 +- worlds/factorio/Technologies.py | 2 +- worlds/factorio/__init__.py | 5 ++++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 4d8e8db2..fd1532ba 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -27,6 +27,7 @@ class MultiWorld(): class AttributeProxy(): def __init__(self, rule): self.rule = rule + def __getitem__(self, player) -> bool: return self.rule(player) diff --git a/WebHostLib/customserver.py b/WebHostLib/customserver.py index 96d233d8..317fd150 100644 --- a/WebHostLib/customserver.py +++ b/WebHostLib/customserver.py @@ -27,7 +27,7 @@ class CustomClientMessageProcessor(ClientMessageProcessor): self.ctx.save() self.output(f"Registered Twitch Stream https://www.twitch.tv/{user}") return True - elif platform.lower().startswith("y"): # youtube + elif platform.lower().startswith("y"): # youtube self.ctx.video[self.client.team, self.client.slot] = "Youtube", user self.ctx.save() self.output(f"Registered Youtube Stream for {user}") diff --git a/worlds/factorio/Technologies.py b/worlds/factorio/Technologies.py index 87e01a06..b9edadf0 100644 --- a/worlds/factorio/Technologies.py +++ b/worlds/factorio/Technologies.py @@ -13,7 +13,7 @@ with open(source_file) as f: with open(recipe_source_file) as f: raw_recipes = json.load(f) tech_table = {} -technology_table = {} +technology_table:Dict[str, Technology] = {} always = lambda state: True diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index 772029d7..bd773c83 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -43,8 +43,11 @@ def get_shapes(world: MultiWorld, player: int) -> Dict[str, List[str]]: tech_names.sort() world.random.shuffle(tech_names) while len(tech_names) > 4: - diamond_0, diamond_1, diamond_2, diamond_3 = tech_names[:4] + slice = tech_names[:4] tech_names = tech_names[4:] + slice.sort(key=lambda tech_name: len(technology_table[tech_name].ingredients)) + diamond_0, diamond_1, diamond_2, diamond_3 = slice + # 0 | # 1 2 | # 3 V