示例#1
0
        public static LogicObjects.VersionInfo GetVersionDataFromLogicFile(string[] LogicFile)
        {
            LogicObjects.VersionInfo versionData = new LogicObjects.VersionInfo {
                Version = 0, Gamecode = "MMR"
            };
            LogicObjects.LogicFile NewformatLogicFile = null;
            try { NewformatLogicFile = LogicObjects.LogicFile.FromJson(string.Join("", LogicFile)); }
            catch { }

            if (NewformatLogicFile != null)
            {
                versionData.Version = NewformatLogicFile.Version;
                return(versionData);
            }

            if (LogicFile[0].Contains("-version"))       //Ensure the first line of this file has version data
            {
                if (!LogicFile[0].Contains("-version ")) //Check if the version line has game code data after "-version"
                {
                    var i = LogicFile[0].Split(' ');
                    versionData.Gamecode = i[0].Replace("-version", "");
                }
                var j = LogicFile[0].Split(' ');
                if (j.Count() > 1 && int.TryParse(j[1], out int Ver))
                {
                    versionData.Version = Ver;
                }
            }
            return(versionData);
        }
示例#2
0
 public static LogicObjects.VersionInfo GetVersionFromLogicFile(string[] LogicFile)
 {
     LogicObjects.VersionInfo version = new LogicObjects.VersionInfo {
         Version = 0, Gamecode = "MMR"
     };
     if (LogicFile[0].Contains("-version"))
     {
         if (!LogicFile[0].Contains("-version "))
         {
             var i = LogicFile[0].Split(' ');
             version.Gamecode = i[0].Replace("-version", "");
         }
         var j = LogicFile[0].Split(' ');
         if (j.Count() > 1)
         {
             version.Version = Convert.ToInt32(j[1]);
         }
     }
     return(version);
 }
示例#3
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);
        }
示例#4
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);
        }