* Checks if two items can be stacked on one another. * @param itemA First item. * @param itemB Second item. * @return True, if the items can be stacked on one another. */
| 925 | * @return True, if the items can be stacked on one another. |
| 926 | */ |
| 927 | bool Inventory::canBeStacked(BattleItem *itemA, BattleItem *itemB) |
| 928 | { |
| 929 | //both items actually exist |
| 930 | return (itemA != 0 && itemB != 0 && |
| 931 | //both items have the same ruleset |
| 932 | itemA->getRules() == itemB->getRules() && |
| 933 | // either they both have no ammo |
| 934 | ((!itemA->getAmmoItem() && !itemB->getAmmoItem()) || |
| 935 | // or they both have ammo |
| 936 | (itemA->getAmmoItem() && itemB->getAmmoItem() && |
| 937 | // and the same ammo type |
| 938 | itemA->getAmmoItem()->getRules() == itemB->getAmmoItem()->getRules() && |
| 939 | // and the same ammo quantity |
| 940 | itemA->getAmmoItem()->getAmmoQuantity() == itemB->getAmmoItem()->getAmmoQuantity())) && |
| 941 | // and neither is set to explode |
| 942 | itemA->getFuseTimer() == -1 && itemB->getFuseTimer() == -1 && |
| 943 | // and neither is a corpse or unconscious unit |
| 944 | itemA->getUnit() == 0 && itemB->getUnit() == 0 && |
| 945 | // and if it's a medkit, it has the same number of charges |
| 946 | itemA->getPainKillerQuantity() == itemB->getPainKillerQuantity() && |
| 947 | itemA->getHealQuantity() == itemB->getHealQuantity() && |
| 948 | itemA->getStimulantQuantity() == itemB->getStimulantQuantity()); |
| 949 | |
| 950 | } |
| 951 | } |
nothing calls this directly
no test coverage detected