Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }