public bool RandomHappen(int percentage)
        {
            if (percentage == 0)
            {
                return(true);
            }
            var a = Attacker.Ability;

            return(!Attacker.AbilityE(As.SHEER_FORCE) && Controller.RandomHappen(Attacker.AbilityE(As.SERENE_GRACE) ? percentage * 3 : Attacker.Field.HasCondition(Cs.Rainbow) ? percentage * 2 : percentage));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Item should not be null, or Unburden effect will be wrong
 /// </summary>
 public static void RemoveItem(this PokemonProxy pm)
 {
     pm.Pokemon.Item = 0;
     if (pm.AbilityE(As.UNBURDEN))
     {
         pm.OnboardPokemon.SetCondition(Cs.Unburden);
     }
 }
Exemplo n.º 3
0
 public static bool RaiseAbility(this PokemonProxy pm, int abilityId)
 {
     if (pm.AbilityE(abilityId))
     {
         RaiseAbility(pm);
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 public static void Illusion(PokemonProxy pm)
 {
     if (pm.AbilityE(As.ILLUSION))
         foreach (var p in pm.Pokemon.Owner.Pokemons.Reverse())
             if (p != pm && p.Hp > 0)
             {
                 pm.OnboardPokemon.SetCondition(Cs.Illusion, p.Pokemon);
                 break;
             }
 }
Exemplo n.º 5
0
 private static bool Safeguard(PokemonProxy pm, PokemonProxy by, bool showFail)
 {
     if (pm.Field.HasCondition(Cs.Safeguard) && pm != by && !by.AbilityE(As.INFILTRATOR))
     {
         if (showFail)
         {
             pm.ShowLogPm("Safeguard");
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
 private static bool CheckAbility(int ability, PokemonProxy pm, PokemonProxy by, AttachedState state, bool showFail)
 {
     if (pm.AbilityE(ability))
     {
         if (showFail)
         {
             pm.RaiseAbility();
             if (pm == by || state == AttachedState.Confuse)
             {
                 pm.ShowLogPm("Cant" + state);
             }
             else
             {
                 pm.NoEffect();
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
        public static void CalculatePriority(this PokemonProxy pm)
        {
            pm.Priority       = 0;
            pm.ItemSpeedValue = 0;
            if (pm.Action != PokemonAction.WillSwitch)
            {
                var m = pm.SelectedMove.MoveE;
                pm.Priority = m.Priority;
                if (m.Move.Category == MoveCategory.Status && pm.AbilityE(As.PRANKSTER) || m.Move.Type == BattleType.Flying && pm.AbilityE(As.GALE_WINGS) && pm.Hp == pm.Pokemon.MaxHp || pm.AbilityE(As.Triage) && m.Heal)
                {
                    pm.Priority++;
                }
                switch (pm.Item)
                {
                case Is.LAGGING_TAIL:
                case Is.FULL_INCENSE:
                    pm.ItemSpeedValue = -1;
                    break;

                case Is.QUICK_CLAW:
                    if (pm.Controller.RandomHappen(20))
                    {
                        ShowLogPm(pm, "QuickItem", Is.QUICK_CLAW);
                        pm.ItemSpeedValue = 1;
                    }
                    break;

                case Is.CUSTAP_BERRY:
                    if (ATs.Gluttony(pm))
                    {
                        ShowLogPm(pm, "QuickItem", Is.CUSTAP_BERRY);
                        pm.ConsumeItem();
                        pm.ItemSpeedValue = 1;
                    }
                    break;
                }
            }
        }
Exemplo n.º 8
0
        private static bool CanAddState(this PokemonProxy pm, PokemonProxy by, bool ability, AttachedState state, bool showFail)
        {
            if (!pm.AliveOnboard)
            {
                return(false);
            }
            string fail = pm.Controller.GameSettings.Mode.NeedTarget() ? "Fail" : Ls.Fail0;

            switch (state)
            {
            case AttachedState.BRN:
                if (pm.State == PokemonState.BRN)
                {
                    goto FAIL_BEENSTATE;
                }
                if (pm.OnboardPokemon.HasType(BattleType.Fire))
                {
                    goto FAIL_NOEFFECT;
                }
                goto STATE;

            case AttachedState.FRZ:
                if (pm.Controller.Weather == Weather.IntenseSunlight)
                {
                    goto FAIL_FAIL;                                                      //战报顺序未测
                }
                if (pm.State == PokemonState.FRZ)
                {
                    goto FAIL_BEENSTATE;
                }
                if (pm.OnboardPokemon.HasType(BattleType.Ice))
                {
                    goto FAIL_NOEFFECT;
                }
                goto STATE;

            case AttachedState.PAR:
                if (pm.State == PokemonState.PAR)
                {
                    goto FAIL_BEENSTATE;
                }
                if (pm.OnboardPokemon.HasType(BattleType.Electric))
                {
                    goto FAIL_NOEFFECT;
                }
                goto STATE;

            case AttachedState.PSN:
                if (pm.State == PokemonState.PSN || pm.State == PokemonState.BadlyPSN)
                {
                    if (showFail)
                    {
                        pm.ShowLogPm("BeenPSN");
                    }
                    return(false);
                }
                if (!by.AbilityE(As.Corrosion) && (pm.OnboardPokemon.HasType(BattleType.Poison) || pm.OnboardPokemon.HasType(BattleType.Steel)))
                {
                    goto FAIL_NOEFFECT;
                }
                goto STATE;

            case AttachedState.SLP:
                if (!(ability && pm.AbilityE(As.SOUNDPROOF)))
                {
                    foreach (var p in pm.Controller.OnboardPokemons)
                    {
                        if (p.Action == PokemonAction.Moving && p.AtkContext.Move.Id == Ms.UPROAR)
                        {
                            if (showFail)
                            {
                                if (p == pm)
                                {
                                    pm.ShowLogPm("UproarCantSLP2");
                                }
                                else
                                {
                                    pm.ShowLogPm("UproarCantSLP");
                                }
                            }
                            return(false);
                        }
                    }
                }
                if (pm.State == PokemonState.SLP)
                {
                    goto FAIL_BEENSTATE;
                }
                goto STATE;

            case AttachedState.Confuse:
                if (pm.OnboardPokemon.HasCondition(Cs.Confuse))
                {
                    goto FAIL_BEENSTATE;
                }
                return(!(Safeguard(pm, by, showFail) || ability && CheckAbility(As.OWN_TEMPO, pm, by, state, showFail)));

            case AttachedState.Attract:
                if (pm.OnboardPokemon.Gender == PokemonGender.None || by.OnboardPokemon.Gender == PokemonGender.None || pm.OnboardPokemon.Gender == by.OnboardPokemon.Gender)
                {
                    goto FAIL_NOEFFECT;
                }
                if (pm.OnboardPokemon.HasCondition(Cs.Attract))
                {
                    goto FAIL_FAIL;
                }
                return(!(ability && CheckAbility(As.OBLIVIOUS, pm, by, state, showFail)));

            case AttachedState.Trap:
                if (pm.OnboardPokemon.HasCondition(Cs.Trap))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.Nightmare:
                if (pm.State == PokemonState.SLP)
                {
                    if (pm.OnboardPokemon.HasCondition(Cs.Nightmare))
                    {
                        goto FAIL_FAIL;
                    }
                    else
                    {
                        return(true);
                    }
                }
                goto FAIL_NOEFFECT;    //战报已测

            case AttachedState.Torment:
                if (pm.OnboardPokemon.HasCondition(Cs.Torment))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.Disable:
                if (pm.LastMove == null || pm.OnboardPokemon.HasCondition(Cs.Disable))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.Yawn:
                if (pm.OnboardPokemon.HasCondition(Cs.Yawn))
                {
                    goto FAIL_FAIL;
                }
                return(CanAddXXX(pm, by, ability, AttachedState.SLP, showFail));

            case AttachedState.HealBlock:
                if (pm.OnboardPokemon.HasCondition(Cs.HealBlock))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.SoundBlock:
                if (pm.OnboardPokemon.HasCondition(Cs.SoundBlock))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.CanAttack:
                if (pm.OnboardPokemon.HasCondition(Cs.CanAttack))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.LeechSeed:
                if (pm.OnboardPokemon.HasType(BattleType.Grass))
                {
                    goto FAIL_NOEFFECT;
                }
                if (pm.OnboardPokemon.HasCondition(Cs.LeechSeed))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.Embargo:
                if (pm.OnboardPokemon.Ability == As.MULTITYPE || pm.OnboardPokemon.Ability == As.RKS_System)
                {
                    goto FAIL_NOEFFECT;
                }
                if (pm.OnboardPokemon.HasCondition(Cs.Embargo))
                {
                    goto FAIL_FAIL;
                }
                return(true);

            case AttachedState.PerishSong:
                return(!pm.OnboardPokemon.HasCondition(Cs.PerishSong));    //无需判断防音 never show fail

            case AttachedState.Ingrain:
                if (pm.OnboardPokemon.HasCondition(Cs.Ingrain))
                {
                    goto FAIL_FAIL;
                }
                return(true);
            }
FAIL_FAIL:
            if (showFail)
            {
                pm.Controller.ReportBuilder.ShowLog(fail);
            }
            return(false);

FAIL_NOEFFECT:
            if (showFail)
            {
                pm.NoEffect();
            }
            return(false);

FAIL_BEENSTATE:
            if (showFail)
            {
                pm.ShowLogPm("Been" + state);
            }
            return(false);

STATE:
            if (pm.State != PokemonState.Normal)
            {
                goto FAIL_FAIL;
            }
            return(CanAddXXX(pm, by, ability, state, showFail) && Rules.CanAddState(pm, state, by, showFail));
        }
Exemplo n.º 9
0
 internal static bool Unnerve(PokemonProxy pm)
 {
     return(pm.OnboardPokemon.HasCondition(Cs.Unnerve) && pm.AbilityE(As.UNNERVE));
 }
Exemplo n.º 10
0
 public static bool Gluttony(PokemonProxy pm)
 {
     return(pm.Hp << 2 <= pm.Pokemon.MaxHp || pm.AbilityE(As.GLUTTONY) && pm.Hp << 1 <= pm.Pokemon.MaxHp);
 }
Exemplo n.º 11
0
 public static bool CanUseItem(PokemonProxy pm)
 {
     return(!(pm.OnboardPokemon.HasCondition(Cs.Embargo) || pm.Controller.Board.HasCondition(Cs.MagicRoom) || pm.AbilityE(As.KLUTZ)));
 }
Exemplo n.º 12
0
 /// <summary>
 /// false if item is zero
 /// </summary>
 /// <param name="pm"></param>
 /// <returns></returns>
 public static bool CanLostItem(PokemonProxy pm)
 {
     return(!(pm.Pokemon.Item == 0 || NeverLostItem(pm.Pokemon) || pm.AbilityE(As.STICKY_HOLD)));
 }
Exemplo n.º 13
0
 public bool AbilityE(int ability)
 {
     return(Defender.AbilityE(ability) && (AtkContext.DefenderAbilityAvailable() || Defender.AbilityE(As.Full_Metal_Body) || Defender.AbilityE(As.Shadow_Shield) || Defender.AbilityE(As.Prism_Armor)));
 }
 public bool AbilityE(int ability)
 {
     return(Defender.AbilityE(ability) && AtkContext.DefenderAbilityAvailable());
 }