From 73e9ad6c4eb1b2c0ba38c9bd50eec8b811506c90 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 14 Jul 2021 18:02:49 +0200 Subject: [PATCH] fixed Descriptions and detection. --- SlotsSlotsSlots/Program.cs | 93 ++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/SlotsSlotsSlots/Program.cs b/SlotsSlotsSlots/Program.cs index 5611935..5533433 100644 --- a/SlotsSlotsSlots/Program.cs +++ b/SlotsSlotsSlots/Program.cs @@ -53,61 +53,66 @@ public static void RunPatch(IPatcherState state) (HashSet> carryWeight, HashSet> health) magicEffects = MagicEffects(state); - var carryWeightSpells = new HashSet<(Dictionary> SpellAndEffects,Dictionary> EffectAndMagnitudes)>(); + var carryWeightSpells = new HashSet<(Dictionary> SpellAndEffects,Dictionary> EffectAndMagnitudes)>(); - var SpellAndEffects = new Dictionary>(); + var SpellAndEffects = new Dictionary>(); var EffectAndMagnitudes = new Dictionary>(); foreach (var spell in state.LoadOrder.PriorityOrder.Spell().WinningOverrides()) { - var deepCopySpell = spell.DeepCopy(); - foreach (var e in deepCopySpell.Effects) - { - if (magicEffects.carryWeight.Contains(e.BaseEffect)) + if (!spell.EditorID.ToString().Equals("AbDragon")) { + var deepCopySpell = spell.DeepCopy(); + foreach (var e in deepCopySpell.Effects) { - float startingMagnitude = e.Data.Magnitude; - e.Data.Magnitude *= effectMultiplier; - - SpellAndEffects.GetOrAdd(spell.FormKey).Add(e.BaseEffect.FormKey); - - var finalMagnitudesHashSet = new HashSet(); - finalMagnitudesHashSet.Add((int)startingMagnitude); - if (EffectAndMagnitudes.TryGetValue(e.BaseEffect.FormKey, out var magnitudesHashSet)) + foreach (var carryWeightEffect in magicEffects.carryWeight) { - foreach (var magnitudeInSet in magnitudesHashSet) + if (e.BaseEffect.Equals(carryWeightEffect)) { - finalMagnitudesHashSet.Add(magnitudeInSet); - finalMagnitudesHashSet.Add(magnitudeInSet + (int)startingMagnitude); - } - } + float startingMagnitude = e.Data.Magnitude; - EffectAndMagnitudes.GetOrAdd(e.BaseEffect.FormKey).UnionWith(finalMagnitudesHashSet); + e.Data.Magnitude *= effectMultiplier; - carryWeightSpells.Add((SpellAndEffects,EffectAndMagnitudes)); + SpellAndEffects.GetOrAdd(spell.FormKey).Add(e.BaseEffect.FormKey); - if (deepCopySpell.Description.ToString().Contains($"carry") || deepCopySpell.Description.ToString().Contains($"Carry")) - { - if ((int)e.Data.Magnitude != 1) - { - deepCopySpell.Description = deepCopySpell.Description - .ToString() - .Replace($"{(int)startingMagnitude}", $"{(int)e.Data.Magnitude}") - .Replace($"Carry Weight is", "Slots are") - .Replace($"Carry Weight", $"Slots"); - Console.WriteLine($"{spell.EditorID.ToString()} was considered a CarryWeight altering Spell and the description, if needed, adjusted:\n \"{ deepCopySpell.Description}\"\n"); - } - else - { - deepCopySpell.Description = deepCopySpell.Description - .ToString() - .Replace($"{(int)startingMagnitude}", $"{(int)e.Data.Magnitude}") - .Replace($"Carry Weight is", "Slots are") - .Replace($"Carry Weight", $"Slot"); - Console.WriteLine($"{spell.EditorID.ToString()} was considered a CarryWeight altering Spell and the description, if needed, adjusted:\n \"{ deepCopySpell.Description}\"\n"); + var finalMagnitudesHashset = new HashSet(); + finalMagnitudesHashset.Add((int)startingMagnitude); + if (EffectAndMagnitudes.TryGetValue(e.BaseEffect.FormKey, out var magnitudesHashSet)) + { + foreach (var magnitudeInSet in magnitudesHashSet) + { + finalMagnitudesHashset.Add(magnitudeInSet); + finalMagnitudesHashset.Add(magnitudeInSet + (int)startingMagnitude); + } + } + EffectAndMagnitudes.GetOrAdd(e.BaseEffect.FormKey).UnionWith(finalMagnitudesHashset); + + carryWeightSpells.Add((SpellAndEffects, EffectAndMagnitudes)); + + if ((deepCopySpell.Description.ToString().Contains($"carry") || deepCopySpell.Description.ToString().Contains($"Carry")) && deepCopySpell.Description.ToString().Contains($"{(int)startingMagnitude}")) + { + if ((int)e.Data.Magnitude != 1) + { + deepCopySpell.Description = deepCopySpell.Description + .ToString() + .Replace($"{(int)startingMagnitude}", $"{(int)e.Data.Magnitude}") + .Replace($"Carry Weight is", "Slots are") + .Replace($"Carry Weight", $"Slots"); + Console.WriteLine($"{spell.EditorID.ToString()} was considered a CarryWeight altering Spell and the description, if needed, adjusted:\n \"{ deepCopySpell.Description}\"\n"); + } + else + { + deepCopySpell.Description = deepCopySpell.Description + .ToString() + .Replace($"{(int)startingMagnitude}", $"{(int)e.Data.Magnitude}") + .Replace($"Carry Weight is", "Slots are") + .Replace($"Carry Weight", $"Slot"); + Console.WriteLine($"{spell.EditorID.ToString()} was considered a CarryWeight altering Spell and the description, if needed, adjusted:\n \"{ deepCopySpell.Description}\"\n"); + } + } + state.PatchMod.Spells.Set(deepCopySpell); } } - state.PatchMod.Spells.Set(deepCopySpell); } } }; @@ -131,11 +136,11 @@ public static void RunPatch(IPatcherState state) { foreach (var spellEffect in spellEffectSet) { - if (carryWeightSpell.EffectAndMagnitudes.TryGetValue(spellEffect, out var magnitudesHashSet)) + if (carryWeightSpell.EffectAndMagnitudes.TryGetValue(spellEffect, out var magnitudesList)) { - foreach (int magnitude in magnitudesHashSet) + foreach (int magnitude in magnitudesList) { - if ((deepCopyPerk.Description.ToString().Contains($"carry") || deepCopyPerk.Description.ToString().Contains($"Carry")) && deepCopyPerk.Description.ToString().Contains($" {magnitude} ")) + if ((deepCopyPerk.Description.ToString().Contains($"carry") || deepCopyPerk.Description.ToString().Contains($"Carry")) && deepCopyPerk.Description.ToString().Contains($"{magnitude}")) { int slots = (int)(magnitude * effectMultiplier); if (slots != 1)