| 854 | } |
| 855 | |
| 856 | Json PlayerInventory::store() const { |
| 857 | auto itemDatabase = Root::singleton().itemDatabase(); |
| 858 | |
| 859 | JsonArray customBar; |
| 860 | for (size_t i = 0; i < m_customBar.size(0); ++i) { |
| 861 | JsonArray customBarGroup; |
| 862 | for (size_t j = 0; j < m_customBar.size(1); ++j) { |
| 863 | auto const& cbl = m_customBar.at(i, j); |
| 864 | customBarGroup.append(JsonArray{jsonFromMaybe(cbl.first, jsonFromInventorySlot), jsonFromMaybe(cbl.second, jsonFromInventorySlot)}); |
| 865 | } |
| 866 | customBar.append(take(customBarGroup)); |
| 867 | } |
| 868 | |
| 869 | JsonObject itemBags; |
| 870 | for (auto& bag : m_bags) |
| 871 | itemBags.add(bag.first, bag.second->diskStore()); |
| 872 | |
| 873 | auto data = JsonObject{ |
| 874 | {"itemBags", itemBags}, |
| 875 | {"swapSlot", itemDatabase->diskStore(m_swapSlot)}, |
| 876 | {"trashSlot", itemDatabase->diskStore(m_trashSlot)}, |
| 877 | {"currencies", jsonFromMap(m_currencies)}, |
| 878 | {"customBarGroup", m_customBarGroup}, |
| 879 | {"customBar", std::move(customBar)}, |
| 880 | {"selectedActionBar", jsonFromSelectedActionBarLocation(m_selectedActionBar)}, |
| 881 | {"beamAxe", itemDatabase->diskStore(m_essential.value(EssentialItem::BeamAxe))}, |
| 882 | {"wireTool", itemDatabase->diskStore(m_essential.value(EssentialItem::WireTool))}, |
| 883 | {"paintTool", itemDatabase->diskStore(m_essential.value(EssentialItem::PaintTool))}, |
| 884 | {"inspectionTool", itemDatabase->diskStore(m_essential.value(EssentialItem::InspectionTool))} |
| 885 | }; |
| 886 | |
| 887 | for (auto& equipment : m_equipment) { |
| 888 | if (equipment.first <= EquipmentSlot::BackCosmetic || equipment.second) |
| 889 | data.set(strf("{}Slot", EquipmentSlotNames.getRight(equipment.first)), itemDatabase->diskStore(equipment.second)); |
| 890 | } |
| 891 | |
| 892 | data.set("equipmentVisibilityMask", m_equipmentVisibilityMask); |
| 893 | |
| 894 | return data; |
| 895 | } |
| 896 | |
| 897 | void PlayerInventory::forEveryItem(function<void(InventorySlot const&, ItemPtr&)> function) { |
| 898 | auto checkedFunction = [function = std::move(function)](InventorySlot const& slot, ItemPtr& item) { |
nothing calls this directly
no test coverage detected