X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FSuicide.js;h=e71e3a2e250c954737fbf8297bf1fed6d39a9249;hb=0f7762c1d87e21d1c13ff0f38bd234b64b0a29d9;hp=c81d35514ae193b715d4d0f23421ba31612b5add;hpb=6f2f94374f1e73c375edf732d9425e575e81fff7;p=vchess.git diff --git a/client/src/variants/Suicide.js b/client/src/variants/Suicide.js index c81d3551..e71e3a2e 100644 --- a/client/src/variants/Suicide.js +++ b/client/src/variants/Suicide.js @@ -3,11 +3,8 @@ import { ArrayFun } from "@/utils/array"; import { shuffle } from "@/utils/alea"; export class SuicideRules extends ChessRules { - static get HasFlags() { - return false; - } - static get HasCastle() { + static get HasFlags() { return false; } @@ -32,8 +29,9 @@ export class SuicideRules extends ChessRules { if (V.PIECES.includes(lowerRi)) { pieces[row[i] == lowerRi ? "b" : "w"]++; sumElts++; - } else { - const num = parseInt(row[i]); + } + else { + const num = parseInt(row[i], 10); if (isNaN(num)) return false; sumElts += num; } @@ -54,12 +52,11 @@ export class SuicideRules extends ChessRules { // Stop at the first capture found (if any) atLeastOneCapture() { const color = this.turn; - const oppCol = V.GetOppCol(color); for (let i = 0; i < V.size.x; i++) { for (let j = 0; j < V.size.y; j++) { if ( this.board[i][j] != V.EMPTY && - this.getColor(i, j) != oppCol && + this.getColor(i, j) == color && this.getPotentialMovesFrom([i, j]).some(m => m.vanish.length == 2) ) { return true; @@ -170,4 +167,5 @@ export class SuicideRules extends ChessRules { " w 0 -" ); } + };