예제 #1
0
 private static void DeAbnormalState(DefContext def, PokemonState state)
 {
     if (def.Defender.Hp != 0 && def.Defender.State == state)
     {
         def.Defender.DeAbnormalState();
     }
 }
예제 #2
0
        private static bool Captivate(DefContext def)
        {
            var dg = def.Defender.OnboardPokemon.Gender;
            var ag = def.AtkContext.Attacker.OnboardPokemon.Gender;

            return(dg == PokemonGender.Male && ag == PokemonGender.Female || dg == PokemonGender.Female && ag == PokemonGender.Male);
        }
예제 #3
0
        public static void KOed(DefContext def, OnboardPokemon o)
        {
            var der = def.Defender;
            var aer = def.AtkContext.Attacker;

            if (o.HasCondition(Cs.DestinyBond))
            {
                aer.ShowLogPm("DestinyBond"); //战报顺序已测
                aer.Faint();
            }
            var mp = def.AtkContext.MoveProxy;

            if (o.HasCondition(Cs.Grudge) && mp != null && mp.PP != 0)
            {
                mp.PP = 0;
                aer.ShowLogPm("Grudge");
            }
            if (def.AtkContext.Move.Id == Ms.FELL_STINGER)
            {
                aer.ChangeLv7D(aer, StatType.Atk, 2, false);
            }
            if (aer.AbilityE(As.MOXIE))
            {
                aer.ChangeLv7D(aer, StatType.Atk, 1, false, true);
            }
        }
예제 #4
0
        private static void GrassKnot(DefContext def)
        {
            double w = def.Defender.Weight;

            if (w >= 200)
            {
                def.BasePower = 120;
            }
            else if (w >= 100)
            {
                def.BasePower = 100;
            }
            else if (w >= 50)
            {
                def.BasePower = 80;
            }
            else if (w >= 25)
            {
                def.BasePower = 60;
            }
            else if (w >= 10)
            {
                def.BasePower = 40;
            }
            else
            {
                def.BasePower = 20;
            }
        }
예제 #5
0
        private static int Generic(DefContext def)
        {
            int hp = def.Defender.OnboardPokemon.GetCondition <int>(Cs.Substitute);

            def.HitSubstitute = hp > 0;
            return(hp);
        }
예제 #6
0
        private static void Flail(DefContext def)
        {
            int pwd = def.AtkContext.Attacker.Hp * 48 / def.AtkContext.Attacker.Pokemon.MaxHp;

            if (pwd == 1)
            {
                def.BasePower = 200;
            }
            else if (pwd <= 4)
            {
                def.BasePower = 150;
            }
            else if (pwd <= 9)
            {
                def.BasePower = 100;
            }
            else if (pwd <= 16)
            {
                def.BasePower = 80;
            }
            else if (pwd <= 32)
            {
                def.BasePower = 40;
            }
            else
            {
                def.BasePower = 20;
            }
        }
예제 #7
0
        private static void HeavySlam(DefContext def)
        {
            double w = def.AtkContext.Attacker.Weight / def.Defender.Weight;

            if (w >= 5)
            {
                def.BasePower = 120;
            }
            else if (w >= 4)
            {
                def.BasePower = 100;
            }
            else if (w >= 3)
            {
                def.BasePower = 80;
            }
            else if (w >= 2)
            {
                def.BasePower = 60;
            }
            else
            {
                def.BasePower = 40;
            }
        }
예제 #8
0
파일: Attacked.cs 프로젝트: gyyfifafans/PBO
 private static void AttackedUpItem(DefContext def, BattleType type, StatType stat)
 {
     if (def.AtkContext.Type == type)
     {
         ITs.ChangeLv5D(def.Defender, stat, 1);
     }
 }
