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) ]) } }