fixed eice selection bug with invalid location
This commit is contained in:
parent
3d86f9c42e
commit
5d04deae9f
2 changed files with 22 additions and 6 deletions
|
|
@ -198,7 +198,7 @@ func _get_random_room_type(level, total_levels):
|
|||
return Utils.RoomType.BOSS
|
||||
elif roll < boss_chance + shop_chance:
|
||||
return Utils.RoomType.SHOP
|
||||
elif roll < boss_chance + shop_chance + event_chance:
|
||||
elif roll < boss_chance + shop_chance + event_chance and level > 5:
|
||||
return Utils.RoomType.EVENT
|
||||
else:
|
||||
return Utils.RoomType.NORMAL
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ extends "res://Systems/StateMachine/ChessGameState.gd"
|
|||
|
||||
var moves_remaining = {}
|
||||
var multiMoving = ""
|
||||
var last_selected = null
|
||||
|
||||
func _ready() -> void:
|
||||
print("Movement state ready")
|
||||
|
|
@ -16,7 +17,7 @@ func _setup_movement_modifiers() -> void:
|
|||
|
||||
func enter(_previous: String, _data := {}) -> void:
|
||||
print("ENTERING STATE ", Constants.MOVEMENT, " ", game.currentPlayer)
|
||||
|
||||
last_selected = null
|
||||
|
||||
_setup_movement_modifiers()
|
||||
if !game.boardContainer.is_connected("tile_pressed", handleMovement):
|
||||
|
|
@ -75,9 +76,16 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
|||
# we need to prevent swapping of focus between peices after the double move process has started
|
||||
# maybe once u start nmoving a peice global stat var is set
|
||||
# and any moving peice needs ot match that
|
||||
print("HANDLING MOVEMENT ", location, " | ", multiMoving, " | ", game.selectedNode)
|
||||
print("HANDLING MOVEMENT ", location, " | ", last_selected, " | ", game.selectedNode)
|
||||
var node = game.get_node("Flow/" + location) as PieceContainer
|
||||
|
||||
var prev_last_selected = last_selected
|
||||
if !generated :
|
||||
if last_selected == null:
|
||||
last_selected = location
|
||||
else:
|
||||
if game.selectedNode == location:
|
||||
last_selected = null
|
||||
var moves = null;
|
||||
# Only try to get piece if we have a selected node
|
||||
if game.selectedNode == "":
|
||||
# print("No Node")
|
||||
|
|
@ -86,13 +94,21 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
|||
if piece != null && piece.Item_Color == game.Turn:
|
||||
game.selectedNode = location
|
||||
game.getMovableAreas()
|
||||
last_selected = location
|
||||
return
|
||||
|
||||
# else:
|
||||
# moves = (game.get_node("Flow/" + game.selectedNode) as PieceContainer).get_piece().getValidMoves(game.boardContainer, location)
|
||||
var sourcePiece = node.get_piece()
|
||||
var moves = null;
|
||||
if sourcePiece:
|
||||
moves = sourcePiece.getValidMoves(game.boardContainer, location)
|
||||
|
||||
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
|
||||
|
||||
# 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()
|
||||
|
|
@ -144,12 +160,12 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
|||
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
|
||||
print("Movemnet ", moves)
|
||||
if isCastlingMove(node, location):
|
||||
handleCastling(node, generated)
|
||||
finished.emit(Constants.POST_MOVE)
|
||||
|
|
|
|||
Loading…
Reference in a new issue