From 3c93da5c047e48a4adea221213227b70e71b2eda Mon Sep 17 00:00:00 2001 From: Sam Zimmerman Date: Sat, 21 Sep 2024 19:26:17 -0700 Subject: [PATCH 1/6] First code upload --- src/__init__.py | 6 +++++- src/hooks/World.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/__init__.py b/src/__init__.py index 020372c..9885314 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -31,7 +31,8 @@ before_create_item, after_create_item, \ before_set_rules, after_set_rules, \ before_generate_basic, after_generate_basic, \ - before_fill_slot_data, after_fill_slot_data, before_write_spoiler + before_fill_slot_data, after_fill_slot_data, before_write_spoiler, \ + before_extend_hint_information from .hooks.Data import hook_interpret_slot_data class ManualWorld(World): @@ -332,6 +333,9 @@ def generate_output(self, output_directory: str): def write_spoiler(self, spoiler_handle): before_write_spoiler(self, self.multiworld, spoiler_handle) + def extend_hint_information(self, hint_data: Dict[int, Dict[int, str]]) -> None: + before_extend_hint_information(self, hint_data) + ### # Non-standard AP world methods ### diff --git a/src/hooks/World.py b/src/hooks/World.py index d7ce12a..1078b37 100644 --- a/src/hooks/World.py +++ b/src/hooks/World.py @@ -138,3 +138,8 @@ def after_fill_slot_data(slot_data: dict, world: World, multiworld: MultiWorld, # This is called right at the end, in case you want to write stuff to the spoiler log def before_write_spoiler(world: World, multiworld: MultiWorld, spoiler_handle) -> None: pass + +# This is called when you want to add information to the hint text +def before_extend_hint_information(world: World, hint_data: Dict[int, Dict[int, str]]) -> None: + pass + From 3f48346e540f2985285c99e20d5fafd20cdf1ccc Mon Sep 17 00:00:00 2001 From: Sam Zimmerman Date: Sat, 21 Sep 2024 19:48:54 -0700 Subject: [PATCH 2/6] Clean up bad typing hints --- src/__init__.py | 2 +- src/hooks/World.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index 9885314..a35f930 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -333,7 +333,7 @@ def generate_output(self, output_directory: str): def write_spoiler(self, spoiler_handle): before_write_spoiler(self, self.multiworld, spoiler_handle) - def extend_hint_information(self, hint_data: Dict[int, Dict[int, str]]) -> None: + def extend_hint_information(self, hint_data: dict[int, dict[int, str]]) -> None: before_extend_hint_information(self, hint_data) ### diff --git a/src/hooks/World.py b/src/hooks/World.py index 1078b37..62325cc 100644 --- a/src/hooks/World.py +++ b/src/hooks/World.py @@ -140,6 +140,6 @@ def before_write_spoiler(world: World, multiworld: MultiWorld, spoiler_handle) - pass # This is called when you want to add information to the hint text -def before_extend_hint_information(world: World, hint_data: Dict[int, Dict[int, str]]) -> None: +def before_extend_hint_information(world: World, hint_data: dict[int, dict[int, str]]) -> None: pass From 326050137bf0435936e0a6eb48ec3cb1c1109825 Mon Sep 17 00:00:00 2001 From: Sam Zimmerman Date: Sat, 21 Sep 2024 19:52:32 -0700 Subject: [PATCH 3/6] Add some guidance on how to use the hook --- src/hooks/World.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hooks/World.py b/src/hooks/World.py index 62325cc..1b3232c 100644 --- a/src/hooks/World.py +++ b/src/hooks/World.py @@ -141,5 +141,16 @@ def before_write_spoiler(world: World, multiworld: MultiWorld, spoiler_handle) - # This is called when you want to add information to the hint text def before_extend_hint_information(world: World, hint_data: dict[int, dict[int, str]]) -> None: + + ### Example way to use this hook: + # hint_data.update({world.player: {}}) + # for location in world.multiworld.get_locations(world.player): + # if not location.address: + # continue + # + # use this section to calculate the hint string + # + # hint_data[world.player][location.address] = hint_string + pass From 2728ae2476aa95dceacfe6bc3a787da4cd2bbd23 Mon Sep 17 00:00:00 2001 From: Sam Zimmerman Date: Sun, 22 Sep 2024 10:03:57 -0700 Subject: [PATCH 4/6] Add code to read entrance strings from json Add `after_extend_hint_information` --- src/__init__.py | 12 +++++++++++- src/data/locations.json | 3 ++- src/hooks/World.py | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index a35f930..57884a3 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -32,7 +32,7 @@ before_set_rules, after_set_rules, \ before_generate_basic, after_generate_basic, \ before_fill_slot_data, after_fill_slot_data, before_write_spoiler, \ - before_extend_hint_information + before_extend_hint_information, after_extend_hint_information from .hooks.Data import hook_interpret_slot_data class ManualWorld(World): @@ -335,6 +335,16 @@ def write_spoiler(self, spoiler_handle): def extend_hint_information(self, hint_data: dict[int, dict[int, str]]) -> None: before_extend_hint_information(self, hint_data) + + for location in self.multiworld.get_locations(world.player): + if not location.address: + continue + if "hint_entrance" in self.location_name_to_location[location.name]: + if self.player not in hint_data: + hint_data.update({self.player: {}}) + hint_data[self.player][location.address] = self.location_name_to_location[location.name]["hint_entrance"] + + after_extend_hint_information(self, hint_data) ### # Non-standard AP world methods diff --git a/src/data/locations.json b/src/data/locations.json index 99605df..a512305 100644 --- a/src/data/locations.json +++ b/src/data/locations.json @@ -25,7 +25,8 @@ { "name": "Beat the Game - Shuma-Gorath", "category": ["Unlocked Teams", "Right Side"], - "requires": "|Shuma-Gorath|" + "requires": "|Shuma-Gorath|", + "hint_entrance": "Unlock Shuma-Gorath" }, { "name": "Beat the Game - Nemesis T-Type", diff --git a/src/hooks/World.py b/src/hooks/World.py index 1b3232c..3b708a3 100644 --- a/src/hooks/World.py +++ b/src/hooks/World.py @@ -154,3 +154,5 @@ def before_extend_hint_information(world: World, hint_data: dict[int, dict[int, pass +def after_extend_hint_information(world: World, hint_data: dict[int, dict[int, str]]) -> None: + pass From a3234790afe793bd509c9d2a9037d859961f817e Mon Sep 17 00:00:00 2001 From: Sam Zimmerman Date: Sun, 22 Sep 2024 10:07:50 -0700 Subject: [PATCH 5/6] Schema fix --- schemas/Manual.locations.schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/schemas/Manual.locations.schema.json b/schemas/Manual.locations.schema.json index c483f1a..c349699 100644 --- a/schemas/Manual.locations.schema.json +++ b/schemas/Manual.locations.schema.json @@ -92,6 +92,10 @@ "type": "boolean", "default": false }, + "hint_entrance": { + "description": "(Optional) Adds additional text to this location's hints to convey useful information. Typically used for entrance randomization.", + "type": "string" + } "_comment": {"$ref": "#/definitions/comment"} } }, From 89e16da68f9ff267f66a9f734fe1a7289caf8f1d Mon Sep 17 00:00:00 2001 From: Sam Zimmerman Date: Thu, 26 Sep 2024 18:00:33 -0700 Subject: [PATCH 6/6] Fix comments --- src/__init__.py | 6 +++--- src/hooks/World.py | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index 57884a3..5387a6b 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -334,9 +334,9 @@ def write_spoiler(self, spoiler_handle): before_write_spoiler(self, self.multiworld, spoiler_handle) def extend_hint_information(self, hint_data: dict[int, dict[int, str]]) -> None: - before_extend_hint_information(self, hint_data) + before_extend_hint_information(hint_data, self, self.multiworld, self.player) - for location in self.multiworld.get_locations(world.player): + for location in self.multiworld.get_locations(self.player): if not location.address: continue if "hint_entrance" in self.location_name_to_location[location.name]: @@ -344,7 +344,7 @@ def extend_hint_information(self, hint_data: dict[int, dict[int, str]]) -> None: hint_data.update({self.player: {}}) hint_data[self.player][location.address] = self.location_name_to_location[location.name]["hint_entrance"] - after_extend_hint_information(self, hint_data) + after_extend_hint_information(hint_data, self, self.multiworld, self.player) ### # Non-standard AP world methods diff --git a/src/hooks/World.py b/src/hooks/World.py index 3b708a3..85d5f40 100644 --- a/src/hooks/World.py +++ b/src/hooks/World.py @@ -140,19 +140,20 @@ def before_write_spoiler(world: World, multiworld: MultiWorld, spoiler_handle) - pass # This is called when you want to add information to the hint text -def before_extend_hint_information(world: World, hint_data: dict[int, dict[int, str]]) -> None: +def before_extend_hint_information(hint_data: dict[int, dict[int, str]], world: World, multiworld: MultiWorld, player: int) -> None: ### Example way to use this hook: - # hint_data.update({world.player: {}}) - # for location in world.multiworld.get_locations(world.player): + # if player not in hint_data: + # hint_data.update({player: {}}) + # for location in multiworld.get_locations(player): # if not location.address: # continue # # use this section to calculate the hint string # - # hint_data[world.player][location.address] = hint_string + # hint_data[player][location.address] = hint_string pass -def after_extend_hint_information(world: World, hint_data: dict[int, dict[int, str]]) -> None: +def after_extend_hint_information(hint_data: dict[int, dict[int, str]], world: World, multiworld: MultiWorld, player: int) -> None: pass