fixed drunk driving turn transtion breaking stockfish
This commit is contained in:
parent
498ddfbd12
commit
ad2d67e91a
3 changed files with 23 additions and 9 deletions
|
|
@ -22,7 +22,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
var current_y = int(current_pos[1])
|
var current_y = int(current_pos[1])
|
||||||
|
|
||||||
# Calculate target position
|
# Calculate target position
|
||||||
var target_y = 7 if target_piece.Item_Color == 1 else 0
|
var target_y = game_state.boardYSize - 1 if target_piece.Item_Color == 1 else 0
|
||||||
var y_direction = 1 if target_y > current_y else -1
|
var y_direction = 1 if target_y > current_y else -1
|
||||||
|
|
||||||
# Generate tiles to check
|
# Generate tiles to check
|
||||||
|
|
@ -32,6 +32,12 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
tiles_to_check.append(str(current_x) + "-" + str(y))
|
tiles_to_check.append(str(current_x) + "-" + str(y))
|
||||||
y += y_direction
|
y += y_direction
|
||||||
|
|
||||||
|
if game_state.isPlayerTurn():
|
||||||
|
print("")
|
||||||
|
else:
|
||||||
|
print("REVERSING TILES TO CHECK")
|
||||||
|
tiles_to_check.reverse()
|
||||||
|
|
||||||
# Find final position (stop before any impassable tile)
|
# Find final position (stop before any impassable tile)
|
||||||
var final_y = target_y
|
var final_y = target_y
|
||||||
for tile_name in tiles_to_check:
|
for tile_name in tiles_to_check:
|
||||||
|
|
@ -41,10 +47,14 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
var tile_y = int(tile_name.split("-")[1])
|
var tile_y = int(tile_name.split("-")[1])
|
||||||
final_y = tile_y - y_direction
|
final_y = tile_y - y_direction
|
||||||
break
|
break
|
||||||
print("CHECKING TILES ", tiles_to_check)
|
|
||||||
# Process pieces in path
|
# Process pieces in path
|
||||||
for tile_name in tiles_to_check:
|
for tile_name in tiles_to_check:
|
||||||
var tile_y = int(tile_name.split("-")[1])
|
var tile = game_state.tileManager.get_tile(tile_name)
|
||||||
|
if tile && !tile.passable:
|
||||||
|
# print("CHECKING TILES ", tile_name, " passable ", tile.passable)
|
||||||
|
break
|
||||||
|
# elif !tile:
|
||||||
|
# print("CHECKING TILES ", tile_name, " no tile")
|
||||||
# Only process tiles up to where we're stopping
|
# Only process tiles up to where we're stopping
|
||||||
|
|
||||||
var container = board_flow.get_node(tile_name) as PieceContainer
|
var container = board_flow.get_node(tile_name) as PieceContainer
|
||||||
|
|
@ -55,7 +65,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
# Move piece to final position
|
# Move piece to final position
|
||||||
print("FINAL TILES ", str(current_x) + "-" + str(final_y))
|
print("FINAL TILES ", str(current_x) + "-" + str(final_y))
|
||||||
var final_container = board_flow.get_node(str(current_x) + "-" + str(final_y)) as PieceContainer
|
var final_container = board_flow.get_node(str(current_x) + "-" + str(final_y)) as PieceContainer
|
||||||
print("FINAL TILES ", final_container.get_piece().Item_Color)
|
# print("FINAL TILES ", final_container.get_piece().Item_Color)
|
||||||
|
|
||||||
# Important: Need to remove the piece from its current container first
|
# Important: Need to remove the piece from its current container first
|
||||||
# AND keep a reference to it
|
# AND keep a reference to it
|
||||||
|
|
@ -66,6 +76,8 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
burned = true
|
burned = true
|
||||||
|
|
||||||
game_state.resolveMoveEffects()
|
game_state.resolveMoveEffects()
|
||||||
|
game_state.clearSelection()
|
||||||
game_state.stateMachine.transitionToNextState(Constants.POST_MOVE)
|
game_state.stateMachine.transitionToNextState(Constants.POST_MOVE)
|
||||||
|
# Breaks Stockfish for some reason
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -198,9 +198,6 @@ func getCurrentFen() -> String:
|
||||||
if piece == null:
|
if piece == null:
|
||||||
emptySquares += 1
|
emptySquares += 1
|
||||||
else:
|
else:
|
||||||
if emptySquares > 0:
|
|
||||||
fen += str(emptySquares)
|
|
||||||
emptySquares = 0
|
|
||||||
# Convert piece to FEN notation
|
# Convert piece to FEN notation
|
||||||
var fenChar = getPieceFenChar(piece)
|
var fenChar = getPieceFenChar(piece)
|
||||||
fen += fenChar
|
fen += fenChar
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ func enter(_previous: String, _data := {}) -> void:
|
||||||
if game.deckManager.hand.is_empty():
|
if game.deckManager.hand.is_empty():
|
||||||
complete_attachment_phase()
|
complete_attachment_phase()
|
||||||
|
|
||||||
|
|
||||||
func exit() -> void:
|
func exit() -> void:
|
||||||
|
|
||||||
if game.boardContainer.is_connected("tile_pressed", handleTilePressed):
|
if game.boardContainer.is_connected("tile_pressed", handleTilePressed):
|
||||||
|
|
@ -63,6 +64,10 @@ func handleTilePressed(location: String) -> void:
|
||||||
print("Failed to attach card")
|
print("Failed to attach card")
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
|
|
||||||
|
var stateString: RichTextLabel = owner.get_node("StateLabel")
|
||||||
|
# prevent transition of state is already changed by other effects
|
||||||
|
if stateString.text == "AttachCards":
|
||||||
print("Card attachment phase timed out")
|
print("Card attachment phase timed out")
|
||||||
finished.emit(Constants.APPLY_CARD_EFFECTS)
|
finished.emit(Constants.APPLY_CARD_EFFECTS)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue