UNPKG

@caveworld/honeycomb-grid

Version:
60 lines (59 loc) 2.33 kB
import { CompassDirection } from '../compass'; import { Hex, HexCoordinates, Point } from '../hex'; import { GridAsJSON, Traverser } from './types'; export declare class Grid<T extends Hex> implements Iterable<T> { #private; static fromIterable<T extends Hex>(hexes: Iterable<T>): Grid<T>; static fromJSON<T extends Hex>({ hexSettings, coordinates }: GridAsJSON<T>): Grid<Hex>; readonly [Symbol.toStringTag] = "Grid"; get size(): number; [Symbol.iterator](): IterableIterator<T>; readonly hexPrototype: T; constructor(hexPrototype: T); constructor(hexPrototype: T, traversers: Traverser<T> | Traverser<T>[]); constructor(hexPrototype: T, hexes: Iterable<T>); constructor(grid: Grid<T>); createHex(coordinates?: HexCoordinates): T; getHex(coordinates: HexCoordinates): T | undefined; hasHex(hex: T): boolean; setHexes(hexes: Iterable<T>): this; filter(predicate: (hex: T) => boolean): Grid<T>; map(fn: (hex: T) => T): Grid<T>; traverse(traversers: Traverser<T> | Traverser<T>[], options?: { bail?: boolean; }): Grid<T>; traverse(hexes: Iterable<T>, options?: { bail?: boolean; }): Grid<T>; traverse(grid: Grid<T>, options?: { bail?: boolean; }): Grid<T>; traverse(input: Traverser<T> | Traverser<T>[] | Iterable<T> | Grid<T>, options?: { bail?: boolean; }): Grid<T>; forEach(fn: (hex: T) => void): this; reduce(reducer: (previousHex: T, currentHex: T) => T): T; reduce(reducer: (previousHex: T, currentHex: T) => T, initialValue: T): T; reduce<R>(reducer: (result: R, hex: T) => R, initialValue: R): R; toArray(): T[]; toJSON(): GridAsJSON<T>; toString(): string; pointToHex(point: Point, options?: { allowOutside: true; }): T; pointToHex(point: Point, options: { allowOutside: false; }): T | null; distance(from: HexCoordinates, to: HexCoordinates, options?: { allowOutside: true; }): number; distance(from: HexCoordinates, to: HexCoordinates, options: { allowOutside: false; }): number | null; neighborOf(hex: T, direction: CompassDirection, options?: { allowOutside: true; }): T; neighborOf(hex: T, direction: CompassDirection, options: { allowOutside: false; }): T | null; }