Skip to content

SWU Simulator SDKTypeScript client for the simulator engine

Namespaced HTTP resources, ergonomic match sessions, and generated protocol types from the Rust server contract.

Quick Start ​

bash
pnpm add @my-swu/simulator-client
ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // Use card ids; see /guide/card-ids for what each number means. 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
hostAccess
= await
simulatorClient
.
matches
.
create
({
// Fixed seed keeps this quick start reproducible.
seed
: '7',
format
: 'premier',
playerCount
: 2,
hostDeck
:
premierHostDeck
,
hostName
: 'Host',
hostAuthenticated
: false,
historyIdentities
: [],
aiOpponents
: [],
}) // Session state keeps private access out of renderable state. const
matchSession
=
simulatorClient
.
session
.
create
(
hostAccess
)
await
matchSession
.
connect
()
matchSession
.
on
('snapshot',
matchSnapshot
=> {
// Snapshots are the UI source of truth.
console
.
log
('prompt:',
matchSnapshot
.
prompt
)
})
matchSession
.
ready
()

Next steps:

Released under the MIT License.