UiShopItem
The UiShopItem class is the base shop item component used for Weapon, Armor, and Utility items. It displays the item's name, current/next tier stats, cost, and handles purchase clicks. It serves as the parent class for UiShopHatItem and UiShopPetItem.
UiShopItem private
Extends UiComponent.
Properties
| Name | Type | Description |
|---|---|---|
ui | Ui | Current Ui instance. Inherited from UiComponent. |
componentElem | HTMLElement | The root .hud-shop-item anchor element with data-item and data-tier attributes. |
itemId | string | The schema ID of this shop item. |
itemTier | number | The player's current tier for this item. Defaults to 1. |
nextTier | number | The next tier to purchase/upgrade to. |
Methods
constructor()
function constructor(ui: Ui, itemId: string): voidCreates the shop item element, sets data-type, binds the click handler, and listens for itemSchemaUpdate and inventoryUpdate events.
setOnCooldown()
function setOnCooldown(cooldownInMs: number): voidAdds the is-on-cooldown CSS class and removes it after cooldownInMs milliseconds.
update()
function update(): voidRecalculates item display: determines current/next tier, max tier state, upgrade availability, computes stat comparisons (Damage, Harvest, Range, Attack Speed, Health, Recharge Delay), formats gold/token costs, and re-renders the component HTML. Toggles is-disabled when upgrade is unavailable.
onClick()
function onClick(event: MouseEvent): voidEmits purchaseItem with itemId and nextTier if not disabled or on cooldown.
onItemSchemaUpdate()
function onItemSchemaUpdate(): voidCalls update().
onInventoryUpdate()
function onInventoryUpdate(): voidCalls update().