예제 #1
0
        public static bool MarkObject(LogicObjects.LogicEntry CheckedObject)
        {
            if (CheckedObject.RandomizedItem > -2)
            {
                CheckedObject.RandomizedItem = -2; return(true);
            }
            if (CheckedObject.SpoilerRandom > -2)
            {
                CheckedObject.RandomizedItem = CheckedObject.SpoilerRandom; return(true);
            }
            if (CheckedObject.RandomizedState() == 2)
            {
                CheckedObject.RandomizedItem = CheckedObject.ID; return(true);
            }
            Tools.CurrentSelectedItem = CheckedObject;
            ItemSelect ItemSelectForm = new ItemSelect(); var dialogResult = ItemSelectForm.ShowDialog();

            if (dialogResult != DialogResult.OK)
            {
                Tools.CurrentSelectedItem = new LogicObjects.LogicEntry(); return(false);
            }
            if (Tools.CurrentSelectedItem.ID < 0)
            {
                CheckedObject.RandomizedItem = -1; Tools.CurrentSelectedItem = new LogicObjects.LogicEntry(); return(true);
            }
            CheckedObject.RandomizedItem = Tools.CurrentSelectedItem.ID;
            Tools.CurrentSelectedItem    = new LogicObjects.LogicEntry();
            return(true);
        }
예제 #2
0
        public static int SetAreaClear(LogicObjects.LogicEntry ClearLogic, LogicObjects.TrackerInstance Instance)
        {
            //0 = do nothing, 1 = Skip Fake item calculation, 2 = Skip Fake item calculation and recalculate logic
            Dictionary <int, int> EntAreaDict = Instance.EntranceAreaDic;

            if (EntAreaDict.Count == 0 || !EntAreaDict.ContainsKey(ClearLogic.ID))
            {
                return(0);
            }
            var RandClearLogic = ClearLogic.RandomizedAreaClear(Instance);

            if (RandClearLogic == null && ClearLogic.Aquired)
            {
                ClearLogic.Aquired = false; return(2);
            }
            if (RandClearLogic == null)
            {
                return(1);
            }
            if (ClearLogic.Aquired != RandClearLogic.Available)
            {
                ClearLogic.Aquired = RandClearLogic.Available; return(2);
            }
            return(1);
        }
예제 #3
0
        public static void CheckEntrancePair(LogicObjects.LogicEntry Location, LogicObjects.TrackerInstance Instance, bool Checking)
        {
            if (Location.ID < 0 || !Instance.Options.CoupleEntrances || !Location.HasRandomItem(true) || !Location.IsEntrance())
            {
                return;
            }
            var reverseLocation = Location.PairedEntry(Instance, true);
            var reverseItem     = Location.PairedEntry(Instance);

            if (reverseItem == null || reverseLocation == null)
            {
                return;
            }
            //is the reverse entrance already checked and randomized to something
            if ((reverseLocation.Checked || (reverseLocation.HasRandomItem(true) && reverseLocation.RandomizedEntry(Instance) != reverseItem) || reverseItem.Aquired) && Checking)
            {
                return;
            }
            //Does the spoiler log conflict with what the reverse check is trying to do
            if (reverseLocation.SpoilerRandom != reverseItem.ID && reverseLocation.SpoilerRandom > -1 && Checking)
            {
                return;
            }
            reverseLocation.Checked        = Checking;
            reverseLocation.RandomizedItem = (Checking) ? reverseItem.ID : -2;
            reverseItem.Aquired            = Checking;
        }
예제 #4
0
        public static LogicObjects.LogicEntry PairedEntry(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, bool RandomizedItem = false)
        {
            var Pairs = Instance.EntrancePairs;
            int ID    = (RandomizedItem) ? entry.RandomizedItem : entry.ID;

            if (Pairs.ContainsKey(ID) && Pairs[ID] < Instance.Logic.Count)
            {
                return(Instance.Logic[Pairs[ID]]);
            }
            return(null);
        }
예제 #5
0
        //Form Objects

        public static bool IsInMMRItemList(LogicObjects.LogicEntry x, bool IncludeOwl = false)
        {
            return
                (
                (
                    x.ItemSubType == "Bottle" ||
                    x.ItemSubType == "Item" ||
                    x.ItemSubType == "Entrance" ||
                    (x.ItemSubType == "Owl Statue" && IncludeOwl)
                ) &&
                x.DictionaryName != "Ice Trap"
                );
        }
