private void LevelUp()
        {
            if (playerPokemon.Xp >= Convert.ToInt32(Math.Pow(playerPokemon.Pokemon.Level, 3)))
            {
                LevelGained = true;
                playerPokemon.Pokemon.Level++;
                txtInformation.Text += $"{Environment.NewLine}Your {playerPokemon.Name} leveled up to level {playerPokemon.Pokemon.Level}! {Environment.NewLine}";


                List <PokemonAttack>      attackList        = DatabaseOperations.GetAvailableAttacks(playerPokemon.Pokemon.PokedexId, playerPokemon.Pokemon.Level);
                List <OwnedPokemonAttack> knownAttacks      = DatabaseOperations.GetKnownAttacks(PlayerPokemonStatics.PlayerPokemon.PokemonId);
                List <OwnedPokemonAttack> knownAttacksFalse = DatabaseOperations.GetKnownAttacksEqualsFalse(PlayerPokemonStatics.PlayerPokemon.PokemonId);

                foreach (var item in attackList)
                {
                    if (playerPokemon.Pokemon.Level >= item.RequiredLevel)
                    {
                        OwnedPokemonAttack newAttack = new OwnedPokemonAttack()
                        {
                            AttackId    = item.AttackId,
                            CurrentPp   = item.Attack.Pp,
                            PokemonId   = playerPokemon.PokemonId,
                            KnownAttack = false
                        };


                        if (!knownAttacks.Contains(newAttack) && !knownAttacksFalse.Contains(newAttack))
                        {
                            DatabaseOperations.AddCaughtPokemonAttacks(newAttack);
                            txtInformation.Text += $"Your {playerPokemon.Name} can learn a new move" + Environment.NewLine;
                        }
                    }
                }

                PlayerPokemonUi();
            }
        }
        private void BtnConfirm_Click(object sender, RoutedEventArgs e)
        {
            Player        player        = new Player();
            PlayerPokemon playerPokemon = new PlayerPokemon();

            player.Name        = txtPlayerName.Text;
            playerPokemon.Name = txtRenamePokemon.Text;



            if (player.IsGeldig() && playerPokemon.IsGeldig() && PokemonSelected() != false)
            {
                TimeSpan startTime = new TimeSpan(0, 0, 0);


                player.Pokedollar = 10000;
                player.PlayedTime = startTime;

                int ok = DatabaseOperations.AddPlayer(player);

                Random r = new Random();

                PlayerPokedex playerPokedex = new PlayerPokedex();

                int id = 0;

                playerPokedex.PlayerId = player.Id;

                if (tbBulbasaur.IsChecked == true)
                {
                    playerPokemon.Height = 0.7m;
                    playerPokemon.Weight = 6.9m;
                    id = 1;
                    playerPokedex.Caught      = true;
                    playerPokedex.Encountered = true;
                    playerPokedex.PokedexId   = id;
                }
                else if (tbCharmander.IsChecked == true)
                {
                    playerPokemon.Height = 0.6m;
                    playerPokemon.Weight = 8.5m;
                    id = 4;
                    playerPokedex.Caught      = true;
                    playerPokedex.Encountered = true;
                    playerPokedex.PokedexId   = id;
                }
                else if (tbSquirtle.IsChecked == true)
                {
                    playerPokemon.Height = 0.5m;
                    playerPokemon.Weight = 9;
                    id = 7;
                    playerPokedex.Caught      = true;
                    playerPokedex.Encountered = true;
                    playerPokedex.PokedexId   = id;
                }



                DatabaseOperations.AddNewPokemonPlayerPokedex(playerPokedex);


                pokemon = new Pokemon
                {
                    Level          = 7,
                    Hp             = r.Next(0, 32),
                    CurrentHp      = 0,
                    Defense        = r.Next(0, 32),
                    Attack         = r.Next(0, 32),
                    SpecialAttack  = r.Next(0, 32),
                    SpecialDefense = r.Next(0, 32),
                    Speed          = r.Next(0, 32),
                    PokedexId      = id,
                };

                playerPokemon.PokemonId = DatabaseOperations.AddPokemon(pokemon);

                pokemon.Pokedex = DatabaseOperations.GetPokedexEntry(id);
                pokemon.SetMaxHp();
                pokemon.CurrentHp = pokemon.CalculatedMaxHP;

                DatabaseOperations.UpdatePokemonCurrentHp(pokemon);



                playerPokemon.InParty  = true;
                playerPokemon.PlayerId = player.Id;
                playerPokemon.Xp       = Convert.ToInt32(Math.Pow(pokemon.Level - 1, 3));

                DatabaseOperations.AddPlayerPokemon(playerPokemon);

                List <PokemonAttack> pokemonAttacks = DatabaseOperations.GetAvailableAttacks(pokemon.PokedexId, pokemon.Level);

                foreach (var item in pokemonAttacks)
                {
                    if (pokemon.Level >= item.RequiredLevel)
                    {
                        OwnedPokemonAttack ownedPokemonAttack = new OwnedPokemonAttack
                        {
                            AttackId    = item.AttackId,
                            CurrentPp   = item.Attack.Pp,
                            PokemonId   = playerPokemon.PokemonId,
                            KnownAttack = true
                        };
                        DatabaseOperations.AddCaughtPokemonAttacks(ownedPokemonAttack);
                    }
                }

                PlayerInformation.PlayerId = ok;

                MainMenuWindow mainMenuWindow = new MainMenuWindow();
                mainMenuWindow.Show();
                this.Close();
            }
            else if (!player.IsGeldig())
            {
                MessageBox.Show(player.Error);
            }
            else if (!playerPokemon.IsGeldig())
            {
                MessageBox.Show(playerPokemon.Error);
            }
            else
            {
                MessageBox.Show("You need to select a pokemon first.");
            }
        }
        private bool Catch(double catchMultiplier, Pokemon pokemon, List <OwnedPokemonAttack> attacks)
        {
            if (lblEnemyName.Content.ToString() == "Wild Pokemon")
            {
                int    catchRate      = pokemon.Pokedex.CatchRate;
                double catchMissingHp = ((100 - pbHpEnemyPokemon.Value) / 100) + 1;
                double catchNumber    = ((catchRate * catchMissingHp) * catchMultiplier);

                Random r = new Random();

                if (r.Next(0, 101) <= catchNumber)
                {
                    // pokemon object aanmaken om te inserten
                    Pokemon p = new Pokemon
                    {
                        Level          = pokemon.Level,
                        Attack         = pokemon.Attack,
                        Defense        = pokemon.Defense,
                        Hp             = pokemon.Hp,
                        CurrentHp      = pokemon.CalculatedMaxHP,
                        SpecialAttack  = pokemon.SpecialAttack,
                        SpecialDefense = pokemon.SpecialDefense,
                        Speed          = pokemon.Speed,
                        PokedexId      = pokemon.PokedexId
                    };

                    int id = DatabaseOperations.AddPokemon(p);

                    // speler pokemon aanmaken om te inserten
                    PlayerPokemon newPlayerPokemon = new PlayerPokemon
                    {
                        Name      = pokemon.Pokedex.Name,
                        Height    = pokemon.Pokedex.AvgHeight,
                        Weight    = pokemon.Pokedex.AvgWeight,
                        Xp        = (pokemon.Level - 1) * (pokemon.Level - 1) * (pokemon.Level - 1),
                        InParty   = false,
                        PlayerId  = PlayerInformation.PlayerId,
                        PokemonId = id,
                    };

                    DatabaseOperations.AddPlayerPokemon(newPlayerPokemon);

                    // pokemon aanvallen aanmaken om te inserten
                    foreach (var item in attacks)
                    {
                        OwnedPokemonAttack attack = new OwnedPokemonAttack
                        {
                            CurrentPp = item.CurrentPp,
                            PokemonId = id,
                            AttackId  = item.AttackId,
                        };
                        if (item.KnownAttack == true)
                        {
                            attack.KnownAttack = true;
                        }
                        else
                        {
                            attack.KnownAttack = false;
                        }



                        DatabaseOperations.AddCaughtPokemonAttacks(attack);
                    }

                    txtInformation.Text               = $"Congratulations , You caught a {pokemon.Pokedex.Name}!";
                    imgEnemyPokemon.Source            = new BitmapImage(new Uri(@"images\sprites\pokeball.png", UriKind.Relative));
                    imgEnemyPokemon.Width             = 50;
                    imgEnemyPokemon.Height            = 50;
                    imgEnemyPokemon.VerticalAlignment = VerticalAlignment.Center;

                    return(true);
                }
                else
                {
                    txtInformation.Text = $"{pokemon.Pokedex.Name} broke free, Try again!";

                    return(false);
                }
            }
            else
            {
                txtInformation.Text = $"You can't catch another trainer's pokemon";

                return(false);
            }
        }