private void AddRow(PoEModData mod = null)
        {
            DockPanel p = new DockPanel()
            {
                Margin = new Thickness(5, 0, 5, 5), HorizontalAlignment = HorizontalAlignment.Stretch, Background = Brushes.AliceBlue
            };
            Button b = new Button()
            {
                Content = "X", Width = 20
            };

            b.Click += Remove_Click;
            DockPanel.SetDock(b, Dock.Left);
            p.Children.Add(b);
            SearchableComboBox c = new SearchableComboBox()
            {
                ItemsSource = new List <PoEModData>(BenchCrafts.Keys), HorizontalAlignment = HorizontalAlignment.Stretch, IsEditable = true, IsTextSearchEnabled = false
            };

            if (mod != null)
            {
                c.SelectedItem = mod;
            }
            p.Children.Add(c);
            ModList.Children.Add(p);
        }
Example #2
0
        //divines each mod, obeying "of prefixes" and "of suffixes" metamods and locked mods
        public bool RerollExplicits()
        {
            bool prefixlock = false;
            bool suffixlock = false;

            foreach (ModCraft m in LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (modtemplate.key == ModLogic.PrefixLock)
                {
                    prefixlock = true;
                }
                if (modtemplate.key == ModLogic.SuffixLock)
                {
                    suffixlock = true;
                }
            }
            bool valid = false;

            foreach (ModCraft m in LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (!m.IsLocked && !(prefixlock && modtemplate.generation_type == ModLogic.Prefix) && !(suffixlock && modtemplate.generation_type == ModLogic.Suffix))
                {
                    m.Reroll();
                    valid = true;
                }
            }
            return(valid);
        }
Example #3
0
        //remove all mods or all crafted mods, obeying prefix/suffix lock, leaving locked mods, and downgrading rarity if necessary
        public void ClearMods()
        {
            bool prefixlock = false;
            bool suffixlock = false;

            foreach (ModCraft m in LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (modtemplate.key == ModLogic.PrefixLock)
                {
                    prefixlock = true;
                }
                if (modtemplate.key == ModLogic.SuffixLock)
                {
                    suffixlock = true;
                }
            }
            for (int i = LiveMods.Count - 1; i >= 0; i--)
            {
                ModCraft   m           = LiveMods[i];
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (!m.IsLocked && !(prefixlock && modtemplate.generation_type == ModLogic.Prefix) && !(suffixlock && modtemplate.generation_type == ModLogic.Suffix))
                {
                    RemoveModAt(LiveMods, i);
                }
            }
        }
Example #4
0
        public void GenerateName()
        {
            PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[SourceData];

            ItemName = itemtemplate.name;
            if (Rarity == ItemRarity.Rare)
            {
                ItemName = GenRareName() + "\n" + itemtemplate.name;
            }
            else if (Rarity == ItemRarity.Magic)
            {
                foreach (ModCraft m in LiveMods)
                {
                    PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                    if (modtemplate.generation_type == ModLogic.Prefix)
                    {
                        ItemName = modtemplate.name + " " + ItemName;
                    }
                    else if (modtemplate.generation_type == ModLogic.Suffix)
                    {
                        ItemName = ItemName + " " + modtemplate.name;
                    }
                }
            }
        }
Example #5
0
        //Fills item with mods based on its rarity, pulling from basemods, destructively modifies basemods to reflect the rollable pool for new item
        public static bool RollItem(ItemCraft item, IDictionary <PoEModData, int> basemods, RollOptions op = null)
        {
            if (op != null && op.ForceMods != null)
            {
                foreach (PoEModData f in op.ForceMods)
                {
                    AddModAndTrim(item, basemods, f, op == null ? false : op.Sanctified);
                }
            }
            if (op != null && op.GlyphicCount > 0)
            {
                for (int i = 0; i < op.GlyphicCount / 100 + ((RNG.Gen.Next(100) < op.GlyphicCount % 100) ? 1 : 0); i++)
                {
                    IDictionary <PoEModData, int> glyphicmods = FindGlyphicMods(item, op.ModWeightGroups, op == null ? false : op.Sanctified);
                    if (glyphicmods.Count == 0)
                    {
                        break;
                    }
                    AddModAndTrim(item, basemods, ChooseMod(glyphicmods), op == null ? false : op.Sanctified);
                }
            }

            int modcount = RollModCount(item.Rarity, CraftingDatabase.AllBaseItems[item.SourceData].item_class);

            while (item.LiveMods.Count < modcount)
            {
                PoEModData mod = ChooseMod(basemods);
                if (mod == null)
                {
                    break;
                }
                AddModAndTrim(item, basemods, mod, op == null ? false : op.Sanctified);
            }
            return(true);
        }
