示例#1
0
        static List <int> GetSecondaryPlayTargets(NetSkill ns, NetCard nc, NetBattlefield bf, List <int> primaryTargets, MHRandom r)
        {
            if (primaryTargets == null ||
                primaryTargets.Count < 1)
            {
                return(null);
            }

            Subskill ss = ns.GetSubSkill();

            if (ss.trigger.triggerGroup == ETriggerGroupType.DoAttack ||
                ss.trigger.triggerGroup == ETriggerGroupType.DoAlternateAttack)
            {
                //there is no secondary targets of playing card to the battelfield unless its a spell
                return(null);
            }

            if (ss.targets.script2 == null ||
                string.IsNullOrEmpty(ss.targets.script2.scriptName))
            {
                return(null);
            }

            return(ns.FindSecondaryTargets(bf, -1, primaryTargets));
        }
示例#2
0
        static IList <int> GetPlayCardTargets(bool friendlyTurn, NetSkill ns, NetCard nc, NetBattlefield bf)
        {
            Subskill ss = ns.GetSubSkill();

            if (ss.trigger.triggerGroup == ETriggerGroupType.DoAttack ||
                ss.trigger.triggerGroup == ETriggerGroupType.DoAlternateAttack)
            {
                if (ss.trigger.requiredToBeInFrontline)
                {
                    if (friendlyTurn)
                    {
                        return(bf.GetFreeFriendlyMeleeSlots(false));
                    }
                    else
                    {
                        return(bf.GetFreeEnemyMeleeSlots(false));
                    }
                }
                else if (ss.trigger.requiredToBeInBackline)
                {
                    if (friendlyTurn)
                    {
                        return(bf.GetFreeFriendlyRangedSlots(false));
                    }
                    else
                    {
                        return(bf.GetFreeEnemyRangedSlots(false));
                    }
                }
                else
                {
                    List <int> both;
                    if (friendlyTurn)
                    {
                        IList <int> a = bf.GetFreeFriendlyMeleeSlots(false);
                        IList <int> b = bf.GetFreeFriendlyRangedSlots(false);
                        both = new List <int>(a.Count + b.Count);
                        both.AddRange(a);
                        both.AddRange(b);
                        return(both);
                    }
                    else
                    {
                        IList <int> a = bf.GetFreeEnemyMeleeSlots(false);
                        IList <int> b = bf.GetFreeEnemyRangedSlots(false);
                        both = new List <int>(a.Count + b.Count);
                        both.AddRange(a);
                        both.AddRange(b);
                        return(both);
                    }
                }
            }
            else
            {
                return(ns.FindValidTargets(bf, -1));
            }
        }
