mwg API
    Preparing search index...

    Function canPlaceSkirmishUnit

    • whether a unit could be placed at (x, y) right now - on the map, passable, and unoccupied

      Parameters

      Returns boolean

      import { startingSkirmish, addSkirmishUnit, canPlaceSkirmishUnit } from '@datamoc/mw_games/board';

      const state = startingSkirmish(6, 6, { plain: { moveCost: 1, defense: 0 } });
      addSkirmishUnit(state, { id: 'axeman', owner: 'blue', x: 0, y: 0, hp: 10, maxHp: 10, moves: 4, attack: 4, hitChance: 0.7 });

      console.log(canPlaceSkirmishUnit(state, 1, 0)); // true
      console.log(canPlaceSkirmishUnit(state, 0, 0)); // false - axeman is already there