return (b[0] == 'w' ? "Empire/" : "") + b;
}
- static GenRandInitFen(randomness) {
- if (randomness == 0)
+ static GenRandInitFen(options) {
+ if (options.randomness == 0)
return "rnbqkbnr/pppppppp/8/8/8/PPPSSPPP/8/TECDKCET w 0 ah -";
// Mapping kingdom --> empire:
'K': 'K'
};
- const baseFen = ChessRules.GenRandInitFen(randomness);
+ const baseFen = ChessRules.GenRandInitFen(options);
return (
baseFen.substr(0, 24) + "PPPSSPPP/8/" +
baseFen.substr(35, 8).split('').map(p => piecesMap[p]).join('') +
// or if move.end.x == enemy king rank.
const color = this.getColor(sq[0], sq[1]);
const oppCol = V.GetOppCol(color);
- // check == -1 if (row, or col) unchecked, 1 if checked and occupied,
- // 0 if checked and clear
- let check = [-1, -1];
return moves.filter(m => {
if (
m.end.y != this.kingPos[oppCol][1] &&
) {
return true;
}
+ // check == -1 if (row, or col) unchecked, 1 if checked and occupied,
+ // 0 if checked and clear
+ let check = [-1, -1];
// TODO: factor two next "if"...
if (m.end.x == this.kingPos[oppCol][0]) {
if (check[0] < 0) {
// Do the check:
check[0] = 0;
- let [kingPos1, kingPos2] =
- [this.kingPos[color][1], this.kingPos[oppCol][1]];
+ let [kingPos1, kingPos2] = [m.end.y, this.kingPos[oppCol][1]];
if (kingPos1 > kingPos2) [kingPos1, kingPos2] = [kingPos2, kingPos1];
for (let i = kingPos1 + 1; i < kingPos2; i++) {
if (this.board[m.end.x][i] != V.EMPTY) {
if (check[1] < 0) {
// Do the check:
check[1] = 0;
- let [kingPos1, kingPos2] =
- [this.kingPos[color][0], this.kingPos[oppCol][0]];
+ let [kingPos1, kingPos2] = [m.end.x, this.kingPos[oppCol][0]];
if (kingPos1 > kingPos2) [kingPos1, kingPos2] = [kingPos2, kingPos1];
for (let i = kingPos1 + 1; i < kingPos2; i++) {
if (this.board[i][m.end.y] != V.EMPTY) {
});
}
+ // TODO: some merging to do with Orda method (and into base_rules.js)
getSlideNJumpMoves_([x, y], steps, oneStep) {
let moves = [];
outerLoop: for (let step of steps) {
if (!step.onlyTake) moves.push(this.getBasicMove([x, y], [i, j]));
// NOTE: (bad) HACK here, since onlyTake is true only for Eagle
// capturing moves, which are oneStep...
- if (!!oneStep || !!step.onlyTake) continue outerLoop;
+ if (oneStep || step.onlyTake) continue outerLoop;
i += s[0];
j += s[1];
}
if (this.getColor(x, y) == 'b') return super.getPotentialKingMoves([x, y]);
// Empire doesn't castle:
return super.getSlideNJumpMoves(
- [x, y],
- V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
- "oneStep"
- );
+ [x, y], V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1);
}
getPotentialSoldierMoves([x, y]) {
if (!lastRank) steps.push([shiftX, 0]);
if (y > 0) steps.push([0, -1]);
if (y < 9) steps.push([0, 1]);
- return super.getSlideNJumpMoves([x, y], steps, "oneStep");
+ return super.getSlideNJumpMoves([x, y], steps, 1);
}
isAttacked(sq, color) {
isAttackedByEagle(sq, color) {
return super.isAttackedBySlideNJump(
- sq, color, V.EAGLE, V.steps[V.KNIGHT], "oneStep");
+ sq, color, V.EAGLE, V.steps[V.KNIGHT], 1);
}
isAttackedByCardinal(sq, color) {
return (
super.isAttackedBySlideNJump(
sq, color, V.DUKE,
- V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"
+ V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1
)
);
}
isAttackedBySoldier([x, y], color) {
const shiftX = (color == 'w' ? 1 : -1); //shift from king
return super.isAttackedBySlideNJump(
- [x, y], color, V.SOLDIER, [[shiftX, 0], [0, 1], [0, -1]], "oneStep");
+ [x, y], color, V.SOLDIER, [[shiftX, 0], [0, 1], [0, -1]], 1);
}
updateCastleFlags(move, piece) {