return !this.isKing(x2, y2);
}
- canStepOver(i, j, p) {
+ // Can piece p (of color c) step over square i, j ?
+ canStepOver(i, j, p, c) {
// In some variants, objects on boards don't stop movement (Chakart)
return this.board[i][j] == "";
}
if (!allowed)
allowed = (sq1, sq2) => this.canTake(sq1, sq2);
const apparentPiece = this.getPiece(x, y); //how it looks
+ const c = this.getColor(x, y);
let res = [];
// Next 3 for Cylinder mode or circular (useless otherwise)
let explored = {};
let stepCounter = 0;
while (
this.onBoard(i, j) &&
- ((i == x && j == y) || this.canStepOver(i, j, apparentPiece))
+ ((i == x && j == y) || this.canStepOver(i, j, apparentPiece, c))
) {
if (!explored[i + "." + j] && (i != x || j != y)) {
explored[i + "." + j] = true;
) {
const apparentPiece = this.getPiece(i, j);
// Quick check: does this potential attacker target x,y ?
- if (this.canStepOver(x, y, apparentPiece))
+ if (this.canStepOver(x, y, apparentPiece, colIJ))
continue;
const stepSpec = this.getStepSpec(colIJ, i, j);
if (stepSpec.indirectAttack) //e.g. 8-pieces (only?)
return {
select: C.Options.select,
input: C.Options.input,
- styles: ["crazyhouse", "cylinder", "doublemove", "progressive",
- "recycle", "rifle", "teleport", "zen"]
+ styles: ["crazyhouse", "cylinder", "recycle", "teleport"]
};
}
}, super.pieces(color, x, y));
}
+ canStepOver(i, j, p, c) {
+ const colIJ = this.getColor(i, j);
+ return this.board[i][j] == "" || (V.LANCERS.includes(p) && c == colIJ);
+ }
+
isImmobilized([x, y]) {
const color = this.getColor(x, y);
const oppCol = C.GetOppTurn(color);
return false;
}
+ getPassMoves(x, y) {
+ const col = this.getColor(x, y);
+ let res = [];
+ if (this.getPiece(x, y) == 'k') {
+ for (let i of [-1, 1]) {
+ for (let j of [-1, 1]) {
+ if (
+ this.onBoard(x + i, y + j) &&
+ this.getPiece(x + i, y + j) == 'j' &&
+ this.getColor(x + i, y + j) != col
+ ) {
+ res.push( new Move({
+ appear: [],
+ vanish: [],
+ start: {x: x, y: y},
+ end: {x: x + i, y: y + j}
+ }) );
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+
+// TODO: finish lancers
+ // http://ftp.chessvariants.com/rules/8-piece-chess
+
+
getPotentialMovesFrom([x, y], color) {
- if (!this.pushFrom)
- return super.getPotentialMovesFrom([x, y], color);
+ if (!this.pushFrom) {
+ return this.getPassMoves(x, y).concat(
+ super.getPotentialMovesFrom([x, y], color) );
+ }
if (x != this.pushFrom.x || y != this.pushFrom.y)
return [];
// After sentry "attack": move enemy as if it was ours
let finalMoves = [];
for (const m of moves) {
//if (m.vanish.length == 0 && ... TODO: drop
- if (V.LANCERS.includes(m.vanish[0].p)) {
- // TODO: how to know it's regular?
+ if (m.vanish.length > 0 && V.LANCERS.includes(m.vanish[0].p)) {
+ // TODO: how to know it's regular? (not sentry push)
this.getLancerOptions(m.end.x, m.end.y).forEach(o => {
finalMoves.push( new Move({
appear: [new PiPo({x:m.end.x,y:m.end.y,c:m.appear[0].c,p:o})],