Access dictionary keys correctly
This commit is contained in:
@@ -32,7 +32,7 @@ public class HealthController(
|
||||
/// </summary>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <param name="request">Healing request</param>
|
||||
/// <param name="sessionId">Player id</param>
|
||||
/// <param name="sessionID">Player id</param>
|
||||
/// <returns>ItemEventRouterResponse</returns>
|
||||
public ItemEventRouterResponse OffRaidHeal(
|
||||
PmcData pmcData,
|
||||
@@ -61,10 +61,10 @@ public class HealthController(
|
||||
else
|
||||
{
|
||||
// Get max healing from db
|
||||
var maxhp = _itemHelper.GetItem(healingItemToUse.Template).Value.Properties.MaxHpResource;
|
||||
var maxHp = _itemHelper.GetItem(healingItemToUse.Template).Value.Properties.MaxHpResource;
|
||||
healingItemToUse.Upd.MedKit = new UpdMedKit
|
||||
{
|
||||
HpResource = maxhp - request.Count
|
||||
HpResource = maxHp - request.Count
|
||||
}; // Subtract amout used from max
|
||||
// request.count appears to take into account healing effects removed, e.g. bleeds
|
||||
// Salewa heals limb for 20 and fixes light bleed = (20+45 = 65)
|
||||
@@ -87,7 +87,7 @@ public class HealthController(
|
||||
return output;
|
||||
}
|
||||
|
||||
// Get inital heal amount
|
||||
// Get initial heal amount
|
||||
var amountToHealLimb = request.Count;
|
||||
|
||||
// Check if healing item removes negative effects
|
||||
@@ -95,19 +95,18 @@ public class HealthController(
|
||||
if (itemRemovesEffects && bodyPartToHeal.Effects is not null)
|
||||
{
|
||||
// Can remove effects and limb has effects to remove
|
||||
var effectsOnBodyPart = bodyPartToHeal.Effects.Keys;
|
||||
foreach (var effectKey in effectsOnBodyPart)
|
||||
foreach (var effectKvP in bodyPartToHeal.Effects)
|
||||
{
|
||||
// Check if healing item removes the effect on limb
|
||||
if (!healItemEffectDetails.TryGetValue(Enum.Parse<DamageEffectType>(effectKey), out var matchingEffectFromHealingItem))
|
||||
if (!healItemEffectDetails.TryGetValue(Enum.Parse<DamageEffectType>(effectKvP.Key), out var matchingEffectFromHealingItem))
|
||||
// Healing item doesn't have matching effect, it doesn't remove the effect
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Adjust limb heal amount based on if its fixing an effect (request.count is TOTAL cost of hp resource on heal item, NOT amount to heal limb)
|
||||
// Adjust limb heal amount based on if it's fixing an effect (request.count is TOTAL cost of hp resource on heal item, NOT amount to heal limb)
|
||||
amountToHealLimb -= (int) (matchingEffectFromHealingItem.Cost ?? 0);
|
||||
bodyPartToHeal.Effects.Remove(effectKey);
|
||||
bodyPartToHeal.Effects.Remove(effectKvP.Key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -650,14 +650,14 @@ public class BotEquipmentModGenerator(
|
||||
}
|
||||
else
|
||||
{
|
||||
var containsModInPool = request.ModPool.Keys.Contains(modToAddTemplate.Value.Id);
|
||||
var containsModInPool = request.ModPool.ContainsKey(modToAddTemplate.Value.Id);
|
||||
|
||||
// Sometimes randomised slots are missing sub-mods, if so, get values from mod pool service
|
||||
// Check for a randomisable slot + without data in modPool + item being added as additional slots
|
||||
if (isRandomisableSlot && !containsModInPool && modToAddTemplate.Value.Properties.Slots.Any())
|
||||
{
|
||||
var modFromService = _botEquipmentModPoolService.GetModsForWeaponSlot(modToAddTemplate.Value.Id);
|
||||
if (modFromService?.Keys.Count > 0)
|
||||
if (modFromService?.Count > 0)
|
||||
{
|
||||
request.ModPool[modToAddTemplate.Value.Id] = modFromService.ToDictionary();
|
||||
containsModInPool = true;
|
||||
@@ -669,7 +669,7 @@ public class BotEquipmentModGenerator(
|
||||
{
|
||||
// Check for required mods the item we've added needs to be classified as 'valid'
|
||||
var modFromService = _botEquipmentModPoolService.GetRequiredModsForWeaponSlot(modToAddTemplate.Value.Id);
|
||||
if (modFromService?.Keys.Count > 0)
|
||||
if (modFromService?.Count > 0)
|
||||
{
|
||||
request.ModPool[modToAddTemplate.Value.Id] = modFromService;
|
||||
containsModInPool = true;
|
||||
|
||||
@@ -146,7 +146,7 @@ public class BotWeaponGenerator(
|
||||
}
|
||||
|
||||
// Add mods to weapon base
|
||||
if (modPool.Keys.Contains(weaponTpl))
|
||||
if (modPool.ContainsKey(weaponTpl))
|
||||
{
|
||||
// Role to treat bot as e.g. pmc/scav/boss
|
||||
var botEquipmentRole = _botGeneratorHelper.GetBotEquipmentRole(botRole);
|
||||
@@ -579,7 +579,7 @@ public class BotWeaponGenerator(
|
||||
protected string GetWeightedCompatibleAmmo(Dictionary<string, Dictionary<string, double>> cartridgePool, TemplateItem weaponTemplate)
|
||||
{
|
||||
var desiredCaliber = GetWeaponCaliber(weaponTemplate);
|
||||
if (!cartridgePool.TryGetValue(desiredCaliber, out var cartridgePoolForWeapon) || cartridgePoolForWeapon?.Keys.Count == 0)
|
||||
if (!cartridgePool.TryGetValue(desiredCaliber, out var cartridgePoolForWeapon) || cartridgePoolForWeapon?.Count == 0)
|
||||
{
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
|
||||
@@ -185,11 +185,11 @@ public class RagfairServerHelper(
|
||||
var currencies = ragfairConfig.Dynamic.Currencies;
|
||||
var bias = new List<string>();
|
||||
|
||||
foreach (var item in currencies.Keys)
|
||||
foreach (var currentKvP in currencies)
|
||||
{
|
||||
for (var i = 0; i < currencies[item]; i++)
|
||||
for (var i = 0; i < currentKvP.Value; i++)
|
||||
{
|
||||
bias.Add(item);
|
||||
bias.Add(currentKvP.Key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user