fixed drunk driving turn transtion breaking stockfish

This commit is contained in:
2ManyProjects 2025-03-01 10:06:27 -06:00
parent 498ddfbd12
commit ad2d67e91a
3 changed files with 23 additions and 9 deletions

View file

@ -22,7 +22,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
var current_y = int(current_pos[1])
# 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
# 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))
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)
var final_y = target_y
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])
final_y = tile_y - y_direction
break
print("CHECKING TILES ", tiles_to_check)
# Process pieces in path
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
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
print("FINAL TILES ", str(current_x) + "-" + str(final_y))
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
# AND keep a reference to it
@ -66,6 +76,8 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
burned = true
game_state.resolveMoveEffects()
game_state.clearSelection()
game_state.stateMachine.transitionToNextState(Constants.POST_MOVE)
# Breaks Stockfish for some reason
return true

View file

@ -198,9 +198,6 @@ func getCurrentFen() -> String:
if piece == null:
emptySquares += 1
else:
if emptySquares > 0:
fen += str(emptySquares)
emptySquares = 0
# Convert piece to FEN notation
var fenChar = getPieceFenChar(piece)
fen += fenChar

View file

@ -22,6 +22,7 @@ func enter(_previous: String, _data := {}) -> void:
timer.start(ATTACHMENT_PHASE_DURATION)
if game.deckManager.hand.is_empty():
complete_attachment_phase()
func exit() -> void:
@ -63,8 +64,12 @@ func handleTilePressed(location: String) -> void:
print("Failed to attach card")
func _on_timer_timeout() -> void:
print("Card attachment phase timed out")
finished.emit(Constants.APPLY_CARD_EFFECTS)
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")
finished.emit(Constants.APPLY_CARD_EFFECTS)
func complete_attachment_phase() -> void:
if timer.time_left > 0: