Fix Arena diag
[vchess.git] / client / src / utils / squareId.js
CommitLineData
582df349 1// Get the identifier of a HTML square from its numeric coordinates o.x,o.y.
6808d7a1 2export function getSquareId(o) {
dac39588 3 // NOTE: a separator is required to allow any size of board
6808d7a1 4 return "sq-" + o.x + "-" + o.y;
582df349
BA
5}
6
7// Inverse function
6808d7a1
BA
8export function getSquareFromId(id) {
9 const idParts = id.split("-");
e50a8025 10 return [parseInt(idParts[1], 10), parseInt(idParts[2], 10)];
582df349 11}