Exemple #1
0
        public static IPokemon CreatePokemon(int level, int id = 0)
        {
            IPokemon pokemon;

            level = level < 1 || level > 100 ? 5 : level;

            if (id != 0)
            {
                id = PokemonList.Pokemons.Any(p => p.Key == id) ? id : 1;

                pokemon = (IPokemon)PokemonList.Pokemons
                          .Where(p => p.Key == id)
                          .First()
                          .Value
                          .Clone();
            }
            else
            {
                var availablePokemons = PokemonList.Pokemons.Where(p => p.Value.MinimalLevel <= level && p.Value.MinimalLevel > 0);
                pokemon = (IPokemon)availablePokemons
                          .ElementAt(GenerateRandomNumber.GetRandomNumber(0, availablePokemons.Count()))
                          .Value
                          .Clone();
            }

            pokemon.Level     = level;
            pokemon.Stats     = PokemonStatsFactory.CreateStats(pokemon.Stats, level);
            pokemon.HPCurrent = pokemon.HPMax = pokemon.Stats.Health;
            pokemon.Attacks   = PokemonAttacksFactory.GetAttacks(pokemon);

            return(pokemon);
        }
Exemple #2
0
 public static IPokemonStats GetCalculatedStats(IPokemonStats pokemonBaseStats, int level)
 {
     return(new PokemonStats
     {
         Health = ((10 + pokemonBaseStats.Health + GenerateRandomNumber.GetRandomNumber(0, 20) + 50) * level) / 50 + 10,
         Attack = (((10 + pokemonBaseStats.Attack + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         Defence = (((10 + pokemonBaseStats.Defence + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         SpecialAttack = (((10 + pokemonBaseStats.SpecialAttack + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         SpecialDefence = (((10 + pokemonBaseStats.SpecialDefence + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         Speed = (((10 + pokemonBaseStats.Speed + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5
     });
 }
Exemple #3
0
 public IAttack GetEnemyAttack() => EnemyPokemon.Attacks.ElementAt(GenerateRandomNumber.GetRandomNumber(0, EnemyPokemon.Attacks.Count));
Exemple #4
0
 public static bool CalculateChance(int chance, int maxRange = 100)
 {
     return(GenerateRandomNumber.GetRandomNumber(0, maxRange) <= chance);
 }