Exemple #1
0
        private static void Generic(AtkContext atk)
        {
            var move = atk.Move;
            var aer  = atk.Attacker;

            if (move.PrepareOneTurn && PrepareOneTurn(atk))
            {
                return;
            }

            if (aer.Controller.GameSettings.Mode.XBound() != 1 && (move.Id == Ms.WATER_PLEDGE || move.Id == Ms.FIRE_PLEDGE || move.Id == Ms.GRASS_PLEDGE))
            {
                if (aer.Field.AddTurnCondition(Cs.Plege, move.Id))
                {
                    foreach (var pm in aer.Controller.ActingPokemons)
                    {
                        if (pm.Pokemon.TeamId == aer.Pokemon.TeamId && pm.SelectedMove != null &&
                            pm.SelectedMove.MoveE.Id != move.Id && (pm.SelectedMove.MoveE.Id == Ms.WATER_PLEDGE || pm.SelectedMove.MoveE.Id == Ms.FIRE_PLEDGE || pm.SelectedMove.MoveE.Id == Ms.GRASS_PLEDGE) &&
                            pm.CanMove)
                        {
                            aer.ShowLogPm(Ls.Pledge, pm.Id);
                            aer.Controller.Board.SetTurnCondition(Cs.NextActingPokemon, pm);
                            return;
                        }
                    }
                }
            }

            if (move.Snatchable)
            {
                foreach (var pm in atk.Controller.OnboardPokemons)
                {
                    if (pm.OnboardPokemon.HasCondition(Cs.Snatch))
                    {
                        pm.OnboardPokemon.RemoveCondition(Cs.Snatch);
                        pm.ShowLogPm("Snatch", aer.Id);
                        var s = new AtkContext(pm)
                        {
                            Move = move
                        };
                        InitAtkContext.Execute(s);
                        MoveE.BuildDefContext(s, null);
                        if (MoveNotFail.Execute(s))
                        {
                            MoveAct.Execute(s);
                        }
                        else
                        {
                            s.FailAll();
                        }
                        atk.SetAttackerAction(PokemonAction.Done);
                        return;
                    }
                }
            }

            if (move.MagicCoat && atk.Targets == null && !atk.HasCondition(Cs.IgnoreMagicCoat))
            {
                foreach (var p in aer.Controller.GetOnboardPokemons(1 - aer.Pokemon.TeamId))
                {
                    if (STs.MagicCoat(atk, p))
                    {
                        atk.SetCondition(Cs.MagicCoat, new List <PokemonProxy>()
                        {
                            p
                        });
                        atk.FailAll(null);
                        MoveE.MagicCoat(atk);
                        return;
                    }
                }
            }

            CalculateType.Execute(atk);

            if (atk.Type == BattleType.Fire && aer.OnboardPokemon.HasCondition(Cs.Powder))
            {
                aer.EffectHurtByOneNth(4, Ls.Powder);
                atk.FailAll(null);
                return;
            }
            if (atk.Move.Move.Category != MoveCategory.Status)
            {
                if (atk.Type == BattleType.Fire && aer.Controller.Board.GetCondition <int>(Cs.SpWeather) == As.PRIMORDIAL_SEA)
                {
                    atk.FailAll(Ls.HeavyRain);
                    return;
                }
                if (atk.Type == BattleType.Water && aer.Controller.Board.GetCondition <int>(Cs.SpWeather) == As.DESOLATE_LAND)
                {
                    atk.FailAll(Ls.HarshSunlight);
                    return;
                }
            }
            if (aer.AbilityE(As.PROTEAN) && aer.OnboardPokemon.SetTypes(atk.Type))
            {
                aer.RaiseAbility();
                aer.ShowLogPm("TypeChange", (int)atk.Type);
            }

            MoveE.FilterDefContext(atk);
            if (atk.Targets != null && atk.Target == null)
            {
                atk.FailAll(null);
            }
            else
            {
                MoveAct.Execute(atk);
                MoveE.MoveEnding(atk);
            }

            if (move.MagicCoat && atk.Targets != null)
            {
                MoveE.MagicCoat(atk);
            }
        }
Exemple #2
0
        public static void Execute(AtkContext atk, Tile selectTile = null)
        {
            var move = atk.Move.Id;
            var aer  = atk.Attacker;

            if (MoveNotFail.Execute(atk))
            {
                switch (move)
                {
                case Ms.METRONOME:     //118
                    Metronome(atk);
                    break;

                case Ms.MIRROR_MOVE:     //119
                    MirrorMove(atk);
                    break;

                case Ms.SLEEP_TALK:     //214
                    SleepTalk(atk);
                    break;

                case Ms.NATURE_POWER:     //267
                    NaturePower(atk, selectTile);
                    break;

                case Ms.ASSIST:     //274
                    Assist(atk);
                    break;

                case Ms.SNATCH:     //289
                    Snatch(atk);
                    break;

                case Ms.ME_FIRST:     //382
                    MeFirst(atk);
                    break;

                case Ms.COPYCAT:     //383
                    Copycat(atk);
                    break;

                case Ms.Instruct:
                    Instruct(atk);
                    goto default;

                default:
                    atk.ImplementPressure();
                    Generic(atk);
                    if (atk.Fail)
                    {
                        switch (move)
                        {
                        case Ms.JUMP_KICK:
                        case Ms.HIGH_JUMP_KICK:
                            if (aer.EffectHurtByOneNth(2, Ls.FailSelfHurt))
                            {
                                aer.CheckFaint();
                            }
                            break;

                        case Ms.SELFDESTRUCT:
                        case Ms.EXPLOSION:
                            aer.Faint();
                            break;

                        case Ms.NATURAL_GIFT:         //363
                        case Ms.FLING:
                            aer.ConsumeItem();
                            break;
                        }
                    }
                    break;
                }
            }
            else
            {
                atk.ImplementPressure();
            }
            if (atk.Move.Id == Ms.RAGE && aer != null)
            {
                aer.OnboardPokemon.SetCondition(Cs.Rage);
            }
        }