From b0888668bf196768ccfa6ce845da365287806000 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 1 Mar 2025 00:27:48 -0600 Subject: [PATCH] Fixed hopscotch capture --- Systems/DeckManager.gd | 2 +- Systems/Game/ChessGame.gd | 2 +- Systems/StateMachine/GameStates/Movement.gd | 20 ++++++++++++++------ Systems/Tiles/Portal.gd | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Systems/DeckManager.gd b/Systems/DeckManager.gd index d923512..d32e54d 100644 --- a/Systems/DeckManager.gd +++ b/Systems/DeckManager.gd @@ -23,12 +23,12 @@ func initializeStartingDeck(): deck.clear(); # for i in range(2): # deck.append(DoubleTimeCard.new()) + deck.append(HopscotchCard.new()) deck.append(FieryCapeCard.new()) deck.append(FieryTrailCard.new()) deck.append(ExplosiveBootsCard.new()) deck.append(DoubleTimeCard.new()) deck.append(DrunkDrivingCard.new()) - deck.append(HopscotchCard.new()) deck.append(SupernovaCard.new()) shuffleDeck() drawStartingHand() diff --git a/Systems/Game/ChessGame.gd b/Systems/Game/ChessGame.gd index e45af58..a1a702f 100644 --- a/Systems/Game/ChessGame.gd +++ b/Systems/Game/ChessGame.gd @@ -43,7 +43,7 @@ var stockfishPath = "res://Assets/ChessEngines/stockfish/stockfish.exe" @export var tileYSize: int = 50 @export var windowXSize: int = 1280 @export var windowYSize: int = 720 -@export var FEN: String = "rnbqkbnr/pppppppp/4U3/2u5/1****u*1/4U3/PPPPPPPP/RNBQKBNR w KQkq - 0 1" +@export var FEN: String = "2rnbqkbnr2/2pppppppp2/6u5/12/2********U1/12/2u9/12/7U4/12/2PPPPPPPP2/2RNBQKBNR2 w KQkq - 0 1" # "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" # "2rnbqkbnr2/2pppppppp2/12/12/2********2/12/12/12/12/12/2PPPPPPPP2/2RNBQKBNR2 w KQkq - 0 1" diff --git a/Systems/StateMachine/GameStates/Movement.gd b/Systems/StateMachine/GameStates/Movement.gd index 6e61d4d..1c0eab2 100644 --- a/Systems/StateMachine/GameStates/Movement.gd +++ b/Systems/StateMachine/GameStates/Movement.gd @@ -77,6 +77,7 @@ func handleMovement(location: String, generated: bool = false) -> void: # Only try to get piece if we have a selected node if game.selectedNode == "": + # print("No Node") # If no node is selected, we might want to select this one if it has a piece var piece = node.get_piece() if piece != null && piece.Item_Color == game.Turn: @@ -93,6 +94,7 @@ func handleMovement(location: String, generated: bool = false) -> void: var sourceContainer = game.get_node("Flow/" + game.selectedNode) as PieceContainer var piece = sourceContainer.get_piece() if piece == null: + # print("No Piece") return # print("SColor ", sourcePiece.Item_Color, " tColor ", piece.Item_Color) @@ -105,14 +107,15 @@ func handleMovement(location: String, generated: bool = false) -> void: if node.get_piece() != null and is_instance_valid(node.get_piece()): var attempting_piece = node.get_piece() - print("Checking Str comp ", str(attempting_piece.get_instance_id()), " ", multiMoving) + # print("Checking Str comp ", str(attempting_piece.get_instance_id()), " ", multiMoving) # Only block if it's a different piece of the same color if str(attempting_piece.get_instance_id()) != multiMoving and attempting_piece.Item_Color == game.Turn: print("early return - can't select different piece of same color during multi-move") return if game.selectedNode == "": + # print("No Node 2") if node.get_piece() != null && node.get_piece().Item_Color == game.Turn: - print("SELECTED NODE ", location) + # print("SELECTED NODE ", location) game.selectedNode = location game.getMovableAreas() return @@ -133,13 +136,16 @@ func handleMovement(location: String, generated: bool = false) -> void: if !is_multi_moving and multiMoving == "": print("CLEAR SELECTION*************") game.clearSelection() + return + return elif moves != null and !moves.regular_moves.has(game.selectedNode) and !moves.special_moves.has(game.selectedNode): + # print(moves, sourcePiece.Item_Color, piece.Item_Color) if sourcePiece and sourcePiece.Item_Color == piece.Item_Color: + # print("Set Location*************") game.selectedNode = location game.getMovableAreas() return - return - elif isCastlingMove(node, location): + if isCastlingMove(node, location): handleCastling(node, generated) finished.emit(Constants.POST_MOVE) # En Passant @@ -177,8 +183,10 @@ func handleMovement(location: String, generated: bool = false) -> void: print("ANOTHER MOVE") game.resetHighlights() if game.selectedNode != "": - game.tileManager.apply_tile_effect(game.selectedNode) - game.getMovableAreas() + + if game.isPlayerTurn(): + game.tileManager.apply_tile_effect(game.selectedNode) + game.getMovableAreas() if game.areas.size() == 0 and game.specialArea.size() == 0: print("Consuming move because no valid moves left") game.resolveMoveEffects() diff --git a/Systems/Tiles/Portal.gd b/Systems/Tiles/Portal.gd index 4144dc8..b3923cc 100644 --- a/Systems/Tiles/Portal.gd +++ b/Systems/Tiles/Portal.gd @@ -40,7 +40,8 @@ func apply_effect(piece: Pawn = null) -> void: animate_portal_teleport(piece, current_container, target_container) print("*****************SETTING SELECTED*(*************)") print(target_container.location) - game.selectedNode = target_container.location + if game.isPlayerTurn(): + game.selectedNode = target_container.location # target_container.animate_movement(current_container, piece); func animate_portal_teleport(piece: Pawn, origin_container: PieceContainer, destination_container: PieceContainer) -> void: