X-Git-Url: https://git.auder.net/%7B%7B%20path%28%27mixstore_store_package_upsert%27%29%20%7D%7D?a=blobdiff_plain;f=utils%2FsetupPieces.js;h=11af74afd360a7b01af0ec41b169147ce9fe4975;hb=0cef7bb4f72046ce60db408bfb76103428e2c15a;hp=988903e5a1083a068ff77ac234de7e09c9343b77;hpb=0adfbdb55452c79532875beb8eed61b1ed4c6cd2;p=xogo.git diff --git a/utils/setupPieces.js b/utils/setupPieces.js index 988903e..11af74a 100644 --- a/utils/setupPieces.js +++ b/utils/setupPieces.js @@ -1,11 +1,11 @@ import {Random} from "/utils/alea.js"; -export class FenUtil = { +export const FenUtil = { // arg o (constraints): "between" with p1 and p2. // "flags", "diffCol": array of pieceType - setupRow(arr, o) { - let res = arr; + setupRow: function(arr, o) { + let res = JSON.parse(JSON.stringify(arr)); if (o.randomness >= 1) res = Random.shuffle(arr); let flags = ""; @@ -51,15 +51,16 @@ export class FenUtil = { } } return {fen: res, flags: flags}; - } + }, - setupPieces(arr, o) { + setupPieces: function(arr, o) { const row1 = FenUtil.setupRow(arr, o); const row2 = o.randomness == 2 ? FenUtil.setupRow(arr, o) : row1; return { - w: row1.fen.toUpperCase, + w: row1.fen, b: row2.fen, flags: row1.flags + row2.flags }; } + };