Skip to content

Commit

Permalink
Pokemon Emerald: Use self.player_name (ArchipelagoMW#3384)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zunawe authored and sflavelle committed Jun 20, 2024
1 parent 3ebde4d commit 12b5ad7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions worlds/pokemon_emerald/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,26 @@ def generate_early(self) -> None:
# In race mode we don't patch any item location information into the ROM
if self.multiworld.is_race and not self.options.remote_items:
logging.warning("Pokemon Emerald: Forcing Player %s (%s) to use remote items due to race mode.",
self.player, self.multiworld.player_name[self.player])
self.player, self.player_name)
self.options.remote_items.value = Toggle.option_true

if self.options.goal == Goal.option_legendary_hunt:
# Prevent turning off all legendary encounters
if len(self.options.allowed_legendary_hunt_encounters.value) == 0:
raise OptionError(f"Pokemon Emerald: Player {self.player} ({self.multiworld.player_name[self.player]}) "
"needs to allow at least one legendary encounter when goal is legendary hunt.")
raise OptionError(f"Pokemon Emerald: Player {self.player} ({self.player_name}) needs to allow at "
"least one legendary encounter when goal is legendary hunt.")

# Prevent setting the number of required legendaries higher than the number of enabled legendaries
if self.options.legendary_hunt_count.value > len(self.options.allowed_legendary_hunt_encounters.value):
logging.warning("Pokemon Emerald: Legendary hunt count for Player %s (%s) higher than number of allowed "
"legendary encounters. Reducing to number of allowed encounters.", self.player,
self.multiworld.player_name[self.player])
self.player_name)
self.options.legendary_hunt_count.value = len(self.options.allowed_legendary_hunt_encounters.value)

# Require random wild encounters if dexsanity is enabled
if self.options.dexsanity and self.options.wild_pokemon == RandomizeWildPokemon.option_vanilla:
raise OptionError(f"Pokemon Emerald: Player {self.player} ({self.multiworld.player_name[self.player]}) must "
"not leave wild encounters vanilla if enabling dexsanity.")
raise OptionError(f"Pokemon Emerald: Player {self.player} ({self.player_name}) must not leave wild "
"encounters vanilla if enabling dexsanity.")

# If badges or HMs are vanilla, Norman locks you from using Surf,
# which means you're not guaranteed to be able to reach Fortree Gym,
Expand Down Expand Up @@ -223,7 +223,7 @@ def generate_early(self) -> None:

if self.options.norman_count.value > max_norman_count:
logging.warning("Pokemon Emerald: Norman requirements for Player %s (%s) are unsafe in combination with "
"other settings. Reducing to 4.", self.player, self.multiworld.get_player_name(self.player))
"other settings. Reducing to 4.", self.player, self.player_name)
self.options.norman_count.value = max_norman_count

def create_regions(self) -> None:
Expand Down Expand Up @@ -588,7 +588,7 @@ def generate_output(self, output_directory: str) -> None:
randomize_opponent_parties(self)
randomize_starters(self)

patch = PokemonEmeraldProcedurePatch(player=self.player, player_name=self.multiworld.player_name[self.player])
patch = PokemonEmeraldProcedurePatch(player=self.player, player_name=self.player_name)
patch.write_file("base_patch.bsdiff4", pkgutil.get_data(__name__, "data/base_patch.bsdiff4"))
write_tokens(self, patch)

Expand All @@ -607,7 +607,7 @@ def write_spoiler(self, spoiler_handle: TextIO):
if self.options.dexsanity:
from collections import defaultdict

spoiler_handle.write(f"\n\nWild Pokemon ({self.multiworld.player_name[self.player]}):\n\n")
spoiler_handle.write(f"\n\nWild Pokemon ({self.player_name}):\n\n")

species_maps = defaultdict(set)
for map in self.modified_maps.values():
Expand Down Expand Up @@ -669,7 +669,7 @@ def extend_hint_information(self, hint_data):

def modify_multidata(self, multidata: Dict[str, Any]):
import base64
multidata["connect_names"][base64.b64encode(self.auth).decode("ascii")] = multidata["connect_names"][self.multiworld.player_name[self.player]]
multidata["connect_names"][base64.b64encode(self.auth).decode("ascii")] = multidata["connect_names"][self.player_name]

def fill_slot_data(self) -> Dict[str, Any]:
slot_data = self.options.as_dict(
Expand Down
2 changes: 1 addition & 1 deletion worlds/pokemon_emerald/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ async def handle_death_link(self, ctx: "BizHawkClientContext", guards: Dict[str,
self.death_counter = times_whited_out
elif times_whited_out > self.death_counter:
await ctx.send_death(f"{ctx.player_names[ctx.slot]} is out of usable POKéMON! "
f"{ctx.player_names[ctx.slot]} whited out!")
f"{ctx.player_names[ctx.slot]} whited out!")
self.ignore_next_death_link = True
self.death_counter = times_whited_out

Expand Down
4 changes: 2 additions & 2 deletions worlds/pokemon_emerald/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def write_tokens(world: "PokemonEmeraldWorld", patch: PokemonEmeraldProcedurePat
location.item.name
) for trainer in alternates)

player_name_ids: Dict[str, int] = {world.multiworld.player_name[world.player]: 0}
player_name_ids: Dict[str, int] = {world.player_name: 0}
item_name_offsets: Dict[str, int] = {}
next_item_name_offset = 0
for i, (flag, item_player, item_name) in enumerate(sorted(location_info, key=lambda t: t[0])):
Expand All @@ -208,7 +208,7 @@ def write_tokens(world: "PokemonEmeraldWorld", patch: PokemonEmeraldProcedurePat
struct.pack("<B", 0)
)
else:
player_name = world.multiworld.player_name[item_player]
player_name = world.multiworld.get_player_name(item_player)

if player_name not in player_name_ids:
# Only space for 50 player names
Expand Down

0 comments on commit 12b5ad7

Please sign in to comment.