@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
package/dist/hex.js CHANGED
@@ -5,8 +5,7 @@ import { HexShape, LegalMark } from "./shapes";
5
5
  import { TP } from "./table-params";
6
6
  export const S_Resign = 'Hex@Resign';
7
7
  export const S_Skip = 'Hex@skip ';
8
- export function newHSC(hex, sc, Aname = hex.Aname) { return { Aname, hex, sc }; }
9
- /** to recognize this class in hexUnderPoint and obtain the associated Hex2. */
8
+ /** to recognize this class in hexUnderPoint and obtain the associated hex2: IHex2 */
10
9
  export class HexCont extends Container {
11
10
  hex2;
12
11
  constructor(hex2) {
@@ -14,10 +13,14 @@ export class HexCont extends Container {
14
13
  this.hex2 = hex2;
15
14
  }
16
15
  }
17
- /** Base Hex, has no connection to graphics.
18
- * topological links to adjacent hex objects.
16
+ function nf(n) { return `${n !== undefined ? (n === Math.floor(n)) ? n : n.toFixed(1) : ''}`; }
17
+ /**
18
+ * Minimal Hex, with topological links to adjacent hex objects,
19
+ * has no connection to graphics.
19
20
  */
20
21
  export class Hex {
22
+ /** Identify Hex instance derived from Hex2Mixin; and so implements IHex2. */
23
+ static isIHex2(hex) { return hex.implementsIHex2; }
21
24
  /** return indicated Hex from otherMap */
22
25
  static ofMap(ihex, otherMap) {
23
26
  try {
@@ -39,8 +42,8 @@ export class Hex {
39
42
  this.links = {};
40
43
  }
41
44
  /** (x,y): center of hex; (width,height) of hex; scaled by radius if supplied
42
- * @param radius [1] radius used in drawPolyStar(radius,,, H.dirRot[tiltDir])
43
- * @param ewTopo [TP.useEwTopo] true -> suitable for ewTopo (long axis of hex is N/S)
45
+ * @param radius [TP.hexRad] 'size' of hex; radius used in drawPolyStar(radius,,, H.dirRot[tiltDir])
46
+ * @param ewTopo [TP.useEwTopo] true -> suitable for ewTopo (has E & W [vertical] sides)
44
47
  * @param row [this.row]
45
48
  * @param col [this.col]
46
49
  * @returns \{ x, y, w, h, dxdc, dydr } of cell at [row, col]
@@ -63,18 +66,17 @@ export class Hex {
63
66
  return { x, y, w, h, dxdc, dydr };
64
67
  }
65
68
  }
66
- get xywh0() { return this.xywh(); } // so can see xywh from debugger
69
+ get xywh0() { return this.xywh(TP.hexRad); } // so can see xywh from debugger
67
70
  // _Aname: string;
68
71
  // get Aname() { return this._Aname; }
69
72
  // protected set Aname (name: string) { this._Aname = name; }
70
73
  Aname;
71
74
  /** reduce to serializable IHex (removes map, inf, links, etc) */
72
75
  get iHex() { return { Aname: this.Aname, row: this.row, col: this.col }; }
73
- nf(n) { return `${n !== undefined ? (n === Math.floor(n)) ? n : n.toFixed(1) : ''}`; }
74
76
  /** [row,col] OR special name */
75
- get rcs() { return (this.row >= 0) ? `[${this.nf(this.row)},${this.nf(this.col)}]` : this.Aname.substring(4); }
76
- get rowsp() { return (this.nf(this.row ?? -1)).padStart(2); }
77
- get colsp() { return (this.nf(this.col ?? -1)).padStart(2); } // col== -1 ? S_Skip; -2 ? S_Resign
77
+ get rcs() { return (this.row >= 0) ? `[${nf(this.row)},${nf(this.col)}]` : this.Aname.substring(4); }
78
+ get rowsp() { return (nf(this.row ?? -1)).padStart(2); }
79
+ get colsp() { return (nf(this.col ?? -1)).padStart(2); } // col== -1 ? S_Skip; -2 ? S_Resign
78
80
  /** [row,col] OR special name */
79
81
  get rcsp() { return (this.row >= 0) ? `[${this.rowsp},${this.colsp}]` : this.Aname.substring(4).padEnd(7); }
80
82
  /** compute ONCE, *after* HexMap is populated with all the Hex! */
@@ -90,6 +92,7 @@ export class Hex {
90
92
  _isLegal;
91
93
  get isLegal() { return this._isLegal; }
92
94
  set isLegal(v) { this._isLegal = v; }
95
+ /** hexlib.Hex uses only the HexM slice of a HexMap. */
93
96
  map; // Note: this.parent == this.map.hexCont [cached] TODO: typify ??
94
97
  row;
95
98
  col;
@@ -181,156 +184,178 @@ export class Hex1 extends Hex {
181
184
  return `${color}@${this.rcsp}`;
182
185
  }
183
186
  }
184
- /** One Hex cell in the game, shown as a polyStar Shape */
185
- export class Hex2 extends Hex1 {
186
- /** Child of mapCont.hexCont: HexCont holds hexShape(color), rcText, distText, capMark */
187
- cont = new HexCont(this); // Hex IS-A Hex0, HAS-A HexCont Container
188
- radius = TP.hexRad; // determines width & height
189
- hexShape = this.makeHexShape(); // shown on this.cont: colored hexagon
190
- get mapCont() { return this.map.mapCont; }
191
- get markCont() { return this.mapCont.markCont; }
192
- get x() { return this.cont.x; }
193
- set x(v) { this.cont.x = v; }
194
- get y() { return this.cont.y; }
195
- set y(v) { this.cont.y = v; }
196
- get scaleX() { return this.cont.scaleX; }
197
- get scaleY() { return this.cont.scaleY; }
198
- // if override set, then must override get!
199
- get district() { return this._district; }
200
- set district(d) {
201
- this._district = d; // cannot use super.district = d [causes recursion, IIRC]
202
- this.distText.text = `${d}`;
203
- }
204
- distColor; // district color of hexShape (paintHexShape)
205
- distText; // shown on this.cont
206
- rcText; // shown on this.cont
207
- setUnit(unit, meep = false) {
208
- const cont = this.mapCont.tileCont, x = this.x, y = this.y;
209
- let k = true; // debug double tile
210
- const this_unit = (meep ? this.meep : this.tile);
211
- if (unit !== undefined && this_unit !== undefined && !(meep && this_unit.recycleVerb === 'demolished')) {
212
- if (this === this_unit.source?.hex && this === unit.source?.hex) {
213
- // Table.dragStart does moveTo(undefined); which triggers source.nextUnit()
214
- // so if we drop to the startHex, we have a collision.
215
- // Resolve by putting this_unit (the 'nextUnit') back in the source.
216
- // (availUnit will recurse to set this.unit = undefined)
217
- this_unit.source.availUnit(this_unit); // Meeple extends Tile, but TS seems confused.
187
+ /**
188
+ * Mixin hexlib/Hex2 with (LocalHex extends Hex1)
189
+ *
190
+ * class LocalHex1 extends Hex1Lib { ... }
191
+ *
192
+ * class LibHex2extendsLocalHex1 extends Hex2Mixin(LocalHex1) { }
193
+ *
194
+ * class LocalHex2 extends LibHex2extendsLocalHex1 { ... }
195
+ */
196
+ export function Hex2Mixin(Base) {
197
+ return class Hex2Impl extends Base {
198
+ /**
199
+ * add Hex2 to map?.mapCont.hexCont; not in map.hexAry!
200
+ *
201
+ * Hex2.cont contains:
202
+ * - hexShape: polyStar Shape of radius @ (XY=0,0)
203
+ * - rcText: '(r,c)' slightly above center, WHITE
204
+ * - distText: initially distText.text = `${district}` slightly below center, BLACK
205
+ */
206
+ constructor(...args) {
207
+ const [map, row, col, name] = args;
208
+ super(map, row, col, name); // invoke the given Base constructor: LocalHex1
209
+ this.constructorCode(map, row, col, name);
210
+ return; // breakpoint able
211
+ }
212
+ implementsIHex2 = true;
213
+ /** Child of mapCont.hexCont: HexCont holds hexShape(color), rcText, distText, capMark */
214
+ cont = new HexCont(this); // Hex IS-A Hex0, HAS-A HexCont Container
215
+ radius = TP.hexRad; // determines width & height
216
+ hexShape = this.makeHexShape(); // shown on this.cont: colored hexagon
217
+ get mapCont() { return this.map.mapCont; }
218
+ get markCont() { return this.mapCont.markCont; }
219
+ get x() { return this.cont.x; }
220
+ set x(v) { this.cont.x = v; }
221
+ get y() { return this.cont.y; }
222
+ set y(v) { this.cont.y = v; }
223
+ get scaleX() { return this.cont.scaleX; }
224
+ get scaleY() { return this.cont.scaleY; }
225
+ // if override set, then must override get!
226
+ get district() { return this._district; }
227
+ set district(d) {
228
+ this._district = d; // cannot use super.district = d [causes recursion, IIRC]
229
+ this.distText.text = `${d}`;
230
+ }
231
+ distColor; // district color of hexShape (paintHexShape)
232
+ distText; // shown on this.cont
233
+ rcText; // shown on this.cont
234
+ setUnit(unit, meep = false) {
235
+ const cont = this.mapCont.tileCont, x = this.x, y = this.y;
236
+ let k = true; // debug double tile
237
+ const this_unit = (meep ? this.meep : this.tile);
238
+ if (unit !== undefined && this_unit !== undefined && !(meep && this_unit.recycleVerb === 'demolished')) {
239
+ if (this === this_unit.source?.hex && this === unit.source?.hex) {
240
+ // Table.dragStart does moveTo(undefined); which triggers source.nextUnit()
241
+ // so if we drop to the startHex, we have a collision.
242
+ // Resolve by putting this_unit (the 'nextUnit') back in the source.
243
+ // (availUnit will recurse to set this.unit = undefined)
244
+ this_unit.source.availUnit(this_unit); // Meeple extends Tile, but TS seems confused.
245
+ }
246
+ else if (k)
247
+ debugger;
248
+ }
249
+ meep ? (super.meep = unit) : (super.tile = unit); // set _meep or _tile;
250
+ if (unit !== undefined) {
251
+ unit.x = x;
252
+ unit.y = y;
253
+ cont.addChild(unit); // meep will go under tile
254
+ // after source.hex is set, updateCounter:
255
+ if (this === unit.source?.hex)
256
+ unit.source.updateCounter();
218
257
  }
219
- else if (k)
220
- debugger;
221
258
  }
222
- meep ? (super.meep = unit) : (super.tile = unit); // set _meep or _tile;
223
- if (unit !== undefined) {
224
- unit.x = x;
225
- unit.y = y;
226
- cont.addChild(unit); // meep will go under tile
227
- // after source.hex is set, updateCounter:
228
- if (this === unit.source?.hex)
229
- unit.source.updateCounter();
259
+ get tile() { return super.tile; }
260
+ set tile(tile) { this.setUnit(tile, false); }
261
+ get meep() { return super.meep; }
262
+ set meep(meep) { this.setUnit(meep, true); }
263
+ constructorCode(map, row, col, name) {
264
+ this.initCont(row, col);
265
+ map?.mapCont.hexCont.addChild(this.cont);
266
+ this.hexShape.name = this.Aname;
267
+ const nf = (n) => `${n !== undefined ? (n === Math.floor(n)) ? n : n.toFixed(1) : ''}`;
268
+ const rc = `${nf(row)},${nf(col)}`, rcf = 26 * TP.hexRad / 60;
269
+ const rct = this.rcText = new CenterText(rc, F.fontSpec(rcf), 'white');
270
+ rct.y -= rcf / 2; // raise it up
271
+ this.cont.addChild(rct);
272
+ const dtf = 20 * TP.hexRad / 60;
273
+ this.distText = new CenterText(``, F.fontSpec(dtf));
274
+ this.distText.y += dtf; // push it down
275
+ this.cont.addChild(this.distText);
276
+ this.legalMark.setOnHex(this);
277
+ this.showText(true); // & this.cache()
230
278
  }
231
- }
232
- get tile() { return super.tile; }
233
- set tile(tile) { this.setUnit(tile, false); }
234
- get meep() { return super.meep; }
235
- set meep(meep) { this.setUnit(meep, true); }
236
- /**
237
- * add Hex2 to map?.mapCont.hexCont; not in map.hexAry!
238
- * Hex2.cont contains:
239
- * - hexShape: polyStar Shape of radius @ (XY=0,0)
240
- * - rcText: '(r,c)' slightly above center, WHITE
241
- * - distText: initially distText.text = `${district}` slightly below center, BLACK
242
- */
243
- constructor(map, row, col, name) {
244
- super(map, row, col, name);
245
- this.initCont(row, col);
246
- map?.mapCont.hexCont.addChild(this.cont);
247
- this.hexShape.name = this.Aname;
248
- const nf = (n) => `${n !== undefined ? (n === Math.floor(n)) ? n : n.toFixed(1) : ''}`;
249
- const rc = `${nf(row)},${nf(col)}`, rcf = 26 * TP.hexRad / 60;
250
- const rct = this.rcText = new CenterText(rc, F.fontSpec(rcf), 'white');
251
- rct.y -= rcf / 2; // raise it up
252
- this.cont.addChild(rct);
253
- const dtf = 20 * TP.hexRad / 60;
254
- this.distText = new CenterText(``, F.fontSpec(dtf));
255
- this.distText.y += dtf; // push it down
256
- this.cont.addChild(this.distText);
257
- this.legalMark.setOnHex(this);
258
- this.showText(true); // & this.cache()
259
- }
260
- /** set visibility of rcText & distText */
261
- showText(vis = !this.rcText.visible) {
262
- this.rcText.visible = this.distText.visible = vis;
263
- this.cont.updateCache();
264
- }
265
- legalMark = new LegalMark();
266
- get isLegal() { return this._isLegal; }
267
- set isLegal(v) {
268
- super.isLegal = v;
269
- this.legalMark.visible = v;
270
- }
271
- initCont(row, col) {
272
- const cont = this.cont;
273
- const { x, y, w, h } = this.xywh(this.radius, TP.useEwTopo, row, col); // include margin space between hexes
274
- cont.x = x;
275
- cont.y = y;
276
- // initialize cache bounds:
277
- cont.setBounds(-w / 2, -h / 2, w, h);
278
- const b = cont.getBounds();
279
- cont.cache(b.x, b.y, b.width, b.height);
280
- // cont.rotation = this.map.topoRot;
281
- }
282
- makeHexShape(shape = HexShape) {
283
- const hs = new shape(this.radius);
284
- this.cont.addChildAt(hs, 0);
285
- this.cont.hitArea = hs;
286
- hs.paint('grey');
287
- return hs;
288
- }
289
- /** set hexShape using color: draw border and fill
290
- * @param color
291
- * @param district if supplied, set this.district
292
- */
293
- setHexColor(color, district) {
294
- if (district !== undefined)
295
- this.district = district; // hex.setHexColor update district
296
- this.distColor = color;
297
- this.hexShape.paint(color);
298
- this.cont.updateCache();
299
- }
300
- // The following were created for the map in hexmarket:
301
- /** unit distance between Hexes: adjacent = 1; see also: radialDist */
302
- metricDist(hex) {
303
- let { x: tx, y: ty } = this.xywh(1), { x: hx, y: hy } = hex.xywh(1);
304
- let dx = tx - hx, dy = ty - hy;
305
- return Math.sqrt(dx * dx + dy * dy); // tw == H.sqrt3
306
- }
307
- /** location of corner between dir0 and dir1; in parent coordinates.
308
- * @param dir0 an EwDir
309
- * @param dir1 an EwDir
310
- */
311
- // hexmarket uses to find ewDir corner between two nsDir edges.
312
- cornerPoint(dir0, dir1) {
313
- const d0 = H.ewDirRot[dir0], d1 = H.ewDirRot[dir1];
314
- let a2 = (d0 + d1) / 2, h = this.radius;
315
- if (Math.abs(d0 - d1) > 180)
316
- a2 += 180;
317
- let a = a2 * H.degToRadians;
318
- return new Point(this.x + Math.sin(a) * h, this.y - Math.cos(a) * h);
319
- }
320
- /** Location of edge point in dir; in parent coordinates.
321
- * @param dir indicates direction to edge
322
- * @param rad [1] per-unit distance from center: 0 --> center, 1 --> exactly on edge, 1+ --> outside hex
323
- * @param point [new Point()] set location-x,y in point and return it.
324
- */
325
- edgePoint(dir, rad = 1, point = new Point()) {
326
- const a = H.nsDirRot[dir] * H.degToRadians, h = rad * this.radius * H.sqrt3_2;
327
- point.x = this.hexShape.x + Math.sin(a) * h;
328
- point.y = this.hexShape.y - Math.cos(a) * h;
329
- return point;
330
- }
279
+ /** set visibility of rcText & distText */
280
+ showText(vis = !this.rcText.visible) {
281
+ this.rcText.visible = this.distText.visible = vis;
282
+ this.cont.updateCache();
283
+ }
284
+ legalMark = new LegalMark();
285
+ get isLegal() { return this._isLegal; }
286
+ set isLegal(v) {
287
+ super.isLegal = v;
288
+ this.legalMark.visible = v;
289
+ }
290
+ /** place this.cont; setBounds(); cont.cache() */
291
+ initCont(row, col) {
292
+ const cont = this.cont;
293
+ const { x, y, w, h } = this.xywh(this.radius, TP.useEwTopo, row, col); // include margin space between hexes
294
+ cont.x = x;
295
+ cont.y = y;
296
+ // initialize cache bounds:
297
+ cont.setBounds(-w / 2, -h / 2, w, h);
298
+ const b = cont.getBounds();
299
+ cont.cache(b.x, b.y, b.width, b.height);
300
+ // cont.rotation = this.map.topoRot;
301
+ }
302
+ makeHexShape(shape = HexShape) {
303
+ const hs = new shape(this.radius);
304
+ this.cont.addChildAt(hs, 0);
305
+ this.cont.hitArea = hs;
306
+ hs.paint('grey');
307
+ return hs;
308
+ }
309
+ /** set hexShape using color: draw border and fill
310
+ * @param color
311
+ * @param district if supplied, set this.district
312
+ */
313
+ setHexColor(color, district) {
314
+ if (district !== undefined)
315
+ this.district = district; // hex.setHexColor update district
316
+ this.distColor = color;
317
+ this.hexShape.paint(color);
318
+ this.cont.updateCache();
319
+ }
320
+ // The following were created for the map in hexmarket:
321
+ /** unit distance between Hexes: adjacent = 1; see also: radialDist */
322
+ metricDist(hex) {
323
+ let { x: tx, y: ty } = this.xywh(1), { x: hx, y: hy } = hex.xywh(1);
324
+ let dx = tx - hx, dy = ty - hy;
325
+ return Math.sqrt(dx * dx + dy * dy); // tw == H.sqrt3
326
+ }
327
+ /** location of corner between dir0 and dir1; in parent coordinates.
328
+ * @param dir0 an EwDir
329
+ * @param dir1 an EwDir
330
+ */
331
+ // hexmarket uses to find ewDir corner between two nsDir edges.
332
+ cornerPoint(dir0, dir1) {
333
+ const d0 = H.ewDirRot[dir0], d1 = H.ewDirRot[dir1];
334
+ let a2 = (d0 + d1) / 2, h = this.radius;
335
+ if (Math.abs(d0 - d1) > 180)
336
+ a2 += 180;
337
+ let a = a2 * H.degToRadians;
338
+ return new Point(this.x + Math.sin(a) * h, this.y - Math.cos(a) * h);
339
+ }
340
+ /** Location of edge point in dir; in parent coordinates.
341
+ * @param dir indicates direction to edge
342
+ * @param rad [1] per-unit distance from center: 0 --> center, 1 --> exactly on edge, 1+ --> outside hex
343
+ * @param point [new Point()] set location-x,y in point and return it.
344
+ */
345
+ edgePoint(dir, rad = 1, point = new Point()) {
346
+ const a = H.nsDirRot[dir] * H.degToRadians, h = rad * this.radius * H.sqrt3_2;
347
+ point.x = this.hexShape.x + Math.sin(a) * h;
348
+ point.y = this.hexShape.y - Math.cos(a) * h;
349
+ return point;
350
+ }
351
+ };
331
352
  }
332
- export class RecycleHex extends Hex2 {
353
+ /** a default Constructor and implementation of IHex2 */
354
+ export class Hex2 extends Hex2Mixin(Hex1) {
333
355
  }
356
+ /** a default Constructor and impl for RecycleHex. */
357
+ export class RecycleHex extends Hex2 {
358
+ } // RecycleHex
334
359
  /**
335
360
  * A HexShape/PaintableShape to indicate selected hex of HexMap.
336
361
  *
@@ -351,11 +376,6 @@ export class HexMark extends HexShape {
351
376
  this.setHexBounds(); // bounds are based on readonly, should be const
352
377
  this.mouseEnabled = false;
353
378
  }
354
- // don't invoke Mark.paint(new_color); TODO: remove this override.
355
- // override paint(color: string): Graphics {
356
- // this.setHexBounds(); // <--- likely redundant, see HexSHape
357
- // return this.graphics; // do not repaint.
358
- // }
359
379
  // Fail: markCont to be 'above' tileCont...
360
380
  /**
361
381
  * Show or hide mark on given hex; and hex.updateCache.
@@ -393,7 +413,7 @@ export class MapCont extends Container {
393
413
  super();
394
414
  this.name = 'mapCont';
395
415
  }
396
- /** initial, default, readonly Container names, fields */
416
+ /** initial, default, readonly Container names, fieldNames */
397
417
  static cNames = ['resaCont', 'hexCont', 'tileCont', 'markCont', 'counterCont'];
398
418
  /** actual cNames being used for this MapCont, set in addContainers() */
399
419
  _cNames = MapCont.cNames.concat();
@@ -406,7 +426,7 @@ export class MapCont extends Container {
406
426
  // capCont: Container // for tile.capMark
407
427
  counterCont; // counters for AuctionCont
408
428
  // eventCont: Container// the eventHex & and whatever Tile is on it...
409
- /** add all the layers of Containers. */
429
+ /** add all the layers of Containers. update this.cNames */
410
430
  addContainers(cNames = this.cNames) {
411
431
  this._cNames = cNames.concat();
412
432
  this.removeAllChildren();
@@ -438,12 +458,12 @@ export class MapCont extends Container {
438
458
  }
439
459
  /**
440
460
  * Collection of Hex *and* Graphics-Containers for Hex2
441
- * allStones: HSC[] and districts: Hex[]
461
+ * districts: Hex[]
442
462
  *
443
463
  * HexMap[row][col]: Hex or Hex2 elements.
444
464
  * If mapCont is set, then populate with Hex2
445
465
  *
446
- * (TP.mh X TP.nh) hexes in districts; allStones: HSC[]
466
+ * (TP.mh X TP.nh) hexes in districts;
447
467
  *
448
468
  * With a Mark and off-map: skipHex & resignHex
449
469
  *
@@ -468,8 +488,9 @@ export class HexMap extends Array {
468
488
  if (addToMapCont)
469
489
  this.addToMapCont(this.hexC);
470
490
  }
471
- get asHex2Map() { return this; }
472
- /** Each occupied Hex, with the occupying PlayerColor */
491
+ /** may be obsolete when using IHex2 */
492
+ get asIHex2Map() { return this; }
493
+ /** Each occupied Hex, with the associated district color */
473
494
  district = [];
474
495
  hexAry; // set by makeAllDistricts()
475
496
  mapCont = new MapCont(); // if/when using Hex2
@@ -481,10 +502,9 @@ export class HexMap extends Array {
481
502
  // -----------------------+ // -----------------------+ // -----------------------+
482
503
  // sqrt3 // sqrt3/2 // 1
483
504
  //
484
- allStones = [];
485
505
  radius = TP.hexRad;
486
506
  /** return this.centerHex.xywh() for this.topo */
487
- get xywh() { return this.centerHex.xywh(); }
507
+ get xywh() { return this.centerHex.xywh(this.radius); }
488
508
  minCol = undefined; // Array.forEach does not look at negative indices!
489
509
  maxCol = undefined; // used by rcLinear
490
510
  minRow = undefined; // to find centerHex
@@ -588,7 +608,7 @@ export class HexMap extends Array {
588
608
  if (!hex) { // || hex.Aname === S_Skip || hex.Aname === S_Resign) {
589
609
  mark.visible = false;
590
610
  }
591
- else if (hex instanceof Hex2) {
611
+ else if (Hex.isIHex2(hex)) {
592
612
  mark.scaleX = hex.scaleX;
593
613
  mark.scaleY = hex.scaleY;
594
614
  mark.visible = true;
@@ -799,7 +819,7 @@ export class HexMap extends Array {
799
819
  */
800
820
  setDistrictAndPaint(hexAry, district = 0) {
801
821
  this.district[district] = hexAry;
802
- if (hexAry[0] instanceof Hex2) {
822
+ if (Hex.isIHex2(hexAry[0])) {
803
823
  this.paintDistrict(hexAry, district);
804
824
  }
805
825
  }