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