1 import ChessRules
from "/base_rules.js";
2 import {ArrayFun
} from "/utils/array.js";
3 import {Random
} from "/utils/alea.js";
4 import {FenUtil
} from "/utils/setupPieces.js";
6 export default class GiveawayRules
extends ChessRules
{
16 {label: "Suicide", value: "suicide"},
17 {label: "Losers", value: "losers"}
20 ].concat(C
.Options
.select
),
21 input: C
.Options
.input
.filter(i
=> i
.variable
== "pawnfall"),
23 "atomic", "cannibal", "cylinder", "dark",
24 "madrasi", "rifle", "teleport", "zen"
30 return this.options
["mode"] == "losers";
33 get pawnPromotions() {
34 let res
= ['q', 'r', 'n', 'b'];
35 if (this.options
["mode"] == "suicide")
40 genRandInitBaseFen() {
42 randomness: this.options
["randomness"],
45 if (this.options
["mode"] == "losers") {
46 setupOpts
["between"] = [{p1: 'k', p2: 'r'}];
47 setupOpts
["flags"] = ['r'];
49 const s
= FenUtil
.setupPieces(
50 ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'], setupOpts
);
52 fen: s
.b
.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" +
53 s
.w
.join("").toUpperCase(),
59 o
.options
["capture"] = true;
63 underCheck(square_s
, oppCol
) {
64 if (this.options
["mode"] == "suicide")
66 return super.underCheck(square_s
, oppCol
);
70 if (this.atLeastOneMove(this.turn
))
72 // No valid move: the side who cannot move wins
73 return (this.turn
== "w" ? "1-0" : "0-1");