+ static IsGoodFlags(flags) {
+ // 4 for castle + 4 for Peach + Mario w, b
+ return !!flags.match(/^[a-z]{4,4}[01]{4,4}$/);
+ }
+
+ setFlags(fenflags) {
+ super.setFlags(fenflags); //castleFlags
+ this.powerFlags = {
+ w: [...Array(2)], //king can send red shell? Queen can be invisible?
+ b: [...Array(2)]
+ };
+ const flags = fenflags.substr(4); //skip first 4 letters, for castle
+ for (let c of ["w", "b"]) {
+ for (let i = 0; i < 2; i++)
+ this.pawnFlags[c][i] = flags.charAt((c == "w" ? 0 : 2) + i) == "1";
+ }
+ }
+
+ aggregateFlags() {
+ return [this.castleFlags, this.powerFlags];
+ }
+
+ disaggregateFlags(flags) {
+ this.castleFlags = flags[0];
+ this.powerFlags = flags[1];
+ }
+
+ getFen() {
+ return super.getFen() + " " + this.getCapturedFen();
+ }
+
+ getFenForRepeat() {
+ return super.getFenForRepeat() + "_" + this.getCapturedFen();
+ }
+
+ getCapturedFen() {
+ let counts = [...Array(10).fill(0)];
+ let i = 0;
+ for (let p of [V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN, V.PAWN])
+ counts[i] = this.captured["w"][p];
+ counts[5 + i] = this.captured["b"][p];
+ i++;
+ }
+ return counts.join("");
+ }
+