Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / MatchesResource

Interface: MatchesResource ​

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

Match resource API methods.

Use this resource for HTTP-only match lifecycle calls. For a stateful socket wrapper, create a MatchSession through client.session.

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: [],
}

// Creating a match returns private host seat access.

const hostAccess = 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,
})

const matchSnapshot = await simulatorClient.matches.get(hostAccess)

console.log(matchSnapshot.phase)

Example ​

ts
import { createSimulatorClient } 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 = await simulatorClient.matches.create({
  format: 'premier',
  playerCount: 2,
  hostDeck: premierHostDeck,
  hostName: 'Host',
  hostAuthenticated: false,
  historyIdentities: [],
  aiOpponents: [],
})

console.log(hostAccess.matchId)

See ​

Methods ​

abandon() ​

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

const matchesResource = simulatorClient.matches

const { abandon } = matchesResource

console.log(abandon)

abandon(access, options?): Promise<void>

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

Permanently abandons a host-owned solo AI match.

Started matches record a host concession before the server removes the runtime. Ordinary socket disconnects remain resumable and do not call this endpoint.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<void>


applyFormatEvent() ​

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

// Format events require private access for the acting seat.
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const nextGameSnapshot = await simulatorClient.matches.applyFormatEvent(
  hostAccess,
  { type: 'readyNextGame' },
)

applyFormatEvent(access, command, options?): Promise<GameState>

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

Applies one out-of-game format command such as sideboarding or Trilogy selection.

Parameters ​

access ​

MatchAccessInput

command ​

FormatEventCommand

options? ​

SimulatorRequestOptions

Returns ​

Promise<GameState>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }

const nextGameSnapshot = await simulatorClient.matches.applyFormatEvent(
  hostAccess,
  { type: 'readyNextGame', ready: true },
)

console.log(nextGameSnapshot.phase)

See ​

https://simulator-sdk.my-swu.com/guide/driving-gameplay#out-of-game-commands


create() ​

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: [],
}

// Host access includes the private seat token for seat one.

const hostAccess = 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,
})

create(request, options?): Promise<MatchAccessResponse>

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

Creates one match and returns host access.

Parameters ​

request ​

CreateMatchRequest

options? ​

SimulatorRequestOptions

Returns ​

Promise<MatchAccessResponse>

Example ​

ts
import { createSimulatorClient } 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 = await simulatorClient.matches.create({
  format: 'premier',
  playerCount: 2,
  hostDeck: premierHostDeck,
  hostName: 'Host',
  hostAuthenticated: false,
  historyIdentities: [],
  aiOpponents: [],
})

console.log(hostAccess.seat)

See ​

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


createPlaygroundShare() ​

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

const matchesResource = simulatorClient.matches

const { createPlaygroundShare } = matchesResource

console.log(createPlaygroundShare)

createPlaygroundShare(access, options?): Promise<CreatePlaygroundShareResponse>

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

Creates one 30-day URL share capability for a Playground.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<CreatePlaygroundShareResponse>


exportPlayground() ​

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

const matchesResource = simulatorClient.matches

const { exportPlayground } = matchesResource

console.log(exportPlayground)

exportPlayground(access, options?): Promise<PlaygroundExportPayload>

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

Creates a portable Playground file with a dedicated restore capability.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<PlaygroundExportPayload>


get() ​

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

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

get(match, options?): Promise<GameState>

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

Fetches the public match projection.

Parameters ​

match ​

string | MatchReference

options? ​

SimulatorRequestOptions

Returns ​

Promise<GameState>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const publicMatchSnapshot = await simulatorClient.matches.get('match_123')
console.log(publicMatchSnapshot.phase)

See ​

https://simulator-sdk.my-swu.com/guide/http-client


join() ​

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

// Seat two submits a separate legal deck when joining the match.
const premierGuestDeck = {
  leader: 46107, // Darth Vader - Unstoppable
  leaders: [],
  base: 309, // Tarkintown
  cards: Array.from({ length: 50 }, () => 35), // TIE/ln Fighter
  sideboard: [],
}

// Only matchId is needed to join; the response returns seat two access.
const matchReference = { matchId: 'match_123' }

const guestAccess = await simulatorClient.matches.join(matchReference, {
  deck: premierGuestDeck,
  name: 'Guest',
  authenticated: false,
  historyIdentities: [],
})

join(match, request, options?): Promise<MatchAccessResponse>

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

Joins an existing match as the next open seat.

Parameters ​

match ​

MatchReference

request ​

JoinMatchRequest

options? ​

SimulatorRequestOptions

Returns ​

Promise<MatchAccessResponse>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const premierGuestDeck = {
  leader: 46107,
  leaders: [],
  base: 309,
  cards: Array.from({ length: 50 }, () => 35),
  sideboard: [],
}

const guestAccess = await simulatorClient.matches.join(
  { matchId: 'match_123' },
  {
    deck: premierGuestDeck,
    name: 'Guest',
    authenticated: false,
    historyIdentities: [],
  },
)

