Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 游戏对象基类的构造函数
        /// </summary>
        /// <remarks></remarks>
        public GameBase()
        {
            //基类大部分的数据对象没有在构造函数中处理
            //这里给有关通信的部分做了引用
            CommService  = new ServiceController(); //初始化服务控制器
            WaittingData = new ThreadData(this);    //初始化问询线程的数据区域
            Response     = new ResponseData();      //初始化问询线程取的回应数据区域
            EventChain   = new List <string>();     //初始化游戏公共事件信息链
            //创建问询与消息对象
            AsynchronousCore = new MessageCore(this);
            GamePacks        = new GamePack[] { };
            Mode             = GameMode.FiveSTD;
            CardsHeap        = new CardHeap(this);  //初始化牌堆
            CardsBuffer      = new SlotContainer(); //创建一个用于公共信息的牌槽

            //复位游戏规则控制数据
            gData      = new GlobalData();
            gData.Game = this as GlobalEvent;

            //设置牌槽
            CardsBuffer.Slots.Add(new Slot(WGFDSlotName, true, true)); //五谷丰登牌槽
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 要求武将消耗体力值
        /// </summary>
        /// <param name="aChief">受伤害的武将</param>
        /// <param name="aDamage">伤害量</param>
        /// <param name="aSource">伤害来源,非玩家操作置null</param>
        /// <param name="aSourceEvent">伤害来源事件</param>
        internal void DamageHealth(ChiefBase aChief, sbyte aDamage, ChiefBase aSource, EventRecoard aSourceEvent)
        {
            if (GamePlayers[aChief].Health - aDamage < 1)
            {
                AsynchronousCore.SendMessage(
                    new Beaver("health", aChief.ChiefName, GamePlayers[aChief].MaxHealth.ToString(), "0").ToString());
                //new XElement("health",
                //new XElement("target", aChief.ChiefName),
                //new XElement("max", GamePlayers[aChief].MaxHealth),
                //new XElement("current", 0)
                //));

                if (Cry4HelpProc(aSource, aChief, (sbyte)Math.Abs(GamePlayers[aChief].Health - aDamage - 1)))
                {
                    //GamePlayers[aChief].Health = 0;
                    GamePlayers[aChief].Dead = true;
                    //drop all cards
                    List <Card> lstDrop = new List <Card>();
                    lstDrop.AddRange(GamePlayers[aChief].Hands);
                    lstDrop.AddRange(GamePlayers[aChief].Debuff);
                    if (GamePlayers[aChief].Weapon != null)
                    {
                        lstDrop.Add(GamePlayers[aChief].Weapon);
                    }
                    if (GamePlayers[aChief].Armor != null)
                    {
                        lstDrop.Add(GamePlayers[aChief].Armor);
                    }
                    if (GamePlayers[aChief].Jia1Ma != null)
                    {
                        lstDrop.Add(GamePlayers[aChief].Jia1Ma);
                    }
                    if (GamePlayers[aChief].Jian1Ma != null)
                    {
                        lstDrop.Add(GamePlayers[aChief].Jian1Ma);
                    }
                    AsynchronousCore.SendMessage(
                        new Beaver("fall", aChief.ChiefName, aChief.ChiefStatus).ToString());
                    //new XElement("fall",
                    //    new XElement("target", aChief.ChiefName),
                    //    new XElement("status", aChief.ChiefStatus)
                    //    )
                    //);
                    AsynchronousCore.SendMessage(MessageCore.MakeDropMessage(aChief, aChief, lstDrop.ToArray()));
                    DropCards(true, CardFrom.HandAndEquipageAndJudgement, string.Empty, lstDrop.ToArray(), Card.Effect.None, aChief, null, null);
                    RefereeProc();
                    if (aChief.ChiefStatus == ChiefBase.Status.Insurgent && aSource != null && !GamePlayers[aSource].Dead)
                    {
                        TakeingCards(aSource, 3);
                    }
                    return;
                }
            }
            else
            {
                AsynchronousCore.SendMessage(new Beaver("health", aChief.ChiefName, GamePlayers[aChief].MaxHealth.ToString(), (GamePlayers[aChief].Health - aDamage).ToString()).ToString());
                //new XElement("health",
                //new XElement("target", aChief.ChiefName),
                //new XElement("max", GamePlayers[aChief].MaxHealth),
                //new XElement("current", GamePlayers[aChief].Health - aDamage)
                //));
                GamePlayers[aChief].Health -= aDamage;
            }
            foreach (ASkill s in GamePlayers[aChief].Chief.Skills)
            {
                s.OnChiefHarmed(aSourceEvent, aSource, aChief, gData, aDamage);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 发送问询
 /// </summary>
 public void SendAskFor(MessageCore aCore)
 {
     aCore.SendMessage(Targets, Message, Common);
 }
Ejemplo n.º 7
0
 internal void SendPickMessage(ChiefBase aChief, Card[] aCards)
 {
     SendMessage(MessageCore.MakePickMessage(aChief, aCards));
 }