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
|
return Utils.RoomType.BOSS
|
||||||
elif roll < boss_chance + shop_chance:
|
elif roll < boss_chance + shop_chance:
|
||||||
return Utils.RoomType.SHOP
|
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
|
return Utils.RoomType.EVENT
|
||||||
else:
|
else:
|
||||||
return Utils.RoomType.NORMAL
|
return Utils.RoomType.NORMAL
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ extends "res://Systems/StateMachine/ChessGameState.gd"
|
||||||
|
|
||||||
var moves_remaining = {}
|
var moves_remaining = {}
|
||||||
var multiMoving = ""
|
var multiMoving = ""
|
||||||
|
var last_selected = null
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
print("Movement state ready")
|
print("Movement state ready")
|
||||||
|
|
@ -16,7 +17,7 @@ func _setup_movement_modifiers() -> void:
|
||||||
|
|
||||||
func enter(_previous: String, _data := {}) -> void:
|
func enter(_previous: String, _data := {}) -> void:
|
||||||
print("ENTERING STATE ", Constants.MOVEMENT, " ", game.currentPlayer)
|
print("ENTERING STATE ", Constants.MOVEMENT, " ", game.currentPlayer)
|
||||||
|
last_selected = null
|
||||||
|
|
||||||
_setup_movement_modifiers()
|
_setup_movement_modifiers()
|
||||||
if !game.boardContainer.is_connected("tile_pressed", handleMovement):
|
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
|
# 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
|
# 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, " | ", multiMoving, " | ", 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
|
||||||
|
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
|
# Only try to get piece if we have a selected node
|
||||||
if game.selectedNode == "":
|
if game.selectedNode == "":
|
||||||
# print("No Node")
|
# print("No Node")
|
||||||
|
|
@ -86,12 +94,20 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
if piece != null && piece.Item_Color == game.Turn:
|
if piece != null && piece.Item_Color == game.Turn:
|
||||||
game.selectedNode = location
|
game.selectedNode = location
|
||||||
game.getMovableAreas()
|
game.getMovableAreas()
|
||||||
|
last_selected = location
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# else:
|
||||||
|
# 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()
|
||||||
var moves = null;
|
|
||||||
if sourcePiece:
|
if sourcePiece:
|
||||||
moves = sourcePiece.getValidMoves(game.boardContainer, location)
|
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
|
# 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
|
||||||
|
|
@ -144,12 +160,12 @@ func handleMovement(location: String, generated: bool = false) -> void:
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
elif moves != null and !moves.regular_moves.has(game.selectedNode) and !moves.special_moves.has(game.selectedNode):
|
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:
|
if sourcePiece and sourcePiece.Item_Color == piece.Item_Color:
|
||||||
# print("Set Location*************")
|
# print("Set Location*************")
|
||||||
game.selectedNode = location
|
game.selectedNode = location
|
||||||
game.getMovableAreas()
|
game.getMovableAreas()
|
||||||
return
|
return
|
||||||
|
print("Movemnet ", moves)
|
||||||
if isCastlingMove(node, location):
|
if isCastlingMove(node, location):
|
||||||
handleCastling(node, generated)
|
handleCastling(node, generated)
|
||||||
finished.emit(Constants.POST_MOVE)
|
finished.emit(Constants.POST_MOVE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue