incognitolm commited on
Commit
5706cbf
·
verified ·
1 Parent(s): c919ba0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -22,12 +22,27 @@ async def create_game(request: Request):
22
  data = await request.json()
23
  pin = data.get("pin")
24
  player_name = data.get("playerName")
 
25
 
26
  if not pin or not player_name:
27
- raise HTTPException(status_code=400, detail="PIN and player name are required.")
28
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  if pin in games:
30
- raise HTTPException(status_code=400, detail="Game already exists.")
31
 
32
  # Initialize permissions as a dictionary with proper keys.
33
  games[pin] = {
 
22
  data = await request.json()
23
  pin = data.get("pin")
24
  player_name = data.get("playerName")
25
+ notPlaying = data.get("notPlaying")
26
 
27
  if not pin or not player_name:
28
+ if not notPlaying:
29
+ raise HTTPException(status_code=400, detail="PIN and player name are required.")
30
+ else:
31
+ games[pin] = {
32
+ "pin": pin,
33
+ "players": None,
34
+ "gameStarted": False,
35
+ "turn": player_name,
36
+ "currentAction": None,
37
+ "currentChallenge": None,
38
+ "pendingCardLoss": None,
39
+ "votes": [],
40
+ "permissions": {player_name: {"steal": True, "gain": True}}
41
+ }
42
+ return {"success": True, "message": "Empty game created."}
43
+
44
  if pin in games:
45
+ return {"success": False, "message": "Game already exists."}
46
 
47
  # Initialize permissions as a dictionary with proper keys.
48
  games[pin] = {