X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FAntiking1%2Fclass.js;h=4ef66f2a817569021dd7abadd28be7290d4eb354;hb=HEAD;hp=f8406b7ebd41ba718c31f7a83ad11c53b1130a8b;hpb=a548cb4e3ad8099e977da9bb4a4184973beb56e3;p=xogo.git diff --git a/variants/Antiking1/class.js b/variants/Antiking1/class.js index f8406b7..c625e89 100644 --- a/variants/Antiking1/class.js +++ b/variants/Antiking1/class.js @@ -1,71 +1,47 @@ import ChessRules from "/base_rules.js"; -import AbstractAntikingRules from "/variants/AbstractAntiking.js"; +import AbstractAntikingRules from "/variants/_Antiking/class.js"; +import BerolinaPawnSpec from "/variants/_Berolina/pawnSpec.js"; -export class Antiking1Rules extends AbstractAntikingRules { - - static get Options() { - return { - styles: [ - "atomic", - "balance", - "cannibal", - "capture", - "crazyhouse", - "doublemove", - "madrasi", - "progressive", - "recycle", - "rifle", - "teleport", - "zen" - ] - }; - } +export default class Antiking1Rules extends AbstractAntikingRules { get hasCastle() { return false; } + get hasEnpassant() { + return false; + } pieces(color, x, y) { - const pawnShift = (color == "w" ? -1 : 1); let res = super.pieces(color, x, y); - res['p'].moves = [ - { - steps: [[pawnShift, 1], [pawnShift, -1]], - range: 1 - } - ]; - res['p'].attack = [ - { - steps: [[pawnShift, 0]], - range: 1 - } - ]; + res['p'] = BerolinaPawnSpec(color); //no 2-squares moves return res; } - genRandInitFen() { + genRandInitBaseFen() { // Always deterministic setup - return ( - '2prbkqA/2p1nnbr/2pppppp/8/8/PPPPPP2/RBNN1P2/aQKBRP2 w 0 ' + - '{"flags":"KAka"}' - ); + return { + fen: "2prbkqA/2p1nnbr/2pppppp/8/8/PPPPPP2/RBNN1P2/aQKBRP2", + o: {"flags": "KAka"} + }; } // (Anti)King flags at 1 (true) if they can knight-jump setFlags(fenflags) { this.kingFlags = { w: {}, b: {} }; - for (let i=0; i Object.keys(this.kingFlags[c])) + Array.prototype.concat.apply([], + ['w', 'b'].map(c => { + const res = Object.keys(this.kingFlags[c]).join(""); + return (c == 'w' ? res.toUpperCase() : res); + }) ).join("") ); } @@ -73,11 +49,11 @@ export class Antiking1Rules extends AbstractAntikingRules { getPotentialMovesFrom([x, y]) { const color = this.turn; let moves = super.getPotentialMovesFrom([x, y]); - if (this.kingFlags[color][piece]) { + if (this.kingFlags[color][this.getPiece(x, y)]) { // Allow knight jump (king or antiking) const knightMoves = super.getPotentialMovesOf('n', [x, y]); // Remove captures (TODO: could be done more efficiently...) - moves = moves.concat(knightJumps.filter(m => m.vanish.length == 1)); + moves = moves.concat(knightMoves.filter(m => m.vanish.length == 1)); } return moves; }