Exemplo n.º 1
0
 // this factors in the material list
 public static int CalculateRecipeRepeat(Recipe recipe)
 {
     int repeat = (from ingred in recipe.Ingredients
                   let ingredCnt = (int) ingred.InBagItemCount -
                                   (Professionbuddy.Instance.MaterialList.ContainsKey(ingred.ID)
                                        ? Professionbuddy.Instance.MaterialList[ingred.ID]
                                        : 0)
                   select (int) Math.Floor(ingredCnt/(double) ingred.Required)).Min();
     return repeat > 0 ? repeat : 0;
 }
Exemplo n.º 2
0
 private void AddRecipe(Recipe recipe)
 {
     if (!Recipes.ContainsKey(recipe.SpellId))
     {
         Recipes.Add(recipe.SpellId, recipe);
         recipe.InitIngredients();
         recipe.InitTools();
     }
 }
Exemplo n.º 3
0
 // this factors in the material list
 public static int CalculateRecipeRepeat(Recipe recipe)
 {
     int ret = int.MaxValue;
     foreach (Ingredient ingred in recipe.Ingredients)
     {
         int ingredCnt = (int)ingred.InBagItemCount -
                         (Professionbuddy.Instance.MaterialList.ContainsKey(ingred.ID)
                              ? Professionbuddy.Instance.MaterialList[ingred.ID]
                              : 0);
         int repeat = (int)System.Math.Floor((double)(ingredCnt / ingred.Required));
         if (ret > repeat)
         {
             ret = repeat;
         }
     }
     return ret;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <returns></returns>
        public static TradeSkill GetTradeSkill(SkillLine skillLine)
        {
            if (!StyxWoW.IsInGame)
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
                throw new InvalidOperationException(String.Format("The tradekill {0} can not be loaded", skillLine));
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
                ObjectManager.Update();
            //Stopwatch sw = new Stopwatch();
            TradeSkill tradeSkill = null;
            try
            {
                using (StyxWoW.Memory.AcquireFrame())
                {
                    WoWSkill wowSkill = StyxWoW.Me.GetSkill(skillLine);
                    // sw.Start();
                    tradeSkill = new TradeSkill(wowSkill);

                    List<SkillLineAbilityEntry> entries = tradeSkill.GetSkillLineAbilityEntries();
                    foreach (SkillLineAbilityEntry entry in entries)
                    {
                        // check if the entry is a recipe
                        if (entry.NextSpellId == 0 && entry.GreySkillLevel > 0 && entry.TradeSkillCategoryIndex != 0)
                        {
                            var recipe = new Recipe(tradeSkill, entry);
                            recipe.UpdateHeader();
                            tradeSkill.AddRecipe(recipe);
                        }
                        //Logging.Write(entry.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
            //Logging.Write("it took {0} ms to load {1}", sw.ElapsedMilliseconds, skillLine);
            return tradeSkill;
        }
 public void AddRecipe(Recipe recipe)
 {
     if (Recipes.ContainsKey(recipe.ID))
         return;
     Recipes.Add(recipe.ID, recipe);
     recipe.InitIngredients();
     recipe.InitTools();
 }