Пример #1
0
        public int GetCantPokemons(PokemonRepository pkm)
        {
            var allPokemons = pkm.GetAll();
            var cant        = allPokemons.Count();

            return(cant);
        }
Пример #2
0
 public static bool IsNameRight(string pokename)
 {
     using (PokemonRepository repos = new PokemonRepository())
     {
         return(repos.GetIDFromName(pokename) == GetIDFromFile());
     }
 }
 public static void Method()
 {
     PokemonRepository repo     = new PokemonRepository();
     List <Pokemon>    pokemons = new List <Pokemon>();
     {
     }
 }
Пример #4
0
 public static int GetRandomPokemonID()
 {
     using (PokemonRepository repos = new PokemonRepository())
     {
         return(repos.GetRandomPokemon());
     }
 }
Пример #5
0
        public async Task It_Should_Return_All_Pokemons()
        {
            //Arrange
            using (var context = new ApplicationContext(_options))
            {
                context.Pokemons.Add(new Pokemon {
                    Name = "Pikachu", Level = 80
                });
                context.Pokemons.Add(new Pokemon {
                    Name = "Charmander", Level = 60
                });
                context.Pokemons.Add(new Pokemon {
                    Name = "Bulbasaur", Level = 50
                });
                context.SaveChanges();
            }
            int expectedQuantity = 4;

            //Act
            using (var context = new ApplicationContext(_options))
            {
                PokemonRepository pokemonRepository = new PokemonRepository(context);
                List <Pokemon>    pokemons          = await pokemonRepository.GetAll();

                //Assert
                Assert.Equal(expectedQuantity, pokemons.Count);
            }
        }
        public void GetRandomMovesValuesTest()
        {
            var da    = new PokemonRepository(_config);
            var moves = da.GetRandomMoves(0, 150);

            moves.ToList().ForEach(AssertPokemonMoveSetResult);
        }
        public void GetMovesForPokemonValuesTest()
        {
            var da    = new PokemonRepository(_config);
            var moves = da.GetMovesForPokemon(62, 100);

            moves.ToList().ForEach(AssertPokemonMoveSetResult);
        }
        public void GetPossiblePokemonValuesTest()
        {
            var da      = new PokemonRepository(_config);
            var pokemon = da.GetPossiblePokemon(100);

            pokemon.ToList().ForEach(t => Assert.True(t != 0, "Not zero"));
        }
Пример #9
0
 public Pokemon(Type type, List <Move> moves, int id, int pokedexId, string name, bool inParty, int level,
                int currentHp, int maxHp, int xp, bool fainted, int attack, int defense, int speed, int evolveLevel,
                int captureRate, int speedGrowth, int attackGrowth, int defenseGrowth, int hpGrowth, int defeatXp)
 {
     this.type     = type;
     this.moves    = moves;
     Id            = id;
     PokedexId     = pokedexId;
     Name          = name;
     InParty       = inParty;
     Level         = level;
     CurrentHp     = currentHp;
     MaxHp         = maxHp;
     Xp            = xp;
     Fainted       = fainted;
     Attack        = attack;
     Defense       = defense;
     Speed         = speed;
     EvolveLevel   = evolveLevel;
     CaptureRate   = captureRate;
     SpeedGrowth   = speedGrowth;
     AttackGrowth  = attackGrowth;
     DefenseGrowth = defenseGrowth;
     HpGrowth      = hpGrowth;
     DefeatXp      = defeatXp;
     repository    = new PokemonRepository();
 }
Пример #10
0
        public void GetTMsValueTest()
        {
            var da  = new PokemonRepository(_config);
            var tms = da.GetTMs();

            tms.ToList().ForEach(tm => Assert.True(tm != 0, "TM not zero"));
        }
Пример #11
0
        public void GetTeamBaseStatsValuesTest()
        {
            var da        = new PokemonRepository(_config);
            var baseStats = da.GetTeamBaseStats(new PokeList(4)
            {
                Species = new byte[] { 0, 1, 2, 3 }
            });

            foreach (var stat in baseStats)
            {
                Assert.True(stat.Id != 0, "Id not zero");
                Assert.True(stat.Hp != 0, "Hp not zero");
                Assert.True(stat.Attack != 0, "Attack not zero");
                Assert.True(stat.Defense != 0, "Defense not zero");
                Assert.True(stat.SpAttack != 0, "SpAttack not zero");
                Assert.True(stat.SpDefense != 0, "SpDefense not zero");
                Assert.True(stat.Speed != 0, "Speed not zero");

                Assert.NotNull(stat.GrowthRate);
                Assert.NotEmpty(stat.GrowthRate);

                Assert.NotNull(stat.Identifier);
                Assert.NotEmpty(stat.Identifier);

                Assert.NotNull(stat.Types);
                Assert.NotEmpty(stat.Types);
            }
        }
Пример #12
0
        public BattlePage()
        {
            rep   = new PokemonRepository();
            realm = Realm.GetInstance();

            if (GlobalVar.battlePageVisited == false)
            {
                GlobalVar.battlePageVisited = true;

                InitializeComponent();

                CargarPokemonsThread = new Java.Lang.Thread(rep.CargarPokemons);

                InicializarPagina();
            }

            CargarDatos();

            GlobalGrid.imageFriendImage.RotateTo(0, 0);
            GlobalGrid.imageEnemyImage.RotateTo(0, 0);

            GenerarGridPokemon(false);
            GenerarGridData(false);
            GenerarGridValues(false);
            GenerarGridHp(false);
            GenerarGridPokemon(true);
            GenerarGridData(true);
            GenerarGridValues(true);
            GenerarGridHp(true);
            GenerarGridMenu();
            GenerarGridAttack();

            Content = GlobalGrid.gridBattlePage;
        }
Пример #13
0
        public async Task <IList <PokemonResponse> > GetAll()
        {
            using (var db = Db)
            {
                var pokemonRepository = new PokemonRepository(db);

                var pokemons = await pokemonRepository.GetAll();

                var pokemonResponse = new List <PokemonResponse>();

                foreach (var pokemon in pokemons)
                {
                    pokemonResponse.Add(
                        new PokemonResponse()
                    {
                        Id          = pokemon.Id,
                        Name        = pokemon.Name,
                        BaseAttack  = pokemon.BaseAttack,
                        BaseDefense = pokemon.BaseDefense,
                        BaseHP      = pokemon.BaseHP,
                        BaseSpAtk   = pokemon.BaseSpAtk,
                        BaseSpDef   = pokemon.BaseSpDef,
                        BaseSpeed   = pokemon.BaseSpeed,
                        Skills      = await GetPokemonSkills(pokemon.Id, db),
                        Types       = await GetPokemonTypes(pokemon.Id, db)
                    });
                }
                return(pokemonResponse);
            }
        }
Пример #14
0
        public async void Delete(int id)
        {
            using (var db = Db)
            {
                var pokemonToPokemonSkillRepository = new PokemonToPokemonSkillRepository(db);
                var skillMaps = await pokemonToPokemonSkillRepository.GetByPokemonId(id);

                foreach (var skillMap in skillMaps)
                {
                    pokemonToPokemonSkillRepository.Delete(skillMap);
                }

                var pokemonToPokemonTypeRepository = new PokemonToPokemonTypeRepository(db);
                var typeMaps = await pokemonToPokemonTypeRepository.GetByPokemonId(id);

                foreach (var typeMap in typeMaps)
                {
                    pokemonToPokemonTypeRepository.Delete(typeMap);
                }

                var pokemonRepository = new PokemonRepository(db);
                var pokemon           = await pokemonRepository.FindOneById(id);

                pokemonRepository.Delete(pokemon);
            }
        }
Пример #15
0
        public void GetWeaknessesValuesTest()
        {
            var da         = new PokemonRepository(_config);
            var weaknesses = da.GetWeaknesses("fire");

            weaknesses.ToList().ForEach(Assert.NotNull);
            weaknesses.ToList().ForEach(Assert.NotEmpty);
        }
Пример #16
0
        public void GetRandomMovesTest()
        {
            var da    = new PokemonRepository(_config);
            var moves = da.GetRandomMoves(0, 150);

            Assert.NotNull(moves);
            Assert.True(moves.Count() > 0, "Moves has at least one move");
        }
Пример #17
0
        public void GetPossiblePokemonTest()
        {
            var da      = new PokemonRepository(_config);
            var pokemon = da.GetPossiblePokemon(100);

            Assert.NotNull(pokemon);
            Assert.True(pokemon.Count() > 0, "Pokemon has at least one pokemon");
        }
Пример #18
0
        public ListPage()
        {
            InitializeComponent();

            rep = new PokemonRepository();

            Content = GenerarGrid();
        }
Пример #19
0
        public void GetTMsTest()
        {
            var da  = new PokemonRepository(_config);
            var tms = da.GetTMs();

            Assert.NotNull(tms);
            Assert.True(tms.Count() > 0, "At least one TM");
        }
Пример #20
0
 public Pokedex()
 {
     Pokemons     = new PokemonRepository();
     PokeTypes    = new PokeTypeRepository();
     Species      = new SpeciesRespository();
     Utilisateurs = new UtilisateurRepository();
     Habitats     = new HabitatRepository();
 }
Пример #21
0
        public void GetWeaknessesTest()
        {
            var da         = new PokemonRepository(_config);
            var weaknesses = da.GetWeaknesses("fire");

            Assert.NotNull(weaknesses);
            Assert.True(weaknesses.Count() > 0, "At least one weakness");
        }
        public PokemonControllerTests()
        {
            pokemonRepository    = new PokemonRepository(new HttpClient());
            translatorRepository = new TranslatorRepository(new HttpClient());
            _pokemonService      = new PokemonService(pokemonRepository, translatorRepository);

            _pokemonController = new PokemonController(_pokemonService);
        }
