Esempio n. 1
0
        // example resource: "PkmnTeamBuilder.Data.SeedFiles.items.json"
        public static List <PokemonType> Seed(ModelBuilder builder)
        {
            var resource = SeedHelper.GetResource("types.json");

            var types = SeedHelper.ReadStream <PokemonType>(resource);

            types = types.Select((x, index) => new PokemonType
            {
                Id   = index + 1,
                Name = x.Name
            });

            //using (var reader = new StreamReader(resource))
            //{
            //    var id = 1;

            //    while(!reader.EndOfStream)
            //    {
            //        var line = reader.ReadLine();
            //        var type = JsonConvert.DeserializeObject<PokemonType>(line);
            //        type.Id = id;

            //        types.Add(type);

            //        id++;
            //    }
            //}

            builder.Entity <PokemonType>()
            .HasData(types.ToArray());

            return(types.ToList());
        }
Esempio n. 2
0
        public static void Seed(ModelBuilder builder, List <PokemonType> types)
        {
            var resource = SeedHelper.GetResource("matchups.json");

            var fullMatchups = SeedHelper.ReadStream <FullMatchup>(resource);

            var matchups = new List <PokemonMatchup>();

            var id = 1;

            foreach (var full in fullMatchups)
            {
                foreach (var modifier in full.Modifiers)
                {
                    var matchup = new PokemonMatchup()
                    {
                        DefendingTypeId = types.First(x => x.Name.ToLower() == full.DefendingType.ToLower()).Id,
                        AttackingTypeId = types.First(x => x.Name.ToLower() == modifier.Attacking.ToLower()).Id,
                        Modifier        = decimal.Parse(modifier.Modifier),
                        Id = id
                    };

                    matchups.Add(matchup);
                    id++;
                }
            }

            builder.Entity <PokemonMatchup>()
            .HasData(matchups.ToArray());
        }
Esempio n. 3
0
        public static void Seed(ModelBuilder builder)
        {
            var resource = SeedHelper.GetResource("stats.json");

            var stats = SeedHelper.ReadStream <PokemonStat>(resource)
                        .Select((x, index) => new PokemonStat
            {
                Id   = index + 1,
                Name = x.Name
            });

            builder.Entity <PokemonStat>()
            .HasData(stats.ToArray());
        }
Esempio n. 4
0
        public static void Seed(ModelBuilder builder)
        {
            var resource = SeedHelper.GetResource("items.json");

            var items = SeedHelper.ReadStream <PokemonItem>(resource)
                        .Select((x, index) => new PokemonItem
            {
                Id          = index + 1,
                Name        = x.Name,
                Icon        = x.Icon,
                Description = x.Description
            });

            builder.Entity <PokemonItem>()
            .HasData(items.ToArray());
        }
Esempio n. 5
0
        public static void Seed(ModelBuilder builder)
        {
            var resource = SeedHelper.GetResource("natures.json");

            var natures = SeedHelper.ReadStream <PokemonNature>(resource)
                          .Select((x, index) => new PokemonNature
            {
                Id   = index + 1,
                Name = x.Name,
                Inc  = x.Inc,
                Dec  = x.Dec
            });

            builder.Entity <PokemonNature>()
            .HasData(natures.ToArray());
        }
Esempio n. 6
0
        public static List<PokemonAbility> Seed(ModelBuilder builder)
        {
            var resource = SeedHelper.GetResource("abilities.json");

            var abilities = SeedHelper.ReadStream<PokemonAbility>(resource)
                .Select((x, index) => new PokemonAbility
                {
                    Id = index + 1,
                    Name = x.Name,
                    Description = x.Description
                });

            builder.Entity<PokemonAbility>()
                .HasData(abilities.ToArray());

            return abilities.ToList();
        }
