示例#1
0
        public async Task GenerateLegacyMovesJson()
        {
            var json = await PokemonGoGameMasterFileManager.ReadFileAsync(PokemonGoGameMasterFileManager.GameMasterJsonPath);

            dynamic gameMaster = JsonConvert.DeserializeObject <dynamic>(json);
            var     regex      = new Regex(@"^COMBAT_V\d+_MOVE_");
            var     templates  = ((IEnumerable <dynamic>)gameMaster.itemTemplates).Where(t => regex.IsMatch((string)t.templateId));

            var moves = new Dictionary <string, bool>();

            foreach (dynamic template in templates)
            {
                string moveId = (string)template.combatMove.uniqueId;
                moves.Add(moveId.Replace("_FAST", String.Empty), moveId.EndsWith("_FAST"));
            }

            var pvpokeJson = await PvPokeGameMasterFileManager.ReadFileAsync(PvPokeGameMasterFileManager.ActualPvPokeGameMasterJsonPath);

            var pvpokeGameMaster     = JsonConvert.DeserializeObject <PvPokeGameMasterFileManager.GameMasterFile>(pvpokeJson);
            var legacyMoveCollection = new LegacyMoveCollection();

            foreach (var pokemon in pvpokeGameMaster.Pokemon)
            {
                var pokemonWithLegacyMoves = new LegacyMoveCollection.PokemonWithLegacyMoves {
                    SpeciesId = pokemon.SpeciesId.Replace("_normal", String.Empty)
                };

                if (pokemon.LegacyMoves != null)
                {
                    foreach (string legacyMove in pokemon.LegacyMoves)
                    {
                        if (legacyMove.StartsWith("HIDDEN_POWER_") || moves[legacyMove])
                        {
                            pokemonWithLegacyMoves.LegacyFastMoves.Add(legacyMove);
                        }
                        else
                        {
                            pokemonWithLegacyMoves.LegacyChargeMoves.Add(legacyMove);
                        }
                    }
                }

                legacyMoveCollection.Pokemon.Add(pokemonWithLegacyMoves);
            }

            string legacyMovesJson = JsonConvert.SerializeObject(legacyMoveCollection, GlobalJsonSerializerSettings.Shared);
            await FileManager.SaveFileAsync(legacyMovesJson, PokemonGoGameMasterFileManager.LegacyMovesJsonPath);

            _output.WriteLine(legacyMovesJson);
        }
示例#2
0
        public async Task GenerateChargeMovesCsv()
        {
            var pvpokeJson = await PvPokeGameMasterFileManager.ReadFileAsync(PvPokeGameMasterFileManager.GeneratedPvPokeGameMasterJsonPath);

            var pvpokeGameMaster = JsonConvert.DeserializeObject <PvPokeGameMasterFileManager.GameMasterFile>(pvpokeJson);

            using (var writer = new StringWriter())
                using (var csv = new CsvWriter(writer))
                {
                    var chargeMoves = pvpokeGameMaster.Moves.Where(m => m.Energy > 0).Select(m => new
                    {
                        Move = m.Name,
                        m.Power,
                        m.Energy,
                        Type = m.Type.ToUpperFirstCharacter()
                    });
                    csv.WriteRecords(chargeMoves);
                    _output.WriteLine(writer.ToString());
                }
        }
示例#3
0
        public async Task GenerateDefaultIVsJson()
        {
            var pvpokeJson = await PvPokeGameMasterFileManager.ReadFileAsync(PvPokeGameMasterFileManager.ActualPvPokeGameMasterJsonPath);

            var pvpokeGameMaster = JsonConvert.DeserializeObject <PvPokeGameMasterFileManager.GameMasterFile>(pvpokeJson);

            var pokemonDefaultIVs = new DefaultIVsCollection();

            foreach (PvPokeGameMasterFileManager.GameMasterFile.PokemonProperty pokemon in pvpokeGameMaster.Pokemon)
            {
                string speciesId = pokemon.SpeciesId.Replace("_normal", String.Empty);
                pokemonDefaultIVs.Pokemon[speciesId] = new Dictionary <string, List <decimal> >();

                foreach (KeyValuePair <string, List <decimal> > pokemonDefaultIV in pokemon.DefaultIVs)
                {
                    pokemonDefaultIVs.Pokemon[speciesId][pokemonDefaultIV.Key] = pokemon.DefaultIVs[pokemonDefaultIV.Key];
                }
            }

            string defaultIVsJson = JsonConvert.SerializeObject(pokemonDefaultIVs, GlobalJsonSerializerSettings.Shared);
            await FileManager.SaveFileAsync(defaultIVsJson, PokemonGoGameMasterFileManager.DefaultIVsJsonPath);

            _output.WriteLine(defaultIVsJson);
        }