Reference Source Test
public class | source

Inventory

Manages the player inventory interface for viewing and using items

Constructor Summary

Public Constructor
public

constructor(game: Game, size: Number)

Default constructor

Member Summary

Public Members
public

action: jQuery

The action container element

public

The actions interface instance

public

The CSS class name identifying this interface as the active context

public

body: jQuery

The inventory dialog body element

public

button: jQuery

The HUD inventory toggle button element

public

The container holding inventory slot data

public

The game instance

public

The currently selected inventory slot data

public

selectedSlot: jQuery

The currently selected inventory slot element

Method Summary

Public Methods
public

add(info: Object)

Adds or updates an item in the inventory display at the given index

public

Deselects the currently selected inventory slot

public

click(event: Event)

Handles a single click on an inventory slot, showing available actions

public

clickAction(event: Event | String)

Handles an action button click, sending the appropriate packet to the server

public

clickDouble(event: Event)

Handles a double click on an inventory slot, immediately using the item

public

Shows the inventory dialog and marks the button as active

public

getList(): jQuery

Returns all inventory slot list items from the DOM

public

Returns the drawing scale from the game renderer

public

Returns the number of slots in the inventory container

public

hide()

Hides the inventory dialog, removes the active state, and clears the selection

public

Returns whether the inventory dialog is currently visible

public

Populates the inventory slot list from server data and binds the toggle button

public

remove(info: Object)

Removes or decrements an item from the inventory display at the given index

public

resize()

Recalculates and reapplies slot image styles when the window is resized

Public Constructors

public constructor(game: Game, size: Number) source

Default constructor

Params:

NameTypeAttributeDescription
game Game

an instance of the game

size Number

the number of inventory slots

Public Members

public action: jQuery source

The action container element

public actions: Actions source

The actions interface instance

public activeClass: String source

The CSS class name identifying this interface as the active context

public body: jQuery source

The inventory dialog body element

public button: jQuery source

The HUD inventory toggle button element

public container: Container source

The container holding inventory slot data

public game: Game source

The game instance

public selectedItem: Slot source

The currently selected inventory slot data

public selectedSlot: jQuery source

The currently selected inventory slot element

Public Methods

public add(info: Object) source

Adds or updates an item in the inventory display at the given index

Params:

NameTypeAttributeDescription
info Object

item info object containing index, name, count, ability, abilityLevel, edible, and equippable

public clearSelection() source

Deselects the currently selected inventory slot

public click(event: Event) source

Handles a single click on an inventory slot, showing available actions

Params:

NameTypeAttributeDescription
event Event

the click event from the slot element

public clickAction(event: Event | String) source

Handles an action button click, sending the appropriate packet to the server

Params:

NameTypeAttributeDescription
event Event | String

the action button click event or action name string

public clickDouble(event: Event) source

Handles a double click on an inventory slot, immediately using the item

Params:

NameTypeAttributeDescription
event Event

the double-click event from the slot element

public display() source

Shows the inventory dialog and marks the button as active

public getList(): jQuery source

Returns all inventory slot list items from the DOM

Return:

jQuery

public getScale(): Number source

Returns the drawing scale from the game renderer

Return:

Number

public getSize(): Number source

Returns the number of slots in the inventory container

Return:

Number

public hide() source

Hides the inventory dialog, removes the active state, and clears the selection

public isVisible(): Boolean source

Returns whether the inventory dialog is currently visible

Return:

Boolean

public loadInventory(data: Array) source

Populates the inventory slot list from server data and binds the toggle button

Params:

NameTypeAttributeDescription
data Array

array of item data objects for each inventory slot

public remove(info: Object) source

Removes or decrements an item from the inventory display at the given index

Params:

NameTypeAttributeDescription
info Object

item info object containing index and count

public resize() source

Recalculates and reapplies slot image styles when the window is resized