Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / LimitedEventsResource

Interface: LimitedEventsResource

Defined in: packages/ts-sdk/src/resources/limited-events.ts:154

Limited Event resource API methods.

Use this resource for Draft and Sealed pods before creating a match from the completed pool.

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',
}) // Draft creation returns event access for the first seat. const
draftEventAccess
= await
simulatorClient
.
limitedEvents
.
create
({
kind
: 'draft',
setCode
: 'SOR',
playerCount
: 4,
}) // Passing access includes viewer-private state in the snapshot. const
limitedEventSnapshot
= await
simulatorClient
.
limitedEvents
.
get
(
draftEventAccess
)
console
.
log
(
limitedEventSnapshot
.
phase
)

Example

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

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

const draftEventAccess = await simulatorClient.limitedEvents.create({
  kind: 'draft',
  setCode: 'SOR',
  playerCount: 4,
})

console.log(draftEventAccess.snapshot.phase.kind)

See

https://simulator-sdk.my-swu.com/guide/limited-events

Methods

applyCommand()

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',
}) // Commands mutate the current viewer's draft or sealed event state. const
draftSeatAccess
= {
eventId
: 'event_123',
seatToken
: 'limited_token_123' }
const
limitedEventSnapshot
= await
simulatorClient
.
limitedEvents
.
applyCommand
(
draftSeatAccess
,
{
type
: 'readyForNextDraft' },
)

applyCommand(access, command): Promise<LimitedEventSnapshot>

Defined in: packages/ts-sdk/src/resources/limited-events.ts:228

Applies one seat command to a limited event.

Parameters

access

LimitedEventAccessInput

command

{[k: string]: unknown; cardId: number; type: "pickLeader"; } | {[k: string]: unknown; cardId: number; type: "pickCard"; } | {[k: string]: unknown; type: "readyForNextDraft"; }

Type Literal

{[k: string]: unknown; cardId: number; type: "pickLeader"; }

cardId

number

Picked leader card id.

type

"pickLeader"


Type Literal

{[k: string]: unknown; cardId: number; type: "pickCard"; }

cardId

number

Picked card id.

type

"pickCard"

Returns

Promise<LimitedEventSnapshot>

Example

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const draftSeatAccess = {
  eventId: 'event_123',
  seatToken: 'limited_token_123',
}

const limitedEventSnapshot =
  await simulatorClient.limitedEvents.applyCommand(
    draftSeatAccess,
    { type: 'readyForNextDraft' },
  )

console.log(limitedEventSnapshot.phase.kind)

See

https://simulator-sdk.my-swu.com/guide/limited-events#draft-picks


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',
}) // Creation returns private access for the event's first seat. const
draftEventAccess
= await
simulatorClient
.
limitedEvents
.
create
({
kind
: 'draft',
setCode
: 'SOR',
playerCount
: 4,
})

create(request): Promise<LimitedEventAccessResponse>

Defined in: packages/ts-sdk/src/resources/limited-events.ts:177

Creates one generated Draft or Sealed event.

Parameters

request

CreateLimitedEventRequest

Returns

Promise<LimitedEventAccessResponse>

Example

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

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

const draftEventAccess = await simulatorClient.limitedEvents.create({
  kind: 'draft',
  setCode: 'SOR',
  playerCount: 4,
})

console.log(draftEventAccess.eventId)

See

https://simulator-sdk.my-swu.com/guide/limited-events#creating-events


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',
}) // Seat access includes viewer-private pack and pool state. const
draftSeatAccess
= {
eventId
: 'event_123',
seatToken
: 'limited_token_123' }
const
limitedEventSnapshot
= await
simulatorClient
.
limitedEvents
.
get
(
draftSeatAccess
)

get(event): Promise<LimitedEventSnapshot>

Defined in: packages/ts-sdk/src/resources/limited-events.ts:201

Fetches one limited event, optionally with viewer-private state.

Parameters

event

string | LimitedEventReference | LimitedEventAccessInput

Returns

Promise<LimitedEventSnapshot>

Example

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

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})
const draftSeatAccess = {
  eventId: 'event_123',
  seatToken: 'limited_token_123',
}

const limitedEventSnapshot =
  await simulatorClient.limitedEvents.get(draftSeatAccess)

console.log(limitedEventSnapshot.viewer?.activePack.length)

See

https://simulator-sdk.my-swu.com/guide/limited-events#reading-events


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',
}) // Joining fills the next open pod seat. const
draftEvent
= {
eventId
: 'event_123' }
const
draftSeatAccess
= await
simulatorClient
.
limitedEvents
.
join
(
draftEvent
)

join(event, request?): Promise<LimitedEventAccessResponse>

Defined in: packages/ts-sdk/src/resources/limited-events.ts:249

Joins one limited event.

Parameters

event

LimitedEventReference

request?

JoinLimitedEventRequest

Returns

Promise<LimitedEventAccessResponse>

Example

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

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

const draftSeatAccess =
  await simulatorClient.limitedEvents.join(draftEventReference)

console.log(draftSeatAccess.seatIndex)

See

https://simulator-sdk.my-swu.com/guide/limited-events#joining-events

Released under the MIT License.