More readable Chess notation

This commit is contained in:
Wuzzy 2023-07-11 11:06:29 +02:00
parent 1919a2e7f8
commit 578dea473a

View File

@ -666,14 +666,15 @@ local function get_moves_formstring(meta)
-- Add move number (e.g. " 3.") -- Add move number (e.g. " 3.")
moves_out = moves_out .. string.format("% d.", move_no) .. "," moves_out = moves_out .. string.format("% d.", move_no) .. ","
end end
local eatenSymbol = "" local betweenCoordsSymbol = "" -- to be inserted between source and destination coords
local enPassantSymbol = "" -- dash for normal moves, × for capturing moves
local enPassantSymbol = "" -- symbol for en passant captures
if pieceTo ~= "" then if pieceTo ~= "" then
-- normal capture -- normal capture
eatenSymbol = "x" betweenCoordsSymbol = "×"
elseif pieceTo == "" and pieceFrom:sub(11,14) == "pawn" and from_x ~= to_x then elseif pieceTo == "" and pieceFrom:sub(11,14) == "pawn" and from_x ~= to_x then
-- 'en passant' capture -- 'en passant' capture
eatenSymbol = "x" betweenCoordsSymbol = "×"
enPassantSymbol = " e. p." enPassantSymbol = " e. p."
end end
@ -683,18 +684,18 @@ local function get_moves_formstring(meta)
moves_out = moves_out .. MOVES_LIST_SYMBOL_EMPTY .. "," moves_out = moves_out .. MOVES_LIST_SYMBOL_EMPTY .. ","
-- queenside castling -- queenside castling
if to_x == 2 then if to_x == 2 then
-- write "0-0-0" -- write "000"
moves_out = moves_out .. "0-0-0" moves_out = moves_out .. "000"
-- kingside castling -- kingside castling
elseif to_x == 6 then elseif to_x == 6 then
-- write "0-0" -- write "00"
moves_out = moves_out .. "0-0" moves_out = moves_out .. "00"
end end
-- Normal halfmove -- Normal halfmove
else else
moves_out = moves_out .. moves_out = moves_out ..
pieceFrom_si_id .. "," .. -- piece image ID pieceFrom_si_id .. "," .. -- piece image ID
coordFrom .. eatenSymbol .. coordTo .. -- coords in long algebraic notation, e.g. "e2e3" coordFrom .. betweenCoordsSymbol .. coordTo .. -- coords in long algebraic notation, e.g. "e2e3"
enPassantSymbol -- written in case of an 'en passant' capture enPassantSymbol -- written in case of an 'en passant' capture
end end