Esempio n. 7
0
        public static List <PokemonMove> Seed(ModelBuilder builder, List <PokemonType> types, List <PokemonMoveCategory> categories)
        {
            var resource = SeedHelper.GetResource("moves.json");

            var fullMoves = SeedHelper.ReadStream <FullMove>(resource);

            var moves = fullMoves
                        .Select((x, index) => new PokemonMove
            {
                Accuracy    = int.Parse(x.Accuracy),
                CategoryId  = categories.First(y => y.Name.ToLower() == x.Category.ToLower()).Id,
                Description = x.Description,
                Id          = index + 1,
                Name        = x.Name,
                Power       = x.Power != "--" ? int.Parse(x.Power) : 0,
                PP          = int.Parse(x.PP),
                TypeId      = types.First(y => y.Name.ToLower() == x.Type.ToLower()).Id
            });

            builder.Entity <PokemonMove>()
            .HasData(moves.ToArray());

            return(moves.ToList());
        }
Esempio n. 8
0
        public static void Seed(ModelBuilder builder, List <PokemonType> types, List <PokemonMoveType> moveTypes, List <PokemonMove> moves, List <PokemonAbility> abilities)
        {
            var resource        = SeedHelper.GetResource("pokemon.json");
            var abilityResource = SeedHelper.GetResource("pokemonAbilities.json");

            var fullPokemon = SeedHelper.ReadStream <FullPokemon>(resource);

            var fullAbilities             = SeedHelper.ReadStream <PokemonAbilities>(abilityResource);
            IEnumerable <Pokemon> pokemon = null;

            pokemon = fullPokemon
                      .Select((x, index) => new Pokemon
            {
                BaseAtk   = x.BaseAtk,
                BaseDef   = x.BaseDef,
                BaseHP    = x.BaseHP,
                BaseSpAtk = x.BaseSpAtk,
                BaseSpDef = x.BaseSpDef,
                BaseSpe   = x.BaseSpe,
                Icon      = x.Icon,
                Id        = index + 1,
                Image     = x.Image,
                Name      = x.Name,
                Number    = x.Number,
                Shiny     = x.Shiny,
                Type1Id   = types.First(y => y.Name.ToLower() == x.Type1.ToLower()).Id,
                Type2Id   = x.Type2 != null ? types.First(y => y.Name.ToLower() == x.Type2.ToLower()).Id : null as int?
            });

            builder.Entity <Pokemon>()
            .HasData(pokemon.ToArray());

            var abilityset = new List <PokemonAbilityset>();
            var moveset    = new List <PokemonMoveset>();

            var moveCounter    = 1;
            var abilityCounter = 1;

            foreach (var pkmn in fullPokemon)
            {
                var id = pokemon.First(x => x.Name == pkmn.Name).Id;

                moveset.AddRange(CreateMoveset(pkmn.Moves.LevelUp, moves, moveTypes, "Level Up", id, ref moveCounter));
                moveset.AddRange(CreateMoveset(pkmn.Moves.TM, moves, moveTypes, "TM", id, ref moveCounter));
                moveset.AddRange(CreateMoveset(pkmn.Moves.TR, moves, moveTypes, "TR", id, ref moveCounter));
                moveset.AddRange(CreateMoveset(pkmn.Moves.Egg, moves, moveTypes, "Egg", id, ref moveCounter));
                moveset.AddRange(CreateMoveset(pkmn.Moves.Tutor, moves, moveTypes, "Tutor", id, ref moveCounter));

                var abils = fullAbilities.First(x => x.PokemonName.ToLower() == pkmn.Name.ToLower());

                foreach (var abil in abils.AbilityNames)
                {
                    abilityset.Add(new PokemonAbilityset()
                    {
                        Id        = abilityCounter++,
                        AbilityId = abilities.First(x => x.Name.ToLower() == abil.ToLower()).Id,
                        PokemonId = id
                    });
                }
            }

            builder.Entity <PokemonMoveset>()
            .HasData(moveset.ToArray());

            builder.Entity <PokemonAbilityset>()
            .HasData(abilityset.ToArray());
        }