Beispiel #1
0
        public void LoadCurrentGearEnchantsBuffs(CharacterCalculationsBase currentCalculations)
        {
            List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>();

            if (Character != null)
            {
                foreach (CharacterSlot slot in Enum.GetValues(typeof(CharacterSlot)))
                {
                    if (Character[slot] != null)
                    {
                        itemCalculations.Add(Calculations.GetItemCalculations(Character[slot], Character, slot));
                    }
                }

                foreach (ComparisonCalculationBase calc in Calculations.GetEnchantCalculations(ItemSlot.None, Character, currentCalculations, true))
                {
                    itemCalculations.Add(calc);
                }

                foreach (ComparisonCalculationBase calc in Calculations.GetBuffCalculations(Character, currentCalculations, "Current"))
                {
                    itemCalculations.Add(calc);
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = itemCalculations.ToArray();
            comparisonGraph1.EquipSlot        = CharacterSlot.None;
            _characterSlot = CharacterSlot.None;
        }
Beispiel #2
0
        private float[] BuildGraphData(Character character, out float minY, out float maxY, out string[] rotations)
        {
            minY = float.MaxValue;
            maxY = 0f;
            float[] overallData = new float[(MaximumX - MinimumX) * GranularityX + 1];
            rotations = new string[overallData.Length];
            Item itemStats = new Item()
            {
                Stats = new Stats()
            };
            PropertyInfo propertyX = typeof(Stats).GetProperty(StatX);
            float        y, x;

            for (int i = 0; i < overallData.Length; i++)
            {
                try
                {
                    x = MinimumX + (float)i / (float)GranularityX;
                    propertyX.SetValue(itemStats.Stats, x, null);
                    CharacterCalculationsBase calcs = Calculations.GetCharacterCalculations(character, itemStats,
                                                                                            false, true, false);
                    y = calcs.OverallPoints;
                    //rotations[i] = calcs.GetCharacterDisplayCalculationValues()["Optimal Rotation"];
                    overallData[i] = y;
                    minY           = Math.Min(minY, y);
                    maxY           = Math.Max(maxY, y);
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }

            return(overallData);
        }
Beispiel #3
0
        public void UpdateStatsGraph(Character character, Stats[] statsList, Color[] colors, int scale, string explanatoryText, string calculation)
        {
            CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character);
            float baseFigure = GetCalculationValue(baseCalc, calculation);

            if (statsList.Length == 0 || statsList.Length > colors.Length)
            {
                return;                                                            // more than 12 elements for the array would run out of colours
            }
            Point[][] points = new Point[statsList.Length][];
            Chart.Series.Clear();
            for (int index = 0; index < statsList.Length; index++)
            {
                Stats newStats = new Stats();
                points[index] = new Point[2 * scale + 1];
                newStats.Accumulate(statsList[index], -scale - 1);

                for (int count = -scale; count <= scale; count++)
                {
                    newStats.Accumulate(statsList[index]);

                    CharacterCalculationsBase currentCalc = Calculations.GetCharacterCalculations(character, new Item()
                    {
                        Stats = newStats
                    }, false, false, false);
                    float currentFigure = GetCalculationValue(currentCalc, calculation);
                    float dpsChange     = currentFigure - baseFigure;
                    points[index][count + scale] = new Point(count, dpsChange);
                }
                Style dataPointStyle = new Style(typeof(LineDataPoint));
                dataPointStyle.Setters.Add(new Setter(DataPoint.TemplateProperty, Resources["InvisibleDataPointTemplate"]));
                dataPointStyle.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(colors[index])));
                Chart.Series.Add(new LineSeries()
                {
                    Title                = statsList[index].ToString(),
                    ItemsSource          = points[index],
                    IndependentValuePath = "X",
                    DependentValuePath   = "Y",
                    DataPointStyle       = dataPointStyle,
                });
            }
            Chart.Axes.Clear();
            Chart.Axes.Add(new LinearAxis()
            {
                Orientation   = AxisOrientation.X,
                Title         = "Stat Change",
                ShowGridLines = true,
            });
            Chart.Axes.Add(new LinearAxis()
            {
                Orientation   = AxisOrientation.Y,
                Title         = calculation,
                ShowGridLines = true,
            });
            orgDataDirty = true;
        }
Beispiel #4
0
 public void LoadEnchantsBySlot(Item.ItemSlot slot, CharacterCalculationsBase currentCalculations)
 {
     if (Items != null && Character != null)
     {
         comparisonGraph1.RoundValues      = true;
         comparisonGraph1.CustomRendered   = false;
         comparisonGraph1.ItemCalculations = Calculations.GetEnchantCalculations(slot, Character, currentCalculations).ToArray();
         comparisonGraph1.EquipSlot        = Character.CharacterSlot.None;
     }
 }
Beispiel #5
0
 public void LoadBuffs(CharacterCalculationsBase currentCalculations, Buff.BuffType buffType, bool activeOnly)
 {
     if (Items != null && Character != null)
     {
         comparisonGraph1.RoundValues      = true;
         comparisonGraph1.CustomRendered   = false;
         comparisonGraph1.ItemCalculations = Calculations.GetBuffCalculations(Character, currentCalculations, buffType, activeOnly).ToArray();
         comparisonGraph1.EquipSlot        = Character.CharacterSlot.None;
     }
 }
Beispiel #6
0
 public void LoadBuffs(CharacterCalculationsBase currentCalculations, string filter)
 {
     if (Character != null)
     {
         comparisonGraph1.RoundValues      = true;
         comparisonGraph1.CustomRendered   = false;
         comparisonGraph1.ItemCalculations = Calculations.GetBuffCalculations(Character, currentCalculations, filter).ToArray();
         comparisonGraph1.EquipSlot        = CharacterSlot.None;
         _characterSlot = CharacterSlot.None;
     }
 }
Beispiel #7
0
 public void UpdateCalculations(object sender, EventArgs e)
 {
     _currentCalculations = null;
     foreach (ComparisonSetControl csc in comparisonSets)
     {
         csc.CurrentCalculations = null;
     }
     if (Character != null)
     {
         UpdateGraph(this, EventArgs.Empty);
     }
 }
