Shops
phantom.aj.shopsThings you own
Shops: catalogues, buying, selling, the shop window.
Scripts and plugins
A script has all of it, as phantom.aj.shops, and so does a plugin, from ctx.phantom(): the SDK runs in the plugin's own frame. Each call is marked with what it needs: game:read for what the area knows and hears, which "game": "read" in the manifest grants, and game:act for doing things in it as the player, which needs "game": "act" (see Permissions).
Overview
| Member | What it does | Plugins |
|---|---|---|
buy() | Buys a piece of clothing, as the shop's buy button does (ItemXtCommManager.requestItemBuy), and resolves once the server has sold it. | game:act |
buyBundle() | Buys the bundle shop's whole bundle for diamonds (requestBuyDiamondBundle), resolving with the diamonds left. | game:act |
close() | Closes the shop window (closeWorldShop), resolving once it is gone; nothing when none is. | game:act |
current() | The shop window open now and what is picked in it, or null when none is. | game:read |
definition() | A piece of clothing's definition (ItemXtCommManager.getItemDef), or null for none. | game:read |
definitions() | Every clothing definition the client has loaded, read a page at a time; none before. | game:read |
definitionsReady() | Whether the client has loaded its clothing definitions (itemDefsHaveLoaded). | game:read |
denItemDefinition() | A den item's definition (DenXtCommManager.getDenItemDef), or null for none. | game:read |
denOffering() | What a den item shop offers, with each item's den item definition. | game:act |
forSale() | What a shop offers that is being sold now, by the server's clock. | game:act |
isAvailable() | Whether something is being sold now, judged by the client against the server's clock (Utility.isAvailable). | game:read |
isOpen() | Whether a shop window is open (ShopManager.isWorldShopOpen). | game:read |
item() | An item at a glance: name, price, rarity, whether it is sold now, and its picture. | game:act |
items() | Many items at a glance, in the order asked, null for an id with no definition. | game:read |
knownShops() | Every list the client knows of a kind a shop is made of, by id. | game:read |
limits() | How much the player may hold, as the client works it out for them now. | game:read |
listing() | A shop's list as the server sent it: its ids, unlooked-up. | game:act |
listType() | Which kind of list an id is (SHOP_LIST_TYPE), or null for one the client does not know. | game:read |
offering() | What a clothing (or diamond, exchange, combined) shop offers, with each item's definition. | game:act |
open() | Opens a shop's window as its door in the world does (genericListVolumeClicked), and resolves once the window is up for that shop. | game:act |
picture() | An item drawn as the game draws it, as a data:image/png URL: clothing as its inventory icon (SimpleIcon), a den item as its own art (DenItemHelper). | game:read |
sell() | Sells clothing back for gems, by each item's invId, as the recycle window does (requestItemRecycle). | game:act |
whenDefinitionsReady() | Waits for the clothing definitions to load; TIMEOUT when they do not in time. | game:read |
onBundleBuy() | Hears the bundle being bought or refused. | game:read |
onBuy() | Hears every purchase answer, whoever asked: what was bought, or why not. | game:read |
onClose() | Hears the shop window being taken down, and whether anything was bought in it. | game:read |
onList() | Hears a shop list arriving from the server, the first time it is asked for in a session (the client answers later openings from its cache). | game:read |
onOpen() | Hears a shop window being opened, by the player or a script (ShopManager.launchStore). | game:read |
onSell() | Hears every sale back for gems, whoever asked; a refused one has no invIds. | game:read |
shops.diamonds: The diamond catalogue.
| Member | What it does | Plugins |
|---|---|---|
definition() | A catalogue row as loaded, with its full price: by its own id, or by what it sells ({ refDefId, kind }, getDiamondDefByRefId). | game:read |
idFor() | The catalogue id that sells a thing for diamonds, or null when nothing does. | game:read |
item() | A diamond shop entry as the shop shows it (getDiamondItem): the price with any sale already taken off. | game:read |
list() | What the client builds from catalogue ids, as a diamond shop does (generateDiamondShopList): what each id stands for, and the class it is. | game:read |
ready() | Whether the client has loaded the diamond catalogue (diamondDefsLoaded). | game:read |
whenReady() | Waits for the diamond catalogue to load; throws TIMEOUT when it does not in time. | game:read |
shops.window: The shop window open now: its rows, what is picked, its buttons.
| Member | What it does | Plugins |
|---|---|---|
buy() | Buys the item in hand as the buy button does (attemptToBuyCurrrentItem), and resolves with what the window heard back. | game:act |
canBuy() | What pressing buy would do now, checked as the client's own button checks (Shop.attemptToPurchaseItem): membership, the currency, room in the closet or den. | game:read |
close() | Closes the window its own way (applyAndClose), which tells whoever opened it what was bought (a den reloads, the avatar editor redresses). | game:act |
closePreview() | Puts the item in hand down: closes the buy popup. | game:act |
color() | Shows the item in hand in another of its colours (or versions, for a den item), by index or the next one, as the colour buttons do. | game:act |
dismissNotice() | Dismisses the notice the window raised over itself: "not enough gems" (cost) or "oops" (oops). | game:act |
page() | Turns to a page (from 1), or the next or previous one, wrapping as the arrows do. | game:act |
preview() | The item in hand, its colours and the popup round it; null when nothing is. | game:read |
rows() | The window's rows: the page on screen by default, a page by number, or 'all'. | game:read |
select() | Picks a row, turning to its page first, as clicking it does. | game:act |
sort() | Sorts the rows by time, price or name, as the sort popup's buttons do. | game:act |
state() | The window as it stands, or null when none is open. | game:read |
onListed() | Hears the window's list arriving and its rows drawn (Shop.shopSetupCommon). | game:read |
onPage() | Hears the window drawing a page of rows (Shop.setupShopWindows). | game:read |
onPurchase() | Hears every purchase the window makes, with what it was buying (Shop.confirmPurchase). | game:read |
onSelect() | Hears a row being picked (by: 'item') or the item in hand changing colour ('color'). | game:read |
onSort() | Hears the rows being sorted (Shop.onSortingBtns). | game:read |
onStep() | Hears the window's other steps: its art loading, popups filling, notices, the purchase flow. | game:read |
shops.popups: The bundle shop, the sold popup, the charm window and the den and party previews.
| Member | What it does | Plugins |
|---|---|---|
bundle() | The bundle shop, or null when it is not open. | game:read |
charm() | The friendship charm window over the shop, or null when none is up. | game:read |
chooseCharmBuddy() | Picks the buddy a charm is for, by their row in the charm window's list. | game:act |
closeBundle() | Closes the bundle shop with its close button. | game:act |
closeCharm() | Takes the charm window down, which closes the shop behind it. | game:act |
dismissSold() | Dismisses the sold popup with its OK button. | game:act |
exitPreview() | Leaves the den or party preview with its back button's own call (exitPreview). | game:act |
openBundle() | Opens the bundle shop (launchStore(1, …)), resolving once it is on screen. | game:act |
previewDen() | Previews the den in the shop's big buy popup, as its preview button does: the client loads the den in place of the player's own. | game:act |
roomPreview() | The den or party preview running now, or null. | game:read |
sold() | The "your item sold" popup, or null when none is up. | game:read |
onBundle() | Hears the bundle shop opening, closing, and its buttons. | game:read |
onCharm() | Hears the charm window's steps. | game:read |
onPreview() | Hears the den and party previews' steps. | game:read |
onSold() | Hears the sold popup coming up, its buttons, and its going. | game:read |
Methods
buy
buy(defId: number, options: BuyOptions) => Promise<Purchase>Buys a piece of clothing, as the shop's buy button does (ItemXtCommManager.requestItemBuy), and resolves once the server has sold it. First checks what the client's own button checks (Shop.attemptToPurchaseItem), so a refusal comes with its reason before anything is spent: members only, not enough of the currency, the closet full. Then REFUSED when the server says no (no longer for sale, not stocked there), TIMEOUT when it does not answer. The item itself arrives afterwards as an inventory change.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options | BuyOptions |
Returns
Promise<Purchase>
Types
Example
buyBundle
buyBundle(options?: ActOptions) => Promise<{ balance: number | null; }>Buys the bundle shop's whole bundle for diamonds (requestBuyDiamondBundle), resolving with the diamonds left. Checks the price first when the bundle shop is open; REFUSED when the player has not the diamonds or the server says no.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<{ balance: number \| null; }>
Types
close
close(options?: ActOptions) => Promise<void>Closes the shop window (closeWorldShop), resolving once it is gone; nothing when none is.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<OpenShop | null>The shop window open now and what is picked in it, or null when none is.
Returns
Promise<OpenShop \| null>
Types
definition
definition(defId: number) => Promise<ItemDefinition | null>A piece of clothing's definition (ItemXtCommManager.getItemDef), or null for none.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<ItemDefinition \| null>
Types
definitions
definitions() => Promise<ItemDefinition[]>Every clothing definition the client has loaded, read a page at a time; none before.
Returns
Promise<ItemDefinition[]>
Types
definitionsReady
definitionsReady() => Promise<boolean>Whether the client has loaded its clothing definitions (itemDefsHaveLoaded).
Returns
Promise<boolean>
denItemDefinition
denItemDefinition(defId: number) => Promise<ShopDenItemDefinition | null>A den item's definition (DenXtCommManager.getDenItemDef), or null for none.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<ShopDenItemDefinition \| null>
Types
denOffering
denOffering(shopId: number, options?: ActOptions) => Promise<ShopOffering<ShopDenItemDefinition>>What a den item shop offers, with each item's den item definition.
Parameters
| Name | Type | |
|---|---|---|
shopId | number | |
options optional | ActOptions |
Returns
Promise<ShopOffering<ShopDenItemDefinition>>
Types
forSale
forSale(shopId: number, options?: ActOptions) => Promise<ItemDefinition[]>What a shop offers that is being sold now, by the server's clock.
Parameters
| Name | Type | |
|---|---|---|
shopId | number | |
options optional | ActOptions |
Returns
Promise<ItemDefinition[]>
Types
isAvailable
isAvailable(window: { availabilityStartTime: number; availabilityEndTime: number; }) => Promise<boolean>Whether something is being sold now, judged by the client against the server's clock (Utility.isAvailable). Takes any definition, or just the two times.
Parameters
| Name | Type | |
|---|---|---|
window | { availabilityStartTime: number; availabilityEndTime: number; } |
Returns
Promise<boolean>
isOpen
isOpen() => Promise<boolean>Whether a shop window is open (ShopManager.isWorldShopOpen).
Returns
Promise<boolean>
item
item(defId: number, options?: ItemSummaryOptions) => Promise<ItemSummary | null>An item at a glance: name, price, rarity, whether it is sold now, and its picture.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options optional | ItemSummaryOptions |
Returns
Promise<ItemSummary \| null>
Types
items
items(defIds: readonly number[], options?: ItemSummaryOptions) => Promise<(ItemSummary | null)[]>Many items at a glance, in the order asked, null for an id with no definition. Pictures are drawn a few at a time (atOnce); one that will not draw is null rather than failing the rest.
Parameters
| Name | Type | |
|---|---|---|
defIds | readonly number[] | |
options optional | ItemSummaryOptions |
Returns
Promise<(ItemSummary \| null)[]>
Types
knownShops
knownShops() => Promise<KnownShop[]>Every list the client knows of a kind a shop is made of, by id.
Returns
Promise<KnownShop[]>
Types
limits
limits() => Promise<ShopLimits>How much the player may hold, as the client works it out for them now.
Returns
Promise<ShopLimits>
Types
listing
listing(shopId: number, options?: ActOptions) => Promise<ShopListing>A shop's list as the server sent it: its ids, unlooked-up. Read from the client's own cache (GenericListXtCommManager._cachedResponses), and asked for as opening the shop does when the client has not got it yet. REFUSED for a list that is not a shop's.
Parameters
| Name | Type | |
|---|---|---|
shopId | number | |
options optional | ActOptions |
Returns
Promise<ShopListing>
Types
listType
listType(shopId: number) => Promise<number | null>Which kind of list an id is (SHOP_LIST_TYPE), or null for one the client does not know.
Parameters
| Name | Type | |
|---|---|---|
shopId | number |
Returns
Promise<number \| null>
offering
offering(shopId: number, options?: ActOptions) => Promise<ShopOffering>What a clothing (or diamond, exchange, combined) shop offers, with each item's definition.
Parameters
| Name | Type | |
|---|---|---|
shopId | number | |
options optional | ActOptions |
Returns
Promise<ShopOffering>
Types
open
open(shopId: number, options?: ActOptions) => Promise<OpenShop>Opens a shop's window as its door in the world does (genericListVolumeClicked), and resolves once the window is up for that shop. REFUSED for a list the client does not know, for one that opens no shop window (den rooms, movies: see their own areas), and in a room preview. The bundle shop is popups.openBundle.
Parameters
| Name | Type | |
|---|---|---|
shopId | number | |
options optional | ActOptions |
Returns
Promise<OpenShop>
Types
picture
picture(item: ItemPictureItem, options?: ItemPictureOptions) => Promise<string>An item drawn as the game draws it, as a data:image/png URL: clothing as its inventory icon (SimpleIcon), a den item as its own art (DenItemHelper). Throws NOT_READY before the definitions are in, REFUSED for an item with no art of its own, TIMEOUT when the art does not load. Pictures drawn are kept (see ItemPictures); cache: false draws again.
Parameters
| Name | Type | |
|---|---|---|
item | ItemPictureItem | |
options optional | ItemPictureOptions |
Returns
Promise<string>
Types
ItemPictureItem · ItemPictureOptions
Example
const png = await phantom.aj.shops.picture({ defId: 222, color: 0xff3366cc }, { maxSize: 96 });sell
sell(invIds: readonly number[], options?: ActOptions) => Promise<Sale>Sells clothing back for gems, by each item's invId, as the recycle window does (requestItemRecycle). Resolves with what the server took; REFUSED when it took none. It cannot be undone.
Parameters
| Name | Type | |
|---|---|---|
invIds | readonly number[] | |
options optional | ActOptions |
Returns
Promise<Sale>
Types
whenDefinitionsReady
whenDefinitionsReady(options?: ActOptions) => Promise<void>Waits for the clothing definitions to load; TIMEOUT when they do not in time.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
Events
onBundleBuy
onBundleBuy(listener: (answer: { bought: boolean; balance: number | null; }) => void) => () => voidHears the bundle being bought or refused.
Parameters
| Name | Type | |
|---|---|---|
listener | (answer: { bought: boolean; balance: number | null; }) => void |
Returns
() => void. Call it to stop listening.
onBuy
onBuy(listener: (answer: PurchaseAnswer) => void) => () => voidHears every purchase answer, whoever asked: what was bought, or why not.
Parameters
| Name | Type | |
|---|---|---|
listener | (answer: PurchaseAnswer) => void |
Returns
() => void. Call it to stop listening.
Types
onClose
onClose(listener: (closed: { bought: boolean; }) => void) => () => voidHears the shop window being taken down, and whether anything was bought in it.
Parameters
| Name | Type | |
|---|---|---|
listener | (closed: { bought: boolean; }) => void |
Returns
() => void. Call it to stop listening.
onList
onList(listener: (listing: ShopListing) => void) => () => voidHears a shop list arriving from the server, the first time it is asked for in a session (the client answers later openings from its cache). Lists that are no shop's are left out.
Parameters
| Name | Type | |
|---|---|---|
listener | (listing: ShopListing) => void |
Returns
() => void. Call it to stop listening.
Types
onOpen
onOpen(listener: (opened: { shopId: number; listType: number; }) => void) => () => voidHears a shop window being opened, by the player or a script (ShopManager.launchStore).
Parameters
| Name | Type | |
|---|---|---|
listener | (opened: { shopId: number; listType: number; }) => void |
Returns
() => void. Call it to stop listening.
onSell
onSell(listener: (sale: Sale) => void) => () => voidHears every sale back for gems, whoever asked; a refused one has no invIds.
Parameters
| Name | Type | |
|---|---|---|
listener | (sale: Sale) => void |
Returns
() => void. Call it to stop listening.
Types
shops.diamonds
The diamond catalogue.
definition
definition(entry: number | { refDefId: number; kind: DiamondKind; }) => Promise<DiamondDefinition | null>A catalogue row as loaded, with its full price: by its own id, or by what it sells ({ refDefId, kind }, getDiamondDefByRefId). Null where there is none.
Parameters
| Name | Type | |
|---|---|---|
entry | number | { refDefId: number; kind: DiamondKind; } |
Returns
Promise<DiamondDefinition \| null>
Types
Example
const row = await phantom.aj.shops.diamonds.definition({ refDefId: 4521, kind: 'item' });idFor
idFor(refDefId: number, kind: DiamondKind) => Promise<number | null>The catalogue id that sells a thing for diamonds, or null when nothing does.
Parameters
| Name | Type | |
|---|---|---|
refDefId | number | |
kind | DiamondKind |
Returns
Promise<number \| null>
Types
item
item(defId: number) => Promise<DiamondItem | null>A diamond shop entry as the shop shows it (getDiamondItem): the price with any sale already taken off. Null for an id the catalogue has not got.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<DiamondItem \| null>
Types
list
list(defIds: readonly number[]) => Promise<DiamondShopList>What the client builds from catalogue ids, as a diamond shop does (generateDiamondShopList): what each id stands for, and the class it is. Ids the catalogue has not got are left out and named, since the client's own builder throws on one.
Parameters
| Name | Type | |
|---|---|---|
defIds | readonly number[] |
Returns
Promise<DiamondShopList>
Types
ready
ready() => Promise<boolean>Whether the client has loaded the diamond catalogue (diamondDefsLoaded).
Returns
Promise<boolean>
whenReady
whenReady(options?: ActOptions) => Promise<void>Waits for the diamond catalogue to load; throws TIMEOUT when it does not in time.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
shops.window
The shop window open now: its rows, what is picked, its buttons.
buy
buy(options?: ActOptions) => Promise<ShopPurchase>Buys the item in hand as the buy button does (attemptToBuyCurrrentItem), and resolves with what the window heard back. REFUSED with the client's reason (members only, short of the currency, no room) before anything is sent, or with the server's. An item priced in diamonds waits for the player to answer the client's "spend diamonds?" popup.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ShopPurchase>
Types
canBuy
canBuy() => Promise<BuyCheck | null>What pressing buy would do now, checked as the client's own button checks (Shop.attemptToPurchaseItem): membership, the currency, room in the closet or den.
Returns
Promise<BuyCheck \| null>
Types
close
close(options?: ActOptions) => Promise<void>Closes the window its own way (applyAndClose), which tells whoever opened it what was bought (a den reloads, the avatar editor redresses). Nothing when no window is open.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
closePreview
closePreview(options?: ActOptions) => Promise<void>Puts the item in hand down: closes the buy popup. Nothing when none is up.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
color
color(to: number | "next", options?: ActOptions) => Promise<ShopPreview>Shows the item in hand in another of its colours (or versions, for a den item), by index or the next one, as the colour buttons do. Resolves with the item as it is shown now.
Parameters
| Name | Type | |
|---|---|---|
to | number | "next" | |
options optional | ActOptions |
Returns
Promise<ShopPreview>
Types
dismissNotice
dismissNotice(options?: ActOptions) => Promise<"cost" | "oops" | null>Dismisses the notice the window raised over itself: "not enough gems" (cost) or "oops" (oops). Resolves with which it was, or null when none was up.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<"cost" \| "oops" \| null>
Types
page
page(to: number | "next" | "previous", options?: ActOptions) => Promise<ShopPage>Turns to a page (from 1), or the next or previous one, wrapping as the arrows do.
Parameters
| Name | Type | |
|---|---|---|
to | number | "next" | "previous" | |
options optional | ActOptions |
Returns
Promise<ShopPage>
Types
preview
preview() => Promise<ShopPreview | null>The item in hand, its colours and the popup round it; null when nothing is.
Returns
Promise<ShopPreview \| null>
Types
rows
rows(options?: { page?: number | "all" | undefined; }) => Promise<ShopRow[]>The window's rows: the page on screen by default, a page by number, or 'all'. None when no window is open or its list has not arrived.
Parameters
| Name | Type | |
|---|---|---|
options optional | { page?: number | "all" | undefined; } |
Returns
Promise<ShopRow[]>
Types
select
select(index: number, options?: ActOptions) => Promise<ShopSelection>Picks a row, turning to its page first, as clicking it does. Resolves with the item in hand. REFUSED for a row the shop has not got.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<ShopSelection>
Types
sort
sort(by: "name" | "time" | "price", options?: ActOptions) => Promise<ShopSort>Sorts the rows by time, price or name, as the sort popup's buttons do. Asking again for the order already showing turns it the other way. REFUSED in a shop with no sort button.
Parameters
| Name | Type | |
|---|---|---|
by | "name" | "time" | "price" | |
options optional | ActOptions |
Returns
Promise<ShopSort>
Types
state
state() => Promise<ShopWindowState | null>The window as it stands, or null when none is open.
Returns
Promise<ShopWindowState \| null>
Types
onListed
onListed(listener: (listed: { shopId: number; listType: number; kind: ShopKind; itemCount: number; }) => void) => () => voidHears the window's list arriving and its rows drawn (Shop.shopSetupCommon).
Parameters
| Name | Type | |
|---|---|---|
listener | (listed: { shopId: number; listType: number; kind: ShopKind; itemCount: number; }) => void |
Returns
() => void. Call it to stop listening.
Types
onPage
onPage(listener: (page: ShopPage) => void) => () => voidHears the window drawing a page of rows (Shop.setupShopWindows).
Parameters
| Name | Type | |
|---|---|---|
listener | (page: ShopPage) => void |
Returns
() => void. Call it to stop listening.
Types
onPurchase
onPurchase(listener: (purchase: ShopPurchase) => void) => () => voidHears every purchase the window makes, with what it was buying (Shop.confirmPurchase).
Parameters
| Name | Type | |
|---|---|---|
listener | (purchase: ShopPurchase) => void |
Returns
() => void. Call it to stop listening.
Types
onSelect
onSelect(listener: (picked: ShopSelection & { by: "color" | "item"; }) => void) => () => voidHears a row being picked (by: 'item') or the item in hand changing colour ('color').
Parameters
| Name | Type | |
|---|---|---|
listener | (picked: ShopSelection & { by: "color" | "item"; }) => void |
Returns
() => void. Call it to stop listening.
Types
onSort
onSort(listener: (sort: ShopSort & { shopId: number; }) => void) => () => voidHears the rows being sorted (Shop.onSortingBtns).
Parameters
| Name | Type | |
|---|---|---|
listener | (sort: ShopSort & { shopId: number; }) => void |
Returns
() => void. Call it to stop listening.
Types
onStep
onStep(listener: (step: ShopStep) => void) => () => voidHears the window's other steps: its art loading, popups filling, notices, the purchase flow.
Parameters
| Name | Type | |
|---|---|---|
listener | (step: ShopStep) => void |
Returns
() => void. Call it to stop listening.
Types
shops.popups
The bundle shop, the sold popup, the charm window and the den and party previews.
bundle
bundle() => Promise<BundleShopState | null>The bundle shop, or null when it is not open.
Returns
Promise<BundleShopState \| null>
Types
charm
charm() => Promise<CharmPopup | null>The friendship charm window over the shop, or null when none is up.
Returns
Promise<CharmPopup \| null>
Types
chooseCharmBuddy
chooseCharmBuddy(index: number, options?: ActOptions) => Promise<CharmPopup>Picks the buddy a charm is for, by their row in the charm window's list.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<CharmPopup>
Types
closeBundle
closeBundle(options?: ActOptions) => Promise<void>Closes the bundle shop with its close button. Nothing when it is not open.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
closeCharm
closeCharm(options?: ActOptions) => Promise<void>Takes the charm window down, which closes the shop behind it. Nothing when none is up.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
dismissSold
dismissSold(options?: ActOptions) => Promise<void>Dismisses the sold popup with its OK button. Nothing when none is up.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
exitPreview
exitPreview(options?: ActOptions) => Promise<void>Leaves the den or party preview with its back button's own call (exitPreview).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
openBundle
openBundle(options?: ActOptions) => Promise<BundleShopState>Opens the bundle shop (launchStore(1, …)), resolving once it is on screen.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<BundleShopState>
Types
previewDen
previewDen(options?: ActOptions) => Promise<RoomPreview>Previews the den in the shop's big buy popup, as its preview button does: the client loads the den in place of the player's own. Resolves once the preview is running.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<RoomPreview>
Types
roomPreview
roomPreview() => Promise<RoomPreview | null>The den or party preview running now, or null.
Returns
Promise<RoomPreview \| null>
Types
sold
sold() => Promise<SoldPopup | null>The "your item sold" popup, or null when none is up.
Returns
Promise<SoldPopup \| null>
Types
onBundle
onBundle(listener: (event: BundleEvent) => void) => () => voidHears the bundle shop opening, closing, and its buttons.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: BundleEvent) => void |
Returns
() => void. Call it to stop listening.
Types
onCharm
onCharm(listener: (event: CharmEvent) => void) => () => voidHears the charm window's steps.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: CharmEvent) => void |
Returns
() => void. Call it to stop listening.
Types
onPreview
onPreview(listener: (event: RoomPreviewEvent) => void) => () => voidHears the den and party previews' steps.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: RoomPreviewEvent) => void |
Returns
() => void. Call it to stop listening.
Types
onSold
onSold(listener: (event: SoldEvent) => void) => () => voidHears the sold popup coming up, its buttons, and its going.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: SoldEvent) => void |
Returns
() => void. Call it to stop listening.
Types
Types
The types the calls above take and give, with every field. Import any of them in a plugin from @phantomclient/plugin/sdk, or use them as they are in a script.
ItemDefinition
A piece of clothing as the client's definitions describe it (ItemXtCommManager.getItemDef). This is where a price and whether an item is members only live: a shop list carries ids only.
| Field | Type | |
|---|---|---|
defId | number | |
name | string | Its name in the player's language, already translated by the client. |
titleStrId | number | |
cost | number | What it costs, in currencyType. |
currencyType | number | Which currency buys it (CURRENCY: 0 gems, 3 diamonds, 100 several at once). |
combinedCost | string | null | A price in several currencies, as the server writes it (4x10,6x5); null for one currency. |
membersOnly | boolean | |
recycleValue | number | The gems selling it back gives. |
type | number | |
enviroType | number | 0 land, 1 ocean, 3 both. |
colors | number[] | The colours it comes in (ARGB), in the order buy's colorIndex counts them. |
layerId | number | |
accId | number | The accessory it is drawn from. |
avatarUseFlag | number | Which animals can wear it, a bit per avatar type id. |
rarity | ItemRarity | |
isGiftable | boolean | |
availabilityStartTime | number | When it went on sale, in seconds since the epoch; 0 for always. |
availabilityEndTime | number | When it stops being sold, in seconds since the epoch; 0 for never. |
combat | { attack: number; defense: number; attackMediaRefId: number; combatType: number; modifierType: number; modifierValue: number; criticalHit: number; } | What it does in an adventure's fights; all 0 for plain clothing. |
ItemRarity
How the definitions mark an item (itemStatus): rare is the one players trade on.
type ItemRarity = 'normal' | 'new' | 'sale' | 'clearance' | 'rare'ShopDenItemDefinition
A den item as the client's definitions describe it (DenXtCommManager.getDenItemDef).
| Field | Type | |
|---|---|---|
defId | number | |
name | string | |
cost | number | |
currencyType | number | |
combinedCost | string | null | |
recycleValue | number | |
membersOnly | boolean | |
rarity | ItemRarity | |
enviroType | number | |
sortCat | number | Which drawer of the den editor: 0 floor, 1 wall, 2 flooring, 3 wallpaper, 4 audio. |
typeCat | number | |
specialType | number | |
availabilityStartTime | number | |
availabilityEndTime | number |
ActOptions
How long something that acts may take, and what may end it first.
| Field | Type | |
|---|---|---|
timeoutMs optional | number | undefined | 10 seconds by default. |
signal optional | AbortSignal | undefined |
ItemPictureItem
What to draw: an id (clothing), or any record carrying one.
type ItemPictureItem = | number
| {
defId: number;
/** `clothing` when left out. */
kind?: ItemKind;
/** Clothing only: the colour (ARGB). The definition's first colour when left out. */
color?: number;
/** A den shop listing's look, which carries the colour the seller owns it in. */
look?: DenShopLook | null;
}ItemPictureOptions
How to draw an item.
type ItemPictureOptions = ActOptions & {
scale?: number;
/** A colour behind it; nothing behind it by default. */
background?: number | null;
/** The most pixels on a side. */
maxSize?: number;
/** Clothing only: the larger icon a shop row shows. */
large?: boolean;
/** Den items only: which version; 0 by default, -1 for the one its art lists first. */
version?: number;
/** False to draw it again rather than answer from the pictures already drawn. */
cache?: boolean;
}ItemSummaryOptions
| Field | Type | |
|---|---|---|
kind optional | ItemKind | undefined | |
picture optional | boolean | ItemPictureOptions | undefined | false for no picture; options to draw it with. Drawn by default. |
atOnce optional | number | undefined | How many pictures are drawn at once for a list; 4 by default. |
ItemSummary
What an item is, at a glance: name, price, rarity, whether it is sold now, and its picture.
| Field | Type | |
|---|---|---|
defId | number | |
kind | ItemKind | |
name | string | |
rarity | ItemRarity | |
cost | number | |
currencyType | number | |
membersOnly | boolean | |
forSale | boolean | Being sold now, judged against the server's clock. |
picture | string | null | A data:image/png URL; null when not asked for or when it would not draw. |
ItemKind
Which set of definitions an id belongs to: clothing and den items number theirs apart.
type ItemKind = 'clothing' | 'den-item'KnownShop
One of the lists the client knows by id, of a kind a shop is made of.
| Field | Type | |
|---|---|---|
shopId | number | |
listType | number |
ShopListing
A shop list as it arrived, before anything is looked up.
| Field | Type | |
|---|---|---|
shopId | number | |
listType | number | |
defIds | number[] |
ShopOffering
What a shop offers, with each item's definition.
| Field | Type | |
|---|---|---|
shopId | number | |
listType | number | Which kind of list it is (SHOP_LIST_TYPE). |
titleStrId | number | null | The title's string id, or null for a shop that keeps its own. |
diamondBundle | boolean | The bundle shop: everything is bought at once for diamondCost diamonds. |
diamondCost | number | |
items | Item[] | |
unknownDefIds | number[] | Ids the client has no definition for, left out of items. |
OpenShop
The shop window open now (ShopManager._shop), and what is picked in it.
| Field | Type | |
|---|---|---|
shopId | number | |
listType | number | |
windowClass | string | shop::Shop, shop::ShopWithPreview (clothing) or shop::ShopToSell (a den shop). |
itemCount | number | |
selectedIndex | number | null | The row picked, from 0; null before one is. |
selectedDefId | number | null | What the buy button would buy (Shop.getCurrentItemDefId); null with no row picked. |
selectedDiamond | boolean | null | |
selectedColorIndex | number |
ShopLimits
How much the player may hold, as the client works it out for them now (shop.ShopManager).
| Field | Type | |
|---|---|---|
items | number | |
denItems | number | |
audioItems | number | |
warnItems | number | |
warnDenItems | number | |
warnAudioItems | number | |
warnDenRooms | number | |
denShopItems | number | The most one den shop may list. |
BuyOptions
How to buy.
type BuyOptions = ActOptions & {
/** The shop it is bought from (required: the server checks the shop stocks it). */
shopId: number;
/** Which of the item's `colors`, from 0. */
colorIndex?: number;
/** Pay in diamonds: `defId` is then the diamond catalogue id (`DiamondItem.defId`). */
diamond?: boolean;
/** A charm bought onto someone's den item. */
forDenItem?: { invId: number; userName: string };
}Purchase
A purchase the server made.
| Field | Type | |
|---|---|---|
defId | number | |
shopId | number | |
balance | string | number | null | The currency left afterwards, or null when the server left it unchanged. For an item priced in several crafting currencies at once (currency type 100) it is the server's combined text, each currency's id and what is left of it: 4x10,6x2. |
currencyType | number |
Sale
Items sold back for gems.
| Field | Type | |
|---|---|---|
invIds | number[] | |
gems | number | null | The gems afterwards, or null when unchanged. |
PurchaseAnswer
A purchase answer, whoever asked for it (onBuy).
| Field | Type | |
|---|---|---|
shopId | number | |
bought | boolean | |
status | number | 1 bought, -2 no longer for sale, anything else refused. |
refusal | string | null | Why not, in words; null when bought. |
balance | string | number | null | As Purchase.balance: a number, or the combined text for several currencies. |
currencyType | number |
DiamondItem
A diamond shop entry as the shop sees it (diamond.DiamondItem): sale price already taken off.
| Field | Type | |
|---|---|---|
defId | number | Its catalogue id, which buy takes with diamond: true. |
value | number | What it costs in diamonds now. |
type | number | 0 accessory, 1 den item, 2 pet, 3 avatar, 4 den, 5 custom avatar. |
refDefId | number | The def id of the thing itself. |
status | number | |
isNew | boolean | |
isOnSale | boolean | |
isOnClearance | boolean | |
isRare | boolean | |
isAvailable | boolean | |
availabilityEndTime | number | |
startTime | number |
DiamondDefinition
A catalogue row as loaded (DiamondXtCommManager.getDiamondDef): the full price.
| Field | Type | |
|---|---|---|
defId | number | |
value | number | |
refDefId | number | |
type | number | |
status | number | |
availabilityStartTime | number | |
availabilityEndTime | number |
DiamondKind
What the catalogue sells for diamonds, by what it is: DiamondXtCommManager's DIAMOND_TYPE_*.
type DiamondKind = 'item' | 'den-item' | 'pet' | 'avatar' | 'den'DiamondShopList
| Field | Type | |
|---|---|---|
items | DiamondShopItem[] | |
unknownDefIds | number[] |
DiamondShopItem
One row the client built from catalogue ids (generateDiamondShopList).
| Field | Type | |
|---|---|---|
diamondDefId | number | |
defId | number | null | The def id of what was built; null where the client built nothing for that row. |
itemClass | string | null |
ShopWindowState
The shop window as it stands.
type ShopWindowState = ShopPage & {
listType: number;
kind: ShopKind;
windowClass: string;
/** The list has arrived and the rows are drawn; nothing can be pressed before. */
listed: boolean;
/** False while hidden behind a den preview. */
visible: boolean;
title: string | null;
titleStrId: number | null;
perPage: number;
/** Whether next and previous do anything. */
canPage: boolean;
/** The order of the rows; null in a shop with no sort button. */
sort: ShopSort | null;
/** Which currency the purse shows, as its art names it (`gems`, `diamonds`, `tickets`…). */
currency: string | null;
/** The balance as the window writes it (`1,250`): what the player sees, not a number. */
balanceShown: string | null;
diamondsShown: string | null;
/** The membership the window read as it opened. */
isMember: boolean;
/** A den shop looked at by its owner. */
isOwner: boolean;
/** The shop raised the recycle window over itself. */
recycling: boolean;
/** Anything was bought since it opened. */
bought: boolean;
}ShopKind
What kind of shop a window is, in words.
type ShopKind = | 'clothing'
| 'den-items'
| 'den-audio'
| 'den-rooms'
| 'exchange'
| 'diamond'
| 'combined'
| 'den-shop'
| 'other'ShopSort
The order a shop's rows are in; label is the sort button's own frame (gemBtnUp).
| Field | Type | |
|---|---|---|
by | "name" | "time" | "price" | |
label | string |
ShopPage
Where a window is in its pages.
| Field | Type | |
|---|---|---|
shopId | number | |
page | number | From 1. |
pageCount | number | |
offset | number | The index of the first row on the page. |
itemCount | number |
ShopRow
One row of a shop window.
| Field | Type | |
|---|---|---|
index | number | Its place in the shop, from 0, in the order showing: what window.select takes. |
slot | number | null | Which of the six rows on screen, from 0; null for a row on another page. |
defId | number | The thing's own def id; in a diamond shop diamondDefId is the catalogue row. |
itemClass | string | |
kind | ShopItemKind | |
name | string | |
cost | number | null | With any sale taken off; null for a price in several currencies. |
currencyType | number | |
membersOnly | boolean | |
isNew | boolean | |
isOnSale | boolean | |
isOnClearance | boolean | |
isRare | boolean | |
isDiamond | boolean | |
isOcean | boolean | |
endTime | number | When it stops being sold, in seconds since the epoch; 0 for never. |
diamondDefId | number | null |
ShopItemKind
What a row is, from the class the client built it as.
type ShopItemKind = 'clothing' | 'den-item' | 'den-room' | 'pet' | 'animal' | 'currency' | 'other'ShopPreview
The item a window is holding up: in its buy popup, or on the animal beside it.
| Field | Type | |
|---|---|---|
index | number | null | |
defId | number | |
itemClass | string | |
kind | ShopItemKind | |
name | string | |
cost | number | null | |
currencyType | number | |
membersOnly | boolean | |
popup | "big" | "small" | "none" | small the usual buy popup, big the one dens use, none neither (a preview shop's try-on). |
tryingOn | boolean | On the animal in a clothing shop. |
colors | number[] | Colours (ARGB) for clothing, versions for a den item; what color counts. |
colorIndex | number | |
shownAffordable | boolean | null | The green buy button is up, which is the player having the currency; null with no button. |
BuyCheck
What pressing buy would do now.
| Field | Type | |
|---|---|---|
allowed | boolean | |
reason | BuyRefusal | null | |
asksFirst | boolean | Diamonds: the client asks the player "spend diamonds?" first and buys only on a yes. |
defId | number | null | |
cost | number | null | |
currencyType | number | null |
ShopSelection
The item a window has in hand, as its events tell it.
| Field | Type | |
|---|---|---|
shopId | number | |
index | number | null | The row, from 0; null when nothing is in hand. |
defId | number | null | |
itemClass | string | null | |
kind | ShopItemKind | null | |
name | string | null | |
cost | number | null | |
currencyType | number | null | |
membersOnly | boolean | |
colorIndex | number |
ShopPurchase
A purchase as the window heard it (Shop.confirmPurchase).
| Field | Type | |
|---|---|---|
shopId | number | |
defId | number | null | |
name | string | null | |
colorIndex | number | |
bought | boolean | |
status | number | 1 bought, -2 no longer for sale, anything else refused. |
refusal | string | null | |
balance | number | null | |
currencyType | number | null |
ShopStep
Something the window did that has no event of its own: its art loading, a popup filling, a refusal popup being dismissed, the purchase flow moving on. kind is the client's own step.
| Field | Type | |
|---|---|---|
kind | ShopStepKind | |
shopId | number | null | |
flag | boolean | null | For shown/hidden and recycleClosed: the flag the client was given. |
ShopStepKind
type ShopStepKind = | 'loaded'
| 'listAsked'
| 'firstDraw'
| 'shown'
| 'hidden'
| 'closePressed'
| 'gone'
| 'balancesDrawn'
| 'priceTagsDrawn'
| 'till'
| 'popupFilled'
| 'smallPopup'
| 'bigPopup'
| 'previewClosed'
| 'denPreviewPressed'
| 'infoPressed'
| 'sortPressed'
| 'buyPressed'
| 'checking'
| 'sent'
| 'wearing'
| 'delisted'
| 'notForSale'
| 'costNoticeClosed'
| 'oopsClosed'
| 'couldNotBuy'
| 'earnGemsPressed'
| 'shortOfRoom'
| 'recycleClosed'
| 'denBought'BundleShopState
The bundle shop as it stands (shop.BundleShop).
| Field | Type | |
|---|---|---|
shown | boolean | On screen; false while its art and list are loading. |
diamondCost | number | What the whole bundle costs in diamonds; 0 until the list is in. |
title | string | null | |
shownAffordable | boolean | null | The price tag is green: the player has the diamonds. Null until shown. |
items | ShopRow[] | What is in it, bought all at once with shops.buyBundle. |
BundleEvent
Something the bundle shop did.
| Field | Type | |
|---|---|---|
kind | "listed" | "bought" | "opened" | "loaded" | "closePressed" | "buyPressed" | "closed" | "clicked" | |
diamondCost | number | |
itemCount | number |
SoldPopup
The popup saying something of the player's sold in their den shop.
type SoldPopup = SoldItem & {
shown: boolean;
/** How many more sales wait their turn behind it. */
waiting: number;
}SoldItem
Something of the player's that sold in their den shop (shop.ItemSoldPopup).
| Field | Type | |
|---|---|---|
defId | number | |
itemClass | string | null | |
kind | ShopItemKind | |
name | string | |
amount | number | |
currencyType | number | |
reopensShop | number | null | The den shop the client opens again once it is dismissed, or null. |
SoldEvent
What the sold popup did (event), with what was sold.
type SoldEvent = SoldItem & { event: 'shown' | 'okPressed' | 'closePressed' | 'closed' }CharmPopup
The friendship charm window (Shop._charmBuyPopup).
| Field | Type | |
|---|---|---|
choosing | boolean | The buddy list and the charm are showing. |
confirming | boolean | The "are you sure" half is showing. |
buddies | number | |
buddyIndex | number | null | The buddy row picked, or null. |
buddyName | string | null | |
canRedeem | boolean | |
canChangeColour | boolean |
CharmEvent
| Field | Type | |
|---|---|---|
kind | "loaded" | "closed" | "built" | "buddiesLoaded" | "colourChanged" | "redeemPressed" | "redeemCancelled" | "redeemRefused" | "redeemConfirmed" | "answered" | |
shopId | number | null | |
buddyName | string | null |
RoomPreview
A room the client has loaded so the player can look before buying (a den) or hosting (a party).
| Field | Type | |
|---|---|---|
kind | "den" | "party" | |
buttons | boolean | The back and buy (or host) buttons are up. |
takeButton | boolean | |
fromShop | boolean | The shop window or party window it came from is still there. |
RoomPreviewEvent
| Field | Type | |
|---|---|---|
of | "den" | "party" | |
kind | "started" | "gone" | "visibilities" | "buttonsAsked" | "buttonsLoaded" | "backPressed" | "takePressed" | "takeConfirmed" | "taken" | |
buttons | boolean | |
flag | boolean | null | For visibilities, buttonsAsked and taken: the flag the client was given. |