MCPcopy Create free account
hub / github.com/TurningWheel/Barony / alchemyAddRecipe

Function alchemyAddRecipe

src/interface/interface.cpp:9017–9083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9015}
9016
9017bool alchemyAddRecipe(int player, int basePotion, int secondaryPotion, int result, bool ignorePotionTypes = false)
9018{
9019 if ( basePotion == POTION_WATER || secondaryPotion == POTION_WATER
9020 || basePotion == secondaryPotion || basePotion == POTION_POLYMORPH
9021 || secondaryPotion == POTION_POLYMORPH )
9022 {
9023 if ( !ignorePotionTypes )
9024 {
9025 return false;
9026 }
9027 }
9028 if ( GenericGUI[player].isItemBaseIngredient(secondaryPotion) && GenericGUI[player].isItemSecondaryIngredient(basePotion) )
9029 {
9030 // keep the orders consistent, base then secondary
9031 int swapBasePotion = basePotion;
9032 basePotion = secondaryPotion;
9033 secondaryPotion = swapBasePotion;
9034 }
9035 bool found = false;
9036 for ( auto& entry : clientLearnedAlchemyRecipes[player] )
9037 {
9038 if ( entry.first == result
9039 && ((entry.second.first == basePotion && entry.second.second == secondaryPotion)
9040 || (entry.second.first == secondaryPotion && entry.second.second == basePotion)) )
9041 {
9042 return false; // already exists
9043 }
9044 }
9045 if ( !found )
9046 {
9047 clientLearnedAlchemyRecipes[player].push_back(std::make_pair(result, std::make_pair(basePotion, secondaryPotion)));
9048 if ( !hideRecipeFromList(result) )
9049 {
9050 std::string itemName = items[result].getIdentifiedName();
9051 size_t pos = std::string::npos;
9052 for ( auto& potionName : Player::SkillSheet_t::skillSheetData.potionNamesToFilter )
9053 {
9054 if ( (pos = itemName.find(potionName)) != std::string::npos )
9055 {
9056 itemName.erase(pos, potionName.length());
9057 }
9058 }
9059 capitalizeString(itemName);
9060 std::string iconPath = "";
9061 node_t* imagePathsNode = nullptr;
9062 for ( auto it = potionStandardAppearanceMap.begin(); it != potionStandardAppearanceMap.end(); ++it )
9063 {
9064 // loop through to get the standard appearance
9065 if ( (*it).first == result )
9066 {
9067 Uint32 index = (*it).second % items[result].variations;
9068 imagePathsNode = list_Node(&items[result].images, index);
9069 if ( imagePathsNode )
9070 {
9071 string_t* imagePath = static_cast<string_t*>(imagePathsNode->element);
9072 iconPath = imagePath->data;
9073 }
9074 }

Callers 1

alchemyCombinePotionsMethod · 0.85

Calls 10

hideRecipeFromListFunction · 0.85
list_NodeFunction · 0.85
AlchNotification_tClass · 0.85
messagePlayerColorFunction · 0.85
makeColorRGBFunction · 0.85
isItemBaseIngredientMethod · 0.80
getIdentifiedNameMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected