export class JanggiRules extends ChessRules {
+ static get Options() {
+ return null;
+ }
+
static get Monochrome() {
return true;
}
if (this.movesCount <= 1) {
const firstRank = (this.movesCount == 0 ? 9 : 0);
const initDestFile = new Map([[1, 2], [7, 6]]);
- // Only option is knight / elephant swap:
- if (x == firstRank && !!initDestFile.get(y)) {
+ // Only option is knight --> elephant swap:
+ if (
+ x == firstRank &&
+ !!initDestFile.get(y) &&
+ this.getPiece(x, y) == V.KNIGHT
+ ) {
const destFile = initDestFile.get(y);
moves.push(
new Move({
if (y == 3) steps.push([shiftX, 1]);
else if (y == 5) steps.push([shiftX, -1]);
}
- return super.getSlideNJumpMoves([x, y], steps, "oneStep");
+ return super.getSlideNJumpMoves([x, y], steps, 1);
}
knightStepsFromRookStep(step) {
this.knightStepsFromRookStep(rookStep));
}
}
- return super.getSlideNJumpMoves([x, y], steps, "oneStep");
+ return super.getSlideNJumpMoves([x, y], steps, 1);
}
elephantStepsFromRookStep(step) {
}
}
}
- return super.getSlideNJumpMoves([x, y], steps, "oneStep");
+ return super.getSlideNJumpMoves([x, y], steps, 1);
}
palacePeopleMoves([x, y]) {
// At the middle: all directions available
Array.prototype.push.apply(steps, ChessRules.steps[V.BISHOP]);
}
- return super.getSlideNJumpMoves([x, y], steps, "oneStep");
+ return super.getSlideNJumpMoves([x, y], steps, 1);
}
getPotentialAdvisorMoves(sq) {
// In the middle of a palace: 4 one-diagonal-step to check
Array.prototype.push.apply(
moves,
- super.getSlideNJumpMoves([x, y],
- ChessRules.steps[V.BISHOP],
- "oneStep")
+ super.getSlideNJumpMoves([x, y], ChessRules.steps[V.BISHOP], 1)
);
}
return moves;
isAttackedByPawn([x, y], color) {
const shiftX = (color == 'w' ? 1 : -1); //shift from king
if (super.isAttackedBySlideNJump(
- [x, y], color, V.PAWN, [[shiftX, 0], [0, 1], [0, -1]], "oneStep")
+ [x, y], color, V.PAWN, [[shiftX, 0], [0, 1], [0, -1]], 1)
) {
return true;
}
}
}
return (
- super.isAttackedBySlideNJump([x, y], color, V.KNIGHT, steps, "oneStep")
+ super.isAttackedBySlideNJump([x, y], color, V.KNIGHT, steps, 1)
);
}
}
}
return (
- super.isAttackedBySlideNJump([x, y], color, V.ELEPHANT, steps, "oneStep")
+ super.isAttackedBySlideNJump([x, y], color, V.ELEPHANT, steps, 1)
);
}