console.log(guestAccess.seat)

See ​

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


leave() ​

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

const matchesResource = simulatorClient.matches

const { leave } = matchesResource

console.log(leave)

leave(access, options?): Promise<void>

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

Records an intentional player departure without conceding the match.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<void>


listActiveAi() ​

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

const matchesResource = simulatorClient.matches

const { listActiveAi } = matchesResource

console.log(listActiveAi)

listActiveAi(request, options?): Promise<ListActiveAiMatchesResponse>

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

Lists caller-owned resumable AI matches retaining a blocked quota slot.

Parameters ​

request ​

ListActiveAiMatchesRequest

options? ​

SimulatorRequestOptions

Returns ​

Promise<ListActiveAiMatchesResponse>


recoverAccess() ​

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

const matchesResource = simulatorClient.matches

const { recoverAccess } = matchesResource

console.log(recoverAccess)

recoverAccess(match, request, options?): Promise<MatchAccessRecoveryResponse>

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

Recovers current host access for an owned remote Solo-versus-AI match.

unavailable intentionally hides whether the match is absent, no longer resumable, or not owned by the supplied history identities.

Parameters ​

match ​

MatchReference

request ​

MatchAccessRecoveryRequest

options? ​

SimulatorRequestOptions

Returns ​

Promise<MatchAccessRecoveryResponse>


refreshAccess() ​

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

const matchesResource = simulatorClient.matches

const { refreshAccess } = matchesResource

console.log(refreshAccess)

refreshAccess(access, options?): Promise<MatchAccessResponse>

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

Refreshes private seat access after validating its existing seat token.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<MatchAccessResponse>


rematch() ​

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

const matchesResource = simulatorClient.matches

const { rematch } = matchesResource

console.log(rematch)

rematch(access, accept, options?): Promise<RematchMatchResponse>

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

Offers, accepts, or declines a rematch against the same opponent.

Both seats call this. The first one gets status: 'waiting'; once every seat has asked, series.rematchReady flips on the match snapshot and each seat calls again to claim its own status: 'ready' access to the new match. Repeat claims return the same access, so a reconnecting client can safely ask again. Passing accept: false declines, and withdraws this seat's own offer.

Parameters ​

access ​

MatchAccessInput

accept ​

boolean

options? ​

SimulatorRequestOptions

Returns ​

Promise<RematchMatchResponse>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }

const rematch = await simulatorClient.matches.rematch(hostAccess, true)
if (rematch.status === 'ready') {
  console.log(rematch.access.matchId)
}

See ​

https://simulator-sdk.my-swu.com/guide/driving-gameplay


respondUndo() ​

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

const matchesResource = simulatorClient.matches

const { respondUndo } = matchesResource

console.log(respondUndo)

respondUndo(access, approve, options?): Promise<GameState>

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

Answers the pending undo approval request for one match.

Approving as the last outstanding seat applies the undo; declining cancels it. A response sent by the original requester withdraws the request regardless of approve.

Parameters ​

access ​

MatchAccessInput

approve ​

boolean

options? ​

SimulatorRequestOptions

Returns ​

Promise<GameState>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }

const undoMatchSnapshot = await simulatorClient.matches.respondUndo(hostAccess, true)
console.log(undoMatchSnapshot.pendingUndo)

See ​

https://simulator-sdk.my-swu.com/guide/driving-gameplay


restore() ​

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

const matchesResource = simulatorClient.matches

const { restore } = matchesResource

console.log(restore)

restore(source, save, options?): Promise<RestoreMatchSaveResponse>

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

Restores a previously saved match into a fresh live session.

Returns the new match id and per-seat access tokens — the original tokens are not preserved, so SDK consumers should treat the returned session as freshly created.

Parameters ​

source ​

MatchAccessInput

save ​

MatchSavePayload

options? ​

SimulatorRequestOptions

Returns ​

Promise<RestoreMatchSaveResponse>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const persisted = JSON.parse(localStorage.getItem('swu-save') ?? '{}') as MatchSavePayload
const restored = await simulatorClient.matches.restore(hostAccess, persisted)
console.log(restored.matchId, restored.accesses.length)

See ​

https://simulator-sdk.my-swu.com/guide/save-restore


restorePlaygroundExport() ​

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

const matchesResource = simulatorClient.matches

const { restorePlaygroundExport } = matchesResource

console.log(restorePlaygroundExport)

restorePlaygroundExport(payload, options?): Promise<RestoreMatchSaveResponse>

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

Restores a portable Playground file without source-match credentials.

Parameters ​

payload ​

PlaygroundExportPayload

options? ​

SimulatorRequestOptions

Returns ​

Promise<RestoreMatchSaveResponse>


restorePlaygroundShare() ​

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

const matchesResource = simulatorClient.matches

const { restorePlaygroundShare } = matchesResource

