Skip to content

Commit

Permalink
The Messenger: Throw error for invalid names and replace _ with (
Browse files Browse the repository at this point in the history
…ArchipelagoMW#1728)

* Replace '_' with ' ' and throw error for other invalid names

Co-authored-by: el-u <[email protected]>
  • Loading branch information
alwaysintreble and el-u authored Apr 20, 2023
1 parent a38a290 commit c8fb46a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion worlds/messenger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import Dict, Any, Optional, List

from BaseClasses import Tutorial, ItemClassification
from BaseClasses import Tutorial, ItemClassification, MultiWorld
from worlds.AutoWorld import World, WebWorld
from .Constants import NOTES, PHOBEKINS, ALL_ITEMS, ALWAYS_LOCATIONS, SEALS, BOSS_LOCATIONS
from .Options import messenger_options, NotesNeeded, Goal, PowerSeals, Logic
Expand Down Expand Up @@ -66,6 +66,13 @@ class MessengerWorld(World):

total_seals: int = 0
required_seals: int = 0

@classmethod
def stage_assert_generate(cls, multiworld: MultiWorld) -> None:
for player in multiworld.get_game_players(cls.game):
player_name = multiworld.player_name[player] = multiworld.get_player_name(player).replace("_", " ")
if not all(c.isalnum() or c in "- " for c in player_name):
raise ValueError(f"Player name {player_name} is not alpha-numeric.")

def generate_early(self) -> None:
if self.multiworld.goal[self.player] == Goal.option_power_seal_hunt:
Expand Down

0 comments on commit c8fb46a

Please sign in to comment.