Example #6
0
 public void AddEnchantment(PoEModData data)
 {
     InsertMod(LiveEnchantments, data);
     if (LiveEnchantments.Count > 1)
     {
         RemoveModAt(LiveEnchantments, 0);
     }
 }
Example #7
0
        //adds one mod from basemods to item, updates rarity, destructively modifies basemods to reflect new rollable pool, returns false if no mod was able to be added
        public static void RollAddMod(ItemCraft item, IDictionary <PoEModData, int> basemods)
        {
            PoEModData mod = ChooseMod(basemods);

            if (mod != null)
            {
                AddModAndTrim(item, basemods, mod);
            }
        }
Example #8
0
        //Finds valid corrupted essence mods and gives them (relative) weights based on the passed item and fossil weights
        public static IDictionary <PoEModData, int> FindGlyphicMods(ItemCraft item, ISet <IList <PoEModWeight> > weightmods, bool sanctified = false)
        {
            IDictionary <PoEModData, int> mods = new Dictionary <PoEModData, int>();
            string itemclass = CraftingDatabase.AllBaseItems[item.SourceData].item_class;

            if (itemclass == "Rune Dagger")
            {
                itemclass = "Dagger";
            }
            if (itemclass == "Warstaff")
            {
                itemclass = "Staff";
            }
            //check for open prefix/suffix
            bool openprefix = item.ModCountByType(Prefix) < item.GetAffixLimit(true);
            bool opensuffix = item.ModCountByType(Suffix) < item.GetAffixLimit(true);
            //track existing mod groups
            ISet <string> groups = new HashSet <string>();

            foreach (ModCraft m in item.LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                groups.Add(modtemplate.group);
            }
            IList <string> catalysttags = null;

            if (item.QualityType != null && CatalystTags.ContainsKey(item.QualityType))
            {
                catalysttags = CatalystTags[item.QualityType];
            }
            foreach (PoEEssenceData ess in CraftingDatabase.Essences.Values)
            {
                if (ess.type.is_corruption_only && ess.mods.Keys.Contains(itemclass))
                {
                    PoEModData m = CraftingDatabase.CoreMods[ess.mods[itemclass]];
                    if (m.generation_type == Prefix && !openprefix)
                    {
                        continue;
                    }
                    if (m.generation_type == Suffix && !opensuffix)
                    {
                        continue;
                    }
                    if (groups.Contains(m.group))
                    {
                        continue;
                    }
                    int weight = CalcGenWeight(m, item.LiveTags, weightmods, catalysttags, item.BaseQuality, sanctified, 1000);
                    if (weight > 0)
                    {
                        mods.Add(m, weight);
                    }
                }
            }
            return(mods);
        }
        //removes a mod and updates the item's tags accordingly
        private void RemoveModAt(IList <ModCraft> modlist, int n)
        {
            PoEModData modtemplate = CraftingDatabase.AllMods[modlist[n].SourceData];

            foreach (string tag in modtemplate.adds_tags)    //for each tag, only remove if no other live mods or implicits are applying the tag
            {
                bool shouldremove = true;
                for (int i = 0; i < LiveMods.Count; i++)
                {
                    if (LiveMods == modlist && i == n)
                    {
                        continue;
                    }
                    PoEModData othertemplate = CraftingDatabase.AllMods[LiveMods[i].SourceData];
                    if (othertemplate.adds_tags.Contains(tag))
                    {
                        shouldremove = false;
                        break;
                    }
                }
                for (int i = 0; i < LiveImplicits.Count; i++)
                {
                    if (LiveImplicits == modlist && i == n)
                    {
                        continue;
                    }
                    PoEModData othertemplate = CraftingDatabase.AllMods[LiveImplicits[i].SourceData];
                    if (othertemplate.adds_tags.Contains(tag))
                    {
                        shouldremove = false;
                        break;
                    }
                }
                for (int i = 0; i < LiveEnchantments.Count; i++)
                {
                    if (LiveEnchantments == modlist && i == n)
                    {
                        continue;
                    }
                    PoEModData othertemplate = CraftingDatabase.AllMods[LiveEnchantments[i].SourceData];
                    if (othertemplate.adds_tags.Contains(tag))
                    {
                        shouldremove = false;
                        break;
                    }
                }
                if (shouldremove)
                {
                    LiveTags.Remove(tag);
                }
            }
            modlist.RemoveAt(n);
        }
