示例#1
0
        // when the scoring type changes
        private void filterJoin_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox box     = (ComboBox)sender;
            string   tabName = (string)box.Tag;
            TabPage  tab     = GetTab(tabName);
            Control  ctrl;

            foreach (var stat in Build.StatNames)
            {
                ctrl = tab.Controls.Find(tabName + stat + "test", false).FirstOrDefault();
                if (ctrl != null)
                {
                    ctrl.Enabled = RuneAttributeFilterEnabled((FilterType)box.SelectedItem);
                }
            }
            ctrl = tab.Controls.Find(tabName + "test", false).FirstOrDefault();
            if (ctrl != null)
            {
                ctrl.Enabled = RuneSumFilterEnabled((FilterType)box.SelectedItem);
            }

            int    count = 30;
            double?test  = null;
            double temp;

            ctrl = tab.Controls.Find(tabName + "test", false).FirstOrDefault();
            if (double.TryParse(ctrl?.Text, out temp))
            {
                test = temp;
            }

            ctrl = tab.Controls.Find(tabName + "count", false).FirstOrDefault();
            if (double.TryParse(ctrl?.Text, out temp))
            {
                count = (int)temp;
            }

            if (!Build.RuneScoring.ContainsKey(LibExtensionMethods.GetIndex(tabName)))
            {
                Build.RuneScoring.Add(LibExtensionMethods.GetIndex(tabName), new Build.RuneScoreFilter((FilterType)box.SelectedItem, test, count));
            }
            Build.RuneScoring[LibExtensionMethods.GetIndex(tabName)] = new Build.RuneScoreFilter((FilterType)box.SelectedItem, test, count);

            // TODO: trim the ZERO nodes on the tree

            // retest the rune
            //TestRune(runeTest);

            UpdateGlobal();
        }
示例#2
0
        void UpdateStat(string tab, string stat)
        {
            SlotIndex tabdex = LibExtensionMethods.GetIndex(tab);
            TabPage   ctab   = GetTab(tab);
            var       ctest  = ctab.Controls.Find(tab + stat + "test", true).First();
            double    tt;
            double?   test = 0;

            double.TryParse(ctest.Text, out tt);
            test = tt;
            if (ctest.Text.Length == 0)
            {
                test = null;
            }

            if (!Build.RuneFilters.ContainsKey(tabdex))
            {
                Build.RuneFilters.Add(tabdex, new Dictionary <string, RuneFilter>());
            }
            var fd = Build.RuneFilters[tabdex];

            if (!fd.ContainsKey(stat))
            {
                fd.Add(stat, new RuneFilter());
            }
            var fi = fd[stat];

            foreach (string type in new string[] { "flat", "perc" })
            {
                if (type == "perc" && stat == "SPD")
                {
                    continue;
                }
                if (type == "flat" && (stat == "ACC" || stat == "RES" || stat == "CD" || stat == "CR"))
                {
                    continue;
                }

                if (tab == "g")
                {
                    ctab.Controls.Find(tab + "i" + stat + type, true).First().Text = "";
                }
                else if (tab == "e" || tab == "o")
                {
                    ctab.Controls.Find(tab + "i" + stat + type, true).First().Text = tabg.Controls.Find("gc" + stat + type, true).First().Text;
                }
                else
                {
                    int s = int.Parse(tab);
                    if (s % 2 == 0)
                    {
                        ctab.Controls.Find(tab + "i" + stat + type, true).First().Text = tabe.Controls.Find("ec" + stat + type, true).First().Text;
                    }
                    else
                    {
                        ctab.Controls.Find(tab + "i" + stat + type, true).First().Text = tabo.Controls.Find("oc" + stat + type, true).First().Text;
                    }
                }

                var c = ctab.Controls.Find(tab + "c" + stat + type, true).First();

                double i  = 0;
                double t  = 0;
                var    ip = double.TryParse(ctab.Controls.Find(tab + "i" + stat + type, true).First().Text, out i);
                var    tp = double.TryParse(ctab.Controls.Find(tab + stat + type, true).First().Text, out t);

                if (ip)
                {
                    c.Text = tp ? t.ToString() : i.ToString();
                }
                else
                {
                    c.Text = tp ? t.ToString() : "";
                }

                fi[type] = t;

                if (ctab.Controls.Find(tab + stat + type, true).First().Text.Length == 0)
                {
                    fi[type] = null;
                }
            }

            fi.Test = test;
        }
