Exemplo n.º 1
0
 /// <summary>
 /// 自动从玩家牌中选择一张牌
 /// 若该玩家有手牌,则在手牌中随机选一张,否则选择武器,防具,+1马,-1马,最后放置的debuff
 /// </summary>
 /// <param name="aChief">需要选择的武将对象</param>
 /// <returns>一张系统选择的牌</returns>
 internal Card AutoSelect(ChiefBase aChief)
 {
     if (GamePlayers[aChief].Hands.Count > 0)
     {
         return(GamePlayers[aChief].Hands[GetRandom(GamePlayers[aChief].Hands.Count)]);
     }
     else if (GamePlayers[aChief].Weapon != null)
     {
         return(GamePlayers[aChief].Weapon);
     }
     else if (GamePlayers[aChief].Armor != null)
     {
         return(GamePlayers[aChief].Armor);
     }
     else if (GamePlayers[aChief].Jia1Ma != null)
     {
         return(GamePlayers[aChief].Jia1Ma);
     }
     else if (GamePlayers[aChief].Jian1Ma != null)
     {
         return(GamePlayers[aChief].Jian1Ma);
     }
     else if (GamePlayers[aChief].Debuff.Count > 0)
     {
         return(GamePlayers[aChief].Debuff.Peek());
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 开启逻辑泵,此后进入处理循环。此方法仅配合Create方法创建自定义环境.必须存在玩家且牌堆有8张以上的牌
 /// </summary>
 /// <param name="aIgnoreTakeCards">是否忽略一开始对玩家每人发4张牌的过程</param>
 /// <remarks>这是一个测试方法,用于测试游戏的逻辑正确,所以,OnCreate事件设置的所有信息不会被忽略,并按照所给定的参数直接进行执行</remarks>
 public void ActiveLogic(bool aIgnoreTakeCards)
 {
     try
     {
         //选择是主公身份的玩家
         Player[]  start = GamePlayers.All.Where(c => c.Chief != null & c.Chief.ChiefStatus == ChiefBase.Status.Majesty).ToArray();
         ChiefBase s     = null;
         //存在主公身份的玩家,那么设置该玩家是开始进入回合.否则设置第一个没有死亡的玩家
         if (start.Count() == 1 && !start[0].Dead)
         {
             s = start[0].Chief;
         }
         else
         {
             s = GamePlayers[-1].Chief;
         }
         if (GamePlayers.All.Count() > 0 && CardsHeap.TotalCards > 8 && s != null)
         {
             LogicLoop(s, aIgnoreTakeCards);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 产生一条触发技能的问询
 /// </summary>
 /// <param name="aChief">需要触发技能的武将</param>
 /// <param name="aSkill">需要触发的技能</param>
 /// <returns>一条问询消息</returns>
 internal static string MakeAskForSkillMessage(ChiefBase aChief, SkillBase aSkill)
 {
     return(new Beaver("askfor.skill", aChief.ChiefName, aSkill.SkillName).ToString());
     //return new XElement("askfor.skill",
     //            new XElement("target", aChief.ChiefName),
     //            new XElement("skill", aSkill.SkillName));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 让玩家从牌堆拿n张牌,该方法会自动将牌放置到武将的手牌中,并且发送takecards消息(n=0方法无作为)
 /// </summary>
 /// <param name="aChief">武将对象</param>
 /// <param name="n">拿牌的数量</param>
 /// <returns>牌的数组</returns>
 internal Card[] TakeingCards(ChiefBase aChief, int n)
 {
     if (n <= 0)
     {
         return new Card[] { }
     }
     ;
     if (GamePlayers[aChief].Dead)
     {
         return new Card[] { }
     }
     ;
     Card[] ret = CardsHeap.Pop(n);
     GamePlayers[aChief].Hands.AddRange(ret);
     AsynchronousCore.SendPrivateMessageWithOpenMessage(aChief, new Beaver("takecards", aChief.ChiefName, Card.Cards2Beaver("cards", ret)).ToString(), new Beaver("takecards", aChief.ChiefName, n.ToString(), GamePlayers[aChief].Hands.Count.ToString()).ToString(), GamePlayers);
     //AsynchronousCore.SendMessage( GamePlayers.All.Where(c=>c.Chief != aChief ).ToArray(),
     //    new Beaver("takecards", aChief.ChiefName , n.ToString() , GamePlayers[aChief].Hands.Count.ToString()).ToString(),true);
     //    //new XElement("takecards",
     //    //    new XElement("target" , aChief.ChiefName),
     //    //    new XElement("takecount" , n.ToString()),
     //    //    new XElement("count" , GamePlayers[aChief].Hands.Count.ToString())
     //    //) , true);
     //AsynchronousCore.SendMessage(new ChiefBase[] { aChief },
     //    new Beaver("takecards", aChief.ChiefName, Card.Cards2Beaver("cards", ret)).ToString(), false);
     //    //new XElement("takecards",
     //    //    new XElement("target", aChief.ChiefName),
     //    //    Card.Cards2XML("cards", ret)
     //    //),false);
     return(ret);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 移除武将的牌,即包含手牌,装备区和判定区,如果不能全部移除将不会改变玩家的牌,但是所执行的事件不能挽回
        /// 注意,方法成功之后移除的牌并不会放入弃牌堆
        /// </summary>
        /// <param name="aChief">武将</param>
        /// <param name="aCards">需要移除的牌</param>
        /// <returns>移除正常返回true</returns>
        private bool RemoveCard(ChiefBase aChief, Card[] aCards)
        {
            Card         weapon    = GamePlayers[aChief].Weapon;
            Card         armor     = GamePlayers[aChief].Armor;
            Card         Jia1      = GamePlayers[aChief].Jia1Ma;
            Card         Jian1     = GamePlayers[aChief].Jian1Ma;
            List <Card>  oldHand   = GamePlayers[aChief].Hands.ToList();
            Stack <Card> oldDebuff = new Stack <Card>(GamePlayers[aChief].Debuff);

            foreach (Card c in aCards)
            {
                if (!GamePlayers[aChief].RemoveHand(c) && !GamePlayers[aChief].RemoveBuff(c))
                {
                    if (GamePlayers[aChief].Weapon != null && GamePlayers[aChief].Weapon.Same(c))
                    {
                        GamePlayers[aChief].UnloadWeapon(this, gData);
                        foreach (ASkill s in aChief.Skills)
                        {
                            s.DropEquipage(aChief, gData);
                        }
                    }
                    else if (GamePlayers[aChief].Armor != null && GamePlayers[aChief].Armor.Same(c))
                    {
                        GamePlayers[aChief].UnloadArmor(this);
                        foreach (ASkill s in aChief.Skills)
                        {
                            s.DropEquipage(aChief, gData);
                        }
                    }
                    else if (GamePlayers[aChief].Jia1Ma != null && GamePlayers[aChief].Jia1Ma.Same(c))
                    {
                        GamePlayers[aChief].UnloadJia1(this);
                        foreach (ASkill s in aChief.Skills)
                        {
                            s.DropEquipage(aChief, gData);
                        }
                    }
                    else if (GamePlayers[aChief].Jian1Ma != null && GamePlayers[aChief].Jian1Ma.Same(c))
                    {
                        GamePlayers[aChief].UnloadJia1(this);
                        foreach (ASkill s in aChief.Skills)
                        {
                            s.DropEquipage(aChief, gData);
                        }
                    }
                    else
                    //这里找不到牌在玩家的任何区域中,执行还原动作,并且返回false
                    {
                        GamePlayers[aChief].Weapon  = weapon;
                        GamePlayers[aChief].Armor   = armor;
                        GamePlayers[aChief].Jia1Ma  = Jia1;
                        GamePlayers[aChief].Jian1Ma = Jian1;
                        GamePlayers[aChief].Hands   = oldHand;
                        GamePlayers[aChief].Debuff  = oldDebuff;
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 从牌堆取出一张牌作为判定牌
        /// </summary>
        /// <param name="aChief">判定的武将对象</param>
        /// <param name="aEffect">要判定的效果</param>
        /// <returns>一张判定牌</returns>
        internal Card popJudgementCard(ChiefBase aChief, Card.Effect aEffect)
        {
            Card c = CardsHeap.Pop(); //取一张牌

            AsynchronousCore.SendMessage(
                new Beaver("judgmentcard", aChief.ChiefName, aEffect.ToString(), Card.Cards2Beaver("cards", new Card[] { c })).ToString());
            //new XElement("judgmentcard",
            //    new XElement("target", aChief.ChiefName),
            //    new XElement("effect", aEffect),
            //    Card.Cards2XML("cards", new Card[] { c })
            //)); //发送揭出判定牌的消息
            ChiefBase t = aChief; //现在从判定牌持有的玩家开始,轮询武将OnChiefJudgementCardShow_Turn方法

            do
            {
                foreach (ASkill s in t.Skills)
                {
                    c = s.OnChiefJudgementCardShow_Turn(aChief, c, t, gData);
                }
                t = t.Next;
            }while (t != aChief);
            c.CardEffect = aEffect;
            //最后这里设定判定牌的性质是考虑之前判定牌不确定的因素
            return(c);
        }
Exemplo n.º 7
0
 /// <summary>
 /// 让玩家自动选择要弃的牌
 /// </summary>
 /// <param name="aChief">武将对象</param>
 /// <returns>返回牌数组</returns>
 private Card[] AutoAbandonment(ChiefBase aChief)
 {
     if (GamePlayers[aChief].Hands.Count <= GamePlayers[aChief].Health)
     {
         return(new Card[0]);
     }
     return(GamePlayers[aChief].Hands.GetRange(0, GamePlayers[aChief].Hands.Count - GamePlayers[aChief].Health).ToArray());
 }
Exemplo n.º 8
0
 /// <summary>
 /// 一条从打出的牌中拾取牌的消息
 /// </summary>
 /// <param name="aChief">拾取牌的武将</param>
 /// <param name="aCards">拾取的牌</param>
 /// <returns></returns>
 internal static string MakePickMessage(ChiefBase aChief, Card[] aCards)
 {
     return(new Beaver("pick", aChief.ChiefName, Card.Cards2Beaver("cards", aCards)).ToString());
     //return new XElement("pick",
     //                new XElement("to", aChief.ChiefName),
     //                Card.Cards2XML("cards", aCards)
     //            );
 }
Exemplo n.º 9
0
 /// <summary>
 /// 产生一条drop消息
 /// </summary>
 /// <param name="aFrom">选择牌的玩家</param>
 /// <param name="aTo">被选择牌的玩家</param>
 /// <param name="aCards">弃掉的牌</param>
 /// <returns>drop消息</returns>
 internal static string MakeDropMessage(ChiefBase aFrom, ChiefBase aTo, Card[] aCards)
 {
     return(new Beaver("drop", aFrom.ChiefName, aTo.ChiefName, Card.Cards2Beaver("cards", aCards)).ToString());
     //return new XElement("drop",
     //                new XElement("from", aFrom.ChiefName),
     //                new XElement("to", aTo.ChiefName),
     //                Card.Cards2XML("cards", aCards)
     //            );
 }
Exemplo n.º 10
0
 /// <summary>
 /// 创建事件节点
 /// </summary>
 /// <param name="aSource">事件源</param>
 /// <param name="aTarget">事件目标</param>
 /// <param name="aTarget2">事件的第二个目标</param>
 /// <param name="aCards">源出的牌</param>
 /// <param name="aEffect">事件的效果</param>
 /// <param name="aSkillName">发动的技能名称</param>
 public EventRecoard(ChiefBase aSource, ChiefBase aTarget, ChiefBase aTarget2, Card[] aCards, Card.Effect aEffect, string aSkillName)
 {
     Source    = aSource;
     Target    = aTarget;
     Cards     = aCards;
     Effect    = aEffect;
     Target2   = aTarget2;
     SkillName = aSkillName;
 }
Exemplo n.º 11
0
        internal int CalcMaxShaTargets(ChiefBase aChief, Card[] aCards)
        {
            int count = 1;

            if (GamePlayers[aChief].Weapon != null)
            {
                Weapon.CalcShaTargetsCount(GamePlayers[aChief].Weapon.CardEffect, aCards, aChief, Card.Effect.Sha, gData, ref count);
            }
            return(count);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 通知玩家状态改变
 /// </summary>
 /// <param name="aChief"></param>
 /// <param name="aStatus"></param>
 internal void SendChangeStatusMessage(ChiefBase aChief, PlayerStatus aStatus)
 {
     SendMessage(new Beaver("status", aChief.ChiefName, aStatus.ToString()).ToString()
                 //new XElement("status",
                 //    new XElement("target" , aChief.ChiefName),
                 //    new XElement("status" , aStatus)
                 //    )
                 );
     Thread.Sleep(250);
 }
Exemplo n.º 13
0
 /// <summary>
 /// 产生触发技能的消息
 /// </summary>
 /// <param name="aChief">触发技能的武将</param>
 /// <param name="aSkill">激发的技能</param>
 /// <param name="aTargets">目标</param>
 /// <param name="aCards">牌</param>
 /// <returns>一条技能触发的消息</returns>
 internal static string MakeTriggerSkillMesssage(ChiefBase aChief, SkillBase aSkill, ChiefBase[] aTargets, Card[] aCards)
 {
     return(new Beaver("skill", aChief.ChiefName, aSkill.SkillName, ChiefBase.Chiefs2Beaver("targets", aTargets), Card.Cards2Beaver("cards", aCards)).ToString());
     //return new XElement("skill",
     //                new XElement("target", aChief.ChiefName),
     //                new XElement("name", aSkill.SkillName),
     //                ChiefBase.Chiefs2XML("targets" , aTargets),
     //                Card.Cards2XML("cards", aCards)
     //            );
 }
Exemplo n.º 14
0
 public static bool EnableTargetArmorWithMessage(Card.Effect aWeaponEffect, ChiefBase aSource, ChiefBase aTarget, GlobalData aData)
 {
     switch (aWeaponEffect)
     {
     case Card.Effect.QingGangJian:
         //aData.Game.AskCore.SendMessage(new XElement("青刚剑"));
         break;
     }
     return(EnableTargetArmor(aWeaponEffect, aSource, aTarget));
 }
Exemplo n.º 15
0
        /// <summary>
        /// 指示武将出牌无效,恢复其原有的手牌和装备
        /// </summary>
        /// <param name="aChief">武将对象</param>
        internal void LeadingInvalid(ChiefBase aChief)
        {
            List <int> IDs = new List <int>();

            foreach (Card c in GB.GamePlayers[aChief].Hands)
            {
                IDs.Add(c.ID);
            }
            GB.GamePlayers[aChief].Callback.LeadingInvalid(IDs.ToArray(), GB.GamePlayers[aChief].Weapon == null ? 0 : GB.GamePlayers[aChief].Weapon.ID, GB.GamePlayers[aChief].Armor == null ? 0 : GB.GamePlayers[aChief].Armor.ID,
                                                           GB.GamePlayers[aChief].Jia1Ma == null ? 0 : GB.GamePlayers[aChief].Jia1Ma.ID, GB.GamePlayers[aChief].Jian1Ma == null ? 0 : GB.GamePlayers[aChief].Jian1Ma.ID);
        }
Exemplo n.º 16
0
 /// <summary>
 /// 问询结果
 /// </summary>
 /// <param name="aTimeout">是否超时</param>
 /// <param name="aLeader">问询目标</param>
 /// <param name="aTargets">目标的目标</param>
 /// <param name="aCards">问询目标出牌</param>
 /// <param name="aEffect">出牌的效果</param>
 /// <param name="aYN">问询的是否结果</param>
 /// <param name="aPlayerLead">问询是否是玩家所选出牌,针对八卦阵</param>
 /// <param name="aSkillName">问询引发的技能名称</param>
 public AskForResult(bool aTimeout, ChiefBase aLeader, ChiefBase[] aTargets, Card[] aCards, Card.Effect aEffect, bool aYN, bool aPlayerLead, string aSkillName)
 {
     TimeOut    = aTimeout;
     Leader     = aLeader;
     Targets    = aTargets;
     Cards      = aCards;
     Effect     = aEffect;
     YN         = aYN;
     PlayerLead = aPlayerLead;
     SkillName  = aSkillName;
 }
Exemplo n.º 17
0
 /// <summary>
 /// 一般出牌情况下,检查出牌是否合法,即牌来自目标的手牌
 /// </summary>
 /// <param name="aResult">问询的回复</param>
 /// <param name="aChief">出牌的武将</param>
 /// <returns>若出牌都在手牌中,返回true</returns>
 private bool CheckValid(MessageCore.AskForResult aResult, ChiefBase aChief)
 {
     if (!aResult.PlayerLead || aResult.SkillName != string.Empty)
     {
         return(true);
     }
     if (aResult.Cards.Count() == 0 && aResult.Effect != Card.Effect.None)
     {
         return(false);
     }
     return(GamePlayers[aChief].HasCardsInHand(aResult.Cards));
 }
Exemplo n.º 18
0
 /// <summary>
 /// 在服务实例的回应中对牌的操作
 /// </summary>
 /// <param name="aWeaponEffect">武器效果</param>
 /// <param name="aCards">玩家的出牌</param>
 /// <param name="aChief">出牌武将</param>
 /// <param name="aTargets">武将目标</param>
 /// <param name="aAskFor">问询内容</param>
 /// <param name="aEffect">最终定义的牌效果</param>
 /// <param name="aData">游戏数据</param>
 public static void LeadCards(Card.Effect aWeaponEffect, Card[] aCards, ChiefBase aChief, ChiefBase[] aTargets, MessageCore.AskForEnum aAskFor, ref Card.Effect aEffect, GlobalData aData)
 {
     switch (aWeaponEffect)
     {
     case Card.Effect.ZhangBaSheMao:
         if (aEffect == Card.Effect.None && aCards.Count() == 2 && aData.Game.GamePlayers[aChief].HasCardsInHand(aCards))
         {
             aEffect = Card.Effect.Sha;
         }
         break;
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// 问询出牌合法性检验,并回应武将所控制的玩家出牌合法性结果,对于判断为非法的出牌,将会设置用户返回结果
 /// </summary>
 /// <param name="aChief">出牌武将</param>
 /// <param name="aResult">问询结果,若出牌不合法,则问询会被修改为默认对象</param>
 /// <remarks>此方法用于通过回调通知调试客户端操作的合法性,回调仅适合用于测试类库逻辑</remarks>
 private void ValidityResult(ChiefBase aChief, ref MessageCore.AskForResult aResult)
 {
     if (!CheckValid(aResult, aChief))
     {
         AsynchronousCore.LeadingInvalid(aChief);
         aResult = new MessageCore.AskForResult(false, aResult.Leader, new ChiefBase[] { }, new Card[] { }, Card.Effect.None, false, true, string.Empty);
     }
     else
     {
         AsynchronousCore.LeadingValid(aChief);
     }
 }
Exemplo n.º 20
0
        public static bool EnableTargetArmor(Card.Effect aWeaponEffect, ChiefBase aSource, ChiefBase aTarget)
        {
            bool ret = true;

            switch (aWeaponEffect)
            {
            case Card.Effect.QingGangJian:
                ret = false;
                break;
            }
            return(ret);
        }
Exemplo n.º 21
0
 /// <summary>
 /// 借刀杀人的过程
 /// </summary>
 /// <param name="r">子事件的起始节点</param>
 /// <returns></returns>
 private EventRecoard JieDaoShaRenProc(EventRecoard r)
 {
     //玩家自己和两个目标不能死亡,目标不能没有武器
     if (!GamePlayers[r.Source].Dead && !GamePlayers[r.Target].Dead && !GamePlayers[r.Target2].Dead && GamePlayers[r.Target].Weapon != null)
     {
         //无懈可击
         if (WuXieProc(r.Target, Card.Effect.JieDaoShaRen))
         {
             return(r);
         }
         string msg = new Beaver("askfor.jdsr.sha", r.Target.ChiefName, r.Target2.ChiefName, r.Source.ChiefName).ToString();
         //new XElement("askfor.jdsr.sha",
         //    new XElement("target", r.Target.ChiefName),
         //    new XElement("target2", r.Target2.ChiefName),
         //    new XElement("source", r.Source.ChiefName)
         //);
         //向目标问询杀
         MessageCore.AskForResult res = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.Sha, new AskForWrapper(msg, this), gData);
         ValidityResult(r.Target, ref res);
         if (res.Effect == Card.Effect.None)
         {
             //获得对方的武器对象
             Card weapon = GamePlayers[r.Target].Weapon;
             Move(r.Target, r.Source, new Card[] { weapon });
             //玩家得到武器牌
             AsynchronousCore.SendMessage(MessageCore.MakeStealMessage(r.Target, r.Source, new Card[] { weapon }));
             //new XElement("steal",
             //    new XElement("from", r.Target.ChiefName),
             //    new XElement("to", r.Source.ChiefName),
             //    Card.Cards2XML("cards", new Card[] { weapon })
             //    )
             //);
         }
         else if (res.Effect == Card.Effect.Sha)
         {
             AsynchronousCore.SendMessage(
                 new Beaver("sha", r.Target.ChiefName, ChiefBase.Chiefs2Beaver("to", new ChiefBase[] { r.Target2 }), res.SkillName, Card.Cards2Beaver("cards", res.Cards)).ToString());
             //new XElement("sha",
             //    new XElement("from", r.Target.ChiefName),
             //    ChiefBase.Chiefs2XML("to", new ChiefBase[] { r.Target2 }),
             //    new XElement("skill", res.SkillName),
             //    Card.Cards2XML("cards", res.Cards)
             //    )
             //    );
             //再此子事件上创建杀的子事件
             DropCards(true, CardFrom.Hand, string.Empty, res.Cards, Card.Effect.Sha, r.Target, r.Target2, null);
             //执行杀的子事件
             ShaProc(lstRecoard.Last());// lstRecoard.ElementAt(lstRecoard.Count - 1)
         }
     }
     return(r);
 }
Exemplo n.º 22
0
        internal void RecoveryJudgementCard(Card aCard, ChiefBase aChief, Card.Effect aEffect)
        {
            bool EnableSengToBin = true;

            foreach (ASkill s in aChief.Skills)
            {
                s.OnChiefJudgementCardTakeEffect(aChief, aCard, ref EnableSengToBin, gData);
            }
            if (EnableSengToBin)
            {
                lstCardBin.Add(aCard);
            }
        }
Exemplo n.º 23
0
 internal void RegainHealth(ChiefBase aChief, sbyte aRegain)
 {
     if (GamePlayers[aChief].MaxHealth != GamePlayers[aChief].Health)
     {
         GamePlayers[aChief].Health += aRegain;
         AsynchronousCore.SendMessage(new Beaver("health", aChief.ChiefName, GamePlayers[aChief].MaxHealth.ToString(), GamePlayers[aChief].Health.ToString()).ToString());
         //new XElement("health",
         //new XElement("target", aChief.ChiefName),
         //new XElement("max", GamePlayers[aChief].MaxHealth),
         //new XElement("current", GamePlayers[aChief].Health)
         //));
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// 计算伤害量
        /// </summary>
        /// <param name="aWeaponEffect">武器效果</param>
        /// <param name="aSource">伤害来源</param>
        /// <param name="aTarget">伤害目标</param>
        /// <param name="aDamageEffect">伤害效果</param>
        /// <param name="aOldDamage">原先的伤害量</param>
        /// <param name="aData">游戏数据</param>
        /// <returns>返回新的伤害量</returns>
        public static sbyte CalcDamage(Card.Effect aWeaponEffect, ChiefBase aSource, ChiefBase aTarget, Card.Effect aDamageEffect, sbyte aOldDamage, GlobalData aData)
        {
            switch (aWeaponEffect)
            {
            case Card.Effect.GuDianDao:
                if (aDamageEffect == Card.Effect.Sha && aTarget != null && aData.Game.GamePlayers[aTarget].Hands.Count == 0)
                {
                    return(++aOldDamage);
                }
                break;
            }

            return(aOldDamage);
        }
Exemplo n.º 25
0
        private byte CalcKitDistance(ChiefBase aChief)
        {
            byte ret = 1;

            if (GamePlayers[aChief].Jian1Ma != null)
            {
                ret++;
            }
            foreach (ASkill s in aChief.Skills)
            {
                ret = s.CalcKitDistance(aChief, ret, gData);
            }
            return(ret);
        }
Exemplo n.º 26
0
        private byte CalcShaDistance(ChiefBase aChief)
        {
            byte ret = 1;

            if (GamePlayers[aChief].Weapon != null)
            {
                ret = Convert.ToByte(Weapon.WeaponRange(GamePlayers[aChief].Weapon.CardEffect));
            }
            if (GamePlayers[aChief].Jian1Ma != null)
            {
                ret++;
            }
            foreach (ASkill s in aChief.Skills)
            {
                ret = s.CalcShaDistance(aChief, ret, gData);
            }
            return(ret);
        }
Exemplo n.º 27
0
        /// <summary>
        /// 发送转移牌的消息
        /// </summary>
        /// <param name="aFrom">牌的来源武将</param>
        /// <param name="aTo">牌的目标武将</param>
        /// <param name="aCards">牌</param>
        /// <param name="aPlayers">玩家集合</param>
        internal void SendGiveMessage(ChiefBase aFrom, ChiefBase aTo, Card[] aCards, Players aPlayers)
        {
            List <Card> vir = new List <Card>();

            foreach (Card c in aCards)
            {
                if (aPlayers[aFrom].Hands.Contains(c))
                {
                    vir.Add(CardHeap.Unknown);
                }
                else
                {
                    vir.Add(c);
                }
            }
            SendMessage(aPlayers.All.Where((i) => i.Chief != aFrom && i.Chief != aTo).ToArray(), MessageCore.MakeGiveMessage(aFrom, aTo, vir.ToArray()), true);

            SendMessage(new ChiefBase[] { aFrom, aTo }, MessageCore.MakeGiveMessage(aFrom, aTo, aCards), false);
        }
Exemplo n.º 28
0
 /// <summary>
 /// 一个用于武将之间移动牌的方法,默认将牌送至收到牌的武将的手牌中
 /// </summary>
 /// <param name="aChiefFrom">给出牌的武将</param>
 /// <param name="aChiefTo">收到牌的武将</param>
 /// <param name="aCards">牌数组</param>
 internal bool Move(ChiefBase aChiefFrom, ChiefBase aChiefTo, Card[] aCards)
 {
     if (GamePlayers[aChiefFrom].Dead || GamePlayers[aChiefTo].Dead)
     {
         return(false);
     }
     if (aChiefTo == aChiefFrom)
     {
         return(false);
     }
     if (!DropCards(false, CardFrom.HandAndEquipage, string.Empty, aCards, Card.Effect.None, aChiefFrom, null, null))
     {
         return(false);
     }
     foreach (Card c in aCards)
     {
         GamePlayers[aChiefTo].Hands.Add(c.GetOriginalCard());
     }
     return(true);
 }
Exemplo n.º 29
0
        /// <summary>
        /// 移除武将的手牌,如果不能全部移除将不会改变玩家的手牌
        /// 注意,方法成功之后移除的手牌并不会放入弃牌堆
        /// </summary>
        /// <param name="aChief">武将</param>
        /// <param name="aCards">需要移除的手牌</param>
        /// <returns>移除正常返回true</returns>
        internal bool RemoveHand(ChiefBase aChief, Card[] aCards)
        {
            foreach (Card c in aCards)
            {
                if (!GamePlayers[aChief].Hands.Contains(c))
                {
                    return(false);
                }
            }
            List <Card> old = GamePlayers[aChief].Hands.ToList();

            foreach (Card c in aCards)
            {
                if (!GamePlayers[aChief].RemoveHand(c))
                {
                    GamePlayers[aChief].Hands = old;
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 对方对杀出闪时候的处理方法
        /// </summary>
        /// <param name="aWeaponEffect"></param>
        /// <param name="aSource"></param>
        /// <param name="aTarget"></param>
        /// <param name="aData"></param>
        /// <param name="aShaEvent"></param>
        /// <returns></returns>
        public static bool TargetShan(Card.Effect aWeaponEffect, ChiefBase aSource, ChiefBase aTarget, GlobalData aData, GlobalEvent.EventRecoard aShaEvent)
        {
            string msg = null;

            MessageCore.AskForResult res = null;
            switch (aWeaponEffect)
            {
            case Card.Effect.GuanShiFu:
                msg = new Beaver("askfor.gsf.cards", aSource.ChiefName).ToString();
                //new XElement("askfor.gsf.cards",
                //    new XElement("target", aSource.ChiefName)
                //    );
                res = aData.Game.AsynchronousCore.AskForCards(aSource, MessageCore.AskForEnum.TargetTwoCardsWithoutWeaponAndJudgement, new AskForWrapper(msg, aData.Game), aData);
                aData.Game.AsynchronousCore.LeadingValid(aSource);
                if (res.Effect != Card.Effect.None)
                {
                    aData.Game.DropCards(true, GlobalEvent.CardFrom.HandAndEquipage, res.SkillName, res.Cards, Card.Effect.None, aSource, aTarget, null);
                    return(true);
                }
                break;

            case Card.Effect.QingLongYanYueDao:
                msg = new Beaver("askfor.qlyy.sha", aSource.ChiefName).ToString();
                //new XElement("askfor.qlyy.sha",
                //    new XElement("target", aSource.ChiefName)
                //    );
                res = aData.Game.AsynchronousCore.AskForCards(aSource, MessageCore.AskForEnum.Sha, new AskForWrapper(msg, aData.Game), aData);
                aData.Game.AsynchronousCore.LeadingValid(aSource);
                if (res.Effect == Card.Effect.Sha)
                {
                    aData.Game.DropCards(true, GlobalEvent.CardFrom.Hand, res.SkillName, res.Cards, Card.Effect.Sha, aSource, aTarget, null);
                    aData.Game.ShaProc(aData.Game.lstRecoard[aData.Game.lstRecoard.Count - 1]);
                }
                break;
            }
            return(false);
        }