X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAntiking1.js;h=ac28c31c5fcbe0fd33ecae5c9bb0cfd5349393b7;hb=6f2f94374f1e73c375edf732d9425e575e81fff7;hp=75cc14cb26fdcbfae9e7943d52f153dbfde2e80e;hpb=32f6285ee325a14286562a53baefc647201df2af;p=vchess.git diff --git a/client/src/variants/Antiking1.js b/client/src/variants/Antiking1.js index 75cc14cb..ac28c31c 100644 --- a/client/src/variants/Antiking1.js +++ b/client/src/variants/Antiking1.js @@ -28,6 +28,19 @@ export class Antiking1Rules extends BerolinaRules { return b[1] == "a" ? "Antiking/" + b : b; } + static IsGoodPosition(position) { + if (!ChessRules.IsGoodPosition(position)) return false; + const rows = position.split("/"); + // Check that exactly one antiking of each color is there: + let antikings = { 'a': 0, 'A': 0 }; + for (let row of rows) { + for (let i = 0; i < row.length; i++) + if (['A','a'].includes(row[i])) antikings[row[i]]++; + } + if (Object.values(antikings).some(v => v != 1)) return false; + return true; + } + setOtherVariables(fen) { super.setOtherVariables(fen); this.antikingPos = { w: [-1, -1], b: [-1, -1] }; @@ -192,21 +205,6 @@ export class Antiking1Rules extends BerolinaRules { this.antikingPos[c] = [move.start.x, move.start.y]; } - getCurrentScore() { - if (this.atLeastOneMove()) - return "*"; - - const color = this.turn; - const oppCol = V.GetOppCol(color); - if ( - !this.isAttacked(this.kingPos[color], oppCol) && - this.isAttacked(this.antikingPos[color], oppCol) - ) { - return "1/2"; - } - return color == "w" ? "0-1" : "1-0"; - } - static get VALUES() { return Object.assign( { a: 1000 },