/// <summary> /// Write the rarely-changed files that are referenced globally. /// </summary> public static void Write(ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator) { DateTime updateDateTime = new DateTime(Math.Max( gameMasterStatsCalculator.GameMasterStats.last_updated.Date.Ticks, manualDataSettings.Ranges.last_updated.Ticks)); DateTime lastUpdated = Utils.GetLastUpdated(XmlFilePath); if (!File.Exists(XmlFilePath) || lastUpdated < updateDateTime) { Settings settings = new Settings() { last_updated = updateDateTime, GameMasterStats = gameMasterStatsCalculator.GameMasterStats, Desirable = new Settings._Desirable(manualDataSettings.Ranges.Desirability), MaxCP = new Settings.Range(manualDataSettings.Ranges.MaxCP), MaxHP = new Settings.Range(manualDataSettings.Ranges.MaxHP), DPSPercent = new Settings.Range(manualDataSettings.Ranges.DPSPercent), DPS = new Settings.Range(manualDataSettings.Ranges.DPS), Capture = new Settings.Difficulty(manualDataSettings.Ranges.CaptureRate), Flee = new Settings.Rate(manualDataSettings.Ranges.FleeRate), Attack = new Settings.Rate(manualDataSettings.Ranges.AttackRate), Dodge = new Settings.Rate(manualDataSettings.Ranges.DodgeRate), }; Utils.WriteXML(settings, XmlFilePath); } }
/// <summary> /// ctor /// </summary> /// <param name="gameMaster"></param> /// <param name="legacyGameMasters"></param> /// <param name="rootFolder"></param> public GameMasterDataWriter(GameMasterTemplate gameMasterTemplate, IEnumerable <GameMasterTemplate> legacyGameMasterTemplates) { // Read the config. ManualDataSettings = new ManualDataSettings(Utils.InputManualDataFileFolder); GameMasterStatsCalculator = new GameMasterStatsCalculator(gameMasterTemplate.FileName); CollectData(gameMasterTemplate, legacyGameMasterTemplates); PokeFormulas.Init(PlayerLevel); ManualDataSettings.RaidBosses.Init(Pokemon); ManualDataSettings.Encounters.Init(Pokemon); ManualDataSettings.SpecialResearch.Init(Pokemon); ManualDataSettings.EventResearch.Init(Pokemon); }
/// <summary> /// Write out data for Encounters /// </summary> public static void Write(ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator) { DateTime updateDateTime = new DateTime(Math.Max( gameMasterStatsCalculator.GameMasterStats.last_updated.Date.Ticks, manualDataSettings.Encounters.last_updated.Ticks)); if (!Directory.Exists(OutputXmlFolder)) { Directory.CreateDirectory(OutputXmlFolder); } // Write all encounter files. Keeping track if all are up-to-date. bool upToDate = true; List <int> written = new List <int>(); foreach (var category in manualDataSettings.Encounters.Category) { upToDate = Write(category.Research, updateDateTime, written) && upToDate; } foreach (var specialResearch in manualDataSettings.SpecialResearch.Event) { foreach (var stage in specialResearch.Stage) { upToDate = Write(stage.Research, updateDateTime, written) && upToDate; if (stage.Rewards.Pokemon != null) { foreach (var pokemon in stage.Rewards.Pokemon) { upToDate = Write(pokemon, updateDateTime, written) && upToDate; } } } } foreach (var eventResearch in manualDataSettings.EventResearch.Event) { upToDate = Write(eventResearch.Research, updateDateTime, written) && upToDate; } if (!upToDate) { using (TextWriter projWriter = new StreamWriter(ProjFilePath)) { projWriter.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); projWriter.WriteLine(" <!-- ======================================================================= -->"); projWriter.WriteLine(" <!-- ============= This file is generated by GM_DataGenerator. ============= -->"); projWriter.WriteLine(" <!-- ===================== (last_updated=\"" + updateDateTime.ToString(PokeConstants.DateFormat) + "\") ===================== --> "); projWriter.WriteLine(" <!-- ======================================================================= -->"); projWriter.WriteLine(" <ItemGroup>"); foreach (var category in manualDataSettings.Encounters.Category) { Write(projWriter, category.Research, written); } foreach (var specialResearch in manualDataSettings.SpecialResearch.Event) { foreach (var stage in specialResearch.Stage) { Write(projWriter, stage.Research, written); if (stage.Rewards.Pokemon != null) { foreach (var pokemon in stage.Rewards.Pokemon) { Write(projWriter, pokemon, written); } } } } foreach (var eventResearch in manualDataSettings.EventResearch.Event) { Write(projWriter, eventResearch.Research, written); } projWriter.WriteLine(" </ItemGroup>"); projWriter.WriteLine("</Project>"); } } }
/// <summary> /// Write out the Raid Boss data. /// </summary> public static void Write(ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator) { DateTime updateDateTime = gameMasterStatsCalculator.GameMasterStats.last_updated.Date; if (!Directory.Exists(OutputXmlFolder)) { Directory.CreateDirectory(OutputXmlFolder); } // Write all raidboss files. Keeping track if all are up-to-date. bool upToDate = true; foreach (var raidboss in manualDataSettings.RaidBosses.RaidBoss) { if (raidboss.id > 0) { upToDate = WriteRaidBoss(raidboss, updateDateTime) && upToDate; } } DateTime projLastUpdated = Utils.GetLastUpdated(ProjFilePath); if (!upToDate || projLastUpdated < updateDateTime) { using (TextWriter projWriter = new StreamWriter(ProjFilePath)) { projWriter.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); projWriter.WriteLine(" <!-- ======================================================================= -->"); projWriter.WriteLine(" <!-- ============= This file is generated by GM_DataGenerator. ============= -->"); projWriter.WriteLine(" <!-- ===================== (last_updated=\"" + updateDateTime.ToString(PokeConstants.DateFormat) + "\") ===================== --> "); projWriter.WriteLine(" <!-- ======================================================================= -->"); projWriter.WriteLine(" <ItemGroup>"); foreach (var raidboss in manualDataSettings.RaidBosses.RaidBoss) { string raidbossFileName = GetFileNameBase(raidboss); projWriter.WriteLine(" <!-- #region " + raidboss.name + " -->"); // Add .xml as part of _datafiles projWriter.WriteLine(" <FixIntermediateFile Include=\"" + ProjXmlFolder + raidbossFileName + ".xml\">"); projWriter.WriteLine(@" <Visible>true</Visible>"); projWriter.WriteLine(@" </FixIntermediateFile>"); // Add .html.xml as DependentUpon .xsl projWriter.WriteLine(" <XslTransform Include=\"" + srcFolder + raidbossFileName + ".html.xml\">"); projWriter.WriteLine(@" <Visible>true</Visible>"); projWriter.WriteLine(@" <DependentUpon>raidboss.xsl</DependentUpon>"); projWriter.WriteLine(@" <Dependencies>"); projWriter.WriteLine(@" charts\raidboss\raidboss.js;"); projWriter.WriteLine(@" js\global.js;"); projWriter.WriteLine(@" " + ProjXmlFolder + raidbossFileName + ".xml;"); projWriter.WriteLine(@" charts\raidboss\index.css;"); projWriter.WriteLine(@" charts\index.css;"); projWriter.WriteLine(@" index.css;"); projWriter.WriteLine(@" </Dependencies>"); projWriter.WriteLine(@" <OutputFileName>" + raidbossFileName + ".html</OutputFileName>"); projWriter.WriteLine(@" </XslTransform>"); projWriter.WriteLine(" <!-- #endregion " + raidboss.name + " -->"); } projWriter.WriteLine(" </ItemGroup>"); projWriter.WriteLine("</Project>"); } } }
/// <summary> /// Write out the Move Sets for each generation of Pokemon. /// </summary> public static void Write(IEnumerable <PokemonTranslator> pokemonTranslators, Dictionary <PokemonId, FormSettingsTranslator> forms, Dictionary <PokemonMove, MoveTranslator> moves, ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator) { DateTime updateDateTime = new DateTime(Math.Max( gameMasterStatsCalculator.GameMasterStats.last_updated.Date.Ticks, manualDataSettings.SpecialMoves.last_updated.Date.Ticks)); bool update = false; for (int gen = 1; gen < PokeConstants.Regions.Length; gen++) { string filePath = Path.Combine(Utils.OutputDataFileFolder, "movesets.gen" + gen + ".xml"); DateTime lastUpdated = Utils.GetLastUpdated(filePath); if (!File.Exists(filePath) || lastUpdated < updateDateTime) { update = true; break; } } if (update) { List <MoveSets._Pokemon>[] pokemonMoveSetList = new List <MoveSets._Pokemon> [PokeConstants.Regions.Length + 1]; for (int gen = 1; gen < PokeConstants.Regions.Length; gen++) { pokemonMoveSetList[gen] = new List <MoveSets._Pokemon>(); } foreach (var pokemonTranslator in pokemonTranslators) { // Need to deal with the following cases: // - Unown has multiple forms, but only a single record. // - Castform has multiple forms and multiple records, but each record has unique movesets. // - Deoxys has multiple forms and multiple records, but all records have the same movesets. if (forms.ContainsKey(pokemonTranslator.PokemonSettings.pokemon_id) && forms[pokemonTranslator.PokemonSettings.pokemon_id].FormSettings.forms.Count > 0) { List <PokemonTranslator> records = new List <PokemonTranslator>(); foreach (var pokemon in pokemonTranslators) { if (pokemon.Id == pokemonTranslator.Id) { records.Add(pokemon); } } // If there are more that 1 match, then we need to deal with pokemon with multiple forms. (E.G. Unown) if (records.Count > 1) { // There are multiple records. We need to compare the movesets for the records. int matches = 0; foreach (var record in records) { if (IsMoveSetMatch(pokemonTranslator, record)) { matches++; } } // If every record matches the moveset, skip all but the base form. if (matches == records.Count) { if (pokemonTranslator.Form != Form.FORM_UNSET) { continue; } } // If only a sub-set of records match the moveset, skip the base form. else if (pokemonTranslator.Form == Form.FORM_UNSET) { continue; } } } List <_Pokemon._MoveSet> moveSets = new List <_Pokemon._MoveSet>(); moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, false, false)); moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, true, false)); moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, false, true)); moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, true, true)); double maxDPS = 0; foreach (var moveSet in moveSets) { if (!moveSet.FastAttack.legacy && !moveSet.ChargedAttack.legacy) { maxDPS = Math.Max(maxDPS, moveSet.true_dps); } } foreach (var moveSet in moveSets) { moveSet.comparison = (int)Math.Ceiling(moveSet.true_dps / maxDPS * 100); } _Pokemon _pokemon = new _Pokemon(pokemonTranslator, moveSets.ToArray()); pokemonMoveSetList[PokeFormulas.GetGeneration(pokemonTranslator)].Add(_pokemon); gameMasterStatsCalculator.Update(_pokemon); } for (int gen = 1; gen < PokeConstants.Regions.Length; gen++) { if (pokemonMoveSetList[gen].Count > 1) { Utils.WriteXML(new MoveSets(gen, pokemonMoveSetList[gen].ToArray(), updateDateTime), Path.Combine(Utils.OutputDataFileFolder, "movesets.gen" + gen + ".xml")); } } } }
/// <summary> /// Write out the stats for each generation of Pokemon /// </summary> public static void Write(IEnumerable <PokemonTranslator> pokemonTranslators, ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator) { DateTime updateDateTime = new DateTime(Math.Max(Math.Max( gameMasterStatsCalculator.GameMasterStats.last_updated.Date.Ticks, manualDataSettings.PokemonAvailability.last_updated.Date.Ticks), manualDataSettings.PokemonAvailability.last_updated.Date.Ticks)); // Create an array of lists to hold each generation. List <PokeStats._Pokemon>[] pokemonList = new List <PokeStats._Pokemon> [PokeConstants.Regions.Length + 1]; for (int i = 1; i < PokeConstants.Regions.Length; i++) { pokemonList[i] = new List <PokeStats._Pokemon>(); } // Need to provide basic info for Unreleased Pokemon. foreach (var pokemon in manualDataSettings.PokemonUnreleased.Pokemon) { if (pokemonList[PokeFormulas.GetGeneration(pokemon)] != null) { pokemonList[PokeFormulas.GetGeneration(pokemon)].Add( new _Pokemon(pokemon, manualDataSettings.PokemonAvailability.GetPokemon(pokemon.name, pokemon.form), manualDataSettings.PokemonAvailability.Pokemon[pokemon.id].rarity)); } gameMasterStatsCalculator.Update(pokemon); } // Now gather the data for the Pokemon in the GAME_MASTER. foreach (var pokemonTranslator in pokemonTranslators) { int gen = PokeFormulas.GetGeneration(pokemonTranslator.Id); _Pokemon pokemon = new _Pokemon(pokemonTranslator, manualDataSettings.PokemonAvailability.GetPokemon(pokemonTranslator.Name, pokemonTranslator.FormName), manualDataSettings.Traits, GetMaxStats(pokemonTranslator)); gameMasterStatsCalculator.Update(pokemon); if (pokemonList[gen] != null) { pokemonList[gen].Add(pokemon); // Handle cases where there are multiple forms, but only one record in the GAME_MASTER if (string.Equals(pokemonTranslator.Name, "Unown", StringComparison.OrdinalIgnoreCase) || string.Equals(pokemonTranslator.Name, "Spinda", StringComparison.OrdinalIgnoreCase)) { foreach (var form in manualDataSettings.PokemonAvailability.Pokemon[pokemonTranslator.Id].Form) { POGOProtos.Enums.Form formId; Enum.TryParse(pokemonTranslator.Name.ToUpper() + "_" + form.name.ToUpper().Replace(' ', '_'), out formId); pokemonTranslator.PokemonSettings.form = formId; pokemonList[gen].Add(new _Pokemon(pokemonTranslator, manualDataSettings.PokemonAvailability.GetPokemon(pokemonTranslator.Name, pokemonTranslator.FormName), manualDataSettings.Traits, GetMaxStats(pokemonTranslator))); } } } } for (int i = 1; i < PokeConstants.Regions.Length; i++) { string filePath = Path.Combine(Utils.OutputDataFileFolder, "pokestats.gen" + i + ".xml"); DateTime lastUpdated = Utils.GetLastUpdated(filePath); if (!File.Exists(filePath) || lastUpdated < updateDateTime) { Utils.WriteXML(new PokeStats(i, pokemonList[i].ToArray(), updateDateTime), Path.Combine(Utils.OutputDataFileFolder, "pokestats.gen" + i + ".xml")); } } }