public GoalStack(RuneOptim.Save d)
 {
     data = d;
     foreach (var m in data.Monsters)
     {
         Things.Add(new MonsterItem()
         {
             Grade     = m.Grade,
             Level     = m.level,
             Monster   = m,
             MonTypeId = m.monsterTypeId
         });
     }
     foreach (var i in data.InventoryItems)
     {
         Things.Add(new CraftItem()
         {
             Amount   = i.Quantity,
             ItemType = i.Type,
             Id       = i.Id
         });
     }
     Things.Add(new CraftItem()
     {
         Amount   = data.WizardInfo.CostumePoint,
         ItemType = ItemType.WizardInfo,
         Id       = (int)WizardType.CostumePoint
     });
     // TODO: the rest
 }
示例#2
0
        /// <summary>
        /// Fills the instance with acceptable runes from save
        /// </summary>
        /// <param name="save">The Save data that contais the runes</param>
        /// <param name="useLocked">If it should include locked runes</param>
        /// <param name="useEquipped">If it should include equipped runes (other than the current monster)</param>
        public void GenRunes(Save save, bool useLocked = false, bool useEquipped = false, bool saveStats = false)
        {
            if (save == null)
                return;
            if (save.Runes == null)
                return;

            IEnumerable<Rune> rsGlobal = save.Runes;

            // Only using 'inventory' or runes on mon
            // also, include runes which have been unequipped (should only look above)
            if (!useEquipped)
                rsGlobal = rsGlobal.Where(r => (r.AssignedName == "Unknown name" || r.AssignedName == mon.Name) || r.Swapped);
            // only if the rune isn't currently locked for another purpose
            if (!useLocked)
                rsGlobal = rsGlobal.Where(r => r.Locked == false);

            // Only runes which we've included
            rsGlobal = rsGlobal.Where(r => BuildSets.Contains(r.Set));

            if (saveStats)
            {
                foreach (Rune r in rsGlobal)
                {
                    r.manageStats_Set++;
                }
            }

            int[] slotFakes = new int[6];
            bool[] slotPred = new bool[6];

            // For each runeslot
            for (int i = 0; i < 6; i++)
            {
                // put the right ones in
                runes[i] = rsGlobal.Where(r => r.Slot == i + 1).ToArray();

                // crank the rune prediction
                Rune[] rs = runes[i];
                int raiseTo = 0;
                bool predictSubs = false;

                // find the largest number to raise to
                // if any along the tree say to predict, do it
                if (runePrediction.ContainsKey("g"))
                {
                    int glevel = runePrediction["g"].Key;
                    if (glevel > raiseTo)
                        raiseTo = glevel;
                    predictSubs |= runePrediction["g"].Value;
                }
                if (runePrediction.ContainsKey(((i % 2 == 0) ? "o" : "e")))
                {
                    int mlevel = runePrediction[((i % 2 == 0) ? "o" : "e")].Key;
                    if (mlevel > raiseTo)
                        raiseTo = mlevel;
                    predictSubs |= runePrediction[((i % 2 == 0) ? "o" : "e")].Value;
                }
                if (runePrediction.ContainsKey((i + 1).ToString()))
                {
                    int slevel = runePrediction[(i + 1).ToString()].Key;
                    if (slevel > raiseTo)
                        raiseTo = slevel;
                    predictSubs |= runePrediction[(i + 1).ToString()].Value;
                }

                slotFakes[i] = raiseTo;
                slotPred[i] = predictSubs;

                // default fail OR
                Predicate<Rune> slotTest = r => false;
                int and = 0;
                // this means that runes won't get in unless they meet at least 1 criteria

                // which tab we pulled the filter from
                string gotScore = "";
                // the value to test SUM against
                int testVal = 0;

                // TODO: check what inheriting SUM (eg. Odd and 3) does
                // TODO: check what inheriting AND/OR then SUM (or visa versa)

                // find the most significant operatand of joining checks
                if (runeScoring.ContainsKey("g") && runeFilters.ContainsKey("g") && runeFilters["g"].Any(r => r.Value.NonZero))
                {
                    var kv = runeScoring["g"];
                    gotScore = "g";
                    and = kv.Key;
                    if (kv.Key == 1)
                    {
                        slotTest = r => true;
                    }
                    else if (kv.Key == 2)
                    {
                        testVal = kv.Value;
                    }
                }
                // is it and odd or even slot?
                string tmk = (i % 2 == 1 ? "e" : "o");
                if (runeScoring.ContainsKey(tmk) && runeFilters.ContainsKey(tmk) && runeFilters[tmk].Any(r => r.Value.NonZero))
                {
                    var kv = runeScoring[tmk];
                    gotScore = tmk;
                    and = kv.Key;
                    if (kv.Key == 1)
                    {
                        slotTest = r => true;
                    }
                    else if (kv.Key == 2)
                    {
                        testVal = kv.Value;
                    }
                }
                // turn the 0-5 to a 1-6
                tmk = (i + 1).ToString();
                if (runeScoring.ContainsKey(tmk) && runeFilters.ContainsKey(tmk) && runeFilters[tmk].Any(r => r.Value.NonZero))
                {
                    var kv = runeScoring[tmk];
                    gotScore = tmk;
                    and = kv.Key;
                    if (kv.Key == 1)
                    {
                        slotTest = r => true;
                    }
                    else if (kv.Key == 2)
                    {
                        testVal = kv.Value;
                    }
                }

                // if an operand was found, ensure the tab contains filter data
                if (gotScore != "")
                {
                    if (runeFilters.ContainsKey(gotScore))
                    {
                        // if all the filters for the tab are zero
                        if (runeFilters[gotScore].All(r => !r.Value.NonZero))
                        {
                            // set to OR TRUE
                            slotTest = r => true;
                            and = 0;
                        }
                    }
                }
                else
                {
                    // if there wasn't any relevant data for how to pick runes, just take 'em all!
                    slotTest = r => true;
                }

                // pull the filters (flat, perc, test) for all the tabs and stats
                Dictionary<string, RuneFilter> rfG = new Dictionary<string, RuneFilter>();
                if (runeFilters.ContainsKey("g"))
                    rfG = runeFilters["g"];

                Dictionary<string, RuneFilter> rfM = new Dictionary<string, RuneFilter>();
                if (runeFilters.ContainsKey((i % 2 == 1 ? "e" : "o")))
                    rfM = runeFilters[(i % 2 == 1 ? "e" : "o")];

                Dictionary<string, RuneFilter> rfS = new Dictionary<string, RuneFilter>();
                if (runeFilters.ContainsKey((i+1).ToString()))
                    rfS = runeFilters[(i + 1).ToString()];

                // if there where no filters with data
                bool blank = true;

                Stats rFlat = new Stats();
                Stats rPerc = new Stats();
                Stats rTest = new Stats();

                foreach (string stat in statNames)
                {
                    RuneFilter rf = new RuneFilter();
                    if (rfS.ContainsKey(stat))
                    {
                        rf = rfS[stat];
                        if (rfM.ContainsKey(stat))
                            rf = RuneFilter.Min(rf, rfM[stat]);

                        if (rfG.ContainsKey(stat))
                            rf = RuneFilter.Min(rf, rfG[stat]);

                    }
                    else
                    {
                        if (rfM.ContainsKey(stat))
                        {
                            rf = rfM[stat];
                            if (rfG.ContainsKey(stat))
                                rf = RuneFilter.Min(rf, rfG[stat]);
                        }
                        else
                        {
                            if (rfG.ContainsKey(stat))
                                rf = rfG[stat];
                        }
                    }
                    if (rf.NonZero)
                    {
                        // put the most relevant divisor in?
                        rFlat[stat] = rf.Flat;
                        rPerc[stat] = rf.Percent;
                        rTest[stat] = rf.Test;
                        blank = false;
                    }
                }

                // TODO: seems like it just ignores all the slotTesting before now

                // no filter data = use all
                if (blank)
                    slotTest = r => true;
                else
                {
                    // Set the test based on the type found
                    if (and == 0)
                    {
                        slotTest = r => r.Or(rFlat, rPerc, rTest, raiseTo, predictSubs);
                    }
                    else if (and == 1)
                    {
                        slotTest = r => r.And(rFlat, rPerc, rTest, raiseTo, predictSubs);
                    }
                    else if (and == 2)
                    {
                        slotTest = r => r.Test(rFlat, rPerc, raiseTo, predictSubs) >= testVal;
                    }
                }
                runes[i] = runes[i].Where(r => slotTest.Invoke(r)).ToArray();

                if (saveStats)
                {
                    foreach (Rune r in runes[i])
                    {
                        r.manageStats_RuneFilt++;
                    }
                }

                if (i % 2 == 1) // actually evens because off by 1
                {
                    // makes sure that the primary stat type is in the selection
                    if (slotStats[i].Count > 0)
                        runes[i] = runes[i].Where(r => slotStats[i].Contains(r.MainType.ToForms())).ToArray();
                }

                if (saveStats)
                {
                    foreach (Rune r in runes[i])
                    {
                        r.manageStats_TypeFilt++;
                    }
                }
            }

            // Make sure that for each set type, there are enough slots with runes in them
            // Eg. if only 1,4,5 have Violent, remove all violent runes because you need 4
            // for each included set
            foreach (RuneSet s in BuildSets)
            {
                // find how many slots have acceptable runes for it
                int slots = 0;
                for (int i = 0; i < 6; i++)
                {
                    if (runes[i].Any(r => r.Set == s))
                        slots += 1;
                }
                // if there isn't enough slots
                if (slots < Rune.SetRequired(s))
                {
                    // remove that set
                    for (int i = 0; i < 6; i++)
                    {
                        runes[i] = runes[i].Where(r => r.Set != s).ToArray();
                    }
                }
            }
        }
