export const GroundType = Object.freeze({ grass: 1, wood: 2 }); export const BlockType = Object.freeze({ stoneWall: 1, torch: 2 }); export const GROUND_DEFINITIONS = Object.freeze({ [GroundType.grass]: Object.freeze({ id: GroundType.grass, key: "grass", displayName: "Grass", sprite: "ground-grass" }), [GroundType.wood]: Object.freeze({ id: GroundType.wood, key: "wood", displayName: "Wood", sprite: "ground-wood" }) }); export const BLOCK_DEFINITIONS = Object.freeze({ [BlockType.stoneWall]: Object.freeze({ id: BlockType.stoneWall, key: "stone-wall", displayName: "Stone wall", sprite: "block-stone-wall", passable: false, lightRangeTiles: 0 }), [BlockType.torch]: Object.freeze({ id: BlockType.torch, key: "torch", displayName: "Torch", sprite: "block-torch", passable: true, lightRangeTiles: 8 }) }); export function groundDefinition (typeId) { return GROUND_DEFINITIONS[typeId] ?? null; } export function blockDefinition (typeId) { return BLOCK_DEFINITIONS[typeId] ?? null; } export function isBlockPassable (typeId) { if (typeId == null) { return true; } const def = blockDefinition(typeId); return def ? def.passable : false; } export function blockLightRange (typeId) { const def = blockDefinition(typeId); return def ? def.lightRangeTiles : 0; }