The Messenger: Throw error for invalid names and replace `_` with ` ` (#1728)

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

Co-authored-by: el-u <109771707+el-u@users.noreply.github.com>
This commit is contained in:
alwaysintreble 2023-04-20 02:11:15 -05:00 committed by GitHub
parent a38a2903d5
commit c8fb46a5e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -1,7 +1,7 @@
import logging import logging
from typing import Dict, Any, Optional, List 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 worlds.AutoWorld import World, WebWorld
from .Constants import NOTES, PHOBEKINS, ALL_ITEMS, ALWAYS_LOCATIONS, SEALS, BOSS_LOCATIONS from .Constants import NOTES, PHOBEKINS, ALL_ITEMS, ALWAYS_LOCATIONS, SEALS, BOSS_LOCATIONS
from .Options import messenger_options, NotesNeeded, Goal, PowerSeals, Logic from .Options import messenger_options, NotesNeeded, Goal, PowerSeals, Logic
@ -66,6 +66,13 @@ class MessengerWorld(World):
total_seals: int = 0 total_seals: int = 0
required_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: def generate_early(self) -> None:
if self.multiworld.goal[self.player] == Goal.option_power_seal_hunt: if self.multiworld.goal[self.player] == Goal.option_power_seal_hunt: