projects
/
xogo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Balaklava, draft Bario complete rules
[xogo.git]
/
variants
/
Bario
/
class.js
diff --git
a/variants/Bario/class.js
b/variants/Bario/class.js
index
871a537
..
1874383
100644
(file)
--- a/
variants/Bario/class.js
+++ b/
variants/Bario/class.js
@@
-6,7
+6,8
@@
export default class BarioRules extends ChessRules {
static get Options() {
return {
static get Options() {
return {
- // TODO: Zen too?
+ select: C.Options.select,
+ input: C.Options.input,
styles: [
"atomic", "cannibal", "capture", "cylinder",
"dark", "madrasi", "rifle", "teleport"
styles: [
"atomic", "cannibal", "capture", "cylinder",
"dark", "madrasi", "rifle", "teleport"
@@
-25,12
+26,7
@@
export default class BarioRules extends ChessRules {
pieces(color, x, y) {
return Object.assign(
pieces(color, x, y) {
return Object.assign(
- {
- 'u': {
- "class": "undefined",
- moves: []
- }
- },
+ { 'u': {"class": "undefined"} },
super.pieces(color, x, y)
);
}
super.pieces(color, x, y)
);
}
@@
-113,6
+109,8
@@
export default class BarioRules extends ChessRules {
case 0:
if (typeof x == "string")
moves = this.getDropMovesFrom([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
break;
case 1:
// Both normal move (from defined piece) and definition allowed
@@
-162,8
+160,10
@@
export default class BarioRules extends ChessRules {
if (super.underCheck(square_s, oppCol))
return true;
// Check potential specializations of undefined using reserve:
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(
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++) {
const [x, y] = square_s[0];
for (let i=0; i<this.size.x; i++) {
for (let j=0; j<this.size.y; j++) {
@@
-201,7
+201,8
@@
export default class BarioRules extends ChessRules {
postPlay(move) {
const color = this.turn;
if (this.movesCount <= 1 || move.reset || move.next) {
postPlay(move) {
const color = this.turn;
if (this.movesCount <= 1 || move.reset || move.next) {
- this.tryChangeTurn();
+ if (!move.next)
+ this.tryChangeTurn();
return;
}
if (this.subTurn == 0)
return;
}
if (this.subTurn == 0)
@@
-216,7
+217,7
@@
export default class BarioRules extends ChessRules {
super.postPlay(move);
else if (typeof move.start.x == "string") {
super.updateReserve(
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++;
if (move.vanish.length == 1 && move.vanish[0].p == 'u')
this.definition = move.end;
this.subTurn++;
@@
-224,17
+225,16
@@
export default class BarioRules extends ChessRules {
else {
this.subTurn = 0;
this.captureUndef = move.end;
else {
this.subTurn = 0;
this.captureUndef = move.end;
- this.tryChangeTurn(
move
, captureUndef);
+ this.tryChangeTurn(
null
, captureUndef);
}
}
}
}
+ // NOTE: not "trying", the turn always change here (TODO?)
tryChangeTurn(move, captureUndef) {
tryChangeTurn(move, captureUndef) {
- if (!move.next) {
- this.definition = null;
- this.subTurn = captureUndef ? 0 : 1;
- this.turn = C.GetOppCol(this.turn);
- this.movesCount++;
- }
+ this.definition = null;
+ this.subTurn = captureUndef ? 0 : 1;
+ this.turn = C.GetOppCol(this.turn);
+ this.movesCount++;
}
computeNextMove(move) {
}
computeNextMove(move) {