예제 #9
0
 private static void TrumpCard(DefContext def)
 {
     if (def.AtkContext.MoveProxy == null || def.AtkContext.MoveProxy.MoveE.Id != Ms.TRUMP_CARD)
     {
         def.BasePower = 40;
     }
     else
     {
         int pwa = def.AtkContext.MoveProxy.PP;
         if (pwa >= 5)
         {
             def.BasePower = 40;
         }
         else if (pwa == 4)
         {
             def.BasePower = 50;
         }
         else if (pwa == 3)
         {
             def.BasePower = 60;
         }
         else if (pwa == 2)
         {
             def.BasePower = 80;
         }
         else
         {
             def.BasePower = 200;
         }
     }
 }
예제 #10
0
파일: Attacked.cs 프로젝트: gyyfifafans/PBO
 private static void AttackedUpItem(DefContext def, MoveCategory cat, StatType stat)
 {
     if (def.AtkContext.Move.Move.Category == cat)
     {
         ITs.ChangeLv5D(def.Defender, stat, 1);
     }
 }
예제 #11
0
        public static bool Execute(DefContext def)
        {
            var der  = def.Defender;
            var atk  = def.AtkContext;
            var move = atk.Move;

            switch (move.Id)
            {
            case Ms.DREAM_EATER:
                return(der.State == PokemonState.SLP);

            case Ms.SYNCHRONOISE:
                return(Sychronoise(def));

            case Ms.CAPTIVATE:
                return(Captivate(def));

            case Ms.VENOM_DRENCH:
                return(der.State == PokemonState.PSN || der.State == PokemonState.BadlyPSN);

            case Ms.FLOWER_SHIELD:
            case Ms.ROTOTILLER:
                return(der.OnboardPokemon.HasType(BattleType.Grass));

            case Ms.MAGNETIC_FLUX:
            {
                var ab = der.Ability;
                return(ab == As.PLUS || ab == As.MINUS);
            }

            case Ms.SPIDER_WEB: //169
            case Ms.MEAN_LOOK:  //212
            case Ms.BLOCK:      //335
                return(!der.OnboardPokemon.HasType(BattleType.Ghost));
            }

            if ((move.Powder || move.Spore) && der.OnboardPokemon.HasType(BattleType.Grass))
            {
                return(false);
            }

            if (move.Move.Category == MoveCategory.Status && move.Id != Ms.THUNDER_WAVE)
            {
                return(true);
            }
            if (move.Class == MoveClass.OHKO && (der.Pokemon.Lv > atk.Attacker.Pokemon.Lv || der.RaiseAbility(As.STURDY)))
            {
                return(false);
            }
            BattleType canAtk;

            {
                var o = der.OnboardPokemon.GetCondition(Cs.CanAttack);
                canAtk = o == null ? BattleType.Invalid : o.BattleType;
            }
            return(canAtk != BattleType.Invalid && der.OnboardPokemon.HasType(canAtk) ||
                   der.ItemE(Is.RING_TARGET) ||
                   (atk.Type == BattleType.Ground ? IsGroundAffectable(der, atk.DefenderAbilityAvailable(), true) : NonGround(def)));
        }
예제 #12
0
파일: Attacked.cs 프로젝트: gyyfifafans/PBO
 private static void AddState(DefContext def, AttachedState state)
 {
     if (def.AtkContext.Attacker.CanAddState(def.Defender, state, false) && def.AtkContext.Controller.RandomHappen(30))
     {
         def.Defender.RaiseAbility();
         def.AtkContext.Attacker.AddState(def.Defender, state, false, 0);
     }
 }
예제 #13
0
파일: Attacked.cs 프로젝트: gyyfifafans/PBO
 private static void RoughSkin(DefContext def)
 {
     if (def.AtkContext.Attacker.CanEffectHurt)
     {
         def.Defender.RaiseAbility();
         def.AtkContext.Attacker.EffectHurtByOneNthImplement(8);
     }
 }
예제 #14
0
 private static void TriAttack(DefContext def)
 {
     if (def.RandomHappen(20))
     {
         int           i = def.Defender.Controller.GetRandomInt(0, 2);
         AttachedState s = i == 0 ? AttachedState.PAR : i == 1 ? AttachedState.BRN : AttachedState.FRZ;
         def.Defender.AddState(def.AtkContext.Attacker, s, false);
     }
 }
        private static void EatDefenderBerry(DefContext def)
        {
            var i = def.GetCondition <int>(Cs.EatenBerry);

            if (i != 0)
            {
                var aer = def.AtkContext.Attacker;
                def.AtkContext.Attacker.ShowLogPm("EatDefenderBerry", i);
                ITs.RaiseItemByMove(aer, i, aer);
            }
        }
