Repeatable quest warning fixes
This commit is contained in:
+6
-6
@@ -177,7 +177,7 @@ public class CompletionQuestGenerator(
|
||||
/// <returns>Filtered selection, or original if null or empty</returns>
|
||||
protected HashSet<MongoId> GetWhitelistedItemSelection(HashSet<MongoId> itemSelection, int pmcLevel)
|
||||
{
|
||||
var itemWhitelist = databaseService.GetTemplates().RepeatableQuests?.Data?.Completion?.ItemsWhitelist;
|
||||
var itemWhitelist = databaseService.GetTemplates().RepeatableQuests.Data?.Completion?.ItemsWhitelist;
|
||||
|
||||
// Whitelist doesn't exist or is empty, return original
|
||||
if (itemWhitelist is null || itemWhitelist.Count == 0)
|
||||
@@ -186,7 +186,7 @@ public class CompletionQuestGenerator(
|
||||
}
|
||||
|
||||
// Filter and concatenate items according to current player level
|
||||
var itemIdsWhitelisted = itemWhitelist.Where(p => p.MinPlayerLevel <= pmcLevel).SelectMany(x => x.ItemIds).ToHashSet(); //.Aggregate((a, p) => a.Concat(p.ItemIds), []);
|
||||
var itemIdsWhitelisted = itemWhitelist.Where(p => p.MinPlayerLevel <= pmcLevel).SelectMany(x => x.ItemIds ?? []).ToHashSet(); //.Aggregate((a, p) => a.Concat(p.ItemIds), []);
|
||||
|
||||
var filteredSelection = itemSelection
|
||||
.Where(x =>
|
||||
@@ -211,7 +211,7 @@ public class CompletionQuestGenerator(
|
||||
/// <returns>Filtered selection, or original if null or empty</returns>
|
||||
protected HashSet<MongoId> GetBlacklistedItemSelection(HashSet<MongoId> itemSelection, int pmcLevel)
|
||||
{
|
||||
var itemBlacklist = databaseService.GetTemplates().RepeatableQuests?.Data?.Completion?.ItemsBlacklist;
|
||||
var itemBlacklist = databaseService.GetTemplates().RepeatableQuests.Data?.Completion?.ItemsBlacklist;
|
||||
|
||||
// Blacklist doesn't exist or is empty, return original
|
||||
if (itemBlacklist is null || itemBlacklist.Count == 0)
|
||||
@@ -222,7 +222,7 @@ public class CompletionQuestGenerator(
|
||||
// Filter and concatenate the arrays according to current player level
|
||||
var itemIdsBlacklisted = itemBlacklist
|
||||
.Where(blacklist => blacklist.MinPlayerLevel <= pmcLevel)
|
||||
.SelectMany(blacklist => blacklist.ItemIds)
|
||||
.SelectMany(blacklist => blacklist.ItemIds ?? [])
|
||||
.ToHashSet(); //.Aggregate(List<ItemsBlacklist> , (a, p) => a.Concat(p.ItemIds) );
|
||||
|
||||
var filteredSelection = itemSelection
|
||||
@@ -288,7 +288,7 @@ public class CompletionQuestGenerator(
|
||||
usedItemIndexes.Add(chosenItemIndex);
|
||||
|
||||
var tplChosen = itemSelection[chosenItemIndex];
|
||||
var itemPrice = itemHelper.GetItemPrice(tplChosen).Value;
|
||||
var itemPrice = itemHelper.GetItemPrice(tplChosen)!.Value;
|
||||
var minValue = completionConfig.MinimumRequestedAmount;
|
||||
var maxValue = completionConfig.MaximumRequestedAmount;
|
||||
|
||||
@@ -308,7 +308,7 @@ public class CompletionQuestGenerator(
|
||||
|
||||
// Push a CompletionCondition with the item and the amount of the item into quest
|
||||
chosenRequirementItemsTpls.Add(tplChosen);
|
||||
quest.Conditions.AvailableForFinish.Add(GenerateCondition(tplChosen, value, repeatableConfig.QuestConfig.CompletionConfig));
|
||||
quest.Conditions.AvailableForFinish!.Add(GenerateCondition(tplChosen, value, repeatableConfig.QuestConfig.CompletionConfig));
|
||||
|
||||
// Is there budget left for more items
|
||||
if (roublesBudget > 0)
|
||||
|
||||
+7
-7
@@ -344,7 +344,7 @@ public class RepeatableQuestRewardGenerator(
|
||||
if (itemHelper.IsOfBaseclass(chosenItemFromPool.Id, BaseClasses.AMMO))
|
||||
{
|
||||
// Don't reward ammo that stacks to less than what's allowed in config
|
||||
if (chosenItemFromPool.Properties.StackMaxSize < repeatableConfig.RewardAmmoStackMinSize)
|
||||
if (chosenItemFromPool.Properties?.StackMaxSize < repeatableConfig.RewardAmmoStackMinSize)
|
||||
{
|
||||
i--;
|
||||
continue;
|
||||
@@ -441,7 +441,7 @@ public class RepeatableQuestRewardGenerator(
|
||||
var rewardItemPrice = presetHelper.GetDefaultPresetOrItemPrice(item.Id);
|
||||
|
||||
// Define price tiers and corresponding stack size options
|
||||
var priceTiers = new List<Tuple<int, List<int>?>>
|
||||
var priceTiers = new List<Tuple<int, List<int>>>
|
||||
{
|
||||
new(3000, [2, 3, 4]),
|
||||
new(10000, [2, 3]),
|
||||
@@ -452,7 +452,7 @@ public class RepeatableQuestRewardGenerator(
|
||||
var tier = priceTiers.FirstOrDefault(tier => rewardItemPrice < tier.Item1);
|
||||
if (tier is null)
|
||||
{
|
||||
return 4; // Default to 2 if no tier matches
|
||||
return 4; // Default to 4 if no tier matches
|
||||
}
|
||||
|
||||
return randomUtil.GetArrayValue(tier.Item2);
|
||||
@@ -467,15 +467,15 @@ public class RepeatableQuestRewardGenerator(
|
||||
/// <returns> List of reward items that fit budget </returns>
|
||||
protected List<TemplateItem> ChooseRewardItemsWithinBudget(
|
||||
RepeatableQuestConfig repeatableConfig,
|
||||
double? roublesBudget,
|
||||
double roublesBudget,
|
||||
MongoId traderId
|
||||
)
|
||||
{
|
||||
// First filter for type and baseclass to avoid lookup in handbook for non-available items
|
||||
var rewardableItemPool = GetRewardableItems(repeatableConfig, traderId);
|
||||
var minPrice = Math.Min(25000, 0.5 * roublesBudget.Value);
|
||||
var minPrice = Math.Min(25000, 0.5 * roublesBudget);
|
||||
|
||||
var rewardableItemPoolWithinBudget = FilterRewardPoolWithinBudget(rewardableItemPool, roublesBudget.Value, minPrice);
|
||||
var rewardableItemPoolWithinBudget = FilterRewardPoolWithinBudget(rewardableItemPool, roublesBudget, minPrice);
|
||||
|
||||
if (rewardableItemPoolWithinBudget.Count == 0)
|
||||
{
|
||||
@@ -533,7 +533,7 @@ public class RepeatableQuestRewardGenerator(
|
||||
if (presetPrice <= roublesBudget)
|
||||
{
|
||||
logger.Debug($"Added weapon: {tpls[0]}with price: {presetPrice}");
|
||||
var chosenPreset = cloner.Clone(randomPreset);
|
||||
var chosenPreset = cloner.Clone(randomPreset)!;
|
||||
|
||||
return new KeyValuePair<Reward, double>(
|
||||
GeneratePresetReward(chosenPreset.Encyclopedia.Value, 1, rewardIndex, chosenPreset.Items),
|
||||
|
||||
@@ -461,19 +461,19 @@ public record CompletionConfig : BaseQuestConfig
|
||||
/// Should the supplied items be required FiR
|
||||
/// </summary>
|
||||
[JsonPropertyName("requiredItemsAreFiR")]
|
||||
public bool? RequiredItemsAreFiR { get; set; }
|
||||
public required bool RequiredItemsAreFiR { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Should the supplied items be required FiR
|
||||
/// Min/Max durability requirements for the item
|
||||
/// </summary>
|
||||
[JsonPropertyName("requiredItemMinDurabilityMinMax")]
|
||||
public MinMax<double>? RequiredItemMinDurabilityMinMax { get; set; }
|
||||
public required MinMax<double> RequiredItemMinDurabilityMinMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Blacklisted item types to not collect
|
||||
/// </summary>
|
||||
[JsonPropertyName("requiredItemTypeBlacklist")]
|
||||
public HashSet<MongoId>? RequiredItemTypeBlacklist { get; set; }
|
||||
public required HashSet<MongoId> RequiredItemTypeBlacklist { get; set; }
|
||||
}
|
||||
|
||||
public record Pickup : BaseQuestConfig
|
||||
|
||||
Reference in New Issue
Block a user