UNPKG

asciitorium

Version:
42 lines (41 loc) 1.33 kB
import { Component, ComponentProps } from '../core/Component.js'; import type { State } from '../core/State.js'; import { type MapAsset, type LegendEntry } from '../core/AssetManager.js'; export type Direction = 'north' | 'south' | 'east' | 'west'; export interface Player { x: number; y: number; direction: Direction; } export interface MapData { map: string[]; } export interface MapViewOptions extends Omit<ComponentProps, 'children'> { mapAsset: State<MapAsset | null>; player: State<Player>; fogOfWar?: boolean | State<boolean>; exploredTiles?: Set<string> | State<Set<string>>; fogCharacter?: string; } export declare class MapView extends Component { focusable: boolean; private mapAssetState; private playerState; private fogOfWarSource; private exploredTilesSource?; private fogCharacter; constructor(options: MapViewOptions); get mapAsset(): MapAsset | null; get mapData(): string[]; get legend(): Record<string, LegendEntry>; get player(): Player; get exploredTiles(): Set<string>; get fogOfWar(): boolean; private isPositionVisible; private isPositionExplored; private addExploredPosition; private getVisiblePositions; draw(): string[][]; private getDirectionChar; handleEvent(event: string): boolean; }