//Adds mod to item, destructively modifies basemods to reflect the new rollable pool public static void AddModAndTrim(ItemCraft item, IDictionary <PoEModData, int> basemods, PoEModData mod, bool lucky = false) { ISet <string> newtags = new HashSet <string>(mod.adds_tags); ISet <string> oldtags = new HashSet <string>(item.LiveTags); foreach (string s in oldtags) { newtags.Remove(s); } string addedgroup = mod.group; item.AddMod(mod, lucky); string affixfill = null; if (mod.generation_type == Prefix && item.ModCountByType(Prefix) >= item.GetAffixLimit()) { affixfill = Prefix; } else if (mod.generation_type == Suffix && item.ModCountByType(Suffix) >= item.GetAffixLimit()) { affixfill = Suffix; } TrimMods(basemods, oldtags, newtags, addedgroup, affixfill); }
public void UpdatePreviews() { if (Bench == null || Bench.BenchItem == null || Currency == null) { WeightedModsDisplay.UpdateData(new Dictionary <PoEModData, object>()); return; } ItemCraft itemcopy = Bench.BenchItem.Copy(); RollOptions ops = new RollOptions(); IDictionary <PoEModData, int> extendedpool = new Dictionary <PoEModData, int>(Bench.BaseValidMods); PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[itemcopy.SourceData]; //Shaper = null/invalid; inf and temp tags used for the 4 conquerors' exalts ItemInfluence inf = ItemInfluence.Shaper; IList <PoEModData> forcedmods = new List <PoEModData>(); int cesscount = 0; object c = Currency.GetSelected(); if (c is PoEEssenceData e) { string itemclass = itemtemplate.item_class; if (itemclass == "Rune Dagger") { itemclass = "Dagger"; } if (itemclass == "Warstaff") { itemclass = "Staff"; } if (e.mods.Keys.Contains(itemclass)) { forcedmods.Add(CraftingDatabase.CoreMods[e.mods[itemclass]]); } ops.ILvlCap = e.item_level_restriction ?? 200; itemcopy.ClearCraftedMods(); itemcopy.ClearMods(); } else if (c is PoECurrencyData) { string currency = ((PoECurrencyData)c).name; if (itemcopy.GetInfluences().Count == 0) { if (currency == "Redeemer's Exalted Orb") { inf = ItemInfluence.Redeemer; } else if (currency == "Hunter's Exalted Orb") { inf = ItemInfluence.Hunter; } else if (currency == "Warlord's Exalted Orb") { inf = ItemInfluence.Warlord; } else if (currency == "Crusader's Exalted Orb") { inf = ItemInfluence.Crusader; } if (inf != ItemInfluence.Shaper) { string tag = itemtemplate.item_class_properties[Utils.EnumConverter.InfToTag(inf)]; if (tag != null) //temporarily add influence tag { itemcopy.LiveTags.Add(tag); } } } if (inf == ItemInfluence.Shaper) //if selected item isn't a conq exalt { //if it's a reroll currency, preview as if the item has been scoured if (currency == "Chaos Orb" || currency == "Orb of Alchemy" || currency == "Orb of Transmutation" || currency == "Orb of Alteration") { itemcopy.ClearMods(); } } } else if (c != null) { IList <PoEFossilData> fossils = ((System.Collections.IList)c).Cast <PoEFossilData>().ToList(); ISet <IList <PoEModWeight> > modweightgroups = new HashSet <IList <PoEModWeight> >(); foreach (PoEFossilData fossil in fossils) { foreach (string t in fossil.added_mods) { if (!extendedpool.ContainsKey(CraftingDatabase.AllMods[t])) { extendedpool.Add(CraftingDatabase.AllMods[t], 0); } } foreach (string t in fossil.forced_mods) { forcedmods.Add(CraftingDatabase.AllMods[t]); } forcedmods = new List <PoEModData>(ModLogic.FindBaseValidMods(itemtemplate, forcedmods, true).Keys); if (fossil.corrupted_essence_chance > 0) { cesscount += fossil.corrupted_essence_chance; } modweightgroups.Add(fossil.negative_mod_weights); modweightgroups.Add(fossil.positive_mod_weights); } ops.ModWeightGroups = modweightgroups; itemcopy.ClearCraftedMods(); itemcopy.ClearMods(); } foreach (PoEModData d in forcedmods) { itemcopy.AddMod(d); } IDictionary <PoEModData, int> validmods = ModLogic.FindValidMods(itemcopy, extendedpool, true, ops); if (inf != ItemInfluence.Shaper) //if a conq exalt is selected, only show influenced mods { validmods = ModLogic.FilterForInfluence(validmods, inf); } IDictionary <PoEModData, object> mods = new Dictionary <PoEModData, object>(); foreach (PoEModData d in validmods.Keys) { mods.Add(d, validmods[d]); } foreach (PoEModData d in forcedmods) { mods.Add(d, "Always"); } if (cesscount > 0) { IDictionary <PoEModData, int> glyphicmods = ModLogic.FindGlyphicMods(itemcopy, ops.ModWeightGroups); if (glyphicmods.Count > 0) { int weightsum = 0; foreach (PoEModData d in glyphicmods.Keys) { weightsum += glyphicmods[d]; } foreach (PoEModData d in glyphicmods.Keys) { mods.Add(d, "Special: " + ((double)cesscount / 100).ToString("0.#") + " x " + ((double)glyphicmods[d] * 100 / weightsum).ToString("N0") + "%"); } } } WeightedModsDisplay.UpdateData(mods); }