X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FEmergo.js;h=13069de48c209d22e94b9fda49e38f5493f93801;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=98d9d71ac4ac2bd9e88162ec3a3912c1ee1488d2;hpb=b27300c2951adcc67acbf4b822267dc102895ce3;p=vchess.git diff --git a/client/src/variants/Emergo.js b/client/src/variants/Emergo.js index 98d9d71a..13069de4 100644 --- a/client/src/variants/Emergo.js +++ b/client/src/variants/Emergo.js @@ -8,6 +8,10 @@ export class EmergoRules extends ChessRules { // Lowercase if black controls. // Single piece (no prisoners): A@ to L@ (+ lowercase) + static get Options() { + return null; + } + static get HasFlags() { return false; } @@ -105,7 +109,7 @@ export class EmergoRules extends ChessRules { return { x: 9, y: 9 }; } - static GenRandInitFen(randomness) { + static GenRandInitFen() { return "9/9/9/9/9/9/9/9/9 w 0 12,12"; } @@ -399,6 +403,7 @@ export class EmergoRules extends ChessRules { return []; } const color = this.turn; + if (!!this.reserve[color] && !this.atLeastOneCapture(color)) return []; const L0 = this.captures.length; const captures = this.captures[L0 - 1]; const L = captures.length; @@ -478,7 +483,11 @@ export class EmergoRules extends ChessRules { move.notTheEnd = true; } else if (move.vanish == 0) { - if (--this.reserve[color][V.PAWN] == 0) this.reserve[color] = null; + const firstCode = (color == 'w' ? 65 : 97); + // Generally, reserveCount == 1 (except for shadow piece) + const reserveCount = move.appear[0].c.charCodeAt() - firstCode + 1; + this.reserve[color][V.PAWN] -= reserveCount; + if (this.reserve[color][V.PAWN] == 0) this.reserve[color] = null; } if (!move.notTheEnd) { this.turn = V.GetOppCol(color); @@ -496,8 +505,10 @@ export class EmergoRules extends ChessRules { } if (move.vanish.length == 0) { const color = (move.appear[0].c == 'A' ? 'w' : 'b'); - if (!this.reserve[color]) this.reserve[color] = { [V.PAWN]: 1 }; - else this.reserve[color][V.PAWN]++; + const firstCode = (color == 'w' ? 65 : 97); + const reserveCount = move.appear[0].c.charCodeAt() - firstCode + 1; + if (!this.reserve[color]) this.reserve[color] = { [V.PAWN]: 0 }; + this.reserve[color][V.PAWN] += reserveCount; } else if (move.vanish.length == 2) { const L0 = this.captures.length;