示例#3
0
        void TestRuneTab(Rune rune, string tab)
        {
            bool      res    = false;
            SlotIndex tabdex = LibExtensionMethods.GetIndex(tab);

            if (!Build.RuneScoring.ContainsKey(tabdex))
            {
                return;
            }

            int? fake = 0;
            bool pred = false;

            if (Build.RunePrediction.ContainsKey(tabdex))
            {
                fake = Build.RunePrediction[tabdex].Key;
                pred = Build.RunePrediction[tabdex].Value;
            }

            var        kv      = Build.RuneScoring[tabdex];
            FilterType scoring = kv.Type;

            if (scoring == FilterType.And)
            {
                res = true;
            }

            double points = 0;

            foreach (var stat in Build.StatNames)
            {
                bool s = GetPts(rune, tab, stat, ref points, fake ?? 0, pred);
                if (scoring == FilterType.And)
                {
                    res &= s;
                }
                else if (scoring == 0)
                {
                    res |= s;
                }
            }

            var ctrl = Controls.Find(tab + "Check", true).FirstOrDefault();

            if (ctrl != null)
            {
                ctrl.Text = res.ToString();
            }

            if (scoring == FilterType.Sum || scoring == FilterType.SumN)
            {
                ctrl.Text = points.ToString("#.##");
            }
            if (scoring == FilterType.Sum)
            {
                ctrl.ForeColor = Color.Red;
                if (points >= Build.RuneScoring[tabdex].Value)
                {
                    ctrl.ForeColor = Color.Green;
                }
            }
        }