Beispiel #8
0
        public void LoadTalentSpecs(TalentPicker picker)
        {
            List <ComparisonCalculationBase> talentCalculations = new List <ComparisonCalculationBase>();

            if (Character != null)
            {
                Character baseChar = Character.Clone();
                switch (baseChar.Class)
                {
                case CharacterClass.Warrior: baseChar.WarriorTalents = new WarriorTalents(); break;

                case CharacterClass.Paladin: baseChar.PaladinTalents = new PaladinTalents(); break;

                case CharacterClass.Hunter: baseChar.HunterTalents = new HunterTalents(); break;

                case CharacterClass.Rogue: baseChar.RogueTalents = new RogueTalents(); break;

                case CharacterClass.Priest: baseChar.PriestTalents = new PriestTalents(); break;

                case CharacterClass.Shaman: baseChar.ShamanTalents = new ShamanTalents(); break;

                case CharacterClass.Mage: baseChar.MageTalents = new MageTalents(); break;

                case CharacterClass.Warlock: baseChar.WarlockTalents = new WarlockTalents(); break;

                case CharacterClass.Druid: baseChar.DruidTalents = new DruidTalents(); break;

                case CharacterClass.DeathKnight: baseChar.DeathKnightTalents = new DeathKnightTalents(); break;

                default: baseChar.DruidTalents = new DruidTalents(); break;
                }
                CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(baseChar, null, false, true, false);

                ComparisonCalculationBase compare;
                Character newChar;
                foreach (SavedTalentSpec spec in picker.SpecsFor(Character.Class))
                {
                    newChar = Character.Clone();
                    newChar.CurrentTalents = spec.TalentSpec();
                    compare      = Calculations.GetCharacterComparisonCalculations(baseCalc, newChar, spec.ToString(), spec == picker.CurrentSpec());
                    compare.Item = null;
                    talentCalculations.Add(compare);
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = talentCalculations.ToArray();
            comparisonGraph1.EquipSlot        = CharacterSlot.None;
            _characterSlot = CharacterSlot.None;
        }
Beispiel #9
0
 public void UpdateCalculations(object sender, EventArgs e)
 {
     _compositeCharacter  = null;
     _currentCalculations = null;
     if (CompositeCharacter != null)
     {
         FormItemSelection.Character           = CompositeCharacter;
         _currentCalculations                  = Calculations.GetCharacterCalculations(CompositeCharacter, null, true, true, true);
         FormItemSelection.CurrentCalculations = _currentCalculations;
         if (CalculationsInvalidated != null)
         {
             CalculationsInvalidated(this, EventArgs.Empty);
         }
     }
 }
Beispiel #10
0
        public virtual List <ComparisonCalculationBase> GetEnchantCalculations(Item.ItemSlot slot, Character character, CharacterCalculationsBase currentCalcs)
        {
            ClearCache();
            List <ComparisonCalculationBase> enchantCalcs    = new List <ComparisonCalculationBase>();
            CharacterCalculationsBase        calcsEquipped   = null;
            CharacterCalculationsBase        calcsUnequipped = null;

            foreach (Enchant enchant in Enchant.FindEnchants(slot))
            {
                //if (enchantCalcs.ContainsKey(enchant.Id)) continue;

                bool isEquipped = character.GetEnchantBySlot(enchant.Slot) == enchant;
                if (isEquipped)
                {
                    calcsEquipped = currentCalcs;
                    Character charUnequipped = character.Clone();
                    charUnequipped.SetEnchantBySlot(enchant.Slot, null);
                    calcsUnequipped = GetCharacterCalculations(charUnequipped);
                }
                else
                {
                    Character charUnequipped = character.Clone();
                    Character charEquipped   = character.Clone();
                    charUnequipped.SetEnchantBySlot(enchant.Slot, null);
                    charEquipped.SetEnchantBySlot(enchant.Slot, enchant);
                    calcsUnequipped = GetCharacterCalculations(charUnequipped);
                    calcsEquipped   = GetCharacterCalculations(charEquipped);
                }
                ComparisonCalculationBase enchantCalc = CreateNewComparisonCalculation();
                enchantCalc.Name = enchant.Name;
                enchantCalc.Item = new Item(enchant.Name, Item.ItemQuality.Temp, Item.ItemType.None,
                                            -1 * (enchant.Id + (10000 * (int)enchant.Slot)), null, Item.ItemSlot.None, null, false, enchant.Stats, new Sockets(), 0, 0, 0, 0, 0,
                                            Item.ItemDamageType.Physical, 0, null);
                enchantCalc.Item.Name     = enchant.Name;
                enchantCalc.Item.Stats    = enchant.Stats;
                enchantCalc.Equipped      = isEquipped;
                enchantCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
                float[] subPoints = new float[calcsEquipped.SubPoints.Length];
                for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
                {
                    subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
                }
                enchantCalc.SubPoints = subPoints;
                enchantCalcs.Add(enchantCalc);
            }
            return(enchantCalcs);
        }
Beispiel #11
0
 public void SetCalculations(CharacterCalculationsBase characterCalculations)
 {
     foreach (KeyValuePair <string, string> kvp in characterCalculations.GetCharacterDisplayCalculationValues())
     {
         string[] valueSplit = kvp.Value.Split('*');
         string   value      = valueSplit[0];
         if (valueSplit.Length > 1)
         {
             ValueLabels[kvp.Key].Text        = value + " *";
             ValueLabels[kvp.Key].ToolTipText = valueSplit[1];
         }
         else
         {
             ValueLabels[kvp.Key].Text = value;
         }
     }
 }
Beispiel #12
0
 private static float GetCalculationValue(CharacterCalculationsBase calcs, string calculation)
 {
     if (calculation == null || calculation == "Overall Rating")
     {
         return(calcs.OverallPoints);
     }
     else
     {
         int index = 0;
         foreach (string subPoint in Calculations.SubPointNameColors.Keys)
         {
             if (calculation.StartsWith(subPoint, StringComparison.Ordinal))
             {
                 return(calcs.SubPoints[index]);
             }
             index++;
         }
         return(0f);
     }
 }
Beispiel #13
0
 public static List<ComparisonCalculationBase> GetBuffCalculations(Character character, CharacterCalculationsBase currentCalcs, string filter)
 {
     return Instance.GetBuffCalculations(character, currentCalcs, filter);
 }
Beispiel #14
0
 private void AsyncCalculationStart(CharacterCalculationsBase calculations, AsyncOperation asyncCalculation)
 {
     Dictionary<string, string> result = calculations.GetAsynchronousCharacterDisplayCalculationValues();
     asyncCalculation.PostOperationCompleted(asyncCalculationCompleted, new AsyncCalculationResult() { Calculations = calculations, DisplayCalculationValues = result });
 }
Beispiel #15
0
        /// <summary>
        /// Direct Upgrades
        /// </summary>
        /// <param name="currentCalculations"></param>
        /// <param name="divideByCost">When true it only includes items with positive cost and shows upgrade value / cost</param>
        public void LoadAvailableGear(CharacterCalculationsBase currentCalculations, bool divideByCost)
        {
            List <ComparisonCalculationBase>     itemCalculations = new List <ComparisonCalculationBase>();
            SortedList <ItemSlot, CharacterSlot> slotMap          = new SortedList <ItemSlot, CharacterSlot>();

            if (Character != null)
            {
                SortedList <string, ItemInstance> items = new SortedList <string, ItemInstance>();

                float Finger1 = (Character[CharacterSlot.Finger1] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[CharacterSlot.Finger1], Character, CharacterSlot.Finger1).OverallPoints);
                float Finger2 = (Character[CharacterSlot.Finger2] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[CharacterSlot.Finger2], Character, CharacterSlot.Finger2).OverallPoints);

                float Trinket1 = (Character[CharacterSlot.Trinket1] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[CharacterSlot.Trinket1], Character, CharacterSlot.Trinket1).OverallPoints);
                float Trinket2 = (Character[CharacterSlot.Trinket2] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[CharacterSlot.Trinket2], Character, CharacterSlot.Trinket2).OverallPoints);

                if (Finger2 < Finger1)
                {
                    slotMap[ItemSlot.Finger] = CharacterSlot.Finger2;
                }

                if (Trinket2 < Trinket1)
                {
                    slotMap[ItemSlot.Trinket] = CharacterSlot.Trinket2;
                }

                float MainHand = (Character[CharacterSlot.MainHand] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[CharacterSlot.MainHand], Character, CharacterSlot.MainHand).OverallPoints);
                float OffHand = (Character[CharacterSlot.OffHand] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[CharacterSlot.OffHand], Character, CharacterSlot.OffHand).OverallPoints);

                if (MainHand > OffHand)
                {
                    slotMap[ItemSlot.OneHand] = CharacterSlot.OffHand;
                }

                foreach (KeyValuePair <ItemSlot, CharacterSlot> kvp in Item.DefaultSlotMap)
                {
                    try
                    {
                        ItemSlot      iSlot = kvp.Key;
                        CharacterSlot slot;

                        if (slotMap.ContainsKey(iSlot))
                        {
                            slot = slotMap[iSlot];
                        }
                        else
                        {
                            slot = kvp.Value;
                        }
                        if (slot != CharacterSlot.None)
                        {
                            ComparisonCalculationBase slotCalc;
                            ItemInstance currentItem = Character[slot];
                            if (currentItem == null)
                            {
                                slotCalc = Calculations.CreateNewComparisonCalculation();
                            }
                            else
                            {
                                slotCalc = Calculations.GetItemCalculations(currentItem, Character, slot);
                            }

                            foreach (ItemInstance item in Character.GetRelevantItemInstances(slot))
                            {
                                if (!items.ContainsKey(item.GemmedId) && (currentItem == null || currentItem.GemmedId != item.GemmedId))
                                {
                                    if (currentItem != null && currentItem.Item.Unique)
                                    {
                                        CharacterSlot otherSlot = CharacterSlot.None;
                                        switch (slot)
                                        {
                                        case CharacterSlot.Finger1:
                                            otherSlot = CharacterSlot.Finger2;
                                            break;

                                        case CharacterSlot.Finger2:
                                            otherSlot = CharacterSlot.Finger1;
                                            break;

                                        case CharacterSlot.Trinket1:
                                            otherSlot = CharacterSlot.Trinket2;
                                            break;

                                        case CharacterSlot.Trinket2:
                                            otherSlot = CharacterSlot.Trinket1;
                                            break;

                                        case CharacterSlot.MainHand:
                                            otherSlot = CharacterSlot.OffHand;
                                            break;

                                        case CharacterSlot.OffHand:
                                            otherSlot = CharacterSlot.MainHand;
                                            break;
                                        }
                                        if (otherSlot != CharacterSlot.None && Character[otherSlot] != null && (Character[otherSlot].Id == item.Id || (item.Item.UniqueId != null && item.Item.UniqueId.Contains(Character[otherSlot].Id))))
                                        {
                                            continue;
                                        }
                                    }

                                    if (!divideByCost || item.Item.Cost > 0.0f)
                                    {
                                        ComparisonCalculationBase itemCalc = Calculations.GetItemCalculations(item, Character, slot);
                                        //bool include = false;
                                        //for (int i = 0; i < itemCalc.SubPoints.Length; i++)
                                        //{
                                        //    itemCalc.SubPoints[i] -= slotCalc.SubPoints[i];
                                        //    include |= itemCalc.SubPoints[i] > 0;
                                        //}
                                        //itemCalc.OverallPoints -= slotCalc.OverallPoints;
                                        //if ( itemCalc.OverallPoints > 0)
                                        //{
                                        //    itemCalculations.Add(itemCalc);
                                        //}

                                        float difference = itemCalc.OverallPoints - slotCalc.OverallPoints;
                                        if (difference > 0)
                                        {
                                            itemCalc.SubPoints = new float[itemCalc.SubPoints.Length];
                                            if (divideByCost)
                                            {
                                                itemCalc.OverallPoints = difference / item.Item.Cost;
                                            }
                                            else
                                            {
                                                itemCalc.OverallPoints = difference;
                                            }
                                            itemCalculations.Add(itemCalc);
                                        }
                                    }

                                    items[item.GemmedId] = item;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.DisplayMode      = ComparisonGraph.GraphDisplayMode.Overall;
            comparisonGraph1.ItemCalculations = FilterTopXGemmings(itemCalculations);
            comparisonGraph1.EquipSlot        = CharacterSlot.AutoSelect;
            comparisonGraph1.SlotMap          = slotMap;
            _characterSlot = CharacterSlot.None;
        }
Beispiel #16
0
 public virtual List<ComparisonCalculationBase> GetEnchantCalculations(ItemSlot slot, Character character, CharacterCalculationsBase currentCalcs, bool equippedOnly, bool forceSlotName=false)
 {
     ClearCache();
     List<ComparisonCalculationBase> enchantCalcs = new List<ComparisonCalculationBase>();
     CharacterCalculationsBase calcsEquipped = null;
     CharacterCalculationsBase calcsUnequipped = null;
     // only need to get unequipped value once not every time around the loop
     Character charUnequipped = character.Clone();
     charUnequipped.SetEnchantBySlot(slot, null);
     calcsUnequipped = GetCharacterCalculations(charUnequipped, null, false, false, false);
     foreach (Enchant enchant in Enchant.FindEnchants(slot, character))
     {
         bool isEquipped = character.GetEnchantBySlot(slot) == enchant;
         if (equippedOnly && !isEquipped) continue;
         Character charEquipped = character.Clone();
         charEquipped.SetEnchantBySlot(slot, enchant);
         calcsEquipped = GetCharacterCalculations(charEquipped, null, false, false, false);
         ComparisonCalculationBase enchantCalc = CreateNewComparisonCalculation();
         enchantCalc.Name = forceSlotName || equippedOnly ? string.Format("{0} ({1})", enchant.Name, slot) : enchant.Name;
         enchantCalc.Item = new Item(enchant.Name, ItemQuality.Temp, ItemType.None,
             -1 * (enchant.Id + ((int)AvailableItemIDModifiers.Enchants * (int)enchant.Slot)), null, ItemSlot.None, null,
             false, enchant.Stats, null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
             0, 0, ItemDamageType.Physical, 0, null);
         enchantCalc.Item.Name = forceSlotName || equippedOnly ? string.Format("{0} ({1})", enchant.Name, slot) : enchant.Name;
         enchantCalc.Item.Stats = enchant.Stats;
         enchantCalc.Equipped = isEquipped;
         enchantCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
         float[] subPoints = new float[calcsEquipped.SubPoints.Length];
         for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
         {
             subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
         }
         enchantCalc.SubPoints = subPoints;
         enchantCalc.ImageSource = enchant.IconSource;
         enchantCalcs.Add(enchantCalc);
         if (equippedOnly && isEquipped) break;
     }
     return enchantCalcs;
 }
Beispiel #17
0
        public virtual ComparisonCalculationBase GetItemSetCalculations(ItemSet itemset, Character character)
        {
            bool useCache = character == _cachedCharacter;
            Character characterWithAllSlotsEmpty = null;

            if (!useCache)
                characterWithAllSlotsEmpty = character.Clone();
            Character characterWithNewItemSet = character.Clone();

            if (!useCache)
            {
                foreach (CharacterSlot cs in Character.EquippableCharacterSlots)
                {
                    characterWithAllSlotsEmpty[cs] = null;
                }
            }
            foreach (CharacterSlot cs in Character.EquippableCharacterSlots)
            {
                characterWithNewItemSet[cs] = itemset[cs];
            }

            CharacterCalculationsBase characterStatsWithAllSlotsEmpty;
            if (useCache && _cachedCharacterStatsWithAllSlotsEmpty != null)
                characterStatsWithAllSlotsEmpty = _cachedCharacterStatsWithAllSlotsEmpty;
            else
            {
                characterStatsWithAllSlotsEmpty = GetCharacterCalculations(characterWithAllSlotsEmpty, null, false, false, false);
                _cachedCharacter = character;
                _cachedCharacterStatsWithAllSlotsEmpty = characterStatsWithAllSlotsEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewItemSet = GetCharacterCalculations(characterWithNewItemSet, null, false, false, false);

            ComparisonCalculationBase itemSetCalc = CreateNewComparisonCalculation();
            itemSetCalc.ItemInstance = null;
            itemSetCalc.Item = null;
            itemSetCalc.Name = itemset.Name != null ? itemset.Name : string.Empty;
            //itemSetCalc.Description = itemset.ListAsDesc;
            itemSetCalc.ItemSet = itemset;
            itemSetCalc.Equipped = true;
            foreach (CharacterSlot cs in Character.EquippableCharacterSlots)
            {
                if (character[cs] != itemset[cs])
                {
                    itemSetCalc.Equipped = false;
                    break;
                }
            }
            itemSetCalc.OverallPoints = characterStatsWithNewItemSet.OverallPoints - characterStatsWithAllSlotsEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItemSet.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItemSet.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItemSet.SubPoints[i] - characterStatsWithAllSlotsEmpty.SubPoints[i];
            }
            itemSetCalc.SubPoints = subPoints;

            characterStatsWithNewItemSet.ToString();

            return itemSetCalc;
        }
Beispiel #18
0
        public virtual ComparisonCalculationBase GetItemCalculations(ItemInstance item, Character character, CharacterSlot slot)
        {
            // Check if the last iteration has the same character and is in the same slot.
            // If it is, we'll use the same characterWithSlotEmpty to save processing time
            bool useCache = character == _cachedCharacter && slot == _cachedSlot;
            Character characterWithSlotEmpty = null;

            if (!useCache)
                characterWithSlotEmpty = character.Clone();
            Character characterWithNewItem = character.Clone();

            if (slot != CharacterSlot.Metas && slot != CharacterSlot.Gems
                && slot != CharacterSlot.Cogwheels && slot != CharacterSlot.Hydraulics)
            {
                // Show Relative to Equipped makes the Base version character with the original item value 0
                // and every other calc relative to that
                if (!useCache) characterWithSlotEmpty[slot] = (Properties.GeneralSettings.Default.ShowRelativeToEquipped && character[slot] != null ? character[slot].Clone() : null);
                characterWithNewItem[slot] = item;
            }

            CharacterCalculationsBase characterStatsWithSlotEmpty;
            if (useCache && _cachedCharacterStatsWithSlotEmpty != null)
                characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty;
            else
            {
                characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty,
                    null,
                    false, false, false);
                _cachedCharacter = character;
                _cachedSlot = slot;
                _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, null, false, false, false);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();
            itemCalc.ItemInstance = item;
            itemCalc.Item = item.Item;
            itemCalc.Name = item.Name;
            itemCalc.Equipped = character[slot] == item;
            itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewItem.ToString();

            return itemCalc;
        }
Beispiel #19
0
 public static ComparisonCalculationBase GetCharacterComparisonCalculations(CharacterCalculationsBase baseCalculations,
     CharacterCalculationsBase newCalculation, string name, bool equipped, bool partequipped)
 {
     return Instance.GetCharacterComparisonCalculations(baseCalculations, newCalculation, name, equipped, partequipped);
 }
Beispiel #20
0
 public virtual List<ComparisonCalculationBase> GetReforgeCalculations(CharacterSlot slot, Character character, CharacterCalculationsBase currentCalcs, bool equippedOnly)
 {
     ClearCache();
     List<ComparisonCalculationBase> reforgeCalcs = new List<ComparisonCalculationBase>();
     if (!equippedOnly)
     {
         CharacterCalculationsBase calcsEquipped = null;
         CharacterCalculationsBase calcsUnequipped = null;
         // only need to get unequipped value once not every time around the loop
         Character charUnequipped = character.Clone();
         charUnequipped.SetReforgingBySlot(slot, null);
         calcsUnequipped = GetCharacterCalculations(charUnequipped, null, false, false, false);
         Item toReforge = character[slot] != null ? character[slot].Item : null;
         int toReforgeSuffix = character[slot] != null ? character[slot].RandomSuffixId : 0;
         if (toReforge == null) return reforgeCalcs;
         List<Reforging> possibleReforges = GetReforgingOptions(toReforge, toReforgeSuffix);
         foreach (Reforging reforge in possibleReforges)
         {
             Reforging origReforge = character.GetReforgingBySlot(slot);
             int id1 = origReforge != null ? origReforge.Id : 0;
             int id2 = reforge != null ? reforge.Id : 0;
             bool isEquipped = id1 == id2;
             Character charEquipped = character.Clone();
             charEquipped.SetReforgingBySlot(slot, reforge);
             calcsEquipped = GetCharacterCalculations(charEquipped, null, false, false, false);
             ComparisonCalculationBase reforgeCalc = CreateNewComparisonCalculation();
             if (reforge != null)
             {
                 reforgeCalc.Name = reforge.ToString();
                 reforgeCalc.Item = new Item(reforge.ToString(), ItemQuality.Temp, ItemType.None,
                     -(int)AvailableItemIDModifiers.Reforges - reforge.Id, null, ItemSlot.None, null,
                     false, new Stats(), null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
                     0, 0, ItemDamageType.Physical, 0, null);
                 reforgeCalc.Item.Stats._rawAdditiveData[(int)reforge.ReforgeFrom] -= reforge.ReforgeAmount;
                 reforgeCalc.Item.Stats._rawAdditiveData[(int)reforge.ReforgeTo] += reforge.ReforgeAmount;
             }
             else
             {
                 reforgeCalc.Name = "Not Reforged";
                 reforgeCalc.Item = new Item("Not Reforged", ItemQuality.Temp, ItemType.None,
                     -(int)AvailableItemIDModifiers.Reforges, null, ItemSlot.None, null,
                     false, new Stats(), null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
                     0, 0, ItemDamageType.Physical, 0, null);
             }
             reforgeCalc.Equipped = isEquipped;
             reforgeCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
             float[] subPoints = new float[calcsEquipped.SubPoints.Length];
             for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
             {
                 subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
             }
             reforgeCalc.SubPoints = subPoints;
             reforgeCalcs.Add(reforgeCalc);
         }
     }
     else
     {
         CharacterCalculationsBase calcsEquipped = null;
         CharacterCalculationsBase calcsUnequipped = null;
         // only need to get unequipped value once not every time around the loop
         Character charUnequipped = character.Clone();
         charUnequipped.SetReforgingBySlot(slot, null);
         calcsUnequipped = GetCharacterCalculations(charUnequipped, null, false, false, false);
         Item toReforge = character[slot] != null ? character[slot].Item : null;
         if (toReforge == null) return reforgeCalcs;
         Reforging reforge = character[slot].Reforging;
         Reforging origReforge = character.GetReforgingBySlot(slot);
         bool isEquipped = true;
         Character charEquipped = character;
         calcsEquipped = GetCharacterCalculations(charEquipped, null, false, false, false);
         ComparisonCalculationBase reforgeCalc = CreateNewComparisonCalculation();
         if (reforge != null)
         {
             reforgeCalc.Name = reforge.ToString();
             reforgeCalc.Item = new Item(reforge.ToString(), ItemQuality.Temp, ItemType.None,
                 -(int)AvailableItemIDModifiers.Reforges - reforge.Id, null, ItemSlot.None, null,
                 false, new Stats(), null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
                 0, 0, ItemDamageType.Physical, 0, null);
             reforgeCalc.Item.Stats._rawAdditiveData[(int)reforge.ReforgeFrom] -= reforge.ReforgeAmount;
             reforgeCalc.Item.Stats._rawAdditiveData[(int)reforge.ReforgeTo] += reforge.ReforgeAmount;
         }
         else
         {
             reforgeCalc.Name = "Not Reforged";
             reforgeCalc.Item = new Item("Not Reforged", ItemQuality.Temp, ItemType.None,
                 -(int)AvailableItemIDModifiers.Reforges, null, ItemSlot.None, null,
                 false, new Stats(), null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
                 0, 0, ItemDamageType.Physical, 0, null);
         }
         reforgeCalc.Equipped = isEquipped;
         reforgeCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
         float[] subPoints = new float[calcsEquipped.SubPoints.Length];
         for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
         {
             subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
         }
         reforgeCalc.SubPoints = subPoints;
         reforgeCalcs.Add(reforgeCalc);
     }
     return reforgeCalcs;
 }
Beispiel #21
0
 public virtual ComparisonCalculationBase GetBossCalculations(BossHandler boss, BossHandler easy, Character character, CharacterCalculationsBase currentCalcs)
 {
     ClearCache();
     CharacterCalculationsBase calcsEquipped = null;
     CharacterCalculationsBase calcsUnequipped = null;
     // only need to get unequipped value once not every time around the loop
     Character charUnequipped = character.Clone();
     charUnequipped.BossOptions = BossOptions.CloneBossHandler(easy);
     calcsUnequipped = GetCharacterCalculations(charUnequipped, null, false, false, false);
     //
     bool isEquipped = false;
     Character charEquipped = character.Clone();
     charUnequipped.BossOptions = BossOptions.CloneBossHandler(boss);
     calcsEquipped = GetCharacterCalculations(charEquipped, null, false, false, false);
     ComparisonCalculationBase bossCalc = CreateNewComparisonCalculation();
     bossCalc.Name = boss.Name + " (" + boss.ContentString + ")";
     bossCalc.Item = new Item(boss.Name + " (" + boss.ContentString + ")", ItemQuality.Temp, ItemType.None,
         boss.GetHashCode(), null, ItemSlot.None, null,
         false, new Stats(), null, ItemSlot.None, ItemSlot.None, ItemSlot.None,
         0, 0, ItemDamageType.Physical, 0, null);
     bossCalc.Equipped = isEquipped;
     bossCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
     float[] subPoints = new float[calcsEquipped.SubPoints.Length];
     for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
     {
         subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
     }
     bossCalc.SubPoints = subPoints;
     //bossCalc.ImageSource = boss.IconSource;
     //
     return bossCalc;
 }
Beispiel #22
0
        public virtual List <ComparisonCalculationBase> GetBuffCalculations(Character character, CharacterCalculationsBase currentCalcs, Buff.BuffType buffType, bool activeOnly)
        {
            ClearCache();
            List <ComparisonCalculationBase> buffCalcs       = new List <ComparisonCalculationBase>();
            CharacterCalculationsBase        calcsEquipped   = null;
            CharacterCalculationsBase        calcsUnequipped = null;
            Character charAutoActivated = character.Clone();

            foreach (Buff autoBuff in currentCalcs.AutoActivatedBuffs)
            {
                if (!charAutoActivated.ActiveBuffs.Contains(autoBuff))
                {
                    charAutoActivated.ActiveBuffs.Add(autoBuff);
                    RemoveConflictingBuffs(charAutoActivated.ActiveBuffs, autoBuff);
                }
            }
            charAutoActivated.DisableBuffAutoActivation = true;
            foreach (Buff buff in Buff.GetBuffsByType(buffType))
            {
                if (!activeOnly || charAutoActivated.ActiveBuffs.Contains(buff))
                {
                    Character charUnequipped = charAutoActivated.Clone();
                    Character charEquipped   = charAutoActivated.Clone();
                    charUnequipped.DisableBuffAutoActivation = true;
                    charEquipped.DisableBuffAutoActivation   = true;
                    if (charUnequipped.ActiveBuffs.Contains(buff))
                    {
                        charUnequipped.ActiveBuffs.Remove(buff);
                    }
                    if (string.IsNullOrEmpty(buff.RequiredBuff))
                    {
                        //if (charUnequipped.ActiveBuffs.Contains("Improved " + buff.Name))
                        //	charUnequipped.ActiveBuffs.Remove("Improved " + buff.Name);
                        charUnequipped.ActiveBuffs.RemoveAll(x => x.Name == "Improved " + buff.Name);
                    }
                    else
                    {
                        //if (charUnequipped.ActiveBuffs.Contains(buff.RequiredBuff))
                        //	charUnequipped.ActiveBuffs.Remove(buff.RequiredBuff);
                        charUnequipped.ActiveBuffs.RemoveAll(x => x.Name == buff.RequiredBuff);
                    }

                    if (!charEquipped.ActiveBuffs.Contains(buff))
                    {
                        charEquipped.ActiveBuffs.Add(buff);
                    }
                    if (string.IsNullOrEmpty(buff.RequiredBuff))
                    {
                        //if (charEquipped.ActiveBuffs.Contains("Improved " + buff.Name))
                        //	charEquipped.ActiveBuffs.Remove("Improved " + buff.Name);
                        charEquipped.ActiveBuffs.RemoveAll(x => x.Name == "Improved " + buff.Name);
                    }
                    else
                    {
                        //if (!charEquipped.ActiveBuffs.Contains(buff.RequiredBuff))
                        //	charEquipped.ActiveBuffs.Add(buff.RequiredBuff);
                        Buff requiredBuff = Buff.GetBuffByName(buff.RequiredBuff);
                        if (!charEquipped.ActiveBuffs.Contains(requiredBuff))
                        {
                            charEquipped.ActiveBuffs.Add(requiredBuff);
                        }
                    }

                    RemoveConflictingBuffs(charEquipped.ActiveBuffs, buff);
                    RemoveConflictingBuffs(charUnequipped.ActiveBuffs, buff);

                    calcsUnequipped = GetCharacterCalculations(charUnequipped);
                    calcsEquipped   = GetCharacterCalculations(charEquipped);

                    ComparisonCalculationBase buffCalc = CreateNewComparisonCalculation();
                    buffCalc.Name = buff.Name;
                    buffCalc.Item = new Item()
                    {
                        Name = buff.Name, Stats = buff.Stats, Quality = Item.ItemQuality.Temp
                    };
                    buffCalc.Equipped      = charAutoActivated.ActiveBuffs.Contains(buff);
                    buffCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
                    float[] subPoints = new float[calcsEquipped.SubPoints.Length];
                    for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
                    {
                        subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
                    }
                    buffCalc.SubPoints = subPoints;
                    buffCalcs.Add(buffCalc);
                }
            }
            return(buffCalcs);
        }
Beispiel #23
0
        public void UpdateScalingGraph(Character character, Stats[] statsList, Stats baseStat, bool requiresReferenceCalculations, Color[] colors, int scale, string explanatoryText, string calculation)
        {
            CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character);

            if (statsList.Length == 0 || statsList.Length > colors.Length)
            {
                return;                                                            // more than 12 elements for the array would run out of colours
            }
            Point[][] points = new Point[statsList.Length][];
            // extract property data for relative stats calculations
            KeyValuePair <PropertyInfo, float>[] properties = new KeyValuePair <PropertyInfo, float> [statsList.Length];
            for (int index = 0; index < statsList.Length; index++)
            {
                var p = statsList[index].Values(x => x > 0);
                foreach (var kvp in p)
                {
                    properties[index] = kvp;
                }
                points[index] = new Point[2 * scale + 1];
            }
            float unit = 1f;
            var   bp   = baseStat.Values(x => x > 0);

            foreach (var kvp in bp)
            {
                unit = kvp.Value;
            }
            Chart.Series.Clear();
            for (int count = -scale; count <= scale; count++)
            {
                Stats newStats = new Stats();
                newStats.Accumulate(baseStat, count);
                Item item = new Item()
                {
                    Stats = newStats
                };
                if (requiresReferenceCalculations)
                {
                    Calculations.GetCharacterCalculations(character, item, true, false, false);
                }
                for (int index = 0; index < statsList.Length; index++)
                {
                    ComparisonCalculationBase currentCalc = CalculationsBase.GetRelativeStatValue(character, properties[index].Key, item, properties[index].Value);
                    float dpsChange = GetCalculationValue(currentCalc, calculation);
                    points[index][count + scale] = new Point(count * unit, dpsChange);
                }
            }
            for (int index = 0; index < statsList.Length; index++)
            {
                Style dataPointStyle = new Style(typeof(LineDataPoint));
                dataPointStyle.Setters.Add(new Setter(DataPoint.TemplateProperty, Resources["InvisibleDataPointTemplate"]));
                dataPointStyle.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(colors[index])));
                Chart.Series.Add(new LineSeries()
                {
                    Title                = statsList[index].ToString(),
                    ItemsSource          = points[index],
                    IndependentValuePath = "X",
                    DependentValuePath   = "Y",
                    DataPointStyle       = dataPointStyle,
                });
            }
            Chart.Axes.Clear();
            Chart.Axes.Add(new LinearAxis()
            {
                Orientation   = AxisOrientation.X,
                Title         = "Stat Change",
                ShowGridLines = true,
            });
            Chart.Axes.Add(new LinearAxis()
            {
                Orientation   = AxisOrientation.Y,
                Title         = calculation,
                ShowGridLines = true,
            });
            // restore reference calculation
            if (requiresReferenceCalculations)
            {
                Stats newStats = new Stats();
                Item  item     = new Item()
                {
                    Stats = newStats
                };
                Calculations.GetCharacterCalculations(character, item, true, false, false);
            }
            orgDataDirty = true;
        }
