| 98 | } |
| 99 | |
| 100 | ItemPtr PlayerInventory::stackWith(InventorySlot const& slot, ItemPtr const& items) { |
| 101 | if (!items || items->empty()) |
| 102 | return {}; |
| 103 | |
| 104 | if (auto es = slot.ptr<EquipmentSlot>()) { |
| 105 | auto& itemSlot = retrieve(slot); |
| 106 | if (!itemSlot && itemAllowedAsEquipment(items, *es)) |
| 107 | m_equipment[*es] = items->take(1); |
| 108 | } else { |
| 109 | auto& dest = retrieve(slot); |
| 110 | if (dest && dest->stackableWith(items)) |
| 111 | dest->stackWith(items); |
| 112 | if (!dest) |
| 113 | dest = items->take(items->count()); |
| 114 | } |
| 115 | |
| 116 | if (items->empty()) |
| 117 | return {}; |
| 118 | |
| 119 | return items; |
| 120 | } |
| 121 | |
| 122 | ItemPtr PlayerInventory::takeSlot(InventorySlot const& slot) { |
| 123 | if (slot.is<SwapSlot>()) |
no test coverage detected