@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.
- package/dist/game-play.d.ts +1 -1
- package/dist/game-play.d.ts.map +1 -1
- package/dist/game-play.js +4 -4
- package/dist/game-play.js.map +1 -1
- package/dist/game-setup.d.ts +39 -11
- package/dist/game-setup.d.ts.map +1 -1
- package/dist/game-setup.js +68 -21
- package/dist/game-setup.js.map +1 -1
- package/dist/hex.d.ts +282 -88
- package/dist/hex.d.ts.map +1 -1
- package/dist/hex.js +191 -171
- package/dist/hex.js.map +1 -1
- package/dist/meeple.d.ts +2 -2
- package/dist/meeple.d.ts.map +1 -1
- package/dist/meeple.js.map +1 -1
- package/dist/plan-proxy.d.ts.map +1 -1
- package/dist/player-panel.js +1 -1
- package/dist/player-panel.js.map +1 -1
- package/dist/player.d.ts +1 -0
- package/dist/player.d.ts.map +1 -1
- package/dist/player.js +1 -0
- package/dist/player.js.map +1 -1
- package/dist/scenario-parser.d.ts +2 -3
- package/dist/scenario-parser.d.ts.map +1 -1
- package/dist/scenario-parser.js.map +1 -1
- package/dist/shapes.d.ts +6 -6
- package/dist/shapes.d.ts.map +1 -1
- package/dist/shapes.js +9 -9
- package/dist/shapes.js.map +1 -1
- package/dist/table-params.d.ts +23 -2
- package/dist/table-params.d.ts.map +1 -1
- package/dist/table-params.js +43 -4
- package/dist/table-params.js.map +1 -1
- package/dist/table.d.ts +1099 -28
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +66 -41
- package/dist/table.js.map +1 -1
- package/dist/tile-source.d.ts +3 -3
- package/dist/tile-source.d.ts.map +1 -1
- package/dist/tile-source.js.map +1 -1
- package/dist/tile.d.ts +19 -14
- package/dist/tile.d.ts.map +1 -1
- package/dist/tile.js +8 -3
- package/dist/tile.js.map +1 -1
- 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
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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 [
|
|
43
|
-
* @param ewTopo [TP.useEwTopo] true -> suitable for ewTopo (
|
|
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) ? `[${
|
|
76
|
-
get rowsp() { return (
|
|
77
|
-
get colsp() { return (
|
|
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
|
-
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
*
|
|
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;
|
|
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
|
-
|
|
472
|
-
|
|
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
|
|
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]
|
|
822
|
+
if (Hex.isIHex2(hexAry[0])) {
|
|
803
823
|
this.paintDistrict(hexAry, district);
|
|
804
824
|
}
|
|
805
825
|
}
|