Beispiel #24
0
 public void UpdateDisplayCalculationValues(Dictionary<string, string> displayCalculationValues, CharacterCalculationsBase _calculatedStats)
 {
     CalculationDisplay.SetCalculations(displayCalculationValues);
     string status;
     if (!displayCalculationValues.TryGetValue("Status", out status))
     {
         int i = 0;
         status = "Overall: " + Math.Round(_calculatedStats.OverallPoints);
         foreach (KeyValuePair<string, Color> kvp in Calculations.SubPointNameColors)
         {
             status += ", " + kvp.Key + ": " + Math.Round(_calculatedStats.SubPoints[i]);
             i++;
         }
         //status = "Rawr version " + typeof(Calculations).Assembly.GetName().Version.ToString();
     }
     StatusText.Text = status;
 }
Beispiel #25
0
 public static List<ComparisonCalculationBase> GetSetBonusCalculations(Character character, CharacterCalculationsBase currentCalcs)
 {
     return Instance.GetSetBonusCalculations(character, currentCalcs);
 }
Beispiel #26
0
 public static ComparisonCalculationBase GetCharacterComparisonCalculations(CharacterCalculationsBase calculations, string name, bool equipped)
 {
     return Instance.GetCharacterComparisonCalculations(calculations, name, equipped);
 }
