private void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.Shift && e.KeyCode == Keys.S)
            {
                using (var p = new Pokemons())
                {
                    p.ShowDialog();
                }
            }

            else if (e.Control && e.Shift && e.KeyCode == Keys.A)
            {
                using (Settings s = new Settings())
                {
                    s.ShowDialog();
                }
            }
            else if (e.Control && e.KeyCode == Keys.Z)
            {
                playerContainer.Undo();
            }
            else if (e.Control && e.KeyCode == Keys.Y)
            {
                playerContainer.Redo();
            }
        }
        public FormNickname(Pokemons poke)
        {
            InitializeComponent();

            pokemon = poke;
            tbNickname.Text = pokemon.name;
        }
 public void mostrarDatosPokemonRival(Pokemons poke)
 {
     txtNombreSist.Text    = poke.Nombre.ToString();
     txtEspecieSist.Text   = poke.Especie.ToString();
     txtHabilidadSist.Text = poke.Habilidad.ToString();
     txtPesoSist.Text      = poke.Peso.ToString();
     txtAlturaSist.Text    = poke.Altura.ToString();
     txtColorSist.Text     = poke.Color.ToString();
     txtHabitadSist.Text   = poke.Habitad.ToString();
 }
        public FormMiniGame(FormPokemons _mainForm, Pokemons _poke)
        {
            mainForm = _mainForm;
            poke = _poke;

            InitializeComponent();

            labelInfo.Parent = pbCanvas;

            Game1();
        }
        public void ChangeDetails(Pokemons poke)
        {
            tbName.Text = poke.name;

            if (poke.gender == 0) tbName.Text += " ♀ ";
            if (poke.gender == 1) tbName.Text += " ♂ ";

            tbName.Text += "\n(" + Pokemons.GetType(poke.type1);

            if (poke.type2 != 0) tbName.Text += " / " + Pokemons.GetType(poke.type2);

            tbName.Text += ")";

            tbStats.Text = "Level: " + poke.level;

            if(poke.level < 100)
                tbStats.Text += "\nXP: " + poke.xp + " / " + Resources.xpneeded[poke.level];

            tbStats.Text += "\n\nHP: " + (int)poke.hp + " / " + (int)poke.hpmax
                        + "\nATK: " + (int)poke.atk + "\nDEF: " + (int)poke.def
                        + "\nSPATK: " + (int)poke.spatk + "\nSPDEF: " + (int)poke.spdef
                        + "\nSpeed: " + (int)poke.speed + "\n\n";

            if (poke.lovebase <= 10) tbStats.Text += poke.name + " is a cold-hearted pokemon.\n";
            else if (poke.lovebase <= 20) tbStats.Text += poke.name + " is a grumpy pokemon.\n";
            else if (poke.lovebase <= 30) tbStats.Text += poke.name + " is a neutral pokemon.\n";
            else if (poke.lovebase <= 40) tbStats.Text += poke.name + " is a friendly pokemon.\n";
            else tbStats.Text += poke.name + " is an affectionate pokemon.\n";

            if(poke.trust <= 20) tbStats.Text += poke.name + " has trust issues.\n";
            else if (poke.trust >= 80) tbStats.Text += poke.name + " trusts you more than anything.\n";

            if (poke.hunger <= 5) tbStats.Text += poke.name + " is hungry.\n";

            if (poke.joy <= 5) tbStats.Text += poke.name + " is very sad.\n";
            else if (poke.joy >= 20) tbStats.Text += poke.name + " is very happy.\n";

            for (int j = 0; j < 4; ++j)
            {
                attack[j].Text = "-";
                attack[j].Enabled = false;
                attack[j].BackColor = Color.BurlyWood;
            }

            for (int j = 0; j < poke.moves.Count; ++j)
            {
                attack[j].Text = poke.moves[j].name;
                attack[j].Enabled = true;
                attack[j].BackColor = poke.moves[j].color;
            }
        }
        public void crearPokemonesRivales()
        {
            Pokemons miPokemon1 = new Pokemons("Psyduck", "Pato", "Humedad", 19, 8, "Amarillo", "Mar");
            Pokemons miPokemon2 = new Pokemons("Meowth", "Gato", "Experto", 4, 4, "Gris", "Bosque");
            Pokemons miPokemon3 = new Pokemons("Gastly", "Bola", "Gas", 1, 3, "Marron", "Fango");
            Pokemons miPokemon4 = new Pokemons("Onix", "Serpiente", "Terremoto", 35, 3, "Gris", "Cuevas");
            Pokemons miPokemon5 = new Pokemons("Snorlax", "Oso", "Dormir", 40, 2, "Plomo", "Bosque");

            lstPokesRivales.Add(miPokemon1);
            lstPokesRivales.Add(miPokemon2);
            lstPokesRivales.Add(miPokemon3);
            lstPokesRivales.Add(miPokemon4);
            lstPokesRivales.Add(miPokemon5);
        }
        public FormBattle(Pokemons poke, bool isEvent)
        {
            InitializeComponent();

            player.usedMasterBall = false;

            enemyPokemonEvent = isEvent;

            enemyPokemon = poke;
            tbHistory.Text = "A wild " + enemyPokemon.name + " appeared!";

            // set temporary stats
            enemyPokemon.SetTemporaryStats();
            enemyPokemon.EraseAffections();

            // see pokemon
            FormPokedex.SeePokemon(poke.index);

            Initialize();
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string _nombre    = txtNombrePokemon.Text;
            string _especie   = txtEspeciePokemon.Text;
            string _habilidad = txtHabilidadPokemon.Text;
            double _peso      = Double.Parse(txtPesoPokemon.Text);
            double _altura    = Double.Parse(txtAlturaPokemon.Text);
            string _color     = cboColorPokemon.SelectedItem.ToString();
            string _habitad   = txtHabitadPokemon.Text;

            //Crear pokemon (instanciar)
            Pokemons pokemon1 = new Pokemons(_nombre, _especie, _habilidad, _peso, _altura, _color, _habitad);

            MessageBox.Show($"nombre: {pokemon1.Nombre}", "titulo");
            limpiarControles();


            //Agregar el pokemon a la Grilla/Grid/Tabla/GridView
            dgbPokemons.Rows.Add(nuFilas++, pokemon1.Nombre, pokemon1.Especie, pokemon1.Habilidad, pokemon1.Peso, pokemon1.Altura, pokemon1.Color, pokemon1.Habitad);
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                string _nombre    = cboNombre.SelectedItem.ToString();
                string _especie   = txtEspeciePokemon.Text;
                string _habilidad = txtHabilidadPokemon.Text;
                double _peso      = Double.Parse(txtPesoPokemon.Text);
                double _altura    = Double.Parse(txtAlturaPokemon.Text);
                string _color     = cboColorPokemon.SelectedItem.ToString();
                string _habitad   = txtHabitadPokemon.Text;


                if (_nombre.Equals(string.Empty))
                {
                    MessageBox.Show("Debe elegir un pokemon");
                }
                else
                {
                    //Crear pokemon (instanciar)
                    Pokemons pokemon1 = new Pokemons(_nombre, _especie, _habilidad, _peso, _altura, _color, _habitad);
                    MessageBox.Show($"nombre: {pokemon1.Nombre}", "titulo");
                    limpiarControles();


                    //Agregar el pokemon a la Grilla/Grid/Tabla/GridView
                    dgbPokemons.Rows.Add(nuFilas++, pokemon1.Nombre, pokemon1.Especie, pokemon1.Habilidad, pokemon1.Peso, pokemon1.Altura, pokemon1.Color, pokemon1.Habitad);
                }

                //Elegir pokemon rival
                Pokemons pokeRival = obtenerPokemonRival();

                //Imprimir
                mostrarDatosPokemonRival(pokeRival);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}");
            }
        }
        private float CalculateDamage(Pokemons attacker, Pokemons defender, Attack move)
        {
            if (move.category == 3 || move.index == 150) return 0; // Status move or splash

            float basedamage = move.damage;

            #region Effects

            if (move.index == 179 || move.index == 175) // Reversal, Flail
            {
                float x = attacker.hp * 100f / attacker.hpmax;
                if (x > 70) basedamage = 20;
                else if (x > 35) basedamage = 40;
                else if (x > 20) basedamage = 80;
                else if (x > 10) basedamage = 100;
                else if (x > 4) basedamage = 150;
                else basedamage = 200;
            }

            if (move.index == 222) // Magnitude
            {
                int z, x = rand.Next() % 100 + 1;
                if (x <= 5) { z = 4; basedamage = 10; }
                else if (x <= 15) { z = 5; basedamage = 30; }
                else if (x <= 35) { z = 6; basedamage = 50; }
                else if (x <= 65) { z = 7; basedamage = 70; }
                else if (x <= 85) { z = 8; basedamage = 90; }
                else if (x <= 95) { z = 9; basedamage = 110; }
                else { z = 10; basedamage = 150; }

                tbHistory.Text = "Magnitude " + z + "!\n" + tbHistory.Text;
            }

            if (move.index == 67 || move.index == 447) // Low Kick, Grass Knot
            {
                if (defender.weight <= 10) basedamage = 20;
                else if (defender.weight <= 25) basedamage = 40;
                else if (defender.weight <= 50) basedamage = 60;
                else if (defender.weight <= 100) basedamage = 80;
                else if (defender.weight <= 200) basedamage = 100;
                else basedamage = 120;
            }

            if (move.index == 255) // Spit Up
            {
                basedamage = 100 * attacker.Stockpile;
                attacker.Stockpile = 0;
            }

            if (move.index == 218) // Frustration
            {
                basedamage = (300 - attacker.love) / 2.5f;
            }

            if (move.index == 216) // Return
            {
                basedamage = (100 + attacker.love) / 2.5f;
            }

            if (move.index == 360) // Gyro Ball
            {
                basedamage = 25f * defender.tspeed / attacker.tspeed;
            }

            if (move.index == 323 || move.index == 284) // Water Spout, Eruption
            {
                basedamage = attacker.hp * move.damage / attacker.hpmax;
            }

            if (move.index == 462 || move.index == 378) // Crush Grip, Wring Out
            {
                basedamage = defender.hp * move.damage / defender.hpmax;
            }

            if (move.index == 376) // Trump Card
            {
                if (move.PP >= 4) basedamage = 40;
                else if (move.PP == 3) basedamage = 50;
                else if (move.PP == 2) basedamage = 60;
                else if (move.PP == 1) basedamage = 75;
                else if (move.PP == 0) basedamage = 190;
            }

            if (move.index == 386) // Punishment
            {
                float x;
                x = attacker.tatk / attacker.atk;
                while (x > 1.1)
                {
                    x /= 1.4f;
                    basedamage += 20;
                }
                x = attacker.tdef / attacker.def;
                while (x > 1.1)
                {
                    x /= 1.4f;
                    basedamage += 20;
                }
                x = attacker.tspatk / attacker.spatk;
                while (x > 1.1)
                {
                    x /= 1.4f;
                    basedamage += 20;
                }
                x = attacker.tspdef / attacker.spdef;
                while (x > 1.1)
                {
                    x /= 1.4f;
                    basedamage += 20;
                }
                x = attacker.tspeed / attacker.speed;
                while (x > 1.1)
                {
                    x /= 1.4f;
                    basedamage += 20;
                }
            }

            if (move.index == 217) // Present
            {
                int x = rand.Next() % 100 + 1;
                if (x <= 40) basedamage = 40;
                else if (x <= 70) basedamage = 80;
                else if (x <= 80) basedamage = 120;
                else basedamage = 0;
            }
            #endregion

            // base damage formula
            float damage = (2 * attacker.level + 10) * basedamage / 250f;

            // attack category (physical, special)
            switch (move.category)
            {
                case 1: damage *= attacker.tatk * 1f / defender.tdef; break;
                case 2: damage *= attacker.tspatk * 1f / defender.tspdef; break;
            }

            damage += 2;

            // same-type attack bonus
            if (move.type == attacker.type1 || move.type == attacker.type2)
                damage *= 1.5f;

            // effectiveness bonus
            damage *= Resources.effectiveness[move.type][defender.type1] * Resources.effectiveness[move.type][defender.type2];

            // love bonus
            if (attacker.love >= 100)
                damage *= (1 + (attacker.love - 100) / 400f);

            // random factor x [0.85,1]
            damage *= (100 - rand.Next() % 16) / 100f;

            damage = (float)Convert.ToDouble(damage.ToString("n2"));

            if (basedamage == 0 && move.index == 217) // Present
            {
                tbHistory.Text = defender.name + " was healed!\n" + tbHistory.Text;
                defender.hp += 80;
                if (defender.hp > defender.hpmax)
                    defender.hp = defender.hpmax;
                damage = 0;
            }

            return damage;
        }
 public void AddPokemon(Pokemons pokemon)
 {
     if (pokemons.Count < 6) pokemons.Add(pokemon);
     else pokemonsLab.Add(pokemon);
 }
        private void YourPokemonDies(Pokemons poke)
        {
            poke.hp = 0;
            ChangeHealth();

            poke.EarnLove(-5, 0, 0);

            // remove from not fainted list
            notFaintedPokemons.Remove(poke);

            bool found = false;

            // check if another pokemon is still alive
            for (int i = 0; i < player.pokemons.Count; ++i)
                if (player.pokemons[i].hp > 0)
                {
                    found = true;
                    firstChangeCrtPokemon = true;
                    ChangeCrtPokemon(i);
                    break;
                }

            // you lose
            if (!found)
            {
                waitTime = true;

                tbHistory.Text = "You lost the battle!\n" + tbHistory.Text;

                EndBattle(false);
            }
        }
        public FormBattle(Character trainer)
        {
            InitializeComponent();

            enemyTrainer = trainer;
            enemyPokemon = trainer.pokemons[0];
            tbHistory.Text = "You started a pokemon battle with " + trainer.name + "!";

            // set temporary stats
            for (int i = 0; i < trainer.pokemons.Count; ++i)
            {
                trainer.pokemons[i].SetTemporaryStats();
                trainer.pokemons[i].EraseAffections();
            }

            // see pokemon
            for (int i = 0; i < trainer.pokemons.Count; ++i)
            {
                FormPokedex.SeePokemon(trainer.pokemons[i].index);
            }

            Initialize();
        }
        private void Battle(Pokemons attacker, Pokemons defender, Attack move)
        {
            tbHistory.Text = "\n" + tbHistory.Text;

            // check if same attack
            if (attacker.sameAttack == 0)
            {
                attacker.sameAttack = -1;

                tbHistory.Text = attacker.name + " became confused!\n" + tbHistory.Text;
                attacker.EraseAffections();
                attacker.isConfused = 3;
            }
            else if (attacker.sameAttack > 0)
            {
                move = attacker.sameAttackDef;
                attacker.sameAttack -= 1;
            }

            if (move.index == 166) // Sketch
            {
                for (int i = 0; i < attacker.moves.Count; ++i)
                    if (attacker.moves[i].index == 166 && attacker.moves[i].PP == 0)
                    {
                        if (lastmove != null)
                            attacker.moves[i] = lastmove;
                        break;
                    }
            }

            lastmove = move;

            #region Affections

            // check for weather damage

            // sandstorm does not damage rock, ground and steel
            if (weatherType == 3 && attacker.type1 != 9 && attacker.type1 != 13 && attacker.type1 != 17
                && attacker.type2 != 9 && attacker.type2 != 13 && attacker.type2 != 17)
            {
                attacker.hp -= attacker.hpmax / 8f;
            }

            // hail does not damage ice
            if (weatherType == 4 && attacker.type1 != 6 && attacker.type2 != 6)
            {
                attacker.hp -= attacker.hpmax / 16f;
            }

            // check if attacker regenerates life
            if (attacker.isRegeneratingLife)
                if (attacker.HealBlock == 0)
                {
                    attacker.hp += attacker.hpmax / 16f;
                    if (attacker.hp > attacker.hpmax)
                        attacker.hp = attacker.hpmax;
                }

            // check if attacker is burnt or poisoned or seeded
            if (attacker.isBurnt > 0 || attacker.isPoisoned > 0 || attacker.isSeeded)
            {
                if (attacker.isBurnt > 0)
                {
                    tbHistory.Text = attacker.name + " is affected by burn!\n" + tbHistory.Text;
                    attacker.isBurnt -= 1;
                    attacker.hp -= attacker.hpmax / 8f;
                }

                if (attacker.isPoisoned > 0)
                {
                    tbHistory.Text = attacker.name + " is affected by poison!\n" + tbHistory.Text;
                    attacker.isPoisoned -= 1;
                    attacker.hp -= attacker.hpmax / 16f;
                }

                if (attacker.isSeeded)
                {
                    tbHistory.Text = attacker.name + " had his HP absorbed!\n" + tbHistory.Text;
                    float x = attacker.hpmax / 12f;
                    attacker.hp -= x;
                    if (defender.HealBlock == 0)
                    {
                        defender.hp += x;
                        if (defender.hp > defender.hpmax)
                            defender.hp = defender.hpmax;
                    }
                }
            }

            // check if pokemon is out of PP
            int PPtotal = 0;
            for (int i = 0; i < attacker.moves.Count; ++i)
            {
                PPtotal += attacker.moves[i].PP;
            }
            if (PPtotal == 0)
            {
                tbHistory.Text = attacker.name + " is out of PPs!\n" + tbHistory.Text;
                attacker.hp = 0;
            }

            bool userCanAttack = true;

            // check if attacker is confused
            if (attacker.isConfused > 0)
            {
                if (rand.Next() % 100 + 1 <= 50)
                {
                    tbHistory.Text = attacker.name + " is confused and hurt itself in confusion!\n" + tbHistory.Text;
                    attacker.hp -= 40;
                    userCanAttack = false;
                }
                attacker.isConfused -= 1;
            }

            ChangeHealth();

            // stop attacking if the attacker is not alive anymore
            if (attacker.hp <= 0)
            {
                if (yourPokemonIsAttacking)
                {
                    YourPokemonDies(attacker);
                }
                else
                {
                    EnemyPokemonDies(attacker);
                }

                return;
            }
            #endregion

            // check if attacker is paralyzed or frozen or asleep or flinch or cannot attack or is attracted
            if (attacker.isParalyzed > 0 || attacker.isFrozen > 0 || attacker.isAsleep > 0 || attacker.Flinch > 0 || attacker.canNotAttack || attacker.isAttracted)
            {
                #region Affections
                if (attacker.isParalyzed > 0)
                {
                    if (rand.Next() % 100 + 1 <= 50)
                    {
                        tbHistory.Text = attacker.name + " is paralyzed!\n" + tbHistory.Text;
                        userCanAttack = false;
                    }
                    attacker.isParalyzed -= 1;
                }
                if (attacker.isFrozen > 0)
                {
                    tbHistory.Text = attacker.name + " is frozen!\n" + tbHistory.Text;
                    attacker.isFrozen -= 1;
                    userCanAttack = false;
                }
                if (attacker.isAsleep > 0)
                {
                    if (rand.Next() % 100 + 1 >= 80) // wake up earlier
                    {
                        attacker.isAsleep = 0;
                        attacker.Nightmare = false;
                    }
                    else
                    {
                        if (attacker.Nightmare)
                        {
                            attacker.hp *= 0.75f;
                            tbHistory.Text = attacker.name + " is having a horrible nightmare!\n" + tbHistory.Text;
                        }

                        tbHistory.Text = attacker.name + " is asleep!\n" + tbHistory.Text;
                        attacker.isAsleep -= 1;

                        if (move.index != 173) // you can use Snore while asleep
                            userCanAttack = false;
                    }

                    if (attacker.isAsleep == 0)
                    {
                        tbHistory.Text = attacker.name + " woke up!\n" + tbHistory.Text;
                    }
                }
                if (attacker.Flinch > 0)
                {
                    tbHistory.Text = attacker.name + " flinched and couldn't move!\n" + tbHistory.Text;
                    attacker.Flinch -= 1;
                    userCanAttack = false;
                }
                if (attacker.canNotAttack)
                {
                    tbHistory.Text = attacker.name + " can not attack this turn!\n" + tbHistory.Text;
                    attacker.canNotAttack = false;
                    userCanAttack = false;
                }
                if (attacker.isAttracted)
                {
                    if (rand.Next() % 100 + 1 < 30)
                    {
                        tbHistory.Text = attacker.name + " is in love with " + defender.name + "!\n" + tbHistory.Text;
                        userCanAttack = false;
                    }
                }
                #endregion
            }

            if (defender.MagnetRise > 0)
                defender.MagnetRise -= 1;

            // two turn attack was intrerupted
            if (!userCanAttack && attacker.twoTurnAttack != -1)
                attacker.twoTurnAttack = -1;

            // Mist
            if (defender.isMist > 0)
                defender.isMist -= 1;

            // Reflect
            if (defender.Reflect > 0)
                defender.Reflect -= 1;

            // Light Screen
            if (defender.LightScreen > 0)
                defender.LightScreen -= 1;

            // Safe Guard
            if (defender.isSafeGuard > 0)
                defender.isSafeGuard -= 1;

            // Heal Block
            if (attacker.HealBlock > 0)
                attacker.HealBlock -= 1;

            if (userCanAttack)
            {
                if (attacker.twoTurnAttack != -1)
                {
                    tbHistory.Text = attacker.name + " dealt " + attacker.twoTurnAttack + " damage!\n" + tbHistory.Text;
                    defender.hp -= attacker.twoTurnAttack;

                    attacker.twoTurnAttack = -1;

                    ChangeHealth();

                    if (defender.hp <= 0)
                    {
                        if (!yourPokemonIsAttacking)
                        {
                            YourPokemonDies(defender);
                        }
                        else
                        {
                            EnemyPokemonDies(defender);
                        }
                        return;
                    }
                }
                else
                {
                    // check if attack miss

                    bool attackMissed = true;

                    if (rand.Next() % 100 + 1 <= move.accuracy * attacker.accuracy / defender.evasiveness)
                        attackMissed = false;

                    if (move.index == 87) // Thunder's accuracy depends on weather
                    {
                        int thunderAccuracy = move.accuracy;
                        if (weatherType == 1) thunderAccuracy = 100;
                        if (weatherType == 2) thunderAccuracy = 50;

                        attackMissed = true;
                        if (rand.Next() % 100 + 1 <= thunderAccuracy && rand.Next() % 100 + 1 <= attacker.accuracy)
                            attackMissed = false;
                    }

                    if (move.index == 351 || move.index == 443 || move.index == 185
                        || move.index == 396 || move.index == 233 || move.index == 332
                        || move.index == 325 || move.index == 345 || move.index == 129)
                        // Never miss: Shock Wave, Magnet Bomb, Faint Attack, Aura Sphere, Vital Throw, Aerial Ace
                        // Shadow Punch, Magical Leaf, Swift
                        attackMissed = false;

                    if (!attackMissed)
                    {
                        if (move.type == 2 && defender.isFrozen > 0) // Fire-type moves defrost defender
                        {
                            tbHistory.Text = move.name + " dispelled the frozen effect from " + defender.name + "!\n" + tbHistory.Text;
                            defender.isFrozen = 0;
                        }

                        if (move.index == 210) // Fury Cutter
                        {
                            if (attacker.FuryCutter < 5)
                                attacker.FuryCutter += 1;
                        }
                        else attacker.FuryCutter = 0;

                        if (move.category != 3) // Physical, Special moves
                        {
                            float damage = CalculateDamage(attacker, defender, move);

                            #region Effects

                            int criticalChance = attacker.critical;

                            if (move.index == 75 || move.index == 2 || move.index == 152
                                || move.index == 444 || move.index == 440 || move.index == 342
                                || move.index == 460 || move.index == 454 || move.index == 400
                                || move.index == 238 || move.index == 299 || move.index == 177
                                || move.index == 314 || move.index == 421 || move.index == 163
                                || move.index == 348 || move.index == 427)
                                // Critical chance: Razor Leaf, Karate Chop, Crabhammer, Stone Edge, Cross Poison,
                                // Poison Tail, Special Rend, Attack Order, Night Slash, Cross Chop, Blaze Kick,
                                // Aeroblast, Air Cutter, Shadow Claw, Slash, Leaf Blade, Psycho Cut
                                criticalChance += 20;

                            if (attacker.isCritChanted)
                                criticalChance = 0;

                            if (rand.Next() % 100 + 1 <= criticalChance)
                            {
                                tbHistory.Text = "Critical Hit!\n" + tbHistory.Text;
                                damage *= 2;
                            }

                            if (weatherType == 1 && move.type == 3)
                                damage *= 1.125f;

                            if (weatherType == 2 && move.type == 2)
                                damage *= 1.125f;

                            if (defender.isWaterSported && move.type == 2)
                                damage *= 0.75f;

                            if (attacker.isCharged)
                            {
                                attacker.isCharged = false;
                                if (move.type == 4) damage *= 1.5f;
                            }

                            if (move.index == 387) // Last Resort
                            {
                                bool tmp = true;
                                for (int i = 0; i < attacker.moves.Count; ++i)
                                {
                                    if (attacker.moves[i].index != 387 && attacker.moves[i].PP > 0)
                                        tmp = false;
                                }
                                if (!tmp) damage = 0;
                            }

                            if (move.index == 263) // Bonus for affections: Facade
                            {
                                if (attacker.isPoisoned > 0 || attacker.isParalyzed > 0 || attacker.isBurnt > 0)
                                    damage *= 2;
                            }

                            if (move.index == 283) // Enemy life = your life: Endeavor
                            {
                                if (defender.hp > attacker.hp) damage = defender.hp - attacker.hp;
                                else damage = 0;
                            }

                            if (move.index == 12 || move.index == 32 || move.index == 329
                                || move.index == 90) // K.O.: Guillotine, Horn Drill, Sheer Cold, Fissure
                            {
                                damage = defender.hpmax;
                            }

                            if (move.index == 362) // Double attack if hp lower than half: Brine
                                if (defender.hp <= defender.hpmax / 2f)
                                {
                                    damage *= 2;
                                }

                            if (move.index == 24 || move.index == 41 || move.index == 155
                                || move.index == 458) // 2 attacks: Double Kick, Twineedle, Bonemerang, Double Hit
                            {
                                int hits = 2;
                                tbHistory.Text = move.name + " hit " + hits + " times!\n" + tbHistory.Text;
                                damage *= hits;
                            }

                            if (move.index == 167) // 1-3 attacks: Triple Kick
                            {
                                int hits = rand.Next() % 2 + 1;
                                tbHistory.Text = move.name + " hit " + hits + " times!\n" + tbHistory.Text;
                                damage *= hits;
                            }

                            if (move.index == 3 || move.index == 4 || move.index == 31
                                || move.index == 42 || move.index == 350 || move.index == 333
                                || move.index == 292 || move.index == 331 || move.index == 198
                                || move.index == 140 || move.index == 154 || move.index == 131)
                            // 2-5 attacks: Double Slap, Comet Punch, Fury Attack, Pin Missile, Rock Blast,
                            // Icicle Spear, Arm Thrust, Bullet Seed, Bone Rush, Barrage, Fury Swipes, Spike Cannon
                            {
                                int hits = rand.Next() % 4 + 2;
                                tbHistory.Text = move.name + " hit " + hits + " times!\n" + tbHistory.Text;
                                damage *= hits;
                            }

                            if (move.index == 71 || move.index == 72 || move.index == 141
                                || move.index == 409 || move.index == 202)
                                // Life drain: Absorb, Mega Drain, Leech Life, Drain Punch, Giga Drain
                                if (attacker.HealBlock == 0)
                                {
                                    attacker.hp += damage * 0.5f;
                                    if (attacker.hp > attacker.hpmax)
                                        attacker.hp = attacker.hpmax;
                                }

                            if (move.index == 138) // Attack while enemy asleep: Dream Eater
                            {
                                if (defender.isAsleep > 0)
                                {
                                    if (attacker.HealBlock == 0)
                                    {
                                        attacker.hp += damage * 0.5f;
                                        if (attacker.hp > attacker.hpmax)
                                            attacker.hp = attacker.hpmax;
                                    }
                                }
                                else damage = 0;
                            }

                            if (move.index == 173) // Attack while asleep: Snore
                            {
                                if (attacker.isAsleep > 0)
                                {
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        defender.Flinch = 1;
                                    }
                                }
                                else damage = 0;
                            }

                            if (move.index == 69 || move.index == 101 || move.index == 149)
                                // damage = level: Seismic Toss, Night Shade, Psywave
                                damage = attacker.level;

                            if (move.index == 149) // Bonus 1-1.5: Psywave
                                damage *= (rand.Next() % 6 + 10) / 10f;

                            if (move.index == 265) // Bonus if enemy paralyzed: Smelling Salts
                            {
                                if (defender.isParalyzed > 0)
                                    damage *= 2;
                            }

                            if (move.index == 162) // 1/2 HP damage: Super Fang
                                damage = defender.hp * 0.5f;

                            if (move.index == 82) // 40 damage: Dragon Rage
                                damage = 40;

                            if (move.index == 49) // 20 damage: Sonic Boom
                                damage = 20;

                            if (move.index == 6) // Bonus money: Pay Day
                                winMoney += 100;

                            if (move.index == 264) // Attack second - failed attack: Focus Punch
                                if (!youAttackFirst)
                                {
                                    damage = 0;
                                    tbHistory.Text = attacker.name + " flinched before attacking!\n" + tbHistory.Text;
                                }

                            if (move.index == 371 || move.index == 228 || move.index == 279
                                || move.index == 372 || move.index == 419)
                                // Attack second - double damage: Payback, Pursuit, Revenge, Assurance, Avalanche
                                if (!youAttackFirst) damage *= 2;

                            if (move.index == 63 || move.index == 308 || move.index == 439
                                || move.index == 459 || move.index == 307 || move.index == 338
                                || move.index == 416)
                            // Cannot attack next turn: Hyper Beam, Hydro Cannon, Rock Wrecker, Roar of Time,
                            // Blast Burn, Frenzy Plant, Giga Impact
                            {
                                attacker.canNotAttack = true;
                            }

                            if (defender.isSafeGuard == 0)
                            {
                                #region Affections

                                if (move.index == 7 || move.index == 52 || move.index == 53
                                    || move.index == 299 || move.index == 126 || move.index == 424
                                    || move.index == 257 || move.index == 436 || move.index == 221
                                    || move.index == 161)
                                    // Burn: Fire Punch, Ember, Flamethrower, Blaze Kick, Fire Blast, Fire Fang,
                                    // Heat Wave, Sacred Fire, Tri Attack
                                    if (rand.Next() % 100 + 1 <= 10 && defender.type1 != 2 && defender.type2 != 2)
                                    {
                                        tbHistory.Text = defender.name + " was burnt!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isBurnt = 3;
                                    }

                                if (move.index == 40 || move.index == 41 || move.index == 440 || move.index == 441
                                    || move.index == 305 || move.index == 398 || move.index == 342 || move.index == 124
                                    || move.index == 188)
                                    // Poison: Poison Sting, Twineedle, Cross Poison, Gunk Shot, Poison Fang, Poison Jab
                                    // Poison Tail, Sludge, Sludge Bomb
                                    if (rand.Next() % 100 + 1 <= 10 && defender.type1 != 8 && defender.type2 != 8
                                        && defender.type1 != 17 && defender.type2 != 17)
                                    {
                                        tbHistory.Text = defender.name + " was poisoned!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isPoisoned = 3;
                                    }

                                if (move.index == 8 || move.index == 58 || move.index == 59
                                    || move.index == 423 || move.index == 181 || move.index == 161)
                                    // Freeze: Ice Punch, Ice Beam, Blizzard, Ice Fang, Powder Snow, Tri Attack
                                    if (rand.Next() % 100 + 1 <= 10 && defender.type1 != 6 && defender.type2 != 6)
                                    {
                                        tbHistory.Text = defender.name + " was frozen!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isFrozen = 3;
                                    }

                                if (move.index == 60 || move.index == 352 || move.index == 324
                                    || move.index == 448 || move.index == 93 || move.index == 146
                                    || move.index == 431)
                                    // Confusion: Psybeam, Water Pulse, Signal Beam, Chatter, Confusion, Dizzy Punch,
                                    // Rock Climb
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        tbHistory.Text = defender.name + " became confused!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isConfused = 3;
                                    }

                                if (move.index == 223) // Confusion 100%: Dynamic Punch
                                {
                                    tbHistory.Text = defender.name + " became confused!\n" + tbHistory.Text;
                                    defender.EraseAffections();
                                    defender.isConfused = 3;
                                }

                                if (move.index == 9 || move.index == 34 || move.index == 84
                                    || move.index == 85 || move.index == 87 || move.index == 435
                                    || move.index == 209 || move.index == 422 || move.index == 344
                                    || move.index == 225 || move.index == 395 || move.index == 340
                                    || move.index == 122 || move.index == 161)
                                    // Paralyze: Thunder Punch, Body Slam, Thunder Shock, Thunderbolt, Thunder
                                    // Discharge, Spark, Thunder Fang, Volt Tackle, Dragon Breath, Force Palm,
                                    // Bounce, Lick, Tri Attack
                                    if (rand.Next() % 100 + 1 <= 10 && defender.type1 != 4 && defender.type2 != 4)
                                    {
                                        tbHistory.Text = defender.name + " was paralyzed!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isParalyzed = 3;
                                    }

                                if (move.index == 192) // Paralyze 100%: Zap Cannon
                                    if (defender.type1 != 4 && defender.type2 != 4)
                                    {
                                        tbHistory.Text = defender.name + " was paralyzed!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isParalyzed = 3;
                                    }

                                #endregion
                            }

                            if (move.index == 23 || move.index == 27 || move.index == 29
                                || move.index == 44 || move.index == 422 || move.index == 127
                                || move.index == 442 || move.index == 157 || move.index == 407
                                || move.index == 423 || move.index == 399 || move.index == 424
                                || move.index == 403 || move.index == 310 || move.index == 302
                                || move.index == 125 || move.index == 326 || move.index == 428
                                || move.index == 158)
                                // Flinch: Stomp, Rolling Kick, Headbutt, Bite, Thunder Fang, Waterfall
                                // Iron Head, Rock Slide, Dragon Rush, Ice Fang, Dark Pulse, Fire Fang,
                                // Air Slash, Sky Attack, Astonish, Needle Arm, Bone Club, Extrasensory,
                                // Zen Headbutt, Hyper Fang
                                if (rand.Next() % 100 + 1 <= 10)
                                {
                                    defender.Flinch = 1;
                                }

                            if (defender.isMist == 0)
                            {
                                #region Stats Reduction

                                if (move.index == 51) // Decrease attack: Aurora Beam
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.tatk <= defender.tatk * 0.41f)
                                        {
                                            tbHistory.Text = defender.name + "'s attack can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.tatk *= 0.8f;
                                            tbHistory.Text = defender.name + " had his attack lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                if (move.index == 296) // Decrease special attack: Mist Ball
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.tspatk <= defender.spatk * 0.41f)
                                        {
                                            tbHistory.Text = defender.name + "'s special attack can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.tspatk *= 0.8f;
                                            tbHistory.Text = defender.name + " had his special attack lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                if (move.index == 231 || move.index == 242 || move.index == 249
                                    || move.index == 306) // Decrease defense: Iron Tail, Crunch, Rock Smash, Crush Claw
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.tdef <= defender.def * 0.41f)
                                        {
                                            tbHistory.Text = defender.name + "'s defense can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.tdef *= 0.8f;
                                            tbHistory.Text = defender.name + " had his defense lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                if (move.index == 370) // Decrease defense 100%: Close Combat
                                {
                                    if (defender.tdef <= defender.def * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s defense can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tdef *= 0.8f;
                                        tbHistory.Text = defender.name + " had his defense lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 330 || move.index == 190 || move.index == 429
                                    || move.index == 426 || move.index == 189)
                                    // Decrease accuracy: Muddy Water, Octazooka, Mirror Shot, Mud Bomb, Mud Slap
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.accuracy <= 41)
                                        {
                                            tbHistory.Text = defender.name + "'s accuracy can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.accuracy *= 0.8f;
                                            tbHistory.Text = defender.name + " had his accuracy lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                if (move.index == 51 || move.index == 430 || move.index == 405
                                    || move.index == 411 || move.index == 247 || move.index == 412
                                    || move.index == 414 || move.index == 295 || move.index == 94)
                                    // Decrease special defense: Acid, Flash Cannon, Bug Buzz, Focus Blast,
                                    // Shadow Ball, Energy Ball, Earth Power, Luster Purge, Psychic
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.tspdef <= defender.spdef * 0.41f)
                                        {
                                            tbHistory.Text = defender.name + "'s special defense can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.tspdef *= 0.8f;
                                            tbHistory.Text = defender.name + " had his special defense lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                if (move.index == 465) // Decrease special defense x2: Seed Flare
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.tspdef <= defender.spdef * 0.41f)
                                        {
                                            tbHistory.Text = defender.name + "'s special defense can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.tspdef *= 0.64f;
                                            tbHistory.Text = defender.name + " had his special defense lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                if (move.index == 370) // Decrease special defense 100%: Close Combat
                                {
                                    if (defender.tspdef <= defender.spdef * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s special defense can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tspdef *= 0.8f;
                                        tbHistory.Text = defender.name + " had his special defense lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 61 || move.index == 145 || move.index == 317
                                    || move.index == 196 || move.index == 132 || move.index == 341)
                                    // Decrease speed: Bubble Beam, Bubble, Rock Tomb, Icy Wind, Constrict, Mud Shot
                                    if (rand.Next() % 100 + 1 <= 10)
                                    {
                                        if (defender.tspeed <= defender.speed * 0.41f)
                                        {
                                            tbHistory.Text = defender.name + "'s speed can not be decreased anymore.\n" + tbHistory.Text;
                                        }
                                        else
                                        {
                                            defender.tspeed *= 0.8f;
                                            tbHistory.Text = defender.name + " had his speed lowered.\n" + tbHistory.Text;
                                        }
                                    }

                                #endregion
                            }

                            #region Stats Raised

                            if (move.index == 130) // Raised defense 100%: Skull Bash
                            {
                                if (attacker.tdef >= 3.8f * attacker.def)
                                {
                                    tbHistory.Text = attacker.name + "'s defense can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tdef *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s defense rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 451) // Raised special attack: Charge Beam
                                if (rand.Next() % 100 + 1 <= 10)
                                {
                                    if (attacker.tspatk >= 3.8f * attacker.spatk)
                                    {
                                        tbHistory.Text = attacker.name + "'s special attack can not be increased anymore!\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        attacker.tspatk *= 1.4f;
                                        tbHistory.Text = attacker.name + "'s special attack rose!\n" + tbHistory.Text;
                                    }
                                }

                            if (move.index == 232 || move.index == 309) // Raised attack: Metal Claw, Meteor Mash
                                if (rand.Next() % 100 + 1 <= 10)
                                {
                                    if (attacker.tatk >= 3.8f * attacker.atk)
                                    {
                                        tbHistory.Text = attacker.name + "'s attack can not be increased anymore!\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        attacker.tatk *= 1.4f;
                                        tbHistory.Text = attacker.name + "'s attack rose!\n" + tbHistory.Text;
                                    }
                                }

                            if (move.index == 99) // Raised attack 100%: Rage
                            {
                                if (attacker.tatk >= 3.8f * attacker.atk)
                                {
                                    tbHistory.Text = attacker.name + "'s attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tatk *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s attack rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 246 || move.index == 318) // Raised all stats: Ancient Power, Silver Wind
                                if (rand.Next() % 100 + 1 <= 10)
                                {
                                    if (attacker.tatk <= 3.8f * attacker.atk) attacker.tatk *= 1.4f;
                                    if (attacker.tdef <= 3.8f * attacker.atk) attacker.tdef *= 1.4f;
                                    if (attacker.tspatk <= 3.8f * attacker.atk) attacker.tspatk *= 1.4f;
                                    if (attacker.tspdef <= 3.8f * attacker.atk) attacker.tspdef *= 1.4f;
                                    if (attacker.tspeed >= 3.8f * attacker.speed) attacker.tspeed *= 1.4f;

                                    tbHistory.Text = attacker.name + " had his stats increased!\n" + tbHistory.Text;
                                }

                            #endregion

                            if (move.index == 434 || move.index == 315 || move.index == 437
                                || move.index == 354)
                            // Recoil - decrease special attack x2: Draco Meteor, Overheat, Leaf Storm, Psycho Boost
                            {
                                if (attacker.tspatk >= attacker.spatk * 0.41f)
                                    attacker.tspatk *= 0.64f;
                            }

                            if (move.index == 359) // Recoil - decrease speed: Hammer Arm
                            {
                                if (attacker.tspeed >= attacker.speed * 0.41f)
                                    attacker.tspeed *= 0.8f;
                            }

                            if (move.index == 276) // Recoil - decrease attack: Superpower
                            {
                                if (attacker.tatk >= attacker.atk * 0.41f)
                                    attacker.tatk *= 0.64f;
                            }

                            if (move.index == 276) // Recoil - decrease defense: Superpower
                            {
                                if (attacker.tdef >= attacker.def * 0.41f)
                                    attacker.tdef *= 0.64f;
                            }

                            if (move.index == 36) // Self-damage: Take Down
                            {
                                attacker.hp *= 0.84f;
                            }

                            if (move.index == 38 || move.index == 344 || move.index == 457
                                || move.index == 394 || move.index == 413 || move.index == 452)
                            // Self-damage: Double-Edge, Volt Tackle, Head Smash, Flare Blitz, Brave Bird, Wood Hammer
                            {
                                attacker.hp *= 0.67f;
                            }

                            if (move.index == 66) // Self-damage: Submission
                            {
                                attacker.hp -= damage * 0.25f;
                                if (attacker.hp <= 1) attacker.hp = 1;
                            }

                            if (move.index == 20 || move.index == 35 || move.index == 83
                                || move.index == 128 || move.index == 250 || move.index == 463
                                || move.index == 328)
                            // Trapped: Bind, Wrap, Fire Spin, Clamp, Whirlpool, Magma Storm, Sand Tomb
                            {
                                int x = rand.Next() % 4 + 2;
                                if (x > defender.isTrapped) defender.isTrapped = x;
                            }

                            if (move.index == 358) // Wake-up Slap
                                if (defender.isAsleep > 0)
                                {
                                    damage *= 2;
                                    defender.isAsleep = 0;
                                    tbHistory.Text = defender.name + " woke up!\n" + tbHistory.Text;
                                }

                            if (move.index == 280) // Destroy LightScreen/Reflect: Brick Break
                            {
                                defender.LightScreen = 0;
                                defender.Reflect = 0;
                            }

                            if (move.index == 229) // Free from trapped: Rapid Spin
                                attacker.isTrapped = 0;

                            if (move.index == 229) // Free from Leech Seed: Rapid Spin
                                attacker.isSeeded = false;

                            if (move.index == 210) // Fury Cutter
                            {
                                damage *= attacker.FuryCutter;
                            }

                            if (move.type == 9 && defender.MagnetRise > 0) // Magnet Rise: Immune to ground-attacks
                            {
                                damage = 0;
                            }

                            if (move.index == 205 || move.index == 301)
                            // Same attack 5 turns - stronger: Rollout, Ice Ball
                            {
                                if (attacker.sameAttack == -1)
                                {
                                    attacker.sameAttack = 4;
                                    attacker.sameAttackDef = move;
                                }
                                else
                                {
                                    damage += damage * (4 - attacker.sameAttack) * 0.5f;
                                }
                            }

                            if (move.index == 80 || move.index == 37 || move.index == 200
                                || move.index == 353)
                                // Same attack 2-3 turns: Petal Dance, Thrash, Outrage, Doom Desire
                                if (attacker.sameAttack == -1)
                                {
                                    attacker.sameAttack = rand.Next() % 2 + 1;
                                    attacker.sameAttackDef = move;
                                }

                            if (move.category == 1 && defender.Reflect > 0) // Reflect
                                damage *= 0.5f;

                            if (move.category == 2 && defender.LightScreen > 0) // Light Screen
                                damage *= 0.5f;

                            if (move.index == 467 || move.index == 19 || move.index == 291
                                || move.index == 91)
                            // Protected for the next attack: Shadow Force, Fly, Dive, Dig
                            {
                                attacker.isProtected = true;
                            }

                            if (move.index == 76 || move.index == 467 || move.index == 19
                                || move.index == 291 || move.index == 13 || move.index == 130
                                || move.index == 91)
                            // Two-turn attack: Solar Beam, Shadow Force, Fly, Dive, Razor Wind, Skull Bash, Dig
                            {
                                if (move.index == 13 && rand.Next() % 100 + 1 <= 25) // Razor Wind
                                    damage *= 2;

                                attacker.twoTurnAttack = damage;
                                tbHistory.Text = attacker.name + " used " + move.name + ".\n" + tbHistory.Text;
                            }

                            if (move.index == 153 || move.index == 120) // Faint: Explosion, Self-Destruct
                            {
                                attacker.hp = 0;

                                if (yourPokemonIsAttacking)
                                {
                                    YourPokemonDies(attacker);
                                }
                                else
                                {
                                    EnemyPokemonDies(attacker);
                                }
                            }

                            if (move.index == 206) // Enemy can not faint
                            {
                                if (defender.hp - damage < 1) damage = defender.hp - 1;
                            }

                            #endregion

                            if (!defender.isProtected)
                            {
                                if (attacker.twoTurnAttack == -1)
                                {
                                    defender.hp -= damage;
                                    tbHistory.Text = attacker.name + " used " + move.name + " and dealt " + damage + " damage.\n" + tbHistory.Text;
                                }
                            }
                            else
                            {
                                tbHistory.Text = attacker.name + " used " + move.name + ".\n" + tbHistory.Text;
                                tbHistory.Text = defender.name + " was protected.\n" + tbHistory.Text;
                                defender.isProtected = false;
                            }

                            ChangeHealth();

                            if (defender.hp <= 0)
                            {
                                if (!yourPokemonIsAttacking)
                                {
                                    YourPokemonDies(defender);
                                }
                                else
                                {
                                    EnemyPokemonDies(defender);
                                    return;
                                }
                            }

                        } // Status moves
                        else
                        {
                            tbHistory.Text = attacker.name + " used " + move.name + "!\n" + tbHistory.Text;

                            #region Effects

                            if (defender.isSafeGuard == 0)
                            {
                                #region Affections
                                if (move.index == 47 || move.index == 79 || move.index == 464
                                    || move.index == 320 || move.index == 147 || move.index == 95
                                    || move.index == 142)
                                // Sleep: Sing, Sleep Powder, Dark Void, Grass Whistle, Spore, Hypnosis, Lovely Kiss
                                {
                                    tbHistory.Text = defender.name + " fell asleep!\n" + tbHistory.Text;
                                    defender.EraseAffections();
                                    defender.isAsleep = 3;
                                }

                                if (move.index == 281) // Sleep both: Yawn
                                {
                                    tbHistory.Text = defender.name + " fell asleep!\n" + tbHistory.Text;
                                    defender.EraseAffections();
                                    defender.isAsleep = 1;

                                    tbHistory.Text = attacker.name + " fell asleep!\n" + tbHistory.Text;
                                    attacker.EraseAffections();
                                    attacker.isAsleep = 1;
                                }

                                if (move.index == 48) // Confusion: Supersonic
                                    if (rand.Next() % 100 + 1 <= 75)
                                    {
                                        tbHistory.Text = defender.name + " became confused!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isConfused = 3;
                                    }

                                if (move.index == 260 || move.index == 109 || move.index == 207
                                    || move.index == 186 || move.index == 298)
                                // Confusion 100%: Flatter, Confuse Ray, Swagger, Sweet Kiss, Teeter Dance
                                {
                                    tbHistory.Text = defender.name + " became confused!\n" + tbHistory.Text;
                                    defender.EraseAffections();
                                    defender.isConfused = 3;
                                }

                                if (move.index == 298) // Self-Confusion: Teeter Dance
                                {
                                    tbHistory.Text = attacker.name + " became confused!\n" + tbHistory.Text;
                                    attacker.EraseAffections();
                                    attacker.isConfused = 3;
                                }

                                if (move.index == 77 || move.index == 139) // Poison: Poison Powder, Poison Gas
                                    if (rand.Next() % 100 + 1 <= 75 && defender.type1 != 8 && defender.type2 != 8
                                        && defender.type1 != 17 && defender.type2 != 17)
                                    {
                                        tbHistory.Text = defender.name + " was poisoned!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isPoisoned = 3;
                                    }

                                if (move.index == 92) // Poison 100%: Toxic
                                    if (defender.type1 != 8 && defender.type2 != 8 && defender.type1 != 17 && defender.type2 != 17)
                                    {
                                        tbHistory.Text = defender.name + " was poisoned!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isPoisoned = 3;
                                    }

                                if (move.index == 261) // Burn: Will-o-wisp
                                    if (defender.type1 != 2 && defender.type2 != 2)
                                    {
                                        tbHistory.Text = defender.name + " was burnt!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isBurnt = 3;
                                    }

                                if (move.index == 78) // Paralyze: Stun Spore
                                    if (rand.Next() % 100 + 1 <= 75 && defender.type1 != 4 && defender.type2 != 4)
                                    {
                                        tbHistory.Text = defender.name + " was paralyzed!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isParalyzed = 3;
                                    }

                                if (move.index == 86 || move.index == 137) // Paralyze 100%: Thunder Wave, Glare
                                    if (defender.type1 != 4 && defender.type2 != 4)
                                    {
                                        tbHistory.Text = defender.name + " was paralyzed!\n" + tbHistory.Text;
                                        defender.EraseAffections();
                                        defender.isParalyzed = 3;
                                    }
                                #endregion
                            }

                            if (move.index == 182 || move.index == 197 || move.index == 203) // Protected for the next attack: Protect, Detect, Endure
                                if (rand.Next() % 100 + 1 <= 100 / move.PPmax * (move.PP + 1))
                                {
                                    attacker.isProtected = true;
                                }

                            if (move.index == 219) // Safe Guard
                            {
                                attacker.isSafeGuard = 5;
                            }

                            if (move.index == 433) // Trick Room
                            {
                                if (trickRoom < 5) trickRoom = 5;
                            }

                            if (move.index == 115) // Reflect
                            {
                                attacker.Reflect = 5;
                            }

                            if (move.index == 113) // LightScreen
                            {
                                attacker.LightScreen = 5;
                            }

                            if (move.index == 432) // Remove Reflect/Light Screen/Safeguard/Mist: Defog
                            {
                                defender.Reflect = 0;
                                defender.LightScreen = 0;
                                defender.isSafeGuard = 0;
                                defender.isMist = 0;
                            }

                            if (move.index == 54) // Mist
                            {
                                attacker.isMist = 5;
                            }

                            if (defender.isMist == 0)
                            {
                                #region Stats Reduction

                                if (move.index == 45 || move.index == 321) // Decrease attack: Growl, Tickle
                                {
                                    if (defender.tatk <= defender.atk * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s attack can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tatk *= 0.8f;
                                        tbHistory.Text = defender.name + " had his attack lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 297 || move.index == 262 || move.index == 204) // Decrease attack x2: Feather Dance, Memento, Charm
                                {
                                    if (defender.tatk <= defender.atk * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s attack can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tatk *= 0.64f;
                                        tbHistory.Text = defender.name + " had his attack lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if ((move.index == 445 && defender.gender == 1 - attacker.gender) || move.index == 262) // Decrease special attack x2: Captivate, Memento
                                {
                                    if (defender.tspatk <= defender.spatk * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s special attack can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tspatk *= 0.64f;
                                        tbHistory.Text = defender.name + " had his special attack lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 39 || move.index == 43 || move.index == 321) // Decrease defense: Tail Whip, Leer, Tickle
                                {
                                    if (defender.tdef <= defender.def * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s defense can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tdef *= 0.8f;
                                        tbHistory.Text = defender.name + " had his defense lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 319 || move.index == 103) // Decrease defense x2: Metal Sound, Screech
                                {
                                    if (defender.tdef <= defender.def * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s defense can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tdef *= 0.64f;
                                        tbHistory.Text = defender.name + " had his defense lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 313) // Decrease special defense x2: Fake Tears
                                {
                                    if (defender.tspdef <= defender.spdef * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s special defense can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tspdef *= 0.64f;
                                        tbHistory.Text = defender.name + " had his special defense lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 108 || move.index == 28 || move.index == 134
                                    || move.index == 148) // Decrease accuracy: Smokescreen, Sand Attack, Kinesis, Flash
                                {
                                    if (defender.accuracy <= 41)
                                    {
                                        tbHistory.Text = defender.name + "'s accuracy can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.accuracy *= 0.8f;
                                        tbHistory.Text = defender.name + " had his accuracy lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 81) // Decrease speed: String Shot
                                {
                                    if (defender.tspeed <= defender.speed * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s speed can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tspeed *= 0.8f;
                                        tbHistory.Text = defender.name + " had his speed lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 184 || move.index == 178) // Decrease speed x2: Scary Face, Cotton Spore
                                {
                                    if (defender.tspeed <= defender.speed * 0.41f)
                                    {
                                        tbHistory.Text = defender.name + "'s speed can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.tspeed *= 0.64f;
                                        tbHistory.Text = defender.name + " had his speed lowered.\n" + tbHistory.Text;
                                    }
                                }

                                if (move.index == 230) // Decrease evasiveness: Sweet Scent
                                {
                                    if (defender.evasiveness <= 41)
                                    {
                                        tbHistory.Text = defender.name + "'s evasiveness can not be decreased anymore.\n" + tbHistory.Text;
                                    }
                                    else
                                    {
                                        defender.evasiveness *= 0.8f;
                                        tbHistory.Text = defender.name + " had his evasiveness lowered.\n" + tbHistory.Text;
                                    }
                                }

                                #endregion
                            }

                            #region Stats Raised

                            int randomStat = 0;
                            if (move.index == 367) // Raised random stats x2: Acupressure
                            {
                                randomStat = rand.Next() % 5 + 1;
                            }

                            if (move.index == 397 || move.index == 294 || move.index == 97
                                || randomStat == 1) // Raised speed x2: Rock Polish, Tail Glow, Agility
                            {
                                if (attacker.tspeed >= 3.8f * attacker.speed)
                                {
                                    tbHistory.Text = attacker.name + "'s speed can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tspeed *= 1.96f;
                                    tbHistory.Text = attacker.name + "'s speed sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 187) // Raised attack x4: Belly Drum
                            {
                                if (attacker.hp > attacker.hpmax * 0.5f)
                                {
                                    attacker.hp -= attacker.hpmax * 0.5f;
                                    attacker.tatk = attacker.atk * 3.8416f;
                                    tbHistory.Text = attacker.name + "'s attack was maximized!\n" + tbHistory.Text;
                                }
                                else tbHistory.Text = attacker.name + "'s HP is too low to use Belly Drum!\n" + tbHistory.Text;
                            }

                            if (move.index == 14 || randomStat == 2) // Raised attack x2: Swords Dance
                            {
                                if (attacker.tatk >= 3.8f * attacker.atk)
                                {
                                    tbHistory.Text = attacker.name + "'s attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tatk *= 1.96f;
                                    tbHistory.Text = attacker.name + "'s attack sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 334 || move.index == 151 || move.index == 112
                                || randomStat == 3) // Raised defense x2: Iron Defense, Acid Armor, Barrier
                            {
                                if (attacker.tdef >= 3.8f * attacker.def)
                                {
                                    tbHistory.Text = attacker.name + "'s defense can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tdef *= 1.96f;
                                    tbHistory.Text = attacker.name + "'s defense sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 110 || move.index == 455 || move.index == 339
                                || move.index == 106 || move.index == 322 || move.index == 111
                                || move.index == 254)
                            // Raised defense: Withdraw, Defend Order, Bulk Up, Harden, Cosmic Power, Defense Curl
                            // Stockpile
                            {
                                if (attacker.tdef >= 3.8f * attacker.def)
                                {
                                    tbHistory.Text = attacker.name + "'s defense can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tdef *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s defense rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 349 || move.index == 339 || move.index == 96
                                || move.index == 336 || move.index == 159)
                            // Raised attack: Dragon Dance, Bulk Up, Meditate, Howl, Sharpen
                            {
                                if (attacker.tatk >= 3.8f * attacker.atk)
                                {
                                    tbHistory.Text = attacker.name + "'s attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tatk *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s attack rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 74 || move.index == 347) // Raised special attack: Growth, Calm Mind
                            {
                                if (attacker.tspatk >= 3.8f * attacker.spatk)
                                {
                                    tbHistory.Text = attacker.name + "'s special attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tspatk *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s special attack rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 417 || randomStat == 4) // Raised special attack x2: Nasty Plot
                            {
                                if (attacker.tspatk >= 3.8f * attacker.spatk)
                                {
                                    tbHistory.Text = attacker.name + "'s special attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tspatk *= 1.96f;
                                    tbHistory.Text = attacker.name + "'s special attack sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 268 || move.index == 455 || move.index == 347
                                || move.index == 322 || move.index == 254)
                            // Raised special defense: Charge, Defend Order, Calm Mind, Cosmic Power, Stockpile
                            {
                                if (attacker.tspdef >= 3.8f * attacker.spdef)
                                {
                                    tbHistory.Text = attacker.name + "'s special defense can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tspdef *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s special defense rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 133 || randomStat == 5) // Raised special defense x2: Amnesia
                            {
                                if (attacker.tspdef >= 3.8f * attacker.spdef)
                                {
                                    tbHistory.Text = attacker.name + "'s special defense can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tspdef *= 1.96f;
                                    tbHistory.Text = attacker.name + "'s special defense sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 349 || move.index == 366) // Raised speed: Dragon Dance, Tailwind
                            {
                                if (attacker.tspeed >= 3.8f * attacker.speed)
                                {
                                    tbHistory.Text = attacker.name + "'s speed can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.tspeed *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s speed rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 107 || move.index == 104) // Raised evasiveness: Minimize, Double Team
                            {
                                if (attacker.evasiveness >= 380)
                                {
                                    tbHistory.Text = attacker.name + "'s evasiveness can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    attacker.evasiveness *= 1.4f;
                                    tbHistory.Text = attacker.name + "'s evasiveness rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 260) // Raised opponent's special attack x2: Flatter
                            {
                                if (defender.tspatk >= 3.8f * defender.spatk)
                                {
                                    tbHistory.Text = defender.name + "'s special attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    defender.tspatk *= 1.96f;
                                    tbHistory.Text = defender.name + "'s special attack sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            if (move.index == 207) // Raised opponent's attack x2: Swagger
                            {
                                if (defender.tatk >= 3.8f * defender.atk)
                                {
                                    tbHistory.Text = defender.name + "'s attack can not be increased anymore!\n" + tbHistory.Text;
                                }
                                else
                                {
                                    defender.tatk *= 1.96f;
                                    tbHistory.Text = defender.name + "'s attack sharply rose!\n" + tbHistory.Text;
                                }
                            }

                            #endregion

                            if (move.index == 114) // Reset all stats: Haze
                            {
                                attacker.tatk = attacker.atk;
                                attacker.tdef = attacker.def;
                                attacker.tspatk = attacker.spatk;
                                attacker.tspdef = attacker.spdef;
                                attacker.tspeed = attacker.speed;

                                defender.tatk = defender.atk;
                                defender.tdef = defender.def;
                                defender.tspatk = defender.spatk;
                                defender.tspdef = defender.spdef;
                                defender.tspeed = defender.speed;
                            }

                            if (move.index == 316 || move.index == 193) // Reset evasiveness: Odor Sleuth, Foresight
                            {
                                defender.evasiveness = 100;
                            }

                            if (move.index == 466) // Raised all stats: Ominous Wind
                            {
                                if (attacker.tatk <= 3.8f * attacker.atk) attacker.tatk *= 1.4f;
                                if (attacker.tdef <= 3.8f * attacker.atk) attacker.tdef *= 1.4f;
                                if (attacker.tspatk <= 3.8f * attacker.atk) attacker.tspatk *= 1.4f;
                                if (attacker.tspdef <= 3.8f * attacker.atk) attacker.tspdef *= 1.4f;
                                if (attacker.tspeed >= 3.8f * attacker.speed) attacker.tspeed *= 1.4f;

                                tbHistory.Text = attacker.name + " has his stats increased!\n" + tbHistory.Text;
                            }

                            if (move.index == 375) // Transfer status problems: Psycho Shift
                            {
                                if (attacker.isAsleep > 0) { defender.EraseAffections(); defender.isAsleep = attacker.isAsleep; }
                                if (attacker.isBurnt > 0) { defender.EraseAffections(); defender.isBurnt = attacker.isBurnt; }
                                if (attacker.isPoisoned > 0) { defender.EraseAffections(); defender.isPoisoned = attacker.isPoisoned; }
                                if (attacker.isConfused > 0) { defender.EraseAffections(); defender.isConfused = attacker.isConfused; }
                                if (attacker.isFrozen > 0) { defender.EraseAffections(); defender.isFrozen = attacker.isFrozen; }
                                if (attacker.isParalyzed > 0) { defender.EraseAffections(); defender.isParalyzed = attacker.isParalyzed; }
                                attacker.EraseAffections();
                            }

                            if (move.index == 244) // Copy stats change: Psych Up
                            {
                                attacker.tatk *= defender.tatk / defender.atk;
                                attacker.tdef *= defender.tdef / defender.def;
                                attacker.tspatk *= defender.tspatk / defender.spatk;
                                attacker.tspdef *= defender.tspdef / defender.spdef;
                                attacker.tspeed *= defender.tspeed / defender.speed;
                            }

                            if (move.index == 384 || move.index == 391) // Swap atk: Power Swap, Heart Swap
                            {
                                float x1 = attacker.tatk / attacker.atk;
                                float x2 = defender.tatk / defender.atk;

                                attacker.tatk = attacker.atk * x2;
                                defender.tatk = defender.atk * x1;
                            }

                            if (move.index == 384 || move.index == 391) // Swap spatk: Power Swap, Heart Swap
                            {
                                float x1 = attacker.tspatk / attacker.spatk;
                                float x2 = defender.tspatk / defender.spatk;

                                attacker.tspatk = attacker.spatk * x2;
                                defender.tspatk = defender.spatk * x1;
                            }

                            if (move.index == 385 || move.index == 391) // Swap def: Guard Swap, Heart Swap
                            {
                                float x1 = attacker.tdef / attacker.def;
                                float x2 = defender.tdef / defender.def;

                                attacker.tdef = attacker.def * x2;
                                defender.tdef = defender.def * x1;
                            }

                            if (move.index == 385 || move.index == 391) // Swap spdef: Guard Swap, Heart Swap
                            {
                                float x1 = attacker.tspdef / attacker.spdef;
                                float x2 = defender.tspdef / defender.spdef;

                                attacker.tspdef = attacker.spdef * x2;
                                defender.tspdef = defender.spdef * x1;
                            }

                            if (move.index == 391) // Swap speed: Heart Swap
                            {
                                float x1 = attacker.tspeed / attacker.speed;
                                float x2 = defender.tspeed / defender.speed;

                                attacker.tspeed = attacker.speed * x2;
                                defender.tspeed = defender.speed * x1;
                            }

                            if (move.index == 379) // Swap atk and def: Power Trick
                            {
                                float aux = attacker.tdef;
                                attacker.tdef = attacker.tatk;
                                attacker.tatk = aux;
                            }

                            if (move.index == 116) // Raised Critical Chance: Focus Energy
                            {
                                if (attacker.critical < 45) attacker.critical += 10;
                            }

                            if (move.index == 381) // Prevent Critical Hits: Lucky Chant
                            {
                                defender.isCritChanted = true;
                            }

                            if (move.index == 220) // Pain Split
                            {
                                float aux = (attacker.hp + defender.hp) * 0.5f;
                                attacker.hp = aux;
                                defender.hp = aux;

                                if (attacker.hp > attacker.hpmax)
                                    attacker.hp = attacker.hpmax;
                                if (defender.hp > defender.hpmax)
                                    defender.hp = defender.hpmax;
                            }

                            if (move.index == 456 || move.index == 355 || move.index == 208
                                || move.index == 105 || move.index == 303 || move.index == 135)
                                // Heal 1/2 HP: Heal Order, Roost, Milk Drink, Recover, Slack Off, Soft-Boiled
                                if (attacker.HealBlock == 0)
                                {
                                    attacker.hp += attacker.hpmax * 0.5f;
                                    if (attacker.hp > attacker.hpmax)
                                        attacker.hp = attacker.hpmax;
                                }

                            if (move.index == 287) // Cure poison, burn, paralysis: Refresh
                            {
                                attacker.isBurnt = 0;
                                attacker.isParalyzed = 0;
                                attacker.isPoisoned = 0;
                            }

                            if (move.index == 312 || move.index == 215) // Aromatherapy, Heal Bell
                            {
                                if (yourPokemonIsAttacking) // erase your affections
                                {
                                    for (int i = 0; i < player.pokemons.Count; ++i)
                                    {
                                        player.pokemons[i].EraseAffections();
                                    }
                                }
                                else // erase enemy's affections
                                {
                                    if (enemyTrainer == null)
                                        enemyPokemon.EraseAffections();
                                    else for (int i = 0; i < enemyTrainer.pokemons.Count; ++i)
                                            enemyTrainer.pokemons[i].EraseAffections();
                                }
                            }

                            if (move.index == 235 || move.index == 236 || move.index == 234) // Heal: Synthesis, Moonlight, Morning Sun
                                if (attacker.HealBlock == 0)
                                {
                                    if (weatherType == 2)
                                        attacker.hp += attacker.hpmax * 0.67f;
                                    else if (weatherType == 0)
                                        attacker.hp += attacker.hpmax * 0.5f;
                                    else attacker.hp += attacker.hpmax * 0.25f;

                                    if (attacker.hp > attacker.hpmax)
                                        attacker.hp = attacker.hpmax;
                                }

                            if (move.index == 156) // Heal: Rest
                                if (attacker.HealBlock == 0)
                                {
                                    attacker.hp = attacker.hpmax;
                                    attacker.EraseAffections();
                                    attacker.isAsleep = 2;
                                }

                            if (move.index == 169 || move.index == 335 || move.index == 212)
                            // Trapped forever: Spider Web, Block, Mean Look
                            {
                                defender.isTrapped = 100;
                            }

                            if (move.index == 73) // Leech Seed
                            {
                                defender.isSeeded = true;
                            }

                            if (move.index == 377) // Heal Block
                            {
                                defender.HealBlock = 5;
                            }

                            if (move.index == 213 && defender.gender == 1 - attacker.gender) // Attract
                            {
                                defender.isAttracted = true;
                            }

                            if (move.index == 254) // Stockpile
                            {
                                if (attacker.Stockpile < 3)
                                    attacker.Stockpile += 1;
                            }

                            if (move.index == 256) // Heal: Swallow
                                if (attacker.HealBlock == 0)
                                {
                                    float hpSwallowed = attacker.hpmax;

                                    if (attacker.Stockpile == 0) hpSwallowed = 0;
                                    else if (attacker.Stockpile == 1) hpSwallowed *= 0.25f;
                                    else if (attacker.Stockpile == 2) hpSwallowed *= 0.5f;

                                    attacker.hp += hpSwallowed;
                                    if (attacker.hp > attacker.hpmax)
                                        attacker.hp = attacker.hpmax;

                                    attacker.Stockpile = 0;
                                }

                            if (move.index == 268) // Charge user
                            {
                                attacker.isCharged = true;
                            }

                            if (move.index == 373 || move.index == 282) // Cannot use items: Embargo, Knock Off
                            {
                                defender.canUseItems = false;
                            }

                            if (move.index == 275) // Can not switch: Ingrain
                            {
                                attacker.canBeSwitched = false;
                            }

                            if (move.index == 392 || move.index == 275) // Regenerate life every turn: Aqua Ring, Ingrain
                            {
                                attacker.isRegeneratingLife = true;
                            }

                            if (move.index == 346) // Weaken fire moves: Water Sport
                            {
                                attacker.isWaterSported = true;
                            }

                            if (move.index == 240) // Weather - rain: Rain Dance
                            {
                                // can not change weather if it's already raining more
                                if (weatherType == 1 && weatherDuration > 5) ;
                                else
                                {
                                    weatherType = 1;
                                    weatherDuration = 5;
                                }
                            }

                            if (move.index == 241) // Weather - sunny: Sunny Day
                            {
                                if (weatherType == 2 && weatherDuration > 5) ;
                                else
                                {
                                    weatherType = 2;
                                    weatherDuration = 5;
                                }
                            }

                            if (move.index == 201) // Weather - sandstorm: Sandstorm
                            {
                                if (weatherType == 3 && weatherDuration > 5) ;
                                else
                                {
                                    weatherType = 3;
                                    weatherDuration = 5;
                                }
                            }

                            if (move.index == 258) // Weather - hail: Hail
                            {
                                if (weatherType == 4 && weatherDuration > 5) ;
                                else
                                {
                                    weatherType = 4;
                                    weatherDuration = 5;
                                }
                            }

                            if (move.index == 171) // Nightmare
                                if (defender.isAsleep > 0)
                                {
                                    defender.Nightmare = true;
                                }

                            if (move.index == 393) // Magnet Rise
                            {
                                attacker.MagnetRise = 5;
                            }

                            if (move.index == 262) // Faint: Memento
                            {
                                attacker.hp = 0;

                                if (yourPokemonIsAttacking)
                                {
                                    YourPokemonDies(attacker);
                                }
                                else
                                {
                                    EnemyPokemonDies(attacker);
                                }
                                return;
                            }

                            ChangeHealth();

                            #endregion
                        }

                        if (move.index == 18 || move.index == 46 || move.index == 100
                            || move.index == 369 || move.index == 226)
                        // Swap pokemon: Whirlwind, Roar, Teleport, U-Turn, Baton Pass
                        {
                            if (move.index == 18)
                                tbHistory.Text = defender.name + " was blown away!\n" + tbHistory.Text;
                            if (move.index == 46)
                                tbHistory.Text = defender.name + " ran away!\n" + tbHistory.Text;

                            bool tmp = yourPokemonIsAttacking;
                            if (move.index == 100 || move.index == 369 || move.index == 226) tmp = !tmp;

                            if (tmp)
                            {
                                if (enemyTrainer != null)
                                {
                                    int crtEnemyPokemon = 0;

                                    for (int i = 0; i < enemyTrainer.pokemons.Count; ++i)
                                        if (enemyTrainer.pokemons[i] == enemyPokemon)
                                        {
                                            crtEnemyPokemon = i;
                                            break;
                                        }

                                    for (int i = 0; i < enemyTrainer.pokemons.Count; ++i)
                                        if (enemyTrainer.pokemons[i].hp > 0 && i != crtEnemyPokemon)
                                        {
                                            enemyPokemon = enemyTrainer.pokemons[i];
                                            battleScreen.Invalidate();
                                            if (move.index == 100 || move.index == 369 || move.index == 226) break;
                                            else return;
                                        }
                                }
                                else
                                {
                                    if (enemyPokemon.isTrapped == 0)
                                    {
                                        waitTime = true;
                                        endBattleTimer.Start();
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                bool changed = false;

                                firstChangeCrtPokemon = true;

                                for (int i = 0; i < player.pokemons.Count; ++i)
                                    if (player.pokemons[i].hp > 0 && i != crtPokemon)
                                    {
                                        changed = true;
                                        ChangeCrtPokemon(i);
                                        break;
                                    }

                                if (!changed && enemyTrainer == null)
                                {
                                    waitTime = true;
                                    endBattleTimer.Start();
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        // attack missed
                        tbHistory.Text = attacker.name + " used " + move.name + " but it missed!\n" + tbHistory.Text;

                        attacker.FuryCutter = 0; // Fury Cutter resets

                        if (move.index == 26 || move.index == 136) // Jump Kick, Hight Jump Kick
                        {
                            tbHistory.Text = attacker.name + " hurt himself!\n" + tbHistory.Text;
                            attacker.hp -= attacker.hpmax / 8f;
                            if (attacker.hp <= 0)
                            {
                                if (yourPokemonIsAttacking)
                                {
                                    YourPokemonDies(attacker);
                                }
                                else
                                {
                                    EnemyPokemonDies(attacker);
                                }
                                return;
                            }
                        }
                    }
                }
            }

            waitTime = true;
            attackTimerCount = 0;
            attackTimer.Start();

            battleScreen.Invalidate();
        }
        private void buttonRelease_Click(object sender, EventArgs e)
        {
            if (crtPokemon == null) return;

            if(FormGame.player.pokemons.Count == 1)
            {
                MessageBox.Show("You must have at least one pokemon in your team!", "" , MessageBoxButtons.OK);
                return;
            }

            if (MessageBox.Show("Are you sure you want to release " + crtPokemon.name + "?", "",
                        MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) return;

            FormGame.player.pokemons.Remove(crtPokemon);

            crtPokemon = null;

            Initialize();
        }
        private void pbPokemon_MouseClick(object sender, MouseEventArgs e)
        {
            for (int i = 0; i < FormGame.player.pokemons.Count; ++i)
            {
                if (pbPokemon[i] == (PictureBox)sender)
                {
                    if(potion != null)
                    {
                        if (FormGame.player.pokemons[i].hp > 0)
                            potion.UsePotion(FormGame.player.pokemons[i]);
                        else MessageBox.Show("You can not use a potion on a dead pokemon", "", MessageBoxButtons.OK);

                        this.Close();
                    }

                    if(move != null)
                    {
                        if (pbPokemon[i].BackColor == Color.LightGreen)
                        {
                            if (MessageBox.Show("Are you sure you want " + FormGame.player.pokemons[i].name + " to learn " + move.name + "?", "",
                                MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                            {
                                FormGame.player.pokemons[i].LearnMove(new Attack(move.index));
                                if (!move.isHM) FormGame.player.TMs.Remove(move);
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show(FormGame.player.pokemons[i].name + " can not learn " + move.name, "", MessageBoxButtons.OK);
                        }
                    }

                    if (evolitem != null)
                    {
                        if (pbPokemon[i].BackColor == Color.LightGreen)
                        {
                            if (MessageBox.Show("Are you sure you want " + FormGame.player.pokemons[i].name + " to evolve?", "",
                                MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                            {
                                int pokeIndex = FormGame.player.pokemons[i].index;

                                int pokeEvolution = Resources.evolution[pokeIndex].evolution;

                                if(pokeIndex == 133) // Eevee
                                {
                                    if (evolitem.type == 1) pokeEvolution = 135;
                                    if (evolitem.type == 2) pokeEvolution = 136;
                                    if (evolitem.type == 3) pokeEvolution = 134;
                                }

                                if(pokeIndex == 44) // Gloom
                                {
                                    if (evolitem.type == 8) pokeEvolution = 182;
                                    if (evolitem.type == 9) pokeEvolution = 45;
                                }

                                if(pokeIndex == 61) // Poliwhirl
                                {
                                    if (evolitem.type == 3) pokeEvolution = 62;
                                    if (evolitem.type == 10) pokeEvolution = 186;
                                }

                                if(pokeIndex == 79) // Slowpoke
                                {
                                    if (evolitem.type == 10) pokeEvolution = 199;
                                }

                                if(pokeIndex == 281) // Kirlia
                                {
                                    if(evolitem.type == 4) pokeEvolution = 475;
                                }

                                if(pokeIndex == 361) // Snorunt
                                {
                                    if(evolitem.type == 4) pokeEvolution = 478;
                                }

                                if (pokeIndex == 366) // Clamperl
                                {
                                    if (evolitem.type == 20) pokeEvolution = 367;
                                    if (evolitem.type == 19) pokeEvolution = 368;
                                }

                                FormGame.player.pokemons[i].Evolve(pokeEvolution);
                                new FormEvolution(pokeIndex, pokeEvolution).ShowDialog();
                                FormGame.player.evolutionItems.Remove(evolitem);
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show(FormGame.player.pokemons[i].name + " can not evolve with this item", "", MessageBoxButtons.OK);
                        }
                    }

                    crtPokemonIndex = i;

                    crtPokemon = FormGame.player.pokemons[i];

                    ChangeDetails(crtPokemon);

                    break;
                }
            }
        }
        private void buttonStartGame_Click(object sender, EventArgs e)
        {
            if (selectedNr < 0)
            {
                labelError.Text = "Select a starter pokemon";
                labelError.Show();
                return;
            }

            if (tbName.Text == "")
            {
                labelError.Text = "Select a name for your trainer";
                labelError.Show();
                return;
            }

            string[] words = tbName.Text.Split();
            if(words[0] != tbName.Text)
            {
                labelError.Text = "Your name can not contain spaces";
                labelError.Show();
                return;
            }

            applicationIsRunning = true;

            Character player = new Character(tbName.Text);

            int pokeNr;

            switch (selectedNr)
            {
                case 0: pokeNr = 1; break;
                case 1: pokeNr = 4; break;
                case 2: pokeNr = 7; break;
                case 3: pokeNr = 152; break;
                case 4: pokeNr = 155; break;
                case 5: pokeNr = 158; break;
                case 6: pokeNr = 252; break;
                case 7: pokeNr = 255; break;
                case 8: pokeNr = 258; break;
                case 9: pokeNr = 387; break;
                case 10: pokeNr = 390; break;
                default: pokeNr = 393; break;
            }

            Pokemons pokemon = new Pokemons(pokeNr, 5);

            FormPokedex.SeePokemon(pokeNr);
            FormPokedex.OwnPokemon(pokeNr);

            // starting pokemon
            pokemon.lovebase = 50;
            pokemon.EarnLove(100, 20, 30);
            player.AddPokemon(pokemon);

            // starting items
            Pokeball pball = new Pokeball(1);
            pball.number = 5;
            player.pokeballs.Add(pball);

            // starting money
            player.money = 1000;

            // starting food
            player.food = 10;

            new FormGame(player).Show();

            this.Close();
        }
 public FormDeleteMove(Pokemons _poke, Attack _move)
 {
     //InitializeComponent();
 }
        private void timerLoading_Tick(object sender, EventArgs e)
        {
            points = (points + 1) % 4;
            labelLoading.Text = "Loading";
            for (int i = 1; i <= points; ++i) labelLoading.Text += ".";

            if (Resources.resourcesDone)
            {
                timerLoading.Stop();

                applicationIsRunning = true;

                if(newGame) new FormCharacterCreation().Show();
                else
                {
                    StreamReader sr = new StreamReader(Application.StartupPath + "\\game.sav");

                    string line;
                    string[] words;

                    line = sr.ReadLine();
                    words = line.Split();

                    Character player = new Character(words[0]);
                    player.money = Convert.ToInt32(words[1]);
                    player.badges = Convert.ToInt32(words[2]);
                    player.healingcenter = Convert.ToInt32(words[3]);
                    player.food = Convert.ToInt32(words[4]);

                    line = sr.ReadLine();
                    words = line.Split();
                    int pokeCount = Convert.ToInt32(words[0]);
                    for(int i=0;i<pokeCount;++i)
                    {
                        line = sr.ReadLine();
                        words = line.Split();
                        Pokemons pokemon = new Pokemons(Convert.ToInt32(words[0]), 1);
                        pokemon.level = Convert.ToInt32(words[1]);

                        pokemon.gender = Convert.ToInt32(words[2]);
                        pokemon.name = words[3] + "";
                        pokemon.lovebase = (float)Convert.ToDouble(words[4]);
                        pokemon.EarnLove((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6]), (float)Convert.ToDouble(words[7]));

                        pokemon.hp = (float)Convert.ToDouble(words[8]);
                        pokemon.hpmax = (float)Convert.ToDouble(words[9]);
                        pokemon.atk = (float)Convert.ToDouble(words[10]);
                        pokemon.def = (float)Convert.ToDouble(words[11]);
                        pokemon.spatk = (float)Convert.ToDouble(words[12]);
                        pokemon.spdef = (float)Convert.ToDouble(words[13]);
                        pokemon.speed = (float)Convert.ToDouble(words[14]);

                        pokemon.xp = Convert.ToInt32(words[15]);

                        line = sr.ReadLine();
                        words = line.Split();
                        pokemon.moves = new List<Attack>();
                        int moveCount = Convert.ToInt32(words[0]);
                        for (int j = 0; j < moveCount; ++j)
                        {
                            Attack move = new Attack(Convert.ToInt32(words[1 + j * 2]));
                            move.PP = Convert.ToInt32(words[2 + j * 2]);
                            pokemon.LearnMove(move);
                        }

                        player.AddPokemon(pokemon);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int pokeLabCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < pokeLabCount; ++i)
                    {
                        line = sr.ReadLine();
                        words = line.Split();
                        Pokemons pokemon = new Pokemons(Convert.ToInt32(words[0]), 1);
                        pokemon.level = Convert.ToInt32(words[1]);

                        pokemon.gender = Convert.ToInt32(words[2]);
                        pokemon.name = words[3] + "";
                        pokemon.lovebase = (float)Convert.ToDouble(words[4]);
                        pokemon.EarnLove((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6]), (float)Convert.ToDouble(words[7]));

                        pokemon.hp = (float)Convert.ToDouble(words[8]);
                        pokemon.hpmax = (float)Convert.ToDouble(words[9]);
                        pokemon.atk = (float)Convert.ToDouble(words[10]);
                        pokemon.def = (float)Convert.ToDouble(words[11]);
                        pokemon.spatk = (float)Convert.ToDouble(words[12]);
                        pokemon.spdef = (float)Convert.ToDouble(words[13]);
                        pokemon.speed = (float)Convert.ToDouble(words[14]);

                        pokemon.xp = Convert.ToInt32(words[15]);

                        line = sr.ReadLine();
                        words = line.Split();
                        pokemon.moves = new List<Attack>();
                        int moveCount = Convert.ToInt32(words[0]);
                        for (int j = 0; j < moveCount; ++j)
                        {
                            Attack move = new Attack(Convert.ToInt32(words[1 + j * 2]));
                            move.PP = Convert.ToInt32(words[2 + j * 2]);
                            pokemon.LearnMove(move);
                        }

                        player.pokemonsLab.Add(pokemon);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int pokeballCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < pokeballCount;++i )
                    {
                        Pokeball ball = new Pokeball(Convert.ToInt32(words[1 + i * 2]));
                        ball.number = Convert.ToInt32(words[2 + i * 2]);
                        player.pokeballs.Add(ball);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int potionCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < potionCount; ++i)
                    {
                        Potion pot = new Potion(Convert.ToInt32(words[1 + i * 2]));
                        pot.number = Convert.ToInt32(words[2 + i * 2]);
                        player.potions.Add(pot);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int TMCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < TMCount; ++i)
                    {
                        player.TMs.Add(new Attack(Convert.ToInt32(words[1 + i])));
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int EvolutionItemsCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < EvolutionItemsCount; ++i)
                    {
                        player.evolutionItems.Add(new EvolutionItem(Convert.ToInt32(words[1 + i])));
                    }

                    FormGame formGame = new FormGame(player);

                    line = sr.ReadLine();
                    words = line.Split();
                    FormGame.map = new Map(Convert.ToInt32(words[0]), Convert.ToInt32(words[1]), Convert.ToInt32(words[2]));
                    FormGame.gameTime = Convert.ToInt32(words[3]);
                    Map.lastTimeGym = Convert.ToInt32(words[4]);

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 0; i < 200;++i )
                    {
                        if (Convert.ToInt32(words[i]) == 1) Map.trainerDefeated[i] = true;
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                    {
                        if (Convert.ToInt32(words[i - 1]) == 1) Map.pokemonDefeated[i] = true;
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    FormPokedex.seen = Convert.ToInt32(words[0]);
                    FormPokedex.owned = Convert.ToInt32(words[1]);

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                        if (Convert.ToInt32(words[i - 1]) == 1)
                            FormPokedex.inPokedex[i] = true;

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                        if (Convert.ToInt32(words[i - 1]) == 1)
                            FormPokedex.ownedPokemon[i] = true;

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                    {
                        string nameString = words[i - 1] + "";
                        if (nameString != "-")
                            FormPokedex.names[i] = nameString;
                    }

                    formGame.Show();

                    sr.Close();
                }

                this.Close();
            }
        }
        public void UsePotion(Pokemons poke)
        {
            // update the numbers of potions
            number -= 1;
            if (number == 0)
                FormGame.player.potions.Remove(this);

            // heal
            if (type <= 4)
            {
                poke.hp += heal;
                if (poke.hp > poke.hpmax)
                    poke.hp = poke.hpmax;
            }
            else
            {
                if (type == 5)
                {
                    for (int i = 0; i < poke.moves.Count; ++i)
                    {
                        poke.moves[i].PP = poke.moves[i].PPmax;
                    }
                }
                if (type == 6) poke.isFrozen = 0;
                if (type == 7) poke.isParalyzed = 0;
                if (type == 8) poke.isAsleep = 0;
                if (type == 9) poke.isPoisoned = 0;
                if (type == 10) poke.isBurnt = 0;
            }
        }
        private void LoadGym(int mapNr)
        {
            pbCanvas.BackgroundImage = Resources.gymInside;

            FormGame.OX = 400;
            FormGame.OY = 330;

            int X = 0, Y = 0;

            if (mapNr == 5) { X = 115; Y = 340; }
            if (mapNr == 8) { X = 382; Y = 501; }
            if (mapNr == 14) { X = 622; Y = 201; }
            if (mapNr == 20) { X = 500; Y = 425; }
            if (mapNr == 24) { X = 370; Y = 260; }
            if (mapNr == 29) { X = 560; Y = 442; }
            if (mapNr == 36) { X = 595; Y = 320; }
            if (mapNr == 40) { X = 380; Y = 120; }
            if (mapNr == 48) { X = 300; Y = 195; }

            exit.Add(new ExitPoint(380, 410, 500, 440, mapNr, X, Y));

            blockedzone.Add(new BlockedZone(0, 0, 150, 600));
            blockedzone.Add(new BlockedZone(650, 0, 800, 600));
            blockedzone.Add(new BlockedZone(0, 0, 800, 200));
            blockedzone.Add(new BlockedZone(0, 425, 800, 600));

            if (mapNr == 5)
            {
                characters.Add(new Character("John the Lumberjack", Resources.character_fighter, 390, 250));
                characters[0].index = 9;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -3));

                Pokemons poke = new Pokemons(285, 10);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(71));
                poke.moves.Add(new Attack(73));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(163, 13);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(33));
                poke.moves.Add(new Attack(95));
                poke.moves.Add(new Attack(64));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(345, 15);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(331));
                poke.moves.Add(new Attack(317));
                poke.moves.Add(new Attack(156));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 8)
            {
                characters.Add(new Character("Desmond", Resources.character_oldman, 390, 250));
                characters[0].index = 19;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -4));

                Pokemons poke = new Pokemons(27, 14);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(229));
                poke.moves.Add(new Attack(111));
                poke.moves.Add(new Attack(205));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(231, 15);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(36));
                poke.moves.Add(new Attack(111));
                poke.moves.Add(new Attack(205));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(215, 18);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(98));
                poke.moves.Add(new Attack(420));
                poke.moves.Add(new Attack(103));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(34, 20);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(341));
                poke.moves.Add(new Attack(24));
                poke.moves.Add(new Attack(46));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 14)
            {
                characters.Add(new Character("Magic Stan", Resources.character_magician, 390, 250));
                characters[0].index = 25;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -5));

                Pokemons poke = new Pokemons(408, 20);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(428));
                poke.moves.Add(new Attack(36));
                poke.moves.Add(new Attack(43));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(302, 23);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(425));
                poke.moves.Add(new Attack(185));
                poke.moves.Add(new Attack(43));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(429, 25);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(310));
                poke.moves.Add(new Attack(149));
                poke.moves.Add(new Attack(109));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 20)
            {
                characters.Add(new Character("Aviana", Resources.character_woman, 390, 250));
                characters[0].index = 64;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -6));

                Pokemons poke = new Pokemons(84, 24);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(98));
                poke.moves.Add(new Attack(228));
                poke.moves.Add(new Attack(367));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(164, 26);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(36));
                poke.moves.Add(new Attack(93));
                poke.moves.Add(new Attack(95));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(178, 26);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(100));
                poke.moves.Add(new Attack(94));
                poke.moves.Add(new Attack(101));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(357, 28);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(75));
                poke.moves.Add(new Attack(403));
                poke.moves.Add(new Attack(18));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(227, 28);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(314));
                poke.moves.Add(new Attack(211));
                poke.moves.Add(new Attack(97));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(430, 30);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(17));
                poke.moves.Add(new Attack(114));
                poke.moves.Add(new Attack(399));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 24)
            {
                characters.Add(new Character("Farmer", Resources.character_farmer, 390, 250));
                characters[0].index = 79;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -7));

                Pokemons poke = new Pokemons(241, 28);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(208));
                poke.moves.Add(new Attack(34));
                poke.moves.Add(new Attack(428));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(128, 30);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(156));
                poke.moves.Add(new Attack(428));
                poke.moves.Add(new Attack(416));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(326, 33);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(316));
                poke.moves.Add(new Attack(93));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 29)
            {
                characters.Add(new Character("Isolde", Resources.character_woman2, 390, 250));
                characters[0].index = 93;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -8));

                Pokemons poke = new Pokemons(197, 40);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(185));
                poke.moves.Add(new Attack(103));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(470, 40);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(202));
                poke.moves.Add(new Attack(320));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(471, 40);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(423));
                poke.moves.Add(new Attack(28));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(136, 45);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(424));
                poke.moves.Add(new Attack(28));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 36)
            {
                characters.Add(new Character("Charles&Clotilde Dubois", Resources.character_spouses, 390, 250));
                characters[0].index = 99;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -9));

                Pokemons poke = new Pokemons(57, 57);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(238));
                poke.moves.Add(new Attack(2));
                poke.moves.Add(new Attack(207));
                poke.moves.Add(new Attack(372));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(419, 60);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(423));
                poke.moves.Add(new Attack(242));
                poke.moves.Add(new Attack(453));
                poke.moves.Add(new Attack(97));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(208, 63);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(422));
                poke.moves.Add(new Attack(423));
                poke.moves.Add(new Attack(424));
                poke.moves.Add(new Attack(106));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(437, 66);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(95));
                poke.moves.Add(new Attack(326));
                poke.moves.Add(new Attack(334));
                poke.moves.Add(new Attack(360));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(248, 69);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(444));
                poke.moves.Add(new Attack(89));
                poke.moves.Add(new Attack(242));
                poke.moves.Add(new Attack(184));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 40)
            {
                characters.Add(new Character("Giovanni", Resources.character_giovanni, 390, 250));
                characters[0].index = 103;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -26));

                Pokemons poke = new Pokemons(99, 65);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(152));
                poke.moves.Add(new Attack(21));
                poke.moves.Add(new Attack(182));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(112, 65);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(36));
                poke.moves.Add(new Attack(30));
                poke.moves.Add(new Attack(184));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(68, 65);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(238));
                poke.moves.Add(new Attack(279));
                poke.moves.Add(new Attack(116));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(76, 65);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(38));
                poke.moves.Add(new Attack(222));
                poke.moves.Add(new Attack(397));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(91, 65);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(56));
                poke.moves.Add(new Attack(48));
                poke.moves.Add(new Attack(62));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(150, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(396));
                poke.moves.Add(new Attack(105));
                poke.moves.Add(new Attack(94));
                characters[0].pokemons.Add(poke);
            }

            if (mapNr == 48)
            {
                characters.Add(new Character("Edmund the Wise", Resources.character_oldman3, 390, 250));
                characters[0].index = 116;
                actionpoint.Add(new ActionPoint(370, 240, 440, 300, -10));

                Pokemons poke = new Pokemons(330, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(225));
                poke.moves.Add(new Attack(103));
                poke.moves.Add(new Attack(185));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(445, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(91));
                poke.moves.Add(new Attack(337));
                poke.moves.Add(new Attack(424));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(373, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(182));
                poke.moves.Add(new Attack(242));
                poke.moves.Add(new Attack(225));
                poke.moves.Add(new Attack(422));
                characters[0].pokemons.Add(poke);
            }
        }
        private void EnemyPokemonDies(Pokemons poke)
        {
            poke.hp = 0;
            ChangeHealth();

            // add win money
            winMoney += (poke.level / 5) * 50;

            // calculate xp
            float exp = poke.level * poke.xpgiven / (7f * notFaintedPokemons.Count);
            if (enemyTrainer != null) exp *= 1.5f; // more xp from trainer battle
            int xp = (int)exp;

            // gain xp for every pokemon engaged in battle that did not faint
            for (int i = 0; i < notFaintedPokemons.Count; ++i)
            {
                notFaintedPokemons[i].EarnLove(5, 0, 0);

                notFaintedPokemons[i].xp += xp;

                while (notFaintedPokemons[i].level < 100 &&
                    notFaintedPokemons[i].xp >= Resources.xpneeded[notFaintedPokemons[i].level])
                {
                    notFaintedPokemons[i].LevelUp();
                }

                tbHistory.Text = notFaintedPokemons[i].name + " gained " + xp + " XP.\n" + tbHistory.Text;
            }

            if (enemyTrainer != null)
                for (int i = 0; i < enemyTrainer.pokemons.Count; ++i)
                {
                    if (enemyTrainer.pokemons[i].hp > 0)
                    {
                        notFaintedPokemons = new List<Pokemons>();
                        notFaintedPokemons.Add(player.pokemons[crtPokemon]);
                        enemyPokemon = enemyTrainer.pokemons[i];
                        battleScreen.Invalidate();
                        battleTurns = 0;
                        return;
                    }
                }

            // you win
            tbHistory.Text = "You won the battle!\n" + tbHistory.Text;
            battleScreen.Invalidate();

            EndBattle(true);

            waitTime = true;
        }
        private void LoadMap20()
        {
            pbCanvas.BackgroundImage = Resources.townpavement;

            exit.Add(new ExitPoint(0, 200, 50, 350, 19, 720, 200));

            wildPokemons.Add(new ints(63, 10, 15, 33));
            wildPokemons.Add(new ints(64, 16, 16, 1));
            wildPokemons.Add(new ints(238, 10, 16, 8));
            wildPokemons.Add(new ints(280, 10, 16, 3));
            wildPokemons.Add(new ints(133, 10, 16, 10));
            wildPokemons.Add(new ints(52, 10, 16, 20));
            wildPokemons.Add(new ints(441, 10, 16, 10));
            wildPokemons.Add(new ints(431, 10, 16, 15));

            characters.Add(new Character("Painter", Resources.character_painter, 281, 215));
            Pokemons poke = new Pokemons(235, 30);
            poke.moves = new List<Attack>();
            poke.moves.Add(new Attack(352));
            poke.moves.Add(new Attack(7));
            poke.moves.Add(new Attack(202));
            poke.moves.Add(new Attack(233));
            characters[0].pokemons.Add(poke);
            characters[0].index = 63;
            actionpoint.Add(new ActionPoint(271, 205, 341, 265, 0));

            #region Environment

            structures.Add(new Structures(2, 0, 30, 150));
            structures.Add(new Structures(2, 0, 30, 280));

            int waterType = 1;
            if (!trainerDefeated[64]) waterType = 2; // water is polluted until you beat the gym leader

            structures.Add(new Structures(1, waterType, 4, 676, -4));
            structures.Add(new Structures(1, waterType, 4, 676, 36));
            structures.Add(new Structures(1, waterType, 4, 676, 76));
            structures.Add(new Structures(1, waterType, 4, 676, 116));
            structures.Add(new Structures(1, waterType, 4, 676, 156));
            structures.Add(new Structures(1, waterType, 4, 676, 196));
            structures.Add(new Structures(1, waterType, 4, 676, 236));
            structures.Add(new Structures(1, waterType, 4, 676, 276));
            structures.Add(new Structures(1, waterType, 4, 676, 316));
            structures.Add(new Structures(1, waterType, 4, 676, 356));
            structures.Add(new Structures(1, waterType, 4, 676, 396));
            structures.Add(new Structures(1, waterType, 4, 676, 436));
            structures.Add(new Structures(1, waterType, 4, 676, 476));
            structures.Add(new Structures(1, waterType, 4, 676, 516));
            structures.Add(new Structures(1, waterType, 4, 676, 556));
            structures.Add(new Structures(1, waterType, 4, 676, 596));
            structures.Add(new Structures(1, waterType, 5, 716, 596));
            structures.Add(new Structures(1, waterType, 5, 756, 596));
            structures.Add(new Structures(1, waterType, 5, 756, 556));
            structures.Add(new Structures(1, waterType, 5, 796, 556));
            structures.Add(new Structures(1, waterType, 5, 796, 596));
            structures.Add(new Structures(1, waterType, 5, 716, 556));
            structures.Add(new Structures(1, waterType, 5, 716, 516));
            structures.Add(new Structures(1, waterType, 5, 716, 476));
            structures.Add(new Structures(1, waterType, 5, 716, 436));
            structures.Add(new Structures(1, waterType, 5, 716, 396));
            structures.Add(new Structures(1, waterType, 5, 716, 356));
            structures.Add(new Structures(1, waterType, 5, 716, 316));
            structures.Add(new Structures(1, waterType, 5, 716, 276));
            structures.Add(new Structures(1, waterType, 5, 716, 236));
            structures.Add(new Structures(1, waterType, 5, 716, 196));
            structures.Add(new Structures(1, waterType, 5, 716, 156));
            structures.Add(new Structures(1, waterType, 5, 716, 116));
            structures.Add(new Structures(1, waterType, 5, 716, 76));
            structures.Add(new Structures(1, waterType, 5, 716, 36));
            structures.Add(new Structures(1, waterType, 5, 716, -4));
            structures.Add(new Structures(1, waterType, 5, 756, -4));
            structures.Add(new Structures(1, waterType, 5, 796, -4));
            structures.Add(new Structures(1, waterType, 5, 796, 36));
            structures.Add(new Structures(1, waterType, 5, 796, 76));
            structures.Add(new Structures(1, waterType, 5, 796, 116));
            structures.Add(new Structures(1, waterType, 5, 796, 156));
            structures.Add(new Structures(1, waterType, 5, 796, 196));
            structures.Add(new Structures(1, waterType, 5, 796, 236));
            structures.Add(new Structures(1, waterType, 5, 796, 276));
            structures.Add(new Structures(1, waterType, 5, 796, 316));
            structures.Add(new Structures(1, waterType, 5, 796, 356));
            structures.Add(new Structures(1, waterType, 5, 796, 396));
            structures.Add(new Structures(1, waterType, 5, 796, 436));
            structures.Add(new Structures(1, waterType, 5, 796, 476));
            structures.Add(new Structures(1, waterType, 5, 796, 516));
            structures.Add(new Structures(1, waterType, 5, 756, 516));
            structures.Add(new Structures(1, waterType, 5, 756, 476));
            structures.Add(new Structures(1, waterType, 5, 756, 436));
            structures.Add(new Structures(1, waterType, 5, 756, 396));
            structures.Add(new Structures(1, waterType, 5, 756, 356));
            structures.Add(new Structures(1, waterType, 5, 756, 316));
            structures.Add(new Structures(1, waterType, 5, 756, 276));
            structures.Add(new Structures(1, waterType, 5, 756, 236));
            structures.Add(new Structures(1, waterType, 5, 756, 196));
            structures.Add(new Structures(1, waterType, 5, 756, 156));
            structures.Add(new Structures(1, waterType, 5, 756, 116));
            structures.Add(new Structures(1, waterType, 5, 756, 76));
            structures.Add(new Structures(1, waterType, 5, 756, 36));

            structures.Add(new Structures(1, 0, 556, 8));
            structures.Add(new Structures(1, 0, 476, 8));
            structures.Add(new Structures(1, 0, 396, 8));
            structures.Add(new Structures(1, 0, 316, 8));
            structures.Add(new Structures(1, 0, 236, 8));
            structures.Add(new Structures(1, 0, 156, 8));
            structures.Add(new Structures(1, 0, 76, 8));
            structures.Add(new Structures(1, 0, 565, 531));
            structures.Add(new Structures(1, 0, 485, 531));
            structures.Add(new Structures(1, 0, 405, 531));
            structures.Add(new Structures(1, 0, 325, 531));
            structures.Add(new Structures(1, 0, 245, 531));
            structures.Add(new Structures(1, 0, 165, 531));
            structures.Add(new Structures(1, 0, 85, 531));
            structures.Add(new Structures(2, 0, 617, 118));
            structures.Add(new Structures(2, 0, 396, 351));
            structures.Add(new Structures(2, 0, 628, 356));
            structures.Add(new Structures(2, 0, 392, 119));

            buildings.Add(new Buildings(1, 432, 48, true));
            buildings.Add(new Buildings(0, 445, 295, true));

            wildgrass.Add(new WildGrass(86, 90));
            wildgrass.Add(new WildGrass(126, 90));
            wildgrass.Add(new WildGrass(166, 90));
            wildgrass.Add(new WildGrass(206, 90));
            wildgrass.Add(new WildGrass(206, 130));
            wildgrass.Add(new WildGrass(206, 170));
            wildgrass.Add(new WildGrass(206, 210));
            wildgrass.Add(new WildGrass(206, 250));
            wildgrass.Add(new WildGrass(206, 290));
            wildgrass.Add(new WildGrass(206, 330));
            wildgrass.Add(new WildGrass(206, 370));
            wildgrass.Add(new WildGrass(206, 410));
            wildgrass.Add(new WildGrass(206, 450));
            wildgrass.Add(new WildGrass(166, 450));
            wildgrass.Add(new WildGrass(126, 450));
            wildgrass.Add(new WildGrass(86, 450));
            wildgrass.Add(new WildGrass(86, 410));
            wildgrass.Add(new WildGrass(86, 370));
            wildgrass.Add(new WildGrass(86, 330));
            wildgrass.Add(new WildGrass(86, 290));
            wildgrass.Add(new WildGrass(86, 250));
            wildgrass.Add(new WildGrass(86, 210));
            wildgrass.Add(new WildGrass(86, 170));
            wildgrass.Add(new WildGrass(86, 130));
            wildgrass.Add(new WildGrass(126, 130));
            wildgrass.Add(new WildGrass(166, 130));
            wildgrass.Add(new WildGrass(166, 170));
            wildgrass.Add(new WildGrass(166, 210));
            wildgrass.Add(new WildGrass(166, 250));
            wildgrass.Add(new WildGrass(166, 290));
            wildgrass.Add(new WildGrass(166, 330));
            wildgrass.Add(new WildGrass(166, 370));
            wildgrass.Add(new WildGrass(166, 410));
            wildgrass.Add(new WildGrass(126, 410));
            wildgrass.Add(new WildGrass(126, 370));
            wildgrass.Add(new WildGrass(126, 330));
            wildgrass.Add(new WildGrass(126, 290));
            wildgrass.Add(new WildGrass(126, 250));
            wildgrass.Add(new WildGrass(126, 210));
            wildgrass.Add(new WildGrass(126, 170));
            wildgrass.Add(new WildGrass(246, 90));
            wildgrass.Add(new WildGrass(286, 90));
            wildgrass.Add(new WildGrass(326, 90));
            wildgrass.Add(new WildGrass(326, 130));
            wildgrass.Add(new WildGrass(366, 210));
            wildgrass.Add(new WildGrass(406, 210));
            wildgrass.Add(new WildGrass(446, 210));
            wildgrass.Add(new WildGrass(486, 210));
            wildgrass.Add(new WildGrass(526, 210));
            wildgrass.Add(new WildGrass(566, 210));
            wildgrass.Add(new WildGrass(566, 250));
            wildgrass.Add(new WildGrass(526, 250));
            wildgrass.Add(new WildGrass(486, 250));
            wildgrass.Add(new WildGrass(446, 250));
            wildgrass.Add(new WildGrass(406, 250));
            wildgrass.Add(new WildGrass(366, 250));
            wildgrass.Add(new WildGrass(326, 330));
            wildgrass.Add(new WildGrass(326, 370));
            wildgrass.Add(new WildGrass(326, 410));
            wildgrass.Add(new WildGrass(326, 450));
            wildgrass.Add(new WildGrass(366, 450));
            wildgrass.Add(new WildGrass(406, 450));
            wildgrass.Add(new WildGrass(446, 450));
            wildgrass.Add(new WildGrass(486, 450));
            wildgrass.Add(new WildGrass(526, 450));
            wildgrass.Add(new WildGrass(566, 450));
            wildgrass.Add(new WildGrass(606, 450));
            wildgrass.Add(new WildGrass(286, 450));
            wildgrass.Add(new WildGrass(246, 450));
            wildgrass.Add(new WildGrass(246, 410));
            wildgrass.Add(new WildGrass(286, 410));
            wildgrass.Add(new WildGrass(286, 410));
            wildgrass.Add(new WildGrass(246, 410));
            wildgrass.Add(new WildGrass(246, 370));
            wildgrass.Add(new WildGrass(286, 370));
            wildgrass.Add(new WildGrass(286, 330));
            wildgrass.Add(new WildGrass(246, 330));
            wildgrass.Add(new WildGrass(246, 130));
            wildgrass.Add(new WildGrass(286, 130));

            #endregion
        }
        public void StopActionFromPokemon(Pokemons poke)
        {
            pokemonDefeated[poke.index] = true;

            if (poke.index == 93) // Haunter (help Little Girl)
            {
                mainForm.ShowMessage("Little Girl: My hero! I was playing around and this evil Haunter appeared from nowhere. Maybe he came from the Haunted House next to the village...");
            }

            if (poke.index == 386 || poke.index == 488 || poke.index == 249) // Deoxys, Cresselia, Lugia will break free from your team
                PokemonBreakFree(poke.index);

            if (poke.index == 249 || (poke.index >= 144 && poke.index <= 146)) // legendary birds
            {
                wildpokemons.Clear();
                actionpoint.Clear();

                pokemonDefeated[249] = true;
                pokemonDefeated[144] = true;
                pokemonDefeated[145] = true;
                pokemonDefeated[146] = true;

                FormGame.map = new Map(43, 410, 150);
                mainForm.ShowMessage("That was strange...");
            }

            if(legendariesCount == -2) // legendary void
            {
                FormGame.map = new Map(49, 385, 515);
            }

            int j = -1;

            for (int i = 0; i < wildpokemons.Count; ++i)
            {
                if (wildpokemons[i].index == poke.index)
                {
                    j = i;
                    wildpokemons.RemoveAt(j);
                    break;
                }
            }

            for (int i = 0; i < actionpoint.Count; ++i)
            {
                if (actionpoint[i].action == j + 100)
                {
                    actionpoint.RemoveAt(i);
                    break;
                }
            }
        }
        private void LoadTournament(int level)
        {
            pbCanvas.BackgroundImage = Resources.tournamentInside;

            FormGame.OX = 272;
            FormGame.OY = 296;

            Keyboard.ChangeDir(3, true);
            player.ChangeSprite();
            Keyboard.ClearStack();
            FormGame.stopMovement = true;

            player.pokeballs.Clear();
            player.potions.Clear();

            if(level == 1)
            {
                characters.Add(new Character("Gary", Resources.character_gary, 482, 280));

                Pokemons poke = new Pokemons(142, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(18));
                poke.moves.Add(new Attack(63));
                poke.moves.Add(new Attack(16));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(9, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(308));
                poke.moves.Add(new Attack(130));
                poke.moves.Add(new Attack(110));
                poke.moves.Add(new Attack(229));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(197, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(94));
                poke.moves.Add(new Attack(247));
                poke.moves.Add(new Attack(104));
                poke.moves.Add(new Attack(130));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(466, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(9));
                poke.moves.Add(new Attack(231));
                poke.moves.Add(new Attack(182));
                poke.moves.Add(new Attack(87));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(126, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(53));
                poke.moves.Add(new Attack(126));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(212, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(98));
                poke.moves.Add(new Attack(232));
                poke.moves.Add(new Attack(129));
                poke.moves.Add(new Attack(211));
                characters[0].pokemons.Add(poke);

                characters[0].index = 118;
            }

            if(level == 2)
            {
                characters.Add(new Character("Ash", Resources.character_ash, 482, 280));

                Pokemons poke = new Pokemons(25, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(344));
                poke.moves.Add(new Attack(231));
                poke.moves.Add(new Attack(97));
                poke.moves.Add(new Attack(85));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(6, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(315));
                poke.moves.Add(new Attack(225));
                poke.moves.Add(new Attack(53));
                poke.moves.Add(new Attack(130));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(7, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(56));
                poke.moves.Add(new Attack(55));
                poke.moves.Add(new Attack(229));
                poke.moves.Add(new Attack(110));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(254, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(348));
                poke.moves.Add(new Attack(97));
                poke.moves.Add(new Attack(98));
                poke.moves.Add(new Attack(437));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(398, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(370));
                poke.moves.Add(new Attack(413));
                poke.moves.Add(new Attack(332));
                poke.moves.Add(new Attack(98));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(143, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(156));
                poke.moves.Add(new Attack(8));
                poke.moves.Add(new Attack(5));
                poke.moves.Add(new Attack(29));
                characters[0].pokemons.Add(poke);

                characters[0].index = 119;
            }

            if (level == 3)
            {
                characters.Add(new Character("Tobias", Resources.character_tobias, 482, 280));

                Pokemons poke = new Pokemons(491, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(58));
                poke.moves.Add(new Attack(464));
                poke.moves.Add(new Attack(138));
                poke.moves.Add(new Attack(399));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(380, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(416));
                poke.moves.Add(new Attack(295));
                poke.moves.Add(new Attack(113));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(381, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(416));
                poke.moves.Add(new Attack(295));
                poke.moves.Add(new Attack(113));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(389, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(202));
                poke.moves.Add(new Attack(235));
                poke.moves.Add(new Attack(89));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(226, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(392));
                poke.moves.Add(new Attack(36));
                poke.moves.Add(new Attack(340));
                poke.moves.Add(new Attack(61));
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(395, 70);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(56));
                poke.moves.Add(new Attack(65));
                poke.moves.Add(new Attack(54));
                characters[0].pokemons.Add(poke);

                characters[0].index = 120;
            }

            if (level == 4)
            {
                characters.Add(new Character("Thomas", Resources.character_thomas, 482, 280));

                Pokemons poke = new Pokemons(392, 80);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(172));
                poke.moves.Add(new Attack(264));
                poke.moves.Add(new Attack(370));
                poke.moves.Add(new Attack(394));
                poke.hpmax = 298;
                poke.hp = poke.hpmax;
                poke.atk = 248;
                poke.def = 203;
                poke.spatk = 248;
                poke.spdef = 213;
                poke.speed = 217;
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(384, 80);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(156));
                poke.moves.Add(new Attack(406));
                poke.moves.Add(new Attack(200));
                poke.moves.Add(new Attack(434));
                poke.hpmax = 225;
                poke.hp = poke.hpmax;
                poke.atk = 191;
                poke.def = 131;
                poke.spatk = 190;
                poke.spdef = 130;
                poke.speed = 135;
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(248, 80);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(242));
                poke.moves.Add(new Attack(89));
                poke.moves.Add(new Attack(444));
                poke.moves.Add(new Attack(63));
                poke.hpmax = 314;
                poke.hp = poke.hpmax;
                poke.atk = 269;
                poke.def = 245;
                poke.spatk = 231;
                poke.spdef = 237;
                poke.speed = 165;
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(376, 80);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(334));
                poke.moves.Add(new Attack(359));
                poke.moves.Add(new Attack(309));
                poke.moves.Add(new Attack(428));
                poke.hpmax = 244;
                poke.hp = poke.hpmax;
                poke.atk = 221;
                poke.def = 217;
                poke.spatk = 181;
                poke.spdef = 176;
                poke.speed = 140;
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(145, 80);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(355));
                poke.moves.Add(new Attack(113));
                poke.moves.Add(new Attack(65));
                poke.moves.Add(new Attack(87));
                poke.hpmax = 253;
                poke.hp = poke.hpmax;
                poke.atk = 174;
                poke.def = 170;
                poke.spatk = 209;
                poke.spdef = 174;
                poke.speed = 169;
                characters[0].pokemons.Add(poke);

                poke = new Pokemons(130, 80);
                poke.love = 200;
                poke.moves = new List<Attack>();
                poke.moves.Add(new Attack(56));
                poke.moves.Add(new Attack(349));
                poke.moves.Add(new Attack(63));
                poke.moves.Add(new Attack(57));
                poke.hpmax = 309;
                poke.hp = poke.hpmax;
                poke.atk = 260;
                poke.def = 214;
                poke.spatk = 195;
                poke.spdef = 236;
                poke.speed = 184;
                characters[0].pokemons.Add(poke);

                characters[0].index = 121;
            }

            ShuffleTeam(characters[0]);

            actionpoint.Add(new ActionPoint(0, 0, 800, 600, 0));
        }