示例#1
0
        public int CalculateDamage(IPokemon pokemon, IPokemon target)
        {
            int damage = 0;

            if (AdditionalEffects.ContainsEffectType(typeof(AlwaysSameDamage)))
            {
                AlwaysSameDamage alwaysSameDamage = AdditionalEffects.First(e => e is AlwaysSameDamage) as AlwaysSameDamage;
                damage = alwaysSameDamage.IsBasedOnLevel() ? pokemon.Level : (int)alwaysSameDamage.PrimaryParameter;
            }

            if (damage == 0 && Power.HasValue)
            {
                damage = DamageCalculator.CalculateAttackDamage(this, pokemon, target);
                if (damage < 1)
                {
                    damage = 1;
                }
                if (BattleHelper.IsCritical(AdditionalEffects, pokemon.IsEnergyFocused))
                {
                    damage *= 2;
                    //_battleLogController.SetText("Critical hit!");
                }
            }
            return(damage);
        }
示例#2
0
        public bool IsAbleToAttack()
        {
            if (IsFlinched)
            {
                IsFlinched = false;
                //_battleLogController.SetText($"{attackingPokemon.Name} is flinched");
                return(false);
            }

            if (IsConfused && BattleHelper.HasFailedConfusion(this))
            {
                var confusionHit = PokemonAttacksFactory.CreateAttack("ConfusionHit");
                int damage       = DamageCalculator.CalculateAttackDamage(confusionHit, this, this);
                Hurt(damage);

                //_battleLogController.SetText($"{attackingPokemon.Name} hurts itself in its confusion");
                return(IsPokemonAlive());
            }

            return(true);
        }