Ejemplo n.º 1
0
        public bool Missed()
        {
            if (AdditionalEffects.ContainsEffectType(typeof(AlwaysHits)))
            {
                return(false);
            }

            return(!ChanceCalculator.CalculateChance(Accuracy.Value));
        }
Ejemplo n.º 2
0
        public static bool IsCritical(ICollection <IAdditionalEffect> attackAdditionalEffects, bool isAttackingPokemonFocused)
        {
            int boostCrit = isAttackingPokemonFocused ? 20 : 0;

            if (AdditionalEffectAvailability.ContainsEffectType(attackAdditionalEffects, typeof(HighCriticalRatio)))
            {
                return(ChanceCalculator.CalculateChance(21 + boostCrit, 255));
            }
            else
            {
                return(ChanceCalculator.CalculateChance(1 + boostCrit, 255));
            }
        }
Ejemplo n.º 3
0
        public bool IsAbleToAttackAfterConditionEffect()
        {
            int damage;

            switch (Condition)
            {
            case 0:
                return(true);

            case Condition.BRN:
                damage = HPMax / 16;
                Hurt(damage);
                //_battleLogController.SetText($"{pokemon.Name} is burning (Damage: {damage})");
                return(IsPokemonAlive());

            case Condition.FRZ:
                //_battleLogController.SetText($"{pokemon.Name} is frozen");
                return(false);

            case Condition.PAR:
                if (ChanceCalculator.CalculateChance(50))
                {
                    return(true);
                }
                //_battleLogController.SetText($"{pokemon.Name} is unable to move");
                return(false);

            case Condition.PSN:
                damage = HPMax / 16;
                Hurt(damage);
                //_battleLogController.SetText($"{pokemon.Name} is hurt by poison (Damage: {damage})");
                return(IsPokemonAlive());

            case Condition.SLP:
                if (ChanceCalculator.CalculateChance(50))
                {
                    //_battleLogController.SetText($"{pokemon.Name} woke up");
                    Condition = 0;
                    return(true);
                }
                //_battleLogController.SetText($"{pokemon.Name} is still sleeping");
                return(false);

            default:
                return(true);
            }
        }
Ejemplo n.º 4
0
 public static bool HasFailedConfusion(IPokemon attackingPokemon) => ChanceCalculator.CalculateChance(50, 100);
Ejemplo n.º 5
0
        private void ExecuteAfterAttackAdditionalEffects(IPokemon pokemon, IAttack attack, IPokemon target)
        {
            if (AdditionalEffectAvailability.ContainsEffectType(attack.AdditionalEffects, typeof(CritBoosting)))
            {
                if (attack.AdditionalEffects.Any(e => e.ID == (int)AdditionalEffectEnum.BoostCriticalSelf))
                {
                    CritBoosting critBoosting = attack.AdditionalEffects.First(e => e.ID == (int)AdditionalEffectEnum.BoostCriticalSelf) as CritBoosting;
                    if (pokemon.IsEnergyFocused == false)
                    {
                        pokemon.IsEnergyFocused = true;
                    }
                    else
                    {
                        _battleLogController.SetText($"{pokemon.Name} is already focused");
                    }
                }
                else if (attack.AdditionalEffects.Any(e => e.ID == (int)AdditionalEffectEnum.BoostCriticalTarget))
                {
                    CritBoosting critBoosting = attack.AdditionalEffects.First(e => e.ID == (int)AdditionalEffectEnum.BoostCriticalTarget) as CritBoosting;
                    if (target.IsEnergyFocused == false)
                    {
                        target.IsEnergyFocused = true;
                    }
                    else
                    {
                        _battleLogController.SetText($"{target.Name} is already focused");
                    }
                }
            }

            if (AdditionalEffectAvailability.ContainsEffectType(attack.AdditionalEffects, typeof(StatusChanger)))
            {
                var statusChanger = attack.AdditionalEffects.First();


                if (attack.AdditionalEffects.Any(e => e.ID == (int)AdditionalEffectEnum.PoisonWeak ||
                                                 e.ID == (int)AdditionalEffectEnum.PoisonMid ||
                                                 e.ID == (int)AdditionalEffectEnum.PoisonHigh ||
                                                 e.ID == (int)AdditionalEffectEnum.PoisonMax))
                {
                    if (ChanceCalculator.CalculateChance((int)statusChanger.PrimaryParameter, 100))
                    {
                        _battleLogController.SetText($"{target.Name} is now poisoned");
                        target.Condition = Condition.PSN;
                    }
                }

                if (attack.AdditionalEffects.Any(e => e.ID == (int)AdditionalEffectEnum.BurnWeak ||
                                                 e.ID == (int)AdditionalEffectEnum.BurnMaxSelf))
                {
                    if (ChanceCalculator.CalculateChance((int)statusChanger.PrimaryParameter, 100))
                    {
                        if (statusChanger.IsOnSelf)
                        {
                            pokemon.Condition = Condition.BRN;
                            _battleLogController.SetText($"{pokemon.Name} is now burning");
                        }
                        else
                        {
                            pokemon.Condition = Condition.BRN;
                            _battleLogController.SetText($"{pokemon.Name} is now burning");
                        }
                    }
                }

                if (attack.AdditionalEffects.Any(e => e.ID == (int)AdditionalEffectEnum.ConfusionWeak ||
                                                 e.ID == (int)AdditionalEffectEnum.ConfusionMax))
                {
                    if (ChanceCalculator.CalculateChance((int)statusChanger.PrimaryParameter, 100))
                    {
                        if (statusChanger.IsOnSelf)
                        {
                            pokemon.IsConfused = true;
                            _battleLogController.SetText($"{pokemon} is now confused");
                        }
                        else
                        {
                            target.IsConfused = true;
                            _battleLogController.SetText($"{target} is now confused");
                        }
                    }
                }
            }
        }