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
+14
View File
@@ -10,13 +10,23 @@ extends Node
var _is_host: bool = false
var _current_player_count: int = 0
var _current_round: int = 0
var _cards_left: int = 0
var _max_rounds: int = 0
func _set_host(is_host: bool) -> void:
_is_host = is_host
func _start_next_play() -> void:
_cards_left -= 1
print("cards left: " + str(_cards_left))
if _cards_left == 0:
_start_next_round()
else:
web_client.start_next_play()
func _start_next_round() -> void:
_current_round += 1
_cards_left = _current_round
web_client.start_next_round(_current_round)
func _get_max_rounds(player_count: int) -> int:
@@ -32,6 +42,7 @@ func _get_max_rounds(player_count: int) -> int:
func _on_start_game_button_pressed() -> void:
_current_round = 1
_cards_left = _current_round
web_client.start_game()
func _on_create_lobby_button_pressed() -> void:
@@ -79,3 +90,6 @@ func _on_web_client_tcp_received_win() -> void:
$WinLabel.show()
await get_tree().create_timer(1.0).timeout
$WinLabel.hide()
func _on_web_client_tcp_request_next_play() -> void:
_start_next_play()