How to use the chessground/util.opposite function in chessground

To help you get started, we’ve selected a few chessground examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Happy0 / ssb-chess / ui / game / PieceGraveyard.js View on Github external
function getMaterialDiff(pieces) {

    var diff = {
      white: { king: 0, queen: 0, rook: 0, bishop: 0, knight: 0, pawn: 0 },
      black: { king: 0, queen: 0, rook: 0, bishop: 0, knight: 0, pawn: 0 },
    };

    for (let k in pieces) {
      const p = pieces[k], them = diff[opposite(p.color)];
      if (them[p.role] > 0) them[p.role]--;
      else diff[p.color][p.role]++;
    }

    return diff;
  }

chessground

lichess.org chess ui

GPL-3.0
Latest version published 3 days ago

Package Health Score

81 / 100
Full package analysis