import { createTileCoordinates , TileCoordinates } from "@creature-chess/models" ; import { BoardState } from "@shoki/board" ; const isInsideGrid = ( { width , height } ) => ( position ) => { const { x , y } = position ; return x >= 0 && y >= 0 && x < width && y < height ; } ; export const getTargetAttackPositions = ( board , { x : positionX , y : positionY } , range = 1 ) => { const positions = [ ] ; for ( let x = positionX - range ; x <= positionX + range ; x ++ ) { if ( x === positionX ) { continue ; } positions . push ( createTileCoordinates ( x , positionY ) ) ; } for ( let y = positionY - range ; y <= positionY + range ; y ++ ) { if ( y === positionY ) { continue ; } positions . push ( createTileCoordinates ( positionX , y ) ) ; } return positions . filter ( isInsideGrid ( board . size ) ) ; } ;