Пример #1
0
        private void DoReroll(RollOptions ops, IDictionary <PoEModData, int> pool, ItemRarity targetrarity, bool ignoremeta, int count)
        {
            ItemCraft dummy = BenchItem.Copy();

            if (ignoremeta)
            {
                dummy.ClearCraftedMods();
            }
            dummy.ClearMods();
            dummy.Rarity = targetrarity;
            IDictionary <PoEModData, int> validatedpool = ModLogic.FindValidMods(dummy, pool, op: ops);

            DoCurrencyRolls((item) =>
            {
                if (ignoremeta)
                {
                    item.ClearCraftedMods();
                }
                item.ClearMods();
                item.Rarity = targetrarity;
                IDictionary <PoEModData, int> poolcopy = new Dictionary <PoEModData, int>(validatedpool);
                ModLogic.RollItem(item, poolcopy, ops);
                DoPostRoll(item, poolcopy);
                item.GenerateName();
            }, count);
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiceSet" /> class.
        /// </summary>
        /// <param name="dice">The dice to initialize the set with.</param>
        /// <param name="options">The dice roll options to apply.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="dice"/> or <paramref name="options"/> are <see langword="null"/></exception>
        public DiceSet([NotNull] IEnumerable <IDie> dice, [NotNull] IEnumerable <IDiceRollOption> options)
            : this(dice)
        {
            if (dice is null)
            {
                throw new ArgumentNullException(nameof(dice));
            }
            if (options is null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            foreach (var option in options)
            {
                RollOptions.Add(option);
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
        public string ApplyFossils(IList <PoEFossilData> fossils, int tries = 1)
        {
            if (BenchItem == null)
            {
                return("Bench is empty");
            }
            if (BenchItem.Rarity == ItemRarity.Magic)
            {
                return("Cannot apply fossils to a magic item");
            }
            ISet <IList <PoEModWeight> > modweightgroups = new HashSet <IList <PoEModWeight> >();
            ISet <PoEModData>            fossilmods      = new HashSet <PoEModData>();                    //forced mods from fossils
            int cesscount = 0;                                                                            //glyphic/tangled corrupted mod count
            IDictionary <PoEModData, int> extendedpool = new Dictionary <PoEModData, int>(BaseValidMods); //extra rollable mods
            PoEBaseItemData itemtemplate = CraftingDatabase.AllBaseItems[BenchItem.SourceData];

            foreach (PoEFossilData fossil in fossils)
            {
                foreach (string t in fossil.forbidden_tags)
                {
                    if (BenchItem.LiveTags.Contains(t))
                    {
                        return("Invalid item class for one or more selected fossils");
                    }
                }
                if (fossil.allowed_tags.Count > 0)
                {
                    bool allowed = false;
                    foreach (string t in fossil.allowed_tags)
                    {
                        if (BenchItem.LiveTags.Contains(t))
                        {
                            allowed = true;
                            break;
                        }
                    }
                    if (!allowed)
                    {
                        return("Invalid item class for one or more selected 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)
                {
                    fossilmods.Add(CraftingDatabase.AllMods[t]);
                }
                if (fossil.corrupted_essence_chance > 0)
                {
                    cesscount += fossil.corrupted_essence_chance;
                }
                modweightgroups.Add(fossil.negative_mod_weights);
                modweightgroups.Add(fossil.positive_mod_weights);
            }
            IList <PoEModData> forcedmods = new List <PoEModData>(ModLogic.FindBaseValidMods(itemtemplate, fossilmods, true).Keys);   //filter by spawn_weight first
            int fprefix = 0;
            int fsuffix = 0;

            foreach (PoEModData m in forcedmods)
            {
                if (m.generation_type == ModLogic.Prefix)
                {
                    fprefix++;
                }
                else
                {
                    fsuffix++;
                }
            }
            if (BenchItem.ModCountByType(ModLogic.Prefix, true) + fprefix > BenchItem.GetAffixLimit(true))
            {
                return("Item does not have space for forced prefix");
            }
            else if (BenchItem.ModCountByType(ModLogic.Suffix, true) + fsuffix > BenchItem.GetAffixLimit(true))
            {
                return("Item does not have space for forced suffix");
            }
            if (cesscount > 0)
            {
                //check that the item can roll a corrupted ess mod
                ItemCraft clone = BenchItem.Copy();
                clone.ClearMods();
                IDictionary <PoEModData, int> glyphicmods = ModLogic.FindGlyphicMods(clone, modweightgroups);
                if (glyphicmods.Count == 0)
                {
                    return("Item cannot roll forced corrupted essence mods");
                }
            }
            RollOptions ops = new RollOptions()
            {
                ForceMods = forcedmods, ModWeightGroups = modweightgroups, GlyphicCount = cesscount
            };

            if (tries == 1)
            {
                foreach (PoEFossilData fossil in fossils)
                {
                    TallyCurrency(fossil.key, 1);
                }
            }
            DoReroll(ops, extendedpool, ItemRarity.Rare, true, tries);
            return(null);
        }