/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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=下一个玩家 //----------------------------------------------------------- //如果玩家都死光了...没分胜负,我想这里会有异常吧 }
/// <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); }
/// <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); }
/// <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); }