fixed various selection bugs
This commit is contained in:
parent
ef6cee7883
commit
7df56f5855
2 changed files with 36 additions and 18 deletions
|
|
@ -676,7 +676,7 @@ func clearSelection() :
|
||||||
|
|
||||||
func getMovableAreas() -> void:
|
func getMovableAreas() -> void:
|
||||||
# Get all valid moves for the selected piece
|
# Get all valid moves for the selected piece
|
||||||
print("HIGHLIGHTING getMovableAreas 1", selectedNode)
|
print("HIGHLIGHTING getMovableAreas ", selectedNode)
|
||||||
resetHighlights()
|
resetHighlights()
|
||||||
areas.clear()
|
areas.clear()
|
||||||
specialArea.clear()
|
specialArea.clear()
|
||||||
|
|
@ -696,8 +696,8 @@ func getMovableAreas() -> void:
|
||||||
cardPreview.update_moves_remaining(moves_left)
|
cardPreview.update_moves_remaining(moves_left)
|
||||||
else:
|
else:
|
||||||
cardPreview.hide_preview()
|
cardPreview.hide_preview()
|
||||||
# print("HIGHLIGHTING getMovableAreas 3")
|
|
||||||
var moves = piece.getValidMoves(boardContainer, selectedNode)
|
var moves = piece.getValidMoves(boardContainer, selectedNode)
|
||||||
|
print("HIGHLIGHTING getMovableAreas ", moves)
|
||||||
areas = moves.regular_moves
|
areas = moves.regular_moves
|
||||||
specialArea = moves.special_moves
|
specialArea = moves.special_moves
|
||||||
# print("HIGHLIGHTING getMovableAreas 4")
|
# print("HIGHLIGHTING getMovableAreas 4")
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
# maybe once u start nmoving a peice global stat var is set
|
# maybe once u start nmoving a peice global stat var is set
|
||||||
# and any moving peice needs ot match that
|
# and any moving peice needs ot match that
|
||||||
print("HANDLING MOVEMENT ", location, " | ", last_selected, " | ", game.selectedNode)
|
print("HANDLING MOVEMENT ", location, " | ", last_selected, " | ", game.selectedNode)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var node = game.get_node("Flow/" + location) as PieceContainer
|
var node = game.get_node("Flow/" + location) as PieceContainer
|
||||||
var prev_last_selected = last_selected
|
var prev_last_selected = last_selected
|
||||||
if !generated :
|
if !generated :
|
||||||
|
|
@ -85,7 +89,13 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
else:
|
else:
|
||||||
if game.selectedNode == location:
|
if game.selectedNode == location:
|
||||||
last_selected = null
|
last_selected = null
|
||||||
var moves = null;
|
var moves = {
|
||||||
|
"regular_moves": game.areas,
|
||||||
|
"special_moves": game.specialArea
|
||||||
|
}
|
||||||
|
|
||||||
|
# areas = moves.regular_moves
|
||||||
|
# specialArea = moves.special_moves
|
||||||
# Only try to get piece if we have a selected node
|
# Only try to get piece if we have a selected node
|
||||||
if game.selectedNode == "":
|
if game.selectedNode == "":
|
||||||
# print("No Node")
|
# print("No Node")
|
||||||
|
|
@ -100,15 +110,13 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
# else:
|
# else:
|
||||||
# moves = (game.get_node("Flow/" + game.selectedNode) as PieceContainer).get_piece().getValidMoves(game.boardContainer, location)
|
# moves = (game.get_node("Flow/" + game.selectedNode) as PieceContainer).get_piece().getValidMoves(game.boardContainer, location)
|
||||||
var sourcePiece = node.get_piece()
|
var sourcePiece = node.get_piece()
|
||||||
if sourcePiece:
|
# if sourcePiece:
|
||||||
moves = sourcePiece.getValidMoves(game.boardContainer, location)
|
# moves = sourcePiece.getValidMoves(game.boardContainer, location)
|
||||||
|
|
||||||
if !(location == game.selectedNode):
|
# if !(location == game.selectedNode):
|
||||||
if !generated and moves != null and !moves.regular_moves.has(game.selectedNode) and !moves.special_moves.has(game.selectedNode):
|
|
||||||
last_selected = prev_last_selected
|
|
||||||
print("Invalid Choice")
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
|
# print("Valid Choice ", moves)
|
||||||
# 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()
|
||||||
|
|
@ -122,7 +130,23 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
var piece_id = piece.get_instance_id()
|
var piece_id = piece.get_instance_id()
|
||||||
|
|
||||||
var is_multi_moving = piece_id in moves_remaining and moves_remaining[piece_id] > 1
|
var is_multi_moving = piece_id in moves_remaining and moves_remaining[piece_id] > 1
|
||||||
|
if !generated and moves != null and !moves.regular_moves.has(location) and !moves.special_moves.has(location) and !(game.selectedNode == location and location == prev_last_selected):
|
||||||
|
last_selected = prev_last_selected
|
||||||
|
print("Invalid Choice ", moves)
|
||||||
|
if isReselectMove(node):
|
||||||
|
if !is_multi_moving and multiMoving == "":
|
||||||
|
print("RESELECT SELECTION*************")
|
||||||
|
game.selectedNode = location
|
||||||
|
game.getMovableAreas()
|
||||||
|
return
|
||||||
|
|
||||||
|
if game.selectedNode == location and location == prev_last_selected:
|
||||||
|
# print("CAN CLEAR SELECTION************* ", multiMoving, " !is_multi_moving ", !is_multi_moving)
|
||||||
|
if !is_multi_moving and multiMoving == "":
|
||||||
|
print("CLEAR SELECTION*************")
|
||||||
|
game.clearSelection()
|
||||||
|
return
|
||||||
|
return
|
||||||
|
|
||||||
if multiMoving.length() > 0:
|
if multiMoving.length() > 0:
|
||||||
|
|
||||||
|
|
@ -153,13 +177,7 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
# finished.emit(Constants.POST_MOVE)
|
# finished.emit(Constants.POST_MOVE)
|
||||||
|
|
||||||
|
|
||||||
if game.selectedNode == location:
|
if moves != null and !moves.regular_moves.has(game.selectedNode) and !moves.special_moves.has(game.selectedNode):
|
||||||
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):
|
|
||||||
if sourcePiece and sourcePiece.Item_Color == piece.Item_Color:
|
if sourcePiece and sourcePiece.Item_Color == piece.Item_Color:
|
||||||
# print("Set Location*************")
|
# print("Set Location*************")
|
||||||
game.selectedNode = location
|
game.selectedNode = location
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue