* Initializes a item of the specified type. * @param rules Pointer to ruleset. * @param id The id of the item. */
| 31 | * @param id The id of the item. |
| 32 | */ |
| 33 | BattleItem::BattleItem(RuleItem *rules, int *id) : _id(*id), _rules(rules), _owner(0), _previousOwner(0), _unit(0), _tile(0), _inventorySlot(0), _inventoryX(0), _inventoryY(0), _ammoItem(0), _fuseTimer(-1), _ammoQuantity(0), _painKiller(0), _heal(0), _stimulant(0), _XCOMProperty(false), _droppedOnAlienTurn(false) |
| 34 | { |
| 35 | if (_rules && _rules->getBattleType() == BT_AMMO) |
| 36 | { |
| 37 | setAmmoQuantity(_rules->getClipSize()); |
| 38 | } else if (_rules && _rules->getBattleType() == BT_MEDIKIT) |
| 39 | { |
| 40 | setHealQuantity (_rules->getHealQuantity ()); |
| 41 | setPainKillerQuantity (_rules->getPainKillerQuantity ()); |
| 42 | setStimulantQuantity (_rules->getStimulantQuantity ()); |
| 43 | } |
| 44 | (*id)++; |
| 45 | |
| 46 | // weapon does not need ammo, ammo item points to weapon |
| 47 | if (_rules && (_rules->getBattleType() == BT_FIREARM || _rules->getBattleType() == BT_MELEE) && _rules->getCompatibleAmmo()->empty()) |
| 48 | { |
| 49 | setAmmoQuantity(_rules->getClipSize()); |
| 50 | _ammoItem = this; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * |
nothing calls this directly
no test coverage detected