Beispiel #27
0
        public virtual ComparisonCalculationBase GetItemCalculations(Item item, Character character, Character.CharacterSlot slot)
        {
            bool      useCache = character == _cachedCharacter && slot == _cachedSlot;
            Character characterWithSlotEmpty = null;

            if (!useCache)
            {
                characterWithSlotEmpty = character.Clone();
            }
            Character characterWithNewItem = character.Clone();

            if (slot != Character.CharacterSlot.Metas && slot != Character.CharacterSlot.Gems)
            {
                if (!useCache)
                {
                    characterWithSlotEmpty[slot] = null;
                }
                characterWithNewItem[slot] = item;
            }


            CharacterCalculationsBase characterStatsWithSlotEmpty;

            if (useCache)
            {
                characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty;
            }
            else
            {
                characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty);
                _cachedCharacter            = character;
                _cachedSlot = slot;
                _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty;
            }


            Item additionalItem = null;

            if (item.FitsInSlot(Character.CharacterSlot.Gems) || item.FitsInSlot(Character.CharacterSlot.Metas))
            {
                additionalItem = item;
            }
            CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, additionalItem);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();

            itemCalc.Item          = item;
            itemCalc.Name          = item.Name;
            itemCalc.Equipped      = character[slot] == item;
            itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewItem.ToString();

            return(itemCalc);
        }
