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:
Fabian Dill 2020-08-20 04:03:49 +02:00
parent 367c853300
commit 72545d12f1
1 changed files with 3 additions and 1 deletions

View File

@ -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)