import { describe, it, expect } from 'vitest'; import { TileType, isBlocking, isDestructible, blocksSight, getDestructionResult, isDestructibleByWalk } from '../terrain'; describe('Terrain', () => { describe('Tile Definitions', () => { it('should correctly identify blocking tiles', () => { expect(isBlocking(TileType.WALL)).toBe(true); expect(isBlocking(TileType.WALL_DECO)).toBe(true); expect(isBlocking(TileType.WATER)).toBe(true); expect(isBlocking(TileType.EMPTY)).toBe(false); expect(isBlocking(TileType.GRASS)).toBe(false); expect(isBlocking(TileType.EXIT)).toBe(false); }); it('should correctly identify destructible tiles', () => { expect(isDestructible(TileType.GRASS)).toBe(true); expect(isDestructible(TileType.DOOR_CLOSED)).toBe(true); expect(isDestructible(TileType.WALL)).toBe(false); expect(isDestructible(TileType.EMPTY)).toBe(false); }); it('should correctly identify tiles blocking sight', () => { expect(blocksSight(TileType.WALL)).toBe(true); expect(blocksSight(TileType.WALL_DECO)).toBe(true); expect(blocksSight(TileType.DOOR_CLOSED)).toBe(true); expect(blocksSight(TileType.GRASS)).toBe(true); // Grass blocks vision in this game logic expect(blocksSight(TileType.EMPTY)).toBe(false); expect(blocksSight(TileType.EXIT)).toBe(false); expect(blocksSight(TileType.GRASS_SAPLINGS)).toBe(false); }); it('should return correct destruction result', () => { expect(getDestructionResult(TileType.GRASS)).toBe(TileType.GRASS_SAPLINGS); expect(getDestructionResult(TileType.DOOR_CLOSED)).toBe(TileType.DOOR_OPEN); expect(getDestructionResult(TileType.DOOR_OPEN)).toBe(TileType.DOOR_CLOSED); expect(getDestructionResult(TileType.WALL)).toBeUndefined(); }); it('should correctly identify tiles destructible by walk', () => { expect(isDestructibleByWalk(TileType.GRASS)).toBe(true); expect(isDestructibleByWalk(TileType.DOOR_CLOSED)).toBe(true); expect(isDestructibleByWalk(TileType.DOOR_OPEN)).toBe(true); // Should be closable by walk expect(isDestructibleByWalk(TileType.WALL)).toBe(false); }); it('should handle unknown tile types gracefully', () => { const unknownTile = 999; expect(isBlocking(unknownTile)).toBe(false); expect(isDestructible(unknownTile)).toBe(false); expect(blocksSight(unknownTile)).toBe(false); expect(getDestructionResult(unknownTile)).toBeUndefined(); expect(isDestructibleByWalk(unknownTile)).toBe(false); }); }); });