mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
prevent most cases of duplicate player names
* in theory dupes are still possible due to later filtering of characters, but this should catch most instances of it.
This commit is contained in:
4
Utils.py
4
Utils.py
@@ -43,10 +43,12 @@ def snes_to_pc(value):
|
||||
|
||||
def parse_player_names(names, players, teams):
|
||||
names = tuple(n for n in (n.strip() for n in names.split(",")) if n)
|
||||
if len(names) != len(set(names)):
|
||||
raise ValueError("Duplicate Player names is not supported.")
|
||||
ret = []
|
||||
while names or len(ret) < teams:
|
||||
team = [n[:16] for n in names[:players]]
|
||||
# where does the 16 character limit come from?
|
||||
# 16 bytes in rom per player, which will map to more in unicode, but those characters later get filtered
|
||||
while len(team) != players:
|
||||
team.append(f"Player{len(team) + 1}")
|
||||
ret.append(team)
|
||||
|
Reference in New Issue
Block a user