Skip to content

SWU Simulator SDKTyped TypeScript client for the swu-simulator engine

HTTP + WebSocket wire contracts generated straight from the Rust server, with runtime validation and a stateful session helper.

Quick Start

bash
pnpm add @my-swu/simulator-client
ts
import { createEngineClient } from '@my-swu/simulator-client'

const client = createEngineClient({
  baseUrl: 'http://127.0.0.1:4000',
})

const premierMainDeck = [
  45, 35, 100, 105, 110, 115, 120, 125, 130,
  135, 140, 145, 1228, 1230, 1232, 1243, 1244,
].flatMap(cardId => [cardId, cardId, cardId])

const host = await client.createMatch({
  seed: 7,
  format: 'premier',
  hostDeck: {
    leader: 46102,
    base: 308,
    cards: premierMainDeck,
  },
})

const connection = await client.connectMatch({
  matchId: host.matchId,
  seatToken: host.seatToken,
})

connection.on('snapshot', snapshot => {
  console.log('prompt:', snapshot.prompt)
})

connection.ready()

Next steps:

Released under the MIT License.