X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FAntiking2%2Fclass.js;h=55c9229425c0ddf8fafd0264013a368fa08eae5d;hb=HEAD;hp=0e6a3e567ae212a6f2e9d86b85caf0e6275ea91a;hpb=a548cb4e3ad8099e977da9bb4a4184973beb56e3;p=xogo.git diff --git a/variants/Antiking2/class.js b/variants/Antiking2/class.js index 0e6a3e5..55c9229 100644 --- a/variants/Antiking2/class.js +++ b/variants/Antiking2/class.js @@ -1,21 +1,18 @@ import ChessRules from "/base_rules.js"; -import AbstractAntikingRules from "/variants/AbstractAntiking.js"; -import { Random } from "/utils/alea.js"; +import AbstractAntikingRules from "/variants/_Antiking/class.js"; +import {Random} from "/utils/alea.js"; -export class Antiking2Rules extends AbstractAntikingRules { - - static get Aliases() { - return Object.assign({'A': AbstractAntikingRules}, ChessRules.Aliases); - } +export default class Antiking2Rules extends AbstractAntikingRules { static get Options() { return { + select: C.Options.select, styles: A.Options.styles.concat("cylinder") }; } - genRandInitFen(seed) { - const baseFen = super.genRandInitFen(seed); + genRandInitBaseFen() { + const baseFen = super.genRandInitBaseFen(); // Just add an antiking on 3rd ranks let akPos = [3, 3]; if (this.options.randomness >= 1) { @@ -25,9 +22,32 @@ export class Antiking2Rules extends AbstractAntikingRules { else akPos[1] = akPos[0]; } - const whiteLine = (akPos[0] > 0 ? akPos[0] : "") + 'A' + (akPos < this.size.y - 1 ? ...); - const blackLine = ... - return baseFen.replace(...) + const antikingLine = (color) => { + const [idx, symbol] = (color == 'w' ? [0, 'a'] : [1, 'A']); + return ( + (akPos[idx] > 0 ? akPos[idx] : "") + symbol + + (akPos[idx] < this.size.y - 1 + ? C.FenEmptySquares(this.size.y - 1 - akPos[idx]) + : "") + ); + }; + return { + fen: baseFen.fen.replace("p/8", "p/" + antikingLine('b')) + .replace("8/P", antikingLine('w') + "/P"), + o: baseFen.o + }; + } + + getCastleMoves([x, y]) { + if (this.getPiece(x, y) == 'a') + return []; + return super.getCastleMoves([x, y]); + } + + updateCastleFlags(move) { + if (move.vanish.length > 0 && move.vanish[0].p == 'a') + return; + super.updateCastleFlags(move); } };