Esempio n. 1
0
 public _GAME_MASTER(string _name, bool _have_original)
 {
     name          = _name;
     timestamp_hex = GameMasterTimestampUtils.FileNameToHexTimeStamp(name);
     timestamp_dec = GameMasterTimestampUtils.HexTimeStampToTicks(timestamp_hex);
     timestamp     = GameMasterTimestampUtils.TicksToDateTime(timestamp_dec).ToString(PokeConstants.DateTimeFormat);
     have_original = _have_original;
 }
Esempio n. 2
0
        public GameMasterStatsCalculator(string currentGameMasterFileName)
        {
            GameMasterStats = new Settings._GameMasterStats(GameMasterTimestampUtils.FileNameToDateTime(currentGameMasterFileName), PokeConstants.Regions.Length - 1);

            for (int i = 0; i < PokeConstants.Regions.Length; i++)
            {
                _moveSetsStats[i] = new _MoveSetStats();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Writes the the GameMaster object into a .json file.
        /// </summary>
        /// <param name="filePathJson"></param>
        internal static void WriteGameMasterJson(GameMaster gameMaster, string filePathJson)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented,
            };

            using (StreamWriter writer = new StreamWriter(filePathJson))
                writer.Write(JsonConvert.SerializeObject(gameMaster, settings));

            GameMasterTimestampUtils.FixGameMasterFileTime(filePathJson);
        }
