MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / maxCraft

Method maxCraft

source/frontend/StarCraftingInterface.cpp:754–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752}
753
754int CraftingPane::maxCraft() {
755 if (m_player->isAdmin())
756 return m_maxSpinCount;
757 auto itemDb = Root::singleton().itemDatabase();
758 int res = 0;
759 if (m_guiList->selectedItem() != NPos && m_guiList->selectedItem() < m_recipes.size()) {
760 HashMap<ItemDescriptor, uint64_t> normalizedBag = m_player->inventory()->availableItems();
761 auto selectedRecipe = recipeFromSelectedWidget();
762 res = itemDb->maxCraftableInBag(normalizedBag, m_player->inventory()->availableCurrencies(), selectedRecipe);
763 res = std::min(res, m_maxSpinCount);
764 }
765 return res;
766}
767
768ItemRecipe CraftingPane::recipeFromSelectedWidget() const {
769 auto pane = m_guiList->selectedWidget();

Callers

nothing calls this directly

Calls 9

singletonClass · 0.85
itemDatabaseMethod · 0.80
availableItemsMethod · 0.80
inventoryMethod · 0.80
maxCraftableInBagMethod · 0.80
availableCurrenciesMethod · 0.80
isAdminMethod · 0.45
selectedItemMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected