/** * Sets the item's ammo item. * @param item BattleItem * @return -2 when ammo doesn't fit, or -1 when weapon already contains ammo */ int BattleItem::setAmmoItem(BattleItem *item) { if (!needsAmmo()) return -2; if (item == 0) { _ammoItem = 0; return 0; } if (_ammoItem) return -1; if (_rules->isCompatible(item->getRules())) { _ammoItem = item; return 0; } return -2; }
/** * Sets the item's ammo item. * @param item BattleItem * @return -2 when ammo doesn't fit, or -1 when weapon already contains ammo */ int BattleItem::setAmmoItem(BattleItem *item) { if (!needsAmmo()) return -2; if (item == 0) { _ammoItem = 0; return 0; } if (_ammoItem) return -1; for (std::vector<std::string>::iterator i = _rules->getCompatibleAmmo()->begin(); i != _rules->getCompatibleAmmo()->end(); ++i) { if (*i == item->getRules()->getType()) { _ammoItem = item; return 0; } } return -2; }