diff --git a/src/game/game.gd b/src/game/game.gd index 0aa1717..53366f7 100644 --- a/src/game/game.gd +++ b/src/game/game.gd @@ -28,6 +28,8 @@ var opponent_wins := 0: var player_move: Move var opponent_move: Move +var _awaiting_opponent_move := false + @onready var player_name_label: Label = %PlayerName @onready var opponent_name: Label = %OpponentName @@ -69,22 +71,26 @@ func set_opponent_name(opp_name: String) -> void: @rpc("any_peer", "call_remote", "reliable", 0) func set_opponent_move(move: Move) -> void: - print("Got move from opponent") - opponent_move = move - opponent_move_label.text = Move.keys()[opponent_move] - if move == Move.NONE: - opponent_ready.hide() - opponent_choosing_move.show() + if _awaiting_opponent_move: + print("Got move from opponent") + opponent_move = move + opponent_move_label.text = Move.keys()[opponent_move] + if move == Move.NONE: + opponent_ready.hide() + opponent_choosing_move.show() + else: + opponent_choosing_move.hide() + opponent_ready.show() + _check_play_condition() else: - opponent_choosing_move.hide() - opponent_ready.show() - _check_play_condition() + print("Got opponent move out of sequence!") func start_round() -> void: move_select.show() opponent_ready.hide() opponent_choosing_move.show() + _awaiting_opponent_move = true func finish_round() -> void: @@ -133,6 +139,7 @@ func _set_player_move(value: Move) -> void: func _check_play_condition() -> void: if player_move and opponent_move: + _awaiting_opponent_move = false _set_outcome_label(get_outcome()) move_select.hide() opponent_ready.hide()