projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Koopa chess + select only required fields in userMode.getOne()
[vchess.git]
/
client
/
src
/
variants
/
Koopa.js
diff --git
a/client/src/variants/Koopa.js
b/client/src/variants/Koopa.js
index
dbce842
..
8d4f0e9
100644
(file)
--- a/
client/src/variants/Koopa.js
+++ b/
client/src/variants/Koopa.js
@@
-205,18
+205,28
@@
export class KoopaRules extends ChessRules {
return moves.concat(promoteAfterStun);
}
return moves.concat(promoteAfterStun);
}
+ getPotentialKingMoves(sq) {
+ return (
+ this.getSlideNJumpMoves(
+ sq,
+ V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
+ "oneStep"
+ ).concat(super.getCastleMoves(sq, true, ['r']))
+ );
+ }
+
filterValid(moves) {
// Forbid kicking own king out
const color = this.turn;
return moves.filter(m => {
filterValid(moves) {
// Forbid kicking own king out
const color = this.turn;
return moves.filter(m => {
- const king
Appear = m.appear.some(a => a.c == color && a.p == V.KING);
- return m.vanish.every(v => {
- return (
- v.c != color ||
- !["k", "l"].includes(v.p) ||
- (v.p == "k" && kingAppear)
- );
-
})
;
+ const king
Vanish =
+ m.vanish.some(v => v.c == color && ['k', 'l'].includes(v.p));
+ if (kingVanish) {
+ const kingAppear =
+ m.appear.some(a => a.c == color && ['k', 'l'].includes(a.p));
+ return kingAppear;
+ }
+
return true
;
});
}
});
}