12ce1d04084a7b2958b1511120f62e91052bb040
[vchess.git] / client / src / variants / Pawnmassacre.js
1 import { ChessRules } from "@/base_rules";
2
3 export class PawnmassacreRules extends ChessRules {
4
5 static get HasFlags() {
6 return false;
7 }
8
9 static GenRandInitFen(randomness) {
10 const bFen =
11 ChessRules.GenRandInitFen(randomness)
12 // Remove castle flags
13 .slice(0, -6).concat("-");
14 const splitIdx = bFen.indexOf(' ');
15 return (
16 bFen.substr(0, splitIdx)
17 .replace("PPPPPPPP", "pppppppp")
18 // Next replacement is OK because only acts on first occurrence
19 .replace("pppppppp", "PPPPPPPP")
20 .split("").reverse().join("")
21 .concat(bFen.substr(splitIdx))
22 );
23 }
24
25 };