Beispiel #28
0
 public virtual void ClearCache()
 {
     _cachedCharacterStatsWithSlotEmpty = null;
     _cachedCharacterStatsWithGemSlotEmpty = null;
     _cachedCharacterStatsWithAllSlotsEmpty = null;
     _cachedCharacter = null;
     _cachedSlot = CharacterSlot.Shirt;
     _cachedGemIndex = 0;
 }
Beispiel #29
0
 public static List <ComparisonCalculationBase> GetBuffCalculations(Character character, CharacterCalculationsBase currentCalcs, Buff.BuffType buffType, bool activeOnly)
 {
     return(Instance.GetBuffCalculations(character, currentCalcs, buffType, activeOnly));
 }
Beispiel #30
0
        public virtual ComparisonCalculationBase GetItemGemCalculations(Item gem, Character character, CharacterSlot slot, int gemIndex)
        {
            if (gemIndex == 0)
            {
                return GetItemCalculations(gem, character, CharacterSlot.Gems);
            }
            bool useCache = character == _cachedCharacter && slot == _cachedSlot && gemIndex == _cachedGemIndex;
            Character characterWithGemSlotEmpty = null;

            if (!useCache)
                characterWithGemSlotEmpty = character.Clone();
            Character characterWithNewGem = character.Clone();

            if (!useCache)
            {
                ItemInstance emptyItemInstance = characterWithGemSlotEmpty[slot];
                if (emptyItemInstance != null)
                {
                    emptyItemInstance = emptyItemInstance.Clone();
                    emptyItemInstance.SetGem(gemIndex, null);
                    characterWithGemSlotEmpty[slot] = emptyItemInstance;
                }
            }
            ItemInstance newItemInstance = characterWithNewGem[slot];
            if (newItemInstance != null)
            {
                newItemInstance = newItemInstance.Clone();
                newItemInstance.SetGem(gemIndex, gem);
                characterWithNewGem[slot] = newItemInstance;
            }

            CharacterCalculationsBase characterStatsWithGemSlotEmpty;
            if (useCache && _cachedCharacterStatsWithGemSlotEmpty != null)
                characterStatsWithGemSlotEmpty = _cachedCharacterStatsWithGemSlotEmpty;
            else
            {
                characterStatsWithGemSlotEmpty = GetCharacterCalculations(characterWithGemSlotEmpty, null, false, false, false);
                _cachedCharacter = character;
                _cachedSlot = slot;
                _cachedGemIndex = gemIndex;
                _cachedCharacterStatsWithGemSlotEmpty = characterStatsWithGemSlotEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewGem = GetCharacterCalculations(characterWithNewGem,
                (Properties.GeneralSettings.Default.ShowRelativeToEquipped ? character[slot].Item : null),
                false, false, false);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();
            itemCalc.Item = gem;
            itemCalc.Name = gem != null ? gem.Name : string.Empty;
            itemCalc.Equipped = (character[slot] != null && character[slot].GetGem(gemIndex) == gem);
            itemCalc.OverallPoints = characterStatsWithNewGem.OverallPoints - characterStatsWithGemSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewGem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewGem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewGem.SubPoints[i] - characterStatsWithGemSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewGem.ToString();

            return itemCalc;
        }
Beispiel #31
0
 public static ComparisonCalculationBase GetBossCalculations(BossHandler boss, BossHandler easy, Character character, CharacterCalculationsBase currentCalcs)
 {
     return Instance.GetBossCalculations(boss, easy, character, currentCalcs);
 }
Beispiel #32
0
        public virtual ComparisonCalculationBase GetItemCalculations(Item additionalItem, Character character, CharacterSlot slot)
        {
            bool useCache = character == _cachedCharacter && slot == _cachedSlot;
            Character characterWithSlotEmpty = null;

            if (!useCache)
                characterWithSlotEmpty = character.Clone();
            Character characterWithNewItem = character.Clone();

            CharacterCalculationsBase characterStatsWithSlotEmpty;
            if (useCache)
                characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty;
            else
            {
                characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty, null, false, false, false);
                _cachedCharacter = character;
                _cachedSlot = slot;
                _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty;
            }

            CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, additionalItem, false, false, false);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();
            itemCalc.Item = additionalItem;
            itemCalc.Name = additionalItem.Name;
            itemCalc.Equipped = false;
            itemCalc.ImageSource = additionalItem.IconPath;
            itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewItem.ToString();

            return itemCalc;
        }
