Beispiel #1
0
 /* The private constructor for a Pokemon initializes the object with null values.
  * It is used when a Pokemon is deserialized from an XML file. */
 private Pokemon()
 {
     baseHP = baseAttack = baseDefence = baseSpecialAttack = baseSpecialDefence = baseSpeed = 0;
     health = new AttributePair(0);
     iv_HP  = iv_Attack = iv_Defence = iv_SpecialAttack = iv_SpecialDefence = iv_Speed = 0;
     ev_HP  = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 0;
     type   = new List <PkmnType>();
 }
Beispiel #2
0
 /* The private constructor for a move initializes everything with null values.
  * It is used when Moves are deserialized from XML. */
 private Move()
 {
     name     = "";
     power    = 0;
     accuracy = 0;
     Category = MoveCategory.physical;
     Type     = PkmnType.normal;
     pp       = new AttributePair(0);
     priority = 0;
     flags    = new bool[20];
 }
Beispiel #3
0
 /* The main Move constructor takes the name, power, accuracy, priority, type, maximum PP, and flags of the move.
  * All the parameters are set appropriately. Array.Copy() is used to copy the flags array. */
 public Move(string name, byte power, byte accuracy, sbyte priority, MoveCategory moveCategory, PkmnType moveType, byte maxPP, bool[] flags)
 {
     this.name     = name;
     this.power    = power;
     this.accuracy = accuracy;
     this.priority = priority;
     this.category = moveCategory;
     this.type     = moveType;
     pp            = new AttributePair(maxPP);
     this.flags    = new bool[20];
     Array.Copy(flags, this.flags, 20);
 }
Beispiel #4
0
        /* The main constructor for a Pokemon takes its species (PokemonData), Gender, moveset, level, and a TrainerRank.
         * The TrainerRank is nullable so that null can be passed in for a wild Pokemon. */
        public Pokemon(PokemonData pokemonData, Gender gender, Move[] moves, byte level, TrainerRank?rank)
        {
            /* The nickname, type and base stats for the Pokemon are copied from the PokemonData for its species. */
            Nickname           = pokemonData.PokemonName;
            pokemonID          = pokemonData.ID;
            baseHP             = pokemonData.BaseHP;
            baseAttack         = pokemonData.BaseAttack;
            baseDefence        = pokemonData.BaseDefence;
            baseSpecialAttack  = pokemonData.BaseSpecialAttack;
            baseSpecialDefence = pokemonData.BaseSpecialDefence;
            baseSpeed          = pokemonData.BaseSpeed;
            type = new List <PkmnType>();
            type = pokemonData.Type;

            /* Gender and Level are set according to what was passed in. */
            this.gender = gender;
            this.level  = level;

            /* Fainted is false by default, as a Pokemon is initially conscious. */
            fainted = false;

            /* The moveset is copied using Array.Copy(). */
            Array.Copy(moves, this.moves, 4);

            /* The IVs for the Pokemon are randomly generated between 0 and 31. */
            iv_HP             = (byte)PkmnUtils.RandomInclusive(31);
            iv_Attack         = (byte)PkmnUtils.RandomInclusive(31);
            iv_Defence        = (byte)PkmnUtils.RandomInclusive(31);
            iv_SpecialAttack  = (byte)PkmnUtils.RandomInclusive(31);
            iv_SpecialDefence = (byte)PkmnUtils.RandomInclusive(31);
            iv_Speed          = (byte)PkmnUtils.RandomInclusive(31);

            /* The EVs of the Pokemon are set according to the TrainerRank passed in.
             * This will only happen if the Pokemon is owned by an NPC trainer.
             * The TrainerRank will be null for player Pokemon (since they earn EVs through battle and start at 0).
             * It will also be null for wild Pokemon since they have EVs of 0. */
            if (rank.HasValue)
            {
                if (rank.Value == TrainerRank.Normal)
                {
                    ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 0;
                }
                else if (rank.Value == TrainerRank.Grunt)
                {
                    ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 10;
                }
                else if (rank.Value == TrainerRank.Elite)
                {
                    ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 20;
                }
                else if (rank.Value == TrainerRank.GymLeader)
                {
                    ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 40;
                }
                else if (rank.Value == TrainerRank.EliteFour)
                {
                    ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 60;
                }
                else if (rank.Value == TrainerRank.Champion)
                {
                    ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 80;
                }
            }
            else
            {
                /* This block executes if the TrainerRank passed in is null.
                 * This means newly created wild Pokemon or player Pokemon have EVs of 0. */
                ev_HP = ev_Attack = ev_Defence = ev_SpecialAttack = ev_SpecialDefence = ev_Speed = 0;
            }

            /* Finally, set the health of the Pokemon using the new HP stats. */
            health = new AttributePair(HP);
        }