예제 #6
0
        public static bool CheckObject(LogicObjects.LogicEntry CheckedObject, LogicObjects.TrackerInstance Instance)
        {
            if (CheckedObject.Checked && CheckedObject.RandomizedItem > -2)
            {
                CheckedObject.Checked = false;
                if (CheckedObject.RandomizedItem > -1 && CheckedObject.RandomizedItem < Instance.Logic.Count && !Tools.SameItemMultipleChecks(CheckedObject.RandomizedItem, Instance))
                {
                    Instance.Logic[CheckedObject.RandomizedItem].Aquired = false;
                    CheckEntrancePair(CheckedObject, Instance, false);
                }
                CheckedObject.RandomizedItem = -2;
                return(true);
            }
            if (CheckedObject.SpoilerRandom > -2 || CheckedObject.RandomizedItem > -2 || CheckedObject.RandomizedState() == 2)
            {
                CheckedObject.Checked = true;
                if (CheckedObject.RandomizedState() == 2)
                {
                    CheckedObject.RandomizedItem = CheckedObject.ID;
                }
                if (CheckedObject.SpoilerRandom > -2)
                {
                    CheckedObject.RandomizedItem = CheckedObject.SpoilerRandom;
                }
                if (CheckedObject.RandomizedItem < 0)
                {
                    CheckedObject.RandomizedItem = -1; return(true);
                }
                Instance.Logic[CheckedObject.RandomizedItem].Aquired = true;
                CheckEntrancePair(CheckedObject, Instance, true);
                return(true);
            }
            Tools.CurrentSelectedItem = CheckedObject; //Set the global CurrentSelectedItem to the Location selected in the list box
            ItemSelect ItemSelectForm = new ItemSelect(); var dialogResult = ItemSelectForm.ShowDialog();

            if (dialogResult != DialogResult.OK)
            {
                Tools.CurrentSelectedItem = new LogicObjects.LogicEntry(); return(false);
            }
            CheckedObject.Checked = true;
            if (Tools.CurrentSelectedItem.ID < 0) //At this point CurrentSelectedItem has been changed to the selected item
            {
                CheckedObject.RandomizedItem = -1; Tools.CurrentSelectedItem = new LogicObjects.LogicEntry(); return(true);
            }
            CheckedObject.RandomizedItem = Tools.CurrentSelectedItem.ID;
            Instance.Logic[Tools.CurrentSelectedItem.ID].Aquired = true;
            Tools.CurrentSelectedItem = new LogicObjects.LogicEntry();
            CheckEntrancePair(CheckedObject, Instance, true);

            return(true);
        }
예제 #7
0
 public static LogicObjects.LogicEntry RandomizedEntry(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, bool ReturnJunkAsItem = false)
 {
     if (ReturnJunkAsItem && entry.HasRandomItem(false) && !entry.HasRandomItem(true))
     {
         return(new LogicObjects.LogicEntry {
             ID = -1, DictionaryName = "Junk", DisplayName = "Junk", LocationName = "Junk", ItemName = "Junk"
         });
     }
     if (!entry.HasRandomItem(true) || entry.RandomizedItem >= Instance.Logic.Count)
     {
         return(null);
     }
     return(Instance.Logic[entry.RandomizedItem]);
 }
예제 #8
0
        public static LogicObjects.LogicEntry RandomizedAreaClear(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance)
        {
            //Finds the area clear related to the dungeon that is randomized to the current area.
            //If woodfall entrance leads to snowhead and you pass this function woodfall clear it will return snowhead clear.
            if (!Instance.EntranceAreaDic.ContainsKey(entry.ID))
            {
                return(null);
            }
            var templeEntrance     = Instance.EntranceAreaDic[entry.ID];                                                                            //What is the dungeon entrance in this area
            var RandTempleEntrance = Instance.Logic[templeEntrance].RandomizedItem;                                                                 //What dungeon does this areas dungeon entrance lead to
            var RandAreaClear      = RandTempleEntrance < 0 ? -1 : Instance.EntranceAreaDic.FirstOrDefault(x => x.Value == RandTempleEntrance).Key; //What is the Area clear Value For That Dungeon
            var RandClearLogic     = RandAreaClear == -1 ? null : Instance.Logic[RandAreaClear];                                                    //Get the full logic data for the area clear that we want to check the availability of.

            return(RandClearLogic);
        }
예제 #9
0
 public static bool Unrandomized(this LogicObjects.LogicEntry entry, int UnRand0Manual1Either2 = 0)
 {
     if (UnRand0Manual1Either2 == 0)
     {
         return(entry.RandomizedState() == 1);
     }
     if (UnRand0Manual1Either2 == 1)
     {
         return(entry.RandomizedState() == 2);
     }
     if (UnRand0Manual1Either2 == 2)
     {
         return(entry.RandomizedState() == 1 || entry.RandomizedState() == 2);
     }
     return(false);
 }
예제 #10
0
 public static LogicObjects.LogicEntry GetItemsNewLocation(this LogicObjects.LogicEntry entry, List <LogicObjects.LogicEntry> Logic)
 {
     return(Logic.Find(x => x.RandomizedItem == entry.ID));
 }
예제 #11
0
 public static bool Useable(this LogicObjects.LogicEntry entry)
 {
     return(entry.Aquired || entry.StartingItem() || (entry.Unrandomized() && entry.Available));
 }
예제 #12
0
 public static bool AppearsInListbox(this LogicObjects.LogicEntry entry)
 {
     return((entry.Randomized() || entry.Unrandomized(1)) && !entry.IsFake);
 }
예제 #13
0
 public static bool IsWarpSong(this LogicObjects.LogicEntry entry)
 {
     return(entry.LocationArea == "Owl Warp");
 }
예제 #14
0
 public static bool StartingItem(this LogicObjects.LogicEntry entry)
 {
     return(entry.Options > 3);
 }
예제 #15
0
        public static bool PopulatePost115TrackerInstance(LogicObjects.TrackerInstance instance)
        {
            LogicObjects.LogicFile NewformatLogicFile = LogicObjects.LogicFile.FromJson(string.Join("", instance.RawLogicFile));
            instance.Logic.Clear();
            instance.DicNameToID.Clear();
            instance.EntrancePairs.Clear();
            instance.LogicVersion = NewformatLogicFile.Version;
            instance.GameCode     = "MMR";

            if (instance.LogicDictionary == null || instance.LogicDictionary.Count < 1)
            {
                string DictionaryPath = VersionHandeling.GetDictionaryPath(instance, true);
                if (!string.IsNullOrWhiteSpace(DictionaryPath))
                {
                    try
                    {
                        instance.LogicDictionary = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(Utility.ConvertCsvFileToJsonObject(File.ReadAllLines(DictionaryPath)));
                    }
                    catch { MessageBox.Show($"The Dictionary File \"{DictionaryPath}\" has been corrupted. The tracker will not function correctly."); }
                }
                else
                {
                    MessageBox.Show($"A valid dictionary file could not be found for this logic. The tracker will not function correctly.");
                }
            }

            Dictionary <string, int> LogicNametoId = new Dictionary <string, int>();
            int DicCounter = 0;

            foreach (var i in NewformatLogicFile.Logic)
            {
                LogicNametoId.Add(i.Id, DicCounter);
                DicCounter++;
            }

            LogicObjects.LogicEntry LogicEntry1 = new LogicObjects.LogicEntry();
            foreach (var i in NewformatLogicFile.Logic)
            {
                LogicEntry1.ID             = NewformatLogicFile.Logic.IndexOf(i);
                LogicEntry1.DictionaryName = i.Id;
                LogicEntry1.Checked        = false;
                LogicEntry1.RandomizedItem = -2;
                LogicEntry1.IsFake         = true;
                LogicEntry1.SpoilerRandom  = -2;
                LogicEntry1.Required       = i.RequiredItems.Select(x => LogicNametoId[x]).ToArray();
                LogicEntry1.Conditionals   = i.ConditionalItems.Select(x => x.Select(y => LogicNametoId[y]).ToArray()).ToArray();
                LogicEntry1.NeededBy       = (int)i.TimeNeeded;
                LogicEntry1.AvailableOn    = (int)i.TimeAvailable;
                LogicEntry1.IsTrick        = i.IsTrick;
                LogicEntry1.TrickEnabled   = i.IsTrick;
                LogicEntry1.TrickToolTip   = i.TrickTooltip;

                var DicEntry = instance.LogicDictionary.Find(x => x.DictionaryName == LogicEntry1.DictionaryName);
                if (DicEntry != null)
                {
                    LogicEntry1.IsFake          = false;
                    LogicEntry1.ItemName        = (string.IsNullOrWhiteSpace(DicEntry.ItemName)) ? null : DicEntry.ItemName;
                    LogicEntry1.LocationName    = (string.IsNullOrWhiteSpace(DicEntry.LocationName)) ? null : DicEntry.LocationName;
                    LogicEntry1.LocationArea    = (string.IsNullOrWhiteSpace(DicEntry.LocationArea)) ? "Misc" : DicEntry.LocationArea;
                    LogicEntry1.ItemSubType     = (string.IsNullOrWhiteSpace(DicEntry.ItemSubType)) ? "Item" : DicEntry.ItemSubType;
                    LogicEntry1.SpoilerLocation = (string.IsNullOrWhiteSpace(DicEntry.SpoilerLocation))
                        ? new List <string> {
                        LogicEntry1.LocationName
                    } : DicEntry.SpoilerLocation.Split('|').ToList();
                    LogicEntry1.SpoilerItem = (string.IsNullOrWhiteSpace(DicEntry.SpoilerItem))
                        ? new List <string> {
                        LogicEntry1.ItemName
                    } : DicEntry.SpoilerItem.Split('|').ToList();
                }

                //Push Data to the instance
                instance.Logic.Add(LogicEntry1);
                LogicEntry1 = new LogicObjects.LogicEntry();
            }

            instance.EntranceRando   = instance.IsEntranceRando();
            instance.EntranceAreaDic = CreateAreaClearDictionary(instance);
            CreateDicNameToID(instance);
            if (instance.EntranceRando)
            {
                CreatedEntrancepairDcitionary(instance);
            }
            MarkUniqeItemsUnrandomizedManual(instance);

            return(true);
        }