Beispiel #33
0
 public static List<ComparisonCalculationBase> GetTinkeringCalculations(ItemSlot slot, Character character, CharacterCalculationsBase currentCalcs, bool equippedOnly, bool forceSlotName = false)
 {
     return Instance.GetTinkeringCalculations(slot, character, currentCalcs, equippedOnly, forceSlotName);
 }
Beispiel #34
0
 public virtual void ClearCache()
 {
     _cachedCharacterStatsWithSlotEmpty = null;
     _cachedCharacter = null;
     _cachedSlot      = Character.CharacterSlot.Shirt;
 }
Beispiel #35
0
 public static List<ComparisonCalculationBase> GetReforgeCalculations(CharacterSlot slot, Character character, CharacterCalculationsBase currentCalcs, bool equippedOnly)
 {
     return Instance.GetReforgeCalculations(slot, character, currentCalcs, equippedOnly);
 }
Beispiel #36
0
        public virtual List<ComparisonCalculationBase> GetSetBonusCalculations(Character character, CharacterCalculationsBase currentCalcs)
        {
            ClearCache();
            List<ComparisonCalculationBase> buffCalcs = new List<ComparisonCalculationBase>();
            CharacterCalculationsBase calcsEquipped = null;
            CharacterCalculationsBase calcsUnequipped = null;
            Character charAutoActivated = character.Clone();
            foreach (Buff autoBuff in currentCalcs.AutoActivatedBuffs)
            {
                if (!charAutoActivated.ActiveBuffs.Contains(autoBuff))
                {
                    charAutoActivated.ActiveBuffsAdd(autoBuff);
                    RemoveConflictingBuffs(charAutoActivated.ActiveBuffs, autoBuff);
                }
            }
            charAutoActivated.DisableBuffAutoActivation = true;

            string filter = "Set Bonuses";
            string[] multiFilter = filter.Split('|');

            List<Buff> relevantBuffs = new List<Buff>();
            Buff.cachedClass = character.Class;
            Buff.cachedPriProf = character.PrimaryProfession;
            Buff.cachedSecProf = character.SecondaryProfession;
            foreach (Buff buff in Buff.RelevantBuffs)
            {
                bool isinMultiFilter = false;
                if (multiFilter.Length > 0)
                {
                    foreach (string mFilter in multiFilter)
                    {
                        if (buff.Group.Equals(mFilter, StringComparison.CurrentCultureIgnoreCase))
                        {
                            isinMultiFilter = true;
                            break;
                        }
                    }
                }
                if (filter == null || filter == "All" || filter == "Current"
                    || buff.Group.Equals(filter, StringComparison.CurrentCultureIgnoreCase)
                    || isinMultiFilter)
                {
                    relevantBuffs.Add(buff);
                    foreach (Buff imp in buff.Improvements)
                    {
                        if (Calculations.Instance.IsBuffRelevant(imp, character))
                        {
                            relevantBuffs.Add(imp);
                        }
                    }
                }
            }

            foreach (Buff buff in relevantBuffs)
            {
                if (!"Current".Equals(filter, StringComparison.CurrentCultureIgnoreCase) || charAutoActivated.ActiveBuffs.Contains(buff))
                {
                    Character charUnequipped = charAutoActivated.Clone();
                    Character charEquipped = charAutoActivated.Clone();
                    charUnequipped.DisableBuffAutoActivation = true;
                    charEquipped.DisableBuffAutoActivation = true;

                    // find next lower set bonus count
                    int maxCount = 0;
                    foreach (Buff lowerSetBonus in relevantBuffs)
                    {
                        if (lowerSetBonus.SetName == buff.SetName && lowerSetBonus.SetThreshold < buff.SetThreshold)
                        {
                            if (lowerSetBonus.SetThreshold > maxCount)
                            {
                                maxCount = lowerSetBonus.SetThreshold;
                            }
                        }
                    }

                    charUnequipped.SetBonusCount[buff.SetName] = maxCount;
                    charEquipped.SetBonusCount[buff.SetName] = buff.SetThreshold;

                    RemoveConflictingBuffs(charEquipped.ActiveBuffs, buff);
                    RemoveConflictingBuffs(charUnequipped.ActiveBuffs, buff);

                    calcsUnequipped = GetCharacterCalculations(charUnequipped, null, false, false, false);
                    calcsEquipped = GetCharacterCalculations(charEquipped, null, false, false, false);

                    ComparisonCalculationBase buffCalc = CreateNewComparisonCalculation();
                    buffCalc.Name = buff.Name;
                    buffCalc.Item = new Item() { Name = buff.Name, Stats = buff.Stats, Quality = ItemQuality.Temp };
                    buffCalc.Equipped = charAutoActivated.ActiveBuffs.Contains(buff);
                    if (!buffCalc.Equipped && buff.ConflictingBuffs.Count > 0 && buff.ConflictingBuffs[0] != null)
                    {
                        bool hasConflictingMatch = false;
                        foreach (String cb in buff.ConflictingBuffs)
                        {
                            foreach (Buff b in character.ActiveBuffs)
                            {
                                if (b.Name != buff.Name && b.ConflictingBuffs.Contains(cb))
                                {
                                    hasConflictingMatch = true;
                                    break;
                                }
                            }
                        }
                        buffCalc.PartEquipped = hasConflictingMatch;
                    }
                    buffCalc.OverallPoints = calcsEquipped.OverallPoints - calcsUnequipped.OverallPoints;
                    float[] subPoints = new float[calcsEquipped.SubPoints.Length];
                    for (int i = 0; i < calcsEquipped.SubPoints.Length; i++)
                    {
                        subPoints[i] = calcsEquipped.SubPoints[i] - calcsUnequipped.SubPoints[i];
                    }
                    buffCalc.SubPoints = subPoints;
                    buffCalcs.Add(buffCalc);
                }
            }
            return buffCalcs;
        }
