X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FDobutsu%2Fclass.js;fp=variants%2FDobutsu%2Fclass.js;h=d8ceafae750b90d086c15e156645a310519b333c;hp=29b0708396449ae3ab5a74fc06cc3a6a8ad275ff;hb=d66135396f3a6e140947545630004ce11f8eee7b;hpb=4fcd7ab062f5250757804d633df01bd0d06da137 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 "*"; }