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);
        }
Exemple #2
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;
        }
Exemple #3
0
 private void SetFormItemSelection(ItemInstance item)
 {
     if (FormMain.Instance.FormItemSelection.Character != null)
     {
         Character emptyGemCharacter = FormMain.Instance.FormItemSelection.Character.Clone();
         emptyGemCharacter[CharacterSlot]       = item;
         _formItemSelection.Character           = emptyGemCharacter;
         _formItemSelection.CurrentCalculations = Calculations.GetCharacterCalculations(emptyGemCharacter);
     }
 }
Exemple #4
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;
        }
Exemple #5
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);
         }
     }
 }
Exemple #6
0
        public void LoadGlyphs()
        {
            List <ComparisonCalculationBase> glyphCalculations = new List <ComparisonCalculationBase>();
            Character baseChar = Character.Clone();
            Character newChar  = Character.Clone();
            CharacterCalculationsBase currentCalc;
            CharacterCalculationsBase newCalc;
            ComparisonCalculationBase compare;
            bool          orig;
            List <string> relevant = Calculations.GetModel(Character.CurrentModel).GetRelevantGlyphs();

            currentCalc = Calculations.GetCharacterCalculations(baseChar, null, false, true, false);
            foreach (PropertyInfo pi in baseChar.CurrentTalents.GetType().GetProperties())
            {
                GlyphDataAttribute[] glyphDatas = pi.GetCustomAttributes(typeof(GlyphDataAttribute), true) as GlyphDataAttribute[];
                if (glyphDatas.Length > 0)
                {
                    GlyphDataAttribute glyphData = glyphDatas[0];
                    if (relevant == null || relevant.Contains(glyphData.Name))
                    {
                        orig = baseChar.CurrentTalents.GlyphData[glyphData.Index];
                        if (orig)
                        {
                            newChar.CurrentTalents.GlyphData[glyphData.Index] = false;
                            newCalc = Calculations.GetCharacterCalculations(newChar, null, false, true, false);
                            compare = Calculations.GetCharacterComparisonCalculations(newCalc, currentCalc, glyphData.Name, orig, false);
                        }
                        else
                        {
                            newChar.CurrentTalents.GlyphData[glyphData.Index] = true;
                            newCalc = Calculations.GetCharacterCalculations(newChar, null, false, true, false);
                            compare = Calculations.GetCharacterComparisonCalculations(currentCalc, newCalc, glyphData.Name, orig, false);
                        }
                        compare.Description = glyphData.Description; // JOTHAY: WTB Tooltips that show info on these charts
                        compare.Item        = null;
                        glyphCalculations.Add(compare);
                        newChar.CurrentTalents.GlyphData[glyphData.Index] = orig;
                    }
                }
            }

            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = glyphCalculations.ToArray();
            comparisonGraph1.EquipSlot        = CharacterSlot.None;
            _characterSlot = CharacterSlot.None;
        }
Exemple #7
0
        public void LoadTalents()
        {
            List <ComparisonCalculationBase> talentCalculations = new List <ComparisonCalculationBase>();
            Character baseChar = Character.Clone();
            Character newChar  = Character.Clone();
            CharacterCalculationsBase currentCalc;
            CharacterCalculationsBase newCalc;
            ComparisonCalculationBase compare;

            currentCalc = Calculations.GetCharacterCalculations(baseChar, null, false, true, false);
            foreach (PropertyInfo pi in baseChar.CurrentTalents.GetType().GetProperties())
            {
                TalentDataAttribute[] talentDatas = pi.GetCustomAttributes(typeof(TalentDataAttribute), true) as TalentDataAttribute[];
                int orig = 0;
                if (talentDatas.Length > 0)
                {
                    TalentDataAttribute talentData = talentDatas[0];
                    orig = baseChar.CurrentTalents.Data[talentData.Index];
                    if (talentData.MaxPoints == (int)pi.GetValue(baseChar.CurrentTalents, null))
                    {
                        newChar.CurrentTalents.Data[talentData.Index]--;
                        newCalc = Calculations.GetCharacterCalculations(newChar, null, false, true, false);
                        compare = Calculations.GetCharacterComparisonCalculations(newCalc, currentCalc, talentData.Name, talentData.MaxPoints == orig, orig != 0);
                    }
                    else
                    {
                        newChar.CurrentTalents.Data[talentData.Index]++;
                        newCalc = Calculations.GetCharacterCalculations(newChar, null, false, true, false);
                        compare = Calculations.GetCharacterComparisonCalculations(currentCalc, newCalc, talentData.Name, talentData.MaxPoints == orig, orig != 0);
                    }
                    string text = string.Format("Current Rank {0}/{1}\r\n\r\n", orig, talentData.MaxPoints);
                    if (orig == 0)
                    {
                        // We originally didn't have it, so first rank is next rank
                        text += "Next Rank:\r\n";
                        text += talentData.Description[0];
                    }
                    else if (orig >= talentData.MaxPoints)
                    {
                        // We originally were at max, so there isn't a next rank, just show the capped one
                        text += talentData.Description[talentData.MaxPoints - 1];
                    }
                    else
                    {
                        // We aren't at 0 or MaxPoints originally, so it's just a point in between
                        text += talentData.Description[orig - 1];
                        text += "\r\n\r\nNext Rank:\r\n";
                        text += talentData.Description[orig];
                    }
                    compare.Description = text;
                    compare.Item        = null;
                    talentCalculations.Add(compare);
                    newChar.CurrentTalents.Data[talentData.Index] = orig;
                }
            }
            comparisonGraph1.RoundValues      = true;
            comparisonGraph1.CustomRendered   = false;
            comparisonGraph1.ItemCalculations = talentCalculations.ToArray();
            comparisonGraph1.EquipSlot        = CharacterSlot.None;
            _characterSlot = CharacterSlot.None;
        }
Exemple #8
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;
        }