示例#3
0
        static IEnumerator <List <int> > GetTargetEnumerator(NetSkill ns, NetCard nc, IList <int> potentialTargets, CardAI ai)
        {
            if (potentialTargets.Count < 1)
            {
                return(null);
            }

            Subskill ss    = ns.GetSubSkill();
            int      count = 0;

            if (ss.trigger.triggerGroup == ETriggerGroupType.DoAttack ||
                ss.trigger.triggerGroup == ETriggerGroupType.DoAlternateAttack)
            {
                count = 1;
            }
            else
            {
                if (potentialTargets.Count < ss.targets.targetCountRange.minimumCount)
                {
                    return(null);
                }
                if (potentialTargets.Count <= ss.targets.targetCountRange.maximumCount)
                {
                    count = potentialTargets.Count;
                }
                else
                {
                    count = ss.targets.targetCountRange.maximumCount;
                }
            }

            List <int> pt = new List <int>(potentialTargets);

            pt.Sort(delegate(int a, int b)
            {
                if (ai.preferredStrategicPlaces != null)
                {
                    bool stratA = ai.preferredStrategicPlaces.Contains(a);
                    bool stratB = ai.preferredStrategicPlaces.Contains(b);

                    if (stratA != stratB)
                    {
                        return(stratA ? -1 : 1);
                    }
                    //if they are the same use regular random
                }

                return(ai.r.GetInt(0, 2) - 1);
            });

            var lu = new ListUtils(pt, count);

            return(lu.GetEnumerator());
        }
        static public string SI_ShieldUpImproved(object info)
        {
            Multitype <NetCard, NetSkill, NetBattlefield> data = info as Multitype <NetCard, NetSkill, NetBattlefield>;

            if (data != null)
            {
                var  ns    = data.t1;
                var  bf    = data.t2;
                FInt value = ns.GetFloatAttribute("TAG-CA_SHIELD");
                if (value == FInt.ZERO)
                {
                    if (bf.ChallengeType == EChallengeType.TypePhysical)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_PHYSICAL");
                    }
                    else if (bf.ChallengeType == EChallengeType.TypeMental)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_MENTAL");
                    }
                    else if (bf.ChallengeType == EChallengeType.TypeMental)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_SPIRIT");
                    }
                }

                FInt f = GameplayUtils.GetDamageFor(data.t1, data.t0);
                return((value + f).ToInt().ToString());
            }

            Multitype <SkillInstance, Subskill, ClientEntityCharacter> dInfo = info as Multitype <SkillInstance, Subskill, ClientEntityCharacter>;
            SkillInstance         si        = dInfo.t0;
            Subskill              ss        = dInfo.t1;
            ClientEntityCharacter character = dInfo.t2;
            var dataInWorld = si.GetCurrentSkillAttributes()[ss];

            if (dataInWorld.attributes != null && dataInWorld.attributes.Count > 0)
            {
                FInt extra = FInt.ZERO;

                string st = null;
                foreach (var v in ss.challengeTypes)
                {
                    if (character != null)
                    {
                        extra = GameplayUtils.GetDamageFor(si, ss, character, v);
                    }

                    FInt   value = dataInWorld.GetFInt("TAG-CA_SHIELD");
                    string color = "";

                    switch (v)
                    {
                    case EChallengeType.TypePhysical:
                        if (value == FInt.ZERO)
                        {
                            value = dataInWorld.GetFInt("TAG-SHIELDING_PHYSICAL");
                        }
                        color = "XML_COLOR-PHYSICAL";
                        break;

                    case EChallengeType.TypeMental:
                        if (value == FInt.ZERO)
                        {
                            value = dataInWorld.GetFInt("TAG-SHIELDING_MENTAL");
                        }
                        color = "XML_COLOR-MENTAL";
                        break;

                    case EChallengeType.TypeSpirit:
                        if (value == FInt.ZERO)
                        {
                            value = dataInWorld.GetFInt("TAG-SHIELDING_SPIRIT");
                        }
                        color = "XML_COLOR-SPIRITUAL";
                        break;
                    }

                    if (st == null)
                    {
                        st = "";
                    }
                    else
                    {
                        st += "|";
                    }

                    if (extra != FInt.ZERO)
                    {
                        st += ColorUtils.GetColorAsTextTag(color) +
                              extra +
                              ColorUtils.GetColorAsTextTag("XML_COLOR-NORMAL_FONT") +
                              " [+" + value + "]";
                    }
                    else
                    {
                        st += " [+" + value + "]";
                    }
                }
                return(st != null ? st : "");
            }

            return("");
        }
        static public string SI_ProceduralDamage(object info)
        {
            Multitype <NetCard, NetSkill, NetBattlefield> data = info as Multitype <NetCard, NetSkill, NetBattlefield>;

            if (data != null)
            {
                return(GameplayUtils.GetDamageFor(data.t1, data.t0).ToString(false));
            }

            Multitype <SkillInstance, Subskill, ClientEntityCharacter> dInfo = info as Multitype <SkillInstance, Subskill, ClientEntityCharacter>;
            SkillInstance         si        = dInfo.t0;
            Subskill              ss        = dInfo.t1;
            ClientEntityCharacter character = dInfo.t2;

            var skillAttributes = si.GetCurrentSkillAttributes()[ss];
            int flags           = skillAttributes.GetFInt("ProceduralFlags").ToInt();

            string st = null;

            FInt  dmgBase = GameplayUtils.GetDamageFor(si, ss, null);
            float addBase = (flags & (int)EActivatorBlocks.Additive) > 0 ?  GameplayUtils.DamageNormalToAdditive(dmgBase) : 0f;

            var a = new FInt(addBase);

            if (ss.challengeTypes == null || character == null)
            {
                if (addBase > 0)
                {
                    st = "x" + dmgBase.ToString(true) + " [+" + a.ToString(true) + "]";
                }
                else
                {
                    st = "x" + dmgBase.ToString(true);
                }
            }
            else
            {
                foreach (var v in ss.challengeTypes)
                {
                    string color = "";
                    switch (v)
                    {
                    case EChallengeType.TypePhysical:
                        color = "XML_COLOR-PHYSICAL";
                        break;

                    case EChallengeType.TypeMental:
                        color = "XML_COLOR-MENTAL";
                        break;

                    case EChallengeType.TypeSpirit:
                        color = "XML_COLOR-SPIRITUAL";
                        break;
                    }

                    if (st == null)
                    {
                        st = "";
                    }
                    else
                    {
                        st += "|";
                    }

                    if (addBase > 0)
                    {
                        st += "x" + dmgBase.ToString(true) + "[+" + a.ToString(true) + "]" +
                              " ( " +
                              ColorUtils.GetColorAsTextTag(color) +
                              GameplayUtils.GetDamageFor(si, ss, character, v, true).ToString(false) +
                              ColorUtils.GetColorAsTextTag("XML_COLOR-NORMAL_FONT") +
                              " )";
                    }
                    else
                    {
                        st += "x" + dmgBase.ToString(true) +
                              " ( " +
                              ColorUtils.GetColorAsTextTag(color) +
                              GameplayUtils.GetDamageFor(si, ss, character, v).ToString(false) +
                              ColorUtils.GetColorAsTextTag("XML_COLOR-NORMAL_FONT") +
                              " )";
                    }
                }
            }
            return(st);
        }
        static public string SI_ShieldUp(object info)
        {
            Multitype <NetCard, NetSkill, NetBattlefield> data = info as Multitype <NetCard, NetSkill, NetBattlefield>;

            if (data != null)
            {
                var  ns    = data.t1;
                var  bf    = data.t2;
                FInt value = ns.GetFloatAttribute("TAG-CA_SHIELD");
                if (value == FInt.ZERO)
                {
                    if (bf.ChallengeType == EChallengeType.TypePhysical)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_PHYSICAL");
                    }
                    else if (bf.ChallengeType == EChallengeType.TypeMental)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_MENTAL");
                    }
                    else if (bf.ChallengeType == EChallengeType.TypeMental)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_SPIRIT");
                    }
                }

                return(value.ToInt().ToString());
            }

            Multitype <SkillInstance, Subskill, ClientEntityCharacter> dInfo = info as Multitype <SkillInstance, Subskill, ClientEntityCharacter>;
            SkillInstance         si        = dInfo.t0;
            Subskill              ss        = dInfo.t1;
            ClientEntityCharacter character = dInfo.t2;
            var dataInWorld = si.GetCurrentSkillAttributes()[ss];

            if (dataInWorld.attributes != null && dataInWorld.attributes.Count > 0)
            {
                string st    = null;
                FInt   value = dataInWorld.GetFInt("TAG-CA_SHIELD");
                if (value == FInt.ZERO)
                {
                    return(value.ToString());
                }

                foreach (var v in ss.challengeTypes)
                {
                    switch (v)
                    {
                    case EChallengeType.TypePhysical:
                        value = dataInWorld.GetFInt("TAG-SHIELDING_PHYSICAL");
                        break;

                    case EChallengeType.TypeMental:
                        value = dataInWorld.GetFInt("TAG-SHIELDING_MENTAL");
                        break;

                    case EChallengeType.TypeSpirit:
                        value = dataInWorld.GetFInt("TAG-SHIELDING_SPIRIT");
                        break;
                    }

                    if (st == null)
                    {
                        st = "";
                    }
                    else
                    {
                        st += "|";
                    }

                    st += value;
                }
                return(st != null ?  st : "");
            }

            return("");
        }