X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FApocalypse.js;h=fc309155877bc3f037125c2fb35f77178ec8a761;hb=HEAD;hp=c136ff2863ffcf2e0821d84e9e22dfd2e33807c4;hpb=b866a62ab3d1d427688954383ed7035111b0e132;p=vchess.git diff --git a/client/src/variants/Apocalypse.js b/client/src/variants/Apocalypse.js index c136ff28..fc309155 100644 --- a/client/src/variants/Apocalypse.js +++ b/client/src/variants/Apocalypse.js @@ -2,6 +2,11 @@ import { ChessRules } from "@/base_rules"; import { randInt } from "@/utils/alea"; export class ApocalypseRules extends ChessRules { + + static get Options() { + return null; + } + static get PawnSpecs() { return Object.assign( {}, @@ -13,6 +18,10 @@ export class ApocalypseRules extends ChessRules { ); } + static get SomeHiddenMoves() { + return true; + } + static get HasCastle() { return false; } @@ -51,7 +60,7 @@ export class ApocalypseRules extends ChessRules { if (['P','p'].includes(row[i])) pawns[row[i]]++; if (V.PIECES.includes(row[i].toLowerCase())) sumElts++; else { - const num = parseInt(row[i]); + const num = parseInt(row[i], 10); if (isNaN(num)) return false; sumElts += num; } @@ -135,8 +144,8 @@ export class ApocalypseRules extends ChessRules { setFlags(fenflags) { this.penaltyFlags = { - 'w': parseInt(fenflags[0]), - 'b': parseInt(fenflags[1]) + 'w': parseInt(fenflags[0], 10), + 'b': parseInt(fenflags[1], 10) }; } @@ -146,8 +155,7 @@ export class ApocalypseRules extends ChessRules { start: this.whiteMove.start, end: this.whiteMove.end, appear: this.whiteMove.appear, - vanish: this.whiteMove.vanish, - illegal: this.whiteMove.illegal + vanish: this.whiteMove.vanish }); } @@ -177,7 +185,7 @@ export class ApocalypseRules extends ChessRules { const mHash = "m" + vm.start.x + vm.start.y + vm.end.x + vm.end.y; if (!moveSet[mHash]) { moveSet[mHash] = true; - vm.illegal = true; //potentially illegal! + vm.end.illegal = true; //potentially illegal! speculations.push(vm); } }); @@ -279,7 +287,7 @@ export class ApocalypseRules extends ChessRules { m.vanish[1].c != m.vanish[0].c || // Self-capture attempt ( - !other.illegal && + !other.end.illegal && other.end.x == m.end.x && other.end.y == m.end.y ) @@ -288,7 +296,7 @@ export class ApocalypseRules extends ChessRules { || ( m.vanish[0].p == V.PAWN && - !other.illegal && + !other.end.illegal && ( ( // Promotion attempt @@ -315,14 +323,14 @@ export class ApocalypseRules extends ChessRules { ) ); }; - if (!!m1.illegal && !isPossible(m1, m2)) { + if (!!m1.end.illegal && !isPossible(m1, m2)) { // Either an anticipated capture of something which didn't move // (or not to the right square), or a push through blocus. // ==> Just discard the move, and add a penalty point this.penaltyFlags[m1.vanish[0].c]++; m1.isNull = true; } - if (!!m2.illegal && !isPossible(m2, m1)) { + if (!!m2.end.illegal && !isPossible(m2, m1)) { this.penaltyFlags[m2.vanish[0].c]++; m2.isNull = true; } @@ -371,8 +379,8 @@ export class ApocalypseRules extends ChessRules { let remain = null; const p1 = m1.vanish[0].p; const p2 = m2.vanish[0].p; - if (!!m1.illegal && !m2.illegal) remain = { c: 'w', p: p1 }; - else if (!!m2.illegal && !m1.illegal) remain = { c: 'b', p: p2 }; + if (!!m1.end.illegal && !m2.end.illegal) remain = { c: 'w', p: p1 }; + else if (!!m2.end.illegal && !m1.end.illegal) remain = { c: 'b', p: p2 }; if (!remain) { // Either both are illegal or both are legal if (p1 == V.KNIGHT && p2 == V.PAWN) remain = { c: 'w', p: p1 }; @@ -428,7 +436,7 @@ export class ApocalypseRules extends ChessRules { else this.whiteMove = move.whiteMove; } - getCheckSquares(color) { + getCheckSquares() { return []; } @@ -474,7 +482,7 @@ export class ApocalypseRules extends ChessRules { let illegalMoves = []; moves.forEach(m => { // Warning: m might be illegal! - if (!m.illegal) { + if (!m.end.illegal) { V.PlayOnBoard(this.board, m); m.eval = this.evalPosition(); V.UndoOnBoard(this.board, m); @@ -509,4 +517,5 @@ export class ApocalypseRules extends ChessRules { V.CoordsToSquare(move.end) ); } + };