UiShopPetItem
The UiShopPetItem class extends UiShopItem to handle pet-type shop items. It adds pet-specific features: equip/revive/evolve actions, XP/level tracking, evolution level requirements, social media unlock flows (Twitter share + Facebook share for PetCARL, YouTube subscribe for PetMiner), and a "Coming Soon" placeholder.
UiShopPetItem private
Extends UiShopItem.
Properties
| Name | Type | Description |
|---|---|---|
inTimeoutAction | boolean | Whether a revive/evolve timeout animation is in progress. |
facebookAppId | string | Facebook app ID for share dialogs. '413139982405300'. |
health | number | The pet's current health. |
experience | number | The pet's current total experience. |
level | number | The pet's current level (Math.floor(experience / 100)). |
Inherits all other properties from UiShopItem.
Methods
constructor()
function constructor(ui: Ui, itemId: string): voidCalls the parent constructor and registers listeners for equippedPet and playerPetTickUpdate.
update()
function update(): voidOverrides parent. Handles rendering states:
- Owned: Shows level, XP bar, Equip/Equipped button, Evolve button (disabled until target level is reached). Shows Revive button if the pet is dead and equipped. Evolution levels:
[8, 16, 24, 32, 48, 64, 96]. - Social unlock (
PetCARL): Shows Tweet + Share buttons. - Social unlock (
PetMiner): Shows YouTube Subscribe button. - Coming Soon (
PetComingSoon): Disabled placeholder. - Default: Shows name, description, and cost.
onClick()
function onClick(event: MouseEvent): voidOverrides parent. Emits purchaseItem only if not disabled, on cooldown, owned, or social.
onEquipPet()
function onEquipPet(event: MouseEvent): voidEmits equipItem with the pet ID and current tier.
onRevivePet()
function onRevivePet(event: MouseEvent): voidShows a "Reviving..." loading state for 3 seconds, then emits purchaseItem and equipItem for PetRevive.
onEvolvePet()
function onEvolvePet(event: MouseEvent): voidShows an "Evolving..." loading state for 3 seconds, then emits purchaseItem for the next tier.
onTwitterShare()
function onTwitterShare(event: MouseEvent): voidOpens a Twitter tweet intent popup and emits twitterShare.
onFacebookShare()
function onFacebookShare(event: MouseEvent): voidOpens a Facebook share dialog and emits facebookShare.
onYouTubeSubscribe()
function onYouTubeSubscribe(event: MouseEvent): voidDisables the YouTube button and emits youTubeSubscribe.
onPetTickUpdate()
function onPetTickUpdate(tick: { model: string, health: number, experience: number }): voidUpdates the pet's health, experience, and level when a matching pet tick is received, then calls update().