X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=base_rules.js;h=ded104e887914b672e5d98876c1f9a6efe338dc1;hp=4805f174b55773fc5e5a3e79dc9792d8a8b6dfaf;hb=6997e386b546c650870d64176029aff55d13edb7;hpb=0c44c6768654f7127e36aa75beee58d61df4fc64 diff --git a/base_rules.js b/base_rules.js index 4805f17..ded104e 100644 --- a/base_rules.js +++ b/base_rules.js @@ -748,13 +748,13 @@ export default class ChessRules { for (let x=0; x { - return (v.p == "k" || C.CannibalKings[v.p]) && v.c == color; + return C.CannibalKings[v.p] && v.c == color; })) { // Search king in appear array: const newKingIdx = m.appear.findIndex(a => { - return (a.p == "k" || C.CannibalKings[a.p]) && a.c == color; + return C.CannibalKings[a.p] && a.c == color; }); if (newKingIdx >= 0) square = [m.appear[newKingIdx].x, m.appear[newKingIdx].y]; @@ -1898,13 +1894,17 @@ export default class ChessRules { // Apply a move on board playOnBoard(move) { - for (let psq of move.vanish) this.board[psq.x][psq.y] = ""; - for (let psq of move.appear) this.board[psq.x][psq.y] = psq.c + psq.p; + for (let psq of move.vanish) + this.board[psq.x][psq.y] = ""; + for (let psq of move.appear) + this.board[psq.x][psq.y] = psq.c + psq.p; } // Un-apply the played move undoOnBoard(move) { - for (let psq of move.appear) this.board[psq.x][psq.y] = ""; - for (let psq of move.vanish) this.board[psq.x][psq.y] = psq.c + psq.p; + for (let psq of move.appear) + this.board[psq.x][psq.y] = ""; + for (let psq of move.vanish) + this.board[psq.x][psq.y] = psq.c + psq.p; } updateCastleFlags(move) { @@ -2093,7 +2093,6 @@ export default class ChessRules { return (color == "w" ? "0-1" : "1-0"); } - // NOTE: quite suboptimal for eg. Benedict (not a big deal I think) playVisual(move, r) { move.vanish.forEach(v => { // TODO: next "if" shouldn't be required