Fix capture
This will probably not be needed in the near future anyway
This commit is contained in:
@@ -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)
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user