diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-11 02:20:39 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-11 02:20:39 +0200 |
commit | 8766149dc12d197205b1632ec6e9fc663de05990 (patch) | |
tree | 56594a56e8602a1146d739bf155fbc6f7a5d385f /src/game-server/inventory.h | |
parent | dfe18975cf97d31005354cfeaac45cb66388e105 (diff) | |
download | manaserv-8766149dc12d197205b1632ec6e9fc663de05990.tar.gz manaserv-8766149dc12d197205b1632ec6e9fc663de05990.tar.bz2 manaserv-8766149dc12d197205b1632ec6e9fc663de05990.tar.xz manaserv-8766149dc12d197205b1632ec6e9fc663de05990.zip |
Basically redid equip and unequip functions().
I made the system handle the fact that equipment item
are completely unlinked to the inventory items.
Equip items now have a unique itemInstance number permitting
to equip the same item type multiple time when the slot capacity
is wide enough to do so.
I also prepared the functions to welcome in the near tests against
scripted equipment.
The equip process is known to be working server-side but the unequip
process has yet to be reviewed, even if implemented.
Diffstat (limited to 'src/game-server/inventory.h')
-rw-r--r-- | src/game-server/inventory.h | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/src/game-server/inventory.h b/src/game-server/inventory.h index 24d46942..06f55e06 100644 --- a/src/game-server/inventory.h +++ b/src/game-server/inventory.h @@ -58,25 +58,17 @@ class Inventory /** * Equips item from given inventory slot. - * @param slot The slot in which the target item is in. - * @param override Whether this item can unequip other items to equip - * itself. If true, items that are unequipped will be - * attempted to be reequipped, but with override disabled. + * @param inventorySlot The slot in which the target item is in. * @returns whether the item could be equipped. */ - bool equip(int slot, bool override = true); + bool equip(int inventorySlot); /** * Unequips item from given equipment slot. - * @param it Starting iterator. When the only parameter, also extracts - * slot number from it. - * Used so that when we already have an iterator to the first - * occurence from a previous operation we can start from - * there. + * @param equipmentSlot Where to remove item(s). * @returns Whether it was unequipped. */ - bool unequip(EquipData::iterator it); - bool unequip(unsigned int slot, EquipData::iterator *itp = 0); + bool unequip(unsigned int equipmentSlot); /** * Inserts some items into the inventory. @@ -115,6 +107,45 @@ class Inventory private: /** + * Tell whether the equipment slot has enough room in an equipment slot. + * @param equipmentSlot the slot in equipement to check. + * @param capacityRequested the capacity needed. + */ + bool checkEquipmentCapacity(unsigned int equipmentSlot, + unsigned int capacityRequested); + + /** + * Test whether the inventory has enough space to welcome + * the willing-to-be equipment slot. + * @todo + */ + bool hasInventoryEnoughSpace(unsigned int equipmentSlot) + { return false; } + + /** + * Test the items unequipment requirements. + * This is especially useful for scripted equipment. + * @todo + */ + bool testUnequipScriptRequirements(unsigned int equipementSlot) + { return true; } + + /** + * Test the items equipment for scripted requirements. + * @todo + */ + bool testEquipScriptRequirements(unsigned int itemId) + { return true; } + + /** + * Return an equip item instance id unique to the item used, + * per character. + * This is used to differenciate some items that can be equipped + * multiple times, like one-handed weapons for instance. + */ + unsigned int getNewEquipItemInstance(); + + /** * Check the inventory is within the slot limit and capacity. * Forcibly delete items from the end if it is not. * @todo Drop items instead? @@ -122,15 +153,7 @@ class Inventory void checkInventorySize(); /** - * Helper function for equip() when computing changes to equipment - * When newCount is 0, the item is being unequipped. - */ - // inventory slot -> {equip slots} - typedef std::multimap<unsigned int, unsigned short> IdSlotMap; - void equip_sub(unsigned int newCount, IdSlotMap::const_iterator &it); - - /** - * Changes equipment and adjusts character attributes. + * Apply equipment triggers. */ void updateEquipmentTrigger(unsigned int oldId, unsigned int itemId); void updateEquipmentTrigger(ItemClass *oldI, ItemClass *newI); |