@thegraid/hexlib 1.0.7 → 1.0.10

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/hex.d.ts CHANGED
@@ -117,7 +117,8 @@ export declare class Hex {
117
117
  hexesInDir(dir: HexDir, rv?: this[]): this[];
118
118
  /** for each Hex in each Dir: func(hex, dir, this) */
119
119
  forEachHexDir(func: (hex: this, dir: HexDir, hex0: this) => unknown): void;
120
- nextHex(ds: HexDir, ns?: number): Hex | undefined;
120
+ /** from this Hex, follow links[ds], ns times. */
121
+ nextHex(dir: HexDir, ns?: number): Hex | undefined;
121
122
  /** return last Hex on axis in given direction */
122
123
  lastHex(ds: HexDir): Hex;
123
124
  /** distance between Hexes: adjacent = 1, based on row, col, sqrt3 */
@@ -221,6 +222,15 @@ export declare class MapCont extends Container {
221
222
  eventCont: Container;
222
223
  /** add all the layers of Containers. */
223
224
  addContainers(): void;
225
+ /**
226
+ * Set hexCont(x,y) so hexMap.getBounds() is centered around mapCont(0,0);
227
+ *
228
+ * [So hexCont.centerHex is at mapCont(0,0)]
229
+ *
230
+ * Move ALL children of mapCont to have that same (x,y) alignment.
231
+ * @param hexCont use getBounds() of given Container to compute alignment.
232
+ */
233
+ centerContainers(hexCont?: Container): void;
224
234
  }
225
235
  export interface HexM<T extends Hex> {
226
236
  readonly district: T[][];
@@ -264,6 +274,10 @@ export declare class HexMap<T extends Hex> extends Array<Array<T>> implements He
264
274
  private maxCol?;
265
275
  private minRow?;
266
276
  private maxRow?;
277
+ get centerRC(): {
278
+ row: number;
279
+ col: number;
280
+ };
267
281
  get centerHex(): T;
268
282
  get nRowCol(): number[];
269
283
  getCornerHex(dn: HexDir): Hex;
@@ -302,6 +316,9 @@ export declare class HexMap<T extends Hex> extends Array<Array<T>> implements He
302
316
  topo: (rc: RC) => (TopoEW | TopoNS);
303
317
  /** see also: Hex.linkDirs */
304
318
  get linkDirs(): HexDir[];
319
+ /** return a new RC; does not mutate the given RC.
320
+ * @return RC of adjacent Hex in given direction for given topo.
321
+ */
305
322
  nextRowCol(rc: RC, dir: HexDir, nt?: Topo): RC;
306
323
  /** link hex to/from each extant neighor */
307
324
  link(hex: T, rc?: RC, map?: T[][], nt?: Topo, lf?: (hex: T) => LINKS<T>): void;
@@ -318,25 +335,85 @@ export declare class HexMap<T extends Hex> extends Array<Array<T>> implements He
318
335
  private _mh;
319
336
  get nh(): number;
320
337
  get mh(): number;
338
+ /** final; set size one time, then it is readonly. */
339
+ setSize(nh?: number, mh?: number): void;
340
+ /** utility for makeAllDistricts; make hex0 at RC */
341
+ calculateRC0(): RC;
321
342
  /**
322
- *
343
+ * Wrapper for makeAllHexes;
344
+ * setSize, calculateRC0, makeAllHexes, set this.hexAry, centerContainers()
323
345
  * @param nh number of hexes on on edge of metaHex
324
346
  * @param mh order of metaHexes (greater than 0);
325
347
  */
326
348
  makeAllDistricts(nh?: number, mh?: number): T[];
327
- centerOnContainer(): void;
349
+ /**
350
+ * overridable action for makeAllDistricts;
351
+ *
352
+ * Base implementation invokes makeMetaDistrict(nh, mh, rc0)
353
+ * @param nh
354
+ * @param mh
355
+ * @param rc0
356
+ * @return hexAry of the created hexes, becomes hexMap.hexAry
357
+ */
358
+ makeAllHexes(nh: number | undefined, mh: number | undefined, rc0: RC): T[];
359
+ /**
360
+ * Make the center district, then make (mh-1) rings other meta-hex districts.
361
+ * @param nh order [number of 'rings'] of meta-hexes (2 or 3 for this game) [TP.mHexes]
362
+ * @param mh size ['rings' in each meta-hex] of meta-hex (1..6) [TP.nHexes]
363
+ * @param rc0 location of initial, central Hex
364
+ * @return
365
+ */
366
+ makeMetaHexRings(nh: number | undefined, mh: number | undefined, rc0: RC): T[];
367
+ /**
368
+ * Make a single metaHex (district) of order nh, at hex[mr, mc]
369
+ *
370
+ * addHex for center and each of nh rings.
371
+ * @param nh order of the metaHex/district
372
+ * @param district identifying number of district
373
+ * @param rc location of center Hex
374
+ * @return array containing all the added Hexes
375
+ */
376
+ makeMetaHex(nh: number, district: number, rc: RC): T[];
377
+ /**
378
+ * pickColor and paint all Hexes in hex2Ary
379
+ *
380
+ * Optional special color for center hex of each district
381
+ * @param hex2Aray a Hex2[] of hexes to be colored by pickColor(hexAry)
382
+ * @param district if district == 0, paint with special distColor[0]
383
+ * @param cColor color for center hex, else use dcolor from pickColor(hex2Ary)
384
+ */
385
+ paintDistrict(hex2Ary: Hex2[], district?: number, cColor?: string): void;
386
+ /** find color not used by hex adjacent to given hexAry */
328
387
  pickColor(hexAry: Hex2[]): string;
388
+ /** record hexAry in this.district[district];
389
+ *
390
+ * paint each Hex using paintDistrict.
391
+ */
392
+ setDistrictAndPaint(hexAry: T[], district?: number): void;
329
393
  /**
330
- * Make one meta-hex district.
394
+ * Make rectangle of hexes created with this.hexC.
331
395
  *
332
- * rings of this.hexC with topo derived from Hex.topo (TP.useEwTopo)
333
- * @param nh order of inner-hex: number hexes on side of meta-hex
334
- * @param district identifying number of this district
335
- * @param mr make new district on meta-row
336
- * @param mc make new district on meta-col
396
+ * Note: district = 0; hexAry.forEach() to set alternate district.
397
+ *
398
+ * rnd == 1 looks best when nc is odd;
399
+ * @param nr height
400
+ * @param nc width [nr + 1]
401
+ * @param rnd 0: all, 1: rm end of row 0 (& half of last row!)
402
+ * @parma half [(rnd === 1) || (nc % 2 === 1)] force/deny final half-row
403
+ * @param hexAry array in which to push the created Hexes [Array()<T>]
404
+ * @returns hexAry with the created Hexes pushed (row major)
405
+ */
406
+ makeRect(nr: number, nc?: number, rnd?: number, half?: boolean, hexAry?: T[]): T[];
407
+ /**
408
+ * create horizontal row using hexAry.push(addHex(row, col++dc, district))
409
+ * @param maxc max col to use (esp when dc > 1)
410
+ * @param row
411
+ * @param col
412
+ * @param district
413
+ * @param hexAry
414
+ * @param dc delta to column [1]
337
415
  */
338
- makeDistrict(nh: number, district: number, mr: number, mc: number): T[];
339
- setDistrictColor(hexAry: T[], district?: number): void;
416
+ addLineOfHex(maxc: number, row: number, col: number, district: number, hexAry: Hex[], dc?: number): void;
340
417
  /**
341
418
  * Select RC location of each Hex on a line, and eval f(rc) => Hex.
342
419
  *
@@ -347,35 +424,23 @@ export declare class HexMap<T extends Hex> extends Array<Array<T>> implements He
347
424
  * @param n number of Hex locations to select
348
425
  * @param rc {row, col} of selected location
349
426
  * @param dir from rc, move by dir to next location
350
- * @param f do 'whatever'; must return the given RC [or other RC seed for nextRowCol()!]
351
- * @returns RC of n+1-th Hex on the line (where you typically change to next dir)
352
- */
353
- forRCsOnLine(n: number, rc: RC, dir: HexDir, f: (rc: RC) => RC): RC;
354
- /**
355
- * Used to create rings of new Hex: this.addHex(row, col, district)
356
- * @param n number of Hex to create
357
- * @param rc create first Hex in given RC location
358
- * @param dir after first Hex move dir for each next Hex
359
- * @param district supplied to addHex()
360
- * @param hexAry push created Hex(s) on this array
361
- * @returns RC of next Hex location on line (typically use next direction and continue...)
427
+ * @param f do 'whatever' based on RC
428
+ * @returns nextRowCol(rc, dir) from the last rc of the line.
362
429
  */
363
- newHexesOnLine(n: number, rc: RC, dir: HexDir, district: number, hexAry: Hex[]): RC;
430
+ forRCsOnLine(n: number, rc: RC, dir: HexDir, f?: (rc: RC) => void): RC;
364
431
  /**
365
- * Apply f(rc, dir) to each of 'n' RCs on nth ring.
432
+ * Apply f(rc, dir) to each of 'n' lines of RCs on nth ring.
366
433
  * Step from centerHex by dirs[4], do a line for each dir in dirs.
367
434
  *
368
435
  * - if topoEW: step to W; make lines going NE, E, SE, SW, W, NW
369
436
  * - if topoNS: step to WS; make lines going N, EN, ES, S, WS, WN
370
- * @param n ring number
371
- * @param f (RC, dir) => void
437
+ * @param rc start of first line (heading dirs[0])
438
+ * @param n ring number; number of hexes per line
372
439
  * @param dirs [this.linkDirs] each topo dirs in [clockwise] order.
440
+ * @param f (RC, dir) => void
373
441
  * @return the *next* RC on the final line (so can easily spiral)
374
442
  */
375
- ringWalk(n: number, f: (rc: RC, dir: HexDir) => void, dirs?: HexDir[]): {
376
- row: number;
377
- col: number;
378
- };
443
+ ringWalk(rc: RC, n: number, dirs: HexDir[] | undefined, f: (rc: RC, dir: HexDir) => void): RC;
379
444
  }
380
445
  /** Marker class for HexMap used by GamePlayD */
381
446
  export declare class HexMapD extends HexMap<Hex> {
package/dist/hex.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAiB,WAAW,EAAK,EAAE,EAAK,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAK,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAM,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG5C,eAAO,MAAM,QAAQ,eAAe,CAAA;AACpC,eAAO,MAAM,MAAM,cAAc,CAAA;AACjC,MAAM,MAAM,IAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9D,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,GAAG,IAAI,KAAK,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;AAG/G,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,IAAI;K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EAAE,QAAQ,SAAI,EAAE,MAAM,CAAC,EAAE,MAAM;IAK5D,0DAA0D;IAC1D,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM;IAajC;;;OAGG;IACH,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,SAAI;IAO7C;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,SAAI,EAAE,IAAI,UAAgC,EAAE,MAAM,GAAE,CAAC,EAAO,GAAG,CAAC,EAAE;IAoBvG;;;;;;;;OAQG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,SAAI;IAM5F;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAO;IAQ/D;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,sBAAgB,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI;CAOnF;AAED,gDAAgD;AAChD,qBAAa,OAAQ,SAAQ,MAAM,CAAC,GAAG,CAAC;CAEvC"}
package/dist/hex.js CHANGED
@@ -137,9 +137,10 @@ export class Hex {
137
137
  forEachHexDir(func) {
138
138
  this.linkDirs.forEach((dir) => this.hexesInDir(dir).filter(hex => !!hex).map(hex => func(hex, dir, this)));
139
139
  }
140
- nextHex(ds, ns = 1) {
140
+ /** from this Hex, follow links[ds], ns times. */
141
+ nextHex(dir, ns = 1) {
141
142
  let hex = this;
142
- while (!!(hex = hex.links[ds]) && --ns > 0) { }
143
+ while (!!(hex = hex.links[dir]) && --ns > 0) { }
143
144
  return hex;
144
145
  }
145
146
  /** return last Hex on axis in given direction */
@@ -398,6 +399,24 @@ export class MapCont extends Container {
398
399
  this.addChild(cont);
399
400
  });
400
401
  }
402
+ /**
403
+ * Set hexCont(x,y) so hexMap.getBounds() is centered around mapCont(0,0);
404
+ *
405
+ * [So hexCont.centerHex is at mapCont(0,0)]
406
+ *
407
+ * Move ALL children of mapCont to have that same (x,y) alignment.
408
+ * @param hexCont use getBounds() of given Container to compute alignment.
409
+ */
410
+ centerContainers(hexCont = this.hexCont) {
411
+ const hexRect = hexCont.getBounds(); // based on aggregate of Hex2.cont.cache(bounds);
412
+ const { x, y, width, height } = hexRect;
413
+ const x0 = x + width / 2, y0 = y + height / 2;
414
+ MapCont.cNames.forEach(cname => {
415
+ const cont = this[cname];
416
+ cont.x = -x0;
417
+ cont.y = -y0;
418
+ });
419
+ }
401
420
  }
402
421
  /**
403
422
  * Collection of Hex *and* Graphics-Containers for Hex2
@@ -435,10 +454,14 @@ export class HexMap extends Array {
435
454
  maxCol = undefined; // used by rcLinear
436
455
  minRow = undefined; // to find centerHex
437
456
  maxRow = undefined; // to find centerHex
457
+ get centerRC() {
458
+ const row = Math.floor(((this.maxRow ?? 0) + (this.minRow ?? 0)) / 2);
459
+ const col = Math.floor(((this.minCol ?? 0) + (this.maxCol ?? 0)) / 2);
460
+ return { row, col };
461
+ }
438
462
  get centerHex() {
439
- let cr = Math.floor(((this.maxRow ?? 0) + (this.minRow ?? 0)) / 2);
440
- let cc = Math.floor(((this.minCol ?? 0) + (this.maxCol ?? 0)) / 2);
441
- return this[cr][cc]; // as Hex2; as T;
463
+ const { row, col } = this.centerRC;
464
+ return this[row][col]; // as Hex2; as T;
442
465
  }
443
466
  // when called, maxRow, etc are defined...
444
467
  get nRowCol() { return [(this.maxRow ?? 0) - (this.minRow ?? 0), (this.maxCol ?? 0) - (this.minCol ?? 0)]; }
@@ -448,7 +471,7 @@ export class HexMap extends Array {
448
471
  rcLinear(row, col) { return col + row * (1 + (this.maxCol ?? 0) - (this.minCol ?? 0)); }
449
472
  metaMap = Array(); // hex0 (center Hex) of each MetaHex, has metaLinks to others.
450
473
  mark; // a cached DisplayObject, used by showMark
451
- Aname = '';
474
+ Aname = 'mainMap';
452
475
  /**
453
476
  * HexMap: TP.nRows X TP.nCols hexes.
454
477
  *
@@ -563,11 +586,13 @@ export class HexMap extends Array {
563
586
  get linkDirs() {
564
587
  return TP.useEwTopo ? H.ewDirs : H.nsDirs;
565
588
  }
589
+ /** return a new RC; does not mutate the given RC.
590
+ * @return RC of adjacent Hex in given direction for given topo.
591
+ */
566
592
  nextRowCol(rc, dir, nt = this.topo(rc)) {
567
593
  const ntdir = nt[dir];
568
594
  const { dr, dc } = ntdir; // OR (nt as TopoEW[dir as EwDir]) OR simply: nt[dir]
569
- let row = rc.row + dr, col = rc.col + dc;
570
- return { row, col };
595
+ return { row: rc.row + dr, col: rc.col + dc };
571
596
  }
572
597
  /** link hex to/from each extant neighor */
573
598
  link(hex, rc = hex, map = this, nt = this.topo(rc), lf = (hex) => hex.links) {
@@ -608,31 +633,109 @@ export class HexMap extends Array {
608
633
  _mh;
609
634
  get nh() { return this._nh; }
610
635
  get mh() { return this._mh; }
636
+ /** final; set size one time, then it is readonly. */
637
+ setSize(nh = TP.nHexes, mh = TP.mHexes) {
638
+ this._nh = nh;
639
+ this._mh = mh;
640
+ }
641
+ /** utility for makeAllDistricts; make hex0 at RC */
642
+ calculateRC0() {
643
+ // suitable for makeMetaHexes
644
+ const offs = Math.ceil(this.nh + this.mh * 1.25);
645
+ return { row: offs, col: offs }; // row,col to be non-negative
646
+ }
611
647
  /**
612
- *
648
+ * Wrapper for makeAllHexes;
649
+ * setSize, calculateRC0, makeAllHexes, set this.hexAry, centerContainers()
613
650
  * @param nh number of hexes on on edge of metaHex
614
651
  * @param mh order of metaHexes (greater than 0);
615
652
  */
616
653
  makeAllDistricts(nh = TP.nHexes, mh = TP.mHexes) {
617
- this._nh = nh;
618
- this._mh = mh;
619
- const hexAry = this.makeDistrict(nh, 0, mh, 0); // nh hexes on outer ring; single meta-hex
620
- this.mapCont.hexCont && this.centerOnContainer();
621
- this.hexAry = hexAry;
654
+ this.setSize(nh, mh);
655
+ const rc0 = this.calculateRC0();
656
+ const hexAry = this.hexAry = this.makeAllHexes(nh, 0, rc0); // nh hexes on outer ring; single meta-hex
657
+ this.mapCont.hexCont && this.mapCont.centerContainers();
622
658
  return hexAry;
623
659
  }
624
- centerOnContainer() {
625
- let mapCont = this.mapCont;
626
- let hexRect = mapCont.hexCont.getBounds(); // based on aggregate of Hex2.cont.cache(bounds);
627
- const { x, y, width, height } = hexRect;
628
- let x0 = x + width / 2, y0 = y + height / 2;
629
- MapCont.cNames.forEach(cname => {
630
- const cont = mapCont[cname];
631
- cont.x = -x0;
632
- cont.y = -y0;
633
- });
634
- // mapCont.x = x0; mapCont.y = y0;
660
+ /**
661
+ * overridable action for makeAllDistricts;
662
+ *
663
+ * Base implementation invokes makeMetaDistrict(nh, mh, rc0)
664
+ * @param nh
665
+ * @param mh
666
+ * @param rc0
667
+ * @return hexAry of the created hexes, becomes hexMap.hexAry
668
+ */
669
+ makeAllHexes(nh = TP.nHexes, mh = TP.mHexes, rc0) {
670
+ return this.makeMetaHexRings(nh, mh, rc0);
635
671
  }
672
+ /**
673
+ * Make the center district, then make (mh-1) rings other meta-hex districts.
674
+ * @param nh order [number of 'rings'] of meta-hexes (2 or 3 for this game) [TP.mHexes]
675
+ * @param mh size ['rings' in each meta-hex] of meta-hex (1..6) [TP.nHexes]
676
+ * @param rc0 location of initial, central Hex
677
+ * @return
678
+ */
679
+ makeMetaHexRings(nh = TP.nHexes, mh = TP.mHexes, rc0) {
680
+ const dL = nh, dS = (nh - 1), dirs = this.linkDirs;
681
+ const nextMetaRC = (rc, nd) => {
682
+ const dirL = dirs[nd], dirS = dirs[(nd + 5) % 6]; // ring starts at 'dist' from center
683
+ rc = this.forRCsOnLine(dL, rc, dirL); // step (WS) by dist
684
+ rc = this.forRCsOnLine(dS, rc, dirS); // step (S) to center of 0-th metaHex
685
+ return rc;
686
+ };
687
+ // do metaRing = 0, district 0:
688
+ let district = 0, rc = rc0;
689
+ const hexAry = this.makeMetaHex(nh, district++, rc); // Central District [0]
690
+ for (let metaRing = 1; metaRing < mh; metaRing++) {
691
+ rc = nextMetaRC(rc, 4); // step in dirs[4] to initial rc (W or WS of previous rc)
692
+ // from rc, for each dir, step dir to center of next metaHex.
693
+ dirs.forEach((dirL, nd) => {
694
+ for (let nhc = 1; nhc <= metaRing; nhc++) {
695
+ rc = nextMetaRC(rc, nd);
696
+ const hexAry2 = this.makeMetaHex(nh, district++, rc);
697
+ hexAry.concat(...hexAry2);
698
+ }
699
+ });
700
+ }
701
+ return hexAry;
702
+ }
703
+ /**
704
+ * Make a single metaHex (district) of order nh, at hex[mr, mc]
705
+ *
706
+ * addHex for center and each of nh rings.
707
+ * @param nh order of the metaHex/district
708
+ * @param district identifying number of district
709
+ * @param rc location of center Hex
710
+ * @return array containing all the added Hexes
711
+ */
712
+ makeMetaHex(nh, district, rc) {
713
+ const hexAry = Array();
714
+ hexAry.push(this.addHex(rc.row, rc.col, district)); // The *center* hex of district
715
+ for (let ring = 1; ring < nh; ring++) {
716
+ rc = this.nextRowCol(rc, this.linkDirs[4]);
717
+ // place 'ring' of hexes, addHex along each line:
718
+ rc = this.ringWalk(rc, ring, this.linkDirs, (rc, dir) => {
719
+ hexAry.push(this.addHex(rc.row, rc.col, district));
720
+ return this.nextRowCol(rc, dir);
721
+ });
722
+ }
723
+ this.setDistrictAndPaint(hexAry, district);
724
+ return hexAry;
725
+ }
726
+ /**
727
+ * pickColor and paint all Hexes in hex2Ary
728
+ *
729
+ * Optional special color for center hex of each district
730
+ * @param hex2Aray a Hex2[] of hexes to be colored by pickColor(hexAry)
731
+ * @param district if district == 0, paint with special distColor[0]
732
+ * @param cColor color for center hex, else use dcolor from pickColor(hex2Ary)
733
+ */
734
+ paintDistrict(hex2Ary, district = 0, cColor) {
735
+ let dcolor = (district == 0) ? HexMap.distColor[0] : this.pickColor(hex2Ary);
736
+ hex2Ary.forEach((hex, n) => hex.setHexColor((n == 0) ? cColor ?? dcolor : dcolor));
737
+ }
738
+ /** find color not used by hex adjacent to given hexAry */
636
739
  pickColor(hexAry) {
637
740
  let hex = hexAry[0];
638
741
  let adjColor = [HexMap.distColor[0]]; // colors not to use
@@ -647,56 +750,61 @@ export class HexMap extends Array {
647
750
  });
648
751
  return HexMap.distColor.find(ci => !adjColor.includes(ci)) ?? 'white'; // or undefined or ...
649
752
  }
753
+ /** record hexAry in this.district[district];
754
+ *
755
+ * paint each Hex using paintDistrict.
756
+ */
757
+ setDistrictAndPaint(hexAry, district = 0) {
758
+ this.district[district] = hexAry;
759
+ if (hexAry[0] instanceof Hex2) {
760
+ this.paintDistrict(hexAry, district);
761
+ }
762
+ }
650
763
  /**
651
- * Make one meta-hex district.
764
+ * Make rectangle of hexes created with this.hexC.
765
+ *
766
+ * Note: district = 0; hexAry.forEach() to set alternate district.
652
767
  *
653
- * rings of this.hexC with topo derived from Hex.topo (TP.useEwTopo)
654
- * @param nh order of inner-hex: number hexes on side of meta-hex
655
- * @param district identifying number of this district
656
- * @param mr make new district on meta-row
657
- * @param mc make new district on meta-col
768
+ * rnd == 1 looks best when nc is odd;
769
+ * @param nr height
770
+ * @param nc width [nr + 1]
771
+ * @param rnd 0: all, 1: rm end of row 0 (& half of last row!)
772
+ * @parma half [(rnd === 1) || (nc % 2 === 1)] force/deny final half-row
773
+ * @param hexAry array in which to push the created Hexes [Array()<T>]
774
+ * @returns hexAry with the created Hexes pushed (row major)
658
775
  */
659
- makeDistrict(nh, district, mr, mc) {
660
- const mcp = Math.abs(mc % 2), mrp = Math.abs(mr % 2), dia = 2 * nh - 1;
661
- // irow-icol define topology of MetaHex composed of HexDistrict
662
- // TODO: generalize using this.topo to compute offsets!
663
- const irow = (mr, mc) => {
664
- let ir = mr * dia - nh * (mcp + 1) + 1;
665
- ir -= Math.floor((mc) / 2); // - half a row for each metaCol
666
- return ir;
667
- };
668
- const icol = (mr, mc, row) => {
669
- let np = Math.abs(nh % 2), rp = Math.abs(row % 2);
670
- let ic = Math.floor(mc * ((nh * 3 - 1) / 2));
671
- ic += (nh - 1); // from left edge to center
672
- ic -= Math.floor((mc + (2 - np)) / 4); // 4-metaCol means 2-rows, mean 1-col
673
- ic += Math.floor((mr - rp) / 2); // 2-metaRow means +1 col
674
- return ic;
675
- };
676
- const hexAry = [];
677
- hexAry['Mr'] = mr;
678
- hexAry['Mc'] = mc;
679
- const row0 = irow(mr, mc), col0 = icol(mr, mc, row0);
680
- hexAry.push(this.addHex(row0, col0, district)); // make centerHex of metaHex
681
- //console.groupCollapsed(`makelDistrict [mr: ${mr}, mc: ${mc}] hex0= ${hex.Aname}:${district}-${dcolor}`)
682
- //console.log(`.makeDistrict: [mr: ${mr}, mc: ${mc}] hex0= ${hex.Aname}`, hex)
683
- let rc = { row: row0, col: col0 };
684
- for (let ring = 1; ring < nh; ring++) {
685
- rc = this.ringWalk(ring, (rc, dir) => {
686
- // place 'ring' hexes along each axis-line:
687
- return this.newHexesOnLine(ring, rc, dir, district, hexAry);
688
- });
776
+ makeRect(nr, nc = nr + 1, rnd = 1, half = (rnd === 1) || (nc % 2 === 1), hexAry = []) {
777
+ const hexAryNR = [];
778
+ hexAryNR['Nr'] = nr;
779
+ hexAryNR['Nc'] = nc; // for debugger
780
+ const district = 0;
781
+ // nr = 9; nc = 11; rnd = 1; half = (rnd === 1) || (nc % 2 === 1);
782
+ const ncOdd = (nc % 2) === 0;
783
+ const c00 = (rnd === 0) ? 0 : 1;
784
+ const nc0 = (rnd === 0) ? 0 : nc - (ncOdd ? 1 : 2 * c00);
785
+ this.addLineOfHex(nc0, 0, c00, district, hexAry);
786
+ for (let row = 1; row < nr - 1; row++) {
787
+ this.addLineOfHex(nc, row, 0, district, hexAry);
689
788
  }
690
- //console.groupEnd()
691
- this.setDistrictColor(hexAry, district);
789
+ const cf0 = (rnd === 0) ? 0 : 2;
790
+ const ncf = nc - ((rnd === 0) ? 0 : 3);
791
+ const dc = (half) ? 2 : 1;
792
+ this.addLineOfHex(ncf, nr - 1, cf0, district, hexAry, dc);
793
+ this.setDistrictAndPaint(hexAry, district);
692
794
  return hexAry;
693
795
  }
694
- setDistrictColor(hexAry, district = 0) {
695
- this.district[district] = hexAry;
696
- if (hexAry[0] instanceof Hex2) {
697
- const hex2Ary = hexAry;
698
- const dcolor = district == 0 ? HexMap.distColor[0] : this.pickColor(hex2Ary);
699
- hex2Ary.forEach(hex => hex.setHexColor(dcolor)); // makeDistrict: dcolor=lightgrey
796
+ /**
797
+ * create horizontal row using hexAry.push(addHex(row, col++dc, district))
798
+ * @param maxc max col to use (esp when dc > 1)
799
+ * @param row
800
+ * @param col
801
+ * @param district
802
+ * @param hexAry
803
+ * @param dc delta to column [1]
804
+ */
805
+ addLineOfHex(maxc, row, col, district, hexAry, dc = 1) {
806
+ for (let i = 0; i < maxc; i += dc) {
807
+ hexAry.push(this.addHex(row, col + i, district));
700
808
  }
701
809
  }
702
810
  /**
@@ -709,50 +817,31 @@ export class HexMap extends Array {
709
817
  * @param n number of Hex locations to select
710
818
  * @param rc {row, col} of selected location
711
819
  * @param dir from rc, move by dir to next location
712
- * @param f do 'whatever'; must return the given RC [or other RC seed for nextRowCol()!]
713
- * @returns RC of n+1-th Hex on the line (where you typically change to next dir)
820
+ * @param f do 'whatever' based on RC
821
+ * @returns nextRowCol(rc, dir) from the last rc of the line.
714
822
  */
715
- forRCsOnLine(n, rc, dir, f) {
823
+ forRCsOnLine(n, rc, dir, f = (rc) => { }) {
716
824
  for (let i = 0; i < n; i++) {
717
- rc = this.nextRowCol(f(rc), dir);
825
+ f(rc);
826
+ rc = this.nextRowCol(rc, dir);
718
827
  }
719
828
  return rc;
720
829
  }
721
830
  /**
722
- * Used to create rings of new Hex: this.addHex(row, col, district)
723
- * @param n number of Hex to create
724
- * @param rc create first Hex in given RC location
725
- * @param dir after first Hex move dir for each next Hex
726
- * @param district supplied to addHex()
727
- * @param hexAry push created Hex(s) on this array
728
- * @returns RC of next Hex location on line (typically use next direction and continue...)
729
- */
730
- newHexesOnLine(n, rc, dir, district, hexAry) {
731
- let hex;
732
- return this.forRCsOnLine(n, rc, dir, (rc) => {
733
- hexAry.push(hex = this.addHex(rc.row, rc.col, district));
734
- return rc;
735
- });
736
- }
737
- /**
738
- * Apply f(rc, dir) to each of 'n' RCs on nth ring.
831
+ * Apply f(rc, dir) to each of 'n' lines of RCs on nth ring.
739
832
  * Step from centerHex by dirs[4], do a line for each dir in dirs.
740
833
  *
741
834
  * - if topoEW: step to W; make lines going NE, E, SE, SW, W, NW
742
835
  * - if topoNS: step to WS; make lines going N, EN, ES, S, WS, WN
743
- * @param n ring number
744
- * @param f (RC, dir) => void
836
+ * @param rc start of first line (heading dirs[0])
837
+ * @param n ring number; number of hexes per line
745
838
  * @param dirs [this.linkDirs] each topo dirs in [clockwise] order.
839
+ * @param f (RC, dir) => void
746
840
  * @return the *next* RC on the final line (so can easily spiral)
747
841
  */
748
- ringWalk(n, f, dirs = this.linkDirs) {
749
- const startHex = this.centerHex.nextHex(dirs[4], n);
750
- let rc = { row: startHex.row, col: startHex.col };
842
+ ringWalk(rc, n, dirs = this.linkDirs, f) {
751
843
  dirs.forEach(dir => {
752
- rc = this.forRCsOnLine(n, rc, dir, (rc) => {
753
- f(rc, dir);
754
- return rc;
755
- });
844
+ rc = this.forRCsOnLine(n, rc, dir, (rc) => f(rc, dir));
756
845
  });
757
846
  return rc;
758
847
  }