game now correctly rotates through plays and goes to the next rounds when all cards have been played

This commit is contained in:
2025-07-15 19:38:27 +02:00
parent 231e861416
commit e0cea82394
6 changed files with 60 additions and 10 deletions
+12 -4
View File
@@ -44,6 +44,7 @@ signal received_win()
signal notify_play_card_request()
signal received_played_card(client_id: String, card_id: int)
signal received_play_winner_request()
signal request_next_play()
signal request_next_round()
enum ConnectionStatus {
@@ -82,7 +83,7 @@ func _process(_delta: float) -> void:
if _processed_status == WebSocketPeer.STATE_OPEN:
while _socket.get_available_packet_count():
cached_response = _socket.get_packet().get_string_from_utf8()
print(cached_response)
#print(cached_response)
#cached_response += (received_data[1] as PackedByteArray).get_string_from_utf8()
if cached_response.ends_with("}"):
#print(cached_response)
@@ -128,14 +129,14 @@ func _handle_response(response: String) -> void:
received_chat_message.emit.call_deferred(data["client_name"], data["message"])
"new_round_started":
print(data)
#print(data)
if data["current_round"] == 1:
var playing_order: Array[String] = []
playing_order.assign(data["playing_order"])
client_order_received.emit.call_deferred(playing_order)
var received_cards = data["cards"]
print(received_cards)
#print(received_cards)
cards_received.emit.call_deferred(received_cards)
trump_received.emit.call_deferred(data["trump"])
"client_submitted_bet":
@@ -217,6 +218,12 @@ func start_game() -> void:
"cards": CardManager.get_shuffled_cards(_connected_client_ids, 1),
}))
func start_next_play() -> void:
_send_message(JSON.stringify({
"response": "start_next_play",
"lobby_id": _lobby_id,
}))
func start_next_round(round_count: int) -> void:
_send_message(JSON.stringify({
"response": "start_next_round",
@@ -248,7 +255,8 @@ func submit_play_winner(winning_client_id: String) -> void:
"lobby_id": _lobby_id,
"client_id": winning_client_id,
}))
request_next_round.emit.call_deferred()
request_next_play.emit.call_deferred()
#request_next_round.emit.call_deferred()
func _send_message(message: String) -> void:
_socket.send_text(message)