X-Git-Url: https://git.auder.net/pieces/Checkered/cb.svg?a=blobdiff_plain;f=base_rules.js;h=9cedfd054e9819a8408285fb916cb4a1828e718d;hb=296f846a620c361b3fe4e61f6bb369adc361d312;hp=aea3f57bbf641d743e32e818f6cc8aadbdbde1ff;hpb=b8950be593d0663202c886f4252513bf1a499ee1;p=xogo.git diff --git a/base_rules.js b/base_rules.js index aea3f57..9cedfd0 100644 --- a/base_rules.js +++ b/base_rules.js @@ -97,6 +97,14 @@ export default class ChessRules { return true; } + // Allow to take (moving: not disappearing) own pieces? + get hasSelfCaptures() { + return ( + this.options["recycle"] || + (this.options["teleport"] && this.subTurnTeleport == 1) + ); + } + get hasReserve() { return ( !!this.options["crazyhouse"] || @@ -1720,10 +1728,7 @@ export default class ChessRules { }); Array.prototype.push.apply(squares, zenCaptures); } - if ( - this.options["recycle"] || - (this.options["teleport"] && this.subTurnTeleport == 1) - ) { + if (this.hasSelfCaptures) { const selfCaptures = this.findDestSquares( [x, y], { @@ -1833,6 +1838,8 @@ export default class ChessRules { } } + // TODO here: should/could use getPotentialMovesFrom ?! (not sure) + // --> would be useful for variants like Copycat. // Search for enemy (or not) pieces attacking [x, y] findCapturesOn([x, y], o, allowed) { if (!o.byCol)