X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FDiscoduel%2Fclass.js;fp=variants%2FDiscoduel%2Fclass.js;h=c081b319b63a2ec6860b080060b5453b1ff2386c;hp=0000000000000000000000000000000000000000;hb=3232aba3419f129c70d5edd9a4ded1fefc146ea0;hpb=130a166fd08355be5f2dfc923777c1c6d03f09ce diff --git a/variants/Discoduel/class.js b/variants/Discoduel/class.js new file mode 100644 index 0000000..c081b31 --- /dev/null +++ b/variants/Discoduel/class.js @@ -0,0 +1,51 @@ +import ChessRules from "/base_rules.js"; +import {ArrayFun} from "/utils/array.js" + +export default class DiscoduelRules extends ChessRules { + + static get Options() { + return {}; //nothing would make sense + } + + get pawnPromotions() { + return ['p']; + } + + get hasFlags() { + return false; + } + + genRandInitBaseFen() { + return { + fen: "1n4n1/8/8/8/8/8/PPPPPPPP/8", + o: {} + }; + } + + getPotentialMovesFrom([x, y]) { + const moves = super.getPotentialMovesFrom([x, y]); + if (this.turn == 'b') + // Prevent pawn captures on last rank: + return moves.filter(m => m.vanish.length == 1 || m.vanish[1].x != 0); + return moves; + } + + filterValid(moves) { + return moves; + } + + getCurrentScore() { + // No real winning condition (promotions count...) + if ( + ArrayFun.range(1, this.size.x).every(row_idx => { + this.board[row_idx].every(square => square.charAt(0) != 'w') + }) + || + !this.atLeastOneMove(this.turn) + ) { + return "1/2"; + } + return "*"; + } + +};