import { startingTactics, addTacticalUnit, tacticalMoves, moveTacticalUnit } from '@datamoc/mw_games/board';const state = startingTactics(6, 6, 'square');addTacticalUnit(state, { id: 'ranger', owner: 'blue', x: 0, y: 0, hp: 10, maxHp: 10, actions: 2 });addTacticalUnit(state, { id: 'raider', owner: 'red', x: 3, y: 0, hp: 10, maxHp: 10, actions: 2 });moveTacticalUnit(state, tacticalMoves(state, 'ranger')[0]);console.log(state.units.find((unit) => unit.id === 'ranger')); // { ..., x: 1, y: 0, actions: 1 } Copy
import { startingTactics, addTacticalUnit, tacticalMoves, moveTacticalUnit } from '@datamoc/mw_games/board';const state = startingTactics(6, 6, 'square');addTacticalUnit(state, { id: 'ranger', owner: 'blue', x: 0, y: 0, hp: 10, maxHp: 10, actions: 2 });addTacticalUnit(state, { id: 'raider', owner: 'red', x: 3, y: 0, hp: 10, maxHp: 10, actions: 2 });moveTacticalUnit(state, tacticalMoves(state, 'ranger')[0]);console.log(state.units.find((unit) => unit.id === 'ranger')); // { ..., x: 1, y: 0, actions: 1 }
Example