Beispiel #1
0
        /* The public constructor for a PokemonData takes a lot of parameters. */
        public PokemonData(string pokemonName, byte baseHP, byte baseAttack, byte baseDefence, byte baseSpecialAttack, byte baseSpecialDefence, byte baseSpeed, ushort id, PkmnType type, PkmnType?secondType, bool canHaveGender, string species, double weightKg, double heightM, EggGroup eggGroup, EggGroup?secondEggGroup, ushort baseExp, byte captureRate, byte baseHappiness, GrowthRate growthRate, byte eggCycles, byte maleRatio, byte femaleRatio, EvYield evYield)
        {
            /* The majority of the fields are set directly using the parameters passed in. */
            PokemonName        = pokemonName;
            BaseHP             = baseHP;
            BaseAttack         = baseAttack;
            BaseDefence        = baseDefence;
            BaseSpecialAttack  = baseSpecialAttack;
            BaseSpecialDefence = baseSpecialDefence;
            BaseSpeed          = baseSpeed;
            ID            = id;
            CanHaveGender = canHaveGender;
            Species       = species;
            WeightKg      = weightKg;
            HeightM       = heightM;
            BaseExp       = baseExp;
            CaptureRate   = captureRate;
            BaseHappiness = baseHappiness;
            GrowthRate    = growthRate;
            EggCycles     = eggCycles;
            GenderRatio   = new GenderRatio(maleRatio, femaleRatio);
            EvYield       = evYield;

            /* For the Type and EggGroups properties, which can contain one or two values each,
             * the second parameter can be passed as null.
             * If the second parameter is null, the lists will only contain one item.
             * If the second parameter has a value, the lists will contain two items. */
            Type = new List <PkmnType>();
            Type.Add(type);
            if (secondType.HasValue)
            {
                Type.Add(secondType.Value);
            }
            EggGroups = new List <EggGroup>();
            EggGroups.Add(eggGroup);
            if (secondEggGroup.HasValue)
            {
                EggGroups.Add(secondEggGroup.Value);
            }
        }
Beispiel #2
0
 /* This static function uses the Gender Ratio of the Pokemon's species to randomly generate a Gender value for the Pokemon,
  * according to the proportions in the Gender Ratio. */
 public static Gender GetGender(GenderRatio ratio)
 {
     /* If the ratio's male and female values are both zero, the Pokemon is genderless. */
     if (ratio.male == 0 && ratio.female == 0)
     {
         return(Gender.none);
     }
     else
     {
         /* If the Pokemon can be male or female, the function uses the Mechanics.ProportionValue<T> class.
          * An array of two ProportionValue<Gender>s is created for the male and female proportion values.
          * The male and female ratioes are added to the array.
          * The ratios are bytes between 0 and 100, so they are converted to doubles between 0 and 1 to be used in the ProportionValue.
          * Finally, the ChooseByRandom() function is used to return a gender using the ratios from the GenderRatio passed in.
          * ChooseByRandom() works such that, for example, if the GenderRatio was 75 for male and 25 for female,
          * there is a 75% chance of the function returning male, and a 25% chance of it returning female. */
         ProportionValue <Gender>[] genders = new ProportionValue <Gender> [2];
         genders[0] = ProportionValue.Create(Convert.ToDouble(ratio.male) / 100, Gender.male);
         genders[1] = ProportionValue.Create(Convert.ToDouble(ratio.female) / 100, Gender.female);
         return(genders.ChooseByRandom());
     }
 }