incognitolm commited on
Commit
dd21b8f
·
verified ·
1 Parent(s): 50d5022

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -406,9 +406,13 @@ async def join_game(request: Request):
406
  if not game:
407
  raise HTTPException(status_code=404, detail="Game not found.")
408
 
409
- # Prevent duplicate player names.
410
- if player_name in game["permissions"]:
411
- raise HTTPException(status_code=400, detail="Player name already taken.")
 
 
 
 
412
 
413
  game["players"].append(player_name)
414
  # Properly initialize the new player's permissions.
 
406
  if not game:
407
  raise HTTPException(status_code=404, detail="Game not found.")
408
 
409
+ # Automatically capitalize the first letter of each word.
410
+ player_name = " ".join(word.capitalize() for word in player_name.split())
411
+
412
+ # Prevent duplicate player names (case-insensitive).
413
+ existing_names = [name.lower() for name in game["permissions"].keys()]
414
+ if player_name.lower() in existing_names:
415
+ return {"success": False, "message": "That name has already been taken."}
416
 
417
  game["players"].append(player_name)
418
  # Properly initialize the new player's permissions.