Пример #23
0
        public void GetMovesForPokemonTest()
        {
            var da    = new PokemonRepository(_config);
            var moves = da.GetMovesForPokemon(62, 100);

            Assert.NotNull(moves);
            Assert.True(moves.Count() > 0, "Moves has at least one move");
        }
Пример #24
0
        private static void CreatePokemon(PokemonRepository repo)
        {
            Pokemon newPokemon = UserIO.PromptUserForNewPokemon();

            newPokemon = repo.Create(newPokemon);

            UserIO.DisplayPokemon(repo.ReadById(newPokemon.Id));
        }
Пример #25
0
 private static void UpdatePokemon(PokemonRepository repo, Pokemon pokemonInfo)
 {
     string name = UserIO.PromptUser("Please Enter a name");
     pokemonInfo.Name = name;
     repo.Update(pokemonInfo.Id, pokemonInfo);
     Console.Clear();
     UserIO.DisplayPokemon(repo.ReadById(pokemonInfo.Id));
 }
Пример #26
0
 private async void btnSave_Click(object sender, RoutedEventArgs e)
 {
     if (Convert.ToInt32(pokemonNumberTextBox.Text) > 807 || Convert.ToInt32(pokemonNumberTextBox.Text) < 1)
     {
         ProfessorOak.ShowMessage("Error", "Pokemon Number is out of range. Must be between 1 and 807.");
     }
     else
     {
         try
         {
             View.Route = null;
             View.Types = null;
             PokemonRepository pr = new PokemonRepository();
             if (View.ID == 0)
             {
                 await pr.AddPokemon(View);
             }
             else
             {
                 await pr.UpdatePokemon(View);
             }
             Frame.GoBack();
         }
         catch (AggregateException ex)
         {
             string errorMsg = "";
             foreach (var exception in ex.InnerExceptions)
             {
                 errorMsg += Environment.NewLine + exception.Message;
             }
             ProfessorOak.ShowMessage("One or more exceptios have occured:", errorMsg);
         }
         catch (ApiException apiEx)
         {
             var sbuilder = new StringBuilder();
             sbuilder.AppendLine(string.Format("HTTP Status Code: {0}", apiEx.StatusCode.ToString()));
             sbuilder.AppendLine("Errors:");
             foreach (var error in apiEx.Errors)
             {
                 sbuilder.AppendLine("-" + error);
             }
             ProfessorOak.ShowMessage("There was a problem saving the Pokemon:", sbuilder.ToString());
         }
         catch (Exception ex)
         {
             if (ex.InnerException.Message.Contains("Connection with the server"))
             {
                 ProfessorOak.ShowMessage("Error", "No connection with the server.");
             }
             else
             {
                 ProfessorOak.ShowMessage("Error", "Could not complete operation.");
             }
         }
     }
 }
Пример #27
0
        public string GetMostFat(PokemonRepository pokeList)
        {
            var pokemons = pokeList.GetAll();

            int cantmax = pokemons.Max(p => p.Weight);
            PokemonData pkm = pokemons.Find(u => u.Weight == cantmax);
            var text = "nombre: " + pkm.Name + "alias: " + pkm.Alias + " altura: " + pkm.Height + "peso: " + pkm.Weight;

            return text;
        }
Пример #28
0
 private static void DeletePokemon(PokemonRepository repo)
 {
     int id = UserIO.PromptUserForInt("Enter Id to remove");
     repo.Delete(id);
     Pokemon deletedInfo = repo.ReadById(UserIO.PromptUserForInt("Enter Id for Pokemon"));
     if (deletedInfo == null)
     {
         Console.WriteLine("No Pokemon found");
     }
 }
Пример #29
0
        public void GetTeamBaseStatsTest()
        {
            var da        = new PokemonRepository(_config);
            var baseStats = da.GetTeamBaseStats(new PokeList(4)
            {
                Species = new byte[] { 0, 1, 2, 3 }
            });

            Assert.NotNull(baseStats);
            Assert.True(baseStats.Count() > 0, "Stats has at least one stat");
        }
Пример #30
0
 public static string GetPokeFile(int PokeID, bool PokeRevealed)
 {
     using (PokemonRepository repos = new PokemonRepository())
     {
         if (PokeRevealed)
         {
             return(AppDomain.CurrentDomain.BaseDirectory + @"App_Data" + repos.GetPokemonByID(PokeID).Pics);
         }
         return(AppDomain.CurrentDomain.BaseDirectory + @"App_Data" + repos.GetPokemonByID(PokeID).ShadowPics);
     }
 }