Example #1
0
    void TreatSecondaries(TargetableElement target, Globals.SecondaryEffect secondary, bool isSelf)
    {
        bool hitResult = false;

        if (target.sourceElement is PokemonCharacter)
        {
            int     didSomething = -1;
            Pokemon pokeTarget   = ((PokemonCharacter)target.sourceElement).pokemonData;

            //Secondary boosts
            if (secondary.boosts != null && !pokeTarget.fainted)
            {
                hitResult    = battle.Boost(secondary.boosts, target, source, secondary.SecondaryToMove());
                didSomething = (hitResult) ? 1 : 0;
            }

            //Secondary status
            if (secondary.status != "")
            {
                hitResult = pokeTarget.TrySetStatus(secondary.status, source, secondary.SecondaryToMove());
                if (!hitResult)
                {
                    return;
                }
                if (didSomething < 1)
                {
                    didSomething = (hitResult) ? 1 : 0;
                }
            }

            //Secondary volatile
            if (secondary.volatileStatus != "")
            {
                //FLONCH
                if (secondary.volatileStatus != "flinch")
                {
                    pokeTarget.StartActionCoolDown();
                }
                else
                {
                    hitResult = pokeTarget.AddVolatile(secondary.volatileStatus, source, secondary.SecondaryToMove());
                    if (didSomething < 1)
                    {
                        didSomething = (hitResult) ? 1 : 0;
                    }
                }
            }
        }
    }