X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=33b0fc9022f6f4a585af32d3d3f534c36f6139e8;hb=6b7b2cf720e6255e4da0dc34fee363c456346a58;hp=2bfdc997588b12a990d74158b5c06c0023e70d40;hpb=b83a675a3066c67cc7843ae27ad8aeffd15b0976;p=vchess.git diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 2bfdc997..33b0fc90 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -428,6 +428,7 @@ export const ChessRules = class ChessRules { this.INIT_COL_ROOK = { w: [-1, -1], b: [-1, -1] }; this.kingPos = { w: [-1, -1], b: [-1, -1] }; //squares of white and black king const fenRows = V.ParseFen(fen).position.split("/"); + const startRow = { 'w': V.size.x - 1, 'b': 0 }; for (let i = 0; i < fenRows.length; i++) { let k = 0; //column index on board for (let j = 0; j < fenRows[i].length; j++) { @@ -441,12 +442,16 @@ export const ChessRules = class ChessRules { this.INIT_COL_KING["w"] = k; break; case "r": - if (this.INIT_COL_ROOK["b"][0] < 0) this.INIT_COL_ROOK["b"][0] = k; - else this.INIT_COL_ROOK["b"][1] = k; + if (i == startRow['b']) { + if (this.INIT_COL_ROOK["b"][0] < 0) this.INIT_COL_ROOK["b"][0] = k; + else this.INIT_COL_ROOK["b"][1] = k; + } break; case "R": - if (this.INIT_COL_ROOK["w"][0] < 0) this.INIT_COL_ROOK["w"][0] = k; - else this.INIT_COL_ROOK["w"][1] = k; + if (i == startRow['w']) { + if (this.INIT_COL_ROOK["w"][0] < 0) this.INIT_COL_ROOK["w"][0] = k; + else this.INIT_COL_ROOK["w"][1] = k; + } break; default: { const num = parseInt(fenRows[i].charAt(j)); @@ -1053,7 +1058,7 @@ export const ChessRules = class ChessRules { play(move) { // DEBUG: // if (!this.states) this.states = []; -// const stateFen = this.getBaseFen() + this.getTurnFen() + this.getFlagsFen(); +// const stateFen = this.getBaseFen() + this.getTurnFen();// + this.getFlagsFen(); // this.states.push(stateFen); if (V.HasFlags) move.flags = JSON.stringify(this.aggregateFlags()); //save flags (for undo) @@ -1073,7 +1078,7 @@ export const ChessRules = class ChessRules { this.unupdateVariables(move); // DEBUG: -// const stateFen = this.getBaseFen() + this.getTurnFen() + this.getFlagsFen(); +// const stateFen = this.getBaseFen() + this.getTurnFen();// + this.getFlagsFen(); // if (stateFen != this.states[this.states.length-1]) debugger; // this.states.pop(); }