Shopsanity Affordable Logic Update (#2617)

* Modified Affordable logic to select randomly from 10, 105, 205, and 505 depending on the selected wallet tier. Updated the tooltip to reflect.

* Clarified logic in comments and variable names.

* Streamlined affordable check for starter wallet.

One more function comment.

* More streamlining of affordable price generation, comment clarification.
This commit is contained in:
Malkierian 2023-03-13 14:24:51 -07:00 committed by GitHub
parent d9008938f8
commit 264623f40a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 21 deletions

View File

@ -128,31 +128,39 @@ static constexpr std::array<double, 60> ShopPriceProbability= {
0.959992180, 0.968187000, 0.975495390, 0.981884488, 0.987344345, 0.991851853, 0.995389113, 0.997937921, 0.999481947, 1.000000000,
};
std::map<uint8_t, int> affordableCaps = {
{RO_SHOPSANITY_PRICE_STARTER, 10},
{RO_SHOPSANITY_PRICE_ADULT, 105},
{RO_SHOPSANITY_PRICE_GIANT, 205},
{RO_SHOPSANITY_PRICE_TYCOON, 505},
};
// If affordable option is on, cap items at affordable price just above the max of the previous wallet tier
int CapPriceAffordable(int value, int cap) {
if (Settings::ShopsanityPricesAffordable.Is(true) && value > cap)
return cap;
return value;
}
// Generate random number from 5 to wallet max
int GetPriceFromMax(int max) {
int temp = Random(1, max) * 5; // random range of 1 - wallet max / 5, where wallet max is the highest it goes as a multiple of 5
return CapPriceAffordable(temp, affordableCaps.find(Settings::ShopsanityPrices.Value<uint8_t>())->second);
return Random(1, max) * 5; // random range of 1 - wallet max / 5, where wallet max is the highest it goes as a multiple of 5
}
// Get random price out of available "affordable prices", or just return 10 if Starter wallet is selected (no need to randomly select
// from a single element)
int GetPriceAffordable() {
if (Settings::ShopsanityPrices.Is(RO_SHOPSANITY_PRICE_STARTER)) {
return 10;
}
static const std::vector<int> affordablePrices = { 10, 105, 205, 505 };
std::vector<int> priceList;
uint8_t maxElements = Settings::ShopsanityPrices.Value<uint8_t>();
for (int i = 0; i < maxElements; i++) {
priceList.push_back(affordablePrices.at(i));
}
return RandomElement(priceList);
}
int GetRandomShopPrice() {
// If Affordable is enabled, no need to set randomizer max price
if (Settings::ShopsanityPricesAffordable.Is(true)) {
return GetPriceAffordable();
}
// max 0 means Balanced is selected, and thus shouldn't trigger GetPriceFromMax
int max = 0;
if(Settings::ShopsanityPrices.Is(RO_SHOPSANITY_PRICE_STARTER)) {// check for xx wallet setting and set max amount as method for
max = 19; // 95/5 // setting true randomization
// check settings for a wallet tier selection and set max amount as method for setting true randomization
if(Settings::ShopsanityPrices.Is(RO_SHOPSANITY_PRICE_STARTER)) {
max = 19; // 95/5
}
else if (Settings::ShopsanityPrices.Is(RO_SHOPSANITY_PRICE_ADULT)) {
max = 40; // 200/5

View File

@ -3094,7 +3094,7 @@ void DrawRandoEditor(bool& open) {
static const char* randoLinksPocket[4] = { "Dungeon Reward", "Advancement", "Anything", "Nothing" };
static const char* randoShuffleSongs[3] = { "Song Locations", "Dungeon Rewards", "Anywhere" };
static const char* randoShopsanity[7] = { "Off", "0 Items", "1 Item", "2 Items", "3 Items", "4 Items", "Random" };
static const char* randoShopsanityPrices[6] = { "Balanced", "Starter Wallet", "Adult Wallet", "Giant's Wallet", "Tycoon's Wallet", "Affordable" };
static const char* randoShopsanityPrices[5] = { "Balanced", "Starter Wallet", "Adult Wallet", "Giant's Wallet", "Tycoon's Wallet" };
static const char* randoTokensanity[4] = { "Off", "Dungeons", "Overworld", "All Tokens" };
static const char* randoShuffleScrubs[4] = { "Off", "Affordable", "Expensive", "Random Prices" };
static const char* randoShuffleMerchants[3] = { "Off", "On (no hints)", "On (with hints)" };
@ -3729,8 +3729,8 @@ void DrawRandoEditor(bool& open) {
UIWidgets::EnhancementCheckbox(Settings::ShopsanityPricesAffordable.GetName().c_str(), "gRandomizeShopsanityPricesAffordable",
CVarGetInteger("gRandomizeShopsanityPrices", RO_SHOPSANITY_PRICE_BALANCED) == RO_SHOPSANITY_PRICE_BALANCED,
"This can only apply to a wallet range.");
UIWidgets::InsertHelpHoverText("Cap item prices to a value just above the previous tier wallet's max value.\n"
"Affordable caps: starter = 10, adult = 105, giant = 205, tycoon = 505\n"
UIWidgets::InsertHelpHoverText("Random selection between the selected wallet tier's affordable price and the affordable prices of the preceding wallet tiers.\n\n"
"Affordable prices per tier: starter = 10, adult = 105, giant = 205, tycoon = 505\n\n"
"Use this to enable wallet tier locking, but make shop items not as expensive as they could be.");
}