示例#3
0
        public void LoadJSON(string text)
        {
            //string save = System.IO.File.ReadAllText("..\\..\\save.json");
            data = JsonConvert.DeserializeObject<Save>(text);
            foreach (Monster mon in data.Monsters)
            {
                var equipedRunes = data.Runes.Where(r => r.AssignedId == mon.ID);

                bool wasStored = (mon.Name.IndexOf("In Storage") >= 0);
                mon.Name = mon.Name.Replace(" (In Storage)", "");

                foreach (Rune rune in equipedRunes)
                {
                    mon.ApplyRune(rune);
                }

                if (mon.priority == 0 && mon.Current.runeCount > 0)
                {
                    mon.priority = priority++;
                }

                var stats = mon.GetStats();

                string pri = "";
                if (mon.priority != 0)
                    pri = mon.priority.ToString();

                ListViewItem item = new ListViewItem(new string[]{
                    mon.Name,
                    mon.ID.ToString(),
                    pri,
                });
                if (wasStored)
                    item.ForeColor = Color.Gray;

                item.Tag = mon;
                listView1.Items.Add(item);
            }
            foreach (Rune rune in data.Runes)
            {
                ListViewItem item = new ListViewItem(new string[]{
                    rune.Set.ToString(),
                    rune.ID.ToString(),
                    rune.Grade.ToString(),
                    Rune.StringIt(rune.MainType, true),
                    rune.MainValue.ToString()
                });
                item.Tag = rune;
                listView2.Items.Add(item);
            }

            if (data.shrines == null)
                data.shrines = new Stats();

            if (config != null)
            {
                if (config.AppSettings.Settings.AllKeys.Contains("shrineSpeed"))
                {
                    int val = 0;
                    int.TryParse(config.AppSettings.Settings["shrineSpeed"].Value, out val);
                    data.shrines.Speed = val;
                    int level = (int)Math.Floor(val / (double)1.5);
                    ((ToolStripMenuItem)speedToolStripMenuItem.DropDownItems[level]).Checked = true;
                }
            }
        }