예제 #16
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);
         }
     }
 }
예제 #17
0
 public byte[] Serialize(DefContext definitionContext)
 {
     if (definitionContext == null)
         return WriteNullReference();
     var type = definitionContext.GetTypeOfObj();
     if (type.IsTypeOf<SimpleDefContext>())
         return WriteSimpleDefContext(definitionContext.CastObj<SimpleDefContext>());
     if (type.IsTypeOf<ComplexDefContext>())
         return WriteComplexDefContext(definitionContext.CastObj<ComplexDefContext>());
     throw new Exception(string.Format("Unknown ObjectDefinition implementation : '{0}'", type.FullName));
 }
예제 #18
0
        private static void HiddenPower(DefContext def)
        {
            var iv = def.AtkContext.Attacker.Pokemon.Iv;
            int pI = (iv.Hp & 2) >> 1;

            pI           |= (iv.Atk & 2);
            pI           |= (iv.Def & 2) << 1;
            pI           |= (iv.Speed & 2) << 2;
            pI           |= (iv.SpAtk & 2) << 3;
            pI           |= (iv.SpDef & 2) << 4;
            def.BasePower = (int)(pI * 40 / 63 + 30);
        }
예제 #19
0
        public static bool OHKO(DefContext def)
        {
            int hp = Generic(def);

            if (hp > 0)
            {
                def.Damage = hp;
                Disappear(def.Defender);
                return(true);
            }
            return(false);
        }
예제 #20
0
        private static void Thief(DefContext def)
        {
            var aer = def.AtkContext.Attacker;

            if (def.AtkContext.HasCondition(Cs.Thief) && ITs.CanLostItem(def.Defender))
            {
                var i = def.Defender.Pokemon.Item;
                def.Defender.RemoveItem();
                aer.SetItem(i); //先铁棘再果子
                aer.ShowLogPm("Thief", i, def.Defender.Id);
            }
        }
예제 #21
0
 private static void SecretPower(DefContext def)
 {
     if (def.RandomHappen(30))
     {
         switch (def.Defender.Controller.GameSettings.Terrain)
         {
         case Terrain.Path:
             def.Defender.AddState(def.AtkContext.Attacker, AttachedState.PAR, false);
             break;
         }
     }
 }
예제 #22
0
        private static void Revenge(DefContext def)
        {
            var o = def.AtkContext.Attacker.OnboardPokemon.GetCondition(Cs.Damage);

            if (o != null && o.By == def.Defender)
            {
                def.BasePower = 120;
            }
            else
            {
                def.BasePower = 60;
            }
        }