Beispiel #37
0
        public void LoadAvailableGear(CharacterCalculationsBase currentCalculations)
        {
            List <ComparisonCalculationBase> itemCalculations           = new List <ComparisonCalculationBase>();
            SortedList <Item.ItemSlot, Character.CharacterSlot> slotMap = new SortedList <Item.ItemSlot, Character.CharacterSlot>();

            if (Items != null && Character != null)
            {
                SortedList <string, Item> items = new SortedList <string, Item>();

                float Finger1 = (Character[Character.CharacterSlot.Finger1] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[Character.CharacterSlot.Finger1], Character, Character.CharacterSlot.Finger1).OverallPoints);
                float Finger2 = (Character[Character.CharacterSlot.Finger2] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[Character.CharacterSlot.Finger2], Character, Character.CharacterSlot.Finger2).OverallPoints);

                float Trinket1 = (Character[Character.CharacterSlot.Trinket1] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[Character.CharacterSlot.Trinket1], Character, Character.CharacterSlot.Trinket1).OverallPoints);
                float Trinket2 = (Character[Character.CharacterSlot.Trinket2] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[Character.CharacterSlot.Trinket2], Character, Character.CharacterSlot.Trinket2).OverallPoints);

                if (Finger2 < Finger1)
                {
                    slotMap[Item.ItemSlot.Finger] = Character.CharacterSlot.Finger2;
                }

                if (Trinket2 < Trinket1)
                {
                    slotMap[Item.ItemSlot.Trinket] = Character.CharacterSlot.Trinket2;
                }

                float MainHand = (Character[Character.CharacterSlot.MainHand] == null ? 0 : Calculations.GetItemCalculations(
                                      Character[Character.CharacterSlot.MainHand], Character, Character.CharacterSlot.MainHand).OverallPoints);
                float OffHand = (Character[Character.CharacterSlot.OffHand] == null ? 0 : Calculations.GetItemCalculations(
                                     Character[Character.CharacterSlot.OffHand], Character, Character.CharacterSlot.OffHand).OverallPoints);

                if (MainHand > OffHand)
                {
                    slotMap[Item.ItemSlot.OneHand] = Character.CharacterSlot.OffHand;
                }



                foreach (Item relevantItem in ItemCache.RelevantItems)
                {
                    try
                    {
                        Item.ItemSlot           iSlot = relevantItem.Slot;
                        Character.CharacterSlot slot;

                        if (slotMap.ContainsKey(iSlot))
                        {
                            slot = slotMap[iSlot];
                        }
                        else
                        {
                            slot = Item.DefaultSlotMap[iSlot];
                        }
                        if (slot != Character.CharacterSlot.None)
                        {
                            ComparisonCalculationBase slotCalc;
                            Item currentItem = Character[slot];
                            if (currentItem == null)
                            {
                                slotCalc = Calculations.CreateNewComparisonCalculation();
                            }
                            else
                            {
                                slotCalc = Calculations.GetItemCalculations(currentItem, Character, slot);
                            }

                            foreach (Item item in ItemCache.Instance.FindAllItemsById(relevantItem.Id))
                            {
                                if (!items.ContainsKey(item.GemmedId) && (currentItem == null || currentItem.GemmedId != item.GemmedId))
                                {
                                    if (currentItem != null && currentItem.Unique)
                                    {
                                        Character.CharacterSlot otherSlot = Character.CharacterSlot.None;
                                        switch (slot)
                                        {
                                        case Character.CharacterSlot.Finger1:
                                            otherSlot = Character.CharacterSlot.Finger2;
                                            break;

                                        case Character.CharacterSlot.Finger2:
                                            otherSlot = Character.CharacterSlot.Finger1;
                                            break;

                                        case Character.CharacterSlot.Trinket1:
                                            otherSlot = Character.CharacterSlot.Trinket2;
                                            break;

                                        case Character.CharacterSlot.Trinket2:
                                            otherSlot = Character.CharacterSlot.Trinket1;
                                            break;

                                        case Character.CharacterSlot.MainHand:
                                            otherSlot = Character.CharacterSlot.OffHand;
                                            break;

                                        case Character.CharacterSlot.OffHand:
                                            otherSlot = Character.CharacterSlot.MainHand;
                                            break;
                                        }
                                        if (otherSlot != Character.CharacterSlot.None && Character[otherSlot] != null && Character[otherSlot].Id == item.Id)
                                        {
                                            continue;
                                        }
                                    }

                                    ComparisonCalculationBase itemCalc = Calculations.GetItemCalculations(item, Character, slot);
                                    bool include = false;
                                    for (int i = 0; i < itemCalc.SubPoints.Length; i++)
                                    {
                                        itemCalc.SubPoints[i] -= slotCalc.SubPoints[i];
                                        include |= itemCalc.SubPoints[i] > 0;
                                    }
                                    itemCalc.OverallPoints -= slotCalc.OverallPoints;
                                    if (itemCalc.OverallPoints > 0)
                                    {
                                        itemCalculations.Add(itemCalc);
                                    }
                                    items[item.GemmedId] = item;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.DisplayMode      = ComparisonGraph.GraphDisplayMode.Overall;
            comparisonGraph1.ItemCalculations = itemCalculations.ToArray();
            comparisonGraph1.EquipSlot        = Character.CharacterSlot.AutoSelect;
            comparisonGraph1.SlotMap          = slotMap;
        }
Beispiel #38
0
 private static float GetCalculationValue(CharacterCalculationsBase calcs, string calculation)
 {
     if (calculation == null || calculation == "Overall Rating")
         return calcs.OverallPoints;
     else
     {
         int index = 0;
         foreach (string subPoint in Calculations.SubPointNameColors.Keys)
         {
             if (calculation.StartsWith(subPoint, StringComparison.Ordinal))
                 return calcs.SubPoints[index];
             index++;
         }
         return 0f;
     }
 }
Beispiel #39
0
 public virtual ComparisonCalculationBase GetCharacterComparisonCalculations(CharacterCalculationsBase baseCalculations, 
     Character character, string name, bool equipped)
 {
     CharacterCalculationsBase characterCalculations = GetCharacterCalculations(character, null, false, true, false);
     ComparisonCalculationBase comparisonCalculations = CreateNewComparisonCalculation();
     comparisonCalculations.Name = name;
     comparisonCalculations.Item = new Item() { Name = name };
     comparisonCalculations.Equipped = equipped;
     comparisonCalculations.OverallPoints = characterCalculations.OverallPoints - baseCalculations.OverallPoints;
     float[] subPoints = new float[characterCalculations.SubPoints.Length];
     for (int i = 0; i < characterCalculations.SubPoints.Length; i++)
     {
         subPoints[i] = characterCalculations.SubPoints[i] - baseCalculations.SubPoints[i];
     }
     comparisonCalculations.SubPoints = subPoints;
     return comparisonCalculations;
 }
Beispiel #40
0
 public virtual ComparisonCalculationBase GetCharacterComparisonCalculations(CharacterCalculationsBase baseCalculation,
     CharacterCalculationsBase newCalculation, string name, bool equipped, bool partequipped)
 {
     ComparisonCalculationBase comparisonCalculations = CreateNewComparisonCalculation();
     comparisonCalculations.Name = name;
     comparisonCalculations.Item = new Item() { Name = name };
     comparisonCalculations.Equipped = equipped;
     comparisonCalculations.PartEquipped = partequipped;
     comparisonCalculations.OverallPoints = newCalculation.OverallPoints - baseCalculation.OverallPoints;
     float[] subPoints = new float[newCalculation.SubPoints.Length];
     for (int i = 0; i < newCalculation.SubPoints.Length; i++)
     {
         subPoints[i] = newCalculation.SubPoints[i] - baseCalculation.SubPoints[i];
     }
     comparisonCalculations.SubPoints = subPoints;
     return comparisonCalculations;
 }
Beispiel #41
0
 public static List <ComparisonCalculationBase> GetEnchantCalculations(Item.ItemSlot slot, Character character, CharacterCalculationsBase currentCalcs)
 {
     return(Instance.GetEnchantCalculations(slot, character, currentCalcs));
 }