more backend improvements; clients are (should be) able to submit cards and start new rounds; determining winners and scoring points is unimplemented

This commit is contained in:
2025-07-15 12:11:50 +02:00
parent 2f3f4dbc14
commit ecfe5955b7
4 changed files with 50 additions and 6 deletions
+31 -6
View File
@@ -211,7 +211,7 @@ class LobbyManager:
"response": "client_submitted_bet",
"client_id": client_id,
"bet": bet,
})
}),
)
async def spread_played_card(self, lobby_id, client_id, played_card) -> None:
@@ -221,7 +221,16 @@ class LobbyManager:
"response": "client_played_card",
"client_id": client_id,
"card": played_card,
})
}),
)
async def spread_play_winner(self, lobby_id, client_id) -> None:
await self.broadcast_message(
lobby_id,
json.dumps({
"response": "client_won_play",
"client_id": client_id,
}),
)
def get_next_client(self, lobby_id, client_id) -> str:
@@ -489,10 +498,20 @@ async def process_input(message: str, websocket) -> None:
client_id,
data_object["played_card"],
)
client_index = lobby_manager.get_lobby(lobby_id).client_playing_order.index(client_id)
if not client_index == (len(lobby_manager.get_lobby(lobby_id).client_playing_order) - 1):
playing_client_id = lobby_manager.get_lobby(lobby_id).client_playing_order[client_index + 1]
playing_order = lobby_manager.get_lobby(lobby_id).client_playing_order
client_index = playing_order.index(client_id)
if client_index == (len(playing_order) - 1):
# end round
await lobby_manager.send_message(
lobby_id,
lobby_manager.get_lobby_host_client_id(lobby_id),
json.dumps({
"response": "determine_round_winner_request",
})
)
else:
# not all clients have played a card yet; continue
playing_client_id = playing_order[client_index + 1]
await lobby_manager.send_message(
lobby_id,
@@ -501,6 +520,12 @@ async def process_input(message: str, websocket) -> None:
"response": "request_card",
}),
)
elif data_object["response"] == "submit_play_winner":
await lobby_manager.spread_play_winner(
data_object["lobby_id"],
data_object["client_id"],
)
if __name__ == '__main__':
run_local = False