Browse Source

♻️ Extract 'ItemStruct.isEquipment' method

pull/1148/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
08ffaa978c
  1. 4
      Source/inv.cpp
  2. 24
      Source/items.h

4
Source/inv.cpp

@ -654,9 +654,7 @@ bool CanBePlacedOnBelt(int playerNumber, const ItemStruct &item)
bool CanEquip(const ItemStruct &item)
{
return
item._iLoc != ILOC_INVALID &&
item._iLoc != ILOC_NONE &&
item._iLoc != ILOC_UNEQUIPABLE &&
item.isEquipment() &&
item._iStatFlag;
}

24
Source/items.h

@ -132,6 +132,30 @@ typedef struct ItemStruct {
return this->_itype == ITYPE_NONE;
}
/**
* @brief Checks whether this item is an equipment.
* @return 'True' in case the item is an equipment and 'False' otherwise.
*/
bool isEquipment() const
{
if (this->isEmpty()) {
return false;
}
switch (this->_iLoc) {
case ILOC_AMULET:
case ILOC_ARMOR:
case ILOC_HELM:
case ILOC_ONEHAND:
case ILOC_RING:
case ILOC_TWOHAND:
return true;
default:
return false;
}
}
} ItemStruct;
typedef struct ItemGetRecordStruct {

Loading…
Cancel
Save