Example #10
0
        public int ModCountByType(string type, bool lockedonly = false)
        {
            int count = 0;

            foreach (ModCraft m in LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (modtemplate.generation_type == type && (!lockedonly || m.IsLocked))
                {
                    count++;
                }
            }
            return(count);
        }
Example #11
0
 public ModCraft(PoEModData data)
 {
     SourceData = data.key;
     Stats      = new List <ModRoll>();
     if (data.stats != null)
     {
         foreach (PoEModStat s in data.stats)
         {
             Stats.Add(new ModRoll(s));
         }
     }
     IsLocked = false;
     Quality  = 0;
 }
Example #12
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            KeyValuePair <PoEModData, object> kv = (KeyValuePair <PoEModData, object>)value;
            PoEModData data = kv.Key;

            if (kv.Value is string)
            {
                if (data.name == "Subterranean" || data.name == "of the Underground")
                {
                    return(Brushes.Gold);
                }
                else
                {
                    return(Brushes.Orchid);
                }
            }
            else
            {
                if (data.name == "Subterranean" || data.name == "of the Underground")
                {
                    return(Brushes.Gold);
                }
                if (Utils.EnumConverter.InfToNames(ItemInfluence.Shaper).Contains(data.name))
                {
                    return(Brushes.DodgerBlue);
                }
                if (Utils.EnumConverter.InfToNames(ItemInfluence.Elder).Contains(data.name))
                {
                    return(Brushes.Gray);
                }
                if (Utils.EnumConverter.InfToNames(ItemInfluence.Redeemer).Contains(data.name))
                {
                    return(Brushes.LightBlue);
                }
                if (Utils.EnumConverter.InfToNames(ItemInfluence.Hunter).Contains(data.name))
                {
                    return(Brushes.LightGreen);
                }
                if (Utils.EnumConverter.InfToNames(ItemInfluence.Warlord).Contains(data.name))
                {
                    return(WarlordBrush);
                }
                if (Utils.EnumConverter.InfToNames(ItemInfluence.Crusader).Contains(data.name))
                {
                    return(Brushes.Pink);
                }
            }
            return(Brushes.White);
        }
