import Inventory from 'WTF-Adventure/WTF-Adventure/client/interface/inventory.js'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 |
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 |
display() 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 |
loadInventory(data: Array) Populates the inventory slot list from server data and binds the toggle button |
|
| public |
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 Members
Public Methods
public add(info: Object) source
Adds or updates an item in the inventory display at the given index
Params:
| Name | Type | Attribute | Description |
| info | Object | item info object containing index, name, count, ability, abilityLevel, edible, and equippable |
public click(event: Event) source
Handles a single click on an inventory slot, showing available actions
Params:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| event | Event | the double-click event from the slot element |
public loadInventory(data: Array) source
Populates the inventory slot list from server data and binds the toggle button
Params:
| Name | Type | Attribute | Description |
| data | Array | array of item data objects for each inventory slot |
Reference
Source
Test
