Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pokemon Emerald: Use self.player_name #3384

Merged
merged 3 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions worlds/pokemon_emerald/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,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 @@ -224,7 +224,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 @@ -589,7 +589,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 @@ -608,7 +608,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 @@ -670,7 +670,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
Loading