client can now only play allowed cards

This commit is contained in:
2025-07-18 14:10:39 +02:00
parent 2e83eea619
commit aef7778a4b
5 changed files with 152 additions and 2 deletions
+16
View File
@@ -17,6 +17,8 @@ var cached_response: String
var _thread: Thread
var _stop_thread: bool = false
var _is_first_play: bool = false
var _connected_client_ids: Array[String] = []
var _connected_client_names: Array[String] = []
@@ -48,6 +50,8 @@ signal received_bet_request(disallowed_bet: int, current_round: int)
signal received_win()
signal received_winning_client(client_id: String)
signal notify_play_card_request()
signal reset_first_card()
signal received_first_card(card_id: int)
signal received_played_card(client_id: String, card_id: int)
signal received_play_winner_request()
signal received_end_game_request()
@@ -155,9 +159,15 @@ func _handle_response(response: String) -> void:
"begin_playing_cards":
# all players know it's time to play
print(data)
_is_first_play = true
reset_first_card.emit.call_deferred()
"request_card":
# individual player asked to play card
notify_play_card_request.emit.call_deferred()
"begin_next_play":
print("beginning next play!")
_is_first_play = true
reset_first_card.emit.call_deferred()
"play_card":
print(data)
#client_played_card.emit.call_deferred(data["client_id"], data["played_card"])
@@ -166,6 +176,12 @@ func _handle_response(response: String) -> void:
"end_game_request":
received_end_game_request.emit.call_deferred()
"client_played_card":
print("RECEIVED FOLLOWING CARD ID: " + str(data["played_card"]))
if _is_first_play:
print("set first card")
received_first_card.emit.call_deferred(data["played_card"])
if not CardManager.get_card_color(data["played_card"]) == Card.CardColor.WHITE:
_is_first_play = false
received_played_card.emit.call_deferred(data["client_id"], data["played_card"])
"client_won_play":
if data["client_id"] == _client_id: