Updated GetDynamicOfferCurrency to make use of existing weighting code

This commit is contained in:
Chomp
2025-02-26 12:36:35 +00:00
parent b3a82038e3
commit 6760b3ac05
+2 -14
View File
@@ -18,6 +18,7 @@ public class RagfairServerHelper(
DatabaseService databaseService,
ItemHelper itemHelper,
TraderHelper traderHelper,
WeightedRandomHelper weightedRandomHelper,
MailSendService mailSendService,
LocalisationService localisationService,
ConfigServer configServer,
@@ -182,20 +183,7 @@ public class RagfairServerHelper(
*/
public string GetDynamicOfferCurrency()
{
var currencies = ragfairConfig.Dynamic.Currencies;
var bias = new List<string>();
foreach (var currentKvP in currencies)
{
for (var i = 0; i < currentKvP.Value; i++)
{
bias.Add(currentKvP.Key);
}
}
var index = Math.Min((int) Math.Floor(randomUtil.RandNum(0, 1, 14) * bias.Count), 99);
return bias[index];
return weightedRandomHelper.GetWeightedValue(ragfairConfig.Dynamic.Currencies);
}
/**