all clients now receive current round
This commit is contained in:
+10
-1
@@ -24,6 +24,7 @@ class Lobby:
|
||||
self.client_playing_order = []
|
||||
self.client_bets = {} # client_id: bet
|
||||
# self.currently_playing_client = 0 # index of client_playing_order
|
||||
self.current_round = 0
|
||||
|
||||
class Client:
|
||||
|
||||
@@ -201,6 +202,7 @@ class LobbyManager:
|
||||
json.dumps({
|
||||
"response": "request_bet",
|
||||
"disallowed_bet": disallowed_bet,
|
||||
"round": self.get_lobby(lobby_id).current_round,
|
||||
})
|
||||
)
|
||||
|
||||
@@ -409,6 +411,8 @@ async def process_input(message: str, websocket) -> None:
|
||||
data_object["cards"],
|
||||
lobby.client_playing_order,
|
||||
)
|
||||
|
||||
lobby_manager.get_lobby(data_object["lobby_id"]).current_round = 1
|
||||
|
||||
print(f"Lobby {lobby_id} is starting the game, playing order is: {lobby.client_playing_order}")
|
||||
|
||||
@@ -434,6 +438,7 @@ async def process_input(message: str, websocket) -> None:
|
||||
|
||||
# Reset bets
|
||||
lobby_manager.get_lobby(lobby_id).client_bets = {}
|
||||
lobby_manager.get_lobby(data_object["lobby_id"]).current_round += 1
|
||||
|
||||
await lobby_manager.spread_cards(
|
||||
lobby_id,
|
||||
@@ -482,6 +487,7 @@ async def process_input(message: str, websocket) -> None:
|
||||
playing_client_id,
|
||||
json.dumps({
|
||||
"response": "request_card",
|
||||
"round": lobby_manager.get_lobby(lobby_id).current_round
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -492,7 +498,10 @@ async def process_input(message: str, websocket) -> None:
|
||||
if last_client_index == (player_count - 2):
|
||||
# last client to bet; limit bet options
|
||||
total_bet = sum(lobby_manager.get_lobby(lobby_id).client_bets.values())
|
||||
disallowed_bet = total_bet - data_object["round"]
|
||||
disallowed_bet = data_object["round"] - total_bet
|
||||
print(f"bets: {data_object["round"]} / {total_bet}")
|
||||
if disallowed_bet < 0:
|
||||
disallowed_bet = -1
|
||||
|
||||
await lobby_manager.request_bet(
|
||||
lobby_id,
|
||||
|
||||
Reference in New Issue
Block a user