示例#1
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));
 }
示例#2
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);
     }
 }
示例#3
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);
 }
示例#4
0
        /// <summary>
        /// 南蛮入侵的过程
        /// </summary>
        /// <param name="r">子事件的起始节点</param>
        /// <returns></returns>
        private EventRecoard NanManRuQinProc(EventRecoard r)
        {
            //对方不能死亡
            if (!GamePlayers[r.Target].Dead)
            {
                //无懈可击的执行过程
                if (WuXieProc(r.Target, Card.Effect.NanManRuQin))
                {
                    return(r);
                }

                if (GamePlayers[r.Target].Armor == null || Armor.EnableFor(GamePlayers[r.Target].Armor.CardEffect, r.Cards, Card.Effect.NanManRuQin, r.Target))
                {
                    string msg = new Beaver("askfor.nmrq.sha", r.Target.ChiefName, r.Source.ChiefName).ToString();
                    //new XElement("askfor.nmrq.sha",
                    //    new XElement("target", r.Target.ChiefName),
                    //    new XElement("source", r.Source.ChiefName)
                    //);
                    //问询杀
                    MessageCore.AskForResult resSha = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.Sha, new AskForWrapper(msg, this), gData);
                    ValidityResult(r.Target, ref resSha);
                    if (resSha.Effect == Card.Effect.Sha)
                    {
                        //将杀放入子事件节点
                        if (resSha.PlayerLead)
                        {
                            DropCards(true, CardFrom.Hand, resSha.SkillName, resSha.Cards, Card.Effect.None, resSha.Leader, r.Source, null);
                            foreach (ASkill s in resSha.Leader.Skills)
                            {
                                s.OnUseEffect(resSha.Leader, Card.Effect.Sha, gData);
                            }
                            AsynchronousCore.SendMessage(
                                new Beaver("nmrq.sha", r.Target.ChiefName, r.Source.ChiefName, resSha.SkillName, Card.Cards2Beaver("cards", resSha.Cards)).ToString());
                            //        new XElement("nmrq.sha",
                            //            new XElement("target", r.Target.ChiefName),
                            //            new XElement("source", r.Source.ChiefName),
                            //            new XElement("skill", resSha.SkillName),
                            //            Card.Cards2XML("cards", resSha.Cards)
                            //        ));
                        }
                    }
                    else
                    {
                        //没有杀,费血
                        DamageHealth(r.Target, 1, r.Source, r);
                    }
                }
            }
            return(r);
        }
示例#5
0
        /// <summary>
        /// 顺手牵羊的过程
        /// </summary>
        /// <param name="r">子事件的起始节点</param>
        /// <returns></returns>
        private EventRecoard ShunShouQianYangProc(EventRecoard r)
        {
            //玩家自己和对方不能死亡,并且对方有牌
            if (!GamePlayers[r.Source].Dead && !GamePlayers[r.Target].Dead && GamePlayers[r.Target].HasCardWithJudgementArea)
            {
                //无懈可击的过程
                if (WuXieProc(r.Target, Card.Effect.ShunShouQianYang))
                {
                    return(r);
                }
                AsynchronousCore.SendMessage(
                    new Beaver("askfor.ssqy.select", r.Source.ChiefName, r.Target.ChiefName).ToString());
                //new XElement("askfor.ssqy.select",
                //    new XElement("target", r.Source.ChiefName),
                //    new XElement("target2", r.Target.ChiefName)
                //));
                //问询玩家选择对方一张牌
                MessageCore.AskForResult res = AsynchronousCore.AskForCards(r.Source, MessageCore.AskForEnum.TargetCardWithJudgementArea, r.Target);
                //如果没有选那就自动抽一张
                if (res.Effect == Card.Effect.None || res.Cards.Count() != 1)
                {
                    Card auto = AutoSelect(r.Target);
                    if (auto == null)
                    {
                        res = new MessageCore.AskForResult(false, res.Leader, res.Targets, new Card[0] {
                        }, Card.Effect.ShunShouQianYang, false, true, string.Empty);
                    }
                    else
                    {
                        res = new MessageCore.AskForResult(false, res.Leader, res.Targets, new Card[] { auto }, Card.Effect.ShunShouQianYang, false, true, string.Empty);
                    }
                }

                if (res.Cards.Count() != 0)
                {
                    Move(r.Target, r.Source, res.Cards);
                    ////把牌给玩家
                    //foreach (Card c in res.Cards)
                    //{
                    //    AsynchronousCore.SendStealMessage(r.Target, r.Source, new Card[] { c }, GamePlayers);
                    //    GamePlayers[r.Source].Hands.Add(c.GetOriginalCard());
                    //}
                    ////增加节点:顺手牵羊选择的牌
                    //EventNode(false, CardFrom.HandAndEquipageAndJudgement, res.SkillName, res.Cards, Card.Effect.None, r.Target, r.Source, null);
                }
            }
            return(r);
        }
示例#6
0
        /// <summary>
        /// 过河拆桥的过程
        /// </summary>
        /// <param name="r">子事件的起始节点</param>
        /// <returns></returns>
        private EventRecoard GuoHeChaiQiaoProc(EventRecoard r)
        {
            //双方不能有任何一方,并且对方有牌可以选择死亡
            if (!GamePlayers[r.Source].Dead && !GamePlayers[r.Target].Dead && GamePlayers[r.Target].HasCardWithJudgementArea)
            {
                //进入无懈可击的过程
                if (WuXieProc(r.Target, Card.Effect.GuoHeChaiQiao))
                {
                    return(r);
                }
                AsynchronousCore.SendMessage(
                    new Beaver("askfor.ghcq.select", r.Source.ChiefName, r.Target.ChiefName).ToString());
                //new XElement("askfor.ghcq.select",
                //    new XElement("target", r.Source.ChiefName),
                //    new XElement("target2", r.Target.ChiefName)
                //));
                //问询玩家选择对方一张牌
                MessageCore.AskForResult res = AsynchronousCore.AskForCards(r.Source, MessageCore.AskForEnum.TargetCardWithJudgementArea, r.Target);
                //如果没有选择那就系统选择一张牌
                if (res.Effect == Card.Effect.None)
                {
                    Card auto = AutoSelect(r.Target);
                    if (auto == null)
                    {
                        res = new MessageCore.AskForResult(false, res.Leader, res.Targets, new Card[0] {
                        }, Card.Effect.GuoHeChaiQiao, false, true, string.Empty);
                    }
                    else
                    {
                        res = new MessageCore.AskForResult(false, res.Leader, res.Targets, new Card[] { auto }, Card.Effect.GuoHeChaiQiao, false, true, string.Empty);
                    }
                }

                if (res.Cards.Count() != 0)
                {
                    //将对方的这张牌加入到子事件节点上并弃置到垃圾桶中
                    DropCards(true, CardFrom.HandAndEquipageAndJudgement, res.SkillName, res.Cards, Card.Effect.None, r.Target, r.Source, null);
                    AsynchronousCore.SendMessage(MessageCore.MakeDropMessage(r.Source, r.Target, res.Cards));
                }
            }
            return(r);
        }