示例#4
0
        void UpdateGlobal()
        {
            // if the window is loading, try not to save the window
            if (loading)
            {
                return;
            }

            foreach (string tab in tabNames)
            {
                SlotIndex tabdex = LibExtensionMethods.GetIndex(tab);
                foreach (string stat in Build.StatNames)
                {
                    UpdateStat(tab, stat);
                }

                if (!Build.RuneScoring.ContainsKey(tabdex) && Build.RuneFilters.ContainsKey(tabdex))
                {
                    // if there is a non-zero
                    if (Build.RuneFilters[tabdex].Any(r => r.Value.NonZero))
                    {
                        Build.RuneScoring.Add(tabdex, new Build.RuneScoreFilter());
                    }
                }

                if (Build.RuneScoring.ContainsKey(tabdex))
                {
                    var kv        = Build.RuneScoring[tabdex];
                    var ctrlTest  = Controls.Find(tab + "test", true).FirstOrDefault();
                    var ctrlCount = Controls.Find(tab + "count", true).FirstOrDefault();

                    //if (!string.IsNullOrWhiteSpace(ctrlTest?.Text))
                    double?testVal = null;
                    int?   count   = null;
                    if (double.TryParse(ctrlTest?.Text, out double tempval))
                    {
                        testVal = tempval;
                    }

                    if (double.TryParse(ctrlCount?.Text, out tempval))
                    {
                        count = (int)tempval;
                    }

                    Build.RuneScoring[tabdex] = new Build.RuneScoreFilter(kv.Type, testVal, count);
                }

                TextBox tb = (TextBox)Controls.Find(tab + "raise", true).FirstOrDefault();
                int     raiseLevel;
                if (!int.TryParse(tb.Text, out raiseLevel))
                {
                    raiseLevel = -1;
                }
                CheckBox cb = (CheckBox)Controls.Find(tab + "bonus", true).FirstOrDefault();

                if (raiseLevel == -1 && !cb.Checked)
                {
                    Build.RunePrediction.Remove(tabdex);
                }
                else
                {
                    Build.RunePrediction[tabdex] = new KeyValuePair <int?, bool>(raiseLevel, cb.Checked);
                }

                Build.GetPrediction(tabdex, out int?raise, out bool pred);
                var ctrlRaise = Controls.Find(tab + "raiseInherit", true).FirstOrDefault();
                ctrlRaise.Text = raise?.ToString();
                var ctrlPred = Controls.Find(tab + "bonusInherit", true).FirstOrDefault();
                ctrlPred.Text = (pred ? "T" : "F");
            }

            foreach (var stat in Build.StatEnums)
            {
                double.TryParse(statRows[stat].Min.Text, out double min);
                Build.Minimum[stat] = min;

                double.TryParse(statRows[stat].Goal.Text, out double goal);
                Build.Goal[stat] = goal;

                double.TryParse(statRows[stat].Worth.Text, out double worth);
                Build.Sort[stat] = worth;

                double.TryParse(statRows[stat].Max.Text, out double max);
                Build.Maximum[stat] = max;

                double.TryParse(statRows[stat].Thresh.Text, out double thr);
                Build.Threshold[stat] = thr;

                if (min > max && !string.IsNullOrWhiteSpace(statRows[stat].Max.Text))
                {
                    statRows[stat].Min.BackColor = Color.Red;
                    statRows[stat].Max.BackColor = Color.Red;
                }
                else if (min > thr && !string.IsNullOrWhiteSpace(statRows[stat].Thresh.Text))
                {
                    statRows[stat].Min.BackColor    = Color.Yellow;
                    statRows[stat].Thresh.BackColor = Color.Yellow;
                }
                else
                {
                    statRows[stat].Min.BackColor    = SystemColors.Window;
                    statRows[stat].Max.BackColor    = SystemColors.Window;
                    statRows[stat].Thresh.BackColor = SystemColors.Window;
                }

                if (thr > 0 && worth == 0)
                {
                    statRows[stat].Thresh.BackColor = Color.Yellow;
                    statRows[stat].Worth.BackColor  = Color.Yellow;
                }
                else if (goal > 0 && worth == 0)
                {
                    statRows[stat].Goal.BackColor  = Color.Yellow;
                    statRows[stat].Worth.BackColor = Color.Yellow;
                }
                else
                {
                    statRows[stat].Goal.BackColor   = SystemColors.Window;
                    statRows[stat].Thresh.BackColor = SystemColors.Window;
                    statRows[stat].Worth.BackColor  = SystemColors.Window;
                }

                double.TryParse(statRows[stat].Current.Text, out double current);
                if (worth != 0 && current != 0)
                {
                    double pts = current;
                    if (goal > 0 && current > goal)
                    {
                        pts = (current - goal) / 2 + goal;
                    }
                    if (max != 0)
                    {
                        pts = Math.Min(max, current);
                    }
                    statRows[stat].CurrentPts.Text = (pts / worth).ToString("0.##");
                }
            }

            foreach (var extra in Build.ExtraEnums)
            {
                double val;
                double total = 0;
                if (double.TryParse(statRows[extra].Min.Text, out val))
                {
                    total = val;
                }
                Build.Minimum.ExtraSet(extra, total);

                double goal = 0;
                if (double.TryParse(statRows[extra].Goal.Text, out val))
                {
                    goal = val;
                }
                Build.Goal.ExtraSet(extra, goal);

                double worth = 0;
                if (double.TryParse(statRows[extra].Worth.Text, out val))
                {
                    worth = val;
                }
                Build.Sort.ExtraSet(extra, worth);

                double max = 0;
                if (double.TryParse(statRows[extra].Max.Text, out val))
                {
                    max = val;
                }
                Build.Maximum.ExtraSet(extra, max);

                double thr = 0;
                if (double.TryParse(statRows[extra].Thresh.Text, out val))
                {
                    thr = val;
                }
                Build.Threshold.ExtraSet(extra, thr);

                double current = 0;
                if (double.TryParse(statRows[extra].Current.Text, out val))
                {
                    current = val;
                }
                if (worth != 0 && current != 0)
                {
                    double pts = current;
                    if (goal > 0 && current > goal)
                    {
                        pts = (current - goal) / 2 + goal;
                    }
                    if (max != 0)
                    {
                        pts = Math.Min(max, current);
                    }
                    statRows[extra].CurrentPts.Text = (pts / worth).ToString("0.##");
                }
                else
                {
                    statRows[extra].CurrentPts.Text = "";
                }
            }

            for (int i = 0; i < 4; i++)
            {
                if (Build?.Mon?.SkillsFunction?[i] != null)
                {
                    var    ff   = Build.Mon.SkillsFunction[i];
                    string stat = "Skill" + i;
                    Attr   aaa  = Attr.Skill1 + i;

                    double val;
                    double total = 0;
                    if (double.TryParse(statRows[aaa].Min.Text, out val))
                    {
                        total = val;
                    }
                    Build.Minimum.ExtraSet(aaa, total);

                    double goal = 0;
                    if (double.TryParse(statRows[aaa].Goal.Text, out val))
                    {
                        goal = val;
                    }
                    Build.Goal.ExtraSet(aaa, goal);

                    double worth = 0;
                    if (double.TryParse(statRows[aaa].Worth.Text, out val))
                    {
                        worth = val;
                    }
                    Build.Sort.ExtraSet(aaa, worth);

                    double max = 0;
                    if (double.TryParse(statRows[aaa].Max.Text, out val))
                    {
                        max = val;
                    }
                    Build.Maximum.ExtraSet(aaa, max);

                    double thr = 0;
                    if (double.TryParse(statRows[aaa].Thresh.Text, out val))
                    {
                        thr = val;
                    }
                    Build.Threshold.ExtraSet(aaa, thr);

                    double current = 0;
                    if (double.TryParse(statRows[aaa].Current.Text, out val))
                    {
                        current = val;
                    }
                    if (worth != 0 && current != 0)
                    {
                        double pts = current;
                        if (goal > 0 && current > goal)
                        {
                            pts = (current - goal) / 2 + goal;
                        }
                        if (max != 0)
                        {
                            pts = Math.Min(max, current);
                        }
                        statRows[aaa].CurrentPts.Text = (pts / worth).ToString("0.##");
                    }
                    else
                    {
                        statRows[aaa].CurrentPts.Text = "";
                    }
                }
            }

            var lists = new ListView[] { priStat2, priStat4, priStat6 };

            for (int j = 0; j < lists.Length; j++)
            {
                var lv = lists[j];
                var bl = Build.SlotStats[(j + 1) * 2 - 1];
                bl.Clear();

                for (int i = 0; i < Build.StatNames.Length; i++)
                {
                    string stat = Build.StatNames[i];
                    if (i < 3)
                    {
                        if (lv.Items.Find(stat + "flat", true).FirstOrDefault().Group == lv.Groups[0])
                        {
                            bl.Add(stat + "flat");
                        }
                        if (lv.Items.Find(stat + "perc", true).FirstOrDefault().Group == lv.Groups[0])
                        {
                            bl.Add(stat + "perc");
                        }
                    }
                    else
                    {
                        if (j == 0 && stat != "SPD")
                        {
                            continue;
                        }
                        if (j == 1 && (stat != "CR" && stat != "CD"))
                        {
                            continue;
                        }
                        if (j == 2 && (stat != "ACC" && stat != "RES"))
                        {
                            continue;
                        }

                        if (lv.Items.Find(stat + (stat == "SPD" ? "flat" : "perc"), true).FirstOrDefault().Group == lv.Groups[0])
                        {
                            bl.Add(stat + (stat == "SPD" ? "flat" : "perc"));
                        }
                    }
                }
            }

            TestRune(runeTest);

            updatePerms();

            if (testWindow != null && !testWindow.IsDisposed)
            {
                testWindow.textBox_TextChanged(null, null);
            }
        }