+ static IsGoodFlags(flags) {
+ // 4 for Peach + Mario w, b
+ return !!flags.match(/^[01]{4,4}$/);
+ }
+
+ setFlags(fenflags) {
+ // King can send shell? Queen can be invisible?
+ this.powerFlags = {
+ w: [{ 'k': false, 'q': false }],
+ b: [{ 'k': false, 'q': false }]
+ };
+ for (let c of ["w", "b"]) {
+ for (let p of ['k', 'q']) {
+ this.powerFlags[c][p] =
+ fenFlags.charAt((c == "w" ? 0 : 2) + (p == 'k' ? 0 : 1)) == "1";
+ }
+ }
+ }
+
+ aggregateFlags() {
+ return this.powerFlags;
+ }
+
+ disaggregateFlags(flags) {
+ this.powerFlags = flags;
+ }
+
+ 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("");
+ }
+