X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=ae2ca80dfa1405239f46806b8124dcea0e9f7d13;hb=3ca478329f818efdfe2e03ce72c0effa6a8b0c0b;hp=8c7d549469dcdd62c5670148227ae8a808ec698c;hpb=dcfaab5dc62ccd9701ff314ad4e3d40c40223d44;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 8c7d549..ae2ca80 100644 --- a/base_rules.js +++ b/base_rules.js @@ -324,7 +324,7 @@ export default class ChessRules { // Flags part of the FEN string getFlagsFen() { - return ["w", "b"].map(c => { + return ['w', 'b'].map(c => { return this.castleFlags[c].map(x => x.toString(36)).join(""); }).join(""); } @@ -340,7 +340,7 @@ export default class ChessRules { if (o.init) return "000000000000"; return ( - ["w","b"].map(c => Object.values(this.reserve[c]).join("")).join("") + ['w', 'b'].map(c => Object.values(this.reserve[c]).join("")).join("") ); } @@ -2236,7 +2236,7 @@ export default class ChessRules { } // NOTE: arg "castleFlags" for Coregal or Twokings - updateCastleFlags(move, castleFlags) { + updateCastleFlags(move, castleFlags, king) { castleFlags = castleFlags || this.castleFlags; // If flags already off, no need to re-check: if ( @@ -2247,7 +2247,7 @@ export default class ChessRules { } // Update castling flags if start or arrive from/at rook/king locations move.appear.concat(move.vanish).forEach(psq => { - if (this.isKing(0, 0, psq.p)) + if ((!!king && psq.p == king) || this.isKing(0, 0, psq.p)) castleFlags[psq.c] = [this.size.y, this.size.y]; // NOTE: not "else if" because king can capture enemy rook... let c = "";