#include <inventory.hpp>
Public Member Functions | |
Inventory (Character *, bool delayed=false) | |
Creates a view on the possessions of a character. | |
~Inventory () | |
Commits delayed changes. | |
void | commit () |
Commits delayed changes. | |
void | cancel () |
Cancels delayed changes. | |
void | sendFull () const |
Sends a complete inventory update to the client. | |
void | initialize () |
Ensures the inventory is sane and apply equipment modifiers. | |
void | equip (int slot) |
Equips item from given inventory slot. | |
void | unequip (int slot) |
Unequips item from given equipment slot. | |
int | fireProjectile () |
Gets the ID of projectiles. | |
int | insert (int itemId, int amount) |
Inserts some items into the inventory. | |
int | remove (int itemId, int amount) |
Removes some items from inventory. | |
int | move (int slot1, int slot2, int amount) |
Moves some items from the first slot to the second one. | |
int | removeFromSlot (int slot, int amount) |
Removes some items from inventory. | |
int | count (int itemId) const |
Counts number of items with given ID. | |
int | getItem (int slot) const |
Gets the ID of the items in a given slot. | |
bool | changeMoney (int) |
Changes amount of money. |
Definition at line 64 of file inventory.hpp.
Inventory::Inventory | ( | Character * | p, | |
bool | delayed = false | |||
) |
Creates a view on the possessions of a character.
delayed | true if changes have to be cancelable. |
Definition at line 33 of file inventory.cpp.
Inventory::~Inventory | ( | ) |
Commits delayed changes.
Sends the update message to the client.
Definition at line 39 of file inventory.cpp.
References MessageOut::getLength(), and GameHandler::sendTo().
void Inventory::initialize | ( | ) |
Ensures the inventory is sane and apply equipment modifiers.
Should be run only once and the very first time.
Definition at line 144 of file inventory.cpp.
References Possessions::equipment, Character::getDatabaseID(), and Possessions::inventory.
int Inventory::fireProjectile | ( | ) |
Gets the ID of projectiles.
Removes one of these projectiles from inventory.
int Inventory::insert | ( | int | itemId, | |
int | amount | |||
) |
Inserts some items into the inventory.
Definition at line 289 of file inventory.cpp.
References Possessions::inventory, MessageOut::writeByte(), and MessageOut::writeShort().
Referenced by equip(), GameHandler::processMessage(), and unequip().
int Inventory::remove | ( | int | itemId, | |
int | amount | |||
) |
Removes some items from inventory.
Definition at line 407 of file inventory.cpp.
References InventoryItem::amount, Possessions::inventory, InventoryItem::itemId, MessageOut::writeByte(), and MessageOut::writeShort().
int Inventory::move | ( | int | slot1, | |
int | slot2, | |||
int | amount | |||
) |
Moves some items from the first slot to the second one.
Definition at line 447 of file inventory.cpp.
References InventoryItem::amount, Possessions::inventory, InventoryItem::itemId, MessageOut::writeByte(), and MessageOut::writeShort().
int Inventory::removeFromSlot | ( | int | slot, | |
int | amount | |||
) |
Removes some items from inventory.
Definition at line 601 of file inventory.cpp.
References InventoryItem::amount, Possessions::inventory, InventoryItem::itemId, MessageOut::writeByte(), and MessageOut::writeShort().
Referenced by GameHandler::processMessage().
bool Inventory::changeMoney | ( | int | amount | ) |
Changes amount of money.
Definition at line 349 of file inventory.cpp.
References Possessions::money, MessageOut::writeByte(), and MessageOut::writeLong().