From 35c9061c9cb3fbb12687e7afba73824c27e4ec1e Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Sat, 24 Aug 2024 02:08:46 +0200 Subject: [PATCH] The Witness: Switch to world.player_name (#3693) * lint * player_name * oops lmao * shorten --- worlds/witness/__init__.py | 15 ++++++++------- worlds/witness/hints.py | 13 +++++-------- worlds/witness/player_logic.py | 3 +-- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/worlds/witness/__init__.py b/worlds/witness/__init__.py index 33c63edd..ee5eba91 100644 --- a/worlds/witness/__init__.py +++ b/worlds/witness/__init__.py @@ -128,10 +128,10 @@ class WitnessWorld(World): ) if not has_locally_relevant_progression and self.multiworld.players == 1: - warning(f"{self.multiworld.get_player_name(self.player)}'s Witness world doesn't have any progression" + warning(f"{self.player_name}'s Witness world doesn't have any progression" f" items. Please turn on Symbol Shuffle, Door Shuffle or Laser Shuffle if that doesn't seem right.") elif not interacts_sufficiently_with_multiworld and self.multiworld.players > 1: - raise OptionError(f"{self.multiworld.get_player_name(self.player)}'s Witness world doesn't have enough" + raise OptionError(f"{self.player_name}'s Witness world doesn't have enough" f" progression items that can be placed in other players' worlds. Please turn on Symbol" f" Shuffle, Door Shuffle, or Obelisk Keys.") @@ -251,9 +251,10 @@ class WitnessWorld(World): self.player_locations.add_location_late(loc) self.get_region(region).add_locations({loc: self.location_name_to_id[loc]}) - player = self.multiworld.get_player_name(self.player) - - warning(f"""Location "{loc}" had to be added to {player}'s world due to insufficient sphere 1 size.""") + warning( + f"""Location "{loc}" had to be added to {self.player_name}'s world + due to insufficient sphere 1 size.""" + ) def create_items(self) -> None: # Determine pool size. @@ -290,7 +291,7 @@ class WitnessWorld(World): self.multiworld.push_precollected(self.create_item(inventory_item_name)) if len(item_pool) > pool_size: - error(f"{self.multiworld.get_player_name(self.player)}'s Witness world has too few locations ({pool_size})" + error(f"{self.player_name}'s Witness world has too few locations ({pool_size})" f" to place its necessary items ({len(item_pool)}).") return @@ -300,7 +301,7 @@ class WitnessWorld(World): num_puzzle_skips = self.options.puzzle_skip_amount.value if num_puzzle_skips > remaining_item_slots: - warning(f"{self.multiworld.get_player_name(self.player)}'s Witness world has insufficient locations" + warning(f"{self.player_name}'s Witness world has insufficient locations" f" to place all requested puzzle skips.") num_puzzle_skips = remaining_item_slots item_pool["Puzzle Skip"] = num_puzzle_skips diff --git a/worlds/witness/hints.py b/worlds/witness/hints.py index c8ddf260..cd1d38f6 100644 --- a/worlds/witness/hints.py +++ b/worlds/witness/hints.py @@ -220,7 +220,7 @@ def try_getting_location_group_for_location(world: "WitnessWorld", hint_loc: Loc def word_direct_hint(world: "WitnessWorld", hint: WitnessLocationHint) -> WitnessWordedHint: location_name = hint.location.name if hint.location.player != world.player: - location_name += " (" + world.multiworld.get_player_name(hint.location.player) + ")" + location_name += " (" + world.player_name + ")" item = hint.location.item @@ -229,7 +229,7 @@ def word_direct_hint(world: "WitnessWorld", hint: WitnessLocationHint) -> Witnes item_name = item.name if item.player != world.player: - item_name += " (" + world.multiworld.get_player_name(item.player) + ")" + item_name += " (" + world.player_name + ")" hint_text = "" area: Optional[str] = None @@ -388,8 +388,7 @@ def make_extra_location_hints(world: "WitnessWorld", hint_amount: int, own_itemp while len(hints) < hint_amount: if not prog_items_in_this_world and not locations_in_this_world and not hints_to_use_first: - player_name = world.multiworld.get_player_name(world.player) - logging.warning(f"Ran out of items/locations to hint for player {player_name}.") + logging.warning(f"Ran out of items/locations to hint for player {world.player_name}.") break location_hint: Optional[WitnessLocationHint] @@ -590,8 +589,7 @@ def make_area_hints(world: "WitnessWorld", amount: int, already_hinted_locations hints.append(WitnessWordedHint(hint_string, None, f"hinted_area:{hinted_area}", prog_amount, hunt_panels)) if len(hinted_areas) < amount: - player_name = world.multiworld.get_player_name(world.player) - logging.warning(f"Was not able to make {amount} area hints for player {player_name}. " + logging.warning(f"Was not able to make {amount} area hints for player {world.player_name}. " f"Made {len(hinted_areas)} instead, and filled the rest with random location hints.") return hints, unhinted_locations_per_area @@ -680,8 +678,7 @@ def create_all_hints(world: "WitnessWorld", hint_amount: int, area_hints: int, # If we still don't have enough for whatever reason, throw a warning, proceed with the lower amount if len(generated_hints) != hint_amount: - player_name = world.multiworld.get_player_name(world.player) - logging.warning(f"Couldn't generate {hint_amount} hints for player {player_name}. " + logging.warning(f"Couldn't generate {hint_amount} hints for player {world.player_name}. " f"Generated {len(generated_hints)} instead.") return generated_hints diff --git a/worlds/witness/player_logic.py b/worlds/witness/player_logic.py index 7313d823..b0e330c9 100644 --- a/worlds/witness/player_logic.py +++ b/worlds/witness/player_logic.py @@ -774,8 +774,7 @@ class WitnessPlayerLogic: # If we are disabling a laser, something has gone wrong. if static_witness_logic.ENTITIES_BY_HEX[entity]["entityType"] == "Laser": laser_name = static_witness_logic.ENTITIES_BY_HEX[entity]["checkName"] - player_name = world.multiworld.get_player_name(world.player) - raise RuntimeError(f"Somehow, {laser_name} was disabled for player {player_name}." + raise RuntimeError(f"Somehow, {laser_name} was disabled for player {world.player_name}." f" This is not allowed to happen, please report to Violet.") newly_discovered_disabled_entities.add(entity)