@tamb/gamegrid
    Preparing search index...

    Interface IGameGrid

    Public contract implemented by GameGrid.

    For DOM events emitted by the grid (CustomEvents), see IGameGridEventDetail and gridEventsEnum.

    interface IGameGrid {
        options: IOptions;
        refs: IRefsObject;
        destroy(): void;
        getActiveCell(): ICell;
        getAllCellsByType(type: string): ICell[];
        getCell(coords: number[] | readonly [number, number]): ICell;
        getMatrix(): ICell[][];
        getOptions(): IOptions;
        getPreviousCell(): ICell;
        getState(): IState;
        moveDown(): void;
        moveLeft(): void;
        moveRight(): void;
        moveUp(): void;
        refresh(): void;
        render(container: HTMLElement): void;
        setActiveCell(x: number, y: number, direction?: string): void;
        setMatrix(matrix: ICell[][]): void;
        setOptions(newOptions: IOptions): void;
        setStateSync(obj: StatePatch): void;
    }

    Implemented by

    Index

    Properties

    options: IOptions

    Runtime toggles: input, collisions, middleware, callbacks, styling. Merged from ctor defaults and GameGrid.setOptions.

    After GameGrid.render, hydrated rows/cells and container. Headless grids mirror cells onto the logical matrix until mount.

    Methods

    • Detach listeners when rendered and clear injected structure; resets rendered in state.

      Returns void

      Idempotent-friendly: always dispatches gridEventsEnum.DESTROYED whether or not DOM was present.

    • Logical cell from GameGrid.getMatrix: matrix[coords[1]][coords[0]] — raw matrix lookup (bounds unchecked).

      Parameters

      • coords: number[] | readonly [number, number]

        [x, y].

      Returns ICell

    • Logical matrix backing the grid (matrix[row][column]matrix[y][x]).

      Returns ICell[][]

    • Mount markup into container, wire keyboard/pointer handlers, activate initial cell.

      Parameters

      • container: HTMLElement

      Returns void

      Clears/rebuilds refs for this mount. Prefer GameGrid.refresh after the first paint when rebuilding from the same host. Dispatches gridEventsEnum.RENDERED once the container is patched and listeners attach.

    • Apply partial state with MiddlewareFn pre (mutate patch) → merge → post.

      Parameters

      Returns void

      Middleware runs around the merge inside this call; does not emit grid CustomEvents.