示例#7
0
 /// <summary>
 /// 五谷丰登的执行过程
 /// </summary>
 /// <param name="r">起始子事件对象</param>
 /// <returns>起始子事件</returns>
 private EventRecoard WuGuFengDengProc(EventRecoard r)
 {
     //子事件的目标必须存在且目标不能死亡
     if (r.Target != null && !GamePlayers[r.Target].Dead)
     {
         //开始无懈可击的处理
         if (WuXieProc(r.Target, Card.Effect.WuGuFengDeng))
         {
             return(r);
         }
         //发送问询
         string msg = new Beaver("askfor.wgfd.select", r.Target.ChiefName).ToString();
         //new XElement("askfor.wgfd.select",
         //    new XElement("target", r.Target.ChiefName)
         //    );
         //获取问询结果
         MessageCore.AskForResult res = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.WuGuFengDeng, new AskForWrapper(msg, this), gData);
         //回应的牌不正确,则自动选择一张
         if (res.Cards.Count() != 1 || (res.Cards.Count() == 1 && !CardsBuffer[WGFDSlotName].Cards.Contains(res.Cards[0])))
         {
             res = new MessageCore.AskForResult(false, r.Target, new ChiefBase[] { }, new Card[] { CardsBuffer[WGFDSlotName].Cards[GetRandom(CardsBuffer[WGFDSlotName].Cards.Count)] }, Card.Effect.None, false, false, res.SkillName);
         }
         foreach (Card c in res.Cards)
         {
             CardsBuffer[WGFDSlotName].Cards.Remove(c);
             GamePlayers[r.Target].Hands.Add(c);
         }
         //发送消息
         AsynchronousCore.SendMessage(
             new Beaver("wgfd.select", r.Target.ChiefName, Card.Cards2Beaver("cards", res.Cards)).ToString());
         //new XElement("wgfd.select",
         //    new XElement("target", r.Target.ChiefName),
         //    Card.Cards2XML("cards", res.Cards)
         //));
     }
     return(r);
 }
示例#8
0
        /// <summary>
        /// 万箭齐发的过程
        /// </summary>
        /// <param name="r">子事件的起始节点</param>
        /// <returns></returns>
        private EventRecoard WanJianQiFaProc(EventRecoard r)
        {
            string msg = null;

            //对方不能死亡
            if (!GamePlayers[r.Target].Dead)
            {
                //进入无懈可击的过程
                if (WuXieProc(r.Target, Card.Effect.WanJianQiFa))
                {
                    return(r);
                }
                if (GamePlayers[r.Target].Armor == null || Armor.EnableFor(GamePlayers[r.Target].Armor.CardEffect, r.Cards, Card.Effect.WanJianQiFa, r.Target))
                {
                    MessageCore.AskForResult resShan = null;
                    msg = new Beaver("askfor.wjqf.shan", r.Target.ChiefName, r.Source.ChiefName).ToString();
                    //new XElement("askfor.wjqf.shan",
                    //    new XElement("target", r.Target.ChiefName),
                    //    new XElement("source", r.Source.ChiefName)
                    //);
                    //问询闪
                    resShan = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.Shan, new AskForWrapper(msg, this), true, gData);
                    ValidityResult(r.Target, ref resShan);
                    //}
                    if (resShan.PlayerLead)
                    {
                        DropCards(true, CardFrom.Hand, resShan.SkillName, resShan.Cards, resShan.Effect, resShan.Leader, r.Source, null);
                    }
                    else
                    {
                        DropCards(false, CardFrom.None, resShan.SkillName, resShan.Cards, resShan.Effect, resShan.Leader, r.Source, null);
                    }
                    //将问询的牌放入到子事件节点
                    //EventNode(true, CardFrom.Hand, resShan.SkillName , resShan.Cards, resShan.Effect, r.Target, r.Source, null);
                    foreach (ASkill s in resShan.Leader.Skills)
                    {
                        s.OnUseEffect(resShan.Leader, Card.Effect.Shan, gData);
                    }
                    if (resShan.Effect == Card.Effect.Shan)
                    {
                        if (resShan.PlayerLead)
                        {
                            AsynchronousCore.SendMessage(
                                new Beaver("wjqf.shan", r.Target.ChiefName, r.Source.ChiefName, resShan.SkillName, Card.Cards2Beaver("cards", resShan.Cards)).ToString());
                        }
                        //new XElement("wjqf.shan",
                        //    new XElement("target", r.Target.ChiefName),
                        //    new XElement("source", r.Source.ChiefName),
                        //    new XElement("skill", resShan.SkillName),
                        //    Card.Cards2XML("cards", resShan.Cards)
                        //));
                    }
                    else
                    {
                        //没有出闪费血
                        DamageHealth(r.Target, 1, r.Source, r);
                    }
                }
            }
            return(r);
        }
示例#9
0
        /// <summary>弃牌问询,注意该方法仅用于弃牌阶段
        /// </summary>
        /// <param name="aChief">需要弃牌的武将</param>
        /// <returns>返回true表示弃牌正常</returns>
        private bool Abandonment(ChiefBase aChief)
        {
            bool first = true;

            //确定玩家弃牌的要求是否达到
            while (GamePlayers[aChief].Hands.Count > (GamePlayers[aChief].Health < 0 ? 0 : GamePlayers[aChief].Health))
            {
                //问询武将出牌
                string msg = new Beaver("askfor.abandonment", aChief.ChiefName).ToString();
                //new XElement("askfor.abandonment",
                //    new XElement("target", aChief.ChiefName)
                //);
                MessageCore.AskForResult res = null;
                if (first)
                {
                    first = false;
                    //弃牌问询
                    res = AsynchronousCore.AskForCards(aChief, MessageCore.AskForEnum.Abandonment, new AskForWrapper(msg, this), gData);
                }
                else
                {
                    //弃牌问询
                    res = AsynchronousCore.AskForCards(aChief, MessageCore.AskForEnum.AbandonmentNext, new AskForWrapper(msg, this), gData);
                }

                if (res.TimeOut || res.Cards.Count() == 0)
                {
                    res = new MessageCore.AskForResult(false, aChief, new ChiefBase[0], AutoAbandonment(aChief), Card.Effect.None, false, true, string.Empty);
                }
                //是否超过弃牌数
                if (GamePlayers[aChief].Hands.Count - res.Cards.Count() < (GamePlayers[aChief].Health < 0 ? 0 : GamePlayers[aChief].Health))
                {
                    //超过了,不合法,自动选择
                    Card[] cards = AutoAbandonment(aChief);
                    if (!RemoveHand(aChief, cards))
                    {
                        return(false);
                    }
                    CardsHeap.AddCards(cards);
                    AsynchronousCore.SendMessage(new Beaver("abandonment", aChief.ChiefName, GamePlayers[aChief].Hands.Count.ToString(), Card.Cards2Beaver("cards", res.Cards)).ToString());
                    //new XElement("abandonment",
                    //    new XElement("target", aChief.ChiefName),
                    //    new XElement("count", GamePlayers[aChief].Hands.Count),
                    //    Card.Cards2XML("cards", res.Cards)
                    //));
                }
                else
                {
                    if (!RemoveHand(aChief, res.Cards))
                    {
                        return(false);
                    }
                    //EventNode(true, CardFrom.Hand, res.Cards, Card.Effect.None, aChief, null, null);
                    CardsHeap.AddCards(res.Cards);
                    AsynchronousCore.SendMessage(
                        new Beaver("abandonment", aChief.ChiefName, GamePlayers[aChief].Hands.Count, Card.Cards2Beaver("cards", res.Cards)).ToString());
                    //new XElement("abandonment",
                    //    new XElement("target", aChief.ChiefName),
                    //    new XElement("count", GamePlayers[aChief].Hands.Count),
                    //    Card.Cards2XML("cards", res.Cards)
                    //));
                }
                //若牌数满足上限,弃牌完成
                if (GamePlayers[aChief].Hands.Count == GamePlayers[aChief].Health)
                {
                    return(true);
                }
            }
            //牌数小于限制,跳过弃牌
            return(true);
        }
