Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / targetGroupsOf

Function: targetGroupsOf() ​

targetGroupsOf(action): TargetSelectionGroup[]

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

Reads the ordered target-selection groups of any targeting action.

Hides the targetPlan / targetGroups split so a consumer that renders pending abilities and playable actions through one code path does not need its own accessor.

Example:

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

// Pending abilities nest their groups under `targetPlan` while play actions
// keep them inline; this reads either shape.
const [pendingAbility] = matchSnapshot.pendingAbilities

console.log(targetGroupsOf(pendingAbility))

Parameters ​

action ​

Example:

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

// Pending abilities nest their groups under `targetPlan` while play actions
// keep them inline; this reads either shape.
const [pendingAbility] = matchSnapshot.pendingAbilities

console.log(targetGroupsOf(pendingAbility))

TargetingActionView | null | undefined

Projected action, or a nullish value while none is selected.

Returns ​

TargetSelectionGroup[]

The action's groups in engine order; empty when there is no action.

Released under the MIT License.