Ejemplo n.º 1
0
        public sealed override void ExecuteAndUpdate(BattlePokemon user, BattlePokemon defender)
        {
            Move move1 = defender.Move1;
            Move move2 = defender.Move2;
            Move move3 = defender.Move3;
            Move move4 = defender.Move4;


            OnUsed();
            if (HasNoEffect(defender))
            {
                OnNoEffect();
            }
            else if (IsAMiss(user, defender))
            {
                OnMissed();
                defender.CheckForRageAndUpdateAttackStatStageIfNecessary();
            }
            //success condition:
            else if (!defender.IsDisabled() &&
                     (
                         (move1 != null && move1.CurrentPP > 0) ||
                         (move2 != null && move2.CurrentPP > 0) ||
                         (move3 != null && move3.CurrentPP > 0) ||
                         (move4 != null && move4.CurrentPP > 0)
                     )
                     )
            {
                bool disabled = false;
                while (!disabled)
                {
                    Random rng   = new Random();
                    int    rando = rng.Next(1, 5);
                    if (rando == 1 &&
                        move1 != null &&
                        move1.CurrentPP > 0)
                    {
                        defender.ActivateDisable(move1, rng.Next(0, 7));
                        disabled = true;
                    }
                    else if (rando == 2 &&
                             move2 != null &&
                             move2.CurrentPP > 0)
                    {
                        defender.ActivateDisable(move2, rng.Next(0, 7));
                        disabled = true;
                    }
                    else if (rando == 3 &&
                             move3 != null &&
                             move3.CurrentPP > 0)
                    {
                        defender.ActivateDisable(move3, rng.Next(0, 7));
                        disabled = true;
                    }
                    else if (rando == 4 &&
                             move4 != null &&
                             move4.CurrentPP > 0)
                    {
                        defender.ActivateDisable(move4, rng.Next(0, 7));
                        disabled = true;
                    }
                }
            }
            else
            {
                OnFailed();
                defender.CheckForRageAndUpdateAttackStatStageIfNecessary();
            }

            SetLastMoveAndMirrorMove(user, defender);
            SubtractPP(1);
        }