From: Benjamin Auder Date: Thu, 4 Jan 2024 09:37:28 +0000 (+0100) Subject: Fix Dobutsu, extend Align4 X-Git-Url: https://git.auder.net/variants/Chakart/css/assets/doc/html/left.jpg?a=commitdiff_plain;h=d66135396f3a6e140947545630004ce11f8eee7b;p=xogo.git Fix Dobutsu, extend Align4 --- diff --git a/variants/Align4/class.js b/variants/Align4/class.js index 09a79ed..f5b8f83 100644 --- a/variants/Align4/class.js +++ b/variants/Align4/class.js @@ -13,6 +13,14 @@ export default class Align4Rules extends ChessRules { {label: "Random", value: 1} ] }], + input: [ + { + label: "Pawn first", + variable: "pawnfirst", + type: "checkbox", + defaut: false + } + ], styles: ["atomic", "capture", "cylinder"] }; } @@ -39,6 +47,17 @@ export default class Align4Rules extends ChessRules { // Just do not update any reserve (infinite supply) updateReserve() {} + canDrop([c, p], [i, j]) { + return ( + this.board[i][j] == "" && + ( + p != "p" || this.options["pawnfirst"] || + (c == 'w' && i < this.size.x - 1) || + (c == 'b' && i > 0) + ) + ); + } + getCurrentScore(move_s) { const score = super.getCurrentScore(move_s); if (score != "*") diff --git a/variants/Dobutsu/class.js b/variants/Dobutsu/class.js index 29b0708..d8ceafa 100644 --- a/variants/Dobutsu/class.js +++ b/variants/Dobutsu/class.js @@ -87,11 +87,16 @@ export default class DobutsuRules extends ChessRules { const res = super.getCurrentScore(move_s); if (res != '*') return res; - const oppCol = C.GetOppTurn(this.turn); - const oppLastRank = (oppCol == 'b' ? 3 : 0); - for (let j=0; j < this.size.y; j++) { - if (this.board[oppLastRank][j] == oppCol + 'k') - return (oppCol == 'w' ? "1-0" : "0-1"); + for (let lastRank of [0, 3]) { + const color = (lastRank == 0 ? 'w' : 'b'); + for (let j=0; j < this.size.y; j++) { + if ( + this.board[lastRank][j] == color + 'k' && + !this.underAttack([lastRank, j], [C.GetOppTurn(color)]) + ) { + return (color == 'w' ? "1-0" : "0-1"); + } + } } return "*"; }