diff --git a/conf/mod_ahbot.conf.dist b/conf/mod_ahbot.conf.dist index 4efb21e..1be7dcf 100644 --- a/conf/mod_ahbot.conf.dist +++ b/conf/mod_ahbot.conf.dist @@ -41,6 +41,29 @@ AuctionHouseBot.EnableBuyer = 0 AuctionHouseBot.GUIDs = 0 AuctionHouseBot.ItemsPerCycle = 75 +############################################################################### +# AuctionHouseBot.ListedItemLevelRestrict.Enabled +# If true, the item level will be restricted in listings +# Default: false +# +# AuctionHouseBot.ListedItemLevelRestrict.MaxItemLevel +# The highest item level that will show up in listings +# Default: 999 +# +# AuctionHouseBot.ListedItemLevelRestrict.MinItemLevel +# The lowest item level that will show up in listings +# Default: 0 +# +# AuctionHouseBot.ListedItemLevelRestrict.ExceptionItemIDs +# Comma separated list of itemIDs to exclude from any item level restriction logic +# Ranges using a dash (-) can also be used +# NOTE: The disabled item list will still be honored even if it's listed here +############################################################################### +AuctionHouseBot.ListedItemLevelRestrict.Enabled = false +AuctionHouseBot.ListedItemLevelRestrict.MaxItemLevel = 999 +AuctionHouseBot.ListedItemLevelRestrict.MinItemLevel = 0 +AuctionHouseBot.ListedItemLevelRestrict.ExceptionItemIDs = + ############################################################################### # AuctionHouseBot..MinItems # AuctionHouseBot..MaxItems diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 5872873..edf2365 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -263,12 +263,17 @@ void AuctionHouseBot::populateItemCandidateList() if (itr->second.ItemId == 0) continue; - // Always store items that are exceptions - if (includeItemIDExecptions.find(itr->second.ItemId) != includeItemIDExecptions.end()) + // If there is an iLevel exception, honor it + if (ListedItemLevelRestrictedEnabled == true) { - // Store the item ID - itemCandidatesByItemClass[itr->second.Class].push_back(itr->second.ItemId); - continue; + // Only test if it's not an exception + if (ListedItemLevelExceptionItems.find(itr->second.ItemId) == ListedItemLevelExceptionItems.end()) + { + if (itr->second.ItemLevel < ListedItemLevelMin) + continue; + if (itr->second.ItemLevel > ListedItemLevelMax) + continue; + } } // Disabled items by Id @@ -279,6 +284,14 @@ void AuctionHouseBot::populateItemCandidateList() continue; } + // These items should be included and would otherwise be skipped due to conditions below + if (includeItemIDExecptions.find(itr->second.ItemId) != includeItemIDExecptions.end()) + { + // Store the item ID + itemCandidatesByItemClass[itr->second.Class].push_back(itr->second.ItemId); + continue; + } + // Skip any items not in the seed list if (std::find(itemCandidateClassWeightedProportionList.begin(), itemCandidateClassWeightedProportionList.end(), itr->second.Class) == itemCandidateClassWeightedProportionList.end()) continue; @@ -797,6 +810,12 @@ void AuctionHouseBot::InitializeConfiguration() ItemsPerCycle = sConfigMgr->GetOption("AuctionHouseBot.ItemsPerCycle", 75); + // Item level Restrictions + ListedItemLevelRestrictedEnabled = sConfigMgr->GetOption("AuctionHouseBot.ListedItemLevelRestrict.Enabled", false); + ListedItemLevelMax = sConfigMgr->GetOption("AuctionHouseBot.ListedItemLevelRestrict.MaxItemLevel", 999); + ListedItemLevelMin = sConfigMgr->GetOption("AuctionHouseBot.ListedItemLevelRestrict.MinItemLevel", 0); + AddItemLevelExceptionItems(sConfigMgr->GetOption("AuctionHouseBot.ListedItemLevelRestrict.ExceptionItemIDs", "")); + // Stack Ratios RandomStackRatioConsumable = GetRandomStackValue("AuctionHouseBot.RandomStackRatio.Consumable", 20); RandomStackRatioContainer = GetRandomStackValue("AuctionHouseBot.RandomStackRatio.Container", 0); @@ -909,6 +928,20 @@ uint32 AuctionHouseBot::GetRandomStackValue(std::string configKeyString, uint32 return stackValue; } +void AuctionHouseBot::AddToListedItemLevelExceptionItems(std::set& workingExceptionItemIDs, uint32 itemLevelExceptionItemID) +{ + if (workingExceptionItemIDs.find(itemLevelExceptionItemID) != workingExceptionItemIDs.end()) + { + if (debug_Out) + LOG_ERROR("module", "AuctionHouseBot: Duplicate item level exxception item ID of {} found, skipping", itemLevelExceptionItemID); + } + else + { + workingExceptionItemIDs.insert(itemLevelExceptionItemID); + } +} + + void AuctionHouseBot::AddToDisabledItems(std::set& workingDisabledItemIDs, uint32 disabledItemID) { if (workingDisabledItemIDs.find(disabledItemID) != workingDisabledItemIDs.end()) @@ -1020,6 +1053,45 @@ void AuctionHouseBot::AddDisabledItems(std::string disabledItemIdString) } } +void AuctionHouseBot::AddItemLevelExceptionItems(std::string itemLevelExceptionIdString) +{ + std::string delimitedValue; + std::stringstream itemLevelExceptionItemIdStream; + + itemLevelExceptionItemIdStream.str(itemLevelExceptionIdString); + while (std::getline(itemLevelExceptionItemIdStream, delimitedValue, ',')) // Process each item ID in the string, delimited by the comma "," + { + std::string valueOne; + std::stringstream itemPairStream(delimitedValue); + itemPairStream >> valueOne; + // If it has a hypen, then it's a range of numbers + if (valueOne.find("-") != std::string::npos) + { + std::string leftIDString = valueOne.substr(0, valueOne.find("-")); + std::string rightIDString = valueOne.substr(valueOne.find("-") + 1); + + auto leftId = atoi(leftIDString.c_str()); + auto rightId = atoi(rightIDString.c_str()); + + if (leftId > rightId) + { + LOG_ERROR("module", "AuctionHouseBot: Duplicate item level exception item ID range of {} to {} needs to be smallest to largest, skipping", leftId, rightId); + } + else + { + for (int32 i = leftId; i <= rightId; ++i) + AddToListedItemLevelExceptionItems(ListedItemLevelExceptionItems, i); + } + + } + else + { + auto itemId = atoi(valueOne.c_str()); + AddToListedItemLevelExceptionItems(ListedItemLevelExceptionItems, itemId); + } + } +} + void AuctionHouseBot::AddPriceMinimumOverrides(std::string priceMinimimOverridesString) { std::string delimitedValue; diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index a012a19..71fcdee 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -148,6 +148,10 @@ private: uint32 ItemsPerCycle; bool DisabledItemTextFilter; std::set DisabledItems; + bool ListedItemLevelRestrictedEnabled; + int32 ListedItemLevelMax; + int32 ListedItemLevelMin; + std::set ListedItemLevelExceptionItems; uint32 RandomStackRatioConsumable; uint32 RandomStackRatioContainer; uint32 RandomStackRatioWeapon; @@ -255,6 +259,8 @@ public: void AddCharacters(std::string characterGUIDString); void AddToDisabledItems(std::set& workingDisabledItemIDs, uint32 disabledItemID); void AddDisabledItems(std::string disabledItemIdString); + void AddToListedItemLevelExceptionItems(std::set& workingExceptionItemIDs, uint32 itemLevelExceptionItemID); + void AddItemLevelExceptionItems(std::string itemLevelExceptionIdString); void AddPriceMinimumOverrides(std::string priceMinimimOverridesString); };