X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=e987492b0682b1a05a757f044176f119039a60b4;hb=e8b85c869f8ed1a2e626f60c218c36121c49ec4e;hp=0dfe217e284c6d63f8e94c7e8af31a3ffdedc696;hpb=f429756ddd1ac5f12b0ae8e2231d7e7886fddc25;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 0dfe217..e987492 100644 --- a/base_rules.js +++ b/base_rules.js @@ -2124,7 +2124,13 @@ export default class ChessRules { (this.options["progressive"] && this.subTurn <= this.movesCount) ) { const oppKingPos = this.searchKingPos(oppCol); - if (oppKingPos[0] >= 0 && !this.underCheck(oppKingPos, color)) { + if ( + oppKingPos[0] >= 0 && + ( + this.options["taking"] || + !this.underCheck(oppKingPos, color) + ) + ) { this.subTurn++; return; } @@ -2183,7 +2189,9 @@ export default class ChessRules { playVisual(move, r) { move.vanish.forEach(v => { if (!this.enlightened || this.enlightened[v.x][v.y]) { - this.g_pieces[v.x][v.y].remove(); + // TODO: next "if" shouldn't be required + if (this.g_pieces[v.x][v.y]) + this.g_pieces[v.x][v.y].remove(); this.g_pieces[v.x][v.y] = null; } }); @@ -2236,6 +2244,11 @@ export default class ChessRules { const dropMove = (typeof i1 == "string"); const startArray = (dropMove ? this.r_pieces : this.g_pieces); let startPiece = startArray[i1][j1]; + // TODO: next "if" shouldn't be required + if (!startPiece) { + callback(); + return; + } let chessboard = document.getElementById(this.containerId).querySelector(".chessboard"); const clonePiece = (