示例#10
0
        /// <summary>
        /// 玩家出牌阶段的处理方法
        /// </summary>
        /// <param name="aResult">问询玩家产生的结果</param>
        /// <returns>如果出牌合法,那么将返回true</returns>
        protected bool LeadEvent(MessageCore.AskForResult aResult)
        {
            //对参数的检查
            if (aResult == null)
            {
                return(false);                  //参数不可以是null
            }
            if (aResult.Leader == null)
            {
                return(false);                          //问询回应者不能是null
            }
            if (aResult.Targets == null)
            {
                return(false);                          //问询目标数组不能是null,但可以是空数组
            }
            if (aResult.Cards == null)
            {
                return(false);                          //问询的出牌数组不能是null,但可以是空数组
            }
            foreach (ChiefBase c in aResult.Targets)    //每个目标对象不能是null
            {
                if (c == null)
                {
                    return(false);
                }
            }
            foreach (Card c in aResult.Cards)   //每个牌对象不能是null
            {
                if (c == null)
                {
                    return(false);
                }
            }
            //出牌无效
            if (!CheckValid(aResult, aResult.Leader))
            {
                return(false);
            }
            //将结果安置在这些临时变量中
            ChiefBase aChiefSource = aResult.Leader;

            ChiefBase[] aChiefTarget = aResult.Targets;
            Card[]      aCards       = aResult.Cards;
            Card.Effect aEffect      = aResult.Effect;

            //清除 打牌列表
            FreeCardBin();
            //清除事件队列
            queRecoard.Clear();
            //清除子事件队列
            lstRecoard.Clear();

            //根据牌的效果确定游戏玩法
            //并将事件安置到子事件队列
            switch (aEffect)
            {
            //技能处理过的回应,那这里就不处理他了
            case Card.Effect.Skill:
                DropCards(true, CardFrom.Slot, string.Empty, CardsBuffer[WGFDSlotName].Cards.ToArray(), Card.Effect.None, null, null, null);
                CardsBuffer[WGFDSlotName].Cards.Clear();
                //释放打牌列表,将这些牌放进弃牌堆
                FreeCardBin();
                //清除事件队列
                queRecoard.Clear();
                //清除子事件队列
                lstRecoard.Clear();
                return(true);

            //出杀
            case Card.Effect.Sha:

                //若出杀有限制且已经没有机会杀了不能执行
                if (!gData.ShaNoLimit && gData.KillRemain < 1)
                {
                    goto FAILED;
                }

                //if (GamePlayers[aChiefSource].Weapon != null)
                //    Weapon.ModifyProperty(GamePlayers[aChiefSource].Weapon.CardEffect, aCards, aChiefSource, aChiefTarget, MessageCore.AskForEnum.Aggressive, Card.Effect.Sha, gData);
                //杀的目标数量高于最大值不能执行
                if (CalcMaxShaTargets(aChiefSource, aCards) < aChiefTarget.Count())
                {
                    goto FAILED;
                }
                //没有目标不能执行
                if (aChiefTarget.Count() == 0)
                {
                    goto FAILED;
                }

                //遍历目标集合,如果目标有自己或者目标已死亡或者 够不到对方不能执行
                foreach (ChiefBase c in aChiefTarget)
                {
                    if (c.IsMe(aChiefSource) || GamePlayers[c].Dead || !WithinShaRange(aChiefSource, c))
                    {
                        goto FAILED;
                    }
                    bool Enable = true;
                    foreach (ASkill s in c.Skills)
                    {
                        Enable = s.EffectFeasible(aCards, aEffect, c, Enable, gData);
                    }
                    if (!Enable)
                    {
                        goto FAILED;
                    }
                }
                //如果有重复的目标也不能执行
                if (aChiefTarget.Distinct().Count() != aChiefTarget.Count())
                {
                    goto FAILED;
                }

                //设置杀计数器
                if (gData.KillRemain < 2)
                {
                    gData.KillRemain = 0;
                }
                else
                {
                    --gData.KillRemain;
                }
                //将杀事件按目标分解成一个个小事件,并装进子事件队列
                //即每个子事件都是玩家杀单独的玩家的处理事件
                foreach (ChiefBase c in aChiefTarget)
                {
                    queRecoard.Enqueue(new EventRecoard(aChiefSource, c, aCards, aEffect, aResult.SkillName));
                }

                //发送消息
                if (aResult.PlayerLead)
                {
                    AsynchronousCore.SendMessage(
                        new Beaver("sha", aChiefSource.ChiefName, ChiefBase.Chiefs2Beaver("to", aChiefTarget), aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                }
                //new XElement("sha",
                //    new XElement("from", aChiefSource.ChiefName),
                //    ChiefBase.Chiefs2XML("to", aChiefTarget),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //    );
                //通知武将技能 玩家使用了杀效果
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //决斗
            case Card.Effect.JueDou:
                if (aChiefTarget.Count() == 1)
                {
                    //目标不能是自己
                    if (aChiefTarget[0].IsMe(aChiefSource))
                    {
                        goto FAILED;
                    }
                    //对方不能死亡
                    if (GamePlayers[aChiefTarget[0]].Dead)
                    {
                        goto FAILED;
                    }
                    bool Enable = true;
                    foreach (ASkill s in aChiefTarget[0].Skills)
                    {
                        Enable = s.EffectFeasible(aCards, aEffect, aChiefTarget[0], Enable, gData);
                    }
                    if (!Enable)
                    {
                        goto FAILED;
                    }
                    //安置到事件子队列
                    queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefTarget[0], aCards, aEffect, aResult.SkillName));
                    //发送消息
                    AsynchronousCore.SendMessage(
                        new Beaver("jd", aChiefSource.ChiefName, aChiefTarget[0].ChiefName, aResult.SkillName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                    //new XElement("jd",
                    //    new XElement("from", aChiefSource.ChiefName),
                    //    new XElement("to", aChiefTarget[0].ChiefName),
                    //    new XElement("skill", aResult.SkillName),
                    //    Card.Cards2XML("cards", aCards)
                    //    )
                    //);
                    //通知武将技能 玩家使用了效果
                    foreach (ASkill s in aChiefSource.Skills)
                    {
                        s.OnUseEffect(aChiefSource, aEffect, gData);
                    }
                }
                else if (aChiefTarget.Count() == 2)
                {
                    if (aChiefTarget[0] == aChiefTarget[1])
                    {
                        goto FAILED;
                    }
                    if (GamePlayers[aChiefTarget[0]].Dead || GamePlayers[aChiefTarget[1]].Dead)
                    {
                        goto FAILED;
                    }
                    bool Enable = true;
                    foreach (ASkill s in aChiefTarget[1].Skills)
                    {
                        Enable = s.EffectFeasible(aCards, aEffect, aChiefTarget[1], Enable, gData);
                    }
                    if (!Enable)
                    {
                        goto FAILED;
                    }
                    //安置到事件子队列
                    queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefTarget[0], aChiefTarget[1], aCards, aEffect, aResult.SkillName));
                    //发送消息
                    AsynchronousCore.SendMessage(
                        new Beaver("jd", aChiefTarget[0].ChiefName, aChiefTarget[1].ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                    //new XElement("jd",
                    //    new XElement("from", aChiefTarget[0].ChiefName),
                    //    new XElement("to", aChiefTarget[1].ChiefName),
                    //    new XElement("skill", aResult.SkillName),
                    //    Card.Cards2XML("cards", aCards)
                    //    )
                    //);
                }
                else
                {
                    goto FAILED;
                }
                break;

            //桃
            case Card.Effect.Tao:
                //血量不能大于等于体力上限
                if (GamePlayers[aChiefSource].Health == GamePlayers[aChiefSource].MaxHealth)
                {
                    goto FAILED;
                }
                //安置到事件子队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefSource, aCards, aEffect, aResult.SkillName));
                //发送消息
                AsynchronousCore.SendMessage(
                    new Beaver("tao", aChiefSource.ChiefName, aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //    new XElement("tao",
                //        new XElement("from", aChiefSource.ChiefName),
                //        new XElement("to", aChiefSource.ChiefName),
                //        new XElement("skill", aResult.SkillName),
                //        Card.Cards2XML("cards", aCards)
                //    )
                //);
                //通知武将技能 玩家使用了效果
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //南蛮入侵
            case Card.Effect.NanManRuQin:
                //下面是把出牌玩家以后的其他玩家依次装入子事件列表中
                ChiefBase t = GamePlayers.NextChief(aChiefSource);
                while (!t.IsMe(aChiefSource))
                {
                    queRecoard.Enqueue(new EventRecoard(aChiefSource, t, aCards, aEffect, aResult.SkillName));
                    t = GamePlayers.NextChief(t);
                }
                AsynchronousCore.SendMessage(
                    new Beaver("nmrq", aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("nmrq",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //万箭齐发
            case Card.Effect.WanJianQiFa:
                //下面是把出牌玩家以后的其他玩家依次装入子事件列表中
                ChiefBase t2 = GamePlayers.NextChief(aChiefSource);
                while (!t2.IsMe(aChiefSource))
                {
                    queRecoard.Enqueue(new EventRecoard(aChiefSource, t2, aCards, aEffect, aResult.SkillName));
                    t2 = GamePlayers.NextChief(t2);
                }
                AsynchronousCore.SendMessage(
                    new Beaver("wjqf", aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("wjqf",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //桃园结义
            case Card.Effect.TaoYuanJieYi:
                //下面是把从出牌玩家开始的所有玩家依次装入子事件列表中
                ChiefBase t3 = aChiefSource;
                do
                {
                    if (GamePlayers[t3].Health < GamePlayers[t3].MaxHealth)
                    {
                        queRecoard.Enqueue(new EventRecoard(aChiefSource, t3, aCards, aEffect, aResult.SkillName));
                    }
                    t3 = GamePlayers.NextChief(t3);
                } while (!t3.IsMe(aChiefSource));
                AsynchronousCore.SendMessage(
                    new Beaver("tyjy", aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("tyjy",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //    );
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //无中生有
            case Card.Effect.WuZhongShengYou:
                //添加进子事件队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefSource, aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("wzsy", aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("wzsy",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //过河拆桥
            case Card.Effect.GuoHeChaiQiao:
                //必须有目标
                if (aChiefTarget.Count() != 1)
                {
                    goto FAILED;
                }
                //目标不能是自己
                if (aChiefTarget[0].IsMe(aChiefSource))
                {
                    goto FAILED;
                }
                //对方不能死亡
                if (GamePlayers[aChiefTarget[0]].Dead)
                {
                    goto FAILED;
                }
                //对方要有牌
                if (!GamePlayers[aChiefTarget[0]].HasCardWithJudgementArea)
                {
                    goto FAILED;
                }
                //添加进子事件队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefTarget[0], aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("ghcq", aChiefSource.ChiefName, aChiefTarget[0].ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("ghcq",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("to", aChiefTarget[0].ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            case Card.Effect.ShunShouQianYang:
                //必须有目标
                if (aChiefTarget.Count() != 1)
                {
                    goto FAILED;
                }
                //目标不能是自己
                if (aChiefTarget[0].IsMe(aChiefSource))
                {
                    goto FAILED;
                }
                //对方不能死亡
                if (GamePlayers[aChiefTarget[0]].Dead)
                {
                    goto FAILED;
                }
                //对方要有牌
                if (!GamePlayers[aChiefTarget[0]].HasCardWithJudgementArea)
                {
                    goto FAILED;
                }
                //可以够到对方
                if (!WithinKitRange(aChiefSource, aChiefTarget[0]))
                {
                    goto FAILED;
                }
                //添加进子事件队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefTarget[0], aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("sspy", aChiefSource.ChiefName, aChiefTarget[0].ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("ssqy",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("to", aChiefTarget[0].ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //借刀杀人
            case Card.Effect.JieDaoShaRen:
                //必须有两个目标
                if (aChiefTarget.Count() != 2)
                {
                    goto FAILED;
                }
                //第一个目标不能是自己
                if (aChiefTarget[0].IsMe(aChiefSource))
                {
                    goto FAILED;
                }
                //第一个目标不能死亡
                if (GamePlayers[aChiefTarget[0]].Dead)
                {
                    goto FAILED;
                }
                //第二个目标不能死亡
                if (GamePlayers[aChiefTarget[1]].Dead)
                {
                    goto FAILED;
                }
                //两个目标不能一样
                if (aChiefTarget[0].IsMe(aChiefTarget[1]))
                {
                    goto FAILED;
                }
                //必须能能够到对方
                if (!WithinShaRange(aChiefTarget[0], aChiefTarget[1]))
                {
                    goto FAILED;
                }
                //添加进子事件队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefTarget[0], aChiefTarget[1], aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("jdsr", aChiefSource.ChiefName, aChiefTarget[0].ChiefName, aChiefTarget[1].ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("jdsr",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("to", aChiefTarget[0].ChiefName),
                //    new XElement("to2", aChiefTarget[1].ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //乐不思蜀
            case Card.Effect.LeBuSiShu:
                //必须有目标且目标不能使自己且目标不能死亡
                if (aChiefTarget.Count() != 1 || aChiefTarget[0] == aChiefSource || GamePlayers[aChiefTarget[0]].Dead)
                {
                    goto FAILED;
                }
                //目标不能有乐不思蜀buff
                if (GamePlayers[aChiefTarget[0]].HasDebuff(Card.Effect.LeBuSiShu))
                {
                    goto FAILED;
                }
                //添加进子事件队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefTarget[0], aCards, aEffect, aResult.SkillName));
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //闪电
            case Card.Effect.ShanDian:
                //玩家不能死亡
                if (GamePlayers[aChiefSource].Dead)
                {
                    goto FAILED;
                }
                //玩家不能有闪电buff
                if (GamePlayers[aChiefSource].HasDebuff(Card.Effect.ShanDian))
                {
                    goto FAILED;
                }
                //添加进子事件队列
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefSource, aCards, aEffect, aResult.SkillName));
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //五谷丰登
            case Card.Effect.WuGuFengDeng:
                ChiefBase t4 = aChiefSource;
                do
                {
                    queRecoard.Enqueue(new EventRecoard(aChiefSource, t4, aCards, aEffect, aResult.SkillName));
                    t4 = GamePlayers.NextChief(t4);
                } while (!t4.IsMe(aChiefSource));
                //List<Card> lstWGFD = CardsHeap.Pop(GamePlayers.PeoplealiveCount).ToList();
                //lstWGFDBuff = lstWGFD;
                CardsBuffer[WGFDSlotName].Cards.Clear();
                CardsBuffer[WGFDSlotName].Cards.AddRange(CardsHeap.Pop(GamePlayers.PeoplealiveCount));
                AsynchronousCore.SendMessage(
                    new Beaver("wgfd", aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", CardsBuffer[WGFDSlotName].Cards.ToArray())).ToString());
                //new XElement("wgfd",
                //new XElement("from", aChiefSource.ChiefName),
                //new XElement("skill", aResult.SkillName),
                //Card.Cards2XML("cards", CardsBuffer[WGFDSlotName].Cards.ToArray())));

                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //八卦阵
            case Card.Effect.BaGuaZhen:
            //藤甲
            case Card.Effect.TengJia:
            //仁王盾
            case Card.Effect.RenWangDun:
            //白银狮子
            case Card.Effect.BaiYinShiZi:
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefSource, aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("armor", aChiefSource.ChiefName, aResult.SkillName, Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("armor",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            //武器
            case Card.Effect.ZhangBaSheMao:
            case Card.Effect.ZhuGeLianNu:
            case Card.Effect.GuDianDao:
            case Card.Effect.QiLinGong:
            case Card.Effect.GuanShiFu:
            case Card.Effect.QingLongYanYueDao:
            case Card.Effect.QingGangJian:
            case Card.Effect.CiXiongShuangGuJian:
            case Card.Effect.ZhuQueYuShan:
            case Card.Effect.FangTianHuaJi:
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefSource, aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("weapon", aChiefSource.ChiefName, aResult.SkillName, aResult.Effect.ToString(), Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("weapon",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    new XElement("effect", aResult.Effect),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            case Card.Effect.Jia1:
            case Card.Effect.Jian1:
                queRecoard.Enqueue(new EventRecoard(aChiefSource, aChiefSource, aCards, aEffect, aResult.SkillName));
                AsynchronousCore.SendMessage(
                    new Beaver("horse", aChiefSource.ChiefName, aResult.SkillName, aResult.Effect.ToString(), Card.Cards2Beaver("cards", aCards)).ToString());
                //new XElement("horse",
                //    new XElement("from", aChiefSource.ChiefName),
                //    new XElement("skill", aResult.SkillName),
                //    new XElement("effect", aResult.Effect),
                //    Card.Cards2XML("cards", aCards)
                //    )
                //);
                foreach (ASkill s in aChiefSource.Skills)
                {
                    s.OnUseEffect(aChiefSource, aEffect, gData);
                }
                break;

            default:
                return(false);
            }
            if (aResult.PlayerLead)
            {
                if (!RemoveHand(aChiefSource, aCards))
                {
                    goto FAILED;
                }
            }

            AsynchronousCore.LeadingValid(aChiefSource);
            //将牌放入 打牌列表
            if (aResult.PlayerLead)
            {
                lstCardBin.AddRange(aCards);
            }
            //处理子事件
            while (queRecoard.Count != 0)
            {
                EventProc();
                //清除子事件节点
                lstRecoard.Clear();
            }
            //删除五谷丰登牌堆中的牌
            DropCards(true, CardFrom.Slot, string.Empty, CardsBuffer[WGFDSlotName].Cards.ToArray(), Card.Effect.None, null, null, null);
            CardsBuffer[WGFDSlotName].Cards.Clear();
            //释放打牌列表,将这些牌放进弃牌堆
            FreeCardBin();
            //清除事件队列
            queRecoard.Clear();
            //清除子事件队列
            lstRecoard.Clear();


            //执行成功
            return(true);

FAILED:
            AsynchronousCore.LeadingInvalid(aChiefSource);
            DropCards(true, CardFrom.Slot, string.Empty, CardsBuffer[WGFDSlotName].Cards.ToArray(), Card.Effect.None, null, null, null);
            CardsBuffer[WGFDSlotName].Cards.Clear();
            //释放打牌列表,将这些牌放进弃牌堆
            FreeCardBin();
            //清除事件队列
            queRecoard.Clear();
            //清除子事件队列
            lstRecoard.Clear();
            //执行成功
            return(false);
        }
示例#11
0
        /// <summary>
        /// 无懈可击子事件
        /// </summary>
        /// <param name="aTarget">需要无懈可击的目标</param>
        /// <param name="aEffect">无懈可击的效果</param>
        /// <returns>true表示无懈可击成立,反之不成立</returns>
        protected bool WuXieProc(ChiefBase aTarget, Card.Effect aEffect)
        {
            //这个量来表示场上是否有无懈可击存在
            bool WuXieExist = false;
            //表决字典
            //表决字典是用来记录玩家(键)的表态(值)
            //某个玩家的值为false代表没有表态,true表带已表态
            //通信层根据这个字典会对值为False的玩家进行并行问询
            //若其中有玩家问询时选择确认(一般指放弃),将其值定位true
            //若所有玩家都是true或超时,表决结束,问询返回None
            //若有玩家出 无懈可击 时,表决问询将直接结束,返回 WuXieKeJi问询
            Dictionary <Player, bool> abstention = new Dictionary <Player, bool>();
            ChiefBase s = aTarget;

            //遍历场上的玩家
            do
            {
                if (!GamePlayers[s].Dead && GamePlayers[s].Hands.Find(c => c.CardEffect == Card.Effect.WuXieKeJi) != null)
                {
                    //这个玩家有手牌无懈可击,将他加入表决字典并置value为false,表示他可以表决
                    abstention.Add(GamePlayers[s], false);
                    //无懈可击存在
                    WuXieExist = true;
                }
                else
                {
                    //这个玩家没有无懈可击,设置其值为true,表示已表决
                    abstention.Add(GamePlayers[s], true);
                }
                s = s.Next;
            } while (s != aTarget);

            //无懈可击存在,启动问询
            if (WuXieExist)
            {
                AsynchronousCore.SendMessage(
                    new Beaver("askfor.wxkj", aTarget.ChiefName, aEffect.ToString()).ToString());
                //new XElement("askfor.wxkj",
                //    new XElement("from", aTarget.ChiefName),
                //    new XElement("effect", aEffect)
                //    )
                //);
                //开始问询
                MessageCore.AskForResult res = AsynchronousCore.AskForCards(MessageCore.AskForEnum.WuXieKeJi, abstention);
                ValidityResult(res.Leader, ref res);
                //若有玩家打出无懈可击
                if (res.Effect == Card.Effect.WuXieKeJi)
                {
                    //事件节点加入
                    DropCards(true, CardFrom.Hand, res.SkillName, res.Cards, Card.Effect.WuXieKeJi, res.Leader, aTarget, null);
                    AsynchronousCore.SendMessage(
                        new Beaver("wxkj", res.Leader.ChiefName, Card.Cards2Beaver("cards", res.Cards)).ToString());
                    //new XElement("wxkj",
                    //    new XElement("from", res.Leader.ChiefName),

                    //    Card.Cards2XML("cards", res.Cards)
                    //));
                    //目标换成出牌者
                    aTarget = res.Leader;
                    //两个结果异或即本轮结果
                    return(true ^ WuXieProc(aTarget, Card.Effect.WuXieKeJi));
                }
            }
            //返回false
            return(false);
        }
示例#12
0
        /// <summary>
        /// 开启逻辑循环
        /// </summary>
        /// <param name="aChiefStart">设置首个进入回合的武将</param>
        /// <param name="aIgnoreTakeCards">是否忽略一开始对玩家每人发4张牌的过程</param>
        protected void LogicLoop(ChiefBase aChiefStart, bool aIgnoreTakeCards)
        {
            AsynchronousCore.SendEnvironmentMessage();
            ChiefBase target = aChiefStart; //target , 问询的目标
            ChiefBase loop   = aChiefStart;

            do
            {
                foreach (ASkill s in loop.Skills)
                {
                    s.OnCreate(loop);
                }
                loop.ReportSkills(gData);
                loop = loop.Next;
            } while (loop != target);

            if (!aIgnoreTakeCards)
            {
                loop = aChiefStart;
                //轮询给每个武将4张牌
                do
                {
                    TakeingCards(loop, 4);
                    loop = loop.Next;
                } while (loop != target);
            }
            RefereeProc();
            //游戏的轮询
            do
            {
                //复位游戏规则控制数据
                gData      = new GlobalData();
                gData.Game = this;
                //设置执行回合的武将
                gData.Active = target;
                //若武将有武器,尝试让该武将的武器配置玩家的某些进攻性属性
                if (GamePlayers[target].Weapon != null)
                {
                    Weapon.ActiveWeapon(GamePlayers[target].Weapon.CardEffect, gData);
                }
                //改变武将状态-回合开始
                AsynchronousCore.SendChangeStatusMessage(target, MessageCore.PlayerStatus.Start);
                {
                    gData.ChiefStatus = "turnStart";
                    //通知该武将的技能该武将进入回合开始阶段
                    foreach (ASkill s in target.Skills)
                    {
                        s.BeforeTurnStart(target, gData);
                    }
                    //事件结束
                    ClearEventProc();
                }
                //改变武将状态-判定
                AsynchronousCore.SendChangeStatusMessage(target, MessageCore.PlayerStatus.Judgment);
                {
                    gData.ChiefStatus = "judgment";
                    //执行武将判定区的判定
                    Judgement(target, gData);
                    //事件结束
                    ClearEventProc();
                }
                foreach (ASkill s in target.Skills)
                {
                    s.BeforeTakeCards(target, gData);
                }
                if (gData.Take)
                {
                    //改变武将状态-拿牌
                    AsynchronousCore.SendChangeStatusMessage(target, MessageCore.PlayerStatus.Take);
                    {
                        gData.ChiefStatus = "take";
                        foreach (ASkill s in target.Skills)
                        {
                            s.TakingCards(target, gData);
                        }
                        //从牌堆取 gData.TakeCardsCount 张牌
                        Card[] ret = TakeingCards(target, gData.TakeCardsCount);
                        //事件结束
                        ClearEventProc();
                    }
                }
                //武将状态-出牌
                //要求 允许出牌且玩家未死亡
                if (gData.Lead && !GamePlayers[target].Dead)
                {
                    //改变武将状态-出牌
                    AsynchronousCore.SendChangeStatusMessage(target, MessageCore.PlayerStatus.Lead);
                    gData.ChiefStatus = "lead";
                    foreach (ASkill s in target.Skills)
                    {
                        s.Leading(target, gData);
                    }
                    //这里是一个循环,不断问询玩家出牌,若玩家Effect为None,就跳过这个阶段
                    while (!GamePlayers[target].Dead)
                    {
                        //重置全局数据中的活动部分
                        gData.Reset();

                        string msg = new Beaver("askfor.aggressive", target.ChiefName).ToString();
                        //new XElement("askfor.aggressive",
                        //    new XElement("target", target.ChiefName)
                        //);
                        //开始问询
                        MessageCore.AskForResult res = AsynchronousCore.AskForCards(target, MessageCore.AskForEnum.Aggressive, new AskForWrapper(msg, this), gData);
                        //是否跳过该阶段
                        if (res.Effect == Card.Effect.None)
                        {
                            AsynchronousCore.SendClearMessage();
                            break;
                        }
                        //出牌进行处理,并反馈是否符合规则
                        if (!LeadEvent(res))
                        {
                            ClearEventProc();
                            break;
                        }
                        else
                        {
                            ClearEventProc();
                        }
                    }
                }

                //在进入弃牌阶段前,通知武将的技能
                foreach (ASkill s in target.Skills)
                {
                    s.BeforeAbandonment(target, gData);
                }

                //允许武将进入弃牌阶段
                if (gData.Abandonment)
                {
                    //改变武将状态-弃牌
                    AsynchronousCore.SendChangeStatusMessage(target, MessageCore.PlayerStatus.Abandoment);
                    {
                        gData.ChiefStatus = "abandoment";
                        //玩家弃牌的问询
                        if (!Abandonment(target))
                        {
                            AsynchronousCore.LeadingInvalid(target);
                        }
                        else
                        {
                            AsynchronousCore.LeadingValid(target);
                        }
                        ClearEventProc();
                    }
                }
                //玩家回合结束前通知武将的技能
                foreach (ASkill s in target.Skills)
                {
                    s.AfterTurnEnd(target, gData);
                }
                //牌检查器报告情况
                AsynchronousCore.SendMessage(CardsHeap.CardsChecker(this));
            } while ((target = target.Next) != null); //target=下一个玩家

            //-----------------------------------------------------------
            //如果玩家都死光了...没分胜负,我想这里会有异常吧
        }
示例#13
0
        /// <summary>
        /// 杀的过程
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        internal EventRecoard ShaProc(EventRecoard r)
        {
            foreach (ASkill s in r.Target.Skills)
            {
                s.PreprocessingSubEvent(r.Target, ref r, gData);
            }
            //这里再检查一次玩家是否死亡是怕玩家在以前的子事件中挂掉了,如果真挂了就忽略掉这次事件
            if (!GamePlayers[r.Target].Dead)
            {
                if (GamePlayers[r.Source].Weapon != null)
                {
                    Weapon.Lead(GamePlayers[r.Source].Weapon.CardEffect, r.Effect, r.Cards, gData, r.Source, r.Target);
                }
                if (GamePlayers[r.Target].Armor == null || (GamePlayers[r.Source].Weapon != null && Weapon.EnableTargetArmorWithMessage(GamePlayers[r.Source].Weapon.CardEffect, r.Source, r.Target, gData) && Armor.EnableFor(GamePlayers[r.Target].Armor.CardEffect, r.Cards, Card.Effect.Sha, r.Target)) || !(GamePlayers[r.Source].Weapon != null && Weapon.EnableTargetArmor(GamePlayers[r.Source].Weapon.CardEffect, r.Source, r.Target)))
                {
                    MessageCore.AskForResult res = null;
                    bool EnableDamage            = false;
                    int  times = 1;
                    foreach (ASkill s in r.Source.Skills)
                    {
                        times = s.CalcAskforTimes(r.Source, r.Target, Card.Effect.Sha, times, gData);
                    }
                    for (int i = 0; i < times; i++)
                    {
                        res          = null;
                        EnableDamage = false;
                        string msg = new Beaver("askfor.sha.shan", r.Target.ChiefName, r.Source.ChiefName).ToString();
                        //new XElement("askfor.sha.shan",
                        //            new XElement("target", r.Target.ChiefName),
                        //            new XElement("source", r.Source.ChiefName)
                        //            );
                        if (GamePlayers[r.Target].Armor != null && (GamePlayers[r.Source].Weapon == null || Weapon.EnableTargetArmor(GamePlayers[r.Source].Weapon.CardEffect, r.Source, r.Target)))
                        {
                            //问询 闪
                            res = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.Shan, new AskForWrapper(msg, this), gData);
                        }
                        else
                        {
                            //问询 闪
                            res = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.Shan, new AskForWrapper(msg, this), false, gData);
                        }
                        //检验出牌合法性
                        ValidityResult(r.Target, ref res);

                        //问询结果放入子事件处理列表
                        if (res.PlayerLead)
                        {
                            DropCards(true, CardFrom.Hand, res.SkillName, res.Cards, res.Effect, res.Leader, r.Source, null);
                        }
                        else
                        {
                            DropCards(false, CardFrom.None, res.SkillName, res.Cards, res.Effect, res.Leader, r.Source, null);
                        }

                        if (res.Effect == Card.Effect.Shan)
                        {
                            if (res.PlayerLead)
                            {
                                AsynchronousCore.LeadingValid(r.Target);
                                AsynchronousCore.SendMessage(
                                    new Beaver("sha.shan", r.Target.ChiefName, r.Source.ChiefName, res.SkillName, Card.Cards2Beaver("cards", res.Cards)).ToString());
                                //new XElement("sha.shan",
                                //    new XElement("from", r.Target.ChiefName),
                                //    new XElement("to", r.Source.ChiefName),
                                //    new XElement("skill", res.SkillName),
                                //    Card.Cards2XML("cards", res.Cards)
                                //    )
                                //);
                            }
                            foreach (ASkill s in res.Leader.Skills)
                            {
                                s.OnUseEffect(res.Leader, Card.Effect.Shan, gData);
                            }
                            if (GamePlayers[r.Source].Weapon != null)
                            {
                                EnableDamage = Weapon.TargetShan(GamePlayers[r.Source].Weapon.CardEffect, r.Source, r.Target, gData, r);
                            }
                        }
                        if (res.Effect == Card.Effect.None || EnableDamage)
                        {
                            break;
                        }
                    }
                    if (res == null || res.Effect == Card.Effect.None || EnableDamage)
                    {
                        sbyte cost = 1;
                        if (GamePlayers[r.Source].Weapon != null)
                        {
                            cost = Weapon.CalcDamage(GamePlayers[r.Source].Weapon.CardEffect, r.Source, r.Target, Card.Effect.Sha, cost, gData);
                        }
                        foreach (ASkill s in r.Source.Skills)
                        {
                            cost = s.CalcDamage(r.Source, r.Effect, cost, gData);
                        }
                        if (GamePlayers[r.Target].Armor != null && GamePlayers[r.Source].Weapon != null && Weapon.EnableTargetArmor(GamePlayers[r.Source].Weapon.CardEffect, r.Source, r.Target))
                        {
                            cost = Armor.CalcDamage(1, r.Cards, GamePlayers[r.Target].Armor.CardEffect);
                        }
                        DamageHealth(r.Target, cost, r.Source, r);
                    }
                }
            }
            return(r);
        }
示例#14
0
        /// <summary>
        /// 角色求救过程
        /// </summary>
        /// <param name="aChiefSource">伤害的来源,可以是null</param>
        /// <param name="aPreDefunct">求救武将</param>
        /// <param name="aRescuePoint">求救血量</param>
        /// <returns>返回true表示该角色求救失败,false表示求救成功</returns>
        private bool Cry4HelpProc(ChiefBase aChiefSource, ChiefBase aPreDefunct, sbyte aRescuePoint)
        {
            if (aPreDefunct == null || aRescuePoint < 1)
            {
                return(true);
            }
            ChiefBase start = aChiefSource != null ? aChiefSource : aPreDefunct;
            ChiefBase t     = start;
            string    msg   = null;

            do
            {
                MessageCore.AskForResult res = null;
                if (t == aPreDefunct)
                {
                    msg = new Beaver("askfor.cry4help.taoorjiu", t.ChiefName, aPreDefunct.ChiefName, aRescuePoint.ToString()).ToString();
                    //new XElement("askfor.cry4help.taoorjiu",
                    //    new XElement("target", t.ChiefName),
                    //    new XElement("target2", aPreDefunct.ChiefName),
                    //    new XElement("rescuepoint", aRescuePoint)
                    //);
                    res = AsynchronousCore.AskForCards(t, MessageCore.AskForEnum.AskForTaoOrJiu, new AskForWrapper(msg, this), gData);
                    AsynchronousCore.LeadingValid(t);
                }
                else
                {
                    msg = new Beaver("askfor.cry4help.tao", t.ChiefName, aPreDefunct.ChiefName, aRescuePoint.ToString()).ToString();
                    //new XElement("askfor.cry4help.tao",
                    //    new XElement("target", t.ChiefName),
                    //    new XElement("target2", aPreDefunct.ChiefName),
                    //    new XElement("rescuepoint", aRescuePoint)
                    //);
                    res = AsynchronousCore.AskForCards(t, MessageCore.AskForEnum.AskForTao, new AskForWrapper(msg, this), gData);
                    AsynchronousCore.LeadingValid(t);
                }
                ValidityResult(t, ref res);
                if (res.Effect != Card.Effect.None)
                {
                    if (res.Effect == Card.Effect.Tao)
                    {
                        AsynchronousCore.SendMessage(
                            new Beaver("tao", t.ChiefName, aChiefSource.ChiefName, res.SkillName, Card.Cards2Beaver("cards", res.Cards)).ToString());
                        //    new XElement("tao",
                        //        new XElement("from", t.ChiefName),
                        //        new XElement("to", aChiefSource.ChiefName),
                        //        new XElement("skill" , res.SkillName ),
                        //        Card.Cards2XML("cards", res.Cards)
                        //    )
                        //);
                    }
                    else if (res.Effect == Card.Effect.Jiu)
                    {
                        AsynchronousCore.SendMessage(new Beaver("jiu", t.ChiefName, res.SkillName, Card.Cards2Beaver("cards", res.Cards)).ToString());
                        //new XElement("jiu",
                        //    new XElement("from", t.ChiefName),
                        //    new XElement("skill", res.SkillName),
                        //    Card.Cards2XML("cards", res.Cards)
                        //)
                        //);
                    }
                    if (res.Effect == Card.Effect.Tao || res.Effect == Card.Effect.Jiu)
                    {
                        sbyte cost = 1;
                        foreach (ASkill s in aPreDefunct.Skills)
                        {
                            cost = s.CalcRescuePoint(aPreDefunct, res.Leader, res.Effect, cost, gData);
                        }
                        aRescuePoint -= cost;
                        if (res.PlayerLead)
                        {
                            DropCards(true, CardFrom.HandAndEquipage, res.SkillName, res.Cards, res.Effect, t, aPreDefunct, null);
                        }
                        if (aRescuePoint < 1)
                        {
                            break;
                        }
                        continue;
                    }
                }
                t = GamePlayers.NextChief(t);
            } while (!t.IsMe(start));
            --aRescuePoint;
            if (aRescuePoint < 0)
            {
                GamePlayers[aPreDefunct].Health = Math.Abs(aRescuePoint);
                AsynchronousCore.SendMessage(new Beaver("health", aPreDefunct.ChiefName, GamePlayers[aPreDefunct].MaxHealth.ToString(), GamePlayers[aPreDefunct].Health.ToString()).ToString());
                //new XElement("health",
                //    new XElement("target", aPreDefunct.ChiefName),
                //    new XElement("max", GamePlayers[aPreDefunct].MaxHealth),
                //    new XElement("current", GamePlayers[aPreDefunct].Health)
                //    ));
            }
            else
            {
                GamePlayers[aPreDefunct].Health = 0;
            }
            return(aRescuePoint < 0 ? false : true);
        }
示例#15
0
        /// <summary>
        /// 决斗的执行过程
        /// </summary>
        /// <param name="r">子事件起始节点</param>
        /// <returns></returns>
        internal EventRecoard JueDouProc(EventRecoard r)
        {
            string msg = null;

            if (r.Target2 != null)
            {
                r.Source = r.Target;
                r.Target = r.Target2;
            }
            //玩家双方都不能死亡
            if (!GamePlayers[r.Target].Dead && !GamePlayers[r.Source].Dead)
            {
                if (r.Target2 == null)
                {
                    //无懈可击的过程
                    if (WuXieProc(r.Target, Card.Effect.JueDou))
                    {
                        return(r);
                    }
                }
                while (true)
                {
                    int times = 1;
                    foreach (ASkill s in r.Source.Skills)
                    {
                        times = s.CalcAskforTimes(r.Source, r.Target, Card.Effect.JueDou, times, gData);
                    }
                    for (int i = 0; i < times; i++)
                    {
                        //先询问对方要出杀
                        MessageCore.AskForResult res = null;
                        msg = new Beaver("askfor.jd.sha", r.Target.ChiefName, r.Source.ChiefName).ToString();
                        //new XElement("askfor.jd.sha",
                        //new XElement("target", r.Target.ChiefName),
                        //new XElement("opponent", r.Source.ChiefName)
                        //);
                        res = AsynchronousCore.AskForCards(r.Target, MessageCore.AskForEnum.Sha, new AskForWrapper(msg, this), gData);
                        ValidityResult(r.Target, ref res);
                        if (res.Effect != Card.Effect.Sha)
                        {
                            //不出杀费血
                            sbyte cost = 1;
                            foreach (ASkill s in r.Source.Skills)
                            {
                                cost = s.CalcDamage(r.Source, Card.Effect.JueDou, cost, gData);
                            }
                            if (GamePlayers[r.Target].Armor != null)
                            {
                                cost = Armor.CalcDamage(cost, r.Cards, GamePlayers[r.Target].Armor.CardEffect);
                            }
                            DamageHealth(r.Target, cost, r.Source, r);
                            return(r);
                        }
                        else
                        {
                            //出杀加入子事件节点
                            if (res.PlayerLead)
                            {
                                DropCards(true, CardFrom.Hand, res.SkillName, res.Cards, Card.Effect.Sha, res.Leader, r.Source, null);
                            }
                            foreach (ASkill s in res.Leader.Skills)
                            {
                                s.OnUseEffect(res.Leader, Card.Effect.Sha, gData);
                            }
                            AsynchronousCore.SendMessage(
                                new Beaver("jd.sha", r.Target.ChiefName, r.Source.ChiefName, Card.Cards2Beaver("cards", res.Cards)).ToString());
                            //new XElement("jd.sha",
                            //    new XElement("target", r.Target.ChiefName),
                            //    new XElement("opponent", r.Source.ChiefName),
                            //    Card.Cards2XML("cards", res.Cards)
                            //));
                        }
                    }
                    times = 1;
                    foreach (ASkill s in r.Target.Skills)
                    {
                        times = s.CalcAskforTimes(r.Target, r.Source, Card.Effect.JueDou, times, gData);
                    }
                    for (int i = 0; i < times; i++)
                    {
                        msg = new Beaver("askfor.jd.sha", r.Source.ChiefName, r.Target.ChiefName).ToString();
                        //new XElement("askfor.jd.sha",
                        //new XElement("target", r.Source.ChiefName),
                        //new XElement("opponent", r.Target.ChiefName)
                        //);
                        //问询自己出杀
                        MessageCore.AskForResult res2 = AsynchronousCore.AskForCards(r.Source, MessageCore.AskForEnum.Sha, new AskForWrapper(msg, this), gData);
                        ValidityResult(r.Source, ref res2);
                        if (res2.Effect != Card.Effect.Sha)
                        {
                            //不出杀费血
                            sbyte cost = 1;
                            foreach (ASkill s in r.Target.Skills)
                            {
                                cost = s.CalcDamage(r.Target, r.Effect, cost, gData);
                            }
                            if (GamePlayers[r.Source].Armor != null)
                            {
                                cost = Armor.CalcDamage(cost, r.Cards, GamePlayers[r.Source].Armor.CardEffect);
                            }
                            DamageHealth(r.Source, cost, r.Target, r);
                            return(r);
                        }
                        else
                        {
                            //出杀加入子事件节点
                            if (res2.PlayerLead)
                            {
                                DropCards(true, CardFrom.Hand, res2.SkillName, res2.Cards, Card.Effect.Sha, res2.Leader, r.Target, null);
                            }
                            foreach (ASkill s in res2.Leader.Skills)
                            {
                                s.OnUseEffect(res2.Leader, Card.Effect.Sha, gData);
                            }
                            AsynchronousCore.SendMessage(
                                new Beaver("jd.sha", r.Source.ChiefName, r.Target.ChiefName, Card.Cards2Beaver("cards", res2.Cards)).ToString());
                            //new XElement("jd.sha",
                            //    new XElement("target", r.Source.ChiefName),
                            //    new XElement("opponent", r.Target.ChiefName),
                            //    Card.Cards2XML("cards", res2.Cards)
                            //));
                        }
                    }
                }
            }
            return(r);
        }