Example #1
0
        private void FillData(OPokemon pokemon)
        {
            textBoxName.Text      = pokemon.Name;
            textBoxName.ForeColor = Color.Black;

            textBoxCategory.Text      = pokemon.Category;
            textBoxCategory.ForeColor = Color.Black;

            richTextBoxDescription.Text      = pokemon.Description;
            richTextBoxDescription.ForeColor = Color.Black;

            numericUpDownHeight.Value = pokemon.Height;
            numericUpDownWeight.Value = pokemon.Weight;

            try
            { numericUpDownHealth.Value = pokemon.Health; }
            catch (Exception)
            { numericUpDownHealth.Value = 1; }
            try
            { numericUpDownAttack.Value = pokemon.Attack; }
            catch (Exception)
            { numericUpDownAttack.Value = 1; }
            try
            { numericUpDownDefense.Value = pokemon.Defense; }
            catch (Exception)
            { numericUpDownDefense.Value = 1; }
            try
            { numericUpDownSpecialAttack.Value = pokemon.SpecialAttack; }
            catch (Exception)
            { numericUpDownSpecialAttack.Value = 1; }
            try
            { numericUpDownSpecialDefense.Value = pokemon.SpecialDefense; }
            catch (Exception)
            { numericUpDownSpecialDefense.Value = 1; }
            try
            { numericUpDownSpeed.Value = pokemon.Speed; }
            catch (Exception)
            { numericUpDownSpeed.Value = 1; }

            numericUpDownHealthEVs.Value         = pokemon.GivedEVs[PokeStat.Health];
            numericUpDownAttackEVs.Value         = pokemon.GivedEVs[PokeStat.Attack];
            numericUpDownDefenseEVs.Value        = pokemon.GivedEVs[PokeStat.Defense];
            numericUpDownSpecialAttackEVs.Value  = pokemon.GivedEVs[PokeStat.SpecialAttack];
            numericUpDownSpecialDefenseEVs.Value = pokemon.GivedEVs[PokeStat.SpecialDefense];
            numericUpDownSpeedEVs.Value          = pokemon.GivedEVs[PokeStat.Speed];

            comboBoxAbility1.SelectedIndex      = pokemon.Abilities[0];
            comboBoxAbility2.SelectedIndex      = pokemon.Abilities[1];
            comboBoxAbilityHidden.SelectedIndex = pokemon.Abilities[2];

            comboBoxLevelType.SelectedIndex = pokemon.LevelType;

            comboBoxType1.SelectedIndex = pokemon.Types[0];
            comboBoxType2.SelectedIndex = pokemon.Types[1];

            numericUpDownMale.Value = pokemon.GenresPercentage[0];
            numericUpDownMale.Value = pokemon.GenresPercentage[1];

            return;
        }
Example #2
0
 public AddOrUpdatePokemonForm(OPokemon pokemon)
 {
     InitializeComponent();
     InitializeComboBoxes();
     this.pokemon = pokemon;
     FillData(pokemon);
     labelTitle.Text = "Update Pokémon";
 }
Example #3
0
        private void btnShowPokemon_Click(object sender, EventArgs e)
        {
            OPokemon p = Pokedex.LoadPokemonFromXML(textBoxEnterPokemonId.Text);

            if (p != null)
            {
                textBoxShowPokemonData.Text = p.Show();
            }
            else
            {
                MessageBox.Show("Pokémon not finded");
            }
        }
Example #4
0
        private void ShowPokemon()
        {
            OPokemon p = /*Pokedex.LoadPokemonFromPokedexXML(textBoxSearchPoke.Text)*/ null;

            if (p != null)
            {
                richTextBoxShowPoke.Text = p.Show();
            }

            else
            {
                MessageBox.Show(textBoxSearchPoke.Text + "Not Finded");
            }
        }
Example #5
0
        public static OPokemon LoadPokemon(string name)
        {
            XDocument doc = XMLTools.GetXMLDocument(path);
            OPokemon  p   = null;

            if (doc != null)
            {
                foreach (XElement e in doc.Root.Elements())
                {
                    if (e.Element("name").Value.ToUpper().Equals(name.ToUpper()))
                    {
                        p = LoadPokemonFromXML(e);
                    }
                }
            }

            return(p);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            OPokemon p = /*Pokedex.LoadPokemonFromPokedexXML(textBoxSearchPoke.Text)*/ null;

            if (index != null && p != null)
            {
                if (mode == Updates)
                {
                    index.OpenChildForm(new AddOrUpdatePokemonForm(p));
                }

                /*else if (mode == Remove)
                 *  try { Pokedex.RemovePokemonFromPokedexXML(p.Name); }
                 *  catch (Exception){ MessageBox.Show("There was an error removing " + p.Name + ". Check the Log for more information.", "Error at Remove"); }*/
                else
                {
                    MessageBox.Show(textBoxSearchPoke.Text + "Not Finded");
                }
            }

            Dispose();
        }