예제 #23
0
        private static bool Sychronoise(DefContext def)
        {
            var types = def.AtkContext.Attacker.OnboardPokemon.Types;

            foreach (var t in types)
            {
                if (def.Defender.OnboardPokemon.HasType(t))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #24
0
        private static void SLevel(DefContext def, int @const)
        {
            var ao  = def.AtkContext.Attacker.OnboardPokemon;
            var l5  = ao.Lv5D;
            int sst = Positive(l5.Atk);

            sst          += Positive(l5.Def);
            sst          += Positive(l5.SpAtk);
            sst          += Positive(l5.SpDef);
            sst          += Positive(l5.Speed);
            sst          += Positive(ao.AccuracyLv);
            sst          += Positive(ao.EvasionLv);
            def.BasePower = sst * 20 + @const;
        }
예제 #25
0
파일: Attacked.cs 프로젝트: gyyfifafans/PBO
        private static void Pickpocket(DefContext d)
        {
            var der = d.Defender;
            var aer = d.AtkContext.Attacker;

            if (der.Pokemon.Item == 0 && ITs.CanLostItem(aer))
            {
                var i = aer.Pokemon.Item;
                aer.RemoveItem();
                der.RaiseAbility();
                der.SetItem(i);
                der.ShowLogPm("Pickpocket", i);
            }
        }
예제 #26
0
        private static void RapidSpin(DefContext def)
        {
            var aer = def.AtkContext.Attacker;

            EHTs.De(aer.Controller.ReportBuilder, aer.Field);
            aer.OnboardPokemon.RemoveCondition(Cs.LeechSeed);
            var trap = aer.OnboardPokemon.GetCondition(Cs.Trap);

            if (trap != null)
            {
                aer.OnboardPokemon.RemoveCondition(Cs.Trap);
                aer.ShowLogPm("TrapFree", trap.Move.Id);
            }
        }
 private static bool NoEffectWithLv7DUp(DefContext def, BattleType type, StatType stat)
 {
     if (def.AtkContext.Type == type)
     {
         var der = def.Defender;
         der.RaiseAbility();
         if (!der.ChangeLv7D(der, stat, 1, false))
         {
             der.NoEffect();
         }
         return(false);
     }
     return(true);
 }
예제 #28
0
        private static void Ct(DefContext def)
        {
            if (!(def.Defender.Field.HasCondition(Cs.LuckyChant) || def.CannotBeCted()))
            {
                var atk = def.AtkContext;
                if (atk.Attacker.OnboardPokemon.HasCondition(Cs.Laser_Focus) || atk.Move.MustCt || (atk.Attacker.Ability == As.Merciless && (def.Defender.State == PokemonState.BadlyPSN || def.Defender.State == PokemonState.PSN)))
                {
                    def.IsCt = true;
                }
                else
                {
                    var pm = atk.Attacker;
                    var ct = atk.Move.Ct1 ? 1 : 0;
                    if (atk.Move.Move.Id == Ms.tenkk_Volt)
                    {
                        ct = 2;
                    }
                    if (pm.OnboardPokemon.HasCondition(Cs.FocusEnergy))
                    {
                        ct += 2;
                    }
                    if (pm.AbilityE(As.SUPER_LUCK))
                    {
                        ct++;
                    }
                    switch (pm.Item)
                    {
                    case Is.SCOPE_LENS:
                    case Is.RAZOR_CLAW:
                        ct++;
                        break;

                    case Is.LUCKY_PUNCH:
                        if (pm.Pokemon.Form.Species.Number == 113)
                        {
                            ct += 2;
                        }
                        break;

                    case Is.STICK:
                        if (pm.Pokemon.Form.Species.Number == 83)
                        {
                            ct += 2;
                        }
                        break;
                    }
                    def.IsCt = ct > 2 || pm.Controller.OneNth(LV_CT[ct]);
                }
            }
        }
예제 #29
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);
                }
            }
        }
예제 #30
0
파일: Attacked.cs 프로젝트: gyyfifafans/PBO
        private static void EffectSpore(DefContext d)
        {
            var a = d.AtkContext;

            if (a.Controller.RandomHappen(10))
            {
                var i     = a.Controller.GetRandomInt(0, 2);
                var state = i == 0 ? AttachedState.PAR : i == 1 ? AttachedState.SLP : AttachedState.PSN;
                if (a.Attacker.CanAddState(d.Defender, state, false))
                {
                    d.Defender.RaiseAbility();
                    a.Attacker.AddState(d.Defender, state, false);
                }
            }
        }
예제 #31
0
        private static void ReHurtBerry(DefContext def, MoveCategory category)
        {
            var aer = def.AtkContext.Attacker;

            if (def.AtkContext.Move.Move.Category == category && aer.CanEffectHurt)
            {
                int hp = aer.Pokemon.MaxHp >> 3;
                if (hp == 0)
                {
                    hp = 1;
                }
                aer.ShowLogPm("ReHurtItem", def.Defender.Id, def.Defender.Pokemon.Item);
                aer.Hp -= hp;
            }
        }
