Beispiel #1
0
 private static void EatDefenderBerry(DefContext def)
 {
     if (ITs.CanLostItem(def.Defender))
     {
         var i = def.Defender.Pokemon.Item;
         if (ITs.Berry(i))
         {
             def.SetCondition(Cs.EatenBerry, i);
         }
     }
 }
Beispiel #2
0
        private static void RemoveItem(DefContext def, bool sp, string log)
        {
            var der = def.Defender;

            if (ITs.CanLostItem(der))
            {
                var i = der.Pokemon.Item;
                if (!sp || ITs.Berry(i) || ITs.Gem(i))
                {
                    der.RemoveItem();
                    der.ShowLogPm(log, i, sp ? 0 : def.AtkContext.Attacker.Id);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// contains battle log
        /// </summary>
        /// <param name="atk"></param>
        /// <returns></returns>
        public static bool Execute(AtkContext atk)
        {
            var aer = atk.Attacker;

            if (atk.Targets == null || atk.Target != null)
            {
                switch (atk.Move.Id)
                {
                case Ms.SKETCH:     //166
                case Ms.TELEPORT:
                case Ms.HAPPY_HOUR:
                    break;

                case Ms.SELFDESTRUCT:     //120
                case Ms.EXPLOSION:
                    if (aer.Controller.Board.Pokemons.RaiseAbility(As.DAMP) != null)
                    {
                        atk.FailAll("FailSp", atk.Attacker.Id, atk.Move.Id);
                        return(false);
                    }
                    return(true);

                case Ms.REST:     //156
                    if (aer.Hp == aer.Pokemon.MaxHp)
                    {
                        atk.FailAll("FullHp", aer.Id);
                        return(false);
                    }
                    if (!PTs.CanAddXXX(aer, aer, true, AttachedState.SLP, true))
                    {
                        atk.FailAll(null);
                        return(false);
                    }
                    return(true);

                case Ms.SNORE:     //173
                case Ms.SLEEP_TALK:
                    if (aer.State == PokemonState.SLP)
                    {
                        return(true);
                    }
                    break;

                case Ms.FAKE_OUT:     //252
                case Ms.MAT_BLOCK:
                    foreach (var m in aer.Moves)
                    {
                        if (m.HasUsed)
                        {
                            goto FAIL;
                        }
                    }
                    return(true);

                case Ms.STOCKPILE:     //254
                    if (aer.OnboardPokemon.GetCondition <int>(Cs.Stockpile) != 3)
                    {
                        return(true);
                    }
                    break;

                case Ms.SPIT_UP:     //255
                case Ms.SWALLOW:
                    if (aer.OnboardPokemon.HasCondition(Cs.Stockpile))
                    {
                        return(true);
                    }
                    break;

                case Ms.NATURAL_GIFT:     //363
                    if (ITs.CanLostItem(aer) && ITs.CanUseItem(aer) && ITs.Berry(aer.Pokemon.Item))
                    {
                        return(true);
                    }
                    break;

                case Ms.FLING:     //374
                    if (ITs.CanLostItem(aer) && ITs.CanUseItem(aer) && MoveBasePower.FlingPower(aer.Pokemon.Item) != 0)
                    {
                        return(true);
                    }
                    break;

                case Ms.ME_FIRST:     //382
                case Ms.SUCKER_PUNCH: //389
                {
                    var der = atk.Target.Defender;
                    var dm  = der.SelectedMove;
                    if (!(der.LastMoveTurn == der.Controller.TurnNumber || dm == null || dm.Move.Type.Category == MoveCategory.Status))
                    {
                        return(true);
                    }
                }
                break;

                case Ms.LAST_RESORT:     //387
                    foreach (var m in aer.Moves)
                    {
                        if (!m.HasUsed && m.MoveE.Id != Ms.LAST_RESORT)
                        {
                            goto FAIL;
                        }
                    }
                    return(true);

                case Ms.ALLY_SWITCH:
                    if (aer.Controller.GameSettings.Mode == GameMode.Double || aer.Controller.GameSettings.Mode == GameMode.Triple && aer.OnboardPokemon.X != 1)
                    {
                        return(true);
                    }
                    break;

                case Ms.BESTOW:     //516
                    if (aer.Pokemon.Item == 0 || ITs.NeverLostItem(aer.Pokemon))
                    {
                        return(true);
                    }
                    break;

                case Ms.BELCH:     //562
                    if (aer.OnboardPokemon.HasCondition(Cs.Belch))
                    {
                        return(true);
                    }
                    break;

                case Ms.HYPERSPACE_FURY:
                    if (aer.Pokemon.Form.Species.Number == Ps.HOOPA)
                    {
                        return(true);
                    }
                    break;

                default:
                    if (!atk.Move.HardToUseContinuously || ContinuousUse(atk))
                    {
                        return(true);
                    }
                    break;
                }
            }
FAIL:
            atk.FailAll();
            return(false);
        }