X-Git-Url: https://git.auder.net/rpsls.js?a=blobdiff_plain;ds=sidebyside;f=base_rules.js;h=6078da86ccfa5e84730fe851c3ad947c0a665c4a;hb=5c1c7bcec764d94b0469ab4d7d0777ce67e05ae3;hp=20ffbee4cdddfc6661f1c031782937800b289827;hpb=6bf2ab3498d5d469ea456b528c178dc481789b76;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 20ffbee..6078da8 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"] || @@ -225,9 +233,9 @@ export default class ChessRules { ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'], { randomness: this.options["randomness"], - between: {p1: 'k', p2: 'r'}, + between: [{p1: 'k', p2: 'r'}], diffCol: ['b'], - flags: ['r'] + flags: ['r', 'k'] } ); return { @@ -1188,7 +1196,7 @@ export default class ChessRules { } pieces(color, x, y) { - const pawnShift = this.getPawnShift(color); + const pawnShift = this.getPawnShift(color || 'w'); return { 'p': { "class": "pawn", @@ -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], {