X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FBario%2Fclass.js;h=01cb3d7f8ed33f44c54047ad76893a19b5a15eab;hb=7bd7cba41f9c2222a29c62ddf8d83fbb46646a1d;hp=6a44834a7623b3c58e90131c173edb24a8fb8695;hpb=182ba661e9c6e30fc641f4e71f29ae76961f4510;p=xogo.git diff --git a/variants/Bario/class.js b/variants/Bario/class.js index 6a44834..01cb3d7 100644 --- a/variants/Bario/class.js +++ b/variants/Bario/class.js @@ -6,7 +6,8 @@ export default class BarioRules extends ChessRules { static get Options() { return { - // TODO: Zen too? + select: C.Options.select, + input: C.Options.input, styles: [ "atomic", "cannibal", "capture", "cylinder", "dark", "madrasi", "rifle", "teleport" @@ -113,6 +114,8 @@ export default class BarioRules extends ChessRules { 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 @@ -200,8 +203,9 @@ export default class BarioRules extends ChessRules { 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) @@ -216,7 +220,7 @@ export default class BarioRules extends ChessRules { 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++; @@ -224,11 +228,11 @@ export default class BarioRules extends ChessRules { 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; @@ -242,7 +246,7 @@ export default class BarioRules extends ChessRules { this.board.some(row => row.some(cell => cell.charAt(0) == this.turn && cell.charAt(1) == 'u')) ) { - return null; + return; } const variety = (c) => { return ( @@ -257,26 +261,29 @@ export default class BarioRules extends ChessRules { )].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 twoOrMorePieces[k]); + if (resetCols.length >= 1) { + for (let i=0; i= 1) {