Ejemplo n.º 1
0
 private void DoPostRoll(ItemCraft item, IDictionary <PoEModData, int> pool)
 {
     if (PostRoll.TryCrafts != null)
     {
         foreach (KeyValuePair <PoEModData, IDictionary <string, int> > kv in PostRoll.TryCrafts)
         {
             string ret = ForceAddMod(kv.Key, item, kv.Value, pool);
             if (ret == null)
             {
                 break;
             }
         }
     }
     if (PostRoll.FillAffix)
     {
         while (item.LiveMods.Count < item.GetAffixLimit() * 2)
         {
             ModLogic.RollAddMod(item, pool);
             if (item.QualityType != null)
             {
                 if (item.Rarity == ItemRarity.Rare)
                 {
                     item.BaseQuality -= 20;
                 }
                 else
                 {
                     item.BaseQuality -= 2;
                 }
             }
         }
     }
     if (PostRoll.Maximize)
     {
         item.MaximizeMods();
     }
 }
Ejemplo n.º 2
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);
        }