private void button1_Click(object sender, EventArgs e)
        {
            var Playthrough = PlaythroughGenerator.GeneratePlaythrough(CheckerInstance, listBox2.SelectedIndex);

            if (Playthrough.GameClearItem == null)
            {
                MessageBox.Show("The selected Game Clear Item can not be obtained in this seed. A playthrough can not be generated.");
                return;
            }
            PlaythroughGenerator.DisplayPlaythrough(Playthrough.ImportantPlaythrough, Playthrough.PlaythroughInstance, Playthrough.GameClearItem.Check.ID, CheckerInstance.Logic);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (!(listBox1.SelectedItem is LogicObjects.ListItem))
            {
                return;
            }
            var Location    = (listBox1.SelectedItem as LogicObjects.ListItem).LocationEntry;
            var Item        = (listBox1.SelectedItem as LogicObjects.ListItem).ItemEntry;
            var Playthrough = PlaythroughGenerator.GeneratePlaythrough(CheckerInstance, Location.ID, true);

            var LocationInPlayThrough = Playthrough.Playthrough.Find(x => x.Check.ID == Location.ID);

            if (LocationInPlayThrough == null)
            {
                MessageBox.Show($"{Item.ItemName ?? Item.DictionaryName} Can not be obtained in this seed");
                return;
            }
            MessageBox.Show($"{Item.ItemName ?? Item.DictionaryName} Can be obtained in Sphere {LocationInPlayThrough.SphereNumber}");
        }
        private void BtnCheckSeed_Click(object sender, EventArgs e)
        {
            if (!chkShowObtainable.Checked && !chkShowUnobtainable.Checked)
            {
                LBResult.Items.Clear();
                return;
            }

            var logicCopy = Utility.CloneTrackerInstance(CheckerInstance);

            foreach (var entry in logicCopy.Logic)
            {
                entry.Available = false;
                entry.Checked   = false;
                entry.Aquired   = false;
                if (entry.SpoilerRandom > -1)
                {
                    entry.RandomizedItem = entry.SpoilerRandom;
                }                                                                            //Make the items randomized item its spoiler item, just for consitancy sake
                else if (entry.RandomizedItem > -1)
                {
                    entry.SpoilerRandom = entry.RandomizedItem;
                }                                                                                  //If the item doesn't have spoiler data, but does have a randomized item. set it's spoiler data to the randomized item
                else if (entry.Unrandomized(2))
                {
                    entry.SpoilerRandom = entry.ID; entry.RandomizedItem = entry.ID;
                }                                                                                                   //If the item doesn't have spoiler data or a randomized item and is unrandomized (manual), set it's spoiler item to it's self
            }

            LBResult.Items.Clear();
            List <int> Ignored = new List <int>();

            foreach (var item in LBIgnoredChecks.Items)
            {
                Ignored.Add((item as LogicObjects.ListItem).PathID);
            }

            var GameClearEntry = logicCopy.Logic.Find(x => x.DictionaryName == "MMRTGameClear");

            if (GameClearEntry != null)
            {
                GameClearEntry.ItemName = (LogicObjects.MainTrackerInstance.IsMM()) ? "Defeat Majora" : "Beat the Game";
            }
            else if (LogicObjects.MainTrackerInstance.IsMM())
            {
                int GameClearID = PlaythroughGenerator.GetGameClearEntry(logicCopy.Logic, LogicObjects.MainTrackerInstance.IsEntranceRando());
                logicCopy.Logic[GameClearID].ItemName = "Defeat Majora";
            }

            CheckSeed(logicCopy, true, Ignored);
            List <string> obtainable   = new List <string>();
            List <string> unobtainable = new List <string>();

            foreach (var item in LBNeededItems.Items)
            {
                bool   Spoil           = false;
                var    ListItem        = item as LogicObjects.ListItem;
                var    iteminLogic     = logicCopy.Logic[ListItem.PathID];
                string ItemName        = iteminLogic.ItemName ?? iteminLogic.DictionaryName;
                var    ItemsLocation   = iteminLogic.GetItemsNewLocation(logicCopy.Logic);
                string LocationFoundAt = (ItemsLocation != null) ? ItemsLocation.LocationName ?? ItemsLocation.DictionaryName : "";
                string DisplayName     = (Spoil) ? ItemName + ": " + LocationFoundAt : ItemName;

                Debugging.Log(logicCopy.Logic[ListItem.PathID].DictionaryName + " " + logicCopy.Logic[ListItem.PathID].Aquired);
                if (logicCopy.Logic[ListItem.PathID].Aquired)
                {
                    obtainable.Add(DisplayName);
                }
                else
                {
                    unobtainable.Add(DisplayName);
                }
            }
            if (unobtainable.Count > 0 && chkShowUnobtainable.Checked)
            {
                LBResult.Items.Add("Unobtainable ==============================");
                foreach (var i in unobtainable)
                {
                    LBResult.Items.Add(i);
                }
            }
            if (obtainable.Count > 0 && chkShowObtainable.Checked)
            {
                LBResult.Items.Add("Obtainable ==============================");
                foreach (var i in obtainable)
                {
                    LBResult.Items.Add(i);
                }
            }
        }
        private void SeedChecker_Load(object sender, EventArgs e)
        {
            CheckerInstance = Utility.CloneTrackerInstance(LogicObjects.MainTrackerInstance);

            if (!Utility.CheckforSpoilerLog(CheckerInstance.Logic))
            {
                var file = Utility.FileSelect("Select A Spoiler Log", "Spoiler Log (*.txt;*html)|*.txt;*html");
                if (file == "")
                {
                    return;
                }
                LogicEditing.WriteSpoilerLogToLogic(CheckerInstance, file);
                if (!Utility.CheckforSpoilerLog(CheckerInstance.Logic, true))
                {
                    MessageBox.Show("Not all items have spoiler data. Your results may be incorrect.");
                }
            }
            else if (!Utility.CheckforSpoilerLog(CheckerInstance.Logic, true))
            {
                MessageBox.Show("Not all items have spoiler data. Your results may be incorrect.");
            }


            var GameClearEntry = CheckerInstance.Logic.Find(x => x.DictionaryName == "MMRTGameClear");

            int GameclearID = -1;

            if (GameClearEntry != null)
            {
                GameClearEntry.DictionaryName = (CheckerInstance.IsMM()) ? "Defeat Majora" : "Beat the Game";
                LBNeededItems.Items.Add(new LogicObjects.ListItem {
                    DisplayName = GameClearEntry.DictionaryName, PathID = GameClearEntry.ID
                });
            }
            else if (CheckerInstance.IsMM())
            {
                Console.WriteLine("Adding MMRTGameClear");
                GameclearID = PlaythroughGenerator.GetGameClearEntry(CheckerInstance.Logic, CheckerInstance.IsEntranceRando());
                if (!CheckerInstance.ItemInRange(GameclearID))
                {
                    return;
                }
                CheckerInstance.Logic[GameclearID].DictionaryName = "Defeat Majora";
                LBNeededItems.Items.Add(new LogicObjects.ListItem {
                    DisplayName = "Defeat Majora", PathID = GameclearID
                });
            }

            listBox2.DataSource = CheckerInstance.Logic.Select(x => x.LocationName ?? x.DictionaryName).ToList();

            GameClearEntry = CheckerInstance.Logic.Find(x => x.DictionaryName == "MMRTGameClear" || x.DictionaryName == "Beat the Game" || x.DictionaryName == "Defeat Majora");

            if (GameClearEntry != null)
            {
                listBox2.SelectedIndex = GameClearEntry.ID;
            }
            else
            {
                listBox2.SelectedIndex = 0;
            }
            WriteSpoilerItemsToBox();
        }