Example #13
0
        public string ApplyEssence(PoEEssenceData ess, int tries = 1)
        {
            if (BenchItem == null)
            {
                return("Bench is empty");
            }
            if (ess.level <= 5 && BenchItem.Rarity != ItemRarity.Normal || ess.level > 5 && BenchItem.Rarity != ItemRarity.Rare)
            {
                return("Invalid item rarity for selected essence");
            }
            string itemclass = CraftingDatabase.AllBaseItems[BenchItem.SourceData].item_class;

            if (itemclass == "Rune Dagger")
            {
                itemclass = "Dagger";
            }
            if (itemclass == "Warstaff")
            {
                itemclass = "Staff";
            }
            if (!ess.mods.Keys.Contains(itemclass))
            {
                return("Invalid item class for selected essence");
            }
            PoEModData mod = CraftingDatabase.CoreMods[ess.mods[itemclass]];

            if (mod.generation_type == ModLogic.Prefix && BenchItem.ModCountByType(ModLogic.Prefix, true) >= BenchItem.GetAffixLimit(true))
            {
                return("Item does not have space for forced prefix");
            }
            else if (mod.generation_type == ModLogic.Suffix && BenchItem.ModCountByType(ModLogic.Suffix, true) >= BenchItem.GetAffixLimit(true))
            {
                return("Item does not have space for forced suffix");
            }
            RollOptions op = new RollOptions()
            {
                ForceMods = new List <PoEModData>()
                {
                    mod
                }, ILvlCap = ess.item_level_restriction ?? 200
            };

            if (tries == 1)
            {
                TallyCurrency(ess.key, 1);
            }
            DoReroll(op, BaseValidMods, ItemRarity.Rare, true, tries);
            return(null);
        }
Example #14
0
        //remove crafted mods, ignoring metamod locks
        public bool ClearCraftedMods()
        {
            int removedcount = 0;

            for (int i = LiveMods.Count - 1; i >= 0; i--)
            {
                ModCraft   m           = LiveMods[i];
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (!m.IsLocked && modtemplate.domain == "crafted")
                {
                    RemoveModAt(LiveMods, i);
                    removedcount++;
                }
            }
            return(removedcount > 0);
        }
Example #15
0
        //Starts from basemods and checks ilvl, live tags (including influence), existing mod groups, option to ignore prefix/suffix space, checks ilvlcap and modweightgroups from RollOptions
        public static IDictionary <PoEModData, int> FindValidMods(ItemCraft item, IDictionary <PoEModData, int> basemods, bool ignorerarity = false, RollOptions op = null)
        {
            IDictionary <PoEModData, int> mods = new Dictionary <PoEModData, int>();

            if (item == null)
            {
                return(mods);
            }
            //check for open prefix/suffix
            bool openprefix = item.ModCountByType(Prefix) < item.GetAffixLimit(ignorerarity);
            bool opensuffix = item.ModCountByType(Suffix) < item.GetAffixLimit(ignorerarity);
            //list existing mod groups
            ISet <string> groups = new HashSet <string>();

            foreach (ModCraft m in item.LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                groups.Add(modtemplate.group);
            }
            int levelcap = (op != null && op.ILvlCap > 0 && op.ILvlCap < item.ItemLevel) ? op.ILvlCap : item.ItemLevel;

            foreach (PoEModData mod in basemods.Keys)
            {
                //intentionally not checking against domain here to allow delve mods, shouldn't be a problem since domain was filtered before
                if (!openprefix && mod.generation_type == Prefix || !opensuffix && mod.generation_type == Suffix)
                {
                    continue;
                }
                if (mod.required_level > levelcap || groups.Contains(mod.group))
                {
                    continue;
                }
                IList <string> catalysttags = null;
                if (item.QualityType != null && CatalystTags.ContainsKey(item.QualityType))
                {
                    catalysttags = CatalystTags[item.QualityType];
                }
                int w = CalcGenWeight(mod, item.LiveTags, op?.ModWeightGroups, catalysttags, item.BaseQuality, op == null ? false : op.Sanctified);
                if (w > 0)
                {
                    mods.Add(mod, w);
                }
            }
            return(mods);
        }
Example #16
0
        private void InsertMod(IList <ModCraft> modlist, PoEModData template)
        {
            ModCraft m = new ModCraft(template);
            int      i = 0;

            while (i < modlist.Count)
            {
                if ((template.generation_type == ModLogic.Prefix && CraftingDatabase.AllMods[modlist[i].SourceData].generation_type != ModLogic.Prefix) ||
                    (template.generation_type == ModLogic.Suffix && CraftingDatabase.AllMods[modlist[i].SourceData].generation_type != ModLogic.Prefix && CraftingDatabase.AllMods[modlist[i].SourceData].generation_type != ModLogic.Suffix))
                {
                    break;
                }
                i++;
            }
            modlist.Insert(i, new ModCraft(template));
            LiveTags.UnionWith(template.adds_tags);
            UpdateModQuality(m, QualityType);
        }
