import { ExtendedCharacter } from './types' import ZoneManager from '../managers/zoneManager' export class MovementValidator { public async isValidMove(character: ExtendedCharacter, position: { x: number; y: number }): Promise { const grid = await ZoneManager.getGrid(character.zoneId) if (!grid?.length) return false return !this.isObstacle(position, grid) } private isObstacle({ x, y }: { x: number; y: number }, grid: number[][]): boolean { const gridX = Math.floor(x) const gridY = Math.floor(y) return grid[gridY]?.[gridX] === 1 || grid[gridY]?.[Math.ceil(x)] === 1 || grid[Math.ceil(y)]?.[gridX] === 1 || grid[Math.ceil(y)]?.[Math.ceil(x)] === 1 } }