Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / MatchAccess

Type Alias: MatchAccess ​

MatchAccess = MatchAccessResponse

Defined in: packages/ts-sdk/src/resources/match-types.ts:59

Access token and private snapshot returned after creating or joining a match.

Keep seatToken private. It authorizes one player seat for socket and format event calls.

Example:

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

// Use card ids; the server validates deck legality.
const premierHostDeck = {
  leader: 46102, // Leia Organa - Someone Who Loves You
  leaders: [], // Twin Suns only; Premier uses the single `leader` above.
  base: 308, // Echo Base
  cards: Array.from({ length: 50 }, () => 45), // Alliance X-Wing
  sideboard: [],
}

const matchAccess = await simulatorClient.matches.create({
  format: 'premier',
  // Twin Suns supports 2-4 players; every other format is exactly 2.
  playerCount: 2,
  hostName: 'Host',
  hostAuthenticated: false,
  historyIdentities: [],
  // One entry per AI-controlled seat; empty means a human opponent joins.
  aiOpponents: [],
  hostDeck: premierHostDeck,
})

console.log(matchAccess)

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const premierHostDeck = {
  leader: 46102,
  leaders: [],
  base: 308,
  cards: Array.from({ length: 50 }, () => 45),
  sideboard: [],
}

const hostAccess: MatchAccess = await simulatorClient.matches.create({
  format: 'premier',
  playerCount: 2,
  hostDeck: premierHostDeck,
  hostName: 'Host',
  hostAuthenticated: false,
  historyIdentities: [],
  aiOpponents: [],
})
console.log(hostAccess.matchId)

See ​

https://simulator-sdk.my-swu.com/guide/match-lifecycle

Released under the MIT License.