Example #17
0
        //Uses benchops to find relevant mod templates in db for the item base
        public static IDictionary <PoEModData, IDictionary <string, int> > FindValidBenchMods(PoEBaseItemData item, ISet <PoEBenchOption> benchops, IDictionary <string, PoEModData> db)
        {
            IDictionary <PoEModData, IDictionary <string, int> > mods = new Dictionary <PoEModData, IDictionary <string, int> >();

            if (item == null)
            {
                return(mods);
            }
            foreach (PoEBenchOption b in benchops)
            {
                if (b.mod_id == null || !b.item_classes.Contains(item.item_class))
                {
                    continue;
                }
                PoEModData mod = db[b.mod_id];
                mods.Add(mod, b.cost);
            }
            return(mods);
        }
Example #18
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PoEModData data = value as PoEModData;
            string     s    = data.name + "; lvl " + data.required_level;

            foreach (PoEModWeight w in data.spawn_weights)
            {
                if (w.tag == "no_attack_mods" && w.weight == 0)
                {
                    s += "; meta-attack";
                }
                else if (w.tag == "no_caster_mods" && w.weight == 0)
                {
                    s += "; meta-caster";
                }
            }
            s += "; " + string.Join(",", data.type_tags);
            return(s);
        }
Example #19
0
        //removes one mod at random, obeying prefix/suffix lock, and leaving locked mods
        public bool RemoveRandomMod()
        {
            bool prefixlock = false;
            bool suffixlock = false;

            foreach (ModCraft m in LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (modtemplate.key == ModLogic.PrefixLock)
                {
                    prefixlock = true;
                }
                if (modtemplate.key == ModLogic.SuffixLock)
                {
                    suffixlock = true;
                }
            }
            IList <ModCraft> choppingblock = new List <ModCraft>();

            foreach (ModCraft m in LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                if (!m.IsLocked && !(prefixlock && modtemplate.generation_type == ModLogic.Prefix) && !(suffixlock && modtemplate.generation_type == ModLogic.Suffix))
                {
                    choppingblock.Add(m);
                }
            }
            if (choppingblock.Count > 0)
            {
                int n = RNG.Gen.Next(choppingblock.Count);
                LiveMods.Remove(choppingblock[n]);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #20
0
        private void UpdateModQuality(ModCraft mod, string name)
        {
            PoEModData     modtemplate = CraftingDatabase.AllMods[mod.SourceData];
            IList <string> tags;

            if (name != null && ModLogic.CatalystTags.Keys.Contains(name))
            {
                tags = ModLogic.CatalystTags[name];
            }
            else
            {
                tags = new List <string>();
            }
            bool match = false;

            foreach (string s in tags)
            {
                if (modtemplate.type_tags.Contains(s))
                {
                    match = true;
                    break;
                }
            }
            if (modtemplate.type_tags.Contains(ModLogic.CatalystIgnore))
            {
                match = false;
            }
            if (match)
            {
                mod.Quality = BaseQuality;
            }
            else
            {
                mod.Quality = 0;
            }
        }
Example #21
0
        public void UpdateData(ItemCraft item)
        {
            SourceItem = item;
            PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[item.SourceData];

            if (item != null)
            {
                ItemNameBox.ToolTip    = "tags: " + string.Join(", ", item.LiveTags);
                ItemNameBox.Foreground = new SolidColorBrush(EnumConverter.RarityToColor(item.Rarity));
                ItemNameBox.Text       = item.ItemName;
                ItemDataBox.Text       = "ilvl: " + item.ItemLevel + " ";
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Shaper)]))
                {
                    ItemDataBox.Text += "  Shaper";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Elder)]))
                {
                    ItemDataBox.Text += "  Elder";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Redeemer)]))
                {
                    ItemDataBox.Text += "  Redeemer";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Hunter)]))
                {
                    ItemDataBox.Text += "  Hunter";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Warlord)]))
                {
                    ItemDataBox.Text += "  Warlord";
                }
                if (item.LiveTags.Contains(itemtemplate.item_class_properties[EnumConverter.InfToTag(ItemInfluence.Crusader)]))
                {
                    ItemDataBox.Text += "  Crusader";
                }
                EnchantmentBox.Children.Clear();
                foreach (ModCraft m in item.LiveEnchantments)
                {
                    TextBlock tb = new TextBlock()
                    {
                        TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Color.FromRgb(184, 218, 242))
                    };
                    tb.Text    = m.ToString();
                    tb.ToolTip = CraftingDatabase.AllMods[m.SourceData].ToString();
                    //HookEvents(tb);
                    EnchantmentBox.Children.Add(tb);
                }
                ImplicitBox.Children.Clear();
                foreach (ModCraft m in item.LiveImplicits)
                {
                    TextBlock tb = new TextBlock()
                    {
                        TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Color.FromRgb(184, 218, 242))
                    };
                    tb.Text    = m.ToString();
                    tb.ToolTip = CraftingDatabase.AllMods[m.SourceData].ToString();
                    HookEvents(tb);
                    ImplicitBox.Children.Add(tb);
                }
                ItemModBox.Children.Clear();
                foreach (ModCraft m in item.LiveMods)
                {
                    PoEModData modtemplate = CraftingDatabase.AllMods[m.SourceData];
                    DockPanel  dock        = new DockPanel();

                    string header = "";
                    if (modtemplate.generation_type == ModLogic.Prefix)
                    {
                        header = "[P] ";
                    }
                    else if (modtemplate.generation_type == ModLogic.Suffix)
                    {
                        header = "[S] ";
                    }
                    TextBlock affix = new TextBlock()
                    {
                        FontWeight = FontWeights.Bold, Foreground = Brushes.DarkGray, Text = header
                    };
                    DockPanel.SetDock(affix, Dock.Right);
                    dock.Children.Add(affix);
                    if (AllowEdit)
                    {
                        Button lockbutton = new Button()
                        {
                            Width = 20, Tag = m
                        };
                        Image lockimg = new Image {
                            Source = m.IsLocked ? Icons.Lock : Icons.Unlock
                        };
                        lockbutton.Content    = lockimg;
                        lockbutton.Background = m.IsLocked ? Brushes.Red : Brushes.Green;
                        lockbutton.Click     += LockButton_Click;
                        DockPanel.SetDock(lockbutton, Dock.Left);
                        dock.Children.Add(lockbutton);
                    }
                    StackPanel     sp        = new StackPanel();
                    IList <string> statlines = m.ToString().Split('\n');
                    foreach (string s in statlines)
                    {
                        TextBlock tb = new TextBlock()
                        {
                            TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Text = s, ToolTip = modtemplate.name + ": " + modtemplate
                        };
                        if (modtemplate.domain == "crafted")
                        {
                            tb.Foreground = new SolidColorBrush(Color.FromRgb(184, 218, 242));
                        }
                        else
                        {
                            tb.Foreground = new SolidColorBrush(Color.FromRgb(136, 136, 255));
                        }
                        HookEvents(tb);
                        sp.Children.Add(tb);
                    }
                    dock.Children.Add(sp);
                    ItemModBox.Children.Add(dock);
                }
                FillPropertyBox(item);
                if (item.TempProps != null)
                {
                    foreach (string tp in item.TempProps.Keys)
                    {
                        TextBlock tb = new TextBlock()
                        {
                            TextWrapping = TextWrapping.Wrap, FontWeight = FontWeights.Bold, Foreground = Brushes.DarkGray, Text = tp + ": " + item.TempProps[tp], Tag = tp
                        };
                        HookEvents(tb);
                        TempPropBox.Children.Add(tb);
                    }
                }
            }
            else
            {
                ItemNameBox.Foreground = Brushes.White;
                ItemNameBox.Text       = "";
                ItemDataBox.Text       = "";
                PropertyBox.Children.Clear();
                ImplicitBox.Children.Clear();
                ItemModBox.Children.Clear();
                TempPropBox.Children.Clear();
            }
        }
