예제 #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 GeneratePvPokeGameMasterJson()
        {
            //await PokemonGoGameMasterFileManager.FetchAndSaveFileAsync();
            var json = await PokemonGoGameMasterFileManager.ReadFileAsync(PokemonGoGameMasterFileManager.GameMasterJsonPath);

            dynamic gameMaster = JsonConvert.DeserializeObject <dynamic>(json);

            var settings = await FileManager.LoadFileAsync <dynamic>(PokemonGoGameMasterFileManager.SettingsJsonPath);

            var cups = await FileManager.LoadFileAsync <dynamic>(PokemonGoGameMasterFileManager.CupsJsonPath);

            var gameMasterFile = new PvPokeGameMasterFileManager.GameMasterFile
            {
                Settings = settings,
                Cups     = cups,
                Pokemon  = await GameMasterFileAdapter.AdaptPokemonAsync(gameMaster),
                Moves    = GameMasterFileAdapter.AdaptMoves(gameMaster)
            };

            string gameMasterJson = JsonConvert.SerializeObject(gameMasterFile, GlobalJsonSerializerSettings.Shared);
            await FileManager.SaveFileAsync(gameMasterJson, PvPokeGameMasterFileManager.GeneratedPvPokeGameMasterJsonPath);

            _output.WriteLine(gameMasterJson);
        }