예제 #32
0
        public object GetInstance(DefContext defContext)
        {
            if (defContext == null) return null;

            var type = defContext.GetTypeOfObj();
            if (type.IsTypeOf<SimpleDefContext>())
                return defContext.CastObj<SimpleDefContext>()
                    .SimpleTypeDef.Value;

            if (type.IsTypeOf<ComplexDefContext>())
            {
                var context = defContext.CastObj<ComplexDefContext>();
                var complexTypeDefs = context.ComplexTypeDefs;
                var typeInfos = context.TypeInfos;

                var typeInfosWithId = new Dictionary<int, TypeInfo>();
                foreach (var typeInfo in typeInfos)
                    typeInfosWithId.Add(typeInfo.Id, typeInfo);

                var instances = new Dictionary<int, object>();
                short indexesAsIds = 0;

                #region Get Instances

                foreach (var complexTypeDef in complexTypeDefs)
                {
                    var typeInfo = typeInfosWithId[complexTypeDef.TypeInfoId];
                    var currentType = Type.GetType(typeInfo.TypeName);
                    if (currentType == null)
                        throw new Exception(string.Format("Unknown type : {0}", typeInfo.TypeName));

                    if (currentType.IsImplOf<Array>())
                    {
                        var arrayDef = complexTypeDef.CastObj<ArrayDef>();
                        instances.Add(indexesAsIds, _complexTypeHelper.CreateInstance(currentType, arrayDef.Indicies));
                    }
                    else
                        instances.Add(indexesAsIds, _complexTypeHelper.CreateInstance(currentType));
                    indexesAsIds++;
                }

                #endregion

                #region Relate Instances

                foreach (var complexTypeDef in complexTypeDefs)
                {
                    var instance = instances[complexTypeDef.Id];
                    var instanceType = instance.GetTypeOfObj();

                    if (instanceType.IsImplOf<Array>())
                    {
                        #region Array

                        var arrayDef = complexTypeDef.CastObj<ArrayDef>();
                        var items = new SimpleList<object>();
                        foreach (var defValue in arrayDef.Items)
                            items.Add(CheckInstance(defValue, instances));
                        var arrayItems = new ArrayItems { Items = items };
                        _complexTypeHelper.SetItems(instance, arrayItems);

                        #endregion
                    }
                    else if (instanceType.IsImplOf<IList>())
                    {
                        #region List

                        var listDef = complexTypeDef.CastObj<ListDef>();
                        var items = new SimpleList<object>();
                        foreach (var defValue in listDef.Items)
                            items.Add(CheckInstance(defValue, instances));
                        var listItems = new ListItems { Items = items };
                        _complexTypeHelper.SetItems(instance, listItems);

                        #endregion
                    }
                    else if (instanceType.IsImplOf<IDictionary>())
                    {
                        #region Dictionary

                        var dictionaryDef = complexTypeDef.CastObj<DictionaryDef>();
                        var keys = new SimpleList<object>();
                        foreach (var defValue in dictionaryDef.Keys)
                            keys.Add(CheckInstance(defValue, instances));

                        var values = new SimpleList<object>();
                        foreach (var defValue in dictionaryDef.Values)
                            values.Add(CheckInstance(defValue, instances));

                        var dictionaryItems = new DictionaryItems { Keys = keys, Values = values };
                        _complexTypeHelper.SetItems(instance, dictionaryItems);

                        #endregion
                    }
                    else // user defined tpye at last
                    {
                        #region UserDefined

                        var userDefinedDef = complexTypeDef.CastObj<UserDefinedDef>();
                        var typeInfo = typeInfosWithId[userDefinedDef.TypeInfoId];
                        var names = new SimpleList<string>();
                        foreach (var index in userDefinedDef.Names)
                            names.Add(typeInfo.PropertyIndexName[index]);

                        var values = new SimpleList<object>();
                        foreach (var defValue in userDefinedDef.Values)
                            values.Add(CheckInstance(defValue, instances));

                        var userDefinedItems = new UserDefinedItems { Names = names, Values = values };
                        _complexTypeHelper.SetItems(instance, userDefinedItems);

                        #endregion
                    }
                }

                #endregion

                return instances[complexTypeDefs.SelectFirst().Id];
            }
            throw new UnknownImplementationException(typeof(DefContext), type);
        }