예제 #16
0
 public static bool FilterSearch(LogicObjects.LogicEntry logic, string searchTerm, string NameToCompare, LogicObjects.LogicEntry RandomizedItem = null)
 {
     if (NameToCompare == null)
     {
         NameToCompare = logic.DictionaryName;
     }
     if (searchTerm == "")
     {
         return(true);
     }
     if (searchTerm[0] == '^')
     {
         searchTerm = searchTerm.Substring(1);
         if (searchTerm == "")
         {
             return(true);
         }
     }
     string[] searchTerms = searchTerm.Split('|');
     foreach (string term in searchTerms)
     {
         string[] subTerms = term.Split('&');
         bool     valid    = true;
         foreach (string i in subTerms)
         {
             bool Inverse = false;
             bool Perfect = false;
             var  subterm = i;
             if (subterm == "")
             {
                 continue;
             }
             if (subterm[0] == '!')
             {
                 Inverse = true;
                 subterm = subterm.Substring(1);
             }
             else if (subterm[0] == '=')
             {
                 Perfect = true;
                 subterm = subterm.Substring(1);
             }
             if (subterm == "")
             {
                 continue;
             }
             if (subterm[0] == '#')
             {
                 if (subterm.Substring(1) == "")
                 {
                     continue;
                 }
                 if (logic.LocationArea.ToLower().Contains(subterm.Substring(1).ToLower()) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && logic.LocationArea.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
             }
             else if (subterm[0] == '@')
             {
                 if (subterm.Substring(1) == "")
                 {
                     continue;
                 }
                 if ((logic.ItemSubType.ToLower().Contains(subterm.Substring(1).ToLower())) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && logic.ItemSubType.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
             }
             else if (subterm[0] == '~')
             {
                 if (subterm.Substring(1) == "")
                 {
                     continue;
                 }
                 if ((logic.DictionaryName.ToLower().Contains(subterm.Substring(1).ToLower())) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && logic.DictionaryName.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
             }
             else if (subterm[0] == '$')
             {
                 if (subterm.Substring(1) == "" || logic.ItemName == null)
                 {
                     continue;
                 }
                 if (logic.ItemName.ToLower().Contains(subterm.Substring(1).ToLower()) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && logic.ItemName.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
             }
             else if (subterm[0] == '%')
             {
                 if (subterm.Substring(1) == "" || logic.LocationName == null)
                 {
                     continue;
                 }
                 if (logic.LocationName.ToLower().Contains(subterm.Substring(1).ToLower()) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && logic.LocationName.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
             }
             else if (subterm[0] == '_')
             {
                 if (subterm.Substring(1) == "")
                 {
                     continue;
                 }
                 if (RandomizedItem == null)
                 {
                     valid = false;
                 }
                 else if (RandomizedItem.ItemName.ToLower().Contains(subterm.Substring(1).ToLower()) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && logic.ItemName.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
             }
             else if (subterm[0] == '*')
             {
                 if (subterm.Substring(1) == "")
                 {
                     continue;
                 }
                 if (NameToCompare.ToLower().Contains(subterm.Substring(1).ToLower()) == Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && NameToCompare.ToLower() != subterm.Substring(1).ToLower())
                 {
                     valid = false;
                 }
                 if (!logic.Starred)
                 {
                     valid = false;
                 }
             }
             else
             {
                 if (!NameToCompare.ToLower().Contains(subterm.ToLower()) == !Inverse)
                 {
                     valid = false;
                 }
                 if (Perfect && NameToCompare.ToLower() != subterm.ToLower())
                 {
                     valid = false;
                 }
             }
         }
         if (valid)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #17
0
 public static bool HasRandomItem(this LogicObjects.LogicEntry entry, bool RealItem)
 {
     return((RealItem) ? entry.RandomizedItem > -1 : entry.RandomizedItem > -2);
 }
예제 #18
0
 public static bool IsEntrance(this LogicObjects.LogicEntry entry)
 {
     return(entry.ItemSubType == "Entrance");
 }
예제 #19
0
        public static bool PopulatePre115TrackerInstance(LogicObjects.TrackerInstance instance)
        {
            /* Sets the Values of the follwing using the data in instance.RawLogicFile
             * Version
             * Game
             * Entrance Area Dictionary
             * Logic
             * LogicDictionary
             * Name to ID Dictionary
             * Entrance pair Dictionary
             */
            instance.Logic.Clear();
            instance.DicNameToID.Clear();
            instance.EntrancePairs.Clear();
            LogicObjects.VersionInfo versionData = VersionHandeling.GetVersionDataFromLogicFile(instance.RawLogicFile);
            instance.LogicVersion = versionData.Version;
            instance.GameCode     = versionData.Gamecode;
            int SubCounter = 0;
            int idCounter  = 0;

            if (instance.LogicDictionary == null || instance.LogicDictionary.Count < 1)
            {
                string DictionaryPath = VersionHandeling.GetDictionaryPath(instance);
                if (!string.IsNullOrWhiteSpace(DictionaryPath))
                {
                    try
                    {
                        instance.LogicDictionary = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(Utility.ConvertCsvFileToJsonObject(File.ReadAllLines(DictionaryPath)));
                    }
                    catch { MessageBox.Show($"The Dictionary File \"{DictionaryPath}\" has been corrupted. The tracker will not function correctly."); }
                }
                else
                {
                    MessageBox.Show($"A valid dictionary file could not be found for this logic. The tracker will not function correctly.");
                }
            }

            LogicObjects.LogicEntry LogicEntry1 = new LogicObjects.LogicEntry();
            var NextLine = 1;

            foreach (string line in instance.RawLogicFile)
            {
                if (NextLine == 1)
                {
                    NextLine++; continue;
                }
                if (line.StartsWith("-"))
                {
                    SubCounter = 0;
                }
                switch (SubCounter)
                {
                case 0:
                    LogicEntry1.ID             = idCounter;
                    LogicEntry1.DictionaryName = line.Substring(2);
                    LogicEntry1.Checked        = false;
                    LogicEntry1.RandomizedItem = -2;
                    LogicEntry1.IsFake         = true;
                    LogicEntry1.SpoilerRandom  = -2;

                    var DicEntry = instance.LogicDictionary.Find(x => x.DictionaryName == LogicEntry1.DictionaryName);
                    if (DicEntry == null)
                    {
                        break;
                    }

                    LogicEntry1.IsFake          = false;
                    LogicEntry1.IsTrick         = false;
                    LogicEntry1.TrickEnabled    = true;
                    LogicEntry1.TrickToolTip    = "";
                    LogicEntry1.ItemName        = (string.IsNullOrWhiteSpace(DicEntry.ItemName)) ? null : DicEntry.ItemName;
                    LogicEntry1.LocationName    = (string.IsNullOrWhiteSpace(DicEntry.LocationName)) ? null : DicEntry.LocationName;
                    LogicEntry1.LocationArea    = (string.IsNullOrWhiteSpace(DicEntry.LocationArea)) ? "Misc" : DicEntry.LocationArea;
                    LogicEntry1.ItemSubType     = (string.IsNullOrWhiteSpace(DicEntry.ItemSubType)) ? "Item" : DicEntry.ItemSubType;
                    LogicEntry1.SpoilerLocation = (string.IsNullOrWhiteSpace(DicEntry.SpoilerLocation))
                            ? new List <string> {
                        LogicEntry1.LocationName
                    } : DicEntry.SpoilerLocation.Split('|').ToList();
                    LogicEntry1.SpoilerItem = (string.IsNullOrWhiteSpace(DicEntry.SpoilerItem))
                            ? new List <string> {
                        LogicEntry1.ItemName
                    } : DicEntry.SpoilerItem.Split('|').ToList();
                    break;

                case 1:
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        LogicEntry1.Required = null; break;
                    }
                    LogicEntry1.Required = line.Split(',').Select(y => int.Parse(y)).ToArray();
                    break;

                case 2:
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        LogicEntry1.Conditionals = null; break;
                    }
                    LogicEntry1.Conditionals = line.Split(';').Select(x => x.Split(',').Select(y => int.Parse(y)).ToArray()).ToArray();
                    break;

                case 3:
                    LogicEntry1.NeededBy = Convert.ToInt32(line);
                    break;

                case 4:
                    LogicEntry1.AvailableOn = Convert.ToInt32(line);
                    break;

                case 5:
                    LogicEntry1.IsTrick      = (line.StartsWith(";"));
                    LogicEntry1.TrickEnabled = true;
                    LogicEntry1.TrickToolTip = (line.Length > 1) ? line.Substring(1) : "No Tooltip Available";
                    //if (LogicEntry1.IsTrick) { Debugging.Log($"Trick {LogicEntry1.DictionaryName} Found. ToolTip =  { LogicEntry1.TrickToolTip }"); }
                    break;
                }
                if ((NextLine) >= instance.RawLogicFile.Count() || instance.RawLogicFile[NextLine].StartsWith("-"))
                {
                    //Push Data to the instance
                    instance.Logic.Add(LogicEntry1);
                    LogicEntry1 = new LogicObjects.LogicEntry();
                    idCounter++;
                }
                NextLine++;
                SubCounter++;
            }

            instance.EntranceRando   = instance.IsEntranceRando();
            instance.EntranceAreaDic = CreateAreaClearDictionary(instance);
            CreateDicNameToID(instance);
            if (instance.EntranceRando)
            {
                CreatedEntrancepairDcitionary(instance);
            }
            MarkUniqeItemsUnrandomizedManual(instance);

            return(true);
        }
예제 #20
0
 public static bool Randomized(this LogicObjects.LogicEntry entry)
 {
     return(entry.RandomizedState() == 0);
 }
예제 #21
0
        public static int RandomizedState(this LogicObjects.LogicEntry entry)
        {
            int option = entry.Options;

            return((entry.Options > 3) ? option - 4 : option);
        }
예제 #22
0
        public static bool PopulateTrackerInstance(LogicObjects.TrackerInstance instance)
        {
            /* Sets the Values of the follwing using the data in instance.RawLogicFile
             * Version
             * Game
             * Entrance Area Dictionary
             * Logic
             * LogicDictionary
             * Name to ID Dictionary
             * Entrance pair Dictionary
             */
            instance.Logic.Clear();
            instance.DicNameToID.Clear();
            instance.EntrancePairs.Clear();
            LogicObjects.VersionInfo version = VersionHandeling.GetVersionFromLogicFile(instance.RawLogicFile); //Returns [0] The logic Version, [1] The game this logic file is for
            instance.LogicVersion = version.Version;
            instance.GameCode     = version.Gamecode;
            string[] VersionData = VersionHandeling.GetDictionaryPath(instance); //Returns [0] Path To Dictionary, [1] path to Entrance Pairs
            int      SubCounter  = 0;
            int      idCounter   = 0;

            LogicObjects.LogicEntry LogicEntry1 = new LogicObjects.LogicEntry();
            if (VersionData.Count() > 0 && VersionData[0] != "")
            {
                instance.LogicDictionary = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(Utility.ConvertCsvFileToJsonObject(VersionData[0]));
            }
            var NextLine = 1;

            foreach (string line in instance.RawLogicFile)
            {
                if (NextLine == 1)
                {
                    NextLine++; continue;
                }
                if (line.StartsWith("-"))
                {
                    SubCounter = 0;
                }
                switch (SubCounter)
                {
                case 0:
                    LogicEntry1.ID             = idCounter;
                    LogicEntry1.DictionaryName = line.Substring(2);
                    LogicEntry1.Checked        = false;
                    LogicEntry1.RandomizedItem = -2;
                    LogicEntry1.IsFake         = true;
                    LogicEntry1.SpoilerRandom  = -2;

                    var DicEntry = instance.LogicDictionary.Find(x => x.DictionaryName == LogicEntry1.DictionaryName);
                    if (DicEntry == null)
                    {
                        break;
                    }

                    LogicEntry1.IsFake          = false;
                    LogicEntry1.IsTrick         = false;
                    LogicEntry1.TrickEnabled    = true;
                    LogicEntry1.TrickToolTip    = "";
                    LogicEntry1.ItemName        = (DicEntry.ItemName == "") ? null : DicEntry.ItemName;
                    LogicEntry1.LocationName    = (DicEntry.LocationName == "") ? null : DicEntry.LocationName;
                    LogicEntry1.LocationArea    = (DicEntry.LocationArea == "") ? "Misc" : DicEntry.LocationArea;
                    LogicEntry1.ItemSubType     = (DicEntry.ItemSubType == "") ? "Item" : DicEntry.ItemSubType;
                    LogicEntry1.SpoilerLocation = (DicEntry.SpoilerLocation == "") ? LogicEntry1.LocationName : DicEntry.SpoilerLocation;
                    LogicEntry1.SpoilerItem     = (DicEntry.SpoilerItem == "") ? LogicEntry1.ItemName : DicEntry.SpoilerItem;
                    break;

                case 1:
                    if (line == null || line == "")
                    {
                        LogicEntry1.Required = null; break;
                    }
                    string[] req = line.Split(',');
                    LogicEntry1.Required = Array.ConvertAll(req, s => int.Parse(s));
                    break;

                case 2:
                    if (line == null || line == "")
                    {
                        LogicEntry1.Conditionals = null; break;
                    }
                    string[] ConditionalSets = line.Split(';');
                    int[][]  Conditionals    = new int[ConditionalSets.Length][];
                    for (int j = 0; j < ConditionalSets.Length; j++)
                    {
                        string[] condtional = ConditionalSets[j].Split(',');
                        Conditionals[j] = Array.ConvertAll(condtional, s => int.Parse(s));
                    }
                    LogicEntry1.Conditionals = Conditionals;
                    break;

                case 3:
                    LogicEntry1.NeededBy = Convert.ToInt32(line);
                    break;

                case 4:
                    LogicEntry1.AvailableOn = Convert.ToInt32(line);
                    break;

                case 5:
                    LogicEntry1.IsTrick      = (line.StartsWith(";"));
                    LogicEntry1.TrickEnabled = true;
                    LogicEntry1.TrickToolTip = (line.Length > 1) ? line.Substring(1) : "No Tooltip Available";
                    if (LogicEntry1.IsTrick)
                    {
                        Console.WriteLine($"Trick {LogicEntry1.DictionaryName} Found. ToolTip =  { LogicEntry1.TrickToolTip }");
                    }
                    break;
                }
                if ((NextLine) >= instance.RawLogicFile.Count() || instance.RawLogicFile[NextLine].StartsWith("-"))
                {
                    //Push Data to the instance
                    instance.Logic.Add(LogicEntry1);
                    LogicEntry1 = new LogicObjects.LogicEntry();
                    idCounter++;
                }
                NextLine++;
                SubCounter++;
            }

            instance.EntranceRando   = instance.IsEntranceRando();
            instance.EntranceAreaDic = VersionHandeling.AreaClearDictionary(instance);
            CreateDicNameToID(instance.DicNameToID, instance.Logic);
            if (VersionData.Count() > 1 && VersionData[1] != "")
            {
                CreatedEntrancepairDcitionary(instance.EntrancePairs, instance.DicNameToID, VersionData);
            }

            return(true);
        }