From: Benjamin Auder Date: Tue, 12 May 2026 09:44:31 +0000 (+0200) Subject: update X-Git-Url: https://git.auder.net/variants/$%7Bvname%7D/%7B%7B%20asset('mixstore/pieces/%7B%7B%20pkg.url%20%7D%7D?a=commitdiff_plain;h=HEAD;p=xogo.git update --- diff --git a/TODO b/TODO index 7114f80..2020aca 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +Issue with Dark Bario + Otage, Emergo, Pacosako : fonction "buildPiece(arg1, arg2)" returns HTML element with 2 SVG or SVG + number ==> plus simple : deux classes, images superposées (?) diff --git a/js/base_rules.js b/js/base_rules.js index bc85aa8..1039596 100644 --- a/js/base_rules.js +++ b/js/base_rules.js @@ -1088,6 +1088,7 @@ export default class ChessRules { // DARK METHODS updateEnlightened() { + console.log("new light"); this.oldEnlightened = this.enlightened; this.enlightened = ArrayFun.init(this.size.x, this.size.y, false); // Add pieces positions + all squares reachable by moves (includes Zen): @@ -1097,6 +1098,9 @@ export default class ChessRules { { this.enlightened[x][y] = true; this.getPotentialMovesFrom([x, y]).forEach(m => { + +console.log(m.end); + this.enlightened[m.end.x][m.end.y] = true; }); } @@ -2310,9 +2314,7 @@ export default class ChessRules { }); } - prePlay(move) { - if (this.hasCastle) - this.updateCastleFlags(move); + tryPrePlayCrazyhouse(move) { if (this.options["crazyhouse"]) { if (move.appear.length > 0 && move.vanish.length > 0) { // Assumption: something is moving @@ -2338,6 +2340,9 @@ export default class ChessRules { delete this.ispawn[square]; }); } + } + + tryPrePlayAtomicReserve(move) { const minSize = Math.min(move.appear.length, move.vanish.length); if ( this.hasReserve && @@ -2365,6 +2370,13 @@ export default class ChessRules { } } + prePlay(move) { + if (this.hasCastle) + this.updateCastleFlags(move); + this.tryPrePlayCrazyhouse(move); + this.tryPrePlayAtomicReserve(move); + } + play(move) { this.prePlay(move); if (this.hasEnpassant) @@ -2373,9 +2385,7 @@ export default class ChessRules { this.postPlay(move); } - postPlay(move) { - if (this.options["dark"]) - this.updateEnlightened(); + tryPostPlayTeleport(move) { if (this.options["teleport"]) { if ( this.subTurnTeleport == 1 && @@ -2391,6 +2401,10 @@ export default class ChessRules { this.subTurnTeleport = 1; this.captured = null; } + } + + postPlay(move) { + this.tryPostPlayTeleport(move); this.tryChangeTurn(move); } @@ -2399,6 +2413,8 @@ export default class ChessRules { this.turn = C.GetOppTurn(this.turn); this.movesCount++; this.subTurn = 1; + if (this.options["dark"]) + this.updateEnlightened(); } else if (!move.next) this.subTurn++; diff --git a/variants/Bario/class.js b/variants/Bario/class.js index e1fd396..e66f356 100644 --- a/variants/Bario/class.js +++ b/variants/Bario/class.js @@ -10,7 +10,7 @@ export default class BarioRules extends ChessRules { input: C.Options.input, styles: [ "atomic", "cannibal", "capture", "cylinder", - "dark", "madrasi", "rifle", "teleport" + "dark", "madrasi", "rifle", "teleport", "zen" ] }; } @@ -279,7 +279,7 @@ export default class BarioRules extends ChessRules { ); if (typeof move.start.x == "number" && !captureUndef) // Normal move (including Teleport) - super.postPlay(move); + super.tryPostPlayTeleport(move); else if (typeof move.start.x == "string") { super.updateReserve( color, move.start.y, this.reserve[color][move.start.y] - 1); @@ -293,13 +293,15 @@ export default class BarioRules extends ChessRules { this.tryChangeTurn(null, captureUndef); } } - +//TODO // NOTE: not "trying", the turn always change here (TODO?) tryChangeTurn(move, captureUndef) { this.definition = null; this.subTurn = captureUndef ? 0 : 1; this.turn = C.GetOppTurn(this.turn); this.movesCount++; + if (this.options["dark"] && this.movesCount >= 2) + this.updateEnlightened(); } computeNextMove(move) {