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() {
41 let setupOpts
= {diffCol: ['b']};
42 if (this.options
["mode"] == "losers") {
43 setupOpts
["between"] = ['k', 'r'];
44 setupOpts
["flags"] = ['r'];
46 const s
= FenUtil
.setupPieces(
47 ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'], setupOpts
);
49 fen: s
.b
.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" +
50 s
.w
.join("").toUpperCase(),
56 o
.options
["capture"] = true;
60 underCheck(square_s
, oppCol
) {
61 if (this.options
["mode"] == "suicide")
63 return super.underCheck(square_s
, oppCol
);
67 if (this.atLeastOneMove(this.turn
))
69 // No valid move: the side who cannot move wins
70 return (this.turn
== "w" ? "1-0" : "0-1");