| 145 | } |
| 146 | |
| 147 | bool PlayerInventory::setItem(InventorySlot const& slot, ItemPtr const& item) { |
| 148 | if (auto currencyItem = as<CurrencyItem>(item)) { |
| 149 | m_currencies[currencyItem->currencyType()] += currencyItem->totalValue(); |
| 150 | return true; |
| 151 | } else if (auto es = slot.ptr<EquipmentSlot>()) { |
| 152 | if (itemAllowedAsEquipment(item, *es)) { |
| 153 | m_equipment[*es] = item; |
| 154 | return true; |
| 155 | } |
| 156 | } else if (slot.is<SwapSlot>()) { |
| 157 | m_swapSlot = item; |
| 158 | return true; |
| 159 | } else if (slot.is<TrashSlot>()) { |
| 160 | m_trashSlot = item; |
| 161 | return true; |
| 162 | } else { |
| 163 | auto bs = slot.get<BagSlot>(); |
| 164 | if (itemAllowedInBag(item, bs.first)) { |
| 165 | m_bags[bs.first]->setItem(bs.second, item); |
| 166 | return true; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | bool PlayerInventory::consumeSlot(InventorySlot const& slot, uint64_t count) { |
| 174 | if (count == 0) |
no test coverage detected