From cb44ae4184d64ab67d576f2ca57373cccf891b5e Mon Sep 17 00:00:00 2001 From: Pavel Lutskov Date: Fri, 13 Aug 2021 17:32:33 +0200 Subject: [PATCH] Fix capture This will probably not be needed in the near future anyway --- frontend/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index 6187056..88e88b1 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -54,7 +54,6 @@ class Chess { this.canMoveTo = []; this.syncBackend(); document.onclick = (ev) => this.click(ev); - console.log(this.moveSource); } syncBackend() { let config = this.backend.getConfig(); @@ -67,7 +66,6 @@ class Chess { showAvailableMoves(canMoveTo) { } click(ev) { - console.log(this); if (this.moveSource === null) { this._firstClick(ev); } @@ -133,13 +131,16 @@ class Configuration { return this.pieces.find(piece => piece.position === position) || null; } dropAt(position) { - return this.pieces.filter(piece => piece.position !== position); + return new Configuration( + this.pieces.filter(piece => piece.position !== position) + ); } makeMove(move) { const pieceToMove = this.getAt(move.from); if (pieceToMove === null) return this; else return new Configuration([ - ...this.dropAt(move.from), pieceToMove.moveTo(move.to) + ...(this.dropAt(move.from).dropAt(move.to).pieces), + pieceToMove.moveTo(move.to) ]) } }