From ad2d67e91a3ce9ca8e8f2f5ce65720883cba52b9 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 1 Mar 2025 10:06:27 -0600 Subject: [PATCH] fixed drunk driving turn transtion breaking stockfish --- Systems/Cards/Drunkdriving.gd | 20 +++++++++++++++---- Systems/Game/ChessGame.gd | 3 --- .../StateMachine/GameStates/AttachCards.gd | 9 +++++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Systems/Cards/Drunkdriving.gd b/Systems/Cards/Drunkdriving.gd index 494ca12..3318806 100644 --- a/Systems/Cards/Drunkdriving.gd +++ b/Systems/Cards/Drunkdriving.gd @@ -22,7 +22,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): var current_y = int(current_pos[1]) # Calculate target position - var target_y = 7 if target_piece.Item_Color == 1 else 0 + var target_y = game_state.boardYSize - 1 if target_piece.Item_Color == 1 else 0 var y_direction = 1 if target_y > current_y else -1 # Generate tiles to check @@ -32,6 +32,12 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): tiles_to_check.append(str(current_x) + "-" + str(y)) y += y_direction + if game_state.isPlayerTurn(): + print("") + else: + print("REVERSING TILES TO CHECK") + tiles_to_check.reverse() + # Find final position (stop before any impassable tile) var final_y = target_y for tile_name in tiles_to_check: @@ -41,10 +47,14 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): var tile_y = int(tile_name.split("-")[1]) final_y = tile_y - y_direction break - print("CHECKING TILES ", tiles_to_check) # Process pieces in path for tile_name in tiles_to_check: - var tile_y = int(tile_name.split("-")[1]) + var tile = game_state.tileManager.get_tile(tile_name) + if tile && !tile.passable: + # print("CHECKING TILES ", tile_name, " passable ", tile.passable) + break + # elif !tile: + # print("CHECKING TILES ", tile_name, " no tile") # Only process tiles up to where we're stopping var container = board_flow.get_node(tile_name) as PieceContainer @@ -55,7 +65,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): # Move piece to final position print("FINAL TILES ", str(current_x) + "-" + str(final_y)) var final_container = board_flow.get_node(str(current_x) + "-" + str(final_y)) as PieceContainer - print("FINAL TILES ", final_container.get_piece().Item_Color) + # print("FINAL TILES ", final_container.get_piece().Item_Color) # Important: Need to remove the piece from its current container first # AND keep a reference to it @@ -66,6 +76,8 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): burned = true game_state.resolveMoveEffects() + game_state.clearSelection() game_state.stateMachine.transitionToNextState(Constants.POST_MOVE) + # Breaks Stockfish for some reason return true diff --git a/Systems/Game/ChessGame.gd b/Systems/Game/ChessGame.gd index 49b5f89..7e477b2 100644 --- a/Systems/Game/ChessGame.gd +++ b/Systems/Game/ChessGame.gd @@ -198,9 +198,6 @@ func getCurrentFen() -> String: if piece == null: emptySquares += 1 else: - if emptySquares > 0: - fen += str(emptySquares) - emptySquares = 0 # Convert piece to FEN notation var fenChar = getPieceFenChar(piece) fen += fenChar diff --git a/Systems/StateMachine/GameStates/AttachCards.gd b/Systems/StateMachine/GameStates/AttachCards.gd index ecf375b..040a2fc 100644 --- a/Systems/StateMachine/GameStates/AttachCards.gd +++ b/Systems/StateMachine/GameStates/AttachCards.gd @@ -22,6 +22,7 @@ func enter(_previous: String, _data := {}) -> void: timer.start(ATTACHMENT_PHASE_DURATION) if game.deckManager.hand.is_empty(): complete_attachment_phase() + func exit() -> void: @@ -63,8 +64,12 @@ func handleTilePressed(location: String) -> void: print("Failed to attach card") func _on_timer_timeout() -> void: - print("Card attachment phase timed out") - finished.emit(Constants.APPLY_CARD_EFFECTS) + + var stateString: RichTextLabel = owner.get_node("StateLabel") + # prevent transition of state is already changed by other effects + if stateString.text == "AttachCards": + print("Card attachment phase timed out") + finished.emit(Constants.APPLY_CARD_EFFECTS) func complete_attachment_phase() -> void: if timer.time_left > 0: