- setOtherVariables(fen)
- {
- super.setOtherVariables(fen);
- const fenParsed = V.ParseFen(fen);
- // Also init reserves (used by the interface to show landable pieces)
- this.reserve =
- {
- "w":
- {
- [V.PAWN]: parseInt(fenParsed.reserve[0]),
- [V.ROOK]: parseInt(fenParsed.reserve[1]),
- [V.KNIGHT]: parseInt(fenParsed.reserve[2]),
- [V.BISHOP]: parseInt(fenParsed.reserve[3]),
- [V.QUEEN]: parseInt(fenParsed.reserve[4]),
- },
- "b":
- {
- [V.PAWN]: parseInt(fenParsed.reserve[5]),
- [V.ROOK]: parseInt(fenParsed.reserve[6]),
- [V.KNIGHT]: parseInt(fenParsed.reserve[7]),
- [V.BISHOP]: parseInt(fenParsed.reserve[8]),
- [V.QUEEN]: parseInt(fenParsed.reserve[9]),
- }
- };
- this.promoted = ArrayFun.init(V.size.x, V.size.y, false);
- if (fenParsed.promoted != "-")
- {
- for (let square of fenParsed.promoted.split(","))
- {
- const [x,y] = V.SquareToCoords(square);
- promoted[x][y] = true;
- }
- }
- }
+ getPromotedFen() {
+ let res = "";
+ for (let i = 0; i < V.size.x; i++) {
+ for (let j = 0; j < V.size.y; j++) {
+ if (this.promoted[i][j]) res += V.CoordsToSquare({ x: i, y: j }) + ",";
+ }
+ }
+ // Remove last comma:
+ if (res.length > 0) res = res.slice(0, -1);
+ else res = "-";
+ return res;
+ }