Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / canDeployAnyLeader

Function: canDeployAnyLeader() ​

canDeployAnyLeader(snapshot): boolean

Defined in: packages/ts-sdk/src/actionable.ts:83

Returns whether the snapshot exposes at least one legal leader deploy action.

Example:

ts
import { canDeployAnyLeader, createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// Public match fetch returns the latest snapshot projection.
const matchSnapshot = await simulatorClient.matches.get('match_123')

// Enable deploy controls only when the engine projected a legal deploy.
console.log(canDeployAnyLeader(matchSnapshot))

Parameters ​

snapshot ​

Example:

ts
import { canDeployAnyLeader, createSimulatorClient } from '@my-swu/simulator-client'

// Point this at the simulator HTTP origin for /health and /api routes.
const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

// Public match fetch returns the latest snapshot projection.
const matchSnapshot = await simulatorClient.matches.get('match_123')

// Enable deploy controls only when the engine projected a legal deploy.
console.log(canDeployAnyLeader(matchSnapshot))

GameState

Returns ​

boolean

Released under the MIT License.