You and your animal
phantom.aj.playerYou and your animal
The player: their avatar, animals, looks, pets and belongings.
Scripts and plugins
A script has all of it, as phantom.aj.player, 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 |
|---|---|---|
can() | What the account may do with other players; all false before login. | game:read |
current() | Who the player is and what the account is, in one read of the client: null before the client has them (before login). | game:read |
discipline() | What moderation has done to the player this session, as the client holds it. | game:act |
hasPendingFlag() | Whether one of the account's pending flags is set, by its bit (isPendingFlagSet). | game:read |
isSettingOn() | Whether one bit of the account's settings is on (Utility.isSettingOn). | game:read |
record() | What the client holds of a player it has met (a buddy, someone whose card was opened, anyone in the room), or of the player themselves when no name is given; null for nobody it knows. | game:read |
setInvisible() | Turns ghost mode on or off (sendInvisModeRequest), which only moderator and guide accounts have. | game:act |
setPendingFlag() | Sets one of the account's pending flags on the server (af), as the client does when the tour ends. | game:act |
onActiveDenChange() | Hears the player's active den change, with its inventory id. | game:read |
onChange() | Hears the player change: membership, chat, privacy, the animal played, invisibility… with which fields changed. | game:read |
onDiscipline() | Hears moderation land on the player: a ban, silence, kick, warning, message or block. | game:read |
onInvisibleChange() | Hears the server set ghost mode. | game:read |
onLogin() | Hears each successful login, moving to another server included, with what the login reply said of the player (their names, membership, allowances, each currency at login). | game:read |
onPartyHosting() | Hears the client told how long someone's custom party has left (-1 when it ended). | game:read |
onTradeListChange() | Hears the player's own trade list arrive or change. | game:read |
player.avatar: The player's animal in the room: where it stands, how it moves, its colours, name bar.
| Member | What it does | Plugins |
|---|---|---|
act() | Does one of the actions window's actions (sit, dance, sleep…), which everyone in the room sees. | game:act |
bubble() | Shows a chat bubble over the animal on this screen only. | game:act |
checkPhoto() | Asks the server whether the player can pay for a photo booth picture: resolves with the gems the server counts, or throws REFUSED when they cannot pay. | game:act |
drawAt() | Draws the animal somewhere else on this screen only (AvatarWorldView.setPos): nothing is sent, and the room puts it back with its next move. | game:act |
face() | Turns the animal to look along a direction (faceAnim), walking on the spot unless told not. | game:act |
fly() | Has the animal fly over what stops a walking animal (water, low walls), by the client's own flying flag (_enviroTypeFlag) and a rebuilt walk grid, until what it gives back is called. | game:act |
glide() | Steers the animal as the arrow keys do (_avatarDirection), until steered again: null stops it. | game:act |
hosting() | The custom adventure and PvP games the player hosts. | game:read |
idleAnimation() | The animation the animal stands in (getBaseIdle), or null while none is drawn. | game:read |
isNoClip() | Whether no-clip is on. | game:read |
noClip() | Lets the animal walk through walls, outside adventures, until what it gives back is called, which builds the room's true walk grid again. | game:act |
opacity() | Keeps the animal drawn at an opacity, 0 to 100, on this screen, through the client's own fades; calling what it gives back lets the client have it again. | game:act |
payForPhoto() | Pays for a photo booth picture; resolves with the gems left, which the HUD shows too. | game:act |
playAnimation() | Plays one of the animal's animations on this screen (AvatarView.playAnim), facing the other way when flip. | game:act |
position() | The animal's position in room coordinates, or null while the room draws none. | game:read |
roomState() | What the client is doing with the animal between rooms. | game:read |
setMode() | Draws the animal as in the world, or as in an adventure's combat (setAvatarMode). | game:act |
setWalkSpeed() | Makes the player's own animal walk times as fast as the client's own pace (above 0, at most 10; 1 is normal), clicked or walked with the arrow keys, until it is set again or the game reloads. | game:act |
standing() | Where the animal stands, or null while the room draws none (between rooms, before login). | game:read |
teleport() | Puts the animal at a point at once, through the client's own placement (AvatarManager.movePlayer), which tells the room: everyone sees it there. | game:act |
tint() | Tints the animal on this screen (setBlendColor), with an outline colour if given. | game:act |
walkPath() | Walks the animal along points of your own, in order, as the room would walk a path. | game:act |
walkSpeed() | How fast the player's own animal walks, as a multiple of the client's own pace: 1 normally. | game:act |
walkTo() | Walks the animal to a point along the room's paths, as a click on the floor does: everyone in the room sees it. | game:act |
whenStanding() | Waits until the room draws the player's animal, and says where it stands. | game:read |
onNoClip() | Hears no-clip go on and off. | game:read |
onRoomState() | Hears the room state change: a room being joined, a den previewed. | game:read |
onStanding() | Hears the animal move, turn, start or stop, read about eight times a second. | game:read |
player.avatar.colors: The animal's colours, and the avatar editor's colour grids.
| Member | What it does | Plugins |
|---|---|---|
current() | The animal's colours, or null before the player has an animal. | game:read |
offer() | Offers other colours of the game's palette in one of the avatar editor's grids (all of them by default), now if the editor is open and each time it opens, until what it gives back is called. | game:act |
paint() | Paints the animal, as the editor's Done does (requestColorChange, ac): everyone sees it. | game:act |
palette() | The game's palette, or null before the game has loaded it (it does as it starts). | game:read |
pick() | Picks a colour in the open avatar editor's grid, as a click on the swatch does: the editor's own handler takes it, and Done paints it. | game:act |
preview() | Draws the animal in other colours on this screen only; nothing is sent. | game:act |
onPaintResult() | Hears the server answer a paint: whether it took the colours. | game:read |
player.avatar.nameBar: The player's name bar.
| Member | What it does | Plugins |
|---|---|---|
current() | The name bar as the server last took it, or null before the player has one. | game:read |
editor() | The name bar the open avatar editor has pending (what Done would send), or null when the editor is not open. | game:read |
set() | Changes the name bar, as the editor's Done does (the same ac that carries the colours): everyone sees it. | game:act |
setInEditor() | Changes the name bar the open editor has pending, and draws it there; Done sends it. | game:act |
player.animals: The player's animals: switching, making and removing them, and the kinds of animal.
| Member | What it does | Plugins |
|---|---|---|
all() | The player's animals, in the switcher's own slot order. | game:read |
buySlot() | Buys room for one more animal (ab), at Animal Jam's price. | game:act |
chooseUsable() | Chooses which one or two animals a non-member keeps using (ao), as the switcher asks when a membership ends, then asks for the list again so the client's slot flags are the server's. | game:act |
closeCreator() | Closes the avatar creator (GuiManager.closeAvatarCreator), resolving once it is gone. | game:act |
create() | Adds a new animal to the account (aa), which is bought: the switcher charges 1000 gems, a diamond animal its diamonds, a shop its price. | game:act |
createFirst() | Adds the first animal to an account made without one, the "fast pass" (afp), which the client offers only while userInfo.needFastPass is set. | game:act |
current() | The animal the player is playing, or null before the client has one. | game:read |
get() | One of the player's animals, by perUserAvId; null when the switcher has no such animal. | game:read |
known() | A player's animals as the client has cached them (UserInfo.avList): every one of the player's own when userName is left out, and for anyone else the ones the client has been told of (the one they were seen as, those their buddy card showed). | game:read |
record() | One cached animal of a player's (getAvatarInfoByUsernamePerUserAvId, which matches the name in any case), or the one they were last seen as when perUserAvId is left out (getAvatarInfoByUserName). | game:read |
refresh() | Asks the server for the player's animals again (requestAvatarList, al), as joining the world does, and resolves with its list. | game:act |
remove() | Deletes one of the player's animals for good, as the switcher's delete button does (AvatarSwitch.removeAvatar, ak), which also takes it off the client's list and frees its items. | game:act |
slots() | How many animals the player has and may use, as the switcher counts them. | game:read |
suits() | Whether the player's animal can go somewhere, as the client checks before a room or a game (AvatarManager.isValidEnviro): 1 land, 2 ocean, 4 air, or several added. | game:read |
switcher() | What the switcher is in the middle of: a switch, a slot being bought, the player being made to choose two animals to keep. | game:read |
switchTo() | Switches to another of the player's animals, as the switcher does (switchAvatars, as), and resolves with the animal switched to once the server has said so. | game:act |
onChange() | Hears the server change the player's animals: a list arriving, an animal added or removed, a slot bought, the first animal added, the usable animals chosen. | game:read |
onSwitch() | Hears anyone in the room switch animals, the player included (as). | game:read |
player.animals.kinds: The kinds of animal the game has.
| Member | What it does | Plugins |
|---|---|---|
asItem() | What the animal shop makes of a kind: its price now, its ribbon, where it may go, as the client's own AvatarItem works it out (a sale halves the price, a diamond kind is priced by the diamond shop). | game:act |
count() | How many kinds the def pack has (getAvatarDefsCount); 0 before it is in. | game:read |
creation() | The kinds the avatar creator offers, by the index its arrows count by, with the diamond shop's counts. | game:read |
custom() | A recycled kind by its customAvId (getAvatarDefByAvType(id, true)); null when unknown. | game:read |
customsOf() | Every recycled kind built on one kind (getCustomAvatarDefsByAvRefId); none when it has none. | game:read |
get() | A kind of animal by its avTypeId (getAvatarDefByAvType(id, false)), with its name translated. | game:read |
hasSeen() | Whether the player has met a kind, from the bit the client keeps per kind in a user var (AvatarUtility.getAvatarDefIsViewableWithAvId), which is how the journey book knows. | game:read |
isLoaded() | Whether the def pack of kinds is in (userInfo.avtDefsCached). | game:read |
load() | Has the client load the def pack of kinds, as it does at start-up (AvatarXtCommManager.requestAvatarInfo), and resolves once it is in. | game:act |
offsets() | Where the client draws things over a kind: the name bar, a chat balloon's tail, an emote's background, the shop window, the talking head, the photo, the minigame lobby. | game:read |
playedBy() | The kind a player in the room is playing, recycled kinds included (getAvatarDefByAvatar, as the item windows ask it): the player's own when userName is left out. | game:read |
player.animals.window: The animal switcher window, as the player sees and presses it.
| Member | What it does | Plugins |
|---|---|---|
current() | The switcher as it stands, or null when it is not open or its art is not in. | game:read |
pressSlot() | Presses a slot, as the player does, drawing the slots before it first as the client would. | game:act |
rebuild() | Draws the switcher's slots again from the client's own list (buildWindows). | game:act |
setMessage() | Shows a warning of your own in the switcher's own warning box, darkening the rest as the client does, or takes it down with null. | game:act |
setRecycling() | Turns recycling on or off, as its recycle button does, and confirms the switcher did. | game:act |
slots() | Every slot, with the animal in it from the client's own list (avatar.AvatarSwitch). | game:read |
onChange() | Hears what happens on the switcher: ready, a slot pressed, a switch, a recycle, a warning. | game:read |
player.looks: What the player's animal wears.
| Member | What it does | Plugins |
|---|---|---|
bodyMods() | Every pair of eyes and every pattern an animal can wear (ItemXtCommManager._bodyItemDefIds, what the editor's tabs list), with the one worn now marked. | game:read |
clearTryOn() | Takes every tried-on piece off, and resolves with the def ids that came off. | game:act |
combatValues() | What the adventures make of what the player's animal wears: its attacks, healing, defence, and a shaman's words. | game:read |
current() | How the player's animal looks now, as the client draws it: its colours, eyes, pattern, and the clothing on it (pieces tryOn put on are left out). | game:read |
drawColors() | Repaints the player's animal on this screen only, from three packed colours (Avatar.copyColors), and resolves once the client holds them. | game:act |
dressing() | What the player's animal can dress from (Avatar.inventoryBodyMod, inventoryClothing), and how the client treats it. | game:read |
hideShown() | Undresses the player's animal on this screen only (AccessoryState.hideAll, hideAllExceptBase, hideAllClothingArticles) and resolves once nothing of it is drawn. | game:act |
isShown() | Whether the client draws one thing on the player's animal, by whichever id is to hand (AccessoryState.isAccessoryVisibleByItemId, ByAccId, ByLayer). | game:read |
of() | How another player's animal looks, wherever they are, as the player search sees it (ag). | game:act |
plan() | What putting a look on would do, without doing it: which of the player's items it would put on and take off, which pieces they do not own, and whether the colours change. | game:act |
putOn() | Puts a look on the player's animal from what they own, and resolves once Animal Jam took it: the clothing as closing the avatar editor sends it (iu), then the colours (ap). | game:act |
shown() | What the client is drawing on the player's animal, from its own record of it (AccessoryState): every body mod and piece of clothing with the layer it is on, pieces tryOn put on included. | game:read |
takeOff() | Takes a tried-on piece off again. | game:act |
tryingOn() | The pieces tried on now, by def id, read from what the client draws. | game:read |
tryOn() | Puts one piece on the player's animal on this screen only, owned or not: built from the client's own definitions and drawn, never sent. | game:act |
wearBodyMod() | Puts one pair of eyes or one pattern on the player's animal, swapping out the one on now in the same request (iu, by negative def ids), and resolves with the eyes and pattern after. | game:act |
onChange() | Hears looks change as the server says it: clothing put on or taken off (il), whoever's it is, and the player's colours painted (ap), whoever asked, the avatar editor included. | game:read |
onLook() | Hears the player's look: once as soon as it can be read, and again after every change that leaves the animal looking different, whoever made it. | game:read |
player.looks.mannequins: The den mannequins in the den on screen.
| Member | What it does | Plugins |
|---|---|---|
all() | Every mannequin in the den on screen, in the client's order; none outside a den. | game:read |
dress() | Draws clothing on a mannequin by definition, owned or not, on this screen (MannequinData.headDefId, headColor, … then refreshAvatarItems). | game:act |
get() | One mannequin, by the invId all gives, or null when the den on screen has none such. | game:read |
paint() | Paints a mannequin (MannequinData.updateColors) and draws it again, resolving with it as the client then holds it. | game:act |
redraw() | Has the client build the animal on a mannequin again from what it holds. | game:act |
takeOff() | Takes one piece off a mannequin by its inventory id (MannequinData.hasThisInvIdOnAndRemove). | game:act |
undress() | Takes every piece of the player's clothing off a mannequin (MannequinData.removeItems). | game:act |
player.pets: The player's pets.
| Member | What it does | Plugins |
|---|---|---|
active() | The pet out beside the player now (PetManager.myActivePetInvId), or null for none. | game:read |
adopt() | Adopts a pet, as the pet creator's Done does: a kind the account has unlocked (sendPetCreateRequest, pc), or one bought as a shop item (sendPetShopBuyRequest, pb) when itemDefId is given. | game:act |
all() | Every pet the player has, in the client's order; none before the client has the list. | game:read |
bringOut() | Brings out one of the player's pets, as the pet inventory does (sendPetSwitchRequest, ps), and resolves with it once the server has. | game:act |
canBringOut() | Whether the player could bring a pet out where they stand, as the pet inventory decides it (PetManager.canCurrAvatarUsePet): a walking pet is refused in the ocean, an unhatched egg anywhere but on land. | game:read |
free() | Frees one of the player's pets for good (sendPetDismissRequest, pd). | game:act |
get() | One of the player's pets by its invId, or null when they have none by it. | game:read |
hasUnnamedEgg() | Whether a hatched egg pet is waiting for a name (hasAtLeastOneHatchedEggPet). | game:read |
hideMasteryBadge() | Hides a pet's mastery badge; resolves with its new look. | game:act |
items() | The player's pets as the inventory and the shops see them (PetManager.myPetListAsIitem): what each is worth, its ribbon, and where it may go now. | game:read |
max() | How many pets the account may hold (PetManager.getPetInventoryMax); null before login. | game:read |
nameEgg() | Names a hatched egg pet from the pet creator's two name lists (sendPetEggNameRequest, pn), and resolves with the name the server kept. | game:act |
picture() | Draws any pet's look to a PNG data URL, off screen, as the client's windows draw one (PetManager.getGuiPet). | game:read |
putAway() | Puts the player's pet away (sendPetSwitchRequest(0)), once the server has. | game:act |
refresh() | Asks the server for the player's pets again, and resolves with them once it has answered. | game:act |
restyle() | Changes what the pet that is out wears, as the pet salon does (sendPetItemRequest, pi), and resolves with its new look and the gems left. | game:act |
showMasteryBadge() | Shows a pet's mastery badge (sendPetMasteryRequest, pm); resolves with its new look. | game:act |
onAdopted() | Hears a pet adopted or bought (pc), however it was asked for. | game:read |
onEggNamed() | Hears a hatched egg pet named (pn): the pet and the name the server kept. | game:read |
onFreed() | Hears one of the player's pets freed (pd), by its invId. | game:read |
onList() | Hears a player's pets listed by the server (pl): the player's own, or someone else's. | game:read |
onLookChange() | Hears a pet's look changed by the server: a mastery badge shown or hidden (pm), or the pet salon (pi, with the gems left). | game:read |
onSwitch() | Hears anyone in the room bring a pet out or put one away (ps), the player too (self). | game:read |
player.pets.kinds: The kinds of pet there are, and the client's own answers about them: phantom.aj.player.pets.kinds.
| Member | What it does | Plugins |
|---|---|---|
all() | Every kind of pet in the def pack, in def id order; none before the pack has arrived. | game:read |
appearance() | How a look is drawn, unpacked into the slots the pet creator edits (PetManager.unpackPetBits). | game:read |
get() | One kind of pet (PetManager.getPetDef, which is _petDefs[defId]), or null for a kind the client does not know. | game:read |
goesEverywhere() | Whether a pet may go both on land and in the ocean (canPetGoInBothEnviroTypes). | game:read |
goesWith() | Whether a pet may go with an animal (canPetGoInEnviroType): the player's own animal, or one of the given environment flag. | game:read |
hasHatched() | Whether an egg adopted at createdTs has hatched: three days, on the server's clock. | game:read |
idOf() | A kind's def id, by its name as the client spells it (PetManager.petDefIdForName). | game:read |
isGroundType() | Whether a kind's type walks (PetManager.isGround). | game:read |
isUnlocked() | Whether the account has unlocked a kind (PetManager.isPetAvailable); false before login. | game:read |
name() | A kind's title (Bunny), by def id (PetManager.petNameForDefId); null when unknown. | game:read |
pack() | Slots, as appearance gives them, packed into a look (PetManager.packPetBits). | game:read |
random() | A random look for a kind, as the pet creator rolls one (createRandomPet, then packPetBits), in one message. | game:read |
unlocked() | The kinds the account has unlocked, by def id (PetManager._unlockedPets, the bit field the server sends at login as pu). | game:read |
worldOf() | The world a pet would be in beside an animal (getEnviroTypeByPetType): 0 land, 1 ocean, 2 air. | game:read |
onLoaded() | Hears the def pack arrive (PetManager.petDefs being set), after which all and get have something to say. | game:read |
onUnlocked() | Hears the server say which kinds the account has unlocked (pu), as def ids. | game:read |
player.pets.adoption: Adopt a Pet, the cards codes on real-world toys add to the player's checklist: phantom.aj.player.pets.adoption.
| Member | What it does | Plugins |
|---|---|---|
cards() | The cards the player holds (AdoptAPetManager.usableAdoptAPetDataCopy), in the client's own order, which is by def id. | game:read |
countOf() | How many cards another player holds (requestPetAdoptUsableCount, answered by padc). | game:read |
hasAny() | Whether the player holds any card at all (hasAtLeastOneUsableAdoptAPet). | game:read |
hasUnseen() | Whether a held card has not been looked at yet (hasUnseenPetData): the burst the pet inventory draws over its checklist button. | game:read |
kind() | What one card is (getAdoptAPetDef), and whether the player holds it; null when unknown. | game:read |
kinds() | Every card there is (AdoptAPetManager.allAdoptAPetDefs), with whether the player holds it. | game:read |
markSeen() | Marks cards as seen, as the checklist does: on the client's own copy (setUsableAdoptAPetDefAsSeen, which hasUnseen reads), then to the server (requestPetAdoptUsableSeenSet, pads, which makes it last past this session). | game:act |
of() | Another player's cards, as their buddy card's checklist asks for them (requestPetAdoptUsableData, answered by pad). | game:act |
series() | How far along each series the player is: one entry per series the checklist has a tab for (allAdoptAPetDefsNonIndexedBySeriesSortedByName, NUM_TIERS), whether or not they hold any. | game:read |
tier() | Where a gift count stands on the tiered gift path (TIERED_GIFT_COUNTS, getCurrTierGiftCountAmount): the player's own count (numTieredGiftCount, user var 426), or gifts to ask where someone else would stand, as another player's checklist does. | game:read |
total() | How many cards there are in all (totalAdoptAPetDefs); null before the def pack is in. | game:read |
onChecklist() | Hears a player's cards arrive (pad), whoever asked for them. | game:read |
onCount() | Hears a player's card count arrive (padc), whoever asked for it. | game:read |
player.pets.world: The pet out beside the player in the room (pet.WorldPet, AvatarWorldView._pet): phantom.aj.player.pets.world.
| Member | What it does | Plugins |
|---|---|---|
current() | The pet beside the player as it is drawn now, or null when none is out or drawn yet. | game:read |
drawLook() | Draws the pet in another look, here only: the whole look (PetBase.updateAllBits) or only what it wears (updateUBits). | game:act |
facts() | What the client knows of the pet it draws (pet.PetBase), or null when none is drawn. | game:read |
keep() | Keeps the pet beside the player at the values given, written in the game every frame so the walk cannot put its own back, and onto every pet the client builds after. | game:act |
poke() | Has the pet hop, as a click on it does (WorldPet.onClick). | game:act |
redraw() | Builds the pet beside the player again from the client's record of it (AvatarManager._needToResetPet, setupActivePet), as the client does after a change it cannot draw in place. | game:act |
setTrickAnimation() | Changes the animation a trick plays for every pet (WorldPet._actionLookup, the static table trick reads), until the function it gives back is called, which puts the table back. | game:act |
sparkle() | Puts a sparkle on the pet, by the sparkle's def id; 0 takes it off. | game:act |
still() | Holds the pet still, its art not animating (PetBase.animatePet(false)), until the function it gives back is called, which lets it move again. | game:act |
trick() | Shows the pet doing a trick, as the chat's pet emotes do (WorldPet.setActionByName). | game:act |
walk() | The walk the client works out for the pet each frame, or null when none is drawn. | game:act |
whenOut() | Waits for a pet to be drawn beside the player, and resolves with it: after bringOut, or a room joined with one out. | game:read |
onChange() | Hears the pet beside the player change: brought out, put away (null), walking, shown or hidden. | game:read |
onWalk() | Hears the walk change (a new side, an animation, a turn), and null when the pet goes. | game:read |
player.pets.inventory: The pet inventory: phantom.aj.player.pets.inventory.
| Member | What it does | Plugins |
|---|---|---|
closeChecklist() | Closes the pet checklist the inventory opened over itself. | game:act |
current() | The inventory as it stands, or null when it is not open or its art is not in. | game:read |
loadMore() | Has the grid draw its next page of slots; resolves with whether there was one. | game:act |
pressSlot() | Presses a pet's slot, as the player does, which shows that pet. | game:act |
reload() | Reads the player's pets again and redraws the grid (reloadPets). | game:act |
setRecycling() | Turns recycling on or off, as the cage button does. | game:act |
setSwitchOnClose() | Whether closing asks to switch to the pet shown (_activePetModified): false closes without switching. | game:act |
slots() | Every slot drawn so far, with the pet in it. | game:read |
onChange() | Hears what happens on the inventory: ready, a page drawn, a pet shown, freed, put out. | game:read |
player.pets.eggs: The egg pet popups, buying an egg and its pet hatching: phantom.aj.player.pets.eggs.
| Member | What it does | Plugins |
|---|---|---|
buy() | Buys the egg, as its button does. | game:act |
hatched() | The hatched popup, or null when it is not open. | game:read |
pickName() | Spins the two name wheels to the words at these places, as the player would, ready for the lever. | game:act |
purchase() | The egg on offer, or null when the purchase popup is not open. | game:read |
player.belongings: The player's clothing, den items and pets as the client lists them, and den rooms.
| Member | What it does | Plugins |
|---|---|---|
all() | Everything the player owns from the lists asked for (all three by default), in one shape a trade takes as it stands: { itemType, invIdx }. | game:read |
clothing() | The player's clothing. | game:read |
denItems() | The player's den items: all of them, or only those for the den room they are in. | game:read |
denPets() | The player's pets as they stand in the den, for one world. | game:read |
denRoom() | One den room the game sells, or null for an id it has none for. | game:read |
denRooms() | Every den room the game sells, by definition id, from the def pack the client loaded. | game:read |
Methods
can
can() => Promise<PlayerAllowances>What the account may do with other players; all false before login.
Returns
Promise<PlayerAllowances>
Types
current
current() => Promise<Player | null>Who the player is and what the account is, in one read of the client: null before the client has them (before login). It follows play: a membership redeemed, a silence lifted, another animal chosen.
Returns
Promise<Player \| null>
Types
discipline
discipline() => Promise<PlayerDiscipline>What moderation has done to the player this session, as the client holds it.
Returns
Promise<PlayerDiscipline>
Types
hasPendingFlag
hasPendingFlag(bit: number) => Promise<boolean>Whether one of the account's pending flags is set, by its bit (isPendingFlagSet).
Parameters
| Name | Type | |
|---|---|---|
bit | number |
Returns
Promise<boolean>
isSettingOn
isSettingOn(bit: number) => Promise<boolean>Whether one bit of the account's settings is on (Utility.isSettingOn).
Parameters
| Name | Type | |
|---|---|---|
bit | number |
Returns
Promise<boolean>
record
record(userName?: string | undefined) => Promise<PlayerRecord | null>What the client holds of a player it has met (a buddy, someone whose card was opened, anyone in the room), or of the player themselves when no name is given; null for nobody it knows.
Parameters
| Name | Type | |
|---|---|---|
userName optional | string | undefined |
Returns
Promise<PlayerRecord \| null>
Types
setInvisible
setInvisible(on: boolean, options?: ActOptions) => Promise<boolean>Turns ghost mode on or off (sendInvisModeRequest), which only moderator and guide accounts have. Resolves with the mode the server set; throws REFUSED when it kept the other one.
Parameters
| Name | Type | |
|---|---|---|
on | boolean | |
options optional | ActOptions |
Returns
Promise<boolean>
Types
setPendingFlag
setPendingFlag(bit: number, options?: ActOptions) => Promise<number>Sets one of the account's pending flags on the server (af), as the client does when the tour ends. Resolves with all the flags once the client holds it.
Parameters
| Name | Type | |
|---|---|---|
bit | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
Events
onActiveDenChange
onActiveDenChange(listener: (invId: number) => void) => () => voidHears the player's active den change, with its inventory id.
Parameters
| Name | Type | |
|---|---|---|
listener | (invId: number) => void |
Returns
() => void. Call it to stop listening.
onChange
onChange(listener: (change: PlayerChange) => void) => () => voidHears the player change: membership, chat, privacy, the animal played, invisibility… with which fields changed. Read twice a second.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: PlayerChange) => void |
Returns
() => void. Call it to stop listening.
Types
onDiscipline
onDiscipline(listener: (event: DisciplineEvent) => void) => () => voidHears moderation land on the player: a ban, silence, kick, warning, message or block.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: DisciplineEvent) => void |
Returns
() => void. Call it to stop listening.
Types
onInvisibleChange
onInvisibleChange(listener: (invisible: boolean) => void) => () => voidHears the server set ghost mode.
Parameters
| Name | Type | |
|---|---|---|
listener | (invisible: boolean) => void |
Returns
() => void. Call it to stop listening.
onLogin
onLogin(listener: (player: LoginPlayer) => void) => () => voidHears each successful login, moving to another server included, with what the login reply said of the player (their names, membership, allowances, each currency at login).
Parameters
| Name | Type | |
|---|---|---|
listener | (player: LoginPlayer) => void |
Returns
() => void. Call it to stop listening.
Types
onPartyHosting
onPartyHosting(listener: (hosting: { userName: string | null; secondsLeft: number; }) => void) => () => voidHears the client told how long someone's custom party has left (-1 when it ended).
Parameters
| Name | Type | |
|---|---|---|
listener | (hosting: { userName: string | null; secondsLeft: number; }) => void |
Returns
() => void. Call it to stop listening.
onTradeListChange
onTradeListChange(listener: () => void) => () => voidHears the player's own trade list arrive or change.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
player.avatar
The player's animal in the room: where it stands, how it moves, its colours, name bar.
act
act(action: "sitNW" | "sitNE" | "sitSE" | "sitSW" | "poseLeft" | "poseRight" | "dance" | "sleep" | "dive" | "hop" | "swirl" | "play", options?: ActOptions) => Promise<"sitNW" | "sitNE" | "sitSE" | "sitSW" | "poseLeft" | "poseRight" | "dance" | "sleep" | "dive" | "hop" | "swirl" | "play">Does one of the actions window's actions (sit, dance, sleep…), which everyone in the room sees. Throws REFUSED when the room offers no such action, or while the player is invisible (the client sends none then).
Parameters
| Name | Type | |
|---|---|---|
action | "sitNW" | "sitNE" | "sitSE" | "sitSW" | "poseLeft" | "poseRight" | "dance" | "sleep" | "dive" | "hop" | "swirl" | "play" | |
options optional | ActOptions |
Returns
Promise<"sitNW" \| "sitNE" \| "sitSE" \| "sitSW" \| "poseLeft" \| "poseRight" \| "dance" \| "sleep" \| "dive" \| "hop" \| "swirl" \| "play">
Types
bubble
bubble(text: string, options?: ActOptions & { severity?: number | undefined; }) => Promise<void>Shows a chat bubble over the animal on this screen only. severity above 1 is a warning.
Parameters
| Name | Type | |
|---|---|---|
text | string | |
options optional | ActOptions & { severity?: number | undefined; } |
Returns
Promise<void>
Types
checkPhoto
checkPhoto(options?: ActOptions) => Promise<number>Asks the server whether the player can pay for a photo booth picture: resolves with the gems the server counts, or throws REFUSED when they cannot pay.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<number>
Types
drawAt
drawAt(point: Point, options?: ActOptions & { glide?: boolean | undefined; }) => Promise<Standing>Draws the animal somewhere else on this screen only (AvatarWorldView.setPos): nothing is sent, and the room puts it back with its next move. glide slides it there.
Parameters
| Name | Type | |
|---|---|---|
point | Point | |
options optional | ActOptions & { glide?: boolean | undefined; } |
Returns
Promise<Standing>
Types
ActOptions · Standing · Point
face
face(direction: Point, options?: ActOptions & { animate?: boolean | undefined; }) => Promise<Standing>Turns the animal to look along a direction (faceAnim), walking on the spot unless told not.
Parameters
| Name | Type | |
|---|---|---|
direction | Point | |
options optional | ActOptions & { animate?: boolean | undefined; } |
Returns
Promise<Standing>
Types
ActOptions · Standing · Point
fly
fly(options?: ActOptions) => Promise<Undo>Has the animal fly over what stops a walking animal (water, low walls), by the client's own flying flag (_enviroTypeFlag) and a rebuilt walk grid, until what it gives back is called.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<Undo>
Types
glide
glide(direction: Point | null, options?: ActOptions) => Promise<Point>Steers the animal as the arrow keys do (_avatarDirection), until steered again: null stops it. Land rooms are walked isometrically, so a diagonal is flattened as the client flattens its own. Resolves with the direction the room now walks.
Parameters
| Name | Type | |
|---|---|---|
direction | Point | null | |
options optional | ActOptions |
Returns
Promise<Point>
Types
hosting
hosting() => Promise<AvatarHosting>The custom adventure and PvP games the player hosts.
Returns
Promise<AvatarHosting>
Types
idleAnimation
idleAnimation() => Promise<number | null>The animation the animal stands in (getBaseIdle), or null while none is drawn.
Returns
Promise<number \| null>
isNoClip
isNoClip() => booleanWhether no-clip is on. Kept here, since the game has no flag of its own for it.
Returns
boolean
noClip
noClip(options?: ActOptions) => Promise<Undo>Lets the animal walk through walls, outside adventures, until what it gives back is called, which builds the room's true walk grid again. Asking while it is on gives the same undo.
The walk grid answers "open" for every cell (RoomGrid.testGridCell, and an empty grid where paths are planned), on this screen only.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<Undo>
Types
opacity
opacity(percent: number, options?: ActOptions) => Promise<Undo>Keeps the animal drawn at an opacity, 0 to 100, on this screen, through the client's own fades; calling what it gives back lets the client have it again.
Parameters
| Name | Type | |
|---|---|---|
percent | number | |
options optional | ActOptions |
Returns
Promise<Undo>
Types
payForPhoto
payForPhoto(options?: ActOptions) => Promise<number>Pays for a photo booth picture; resolves with the gems left, which the HUD shows too.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<number>
Types
playAnimation
playAnimation(animation: number, options?: ActOptions & { flip?: boolean | undefined; }) => Promise<void>Plays one of the animal's animations on this screen (AvatarView.playAnim), facing the other way when flip. The room plays its own again with the next move.
Parameters
| Name | Type | |
|---|---|---|
animation | number | |
options optional | ActOptions & { flip?: boolean | undefined; } |
Returns
Promise<void>
Types
position
position() => Promise<Point | null>The animal's position in room coordinates, or null while the room draws none.
Returns
Promise<Point \| null>
Types
roomState
roomState() => Promise<AvatarRoomState>What the client is doing with the animal between rooms.
Returns
Promise<AvatarRoomState>
Types
setMode
setMode(mode: "world" | "combat", options?: ActOptions) => Promise<void>Draws the animal as in the world, or as in an adventure's combat (setAvatarMode).
Parameters
| Name | Type | |
|---|---|---|
mode | "world" | "combat" | |
options optional | ActOptions |
Returns
Promise<void>
Types
setWalkSpeed
setWalkSpeed(times: number, options?: ActOptions) => Promise<number>Makes the player's own animal walk times as fast as the client's own pace (above 0, at most 10; 1 is normal), clicked or walked with the arrow keys, until it is set again or the game reloads. On this screen only: the server is told where the animal is going as it always is, so everybody else sees it walk at the usual pace. Resolves with the speed read back.
Parameters
| Name | Type | |
|---|---|---|
times | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
standing
standing() => Promise<Standing | null>Where the animal stands, or null while the room draws none (between rooms, before login).
Returns
Promise<Standing \| null>
Types
teleport
teleport(point: Point, options?: ActOptions) => Promise<Standing>Puts the animal at a point at once, through the client's own placement (AvatarManager.movePlayer), which tells the room: everyone sees it there. Resolves once the animal stands there; throws when the client would not move it (in a minigame, behind a popup).
Parameters
| Name | Type | |
|---|---|---|
point | Point | |
options optional | ActOptions |
Returns
Promise<Standing>
Types
ActOptions · Standing · Point
tint
tint(color: number, options?: ActOptions & { outline?: number | undefined; }) => Promise<Undo>Tints the animal on this screen (setBlendColor), with an outline colour if given. Calling what it gives back takes the tint off. Nothing is sent: only this player sees it.
Parameters
| Name | Type | |
|---|---|---|
color | number | |
options optional | ActOptions & { outline?: number | undefined; } |
Returns
Promise<Undo>
Types
walkPath
walkPath(points: readonly Point[], options?: AvatarWalkOptions) => Promise<Standing>Walks the animal along points of your own, in order, as the room would walk a path.
Parameters
| Name | Type | |
|---|---|---|
points | readonly Point[] | |
options optional | AvatarWalkOptions |
Returns
Promise<Standing>
Types
walkSpeed
walkSpeed() => Promise<number>How fast the player's own animal walks, as a multiple of the client's own pace: 1 normally. Read from AvatarWorldView.phantomWalkSpeed, which Phantom's walk-speed patch adds.
Returns
Promise<number>
walkTo
walkTo(point: Point, options?: AvatarWalkOptions) => Promise<Standing>Walks the animal to a point along the room's paths, as a click on the floor does: everyone in the room sees it. Resolves with where it stopped: the point, or as near as the paths go.
Parameters
| Name | Type | |
|---|---|---|
point | Point | |
options optional | AvatarWalkOptions |
Returns
Promise<Standing>
Types
AvatarWalkOptions · Standing · Point
Example
const { position } = await phantom.aj.player.avatar.walkTo({ x: 400, y: 300 });whenStanding
whenStanding(options?: ActOptions) => Promise<Standing>Waits until the room draws the player's animal, and says where it stands. Throws TIMEOUT when it is not drawn in time (30 seconds by default).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<Standing>
Types
onNoClip
onNoClip(listener: (on: boolean) => void) => () => voidHears no-clip go on and off.
Parameters
| Name | Type | |
|---|---|---|
listener | (on: boolean) => void |
Returns
() => void. Call it to stop listening.
onRoomState
onRoomState(listener: (state: AvatarRoomState, previous: AvatarRoomState | null) => void) => () => voidHears the room state change: a room being joined, a den previewed.
Parameters
| Name | Type | |
|---|---|---|
listener | (state: AvatarRoomState, previous: AvatarRoomState | null) => void |
Returns
() => void. Call it to stop listening.
Types
onStanding
onStanding(listener: (standing: Standing | null, previous: Standing | null) => void, options?: { everyFrames?: number | undefined; }) => () => voidHears the animal move, turn, start or stop, read about eight times a second. Told once at the start; null while the room draws no animal.
Parameters
| Name | Type | |
|---|---|---|
listener | (standing: Standing | null, previous: Standing | null) => void | |
options optional | { everyFrames?: number | undefined; } |
Returns
() => void. Call it to stop listening.
Types
player.avatar.colors
The animal's colours, and the avatar editor's colour grids.
current
current() => Promise<AnimalColors | null>The animal's colours, or null before the player has an animal.
Returns
Promise<AnimalColors \| null>
Types
offer
offer(part: "color1" | "color2" | "eyes" | "pattern", indexes?: readonly number[] | undefined, options?: ColorOfferOptions) => Promise<ColorOffer>Offers other colours of the game's palette in one of the avatar editor's grids (all of them by default), now if the editor is open and each time it opens, until what it gives back is called. The grid is laid out to fit; picking a swatch is then the editor's own.
Parameters
| Name | Type | |
|---|---|---|
part | "color1" | "color2" | "eyes" | "pattern" | |
indexes optional | readonly number[] | undefined | |
options optional | ColorOfferOptions |
Returns
Promise<ColorOffer>
Types
ColorOfferOptions · ColorOffer
Example
const offer = await phantom.aj.player.avatar.colors.offer('color1');
console.log(offer.count, 'colours offered');paint
paint(change: ColorChange, options?: ActOptions) => Promise<AnimalColors>Paints the animal, as the editor's Done does (requestColorChange, ac): everyone sees it. Resolves with the colours once the server took them; throws REFUSED when it would not (a colour the account may not use).
Parameters
| Name | Type | |
|---|---|---|
change | ColorChange | |
options optional | ActOptions |
Returns
Promise<AnimalColors>
Types
ColorChange · ActOptions · AnimalColors
Example
palette
palette() => Promise<Palette | null>The game's palette, or null before the game has loaded it (it does as it starts).
Returns
Promise<Palette \| null>
Types
pick
pick(part: "color1" | "color2" | "eyes" | "pattern", index: number, options?: ActOptions) => Promise<number>Picks a colour in the open avatar editor's grid, as a click on the swatch does: the editor's own handler takes it, and Done paints it. Throws NOT_READY when the editor is not open.
Parameters
| Name | Type | |
|---|---|---|
part | "color1" | "color2" | "eyes" | "pattern" | |
index | number | |
options optional | ActOptions |
Returns
Promise<number>
Types
preview
preview(change: ColorChange, options?: ActOptions) => Promise<() => Promise<void>>Draws the animal in other colours on this screen only; nothing is sent. Calling what it gives back draws its own colours again.
Parameters
| Name | Type | |
|---|---|---|
change | ColorChange | |
options optional | ActOptions |
Returns
Promise<() => Promise<void>>
Types
onPaintResult
onPaintResult(listener: (accepted: boolean) => void) => () => voidHears the server answer a paint: whether it took the colours.
Parameters
| Name | Type | |
|---|---|---|
listener | (accepted: boolean) => void |
Returns
() => void. Call it to stop listening.
player.avatar.nameBar
The player's name bar.
current
current() => Promise<NameBar | null>The name bar as the server last took it, or null before the player has one.
Returns
Promise<NameBar \| null>
Types
editor
editor() => Promise<NameBar | null>The name bar the open avatar editor has pending (what Done would send), or null when the editor is not open.
Returns
Promise<NameBar \| null>
Types
set
set(look: Partial<Pick<NameBar, "color" | "badge" | "showLevel">>, options?: ActOptions) => Promise<NameBar>Changes the name bar, as the editor's Done does (the same ac that carries the colours): everyone sees it. Resolves with the name bar once the server took it; REFUSED when not.
Parameters
| Name | Type | |
|---|---|---|
look | Partial<Pick<NameBar, "color" | "badge" | "showLevel">> | |
options optional | ActOptions |
Returns
Promise<NameBar>
Types
Example
setInEditor
setInEditor(look: Partial<Pick<NameBar, "color" | "badge" | "showLevel">>, options?: ActOptions) => Promise<NameBar>Changes the name bar the open editor has pending, and draws it there; Done sends it. Throws NOT_READY when the editor is not open.
Parameters
| Name | Type | |
|---|---|---|
look | Partial<Pick<NameBar, "color" | "badge" | "showLevel">> | |
options optional | ActOptions |
Returns
Promise<NameBar>
Types
player.animals
The player's animals: switching, making and removing them, and the kinds of animal.
all
all() => Promise<Animal[]>The player's animals, in the switcher's own slot order. Empty before the switcher has them.
Returns
Promise<Animal[]>
Types
Example
for (const animal of await phantom.aj.player.animals.all()) {
console.log(animal.avName, animal.playing ? '(playing)' : '', animal.usable ? '' : '(locked)');
}buySlot
buySlot(options?: ActOptions) => Promise<void>Buys room for one more animal (ab), at Animal Jam's price. Throws REFUSED when not sold.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
chooseUsable
chooseUsable(avInvIds: readonly number[], options?: ActOptions) => Promise<void>Chooses which one or two animals a non-member keeps using (ao), as the switcher asks when a membership ends, then asks for the list again so the client's slot flags are the server's. Throws REFUSED when the server does not take the choice.
Parameters
| Name | Type | |
|---|---|---|
avInvIds | readonly number[] | |
options optional | ActOptions |
Returns
Promise<void>
Types
closeCreator
closeCreator(options?: ActOptions) => Promise<void>Closes the avatar creator (GuiManager.closeAvatarCreator), resolving once it is gone.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
create
create(animal: NewAnimal, options?: CreateOptions) => Promise<CreatedAnimal>Adds a new animal to the account (aa), which is bought: the switcher charges 1000 gems, a diamond animal its diamonds, a shop its price. It needs a free slot (slots, buySlot). It is put in the switcher's list, and is not switched to unless fromCreator (see CreateOptions). Throws REFUSED with the server's status when it is not added.
Parameters
| Name | Type | |
|---|---|---|
animal | NewAnimal | |
options optional | CreateOptions |
Returns
Promise<CreatedAnimal>
Types
NewAnimal · AvatarNameIds · CreateOptions · CreatedAnimal
Example
const added = await phantom.aj.player.animals.create({ avTypeId: 13, nameIds: [1001, 2002, 3003] });
await phantom.aj.player.animals.switchTo(added.perUserAvId);createFirst
createFirst(avTypeId: number, nameIds: AvatarNameIds, options?: ActOptions) => Promise<void>Adds the first animal to an account made without one, the "fast pass" (afp), which the client offers only while userInfo.needFastPass is set. The client's own handler takes the answer, asks for the list again and joins the world. Throws REFUSED when it is not added.
Parameters
| Name | Type | |
|---|---|---|
avTypeId | number | |
nameIds | AvatarNameIds | |
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<Animal | null>The animal the player is playing, or null before the client has one.
Returns
Promise<Animal \| null>
Types
get
get(perUserAvId: number) => Promise<Animal | null>One of the player's animals, by perUserAvId; null when the switcher has no such animal.
Parameters
| Name | Type | |
|---|---|---|
perUserAvId | number |
Returns
Promise<Animal \| null>
Types
known
known(userName?: string | undefined) => Promise<KnownAnimal[]>A player's animals as the client has cached them (UserInfo.avList): every one of the player's own when userName is left out, and for anyone else the ones the client has been told of (the one they were seen as, those their buddy card showed). By perUserAvId.
Parameters
| Name | Type | |
|---|---|---|
userName optional | string | undefined |
Returns
Promise<KnownAnimal[]>
Types
record
record(userName: string, perUserAvId?: number | undefined) => Promise<KnownAnimal | null>One cached animal of a player's (getAvatarInfoByUsernamePerUserAvId, which matches the name in any case), or the one they were last seen as when perUserAvId is left out (getAvatarInfoByUserName). Null when the client has none.
Parameters
| Name | Type | |
|---|---|---|
userName | string | |
perUserAvId optional | number | undefined |
Returns
Promise<KnownAnimal \| null>
Types
refresh
refresh(options?: ActOptions) => Promise<ListedAnimal[]>Asks the server for the player's animals again (requestAvatarList, al), as joining the world does, and resolves with its list. The client's own callback takes the answer too, so its slot flags and its cache are the server's afterwards.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<ListedAnimal[]>
Types
remove
remove(perUserAvId: number, options?: ActOptions) => Promise<void>Deletes one of the player's animals for good, as the switcher's delete button does (AvatarSwitch.removeAvatar, ak), which also takes it off the client's list and frees its items. Cannot be undone. Throws REFUSED for the last animal left, and when the server says no.
Parameters
| Name | Type | |
|---|---|---|
perUserAvId | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
slots
slots() => Promise<AnimalSlots>How many animals the player has and may use, as the switcher counts them. Zeroes before.
Returns
Promise<AnimalSlots>
Types
suits
suits(enviroType: number) => Promise<boolean>Whether the player's animal can go somewhere, as the client checks before a room or a game (AvatarManager.isValidEnviro): 1 land, 2 ocean, 4 air, or several added. False before the client has the animal.
Parameters
| Name | Type | |
|---|---|---|
enviroType | number |
Returns
Promise<boolean>
switcher
switcher() => Promise<SwitcherState>What the switcher is in the middle of: a switch, a slot being bought, the player being made to choose two animals to keep. All of it is the client's own copy of the server's answers.
Returns
Promise<SwitcherState>
Types
switchTo
switchTo(perUserAvId: number, options?: ActOptions) => Promise<AnimalSwitch>Switches to another of the player's animals, as the switcher does (switchAvatars, as), and resolves with the animal switched to once the server has said so. Throws NOT_READY for an animal the switcher does not hold, and REFUSED when the server says no.
Parameters
| Name | Type | |
|---|---|---|
perUserAvId | number | |
options optional | ActOptions |
Returns
Promise<AnimalSwitch>
Types
Example
const [, second] = await phantom.aj.player.animals.all();
if (second?.usable) await phantom.aj.player.animals.switchTo(second.perUserAvId);onChange
onChange(listener: (change: AnimalChange) => void) => () => voidHears the server change the player's animals: a list arriving, an animal added or removed, a slot bought, the first animal added, the usable animals chosen. Whoever asked: the client's own windows too.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: AnimalChange) => void |
Returns
() => void. Call it to stop listening.
Types
onSwitch
onSwitch(listener: (change: AnimalSwitch) => void) => () => voidHears anyone in the room switch animals, the player included (as). Refused switches are not told: switchTo throws for those.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: AnimalSwitch) => void |
Returns
() => void. Call it to stop listening.
Types
player.animals.kinds
The kinds of animal the game has.
asItem
asItem(avTypeId: number, options?: KindItemOptions) => Promise<KindItem | null>What the animal shop makes of a kind: its price now, its ribbon, where it may go, as the client's own AvatarItem works it out (a sale halves the price, a diamond kind is priced by the diamond shop). The item is built, read and taken down again in one message; nothing is drawn or sent. Null when the client has no def for the kind.
Parameters
| Name | Type | |
|---|---|---|
avTypeId | number | |
options optional | KindItemOptions |
Returns
Promise<KindItem \| null>
Types
count
count() => Promise<number>How many kinds the def pack has (getAvatarDefsCount); 0 before it is in.
Returns
Promise<number>
creation
creation() => Promise<CreationKinds>The kinds the avatar creator offers, by the index its arrows count by, with the diamond shop's counts. Empty until the creator has been opened once, which is when the client builds them.
Returns
Promise<CreationKinds>
Types
custom
custom(customAvId: number) => Promise<AnimalKind | null>A recycled kind by its customAvId (getAvatarDefByAvType(id, true)); null when unknown.
Parameters
| Name | Type | |
|---|---|---|
customAvId | number |
Returns
Promise<AnimalKind \| null>
Types
customsOf
customsOf(avTypeId: number) => Promise<AnimalKind[]>Every recycled kind built on one kind (getCustomAvatarDefsByAvRefId); none when it has none.
Parameters
| Name | Type | |
|---|---|---|
avTypeId | number |
Returns
Promise<AnimalKind[]>
Types
get
get(avTypeId: number) => Promise<AnimalKind | null>A kind of animal by its avTypeId (getAvatarDefByAvType(id, false)), with its name translated. Null for a kind the client does not know, or before the pack is in.
Parameters
| Name | Type | |
|---|---|---|
avTypeId | number |
Returns
Promise<AnimalKind \| null>
Types
Example
const kind = await phantom.aj.player.animals.kinds.get(13);
if (kind) console.log(kind.title, kind.cost, kind.membersOnly ? 'members' : 'everyone');hasSeen
hasSeen(avTypeId: number, options?: { customAvId?: number | undefined; }) => Promise<boolean>Whether the player has met a kind, from the bit the client keeps per kind in a user var (AvatarUtility.getAvatarDefIsViewableWithAvId), which is how the journey book knows.
Parameters
| Name | Type | |
|---|---|---|
avTypeId | number | |
options optional | { customAvId?: number | undefined; } |
Returns
Promise<boolean>
isLoaded
isLoaded() => Promise<boolean>Whether the def pack of kinds is in (userInfo.avtDefsCached).
Returns
Promise<boolean>
load
load(options?: ActOptions) => Promise<void>Has the client load the def pack of kinds, as it does at start-up (AvatarXtCommManager.requestAvatarInfo), and resolves once it is in. Whatever the client was itself waiting on the pack for is handed back to it. Resolves at once when it is already in.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
offsets
offsets(avTypeId: number) => Promise<KindOffsets | null>Where the client draws things over a kind: the name bar, a chat balloon's tail, an emote's background, the shop window, the talking head, the photo, the minigame lobby. One message. A kind the table does not list answers the client's own fallback; null when it cannot answer.
Parameters
| Name | Type | |
|---|---|---|
avTypeId | number |
Returns
Promise<KindOffsets \| null>
Types
playedBy
playedBy(userName?: string | undefined) => Promise<AnimalKind | null>The kind a player in the room is playing, recycled kinds included (getAvatarDefByAvatar, as the item windows ask it): the player's own when userName is left out. Null when there is no such animal in the room or no def for it.
Parameters
| Name | Type | |
|---|---|---|
userName optional | string | undefined |
Returns
Promise<AnimalKind \| null>
Types
player.animals.window
The animal switcher window, as the player sees and presses it.
current
current() => Promise<AvatarSwitcherView | null>The switcher as it stands, or null when it is not open or its art is not in.
Returns
Promise<AvatarSwitcherView \| null>
Types
pressSlot
pressSlot(index: number, options?: ActOptions) => Promise<void>Presses a slot, as the player does, drawing the slots before it first as the client would.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
rebuild
rebuild(options?: ActOptions) => Promise<void>Draws the switcher's slots again from the client's own list (buildWindows).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
setMessage
setMessage(message: string | null, options?: ActOptions) => Promise<void>Shows a warning of your own in the switcher's own warning box, darkening the rest as the client does, or takes it down with null. Only this screen changes.
Parameters
| Name | Type | |
|---|---|---|
message | string | null | |
options optional | ActOptions |
Returns
Promise<void>
Types
setRecycling
setRecycling(on: boolean, options?: ActOptions) => Promise<void>Turns recycling on or off, as its recycle button does, and confirms the switcher did.
Parameters
| Name | Type | |
|---|---|---|
on | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
slots
slots() => Promise<SwitcherSlot[]>Every slot, with the animal in it from the client's own list (avatar.AvatarSwitch).
Returns
Promise<SwitcherSlot[]>
Types
onChange
onChange(listener: (change: SwitcherChange) => void) => () => voidHears what happens on the switcher: ready, a slot pressed, a switch, a recycle, a warning.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: SwitcherChange) => void |
Returns
() => void. Call it to stop listening.
Types
player.looks
What the player's animal wears.
bodyMods
bodyMods() => Promise<BodyMod[]>Every pair of eyes and every pattern an animal can wear (ItemXtCommManager._bodyItemDefIds, what the editor's tabs list), with the one worn now marked. They are no inventory items: all are the player's to wear. Empty before the client has loaded its item definitions.
Returns
Promise<BodyMod[]>
Types
clearTryOn
clearTryOn(options?: ActOptions) => Promise<number[]>Takes every tried-on piece off, and resolves with the def ids that came off.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<number[]>
Types
combatValues
combatValues() => Promise<CombatValues | null>What the adventures make of what the player's animal wears: its attacks, healing, defence, and a shaman's words. The client's own sums, never the server's. Null before there is an animal.
Returns
Promise<CombatValues \| null>
Types
current
current() => Promise<Look | null>How the player's animal looks now, as the client draws it: its colours, eyes, pattern, and the clothing on it (pieces tryOn put on are left out). Null before the player has an animal.
Returns
Promise<Look \| null>
Types
drawColors
drawColors(colors: readonly [number, number, number], options?: ActOptions) => Promise<void>Repaints the player's animal on this screen only, from three packed colours (Avatar.copyColors), and resolves once the client holds them. The next thing the client draws the animal from puts its real colours back.
Parameters
| Name | Type | |
|---|---|---|
colors | readonly [number, number, number] | |
options optional | ActOptions |
Returns
Promise<void>
Types
dressing
dressing() => Promise<AvatarDressing | null>What the player's animal can dress from (Avatar.inventoryBodyMod, inventoryClothing), and how the client treats it. Explains why a piece will not go on: ocean clothing is not even in the land list. Null before there is an animal.
Returns
Promise<AvatarDressing \| null>
Types
hideShown
hideShown(what: HideWhat, options?: ActOptions) => Promise<void>Undresses the player's animal on this screen only (AccessoryState.hideAll, hideAllExceptBase, hideAllClothingArticles) and resolves once nothing of it is drawn. Nothing is sent, but the client marks the pieces off as it hides them, so do not put a look on from this state; rejoining the room draws the animal again.
Parameters
| Name | Type | |
|---|---|---|
what | HideWhat | |
options optional | ActOptions |
Returns
Promise<void>
Types
isShown
isShown(what: { invId: number; } | { accId: number; } | { layer: number; }) => Promise<boolean>Whether the client draws one thing on the player's animal, by whichever id is to hand (AccessoryState.isAccessoryVisibleByItemId, ByAccId, ByLayer). Two colours of one hat share an accId and not an invId. False when there is no animal.
Parameters
| Name | Type | |
|---|---|---|
what | { invId: number; } | { accId: number; } | { layer: number; } |
Returns
Promise<boolean>
of
of(userName: string, options?: ActOptions) => Promise<Look | null>How another player's animal looks, wherever they are, as the player search sees it (ag). Null when they are offline or there is no such player; throws TIMEOUT when the server does not answer.
Parameters
| Name | Type | |
|---|---|---|
userName | string | |
options optional | ActOptions |
Returns
Promise<Look \| null>
Types
Example
const look = await phantom.aj.player.looks.of('friend');
if (look) await phantom.aj.player.looks.putOn(look);plan
plan(look: Look, options?: LookOptions & ActOptions) => Promise<LookPlan>What putting a look on would do, without doing it: which of the player's items it would put on and take off, which pieces they do not own, and whether the colours change. Reads the player's whole inventory, asking the server for it the first time as the client does.
Parameters
| Name | Type | |
|---|---|---|
look | Look | |
options optional | LookOptions & ActOptions |
Returns
Promise<LookPlan>
Types
LookOptions · LookPlan · LookItemPlan · AvatarColors · ActOptions · Look
putOn
putOn(look: Look, options?: LookOptions & ActOptions) => Promise<LookResult>Puts a look on the player's animal from what they own, and resolves once Animal Jam took it: the clothing as closing the avatar editor sends it (iu), then the colours (ap). Pieces not owned, or not wearable on this animal, are left out, and plan in the result says which. Throws REFUSED when the server says no to either.
Parameters
| Name | Type | |
|---|---|---|
look | Look | |
options optional | LookOptions & ActOptions |
Returns
Promise<LookResult>
Types
LookResult · ActOptions · Look · LookOptions
Example
const look = await phantom.aj.player.looks.of('friend');
if (look) {
const { plan } = await phantom.aj.player.looks.putOn(look, { otherColours: true });
console.log(plan.items.filter((item) => item.invId === null).length, 'pieces missing');
}shown
shown() => Promise<ShownLook | null>What the client is drawing on the player's animal, from its own record of it (AccessoryState): every body mod and piece of clothing with the layer it is on, pieces tryOn put on included. Null before the player has an animal.
Returns
Promise<ShownLook \| null>
Types
takeOff
takeOff(defId: number, options?: ActOptions) => Promise<void>Takes a tried-on piece off again. A piece that is not tried on is left alone.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
tryingOn
tryingOn() => Promise<number[]>The pieces tried on now, by def id, read from what the client draws.
Returns
Promise<number[]>
tryOn
tryOn(defId: number, options?: TryOnOptions) => Promise<TryOn>Puts one piece on the player's animal on this screen only, owned or not: built from the client's own definitions and drawn, never sent. The handle it resolves with takes it off; so do takeOff(defId) and a reload of the client. Throws REFUSED for anything that is not worn on an animal, or an id this game has no definition for.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options optional | TryOnOptions |
Returns
Promise<TryOn>
Types
Example
wearBodyMod
wearBodyMod(kind: "eyes" | "pattern", defId: number, options?: ActOptions) => Promise<{ eyes: number; pattern: number; }>Puts one pair of eyes or one pattern on the player's animal, swapping out the one on now in the same request (iu, by negative def ids), and resolves with the eyes and pattern after. 0 takes the pattern off. Throws REFUSED when the server says no (a members' one, or one this animal cannot wear).
Parameters
| Name | Type | |
|---|---|---|
kind | "eyes" | "pattern" | |
defId | number | |
options optional | ActOptions |
Returns
Promise<{ eyes: number; pattern: number; }>
Types
onChange
onChange(listener: (change: LookChange) => void) => () => voidHears looks change as the server says it: clothing put on or taken off (il), whoever's it is, and the player's colours painted (ap), whoever asked, the avatar editor included.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: LookChange) => void |
Returns
() => void. Call it to stop listening.
Types
onLook
onLook(listener: (look: Look) => void) => () => voidHears the player's look: once as soon as it can be read, and again after every change that leaves the animal looking different, whoever made it. Changes that leave it looking the same (a stranger's clothing, a piece put back) wake nobody; only one read is in flight at a time.
Parameters
| Name | Type | |
|---|---|---|
listener | (look: Look) => void |
Returns
() => void. Call it to stop listening.
Types
player.looks.mannequins
The den mannequins in the den on screen.
all
all() => Promise<Mannequin[]>Every mannequin in the den on screen, in the client's order; none outside a den.
Returns
Promise<Mannequin[]>
dress
dress(invId: number, clothing: Partial<Record<MannequinSlotName, { defId: number; color?: number | undefined; }>>, options?: ActOptions) => Promise<Mannequin>Draws clothing on a mannequin by definition, owned or not, on this screen (MannequinData.headDefId, headColor, … then refreshAvatarItems). Shows on a mannequin that is not the player's, which the client draws from these; the player's own are drawn from their inventory ids, so this changes nothing there. Never sent.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
clothing | Partial<Record<MannequinSlotName, { defId: number; color?: number | undefined; }>> | |
options optional | ActOptions |
Returns
Promise<Mannequin>
Types
get
get(invId: number) => Promise<Mannequin | null>One mannequin, by the invId all gives, or null when the den on screen has none such.
Parameters
| Name | Type | |
|---|---|---|
invId | number |
Returns
Promise<Mannequin \| null>
paint
paint(invId: number, colors: MannequinColors, options?: ActOptions) => Promise<Mannequin>Paints a mannequin (MannequinData.updateColors) and draws it again, resolving with it as the client then holds it.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
colors | MannequinColors | |
options optional | ActOptions |
Returns
Promise<Mannequin>
Types
redraw
redraw(invId: number, options?: ActOptions) => Promise<Mannequin>Has the client build the animal on a mannequin again from what it holds.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
options optional | ActOptions |
Returns
Promise<Mannequin>
Types
takeOff
takeOff(invId: number, itemInvId: number, options?: ActOptions) => Promise<Mannequin>Takes one piece off a mannequin by its inventory id (MannequinData.hasThisInvIdOnAndRemove). Throws REFUSED when the mannequin does not wear it.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
itemInvId | number | |
options optional | ActOptions |
Returns
Promise<Mannequin>
Types
undress
undress(invId: number, options?: ActOptions) => Promise<Mannequin>Takes every piece of the player's clothing off a mannequin (MannequinData.removeItems).
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
options optional | ActOptions |
Returns
Promise<Mannequin>
Types
player.pets
The player's pets.
active
active() => Promise<Pet | null>The pet out beside the player now (PetManager.myActivePetInvId), or null for none.
Returns
Promise<Pet \| null>
adopt
adopt(request: AdoptRequest, options?: ActOptions) => Promise<Adoption>Adopts a pet, as the pet creator's Done does: a kind the account has unlocked (sendPetCreateRequest, pc), or one bought as a shop item (sendPetShopBuyRequest, pb) when itemDefId is given. Resolves with the pet and the balance left; throws REFUSED when the server makes none.
Parameters
| Name | Type | |
|---|---|---|
request | AdoptRequest | |
options optional | ActOptions |
Returns
Promise<Adoption>
Types
Example
const look = await phantom.aj.player.pets.kinds.random(1);
if (look) await phantom.aj.player.pets.adopt({ shopId: 1, look, name: { first: 3, second: 7 } });all
all() => Promise<Pet[]>Every pet the player has, in the client's order; none before the client has the list.
Returns
Promise<Pet[]>
bringOut
bringOut(invId: number, options?: ActOptions) => Promise<Pet>Brings out one of the player's pets, as the pet inventory does (sendPetSwitchRequest, ps), and resolves with it once the server has. Throws REFUSED when the server says no: a pet this animal or room cannot have (canBringOut asks first).
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
options optional | ActOptions |
Returns
Promise<Pet>
Types
canBringOut
canBringOut(pet: PetIdentity) => Promise<boolean>Whether the player could bring a pet out where they stand, as the pet inventory decides it (PetManager.canCurrAvatarUsePet): a walking pet is refused in the ocean, an unhatched egg anywhere but on land. False outside a room and for a kind the client does not know.
Parameters
| Name | Type | |
|---|---|---|
pet | PetIdentity |
Returns
Promise<boolean>
free
free(invId: number, options?: ActOptions) => Promise<void>Frees one of the player's pets for good (sendPetDismissRequest, pd).
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
get
get(invId: number) => Promise<Pet | null>One of the player's pets by its invId, or null when they have none by it.
Parameters
| Name | Type | |
|---|---|---|
invId | number |
Returns
Promise<Pet \| null>
hasUnnamedEgg
hasUnnamedEgg() => Promise<boolean>Whether a hatched egg pet is waiting for a name (hasAtLeastOneHatchedEggPet).
Returns
Promise<boolean>
hideMasteryBadge
hideMasteryBadge(invId: number, options?: ActOptions) => Promise<PetLookChange>Hides a pet's mastery badge; resolves with its new look.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
options optional | ActOptions |
Returns
Promise<PetLookChange>
Types
items
items() => Promise<PetAsItem[]>The player's pets as the inventory and the shops see them (PetManager.myPetListAsIitem): what each is worth, its ribbon, and where it may go now.
Returns
Promise<PetAsItem[]>
max
max() => Promise<number | null>How many pets the account may hold (PetManager.getPetInventoryMax); null before login.
Returns
Promise<number \| null>
nameEgg
nameEgg(invId: number, name: { first: number; second: number; }, options?: ActOptions) => Promise<string>Names a hatched egg pet from the pet creator's two name lists (sendPetEggNameRequest, pn), and resolves with the name the server kept.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
name | { first: number; second: number; } | |
options optional | ActOptions |
Returns
Promise<string>
Types
picture
picture(pet: PetPictureSubject, options?: PetPictureOptions) => Promise<string>Draws any pet's look to a PNG data URL, off screen, as the client's windows draw one (PetManager.getGuiPet). Waits for the pet's art to load; throws TIMEOUT when it does not.
Parameters
| Name | Type | |
|---|---|---|
pet | PetPictureSubject | |
options optional | PetPictureOptions |
Returns
Promise<string>
Example
const [pet] = await phantom.aj.player.pets.all();
if (pet) {
const img = document.createElement('img');
img.src = await phantom.aj.player.pets.picture(pet, { maxSize: 96 });
}putAway
putAway(options?: ActOptions) => Promise<void>Puts the player's pet away (sendPetSwitchRequest(0)), once the server has.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
refresh
refresh(options?: ActOptions) => Promise<Pet[]>Asks the server for the player's pets again, and resolves with them once it has answered.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<Pet[]>
Types
restyle
restyle(worn: PetWornSlots, options?: ActOptions & { enviroType?: number | undefined; }) => Promise<PetRestyle>Changes what the pet that is out wears, as the pet salon does (sendPetItemRequest, pi), and resolves with its new look and the gems left. The room's world is sent with it, as the salon sends it, unless enviroType says otherwise.
Parameters
| Name | Type | |
|---|---|---|
worn | PetWornSlots | |
options optional | ActOptions & { enviroType?: number | undefined; } |
Returns
Promise<PetRestyle>
Types
showMasteryBadge
showMasteryBadge(invId: number, options?: ActOptions) => Promise<PetLookChange>Shows a pet's mastery badge (sendPetMasteryRequest, pm); resolves with its new look.
Parameters
| Name | Type | |
|---|---|---|
invId | number | |
options optional | ActOptions |
Returns
Promise<PetLookChange>
Types
onAdopted
onAdopted(listener: (adoption: Adoption) => void) => () => voidHears a pet adopted or bought (pc), however it was asked for.
Parameters
| Name | Type | |
|---|---|---|
listener | (adoption: Adoption) => void |
Returns
() => void. Call it to stop listening.
onEggNamed
onEggNamed(listener: (named: { invId: number; name: string; }) => void) => () => voidHears a hatched egg pet named (pn): the pet and the name the server kept.
Parameters
| Name | Type | |
|---|---|---|
listener | (named: { invId: number; name: string; }) => void |
Returns
() => void. Call it to stop listening.
onFreed
onFreed(listener: (invId: number) => void) => () => voidHears one of the player's pets freed (pd), by its invId.
Parameters
| Name | Type | |
|---|---|---|
listener | (invId: number) => void |
Returns
() => void. Call it to stop listening.
onList
onList(listener: (list: { userName: string; pets: ListedPet[]; }) => void) => () => voidHears a player's pets listed by the server (pl): the player's own, or someone else's.
Parameters
| Name | Type | |
|---|---|---|
listener | (list: { userName: string; pets: ListedPet[]; }) => void |
Returns
() => void. Call it to stop listening.
onLookChange
onLookChange(listener: (change: PetLook & { invId: number; } & { cause: "mastery" | "salon"; gems: number | null; }) => void) => () => voidHears a pet's look changed by the server: a mastery badge shown or hidden (pm), or the pet salon (pi, with the gems left).
Parameters
| Name | Type | |
|---|---|---|
listener | (change: PetLook & { invId: number; } & { cause: "mastery" | "salon"; gems: number | null; }) => void |
Returns
() => void. Call it to stop listening.
onSwitch
onSwitch(listener: (change: PetSwitch) => void) => () => voidHears anyone in the room bring a pet out or put one away (ps), the player too (self). Refusals are not told; bringOut throws them.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: PetSwitch) => void |
Returns
() => void. Call it to stop listening.
player.pets.kinds
The kinds of pet there are, and the client's own answers about them: phantom.aj.player.pets.kinds. Read from the def pack the client loads at startup (PetManager._petDefs), so nothing here is sent, and everything answers null or [] before that pack has arrived (onLoaded).
all
all() => Promise<PetKind[]>Every kind of pet in the def pack, in def id order; none before the pack has arrived.
Returns
Promise<PetKind[]>
appearance
appearance(look: PetLook) => Promise<PetAppearance | null>How a look is drawn, unpacked into the slots the pet creator edits (PetManager.unpackPetBits). Works for any pet's look: the player's, or one seen in a room. Null when the client cannot be asked.
Parameters
| Name | Type | |
|---|---|---|
look | PetLook |
Returns
Promise<PetAppearance \| null>
get
get(defId: number) => Promise<PetKind | null>One kind of pet (PetManager.getPetDef, which is _petDefs[defId]), or null for a kind the client does not know. Its price, its currency, where it goes and whether it is an egg.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<PetKind \| null>
goesEverywhere
goesEverywhere(pet: PetIdentity) => Promise<boolean>Whether a pet may go both on land and in the ocean (canPetGoInBothEnviroTypes).
Parameters
| Name | Type | |
|---|---|---|
pet | PetIdentity |
Returns
Promise<boolean>
goesWith
goesWith(pet: PetIdentity, options?: { enviroTypeFlag?: number | undefined; }) => Promise<boolean>Whether a pet may go with an animal (canPetGoInEnviroType): the player's own animal, or one of the given environment flag.
Parameters
| Name | Type | |
|---|---|---|
pet | PetIdentity | |
options optional | { enviroTypeFlag?: number | undefined; } |
Returns
Promise<boolean>
hasHatched
hasHatched(createdTs: number) => Promise<boolean>Whether an egg adopted at createdTs has hatched: three days, on the server's clock.
Parameters
| Name | Type | |
|---|---|---|
createdTs | number |
Returns
Promise<boolean>
idOf
idOf(name: string) => Promise<number | null>A kind's def id, by its name as the client spells it (PetManager.petDefIdForName).
Parameters
| Name | Type | |
|---|---|---|
name | string |
Returns
Promise<number \| null>
isGroundType
isGroundType(type: number) => Promise<boolean>Whether a kind's type walks (PetManager.isGround).
Parameters
| Name | Type | |
|---|---|---|
type | number |
Returns
Promise<boolean>
isUnlocked
isUnlocked(defId: number) => Promise<boolean>Whether the account has unlocked a kind (PetManager.isPetAvailable); false before login.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<boolean>
name
name(defId: number) => Promise<string | null>A kind's title (Bunny), by def id (PetManager.petNameForDefId); null when unknown.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<string \| null>
pack
pack(slots: readonly number[]) => Promise<PetLook | null>Slots, as appearance gives them, packed into a look (PetManager.packPetBits).
Parameters
| Name | Type | |
|---|---|---|
slots | readonly number[] |
Returns
Promise<PetLook \| null>
random
random(defId: number) => Promise<PetLook | null>A random look for a kind, as the pet creator rolls one (createRandomPet, then packPetBits), in one message. Worked out in the client and sent nowhere. Null for a kind the client cannot roll.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<PetLook \| null>
Example
const look = await phantom.aj.player.pets.kinds.random(1);
if (look) await phantom.aj.player.pets.picture(look);unlocked
unlocked() => Promise<number[]>The kinds the account has unlocked, by def id (PetManager._unlockedPets, the bit field the server sends at login as pu). The pet creator offers these without a purchase.
Returns
Promise<number[]>
worldOf
worldOf(pet: PetIdentity, options?: { enviroTypeFlag?: number | undefined; }) => Promise<number | null>The world a pet would be in beside an animal (getEnviroTypeByPetType): 0 land, 1 ocean, 2 air. The player's own animal unless a flag is given; null for an unknown kind.
Parameters
| Name | Type | |
|---|---|---|
pet | PetIdentity | |
options optional | { enviroTypeFlag?: number | undefined; } |
Returns
Promise<number \| null>
onLoaded
onLoaded(listener: () => void) => () => voidHears the def pack arrive (PetManager.petDefs being set), after which all and get have something to say. It arrives once per load of the client.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onUnlocked
onUnlocked(listener: (defIds: number[]) => void) => () => voidHears the server say which kinds the account has unlocked (pu), as def ids.
Parameters
| Name | Type | |
|---|---|---|
listener | (defIds: number[]) => void |
Returns
() => void. Call it to stop listening.
player.pets.adoption
Adopt a Pet, the cards codes on real-world toys add to the player's checklist: phantom.aj.player.pets.adoption. Read from AdoptAPetManager, which holds the player's cards (from their login) and the cards' def pack (loaded beside it); both answer empty until they are in.
cards
cards() => Promise<AdoptionCard[]>The cards the player holds (AdoptAPetManager.usableAdoptAPetDataCopy), in the client's own order, which is by def id. The checklist shows them by invId, highest first.
Returns
Promise<AdoptionCard[]>
countOf
countOf(userName: string, options?: ActOptions) => Promise<number>How many cards another player holds (requestPetAdoptUsableCount, answered by padc).
Parameters
| Name | Type | |
|---|---|---|
userName | string | |
options optional | ActOptions |
Returns
Promise<number>
Types
hasAny
hasAny() => Promise<boolean>Whether the player holds any card at all (hasAtLeastOneUsableAdoptAPet).
Returns
Promise<boolean>
hasUnseen
hasUnseen() => Promise<boolean>Whether a held card has not been looked at yet (hasUnseenPetData): the burst the pet inventory draws over its checklist button. markSeen turns it off.
Returns
Promise<boolean>
kind
kind(defId: number) => Promise<AdoptionCardKind | null>What one card is (getAdoptAPetDef), and whether the player holds it; null when unknown.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<AdoptionCardKind \| null>
kinds
kinds() => Promise<AdoptionCardKind[]>Every card there is (AdoptAPetManager.allAdoptAPetDefs), with whether the player holds it.
Returns
Promise<AdoptionCardKind[]>
markSeen
markSeen(defIds: number | readonly number[], options?: ActOptions) => Promise<void>Marks cards as seen, as the checklist does: on the client's own copy (setUsableAdoptAPetDefAsSeen, which hasUnseen reads), then to the server (requestPetAdoptUsableSeenSet, pads, which makes it last past this session). The server does not answer pads, so this confirms the client's copy, and throws REFUSED when a card the player holds still reads as unseen.
Parameters
| Name | Type | |
|---|---|---|
defIds | number | readonly number[] | |
options optional | ActOptions |
Returns
Promise<void>
Types
of
of(userName: string, options?: ActOptions) => Promise<AdoptionCardRef[]>Another player's cards, as their buddy card's checklist asks for them (requestPetAdoptUsableData, answered by pad). Throws REFUSED when the server says no.
Parameters
| Name | Type | |
|---|---|---|
userName | string | |
options optional | ActOptions |
Returns
Promise<AdoptionCardRef[]>
Types
series
series() => Promise<AdoptionSeries[]>How far along each series the player is: one entry per series the checklist has a tab for (allAdoptAPetDefsNonIndexedBySeriesSortedByName, NUM_TIERS), whether or not they hold any.
Returns
Promise<AdoptionSeries[]>
tier
tier(options?: { gifts?: number | undefined; }) => Promise<AdoptionTier>Where a gift count stands on the tiered gift path (TIERED_GIFT_COUNTS, getCurrTierGiftCountAmount): the player's own count (numTieredGiftCount, user var 426), or gifts to ask where someone else would stand, as another player's checklist does.
Parameters
| Name | Type | |
|---|---|---|
options optional | { gifts?: number | undefined; } |
Returns
Promise<AdoptionTier>
total
total() => Promise<number | null>How many cards there are in all (totalAdoptAPetDefs); null before the def pack is in.
Returns
Promise<number \| null>
onChecklist
onChecklist(listener: (cards: AdoptionCardRef[]) => void) => () => voidHears a player's cards arrive (pad), whoever asked for them. Refusals are not told.
Parameters
| Name | Type | |
|---|---|---|
listener | (cards: AdoptionCardRef[]) => void |
Returns
() => void. Call it to stop listening.
onCount
onCount(listener: (count: number) => void) => () => voidHears a player's card count arrive (padc), whoever asked for it.
Parameters
| Name | Type | |
|---|---|---|
listener | (count: number) => void |
Returns
() => void. Call it to stop listening.
player.pets.world
The pet out beside the player in the room (pet.WorldPet, AvatarWorldView._pet): phantom.aj.player.pets.world. The view builds a new pet for every room and every pet brought out, so all of this follows the path rather than one object. Everything that draws is drawn on this screen only unless it says it is seen by everyone.
current
current() => Promise<PetInWorld | null>The pet beside the player as it is drawn now, or null when none is out or drawn yet.
Returns
Promise<PetInWorld \| null>
drawLook
drawLook(look: PetLook | { uBits: number; }, options?: ActOptions) => Promise<void>Draws the pet in another look, here only: the whole look (PetBase.updateAllBits) or only what it wears (updateUBits). The player's pet is not changed; pets.restyle does that. Throws REFUSED when the pet's art has not loaded, since the client draws nothing then.
Parameters
| Name | Type | |
|---|---|---|
look | PetLook | { uBits: number; } | |
options optional | ActOptions |
Returns
Promise<void>
Types
facts
facts() => Promise<PetFacts | null>What the client knows of the pet it draws (pet.PetBase), or null when none is drawn.
Returns
Promise<PetFacts \| null>
keep
keep(values: PetKeep, options?: ActOptions) => Promise<() => Promise<void>>Keeps the pet beside the player at the values given, written in the game every frame so the walk cannot put its own back, and onto every pet the client builds after. Calling what it gives back puts back what was there.
Parameters
| Name | Type | |
|---|---|---|
values | PetKeep | |
options optional | ActOptions |
Returns
Promise<() => Promise<void>>
Types
Example
const big = await phantom.aj.player.pets.world.keep({ scale: 2, side: 40 });poke
poke(options?: ActOptions & SeenBy) => Promise<void>Has the pet hop, as a click on it does (WorldPet.onClick). Seen by everyone by default, as the click is, which sends the pet action (UserCommXtCommManager.sendPetAction(0)); with seenBy: 'me' it is drawn here only. The server does not answer a pet action, so this resolves once the client has drawn the hop and sent it.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions & SeenBy |
Returns
Promise<void>
Types
redraw
redraw(options?: ActOptions) => Promise<void>Builds the pet beside the player again from the client's record of it (AvatarManager._needToResetPet, setupActivePet), as the client does after a change it cannot draw in place.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
setTrickAnimation
setTrickAnimation(trick: PetTrick, animation: number, options?: ActOptions) => Promise<() => Promise<void>>Changes the animation a trick plays for every pet (WorldPet._actionLookup, the static table trick reads), until the function it gives back is called, which puts the table back.
Parameters
| Name | Type | |
|---|---|---|
trick | PetTrick | |
animation | number | |
options optional | ActOptions |
Returns
Promise<() => Promise<void>>
Types
sparkle
sparkle(sparkleId: number, options?: ActOptions & SeenBy) => Promise<void>Puts a sparkle on the pet, by the sparkle's def id; 0 takes it off. Drawn here only by default (WorldPet.setAction(1, id)); seenBy: 'everyone' sends it as the client's own sparkles are sent (PetManager.sendPetSparkle), for every client in the room to draw.
Parameters
| Name | Type | |
|---|---|---|
sparkleId | number | |
options optional | ActOptions & SeenBy |
Returns
Promise<void>
Types
still
still(options?: ActOptions) => Promise<() => Promise<void>>Holds the pet still, its art not animating (PetBase.animatePet(false)), until the function it gives back is called, which lets it move again.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<() => Promise<void>>
Types
trick
trick(trick: PetTrick, options?: ActOptions) => Promise<void>Shows the pet doing a trick, as the chat's pet emotes do (WorldPet.setActionByName). This screen only. Throws NOT_READY when no pet is drawn.
Parameters
| Name | Type | |
|---|---|---|
trick | PetTrick | |
options optional | ActOptions |
Returns
Promise<void>
Types
walk
walk() => Promise<PetWalk | null>The walk the client works out for the pet each frame, or null when none is drawn.
Returns
Promise<PetWalk \| null>
whenOut
whenOut(options?: ActOptions) => Promise<PetInWorld>Waits for a pet to be drawn beside the player, and resolves with it: after bringOut, or a room joined with one out. Throws TIMEOUT when none is drawn in time.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<PetInWorld>
Types
onChange
onChange(listener: (pet: PetInWorld | null) => void) => () => voidHears the pet beside the player change: brought out, put away (null), walking, shown or hidden. Read in the game every third frame, and only told when something changed.
Parameters
| Name | Type | |
|---|---|---|
listener | (pet: PetInWorld | null) => void |
Returns
() => void. Call it to stop listening.
onWalk
onWalk(listener: (walk: PetWalk | null) => void) => () => voidHears the walk change (a new side, an animation, a turn), and null when the pet goes.
Parameters
| Name | Type | |
|---|---|---|
listener | (walk: PetWalk | null) => void |
Returns
() => void. Call it to stop listening.
player.pets.inventory
The pet inventory: phantom.aj.player.pets.inventory.
closeChecklist
closeChecklist(options?: ActOptions) => Promise<void>Closes the pet checklist the inventory opened over itself.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<PetInventoryView | null>The inventory as it stands, or null when it is not open or its art is not in.
Returns
Promise<PetInventoryView \| null>
loadMore
loadMore(options?: ActOptions) => Promise<boolean>Has the grid draw its next page of slots; resolves with whether there was one.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<boolean>
Types
pressSlot
pressSlot(index: number, options?: ActOptions) => Promise<void>Presses a pet's slot, as the player does, which shows that pet.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
reload
reload(options?: ActOptions) => Promise<void>Reads the player's pets again and redraws the grid (reloadPets).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
setRecycling
setRecycling(on: boolean, options?: ActOptions) => Promise<void>Turns recycling on or off, as the cage button does.
Parameters
| Name | Type | |
|---|---|---|
on | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
setSwitchOnClose
setSwitchOnClose(ask: boolean, options?: ActOptions) => Promise<void>Whether closing asks to switch to the pet shown (_activePetModified): false closes without switching. Resolves once the inventory holds the answer.
Parameters
| Name | Type | |
|---|---|---|
ask | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
slots
slots() => Promise<PetSlot[]>Every slot drawn so far, with the pet in it.
Returns
Promise<PetSlot[]>
onChange
onChange(listener: (change: PetInventoryChange) => void) => () => voidHears what happens on the inventory: ready, a page drawn, a pet shown, freed, put out.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: PetInventoryChange) => void |
Returns
() => void. Call it to stop listening.
player.pets.eggs
The egg pet popups, buying an egg and its pet hatching: phantom.aj.player.pets.eggs.
buy
buy(options?: ActOptions) => Promise<EggPurchase>Buys the egg, as its button does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<EggPurchase>
Types
hatched
hatched() => Promise<EggHatched | null>The hatched popup, or null when it is not open.
Returns
Promise<EggHatched \| null>
pickName
pickName(first: number, second: number, options?: ActOptions) => Promise<EggHatched>Spins the two name wheels to the words at these places, as the player would, ready for the lever. Throws NOT_READY before naming starts and REFUSED for a place a wheel has not got.
Parameters
| Name | Type | |
|---|---|---|
first | number | |
second | number | |
options optional | ActOptions |
Returns
Promise<EggHatched>
Types
purchase
purchase() => Promise<EggPurchase | null>The egg on offer, or null when the purchase popup is not open.
Returns
Promise<EggPurchase \| null>
player.belongings
The player's clothing, den items and pets as the client lists them, and den rooms.
all
all(kinds?: readonly BelongingKind[]) => Promise<Belonging[]>Everything the player owns from the lists asked for (all three by default), in one shape a trade takes as it stands: { itemType, invIdx }.
Parameters
| Name | Type | |
|---|---|---|
kinds optional | readonly BelongingKind[] |
Returns
Promise<Belonging[]>
clothing
clothing(options?: { avTypeId?: number | undefined; bodyMods?: boolean | undefined; }) => Promise<ClothingItem[]>The player's clothing. avTypeId narrows it to what one kind of animal can wear; bodyMods adds the eyes and patterns kept as items.
Parameters
| Name | Type | |
|---|---|---|
options optional | { avTypeId?: number | undefined; bodyMods?: boolean | undefined; } |
Returns
Promise<ClothingItem[]>
denItems
denItems(options?: { forRoom?: boolean | undefined; }) => Promise<DenItem[]>The player's den items: all of them, or only those for the den room they are in.
Parameters
| Name | Type | |
|---|---|---|
options optional | { forRoom?: boolean | undefined; } |
Returns
Promise<DenItem[]>
denPets
denPets(world: "land" | "ocean") => Promise<DenItem[]>The player's pets as they stand in the den, for one world.
Parameters
| Name | Type | |
|---|---|---|
world | "land" | "ocean" |
Returns
Promise<DenItem[]>
denRoom
denRoom(defId: number) => Promise<DenRoomDefinition | null>One den room the game sells, or null for an id it has none for.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<DenRoomDefinition \| null>
denRooms
denRooms() => Promise<DenRoomDefinition[]>Every den room the game sells, by definition id, from the def pack the client loaded.
Returns
Promise<DenRoomDefinition[]>
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.
Player
The signed in player as the client holds them now.
| Field | Type | |
|---|---|---|
userId | number | Their id in the room's server (AvatarManager.playerSfsUserId); it changes with the server. |
userName | string | null | Their account name. |
uuid | string | null | The account's lasting id. |
avatarName | string | null | The name of the animal being played. |
shownName | string | null | The account name as others see it: theirs once approved, a stock one before. |
perUserAvId | number | null | Which of their animals is being played (myPerUserAvId), as animals numbers them. |
accountType | number | null | The account type; 2 and above is a member, 4 a moderator's. |
member | boolean | |
moderator | boolean | |
guide | boolean | One of Animal Jam's guides. |
silenced | boolean | Nothing they say reaches the room. |
invisible | boolean | Ghost mode (clientInfo.invisMode): others do not see them. |
chat | { now: number; full: number; degraded: boolean; } | What the chat bar offers now, and what the account allows when nothing lowers it. |
loginCount | number | null | |
createdAt | number | null | When the account was made, in milliseconds. |
daysSinceLastLogin | number | null | |
worldMapRoom | string | null | The room the world map opens on. |
pendingFlags | number | The account's pending flags as one number; hasPendingFlag asks for one bit. |
tourDone | boolean | The new player's first five minutes are behind them (bit 0). |
needsFirstAnimal | boolean | The account has still to choose its first animal (bit 4). |
privacy | { den: number; eCards: number; playerWall: number; webPlayerWall: number; } | Who may come into the den (0 nobody, 1 buddies, 2 all), send jam-a-grams, post on the wall. |
animalDefsLoaded | boolean | The client has its animal definitions, which reading a kind of animal needs. |
hostingParty | boolean | A party the player hosts is still running. |
membershipDaysLeft | number | null | Days left of membership; null when the client was not told. |
email | { address: string | null; pending: string | null; } | The verified address and one waiting on verification. |
activeDenId | number | null | The inventory id of the den the player has active. |
buddyCount | number |
PlayerChange
What onChange hears: the player now, and which fields just changed.
| Field | Type | |
|---|---|---|
player | Player | |
changed | (keyof Player)[] |
LoginPlayer
The signed in player, read from a login reply's params as GamePlay.onWorldLogIn stores it.
| Field | Type | |
|---|---|---|
userId | number | |
userName | string | |
dbUserId | number | |
uuid | string | |
avatarName | string | |
perUserAvatarId | number | |
accountType | number | |
member | boolean | |
guide | boolean | |
moderator | boolean | |
silenced | boolean | |
chatType | number | userInfo.sgChatType, which decides what the chat bar offers. |
can | { buddy: boolean; trade: boolean; gift: boolean; chat: boolean; jamAGram: boolean; } | What the account allows, from the interactions bits (Utility.canBuddy and the rest). |
interactions | number | |
currencies | Record<"gems" | "tickets" | "orbs" | "diamonds" | "straw" | "bamboo" | "wood" | "stone" | "silver" | "gold" | "gemstone" | "ecoCredits", number> | Each currency's count at login. Later changes come in other messages. |
numLogins | number | |
createdAt | number | |
pendingFlags | number | |
daysLeftOnSubscription | number | |
unreadJamAGrams | number | |
email | string | |
denPrivacy | number | |
jamAGramPrivacy | number | |
activeDenRoomInvId | number | |
activePetInvId | number | |
lastBroadcastMessage | string |
PlayerAllowances
What the account may do with other players (Utility.canBuddy and its neighbours).
| Field | Type | |
|---|---|---|
buddy | boolean | |
trade | boolean | |
gift | boolean | |
chat | boolean | |
jamAGram | boolean | |
multiplayer | boolean | |
pvp | boolean | |
quest | boolean |
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 |
PlayerDiscipline
What moderation has done to the player this session.
| Field | Type | |
|---|---|---|
banned | boolean | Banned or suspended (wasUserBanned). |
suspension | "permanent" | "temporary" | null | |
suspensionHours | number | How many hours a suspension lasts; 0 when there is none. |
kicked | boolean | |
kickReason | number | null | The kick's reason number; null when there was none. |
kickMessage | string | null | |
silenced | boolean | |
chat | { now: number; full: number; degraded: boolean; } | |
tradeBlocked | boolean | Trading or gifting is off although the account allows it. |
giftBlocked | boolean |
DisciplineEvent
One piece of moderation landing on the player (fd).
| Field | Type | |
|---|---|---|
action | string | The client's own code: fb, fs, fk, fp, fw, fg or fc. |
kind | "ban" | "silence" | "kick" | "message" | "warning" | "tradeBlock" | "denCleared" | "unknown" | |
applied | boolean | False is the server lifting an earlier one. |
reason | DisciplineReason | null | |
amount | number | null | A ban's seconds (-1 for good), a kick's reason, a silence's count, a block's seconds. |
hours | number | null | The hours amount comes to, where the client works them out. |
text | string | null | A moderator's message, when one is to be shown. |
disconnects | boolean | The client drops the connection over it (a kick whose reason is 0 or less). |
extra | readonly string[] |
PlayerRecord
What the client holds of a player it has met (avatar.UserInfo), the player too.
| Field | Type | |
|---|---|---|
userName | string | |
uuid | string | null | |
accountType | number | null | |
member | boolean | |
guide | boolean | |
nameApproved | boolean | Their name was approved; until then shownName is a stock one. |
shownName | string | null | |
currentAvatarId | number | null | Which of their animals they were last seen as. |
avatarIds | number[] | Their animals the client holds, by perUserAvId. |
daysSinceLastLogin | number | null | |
hostingParty | boolean | |
partySecondsLeft | number | Seconds left of a party they host; 0 when none. |
lastAchievementRequest | number | null | When the client last asked for their achievements, by its clock; null when never. |
achievementsByType | Record<number, number> | Their achievements the client holds, counted by type; empty until asked for. |
Standing
Where the animal stands, as the room draws it now.
| Field | Type | |
|---|---|---|
position | Point | Its feet, in room coordinates (avatarPos). |
facing | Facing | |
moving | boolean | Walking, or sliding, now. |
radius | number | How far round it the room keeps others, in room pixels. |
Point
A point in the room or on the stage, in pixels. One type for every area.
| Field | Type | |
|---|---|---|
x | number | |
y | number |
Facing
Which way an animal faces.
type Facing = 'left' | 'right'AvatarWalkOptions
How a walk is waited for.
type AvatarWalkOptions = ActOptions & {
/**
* `arrived` (the default) resolves once the animal has stopped; `started` as soon as the room
* has taken the walk. 30 seconds are allowed by default.
*/
until?: 'started' | 'arrived';
}Undo
A drawn change that lasts until this is called, which puts back what was there.
type Undo = () => Promise<void>AvatarRoomState
What the client is doing with the player's animal between rooms.
| Field | Type | |
|---|---|---|
joiningRoom | boolean | A room is being joined (joiningNewRoom). |
inPreviewRoom | boolean | The animal is in a den's preview (isMyAvtInPreviewRoom). |
waitingForLanguage | boolean | The client waits for a language pack before drawing (waitForLangPack). |
AvatarHosting
The custom games the player hosts.
| Field | Type | |
|---|---|---|
adventure | HostedGame | null | |
pvp | HostedGame | null | |
hostingAdventure | boolean | The client counts the player as hosting an adventure (isMyUserInCustomAdventureHosting). |
HostedGame
A custom adventure or PvP game the player hosts.
| Field | Type | |
|---|---|---|
infoText | string | null | |
userMessage | string | null | |
difficulty | number | |
severity | number |
AnimalColors
An animal's colours, each part as its index in the game's palette, and as packed.
type AnimalColors = Record<ColorPart, number> & { packed: PackedColors }PackedColors
An animal's colours as the client packs them in Avatar.colors: three 32-bit words.
| Field | Type | |
|---|---|---|
0 | number | |
1 | number | |
2 | number | |
length | 3 | |
toString | () => string | Returns a string representation of an array. |
toLocaleString | { (): string; (locales: string | string[], options?: (NumberFormatOptions & DateTimeFormatOptions) | undefined): string; } | Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. |
concat | { (...items: ConcatArray<number>[]): number[]; (...items: (number | ConcatArray<number>)[]): number[]; } | Combines two or more arrays. |
join | (separator?: string | undefined) => string | Adds all the elements of an array separated by the specified separator string. |
slice | (start?: number | undefined, end?: number | undefined) => number[] | Returns a section of an array. |
indexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the first occurrence of a value in an array. |
lastIndexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the last occurrence of a specified value in an array. |
every | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): boolean; } | Determines whether all the members of an array satisfy the specified test. |
some | (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
forEach | (callbackfn: (value: number, index: number, array: readonly number[]) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
map | <U>(callbackfn: (value: number, index: number, array: readonly number[]) => U, thisArg?: any) => U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
filter | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): number[]; } | Returns the elements of an array that meet the condition specified in a callback function. |
reduce | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
reduceRight | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
find | { <S extends number>(predicate: (value: number, index: number, obj: readonly number[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any): number | undefined; } | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
findIndex | (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any) => number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
entries | () => ArrayIterator<[number, number]> | Returns an iterable of key, value pairs for every entry in the array |
keys | () => ArrayIterator<number> | Returns an iterable of keys in the array |
values | () => ArrayIterator<number> | Returns an iterable of values in the array |
includes | (searchElement: number, fromIndex?: number | undefined) => boolean | Determines whether an array includes a certain element, returning true or false as appropriate. |
flatMap | <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This | undefined) => U[] | Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. |
flat | <A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[] | Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. |
at | (index: number) => number | undefined | Returns the item located at the specified index. |
__@iterator@147944 | () => ArrayIterator<number> | Iterator of values in the array. |
__@unscopables@147954 | { readonly [x: number]: boolean | undefined; readonly length?: boolean | undefined; toString?: boolean | undefined; toLocaleString?: boolean | undefined; concat?: boolean | undefined; join?: boolean | undefined; slice?: boolean | undefined; indexOf?: boolean | undefined; lastIndexOf?: boolean | undefined; every?: boolean | undefined; some?: boolean | undefined; forEach?: boolean | undefined; map?: boolean | undefined; filter?: boolean | undefined; reduce?: boolean | undefined; reduceRight?: boolean | undefined; find?: boolean | undefined; findIndex?: boolean | undefined; entries?: boolean | undefined; keys?: boolean | undefined; values?: boolean | undefined; includes?: boolean | undefined; flatMap?: boolean | undefined; flat?: boolean | undefined; at?: boolean | undefined; [Symbol.iterator]?: boolean | undefined; readonly [Symbol.unscopables]?: boolean | undefined; } | Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. |
Palette
The game's palette, and the part of it the avatar editor offers for each colour.
| Field | Type | |
|---|---|---|
colors | number[] | Every colour of the game's palette, as 0xRRGGBB, by index. |
offered | Record<"color1" | "color2" | "eyes" | "pattern", number[]> | The indexes the editor offers for each part. |
limit | number | How many indexes an animal's colours can carry. |
ColorChange
A change of colours: palette indexes by part, or the three packed words themselves.
type ColorChange = Partial<Record<ColorPart, number>> | PackedColorsColorOfferOptions
How offer lays its swatches out; the grid's own size by default.
type ColorOfferOptions = ActOptions & {
width?: number;
height?: number;
columns?: number;
rows?: number;
}ColorOffer
An offer of colours in the editor: call it to put the editor's own back.
type ColorOffer = (() => Promise<void>) & {
/** How many swatches the grid offers. */
readonly count: number;
}NameBar
The player's name bar, unpacked from nameBarData.
| Field | Type | |
|---|---|---|
data | number | The packed number the server keeps. |
color | number | The colour, 0 to 9. |
badge | number | The badge's definition id, 1 to 256. |
showLevel | boolean | Whether the adventure level shows on it. |
Animal
One of the player's own animals, as the avatar switcher holds it (avatar.Avatar).
| Field | Type | |
|---|---|---|
perUserAvId | number | Which of the player's animals: what switchTo and remove take. |
avInvId | number | Its slot, which the items it wears and the non-member slot flags name it by. |
avName | string | null | |
avTypeId | number | Its kind (kinds.get), and its recycled kind (kinds.custom), null for an ordinary one. |
customAvId | number | null | |
colors | PackedColors | |
enviroTypeFlag | number | Where it can go: 1 land, 2 ocean, 4 air, added together. |
usable | boolean | Whether the player may play it now: always for a member, two slots for a non-member. |
playing | boolean | Whether it is the one the player is playing. |
AnimalSlots
How many animals the player has, and how many they may use (avatar.AvatarSwitch).
| Field | Type | |
|---|---|---|
total | number | |
members | number | |
nonMembers | number | |
nonMemberOceanOnly | number | |
usable | number | How many the player could switch to now, membership and open slots considered. |
openNonMemberSlots | number | Non-member slots opened beyond the free ones, by buying them. |
slotFlags | number | The two slots a non-member may use, packed (each half a slot plus one); all bits for a member. |
SwitcherState
What the avatar switcher is in the middle of: for finding out why it will not do something.
| Field | Type | |
|---|---|---|
userName | string | null | The account it holds animals for, and the player's id in the room. |
userId | number | null | |
activeIndex | number | Which slot is active, and which one it is switching to (-1 for none). |
switchingTo | number | |
switching | boolean | |
switchingDen | boolean | |
addingSlot | boolean | Waiting on a slot being bought. |
choosing | boolean | Asking the player to choose which animals to keep, and whether it must. |
mustChoose | boolean | |
ordering | number[] | The order the window draws the animals in, by slot. |
adding | { index: number; name: string | null; avatarName: string | null; } | The animal being added: its slot and name, and the name it was given (-1 / null for none). |
removingIndex | number | |
status | number | The status the switcher holds for what it is doing, as the server answered it. |
namingScreenOpen | boolean |
KnownAnimal
One animal of a player's, as the client caches it per account (avatar.AvatarInfo).
| Field | Type | |
|---|---|---|
userName | string | null | |
perUserAvId | number | |
avInvId | number | null | |
uuid | string | null | |
avName | string | null | |
avTypeId | number | |
customAvId | number | null | |
colors | PackedColors | |
world | "land" | "ocean" | The world it is in now. |
pets | { land: number | null; ocean: number | null; out: number | null; } | Its pets by inventory id: the one it takes out on land, in the ocean, and the one out now. |
quest | { level: number; xp: number; xpPercent: number; healthPercent: number; health: number; attack: { base: number; max: number; }; defense: { base: number; max: number; }; torch: boolean; dead: boolean; } | Its adventure numbers, as the server last sent them. health is twice its hearts. |
ListedAnimal
One of the player's animals as the server lists them (al).
| Field | Type | |
|---|---|---|
perUserAvId | number | |
avInvId | number | |
avName | string | null | |
avTypeId | number | |
customAvId | number | null |
AnimalSwitch
Someone in the room switching animals, the player included (as).
| Field | Type | |
|---|---|---|
userId | number | Who switched, by their id in the room. |
perUserAvId | number | |
avInvId | number | |
avName | string | null | |
avTypeId | number | |
customAvId | number | null | |
colors | PackedColors | |
questLevel | number | |
petInvId | number | null | The pet the player's new animal has out, by inventory id; told only of the player's own. |
NewAnimal
A new animal: its kind, its name, and where it is bought.
| Field | Type | |
|---|---|---|
avTypeId | number | |
nameIds | AvatarNameIds | The name's three parts, as localisation ids, one from each wheel of the avatar creator. |
customAvId optional | number | undefined | A recycled kind of it; the kind's own look when left out. |
diamondDefId optional | number | undefined | The diamond shop item a diamond animal is bought as. |
shopId optional | number | undefined | The shop it is bought in; the switcher's own when left out. |
AvatarNameIds
An avatar's name as the avatar creator builds it: three localisation ids, one from each of its three wheels (GuiCreateAName._avatarNameChosenIds). They go in the order the server keeps them; in a right-to-left language the client swaps the last two before sending (AvatarSwitch.addNewWorldAvatar).
| Field | Type | |
|---|---|---|
0 | number | |
1 | number | |
2 | number | |
length | 3 | |
toString | () => string | Returns a string representation of an array. |
toLocaleString | { (): string; (locales: string | string[], options?: (NumberFormatOptions & DateTimeFormatOptions) | undefined): string; } | Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. |
concat | { (...items: ConcatArray<number>[]): number[]; (...items: (number | ConcatArray<number>)[]): number[]; } | Combines two or more arrays. |
join | (separator?: string | undefined) => string | Adds all the elements of an array separated by the specified separator string. |
slice | (start?: number | undefined, end?: number | undefined) => number[] | Returns a section of an array. |
indexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the first occurrence of a value in an array. |
lastIndexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the last occurrence of a specified value in an array. |
every | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): boolean; } | Determines whether all the members of an array satisfy the specified test. |
some | (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
forEach | (callbackfn: (value: number, index: number, array: readonly number[]) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
map | <U>(callbackfn: (value: number, index: number, array: readonly number[]) => U, thisArg?: any) => U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
filter | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): number[]; } | Returns the elements of an array that meet the condition specified in a callback function. |
reduce | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
reduceRight | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
find | { <S extends number>(predicate: (value: number, index: number, obj: readonly number[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any): number | undefined; } | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
findIndex | (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any) => number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
entries | () => ArrayIterator<[number, number]> | Returns an iterable of key, value pairs for every entry in the array |
keys | () => ArrayIterator<number> | Returns an iterable of keys in the array |
values | () => ArrayIterator<number> | Returns an iterable of values in the array |
includes | (searchElement: number, fromIndex?: number | undefined) => boolean | Determines whether an array includes a certain element, returning true or false as appropriate. |
flatMap | <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This | undefined) => U[] | Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. |
flat | <A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[] | Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. |
at | (index: number) => number | undefined | Returns the item located at the specified index. |
__@iterator@147944 | () => ArrayIterator<number> | Iterator of values in the array. |
__@unscopables@147954 | { readonly [x: number]: boolean | undefined; readonly length?: boolean | undefined; toString?: boolean | undefined; toLocaleString?: boolean | undefined; concat?: boolean | undefined; join?: boolean | undefined; slice?: boolean | undefined; indexOf?: boolean | undefined; lastIndexOf?: boolean | undefined; every?: boolean | undefined; some?: boolean | undefined; forEach?: boolean | undefined; map?: boolean | undefined; filter?: boolean | undefined; reduce?: boolean | undefined; reduceRight?: boolean | undefined; find?: boolean | undefined; findIndex?: boolean | undefined; entries?: boolean | undefined; keys?: boolean | undefined; values?: boolean | undefined; includes?: boolean | undefined; flatMap?: boolean | undefined; flat?: boolean | undefined; at?: boolean | undefined; [Symbol.iterator]?: boolean | undefined; readonly [Symbol.unscopables]?: boolean | undefined; } | Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. |
CreateOptions
type CreateOptions = ActOptions & {
/**
* Add it the way the avatar creator's Done button does (`NewWorldAvatar.newAvatarData`): with the
* colours and accessories the player gave it in the open creator, and switched to straight after,
* as the client does. Needs the creator's animals (`kinds.creation()`), so the creator must have
* been opened.
*/
fromCreator?: boolean;
/** The name in words, which the creator path wants not empty. */
name?: string;
}CreatedAnimal
A new animal, as the server added it.
| Field | Type | |
|---|---|---|
perUserAvId | number | |
avInvId | number | |
listed | boolean | Whether the switcher's own list was given it, so switchTo finds it at once. False when the client could not fill it in; it is the player's all the same, and is listed after a relog. |
AnimalChange
A change to the player's animals, as the server told it; ok false for a refusal.
type AnimalChange = | {
kind: 'listed';
userName: string;
/** The player's own list, which carries the animals; someone else's carries only ids. */
own: boolean;
perUserAvIds: number[];
animals: ListedAnimal[];
}
| {
kind: 'added';
ok: boolean;
/** 1 added, -1 a shop's animal no longer on sale, anything else refused. */
status: number;
perUserAvId: number | null;
avInvId: number | null;
}
| { kind: 'removed' | 'slotBought' | 'firstAdded' | 'usableChosen'; ok: boolean }AnimalKind
A kind of animal, from the def pack the client loads (avatar.AvatarDef).
| Field | Type | |
|---|---|---|
avTypeId | number | The kind's id: an animal's own avTypeId. For a recycled kind, the kind it is built on. |
title | string | null | Its name in the player's language, as the client translates it; null when it has none. |
titleStrId | number | |
cost | number | What it costs, in gems, or in diamonds for a diamond animal. |
status | number | 0 normal, 1 new, 2 sale, 3 clearance, 4 rare. |
availability | KindAvailability | |
membersOnly | boolean | |
enviroTypeFlag | number | Where it can go: 1 land, 2 ocean, 4 air, added together. |
eyes | number | The eyes and the pattern it starts with. |
pattern | number | |
colors | PackedColors | The colours it starts painted, and the colours a den mannequin of it is painted. |
mannequinColors | PackedColors | |
iconMediaId | number | |
attackItemRefId | number | null | The attack item an adventure gives it, by reference id; null for none. |
availableFrom | number | null | When it went on sale and comes off, in epoch seconds; null for "always". |
availableUntil | number | null | |
custom | { customAvId: number; iconRefId: number; particleRefId: number; patternRefIds: number[]; secondColor: number | null; } | null | What a recycled kind (CustomAvatarDef) adds of its own; null for an ordinary kind. |
KindAvailability
Where a kind stands in the game, as the shops and the creator read its def's availability.
type KindAvailability = 'hidden' | 'active' | 'endangered' | 'extinct'KindItemOptions
How asItem builds the shop's item.
| Field | Type | |
|---|---|---|
customAvId optional | number | undefined | A recycled kind of it, by its customAvId. |
invId optional | number | undefined | The inventory place to build it for; 0 by default, an item built to be looked at. |
forShop optional | boolean | undefined | Build it as a shop window does. |
status optional | number | undefined | Price it under another shop status (updateValueWithNewStatus): 1 new, 2 sale, 3 clearance, 4 rare. A rare item keeps its ribbon whatever, as the client has it. |
KindItem
A kind as the animal shop's own item works it out (avatar.AvatarItem): price and ribbon.
| Field | Type | |
|---|---|---|
avTypeId | number | |
customAvId | number | null | |
name | string | null | |
value | number | What it costs now, a sale already taken off, and what recycling it gives back. |
recycleValue | number | |
currencyType | number | 0 gems, 3 diamonds. |
itemStatus | number | The ribbon: 1 new, 2 on sale, 3 clearance, 4 rare. |
startTime | number | null | |
endTime | number | null | |
enviroType | number | |
membersOnly | boolean | |
isNew | boolean | |
isOnSale | boolean | |
isOnClearance | boolean | |
isRare | boolean | |
isDiamond | boolean | |
isRareDiamond | boolean | |
isLand | boolean | |
isOcean | boolean | |
isLandAndOcean | boolean | |
isAvailable | boolean | Whether its kind is still sold. |
isCustom | boolean | |
denShopInvId | number | null | Its place in a den shop, when it is listed in one. |
KindOffsets
Where the client draws things over one kind, in that kind's own pixels (AvatarUtility).
| Field | Type | |
|---|---|---|
chat | Point | |
hud | Point | |
view | Point | |
emoteBackground | Point | |
itemWindow | Point | |
talkingHead | Point | |
photo | Point | |
minigameLobby | Point | |
byDefId | Point |
CreationKinds
The animals the client built for the avatar creator (AvatarUtility.creationAvatarsList).
| Field | Type | |
|---|---|---|
kinds | { index: number; avTypeId: number; customAvId: number | null; avName: string | null; }[] | Each kind the creator offers, by the index its arrows count by. |
nonMemberCount | number | How many of them a non-member may pick. |
viewsLoaded | number | How many creator views have loaded. |
diamondStoreCount | number | How many kinds the diamond shop offers now, and how many it has data for. |
diamondListCount | number |
AvatarSwitcherView
The animal switcher (gui.AvatarSwitcher), as it stands.
| Field | Type | |
|---|---|---|
ready | boolean | Whether its slots are drawn. |
selected | number | The slot of the animal being played. |
slots | number | |
counter | string | What its counter says ("3/12"). |
recycling | boolean | |
choosing | boolean | Choosing which animals to keep, after a membership ran out. |
choosingOcean | boolean | |
chosen | number[] | |
gems | number | |
canAdd | boolean | |
canRecycle | boolean | |
message | string | null | The warning it is showing, or null. |
SwitcherSlot
One slot of the animal switcher.
| Field | Type | |
|---|---|---|
index | number | |
state | AvatarSlotState | |
name | string | null | |
invId | number | null | |
selected | boolean | |
checked | boolean | |
recycleMark | boolean | |
level | number | |
drawn | boolean | Whether the client has drawn it yet; what is not drawn reads from the animal list alone. |
AvatarSlotState
type AvatarSlotState = 'animal' | 'empty' | 'locked' | 'unusable'SwitcherChange
Something happening on a switcher, told by the client method it happened in.
type SwitcherChange = | { kind: 'ready'; selected: number; slots: number; choosing: boolean }
| { kind: 'slotPressed'; index: number; selected: number; recycling: boolean }
| { kind: 'switched'; ok: boolean }
| { kind: 'added'; ok: boolean; code: number }
| { kind: 'recycled'; ok: boolean; index: number; invId: number | null; gems: number | null }
| { kind: 'bought'; index: number }
| { kind: 'recycling'; on: boolean }
| { kind: 'message'; message: string | null }
| { kind: 'shown'; shown: boolean }Look
How an animal looks, as the game saves it: its colours, its eyes and pattern, and the clothing it wears. Plain data, to keep, compare and hand back to putOn.
| Field | Type | |
|---|---|---|
avTypeId | number | The kind of animal it was taken from, by its def id; -1 when not known. |
colors | Record<"color1" | "color2" | "eyes" | "pattern", number> | The palette index of each colour the avatar editor chooses, 0 to 255. |
eyes | number | The eyes, by their item def id; 0 for none known. |
pattern | number | The pattern, by its item def id; 0 for none. |
items | LookItem[] | The clothing worn. |
LookItem
One piece of clothing in a look: which item, and in which of its colours.
| Field | Type | |
|---|---|---|
defId | number | The item's definition id. |
color | number | Its colour, as the server sends it (ARGB, unsigned). |
LookOptions
How plan and putOn match a look to what the player owns.
| Field | Type | |
|---|---|---|
replace optional | boolean | undefined | Take off what the animal wears that the look does not have, so it ends up wearing the look alone. True unless given; false only adds. |
otherColours optional | boolean | undefined | Put on an item the player owns in another colour when they do not own the look's own colour. False unless given, so a look is only ever copied exactly. |
keepColors optional | boolean | undefined | Leave the colours as they are. |
LookPlan
What plan would do to make the player's animal look like a look.
| Field | Type | |
|---|---|---|
items | LookItemPlan[] | Every item of the look and what became of it. |
eyes | "not-wearable" | "same" | "change" | Eyes and pattern: same as now, changed, or not-wearable on this animal. |
pattern | "not-wearable" | "same" | "change" | |
wear | number[] | The invIds to put on, eyes and pattern as their negative def ids, as the editor sends them. |
remove | number[] | The invIds to take off. |
colors | AvatarColors | null | The three packed colours to paint, or null when the colours are already the look's. |
LookItemPlan
What became of one piece of clothing of a look, planned against what the player owns.
| Field | Type | |
|---|---|---|
item | LookItem | |
invId | number | null | The player's own item it is matched to, by invId; null when none is. |
status | "worn" | "put-on" | "other-colour" | "not-owned" | "not-wearable" | worn: already on. put-on: owned and put on. other-colour: owned only in another colour, which is put on instead (only with otherColours). not-owned: the player has none. not-wearable: owned, but the client says this animal cannot wear it. |
AvatarColors
An avatar's three colours, packed as Avatar.colors holds them.
| Field | Type | |
|---|---|---|
0 | number | |
1 | number | |
2 | number | |
length | 3 | |
toString | () => string | Returns a string representation of an array. |
toLocaleString | { (): string; (locales: string | string[], options?: (NumberFormatOptions & DateTimeFormatOptions) | undefined): string; } | Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. |
concat | { (...items: ConcatArray<number>[]): number[]; (...items: (number | ConcatArray<number>)[]): number[]; } | Combines two or more arrays. |
join | (separator?: string | undefined) => string | Adds all the elements of an array separated by the specified separator string. |
slice | (start?: number | undefined, end?: number | undefined) => number[] | Returns a section of an array. |
indexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the first occurrence of a value in an array. |
lastIndexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the last occurrence of a specified value in an array. |
every | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): boolean; } | Determines whether all the members of an array satisfy the specified test. |
some | (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
forEach | (callbackfn: (value: number, index: number, array: readonly number[]) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
map | <U>(callbackfn: (value: number, index: number, array: readonly number[]) => U, thisArg?: any) => U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
filter | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): number[]; } | Returns the elements of an array that meet the condition specified in a callback function. |
reduce | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
reduceRight | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
find | { <S extends number>(predicate: (value: number, index: number, obj: readonly number[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any): number | undefined; } | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
findIndex | (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any) => number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
entries | () => ArrayIterator<[number, number]> | Returns an iterable of key, value pairs for every entry in the array |
keys | () => ArrayIterator<number> | Returns an iterable of keys in the array |
values | () => ArrayIterator<number> | Returns an iterable of values in the array |
includes | (searchElement: number, fromIndex?: number | undefined) => boolean | Determines whether an array includes a certain element, returning true or false as appropriate. |
flatMap | <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This | undefined) => U[] | Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. |
flat | <A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[] | Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. |
at | (index: number) => number | undefined | Returns the item located at the specified index. |
__@iterator@147944 | () => ArrayIterator<number> | Iterator of values in the array. |
__@unscopables@147954 | { readonly [x: number]: boolean | undefined; readonly length?: boolean | undefined; toString?: boolean | undefined; toLocaleString?: boolean | undefined; concat?: boolean | undefined; join?: boolean | undefined; slice?: boolean | undefined; indexOf?: boolean | undefined; lastIndexOf?: boolean | undefined; every?: boolean | undefined; some?: boolean | undefined; forEach?: boolean | undefined; map?: boolean | undefined; filter?: boolean | undefined; reduce?: boolean | undefined; reduceRight?: boolean | undefined; find?: boolean | undefined; findIndex?: boolean | undefined; entries?: boolean | undefined; keys?: boolean | undefined; values?: boolean | undefined; includes?: boolean | undefined; flatMap?: boolean | undefined; flat?: boolean | undefined; at?: boolean | undefined; [Symbol.iterator]?: boolean | undefined; readonly [Symbol.unscopables]?: boolean | undefined; } | Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. |
LookResult
What putOn did: the plan it followed, and the look the animal has after.
| Field | Type | |
|---|---|---|
plan | LookPlan | |
sent | { items: boolean; colors: boolean; } | Whether clothing, eyes or pattern were sent (iu), and whether colours were (ap). |
look | Look | null | The look as the client draws it once the server has taken it. |
LookChange
A change to how a player's animal looks, as the server sent it.
type LookChange = | {
kind: 'clothing';
/** Whose avatar, by account name, and which of their avatars. */
userName: string;
perUserAvId: number;
/** The `invId`s put on, or new to the inventory. */
added: number[];
/** The `invId`s taken off, or gone. */
removed: number[];
}
| {
/** The player's colours: whether the server took them. */
kind: 'colors';
success: boolean;
}ShownLook
What the client is drawing on the player's animal (avatar.AccessoryState).
| Field | Type | |
|---|---|---|
avatarName | string | null | Whose animal the record belongs to (AccessoryState.ownerAvatar.avName). |
items | DrawnItem[] | Everything drawn, body mods and clothing, in the client's order. |
pattern | number | The pattern and the eyes being drawn, by def id; 0 for none. |
eyes | number | |
clothingShown | number | How many pieces of clothing the client counts as shown (numClothingItemsShown). |
DrawnItem
One thing the client is drawing on an animal, from its own record (AccessoryState).
| Field | Type | |
|---|---|---|
invId | number | Its place in the inventory; negative for a piece tryOn put on, which is in none. |
defId | number | |
accId | number | The art it is drawn from, which every colour of one item shares. |
layer | number | The layer it is drawn on: 2 the pattern, 3 the eyes, 4 and up clothing. |
color | number | ARGB, unsigned. |
bodyMod | boolean | Eyes and patterns are body mods; everything else is clothing. |
CombatValues
What the adventures make of what an animal wears (avatar.Avatar), as the client adds each item's numbers up. The server works its own out and never sends them: these are the client's copy.
| Field | Type | |
|---|---|---|
ranged | CombatPair | |
melee | CombatPair | |
fierce | CombatPair | |
healing | CombatPair | |
defence | CombatPair | |
isShaman | boolean | Whether the animal carries a shaman's words, and what they are. |
shamanName | string | null | |
shamanText | string | null | |
roomType | number | Which world the animal is dressed for: 0 land, 1 ocean. |
CombatPair
A pair the adventures keep for each value: the total from the items, and the modifier on top.
| Field | Type | |
|---|---|---|
base | number | |
modifier | number |
AvatarDressing
What an animal has to dress from (Avatar.inventoryBodyMod, inventoryClothing, …).
| Field | Type | |
|---|---|---|
bodyMods | number | How many body mods and pieces of clothing the animal can draw from. |
clothing | number | |
denItemsFull | number | How many den items the animal carries the lists for, whole and partial. |
denItemsPartial | number | |
isMannequin | boolean | Whether this animal is a den mannequin's rather than a player's. |
singleEnvironment | boolean | Whether its kind belongs to one world only, which decides how its clothing is filtered. |
roomType | number | Which world it is dressed for: 0 land, 1 ocean. |
BodyMod
One of the eyes or patterns an animal can wear.
| Field | Type | |
|---|---|---|
kind | "eyes" | "pattern" | |
defId | number | Its definition id, as a Look's eyes and pattern hold it. |
name | string | null | Its name in the player's language, as the client translated it. |
titleStrId | number | The string id its name is translated from. |
membersOnly | boolean | Whether only a member may wear it. |
inUse | boolean | Whether the animal the player is on wears it now. |
TryOnOptions
How tryOn draws the piece.
type TryOnOptions = ActOptions & {
/** The colour to draw it in, packed as the client packs them; 0, the default, draws its own. */
color?: number;
}TryOn
A piece tried on: call it to take it off again. defId is the piece. Taking it off twice, or after the client was reloaded (which takes it off by itself), does nothing.
type TryOn = (() => Promise<void>) & { readonly defId: number }