fixes lol
All checks were successful
Build and Push / build-all (push) Successful in 1m13s

This commit is contained in:
doomtube 2026-01-08 23:58:35 -05:00
parent b43c6210be
commit 89c2e1630d

View file

@ -550,7 +550,7 @@ func (m *ChessMatch) MatchLoop(ctx context.Context, logger runtime.Logger, db *s
} }
// Validate and apply the move // Validate and apply the move
result := validateChessMove(s.FEN, moveData.From, moveData.To, moveData.Promotion) result := validateChessMove(s.FEN, moveData.From, moveData.To, moveData.Promotion, logger)
if !result.Valid { if !result.Valid {
logger.Warn("Invalid move: %+v", moveData) logger.Warn("Invalid move: %+v", moveData)
continue continue
@ -754,16 +754,20 @@ type MoveResult struct {
} }
// Validate chess move using corentings/chess/v2 library // Validate chess move using corentings/chess/v2 library
func validateChessMove(fenStr, from, to, promotion string) MoveResult { func validateChessMove(fenStr, from, to, promotion string, logger runtime.Logger) MoveResult {
result := MoveResult{Turn: "w"} result := MoveResult{Turn: "w"}
logger.Info("validateChessMove: FEN=%s, move=%s%s", fenStr, from, to)
// Parse FEN // Parse FEN
fen, err := chess.FEN(fenStr) fen, err := chess.FEN(fenStr)
if err != nil { if err != nil {
logger.Error("validateChessMove: FEN parse error: %v", err)
return result return result
} }
game := chess.NewGame(fen) game := chess.NewGame(fen)
logger.Info("validateChessMove: Game created, valid moves count: %d", len(game.ValidMoves()))
// Verify move is valid first // Verify move is valid first
found := false found := false
@ -807,9 +811,11 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult {
// Check game over // Check game over
outcome := game.Outcome() outcome := game.Outcome()
method := game.Method()
logger.Info("validateChessMove: outcome=%v, method=%v", outcome, method)
if outcome != chess.NoOutcome { if outcome != chess.NoOutcome {
result.GameOver = true result.GameOver = true
method := game.Method()
switch outcome { switch outcome {
case chess.WhiteWon: case chess.WhiteWon:
@ -819,6 +825,7 @@ func validateChessMove(fenStr, from, to, promotion string) MoveResult {
case chess.Draw: case chess.Draw:
result.Result = "1/2-1/2" result.Result = "1/2-1/2"
} }
logger.Info("validateChessMove: GAME OVER detected! result=%s, reason will be set based on method", result.Result)
switch method { switch method {
case chess.Checkmate: case chess.Checkmate: