- const oppCol = this.getOppCol(c);
- const oppFirstRank = (oppCol == "w" ? 7 : 0);
-
- // Did we explode our king ? (TODO: remove move earlier)
- if (Math.abs(this.kingPos[c][0]-move.end.x) <= 1
- && Math.abs(this.kingPos[c][1]-move.end.y) <= 1)
- {
- this.kingPos[c] = [-1,-1];
- this.castleFlags[c] = [false,false];
- }
-
- // Did we explode opponent king ?
- if (Math.abs(this.kingPos[oppCol][0]-move.end.x) <= 1
- && Math.abs(this.kingPos[oppCol][1]-move.end.y) <= 1)
- {
- this.kingPos[oppCol] = [-1,-1];
- this.castleFlags[oppCol] = [false,false];
- }
- else
+ const firstRank = {"w": 7, "b": 0};
+ for (let c of ["w","b"])