console.log(restorePlaygroundShare)

restorePlaygroundShare(shareToken, options?): Promise<RestoreMatchSaveResponse>

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

Restores one unexpired Playground URL share into a fresh match.

Parameters ​

shareToken ​

string

options? ​

SimulatorRequestOptions

Returns ​

Promise<RestoreMatchSaveResponse>


save() ​

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

const matchesResource = simulatorClient.matches

const { save } = matchesResource

console.log(save)

save(access, options?): Promise<MatchSavePayload>

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

Captures a full state snapshot of an authorized, finished match.

The returned object contains the engine's MatchState plus the per-seat decks needed to rebuild the catalog at restore time. SDK consumers persist it however they like — clipboard, file download, IndexedDB, server upload — the simulator does not store it.

Unlike the older debug replay snapshot, this works for AI-opponent matches and does not need to replay any commands at restore time.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<MatchSavePayload>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }

const save = await simulatorClient.matches.save(hostAccess)
localStorage.setItem('swu-save', JSON.stringify(save))

See ​

https://simulator-sdk.my-swu.com/guide/save-restore


setAiPaused() ​

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

// Pause and resume affect an attached AI opponent, not gameplay state.
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const aiStatusPayload = await simulatorClient.matches.setAiPaused(hostAccess, true)

setAiPaused(access, paused, options?): Promise<AiStatusPayload>

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

Pauses or resumes an attached AI opponent for one match.

The response reports each AI-controlled seat and its pause state. Non-AI matches accept the request and return an empty seats list.

Parameters ​

access ​

MatchAccessInput

paused ​

boolean

options? ​

SimulatorRequestOptions

Returns ​

Promise<AiStatusPayload>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }

const status = await simulatorClient.matches.setAiPaused(hostAccess, true)
console.log(status.seats.every(seat => seat.paused))

See ​

https://simulator-sdk.my-swu.com/guide/driving-gameplay


setPlaygroundAiSeat() ​

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

const matchesResource = simulatorClient.matches

const { setPlaygroundAiSeat } = matchesResource

console.log(setPlaygroundAiSeat)

setPlaygroundAiSeat(access, request, options?): Promise<AiStatusPayload>

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

Attaches, updates, pauses, or removes one AI controller in a Playground.

Parameters ​

access ​

MatchAccessInput

request ​

Omit<SetPlaygroundAiSeatRequest, "seatToken">

options? ​

SimulatorRequestOptions

Returns ​

Promise<AiStatusPayload>


spectate() ​

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

const matchesResource = simulatorClient.matches

const { spectate } = matchesResource

console.log(spectate)

spectate(match, request, options?): Promise<MatchSpectatorAccessResponse>

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

Joins an existing match as a read-only spectator.

Parameters ​

match ​

MatchReference

request ​

SpectateMatchRequest

options? ​

SimulatorRequestOptions

Returns ​

Promise<MatchSpectatorAccessResponse>


submitDeck() ​

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

const matchesResource = simulatorClient.matches

const { submitDeck } = matchesResource

console.log(submitDeck)

submitDeck(access, request, options?): Promise<GameState>

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

Submits (or replaces) the deck of a joined seat while the match is still gathering players.

Pairs with a deck-less join (omit deck in the join request) — the seat reserves its slot first and registers the deck here. The seat cannot mark itself ready until a deck has been submitted, and the deck locks in once the seat is ready.

Parameters ​

access ​

MatchAccessInput

request ​

Omit<SubmitMatchDeckRequest, "seatToken">

options? ​

SimulatorRequestOptions

Returns ​

Promise<GameState>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const guestAccess = await simulatorClient.matches.join({ matchId: 'match_123' }, {
  name: 'Guest',
  authenticated: false,
  historyIdentities: [],
})
const premierGuestDeck = {
  leader: 46107,
  leaders: [],
  base: 309,
  cards: Array.from({ length: 50 }, () => 35),
  sideboard: [],
}

const guestMatchSnapshot = await simulatorClient.matches.submitDeck(guestAccess, {
  deck: premierGuestDeck,
})
console.log(guestMatchSnapshot.players[1]?.deckSubmitted)

See ​

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


undo() ​

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

// Undo requires any valid private seat access for the match.
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }
const restoredMatchSnapshot = await simulatorClient.matches.undo(hostAccess)

undo(access, options?): Promise<GameState>

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

Rolls back the latest accepted player action for one match.

The returned snapshot is the authoritative private view for the supplied seat after rollback.

Parameters ​

access ​

MatchAccessInput

options? ​

SimulatorRequestOptions

Returns ​

Promise<GameState>

Example ​

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const hostAccess = { matchId: 'match_123', seatToken: 'seat_token_123' }

const restoredMatchSnapshot = await simulatorClient.matches.undo(hostAccess)
console.log(restoredMatchSnapshot.phase)

See ​

https://simulator-sdk.my-swu.com/guide/driving-gameplay

Released under the MIT License.