Example #22
0
        //baseweightoverride used for corrupted essence mods from glyphic/tangled because their templates have no base weights
        private static int CalcGenWeight(PoEModData mod, ISet <string> tags, ISet <IList <PoEModWeight> > weightgroups = null, IList <string> catalysttags = null, int catalystquality = 0, bool sanctified = false, int?baseweightoverride = null)
        {
            int weight = 0;

            if (mod.spawn_weights != null)
            {
                foreach (PoEModWeight w in mod.spawn_weights)
                {
                    if (tags.Contains(w.tag))
                    {
                        weight = w.weight;
                        break;
                    }
                }
            }
            if (baseweightoverride != null)
            {
                weight = baseweightoverride.Value;
            }
            if (mod.generation_weights != null)
            {
                foreach (PoEModWeight w in mod.generation_weights)
                {
                    if (tags.Contains(w.tag))
                    {
                        weight = weight * w.weight / 100;
                        break;
                    }
                }
            }
            if (!mod.type_tags.Contains(CatalystIgnore) && catalysttags != null)
            {
                bool applycatqual = false;
                foreach (string t in mod.type_tags)
                {
                    if (catalysttags.Contains(t))
                    {
                        applycatqual = true;
                        break;
                    }
                }
                if (applycatqual)
                {
                    weight = (int)(weight * (100 + catalystquality * CatalystEffect) / 100);
                }
            }
            if (weightgroups != null)
            {
                double sumnegs = 0;
                int    sumadds = 0;
                foreach (IList <PoEModWeight> l in weightgroups)
                {
                    foreach (PoEModWeight w in l)
                    {
                        if (mod.type_tags.Contains(w.tag))
                        {
                            if (w.weight > 100)
                            {
                                sumadds += w.weight;
                            }
                            else if (w.weight != 0)
                            {
                                sumnegs += (double)100 / w.weight;
                            }
                            else
                            {
                                weight = 0;
                            }
                            break;
                        }
                    }
                    if (weight == 0)
                    {
                        break;
                    }
                }
                weight = weight * Math.Max(sumadds, 100) / 100;
                weight = (int)(weight / Math.Max(sumnegs, 1));
            }
            if (sanctified)
            {
                weight = weight * (60 + mod.required_level) / 100;
            }
            return(weight);
        }
