<% if (plugins.chess) { %>

Last chess game

<% if (plugins.chess.error) { %>
<%= plugins.chess.error.message %>
<% } else { %>
From <%= plugins.chess.platform %>
<%= plugins.chess.meta["White"] %> <% if (plugins.chess.meta["WhiteElo"]) { %>(<%= plugins.chess.meta["WhiteElo"] %> ELO)<% } %>
<% if (plugins.chess.result.white > plugins.chess.result.black) { %> <% } else { %> <% } %> <%= plugins.chess.result.white %> victor<%= s(plugins.chess.result.white, "y") %>
<%= plugins.chess.meta["Date"] %>
<%= plugins.chess.meta["Black"] %> <% if (plugins.chess.meta["BlackElo"]) { %>(<%= plugins.chess.meta["BlackElo"] %> ELO)<% } %>
<% if (plugins.chess.result.black > plugins.chess.result.white) { %> <% } else { %> <% } %> <%= plugins.chess.result.black %> victor<%= s(plugins.chess.result.black, "y") %>
<% { //Utilities functions const pieces = { w: {p: "♙", r: "♖", n: "♘", b: "♗", q: "♕", k: "♔"}, b: {p: "♟︎", r: "♜", n: "♞", b: "♝", q: "♛", k: "♚"}, } const init = ["rnbqkbnr", "pppppppp", "", "", "", "", "PPPPPPPP", "RNBQKBNR"] const column = p => ["a", "b", "c", "d", "e", "f", "g", "h"].indexOf(p[0]) const row = p => ["8", "7", "6", "5", "4", "3", "2", "1"].indexOf(p[1]) const animation = plugins.chess.animation const size = animation.size //Empty board for (let i = 0; i < 8; i++) { %>
<% for (let j = 0; j < 8; j++) { %>
<% } %>
<% } //Initial board state for (let i = 0; i < init.length; i++) { for (let j = 0; j < init[i].length; j++) { const color = /[A-Z]/.test(init[i][j]) ? "w" : "b", piece = init[i][j].toLocaleLowerCase() %>
<%- pieces[color][piece] %>
<% }} //Draw moves const moves = plugins.chess.moves for (let i = 0; i < moves.length; i++) { const {color, piece, from, to} = moves[i] %>
<%- pieces[color][piece] %>
<%- pieces[color][piece] %>
<% } %> <% } %>
<% } %>
<% } %>