v0.14.0 web replay UI, My games, CLI replay
This commit is contained in:
37 files changed
+4058
-1803
No files matched your search
@@ -674,6 +674,7 @@ func (p *Processor) buildGameResponse(gameID string, g game.View) core.GameRespo
|
||||
State: g.State.String(),
|
||||
Termination: string(g.Termination),
|
||||
Moves: g.Moves,
|
||||
SAN: notateLine(g.FENs, g.Moves),
|
||||
Players: core.PlayersResponse{
|
||||
White: g.WhitePlayer,
|
||||
Black: g.BlackPlayer,
|
||||
@@ -721,6 +722,27 @@ func (p *Processor) Close() error {
|
||||
return errors.Join(queueErr, engineErr)
|
||||
}
|
||||
|
||||
// notateLine derives SAN for each live move from the position before it,
|
||||
// fens[i] being the position before moves[i]. Each ply stands alone, so a
|
||||
// position the core cannot parse leaves only that entry empty (and is logged
|
||||
// once, by the shadow check, when the move was made).
|
||||
func notateLine(fens, moves []string) []string {
|
||||
san := make([]string, len(moves))
|
||||
for i, uci := range moves {
|
||||
if i >= len(fens) {
|
||||
break
|
||||
}
|
||||
pos, err := chess.ParseFEN(fens[i])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if m, err := pos.ParseUCI(uci); err == nil {
|
||||
san[i] = pos.SAN(m)
|
||||
}
|
||||
}
|
||||
return san
|
||||
}
|
||||
|
||||
// rulesResult is the rules core's verdict on a move, computed alongside the
|
||||
// engine's. Stockfish stays authoritative; a disagreement is logged so the
|
||||
// core can be trusted, or fixed, before it validates anything.
|
||||
|
||||
Reference in new issue
Block a user