X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FEmergo.js;h=a1a98488b23bb989950327137631f7312499a570;hb=3de62e0a608bd2be22c875930bb538b674968a6b;hp=81ad5d5f4ef5c4938b237ff227e8b0c860b01582;hpb=4ab9394ba4b27737fe6706af2fbb8d7c6c9fe268;p=vchess.git diff --git a/client/src/variants/Emergo.js b/client/src/variants/Emergo.js index 81ad5d5f..a1a98488 100644 --- a/client/src/variants/Emergo.js +++ b/client/src/variants/Emergo.js @@ -399,7 +399,7 @@ export class EmergoRules extends ChessRules { return []; } const color = this.turn; - if (!!this.reserve[color] && !this.atLeastOneCapture()) return []; + if (!!this.reserve[color] && !this.atLeastOneCapture(color)) return []; const L0 = this.captures.length; const captures = this.captures[L0 - 1]; const L = captures.length; @@ -479,7 +479,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); @@ -497,8 +501,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;