@thegraid/hexlib 1.0.13 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/game-play.d.ts +1 -1
  2. package/dist/game-play.d.ts.map +1 -1
  3. package/dist/game-play.js +4 -4
  4. package/dist/game-play.js.map +1 -1
  5. package/dist/game-setup.d.ts +39 -11
  6. package/dist/game-setup.d.ts.map +1 -1
  7. package/dist/game-setup.js +68 -21
  8. package/dist/game-setup.js.map +1 -1
  9. package/dist/hex.d.ts +282 -88
  10. package/dist/hex.d.ts.map +1 -1
  11. package/dist/hex.js +191 -171
  12. package/dist/hex.js.map +1 -1
  13. package/dist/meeple.d.ts +2 -2
  14. package/dist/meeple.d.ts.map +1 -1
  15. package/dist/meeple.js.map +1 -1
  16. package/dist/plan-proxy.d.ts.map +1 -1
  17. package/dist/player-panel.js +1 -1
  18. package/dist/player-panel.js.map +1 -1
  19. package/dist/player.d.ts +1 -0
  20. package/dist/player.d.ts.map +1 -1
  21. package/dist/player.js +1 -0
  22. package/dist/player.js.map +1 -1
  23. package/dist/scenario-parser.d.ts +2 -3
  24. package/dist/scenario-parser.d.ts.map +1 -1
  25. package/dist/scenario-parser.js.map +1 -1
  26. package/dist/shapes.d.ts +6 -6
  27. package/dist/shapes.d.ts.map +1 -1
  28. package/dist/shapes.js +9 -9
  29. package/dist/shapes.js.map +1 -1
  30. package/dist/table-params.d.ts +23 -2
  31. package/dist/table-params.d.ts.map +1 -1
  32. package/dist/table-params.js +43 -4
  33. package/dist/table-params.js.map +1 -1
  34. package/dist/table.d.ts +1099 -28
  35. package/dist/table.d.ts.map +1 -1
  36. package/dist/table.js +66 -41
  37. package/dist/table.js.map +1 -1
  38. package/dist/tile-source.d.ts +3 -3
  39. package/dist/tile-source.d.ts.map +1 -1
  40. package/dist/tile-source.js.map +1 -1
  41. package/dist/tile.d.ts +19 -14
  42. package/dist/tile.d.ts.map +1 -1
  43. package/dist/tile.js +8 -3
  44. package/dist/tile.js.map +1 -1
  45. package/package.json +2 -2
@@ -7,10 +7,49 @@ export function otherColor(color) { return color === playerColor0 ? playerColor1
7
7
  export function playerColorRecord(b, w, c) { return { b, w, c }; }
8
8
  ;
9
9
  export function playerColorRecordF(f) { return playerColorRecord(f(playerColor0), f(playerColor1), f(playerColor2)); }
10
- export function buildURL(scheme = 'wss', host = TP.ghost, domain = TP.gdomain, port = TP.gport, path = '') {
11
- return `${scheme}://${host}.${domain}:${port}${path}`;
12
- }
13
10
  export class TP {
11
+ static buildURL(scheme = 'wss', host = TP.ghost, domain = TP.gdomain, port = TP.gport, path = '') {
12
+ return `${scheme}://${host}.${domain}:${port}${path}`;
13
+ }
14
+ static staticFields(over = TP) {
15
+ const basic_props = Object.getOwnPropertyNames(class {
16
+ }); // [length, prototype, name]
17
+ const static_props = Object.getOwnPropertyNames(over).filter(k => !basic_props.includes(k));
18
+ return static_props;
19
+ }
20
+ /** called by framework before TP is used; put your overrides here.
21
+ * @param qParams
22
+ * @param force true to apply exact value, if new key or new type.
23
+ */
24
+ static setParams(qParams = {}, force = false, over = TP) {
25
+ /** do not muck with standard basic properties of all/empty classes */
26
+ const static_props = TP.staticFields(over);
27
+ for (let [key, value] of Object.entries(qParams)) {
28
+ if (force || static_props.includes(key)) {
29
+ if (!force && (typeof value === 'string' && typeof over[key] === 'number')) {
30
+ value = Number.parseInt(value); // minimal effort to align types.
31
+ }
32
+ TP[key] = value; // set a static value in base; DANGER! not typesafe!
33
+ }
34
+ }
35
+ }
36
+ /**
37
+ * After pushing all values from local subclass of TP into base TP,
38
+ * delete them, so there is only the one copy in original base class: TP (from hexlib)
39
+ * Local references should still get/set values in the base object.
40
+ *
41
+ * This way, tsc still sees local TP for type safety,
42
+ * but there is a single object for updates using Chooser.
43
+ *
44
+ * @param local the locally created subclass of TP with static fields
45
+ */
46
+ static eraseLocal(local) {
47
+ const static_props = TP.staticFields(local);
48
+ static_props.forEach(key => delete local[key]);
49
+ const new_props = TP.staticFields(local);
50
+ // assert new_props is empty!
51
+ }
52
+ /** the current map from PlayerColor to colorn */
14
53
  static colorScheme = playerColorRecordF(n => n);
15
54
  static useEwTopo = true;
16
55
  static cacheTiles = 2;
@@ -34,7 +73,7 @@ export class TP {
34
73
  static ghost = 'game7'; // game-setup.network()
35
74
  static gdomain = 'thegraid.com';
36
75
  static gport = 8447;
37
- static networkUrl = 'wss://game7.thegraid.com:8447'; // URL to cgserver (wspbserver)
76
+ static networkUrl = TP.buildURL(); // URL to cgserver (wspbserver)
38
77
  static networkGroup = 'citymap:game1';
39
78
  static vpToWin = 20;
40
79
  static roboDrawTile = 1.0; // Bias toward draw Tile
@@ -1 +1 @@
1
- {"version":3,"file":"table-params.js","sourceRoot":"","sources":["../src/table-params.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,CAAU,CAAA,CAAC,iBAAiB;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAA,CAAC,4BAA4B;AAClF,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;AAG5C,MAAM,UAAU,UAAU,CAAC,KAAkB,IAAiB,OAAO,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAA,CAAC,CAAC;AAI3H,MAAM,UAAU,iBAAiB,CAAI,CAAI,EAAE,CAAI,EAAE,CAAI,IAA0B,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA,CAAC,CAAC;AAAA,CAAC;AACpG,MAAM,UAAU,kBAAkB,CAAI,CAAyB,IAAI,OAAO,iBAAiB,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