Esempio n. 4
0
        private void maskedDateTimePicker_ValueChanged(object sender, EventArgs e)
        {
            if (Working)
            {
                return;
            }

            try
            {
                Working         = true;
                numberBox.Value = GameMasterTimestampUtils.DateTimeToTicks(maskedDateTimePicker.Value);
            }
            finally
            {
                Working = false;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Static method to load a GAME_MASTER file.
        /// </summary>
        /// <param name="filePathGameMaster">Path to the GAME_MASTER file.</param>
        /// <returns></returns>
        /// <remarks>
        /// If a .json exists, it will be loaded.
        /// If not, the GAME_MASTER file will be loaded and the .json will be created.
        /// </remarks>
        public static GameMaster GetGameMaster(string filePathGameMaster)
        {
            string filePathJson = filePathGameMaster + ".json";

            if (File.Exists(filePathJson))
            {
                return(ReadGameMasterJson(filePathJson));
            }
            else
            {
                GameMaster gameMaster = ReadGameMaster(filePathGameMaster);
                if (gameMaster != null)
                {
                    GameMasterTimestampUtils.FixGameMasterFileTime(filePathGameMaster);
                    WriteGameMasterJson(gameMaster, filePathJson);
                }

                return(gameMaster);
            }
        }
Esempio n. 6
0
        private void numberBox_ValueChanged(object sender, EventArgs e)
        {
            if (Working)
            {
                return;
            }

            try
            {
                Working = true;

                maskedDateTimePicker.Value = checkBoxGameMaster.Checked ?
                                             GameMasterTimestampUtils.TicksToDateTime(numberBox.Value) :
                                             TimestampUtils.TicksToDateTime(numberBox.Value);
            }
            finally
            {
                Working = false;
            }
        }
Esempio n. 7
0
        private void numberBoxTimeStamp_ValueChanged(object sender, EventArgs e)
        {
            // Make sure we aren't in the middle of doing work.
            if (Working)
            {
                return;
            }

            try
            {
                Working = true;

                // Convert TimeStamp to DateTime for each.
                maskedDateTimePickerNormal.Value     = TimestampUtils.TicksToDateTime(numberBoxTimeStamp.Value);
                maskedDateTimePickerGameMaster.Value = GameMasterTimestampUtils.TicksToDateTime(numberBoxTimeStamp.Value);
            }
            finally
            {
                Working = false;
            }
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="folder"></param>
        /// <returns></returns>
        private IEnumerable <string> GetFileList(string folder)
        {
            // Get the desirable filePaths.
            List <string> filePaths = new List <string>();

            foreach (var filePath in Directory.EnumerateFiles(folder, GAME_MASTER_SEARCH_PATTERN))
            {
                string fileName = Path.GetFileNameWithoutExtension(filePath);

                // Add it if the name contains a valid timestamp.
                if (Int64.TryParse(fileName.Substring(0, 16), System.Globalization.NumberStyles.HexNumber, null, out long dummy))
                {
                    string filePathGameMaster = Path.Combine(folder, fileName);
                    if (!filePaths.Contains(filePathGameMaster))
                    {
                        filePaths.Add(filePathGameMaster);
                    }
                }
            }

            // Sort by the HEX value on the front of the file name, adjusted for Mangling.
            return(filePaths.OrderBy(filePath => 0 - GameMasterTimestampUtils.FileNameToDateTime(filePath).Ticks));
        }
Esempio n. 9
0
 private void maskedDateTimePickerGameMaster_ValueChanged(object sender, EventArgs e)
 {
     numberBoxTimeStamp.Value = GameMasterTimestampUtils.DateTimeToTicks(maskedDateTimePickerNormal.Value);
 }
Esempio n. 10
0
 public static void Init(string rootFolder)
 {
     RootFolder = rootFolder;
     GameMasterTimestampUtils.Init(GAME_MASTER_Folder);
 }
Esempio n. 11
0
        /// <summary>
        /// Determines whether the specified itemTemplate, from the GAME_MASTER with the specified timestamp,
        /// contains movesets that should included in the legacy lists.
        /// </summary>
        /// <param name="itemTemplate"></param>
        /// <param name="timestamp"></param>
        /// <returns></returns>
        private static bool IsValidItemTemplate(ItemTemplate itemTemplate, ulong timestamp)
        {
            // If there is no pokemonSettings, the it doesn't contain MoveSets.
            if (itemTemplate.pokemon_settings == null)
            {
                return(false);
            }

            // If baseCaptureRate isn't positive, then it cannot be caught. (Not released)
            if (itemTemplate.pokemon_settings.encounter.base_capture_rate <= 0)
            {
                return(false);
            }

            // If is a GAME_MASTER before the one used during the Pokemon's release, just ignore it.
            if (GetReleaseDate(int.Parse(itemTemplate.template_id.Substring(1, 4))) > GameMasterTimestampUtils.TicksToDateTime(timestamp))
            {
                return(false);
            }

            // If we made it here, then it should be used.
            return(true);
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Count() < 1 || args[0].Contains("?"))
                {
                    WriteHelp();
                    return;
                }

                int decoded = 0;
                for (int arg = 0; arg < args.Length; arg++)
                {
                    bool createOnly = string.Equals(args[arg], "-c") || string.Equals(args[arg], "-create");
                    if (createOnly)
                    {
                        arg++;
                        if (arg >= args.Length)
                        {
                            break;
                        }
                    }

                    string folder;
                    string filePattern;
                    int    pos = args[arg].LastIndexOf('\\');
                    if (pos == -1)
                    {
                        folder      = ".";
                        filePattern = args[arg];
                    }
                    else
                    {
                        folder      = args[arg].Substring(0, pos);
                        filePattern = args[arg].Substring(pos + 1);
                    }

                    if (!Directory.Exists(folder))
                    {
                        ConsoleOutput.OutputError("ERROR: Folder does not exist: \"{0}\"", folder);
                        continue;
                    }

                    GameMasterTimestampUtils.Init(folder);

                    foreach (var filePath in Directory.EnumerateFiles(folder, filePattern))
#if true
                    { if (Path.GetExtension(filePath).Length == 0 && (!createOnly || !File.Exists(filePath + ".json")))
                      {
                          Console.Out.WriteLine("Decoding \"" + filePath + "\"");
                          GameMasterDecoder.WriteGameMasterJson(filePath);
                          decoded++;
                      }
                    }
#else
                    {   // This code is to reset the timestamps of the files
                        try
                        {
                            GameMasterTimestampUtils.FixGameMasterFileTime(filePath);
                        }
                        catch (Exception) { }
                    }
#endif
                }

                ConsoleOutput.OutputSuccess($"Finished. {decoded} files decoded.");
            }
            catch (Exception ex)
            {
                ConsoleOutput.OutputException(ex, "********** ERROR!!! **********");
            }
        }