Example #23
0
        //Adds a mod directly to target item (or bench item) if legal; updates costs if provided; modifies mod pool accordingly if provided
        public string ForceAddMod(PoEModData mod, ItemCraft target = null, IDictionary <string, int> costs = null, IDictionary <PoEModData, int> pool = null)
        {
            target = target ?? BenchItem;
            if (mod.generation_type == ModLogic.Prefix)
            {
                if (target.ModCountByType(ModLogic.Prefix) >= target.GetAffixLimit(true))
                {
                    return("Item cannot have another prefix");
                }
            }
            else
            {
                if (target.ModCountByType(ModLogic.Suffix) >= target.GetAffixLimit(true))
                {
                    return("Item cannot have another suffix");
                }
            }
            foreach (ModCraft livemod in target.LiveMods)
            {
                PoEModData modtemplate = CraftingDatabase.AllMods[livemod.SourceData];
                if (modtemplate.group == mod.group)
                {
                    return("Item already has a mod in this mod group");
                }
            }
            if (mod.domain == "crafted")   //if crafted check the specific cases of quality craft on item w/ quality mod, and conversion glove mod
            {
                if (target.LiveTags.Contains("local_item_quality"))
                {
                    foreach (PoEModWeight w in mod.spawn_weights)
                    {
                        if (w.tag == "local_item_quality" && w.weight == 0)
                        {
                            return("Cannot craft quality on an item with another quality mod");
                        }
                    }
                }
                if (target.LiveTags.Contains("has_physical_conversion_mod") && mod.adds_tags.Contains("has_physical_conversion_mod"))
                {
                    return("Item already has a physical conversion mod");
                }
                //This check turned out to the too restrictive. Many crafted mods have 0 spawn weight on item types they should be craftable on.
                //if (ModLogic.CalcGenWeight(mod, target.LiveTags) <= 0)
                //    return "Invalid craft for current item and/or item mods";
            }
            PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[target.SourceData];

            //if it's an influenced mod, add the appropriate tag
            foreach (ItemInfluence inf in Enum.GetValues(typeof(ItemInfluence)))
            {
                if (EnumConverter.InfToNames(inf).Contains(mod.name))
                {
                    string inftag = itemtemplate.item_class_properties[EnumConverter.InfToTag((ItemInfluence)inf)];
                    if (inftag != null)
                    {
                        target.LiveTags.Add(inftag);
                    }
                    break;
                }
            }
            //if a mod pool is provided, updated it accordingly, otherwise just add the mod directly
            if (pool != null)
            {
                ModLogic.AddModAndTrim(target, pool, mod);
            }
            else
            {
                target.AddMod(mod);
            }
            ItemRarity newrarity = target.GetMinimumRarity();

            if (newrarity > target.Rarity)
            {
                target.Rarity = newrarity;
            }
            if (costs != null && target == BenchItem)
            {
                foreach (string s in costs.Keys)
                {
                    TallyCurrency(s, costs[s]);
                }
            }
            return(null);
        }
