@@ -31,6 +31,7 @@ class Chess {
|
||||
this.canvas = new visuals.Canvas();
|
||||
this.configVis = new visuals.ConfigVis(this.backend.getConfig());
|
||||
this.configVis.draw(this.canvas);
|
||||
this.activeSquares = new visuals.ActiveSquares();
|
||||
this.moveSource = null;
|
||||
this.canMoveTo = [];
|
||||
document.onclick = (ev) => this.click(ev);
|
||||
@@ -44,12 +45,14 @@ class Chess {
|
||||
if (source === null) return;
|
||||
let validMoves = this.backend.getAvailableMoves(source);
|
||||
if (validMoves === null) return;
|
||||
this.activeSquares.selectSquare(this.canvas, source);
|
||||
this.moveSource = source;
|
||||
}
|
||||
finalizeMove(target) {
|
||||
if (target !== null) {
|
||||
this.backend.makeMove(this.moveSource, target);
|
||||
}
|
||||
this.activeSquares.unselectSquare(this.canvas);
|
||||
this.syncBackend();
|
||||
this.moveSource = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user