static get Options() {
return {
- // TODO: Zen too?
+ select: C.Options.select,
+ input: C.Options.input,
styles: [
"atomic", "cannibal", "capture", "cylinder",
"dark", "madrasi", "rifle", "teleport"
pieces(color, x, y) {
return Object.assign(
- {
- 'u': {
- "class": "undefined",
- moves: []
- }
- },
+ { 'u': {"class": "undefined"} },
super.pieces(color, x, y)
);
}
case 0:
if (typeof x == "string")
moves = this.getDropMovesFrom([x, y]);
+ // Empty move: just start + end
+ moves.forEach(m => {m.vanish.pop(); m.appear.pop();});
break;
case 1:
// Both normal move (from defined piece) and definition allowed
if (super.underCheck(square_s, oppCol))
return true;
// Check potential specializations of undefined using reserve:
+ const inReserve = Object.keys(this.reserve[oppCol])
+ .filter(k => this.reserve[oppCol][k] >= 1);
const allAttacks = Array.prototype.concat.apply(
- ['r', 'n', 'b', 'q'].map(p => this.pieces()[p].moves[0]));
+ inReserve.map(p => this.pieces()[p].both[0]));
const [x, y] = square_s[0];
for (let i=0; i<this.size.x; i++) {
for (let j=0; j<this.size.y; j++) {
postPlay(move) {
const color = this.turn;
- if (this.movesCount <= 1 || move.reset) {
- this.tryChangeTurn();
+ if (this.movesCount <= 1 || move.reset || move.next) {
+ if (!move.next)
+ this.tryChangeTurn();
return;
}
if (this.subTurn == 0)
super.postPlay(move);
else if (typeof move.start.x == "string") {
super.updateReserve(
- color, move.appear[0].p, this.reserve[color][move.appear[0].p] - 1);
+ color, move.start.y, this.reserve[color][move.start.y] - 1);
if (move.vanish.length == 1 && move.vanish[0].p == 'u')
this.definition = move.end;
this.subTurn++;
else {
this.subTurn = 0;
this.captureUndef = move.end;
- this.tryChangeTurn(move, captureUndef);
+ this.tryChangeTurn(null, captureUndef);
}
}
- // NOTE: not "try" here, we know the turn changes (TODO?)
+ // NOTE: not "trying", the turn always change here (TODO?)
tryChangeTurn(move, captureUndef) {
this.definition = null;
this.subTurn = captureUndef ? 0 : 1;
- this.turn = C.GetOppCol(this.turn);
+ this.turn = C.GetOppTurn(this.turn);
this.movesCount++;
}
this.board.some(row => row.some(cell =>
cell.charAt(0) == this.turn && cell.charAt(1) == 'u'))
) {
- return null;
+ return;
}
const variety = (c) => {
return (
)].length >= 2
);
};
- this.playOnBoard(move);
let next = {start: move.end, end: move.end, vanish: [], appear: []};
- for (let c of ['w', 'b']) {
- if (variety(c)) {
- for (let i=0; i<this.size.x; i++) {
- for (let j=0; j<this.size.y; j++) {
- const pieceIJ = this.getPiece(i, j);
- if (
- this.board[i][j] != "" &&
- !['p', 'k', 'u'].includes(pieceIJ)
- ) {
- // NOTE: could also use a "flip" strategy similar to Benedict
- next.vanish.push(new PiPo({c: c, p: pieceIJ, x: i, y: j}));
- next.appear.push(new PiPo({c: c, p: 'u', x: i, y: j}));
- this.reserve[c][pieceIJ]++;
- }
+ this.playOnBoard(move);
+ const twoOrMorePieces = {w: variety('w'), b: variety('b')};
+ const resetCols =
+ Object.keys(twoOrMorePieces).filter(k => twoOrMorePieces[k]);
+ if (resetCols.length >= 1) {
+ for (let i=0; i<this.size.x; i++) {
+ for (let j=0; j<this.size.y; j++) {
+ const colIJ = this.getColor(i, j);
+ const pieceIJ = this.getPiece(i, j);
+ if (
+ resetCols.includes(colIJ) &&
+ this.board[i][j] != "" &&
+ !['p', 'k', 'u'].includes(pieceIJ)
+ ) {
+ // NOTE: could also use a "flip" strategy similar to Benedict
+ next.vanish.push(new PiPo({c: colIJ, p: pieceIJ, x: i, y: j}));
+ next.appear.push(new PiPo({c: colIJ, p: 'u', x: i, y: j}));
+ this.reserve[colIJ][pieceIJ]++;
}
}
- super.re_drawReserve([c]);
}
+ super.re_drawReserve(resetCols);
}
this.undoOnBoard(move);
if (next.vanish.length >= 1) {