Esempio n. 1
0
        /// <summary>
        ///     Build an array of <see cref="RecipeIngredient" />s used in the current recipe.
        /// </summary>
        /// <returns>An array of <see cref="RecipeIngredient" />s used in the current recipe.</returns>
        private RecipeIngredient[] BuildIngredients()
        {
            const int MaterialCount   = 10;
            const int CrystalCategory = 59;

            List <RecipeIngredient> ingredients = new List <RecipeIngredient>();

            for (int i = 0; i < MaterialCount; ++i)
            {
                Item item = As <Item>("Item{Ingredient}", i);
                if (item == null || item.Key == 0)
                {
                    continue;
                }

                int count = AsInt32("Amount{Ingredient}", i);
                if (count == 0)
                {
                    continue;
                }

                RecipeIngredientType type = item.ItemUICategory.Key == CrystalCategory ? RecipeIngredientType.Crystal : RecipeIngredientType.Material;
                ingredients.Add(new RecipeIngredient(type, item, count));
            }
            int itemLevelSum =
                ingredients.Where(_ => _.Type == RecipeIngredientType.Material)
                .Sum(_ => _.Count * _.Item.ItemLevel.Key);
            float qualityFromMats = RecipeLevel.Quality * ((float)MaterialQualityFactor / 100);

            foreach (RecipeIngredient mat in ingredients.Where(_ => _.Type == RecipeIngredientType.Material))
            {
                mat.QualityPerItem = mat.Item.ItemLevel.Key * qualityFromMats / itemLevelSum;
            }

            return(ingredients.ToArray());
        }
Esempio n. 2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RecipeIngredient" /> class.
 /// </summary>
 /// <param name="type"><see cref="RecipeIngredientType" /> for the ingredient.</param>
 /// <param name="item"><see cref="Item" /> for the ingredient.</param>
 /// <param name="count">Item count for the ingredient.</param>
 public RecipeIngredient(RecipeIngredientType type, Item item, int count)
 {
     Type  = type;
     Item  = item;
     Count = count;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="RecipeIngredient" /> class.
 /// </summary>
 /// <param name="type"><see cref="RecipeIngredientType" /> for the ingredient.</param>
 /// <param name="item"><see cref="Item" /> for the ingredient.</param>
 /// <param name="count">Item count for the ingredient.</param>
 public RecipeIngredient(RecipeIngredientType type, Item item, int count) {
     Type = type;
     Item = item;
     Count = count;
 }