c08b585bca0ed87c611250238f93121124a03892
[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 get showFirstTurn() {
10 return true;
11 }
12
13 static GenRandInitFen(options) {
14 const bFen =
15 ChessRules.GenRandInitFen(options)
16 // Remove castle flags
17 .slice(0, -6).concat("-");
18 const splitIdx = bFen.indexOf(' ');
19 return (
20 bFen.substr(0, splitIdx)
21 .replace("PPPPPPPP", "pppppppp")
22 // Next replacement is OK because only acts on first occurrence
23 .replace("pppppppp", "PPPPPPPP")
24 .split("").reverse().join("")
25 .concat(bFen.substr(splitIdx))
26 );
27 }
28
29 };