Example #24
0
 public static void FillTranslationData(PoEModData mod)
 {
     mod.full_translation = TranslateModData(mod);
 }
Example #25
0
        //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);
        }
Example #26
0
        //made private for new implementation - this is only called once on load
        //accurate when called from a mod's ToString(), but repeating lots of live translations is slow
        private static string TranslateModData(PoEModData mod)
        {
            IList <PoEModStat> statscopy = new List <PoEModStat>(mod.stats);
            IList <string>     lines     = new List <string>();

            while (statscopy.Count > 0)
            {
                string id = statscopy[0].id;
                if (!Data.ContainsKey(id))
                {
                    //Debug.WriteLine("skipping stat translation for " + id);
                    statscopy.RemoveAt(0);
                    continue;
                }
                StatLocalization chunk = Data[id];
                IList <int>      min   = new List <int>();
                IList <int>      max   = new List <int>();
                for (int i = 0; i < chunk.ids.Count; i++)       //copy out minmax and remove handled stats from statcopy
                {
                    int found = -1;
                    for (int j = 0; j < statscopy.Count; j++)
                    {
                        if (statscopy[j].id == chunk.ids[i])
                        {
                            found = j;
                            min.Add(statscopy[j].min);
                            max.Add(statscopy[j].max);
                            break;
                        }
                    }
                    if (found < 0)
                    {
                        min.Add(0);
                        max.Add(0);
                    }
                    else
                    {
                        statscopy.RemoveAt(found);
                    }
                }

                if (chunk.hidden)
                {
                    continue;
                }
                LocalizationDefinition def = null;
                foreach (LocalizationDefinition d in chunk.definitions)     //find matching definition
                {
                    if (MeetsCondition(max, d.condition))
                    {
                        def = d;
                        break;
                    }
                }
                if (def == null)
                {
                    continue;
                }
                string linetext = BuildText(def.text, min, max, def.format, def.index_handlers);
                lines.Add(linetext);
            }
            return(string.Join("\n", lines));
        }
Example #27
0
 public void AddImplicit(PoEModData data)
 {
     InsertMod(LiveImplicits, data);
 }
Example #28
0
 public void AddMod(PoEModData data)
 {
     InsertMod(LiveMods, data);
 }
Example #29
0
 public void AddMod(PoEModData data, bool lucky = false)
 {
     InsertMod(LiveMods, data, lucky);
 }