cm-chessboard 4.1.2 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.html +8 -5
  2. package/package.json +1 -1
package/index.html CHANGED
@@ -37,15 +37,18 @@ It works, it is cool and it is easy to use. 👍</p>
37
37
  const board = new Chessboard(document.getElementById("board"), {
38
38
  position: "start"
39
39
  })
40
- setInterval(() => {
40
+ const interval = setInterval(() => {
41
41
  makeRandomMove()
42
42
  board.setPosition(chess.fen(), true)
43
43
  }, 250)
44
44
  function makeRandomMove() {
45
- const possibleMoves = chess.moves();
46
- if (possibleMoves.length === 0) return;
47
- const randomIndex = Math.floor(Math.random() * possibleMoves.length);
48
- chess.move(possibleMoves[randomIndex]);
45
+ const possibleMoves = chess.moves()
46
+ if (possibleMoves.length === 0) {
47
+ clearInterval(interval)
48
+ return
49
+ }
50
+ const randomIndex = Math.floor(Math.random() * possibleMoves.length)
51
+ chess.move(possibleMoves[randomIndex])
49
52
  }
50
53
  </script>
51
54
  <div class="clearfix"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",