Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / getDeployableLeaderIndices

Function: getDeployableLeaderIndices() ​

getDeployableLeaderIndices(snapshot): number[]

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

Returns unique leader slot indices that have at least one legal deploy action.

Example:

ts
import { createSimulatorClient, getDeployableLeaderIndices } 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',
})

const matchSnapshot = await simulatorClient.matches.get('match_123')

// Twin Suns seats own two leader slots, so deploys are indexed.
console.log(getDeployableLeaderIndices(matchSnapshot))

Parameters ​

snapshot ​

Example:

ts
import { createSimulatorClient, getDeployableLeaderIndices } 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',
})

const matchSnapshot = await simulatorClient.matches.get('match_123')

// Twin Suns seats own two leader slots, so deploys are indexed.
console.log(getDeployableLeaderIndices(matchSnapshot))

GameState

Returns ​

number[]

Released under the MIT License.