//--------------------------Constructor-----------------------------
        public StatsWindow(SkillTree tree, CharItemData itemAttributes)
        {
            InitializeComponent();
            this.Tree = tree;
            ItemAttributes = itemAttributes;
            requiredStats = new CharStats.VIPStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            characterStats = new CharStats(Tree);
            statsComparer = new StatsComparer(Tree);

            changeStatsGroupBox.DataContext = statsComparer;
            UpdateStatComparer();

            InitListViews();
            intitializationFinished = true;
            buildRecords = new Dictionary<HashSet<ushort>, CharStats.VIPStats>();
        }
        private void GetMaxStats()
        {
            maxStats = new CharStats.VIPStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            int maxPoints = 1;
            foreach (var build in availableBuilds)
            {
                CharStats.VIPStats stats = buildRecords[build];

                if (stats.AttackSkillDPS > maxStats.AttackSkillDPS)
                    maxStats.AttackSkillDPS = stats.AttackSkillDPS;
                if (stats.SpellSkillDPS > maxStats.SpellSkillDPS)
                    maxStats.SpellSkillDPS = stats.SpellSkillDPS;
                if (stats.ChanceToBlock > maxStats.ChanceToBlock)
                    maxStats.ChanceToBlock = stats.ChanceToBlock;
                if (stats.ChanceToEvade > maxStats.ChanceToEvade)
                    maxStats.ChanceToEvade = stats.ChanceToEvade;
                if (stats.CritChanceMH > maxStats.CritChanceMH)
                    maxStats.CritChanceMH = stats.CritChanceMH;
                if (stats.CritChanceOH > maxStats.CritChanceOH)
                    maxStats.CritChanceOH = stats.CritChanceOH;
                if (stats.SpellCritChance > maxStats.SpellCritChance)
                    maxStats.SpellCritChance = stats.SpellCritChance;
                if (stats.EnergyShield > maxStats.EnergyShield)
                    maxStats.EnergyShield = stats.EnergyShield;
                if (stats.Life > maxStats.Life)
                    maxStats.Life = stats.Life;
                if (stats.Mana > maxStats.Mana)
                    maxStats.Mana = stats.Mana;
                if (stats.PhysDamageReduction > maxStats.PhysDamageReduction)
                    maxStats.PhysDamageReduction = stats.PhysDamageReduction;
                if (build.Count > maxPoints)
                    maxPoints = build.Count - 1;
            }

            maxCritMHTextBlock.Text = "Critical MainHand (" + maxStats.CritChanceMH.ToString() + "):";
            maxCritOHTextBlock.Text = "Critical OffHand (" + maxStats.CritChanceOH.ToString() + "):";
            maxSpellCritTextBlock.Text = "Critical Spell (" + maxStats.SpellCritChance.ToString() + "):";
            maxEvadeTextBlock.Text = "Evasion Chance (" + maxStats.ChanceToEvade.ToString() + "):";
            maxBlockTextBlock.Text = "Block Chance (" + maxStats.ChanceToBlock.ToString() + "):";
            maxEnergySTextBlock.Text = "Energy Shield (" + maxStats.EnergyShield.ToString() + "):";
            maxLifeTextBlock.Text = "Life (" + maxStats.Life.ToString() + "):";
            maxManaTextBlock.Text = "Mana (" + maxStats.Mana.ToString() + "):";
            maxDmgRedTextBlock.Text = "Physical Reduction (" + maxStats.PhysDamageReduction.ToString() + "):";
            maxSPTextBlock.Text = "Max Used Points (" + maxPoints.ToString() + "):";
        }
        private void GetBuildsStats(List<HashSet<ushort>> buildCollection)
        {
            bool firstTime = true;
            foreach (var build in buildCollection)
            {
                Dictionary<string, List<float>> passiveAttribs = new Dictionary<string, List<float>>();
                foreach (ushort inode in build)
                {
                    var node = Tree.Skillnodes[inode];
                    foreach (var attr in node.Attributes)
                    {
                        if (!passiveAttribs.ContainsKey(attr.Key))
                            passiveAttribs[attr.Key] = new List<float>();
                        for (int i = 0; i < attr.Value.Count; i++)
                        {

                            if (passiveAttribs.ContainsKey(attr.Key) && passiveAttribs[attr.Key].Count > i)
                                passiveAttribs[attr.Key][i] += attr.Value[i];
                            else
                            {
                                passiveAttribs[attr.Key].Add(attr.Value[i]);
                            }
                        }
                    }
                }

                foreach (CharItemData.Attribute mod in ItemAttributes.NonLocalMods)
                {
                    if (passiveAttribs.ContainsKey(mod.TextAttribute))
                    {
                        for (int i = 0; i < mod.Values.Count; i++)
                        {
                            passiveAttribs[mod.TextAttribute][i] += mod.Values[i];
                        }
                    }
                    else
                    {
                        passiveAttribs[mod.TextAttribute] = mod.Values;
                    }
                }
                CharacterStats.UpdateStats(passiveAttribs, Tree.CharLevel, ItemAttributes);
                if (firstTime)
                {
                    CloneCharStats(statsComparer, CharacterStats);
                    firstTime = false;
                }
                CharStats.VIPStats stats = new CharStats.VIPStats(CharacterStats.Life, CharacterStats.LifeRegen, CharacterStats.Mana, CharacterStats.ManaRegen, CharacterStats.EnergyShield, CharacterStats.PhysDamageReduction, CharacterStats.ChanceToEvade, CharacterStats.ChanceToBlock, CharacterStats.CritChanceMH, CharacterStats.CritChanceOH, CharacterStats.CritChanceSpell, CharacterStats.AttackSkillDPS, CharacterStats.SpellSkillDPS);
                buildRecords.Add(build, stats);
            }
            buildCollection.Clear();
            buildCollection = null;
        }