* Checks if there's an inventory item in * the specified inventory position. * @param slot Inventory slot. * @param x X position in slot. * @param y Y position in slot. * @return Item in the slot, or NULL if none. */
| 1673 | * @return Item in the slot, or NULL if none. |
| 1674 | */ |
| 1675 | BattleItem *BattleUnit::getItem(RuleInventory *slot, int x, int y) const |
| 1676 | { |
| 1677 | // Soldier items |
| 1678 | if (slot->getType() != INV_GROUND) |
| 1679 | { |
| 1680 | for (std::vector<BattleItem*>::const_iterator i = _inventory.begin(); i != _inventory.end(); ++i) |
| 1681 | { |
| 1682 | if ((*i)->getSlot() == slot && (*i)->occupiesSlot(x, y)) |
| 1683 | { |
| 1684 | return *i; |
| 1685 | } |
| 1686 | } |
| 1687 | } |
| 1688 | // Ground items |
| 1689 | else if (_tile != 0) |
| 1690 | { |
| 1691 | for (std::vector<BattleItem*>::const_iterator i = _tile->getInventory()->begin(); i != _tile->getInventory()->end(); ++i) |
| 1692 | { |
| 1693 | if ((*i)->occupiesSlot(x, y)) |
| 1694 | { |
| 1695 | return *i; |
| 1696 | } |
| 1697 | } |
| 1698 | } |
| 1699 | return 0; |
| 1700 | } |
| 1701 | |
| 1702 | /** |
| 1703 | * Checks if there's an inventory item in |
no test coverage detected