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 cardDisplay: CardDisplay
@onready var cardPreview: CardPreview @onready var cardPreview: CardPreview
@export var boardXSize = 8 @export var boardXSize = 12
@export var boardYSize = 8 @export var boardYSize = 12
@export var tileXSize: int = 50 @export var tileXSize: int = 50
@export var tileYSize: int = 50 @export var tileYSize: int = 50
@export var windowXSize: int = 1280 @export var windowXSize: int = 1280

View file

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

View file

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