Example #7
0
        private void AddPokemon()
        {
            pokemon = new OPokemon();

            if (CheckData())
            {
                try
                {
                    SetDataInPokemon();

                    //Pokedex.SavePokemonInPokedexXML(pokemon);

                    MessageBox.Show("Congratulations. You added a Pokémon succesfuly.", "Pokémon Added", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Dispose();
                }catch (Exception e)
                {
                    Log.Execute("Error adding " + pokemon.Name + ".", e);
                    MessageBox.Show("There was a problem adding the Pokémon. Please, check the Log for more information.", "Add Pokémon Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            return;
        }
Example #8
0
        public static List <OPokemon> Load()
        {
            List <OPokemon> pokemon = new List <OPokemon>();

            XDocument doc  = XMLTools.GetXMLDocument(path);
            XElement  root = doc.Root;

            if (doc != null)
            {
                foreach (XElement e in root.Elements("pokemon"))
                {
                    try
                    {
                        OPokemon newPoke = LoadPokemonFromXML(e);
                        pokemon.Add(newPoke);
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(pokemon);
        }
Example #9
0
        private static OPokemon LoadPokemonFromXML(XElement e)
        {
            OPokemon p = new OPokemon();

            p.Id            = Convert.ToInt32(e.Attribute("id").Value);
            p.PokedexNumber = Convert.ToInt32(e.Element("pokedexNumber").Value);
            p.Name          = e.Element("name").Value;
            p.Category      = e.Element("category").Value;
            p.Habitat       = e.Element("habitat").Value;
            p.FileName      = e.Element("fileName").Value;
            p.Description   = e.Element("description").Value;
            p.FileName      = e.Element("fileName").Value;
            p.Height        = Convert.ToUInt16(e.Element("height").Value);
            p.Weight        = Convert.ToUInt16(e.Element("weight").Value);
            p.Color         = Color.FromName(e.Element("color").Value);
            p.Rareness      = Convert.ToByte(e.Element("rareness").Value);
            p.Happiness     = Convert.ToByte(e.Element("happiness").Value);
            p.StepsToHatch  = Convert.ToInt32(e.Element("stepsToHatch").Value);

            p.Types[0] = Convert.ToByte(e.Element("type1").Value);
            p.Types[0] = Convert.ToByte(e.Element("type2").Value);

            p.Health         = Convert.ToByte(e.Element("health").Value);
            p.Attack         = Convert.ToByte(e.Element("attack").Value);
            p.SpecialAttack  = Convert.ToByte(e.Element("specialAttack").Value);
            p.Defense        = Convert.ToByte(e.Element("defense").Value);
            p.SpecialDefense = Convert.ToByte(e.Element("specialDefense").Value);
            p.Speed          = Convert.ToByte(e.Element("speed").Value);

            List <XElement> abilities = e.Element("abilities").Elements("ability").ToList();

            for (int i = 0; i < abilities.Count; ++i)
            {
                string s = abilities[i].Value;
                if (s != null)
                {
                    p.Abilities[i] = Convert.ToByte(s);
                }
            }

            List <XElement> movesWillLearnByLevel = e.Element("movesWillLearnByLevel").Elements("move").ToList();

            for (int i = 0; i < movesWillLearnByLevel.Count; ++i)
            {
                string s = movesWillLearnByLevel[i].Value;
                if (s != null)
                {
                    p.MovesWillLearnByLevel.Add(new OPokemon.MoveWillLearnByLevel(Convert.ToByte(movesWillLearnByLevel[i].Attribute("level").Value), Convert.ToInt32(s)));
                }
            }

            List <XElement> canLearnMoves = e.Element("canLearnMoves").Elements("move").ToList();

            for (int i = 0; i < canLearnMoves.Count; ++i)
            {
                string s = canLearnMoves[i].Value;
                if (s != null)
                {
                    p.CanLearnMoves.Add(Convert.ToInt32(s));
                }
            }

            XElement genres = e.Element("genresPercentage");

            p.GenresPercentage[0] = Convert.ToByte(genres.Element("male").Value);
            p.GenresPercentage[1] = Convert.ToByte(genres.Element("female").Value);

            p.EggGroup = Convert.ToByte(e.Element("eggGroup").Value);

            p.LevelType   = Convert.ToByte(e.Element("levelType").Value);
            p.IsMega      = Convert.ToBoolean(e.Element("isMega").Value);
            p.IsLegendary = Convert.ToBoolean(e.Element("isLegendary").Value);

            p.GivedEVs[PokeStat.Health]         = Convert.ToByte(e.Element("healthEV").Value);
            p.GivedEVs[PokeStat.Attack]         = Convert.ToByte(e.Element("attackEV").Value);
            p.GivedEVs[PokeStat.SpecialAttack]  = Convert.ToByte(e.Element("specialAttackEV").Value);
            p.GivedEVs[PokeStat.Defense]        = Convert.ToByte(e.Element("defenseEV").Value);
            p.GivedEVs[PokeStat.SpecialDefense] = Convert.ToByte(e.Element("specialDefenseEV").Value);
            p.GivedEVs[PokeStat.Speed]          = Convert.ToByte(e.Element("speedEV").Value);

            p.ExperienceGives = Convert.ToByte(e.Element("experienceGives").Value);

            return(p);
        }