/// <summary> /// 清除事件链的过程 /// </summary> /// <remarks>该方法是将公共牌槽,武将可回收牌槽等剩余的牌放入垃圾桶中,并将发送事件结束的XML消息 /// 清除事件链发生在每个游戏阶段的起始事件完成后</remarks> private void ClearEventProc() { //尝试回收游戏对象中牌槽容器的牌 foreach (Slot s in CardsBuffer.Slots) { if (s.Recyclable && s.Cards.Count != 0) { DropCards(true, CardFrom.Slot, string.Empty, s.Cards.ToArray(), Card.Effect.None, null, null, null); s.Cards.Clear(); } } //尝试回收玩家牌槽容器中的牌 foreach (Player p in GamePlayers.All) { if (p.Chief != null) { foreach (Slot s in p.Chief.SlotsBuffer.Slots) { if (s.Recyclable && s.Cards.Count != 0) { DropCards(true, CardFrom.Slot, string.Empty, s.Cards.ToArray(), Card.Effect.None, null, null, null); s.Cards.Clear(); } } } } //发送事件结束消息 AsynchronousCore.SendClearMessage(); }
/// <summary> /// 开始玩家的选将过程,要求玩家数量必须等于游戏模式中指定的数量 /// </summary> /// <returns>若该过程无误,则返回true</returns> public bool SelectChiefs() { if (GamePlayers.All.Count() < 2) { return(false); } foreach (Player p in GamePlayers.All) { p.Chief = null; p.AvailableChiefs = new ChiefBase[0] { }; } //发送游戏环境数据给所有玩家 AsynchronousCore.SendEnvironmentMessage(); int m = 0; int l1 = 0; int l2 = 0; int i1 = 0; int i2 = 0; int i3 = 0; int i4 = 0; int s1 = 0; int s2 = 0; //获取场上玩家数量 int max = GamePlayers.All.Count(); //重置牌堆 CardsHeap = new CardHeap(this); //一个用来放置可选武将的列表 List <ChiefBase> heap = new List <ChiefBase>(); //根据模式设置牌堆里面的牌 switch (Mode) { case GameMode.FiveJunZheng: case GameMode.EightJunZheng: CardsHeap.FillOriginCards(); CardsHeap.FillExCards(); CardsHeap.FillShenCards(); break; case GameMode.FiveSTD: case GameMode.EightSTD: CardsHeap.FillOriginCards(); CardsHeap.FillExCards(); break; } //根据扩展包情况加入武将 heap = ChiefHeap.GetOriginChiefs(); //主公可选武将列表 List <ChiefBase> mLst = new List <ChiefBase>(); mLst.AddRange(heap.Where(c => c.ChiefName == "刘备" || c.ChiefName == "孙权" || c.ChiefName == "曹操")); if (GamePacks.Contains(GamePack.Feng)) { heap.AddRange(ChiefHeap.GetFengPackChiefs()); mLst.AddRange(heap.Where(c => c.ChiefName == "张角")); } if (GamePacks.Contains(GamePack.Huo)) { heap.AddRange(ChiefHeap.GetHuoPackChiefs()); mLst.AddRange(heap.Where(c => c.ChiefName == "袁绍")); } if (GamePacks.Contains(GamePack.Lin)) { heap.AddRange(ChiefHeap.GetLinPackChiefs()); mLst.AddRange(heap.Where(c => c.ChiefName == "董卓")); } //乱序可选武将 heap = ShuffleList <ChiefBase>(heap); //将非主公武将从heap中找到放置到heap2 ChiefBase[] heap2 = heap.Where(c => c.ChiefName != "刘备" && c.ChiefName != "孙权" && c.ChiefName != "曹操" && c.ChiefName != "张角" && c.ChiefName != "袁绍" && c.ChiefName != "董卓").ToArray(); //加入两个非主公武将到主公可选武将列表中 mLst.Add(heap2[0]); mLst.Add(heap2[1]); //把主公可选武将写成XML格式 Beaver r = null; foreach (ChiefBase c in mLst) { if (r == null) { r = new Beaver("chiefs", c.ChiefName); } else { r.Add(string.Empty, c.ChiefName); } } if (r == null) { r = new Beaver("chiefs"); } //表决字典 Dictionary <Player, bool> Abstention = new Dictionary <Player, bool>(); //这个列表用来产生身份序列 List <int> l = null; //按照人数开始配置角色 switch (Mode) { case GameMode.FiveSTD: case GameMode.FiveJunZheng: //五人场人数必须为5 if (GamePlayers.All.Count() != 5) { return(false); } l = new List <int>(new int[] { 0, 1, 2, 3, 4 }); l = ShuffleList <int>(l); m = l[0]; //主 l1 = l[1]; //忠 s1 = l[2]; //内 i1 = l[3]; //反 i2 = l[4]; //反 //给所有玩家群发主公是谁 AsynchronousCore.SendMessage(new Player[] { GamePlayers[m] }, new Beaver("ChiefStatus", ChiefBase.Status.Majesty.ToString(), GamePlayers[m].UID).ToString(), true); //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Majesty), // new XElement("UID", GamePlayers[m].UID) // ), true); //给其他角色发送自己身份是什么 AsynchronousCore.SendMessage(new Player[] { GamePlayers[l1] }, new Beaver("ChiefStatus", ChiefBase.Status.Loyalist.ToString(), GamePlayers[l1].UID).ToString(), false); //new Player[] { GamePlayers[l1] }, //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Loyalist), // new XElement("UID", GamePlayers[l1].UID) // ), false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[s1] }, new Beaver("ChiefStatus", ChiefBase.Status.Spy.ToString(), GamePlayers[s1].UID).ToString(), false); //new Player[] { GamePlayers[s1] }, //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Spy), // new XElement("UID", GamePlayers[s1].UID) // ), false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[i1] }, new Beaver("ChiefStatus", ChiefBase.Status.Insurgent.ToString(), GamePlayers[i1].UID).ToString(), false); //new Player[] { GamePlayers[i1] }, //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Insurgent), // new XElement("UID", GamePlayers[i1].UID) // ), false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[i2] }, new Beaver("ChiefStatus", ChiefBase.Status.Insurgent.ToString(), GamePlayers[i2].UID).ToString(), false); //new Player[] { GamePlayers[i2] }, //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Insurgent), // new XElement("UID", GamePlayers[i2].UID) // ), false); //设置主公可选武将列表 GamePlayers[m].AvailableChiefs = mLst.ToArray(); //通知主公选武将 AsynchronousCore.SendMessage( new Player[] { GamePlayers[m] }, new Beaver("askfor.selectchief", GamePlayers[m].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[m].UID), // r) , false); //通知其他玩家主公正在选武将 AsynchronousCore.SendMessage( GamePlayers.All.Where(c => c.UID != GamePlayers[m].UID).ToArray(), new Beaver("askfor.selectchief", GamePlayers[m].UID).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[m].UID)) , true); //设置表决字典,除了主公玩家置false,其他玩家置true foreach (Player p in GamePlayers.All) { if (GamePlayers[m] == p && !p.IsEscaped && !p.IsOffline) { Abstention.Add(p, false); } else { Abstention.Add(p, true); } } //等待问询结果 AsynchronousCore.AskForChief(Abstention); //主公没选择武将的话,随机配置一个 if (GamePlayers[m].Chief == null) { GamePlayers[m].Chief = mLst[GetRandom(mLst.Count)]; } //设置主公的一些属性 GamePlayers[m].Chief.ChiefStatus = ChiefBase.Status.Majesty; GamePlayers[m].Chief.playersObject = GamePlayers; GamePlayers[m].MaxHealth = GamePlayers[m].Chief.Health; GamePlayers[m].MaxHealth++; GamePlayers[m].Health = GamePlayers[m].MaxHealth; //通知玩家主公选择了谁 AsynchronousCore.SendMessage( new Beaver("selectchief", GamePlayers[m].UID, GamePlayers[m].Chief.ChiefName, GamePlayers[m].MaxHealth.ToString()).ToString()); //new XElement("selectchief", // new XElement("UID", GamePlayers[m].UID), // new XElement("chief_name", GamePlayers[m].Chief.ChiefName), // new XElement("max_health", GamePlayers[m].MaxHealth) // ) //); //heap中去除掉主公选择的武将并重新乱序排列 heap = ShuffleList <ChiefBase>(heap.Where(c => c != GamePlayers[m].Chief).ToList()); //其他玩家每人抽三个武将到自己的可选武将中 GamePlayers[l1].AvailableChiefs = heap.GetRange(0, 3).ToArray(); GamePlayers[s1].AvailableChiefs = heap.GetRange(3, 3).ToArray(); GamePlayers[i1].AvailableChiefs = heap.GetRange(6, 3).ToArray(); GamePlayers[i2].AvailableChiefs = heap.GetRange(9, 3).ToArray(); //重新设置表决字典,除了主公,其他人都置false Abstention = new Dictionary <Player, bool>(); foreach (Player p in GamePlayers.All) { if (GamePlayers[m] == p) { Abstention.Add(p, true); } else { Abstention.Add(p, false); } } //通知非主公玩家去选自己的武将 r = Chiefs2Beaver(l1); AsynchronousCore.SendMessage( new Player[] { GamePlayers[l1] }, new Beaver("askfor.selectchief", GamePlayers[l1].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[l1].UID), // r) , false); r = Chiefs2Beaver(s1); AsynchronousCore.SendMessage( new Player[] { GamePlayers[s1] }, new Beaver("askfor.selectchief", GamePlayers[s1].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[s1].UID), // new XElement("chiefs", // new XElement("chief", GamePlayers[s1].AvailableChiefs[0].ChiefName), // new XElement("chief", GamePlayers[s1].AvailableChiefs[1].ChiefName), // new XElement("chief", GamePlayers[s1].AvailableChiefs[2].ChiefName) // )) , false); r = Chiefs2Beaver(i1); AsynchronousCore.SendMessage( new Player[] { GamePlayers[i1] }, new Beaver("askfor.selectchief", GamePlayers[i1].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[i1].UID), // new XElement("chiefs", // new XElement("chief", GamePlayers[i1].AvailableChiefs[0].ChiefName), // new XElement("chief", GamePlayers[i1].AvailableChiefs[1].ChiefName), // new XElement("chief", GamePlayers[i1].AvailableChiefs[2].ChiefName) // )) , false); r = Chiefs2Beaver(i2); AsynchronousCore.SendMessage( new Player[] { GamePlayers[i2] }, new Beaver("askfor.selectchief", GamePlayers[i2].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[i2].UID), // new XElement("chiefs", // new XElement("chief", GamePlayers[i2].AvailableChiefs[0].ChiefName), // new XElement("chief", GamePlayers[i2].AvailableChiefs[1].ChiefName), // new XElement("chief", GamePlayers[i2].AvailableChiefs[2].ChiefName) // )) , false); //问询玩家选择武将 AsynchronousCore.AskForChief(Abstention); //针对非主公玩家配置数据 foreach (Player p in GamePlayers.All) { p.Score = 0; if (GamePlayers[m] == p) { continue; } if (p.Chief == null) { //没选武将随机配置一个 p.Chief = p.AvailableChiefs[GetRandom(p.AvailableChiefs.Count())]; } p.Chief.playersObject = GamePlayers; p.MaxHealth = p.Chief.Health; p.Health = p.MaxHealth; //通知所有玩家该玩家选择的武将 AsynchronousCore.SendMessage( new Beaver("selectchief", p.UID, p.Chief.ChiefName, p.MaxHealth).ToString() //new XElement("selectchief", // new XElement("UID", p.UID), // new XElement("chief_name", p.Chief.ChiefName), // new XElement("max_health", p.MaxHealth) // ) ); } ////开始分配武将的技能 //foreach (Player p in GamePlayers.All) //{ // //再发送出去 // p.Chief.ReportSkills(gData); //} //设置非主公武将的身份 GamePlayers[l1].Chief.ChiefStatus = Data.ChiefBase.Status.Loyalist; GamePlayers[s1].Chief.ChiefStatus = Data.ChiefBase.Status.Spy; GamePlayers[i1].Chief.ChiefStatus = Data.ChiefBase.Status.Insurgent; GamePlayers[i2].Chief.ChiefStatus = Data.ChiefBase.Status.Insurgent; //事件结束 AsynchronousCore.SendClearMessage(); return(true); case GameMode.EightSTD: case GameMode.EightJunZheng: //玩家人数不为8则不能执行 if (GamePlayers.All.Count() != 8) { return(false); } l = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); l = ShuffleList <int>(l); m = l[0]; //主 l1 = l[1]; //忠 l2 = l[2]; //忠 s1 = l[3]; //内 i1 = l[4]; //反 i2 = l[5]; //反 i3 = l[6]; //反 i4 = l[7]; //反 //给所有玩家通知主公是谁 AsynchronousCore.SendMessage( new Beaver("ChiefStatus", ChiefBase.Status.Majesty.ToString(), GamePlayers[m].UID).ToString()); //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Majesty), // new XElement("UID", GamePlayers[m].UID) // )); //其他玩家自己收到自己的身份 AsynchronousCore.SendMessage(new Player[] { GamePlayers[l1] }, new Beaver("ChiefStatus", ChiefBase.Status.Loyalist.ToString(), GamePlayers[l1].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Loyalist), // new XElement("UID", GamePlayers[l1].UID)) , false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[l2] }, new Beaver("ChiefStatus", ChiefBase.Status.Loyalist.ToString(), GamePlayers[l2].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Loyalist), // new XElement("UID", GamePlayers[l2].UID)) , false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[s1] }, new Beaver("ChiefStatus", ChiefBase.Status.Spy.ToString(), GamePlayers[s1].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Spy), // new XElement("UID", GamePlayers[s1].UID)) , false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[i1] }, new Beaver("ChiefStatus", ChiefBase.Status.Insurgent.ToString(), GamePlayers[i1].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Insurgent), // new XElement("UID", GamePlayers[i1].UID)) , false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[i2] }, new Beaver("ChiefStatus", ChiefBase.Status.Insurgent.ToString(), GamePlayers[i2].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Insurgent), // new XElement("UID", GamePlayers[i2].UID)) , false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[i3] }, new Beaver("ChiefStatus", ChiefBase.Status.Insurgent.ToString(), GamePlayers[i3].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Insurgent), // new XElement("UID", GamePlayers[i3].UID)) , false); AsynchronousCore.SendMessage(new Player[] { GamePlayers[i4] }, new Beaver("ChiefStatus", ChiefBase.Status.Insurgent.ToString(), GamePlayers[i4].UID).ToString() //new XElement("ChiefStatus", // new XElement("Status", ChiefBase.Status.Insurgent), // new XElement("UID", GamePlayers[i4].UID)) , false); //设置主公可选的武将列表 GamePlayers[m].AvailableChiefs = mLst.ToArray(); //给主公私下发送的选将事件 AsynchronousCore.SendMessage( new Player[] { GamePlayers[m] }, new Beaver("askfor.selectchief", GamePlayers[m].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[m].UID), // r) , false); //给所有非主公玩家通知主公在选将 AsynchronousCore.SendMessage( GamePlayers.All.Where(c => c.UID != GamePlayers[m].UID).ToArray(), new Beaver("askfor.selectchief", GamePlayers[m].UID).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[m].UID)) , true); //设置表决字典,让主公玩家未表决 Abstention = new Dictionary <Player, bool>(); foreach (Player p in GamePlayers.All) { if (GamePlayers[m] == p) { Abstention.Add(p, false); } else { Abstention.Add(p, true); } } //开始问询 AsynchronousCore.AskForChief(Abstention); //没有选将设置随机选择武将 if (GamePlayers[m].Chief == null) { GamePlayers[m].Chief = mLst[GetRandom(mLst.Count)]; } //设置主公玩家的一些属性 GamePlayers[m].Chief.ChiefStatus = ChiefBase.Status.Majesty; GamePlayers[m].Chief.playersObject = GamePlayers; GamePlayers[m].MaxHealth = GamePlayers[m].Chief.Health; GamePlayers[m].MaxHealth++; GamePlayers[m].Health = GamePlayers[m].MaxHealth; //通知玩家主公选择了什么以及血量 AsynchronousCore.SendMessage( new Beaver("selectchief", GamePlayers[m].UID, GamePlayers[m].Chief.ChiefName, GamePlayers[m].MaxHealth.ToString()).ToString()); //new XElement("selectchief", // new XElement("UID", GamePlayers[m].UID), // new XElement("chief_name", GamePlayers[m].Chief.ChiefName), // new XElement("max_health", GamePlayers[m].MaxHealth) // ) //); //武将堆排除掉主公选择的武将之后重新排序 heap = ShuffleList <ChiefBase>(heap.Where(c => c != GamePlayers[m].Chief).ToList()); //其他玩家从heap抽3个武将作为可选武将 GamePlayers[l1].AvailableChiefs = heap.GetRange(0, 3).ToArray(); GamePlayers[l2].AvailableChiefs = heap.GetRange(3, 3).ToArray(); GamePlayers[s1].AvailableChiefs = heap.GetRange(6, 3).ToArray(); GamePlayers[i1].AvailableChiefs = heap.GetRange(9, 3).ToArray(); GamePlayers[i2].AvailableChiefs = heap.GetRange(12, 3).ToArray(); GamePlayers[i3].AvailableChiefs = heap.GetRange(15, 3).ToArray(); GamePlayers[i4].AvailableChiefs = heap.GetRange(18, 3).ToArray(); //设置表决字典,让非主公玩家选将 Abstention = new Dictionary <Player, bool>(); foreach (Player p in GamePlayers.All) { if (GamePlayers[m] == p) { Abstention.Add(p, true); } else { Abstention.Add(p, false); } } AsynchronousCore.SendMessage( new Beaver("askfor.selectchief").ToString()); //new XElement("askfor.selectchief") //); r = Chiefs2Beaver(l1); AsynchronousCore.SendMessage( new Player[] { GamePlayers[l1] }, new Beaver("askfor.selectchief", GamePlayers[l1].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[l1].UID), // r) , false); r = Chiefs2Beaver(l2); AsynchronousCore.SendMessage( new Player[] { GamePlayers[l2] }, new Beaver("askfor.selectchief", GamePlayers[l2].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[l2].UID), // r) , false); r = Chiefs2Beaver(s1); AsynchronousCore.SendMessage( new Player[] { GamePlayers[s1] }, new Beaver("askfor.selectchief", GamePlayers[s1].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[s1].UID), // r) , false); r = Chiefs2Beaver(i1); AsynchronousCore.SendMessage( new Player[] { GamePlayers[i1] }, new Beaver("askfor.selectchief", GamePlayers[i1].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[i1].UID), // r) , false); r = Chiefs2Beaver(i2); AsynchronousCore.SendMessage( new Player[] { GamePlayers[i2] }, new Beaver("askfor.selectchief", GamePlayers[i2].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[i2].UID), // r) , false); r = Chiefs2Beaver(i3); AsynchronousCore.SendMessage( new Player[] { GamePlayers[i3] }, new Beaver("askfor.selectchief", GamePlayers[i3].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[i3].UID), // r) , false); r = Chiefs2Beaver(i4); AsynchronousCore.SendMessage( new Player[] { GamePlayers[i4] }, new Beaver("askfor.selectchief", GamePlayers[i4].UID, r).ToString() //new XElement("askfor.selectchief", // new XElement("UID", GamePlayers[i4].UID), // r) , false); AsynchronousCore.AskForChief(Abstention); foreach (Player p in GamePlayers.All) { p.Score = 0; if (GamePlayers[m] == p) { continue; } if (p.Chief == null) { p.Chief = p.AvailableChiefs[GetRandom(p.AvailableChiefs.Count())]; } p.Chief.playersObject = GamePlayers; p.MaxHealth = p.Chief.Health; p.Health = p.MaxHealth; p.Dead = false; AsynchronousCore.SendMessage( new Beaver("selectchief", p.UID, p.Chief.ChiefName, p.MaxHealth.ToString()).ToString()); //new XElement("selectchief", // new XElement("UID", p.UID), // new XElement("chief_name", p.Chief.ChiefName), // new XElement("max_health", p.MaxHealth) // ) //); } ////开始分配武将的技能 //foreach (Player p in GamePlayers.All) //{ // //再发送出去 // p.Chief.ReportSkills(gData); //} GamePlayers[l1].Chief.ChiefStatus = Data.ChiefBase.Status.Loyalist; GamePlayers[l2].Chief.ChiefStatus = ChiefBase.Status.Loyalist; GamePlayers[s1].Chief.ChiefStatus = Data.ChiefBase.Status.Spy; GamePlayers[i1].Chief.ChiefStatus = Data.ChiefBase.Status.Insurgent; GamePlayers[i2].Chief.ChiefStatus = Data.ChiefBase.Status.Insurgent; GamePlayers[i3].Chief.ChiefStatus = Data.ChiefBase.Status.Insurgent; GamePlayers[i4].Chief.ChiefStatus = Data.ChiefBase.Status.Insurgent; AsynchronousCore.SendClearMessage(); return(true); } return(false); }
/// <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=下一个玩家 //----------------------------------------------------------- //如果玩家都死光了...没分胜负,我想这里会有异常吧 }