fixed turn bug with unit selection

This commit is contained in:
2ManyProjects 2025-02-26 22:01:18 -06:00
parent 4aa9085c9c
commit dbb0b693b9
3 changed files with 19 additions and 4 deletions

View file

@ -37,8 +37,8 @@ var stockfishPath = "res://Assets/ChessEngines/stockfish/stockfish.exe"
@onready var cardDisplay: CardDisplay
@onready var cardPreview: CardPreview
@export var boardXSize = 8
@export var boardYSize = 8
@export var boardXSize = 12
@export var boardYSize = 12
@export var tileXSize: int = 50
@export var tileYSize: int = 50
@export var windowXSize: int = 1280

View file

@ -83,12 +83,18 @@ func handleMovement(location: String, generated: bool = false) -> void:
game.selectedNode = location
game.getMovableAreas()
return
var sourcePiece = node.get_piece()
var moves = null;
if sourcePiece:
moves = sourcePiece.getValidMoves(game.boardContainer, location)
# Now we know we have a selected node, get its piece
var sourceContainer = game.get_node("Flow/" + game.selectedNode) as PieceContainer
var piece = sourceContainer.get_piece()
if piece == null:
return
# print("SColor ", sourcePiece.Item_Color, " tColor ", piece.Item_Color)
var piece_id = piece.get_instance_id()
@ -121,10 +127,18 @@ func handleMovement(location: String, generated: bool = false) -> void:
if piece_id in moves_remaining:
moves_remaining.erase(piece_id)
# finished.emit(Constants.POST_MOVE)
if game.selectedNode == location:
if !is_multi_moving and multiMoving == "":
print("CLEAR SELECTION*************")
game.clearSelection()
elif moves != null and !moves.regular_moves.has(game.selectedNode) and !moves.special_moves.has(game.selectedNode):
if sourcePiece and sourcePiece.Item_Color == piece.Item_Color:
game.selectedNode = location
game.getMovableAreas()
return
return
elif isCastlingMove(node, location):
handleCastling(node, generated)
finished.emit(Constants.POST_MOVE)

View file

@ -23,9 +23,10 @@ func apply_effect(piece: Pawn = null) -> void:
return
if last_piece and last_piece.id == piece.id:
return
# Check if partner portal tile has a piece on it
var partner_container = other_portal.base_button as PieceContainer
if partner_container.has_piece():
return
if partner_container && partner_container.has_piece():
return