Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 410 |
-
|
| 411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|