import {FenUtil} from "/utils/setupPieces.js";
import PiPo from "/utils/PiPo.js";
import Move from "/utils/Move.js";
-
-// Helper class for move animation
-class TargetObj {
-
- constructor(callOnComplete) {
- this.value = 0;
- this.target = 0;
- this.callOnComplete = callOnComplete;
- }
- increment() {
- if (++this.value == this.target)
- this.callOnComplete();
- }
-
-};
+import TargetObj from "/utils/TargetObj.js";
// NOTE: x coords: top to bottom (white perspective); y: left to right
// NOTE: ChessRules is aliased as window.C, and variants as window.V
--- /dev/null
+// Helper class for move animation
+export default class TargetObj {
+
+ constructor(callOnComplete) {
+ this.value = 0;
+ this.target = 0;
+ this.callOnComplete = callOnComplete;
+ }
+ increment() {
+ if (++this.value == this.target)
+ this.callOnComplete();
+ }
+
+};
+
return [...Array(max - min).keys()].map(k => k + min);
},
- toObject: function(keys, values) {
- if (!Array.isArray(values))
- // Second argument is a scalar
- values = Array(keys.length).fill(values);
- return (
- ArrayFun.range(keys.length)
- .reduce((acc, curr) => (acc[keys[curr]] = values[curr], acc), {})
- );
- }
-
};
"doublemove",
"progressive",
"recycle",
- //"rifle", //TODO
"teleport",
"zen"
]
return V.MergeComposed[[p1, p2].sort().join("")];
}
- // TODO: interaction with rifle ?
postProcessPotentialMoves(moves) {
// Filter out capturing promotions (except one),
// because they are all the same.
"balance",
"capture",
"cylinder",
- "dark",
"doublemove",
"progressive",
"zen"
? JSON.parse(fenParsed.whiteMove)
: [];
this.firstMove = null; //used if black turn pawn relocation
- this.penalties = ArrayFun.toObject(
- ['w', 'b'],
- [0, 1].map(i => parseInt(fenParsed.penalties.charAt(i), 10))
- );
+ this.penalties = {
+ 'w': parseInt(fenParsed.penalties.charAt(0), 10),
+ 'b': parseInt(fenParsed.penalties.charAt(1), 10)
+ };
}
genRandInitBaseFen() {
export default class ArenaRules extends ChessRules {
static get Options() {
- return {}; //TODO
+ return {
+ select: C.Options.select,
+ input: [],
+ styles: ["atomic", "cannibal", "capture", "cylinder", "zen"]
+ };
}
get hasFlags() {
export default class ChecklessRules extends ChessRules {
+ static get Options() {
+ return {
+ select: C.Options.select,
+ input: C.Options.input.filter(o => o.variable == "pawnfall"),
+ styles: ["cannibal", "capture", "crazyhouse", "cylinder", "madrasi",
+ "progressive", "recycle", "rifle", "teleport", "zen"]
+ };
+ }
+
// Cannot use super.atLeastOneMove: lead to infinite recursion
atLeastOneMove_aux(kingPos, oppKingPos, color, oppCol) {
for (let i = 0; i < this.size.x; i++) {
static get Options() {
return {
select: C.Options.select,
- input: [
- {
- label: "Capture king",
- variable: "taking",
- type: "checkbox",
- defaut: false
- },
- {
- label: "Falling pawn",
- variable: "pawnfall",
- type: "checkbox",
- defaut: true
- }
- ],
+ input: C.Options.input,
styles: C.Options.styles.filter(s => s != "recycle")
};
}