/// <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="aChief">执行过程的武将</param> /// <param name="aData">全局数据</param> private void Judgement(ChiefBase aChief, GlobalData aData) { //清除垃圾桶,事件队列 FreeCardBin(); queRecoard.Clear(); //Debuff栈退栈循环 while (GamePlayers[aChief].Debuff.Count != 0 && !GamePlayers[aChief].Dead) { //清除事件子队列 lstRecoard.Clear(); //取Debuff栈元素,退栈 Card buff = GamePlayers[aChief].Debuff.Pop(); //加入子事件队列 queRecoard.Enqueue(new EventRecoard(aChief, aChief, new Card[] { buff }, buff.CardEffect, string.Empty)); lstCardBin.Add(buff); //判断Debuff类型 switch (buff.CardEffect) { //兵粮寸断 case Card.Effect.BingLiangCunDuan: //无懈可击的过程 if (WuXieProc(aChief, Card.Effect.BingLiangCunDuan)) { continue; } //获取判定牌 Card judgementBLCD = popJudgementCard(aChief, buff.CardEffect); //对判定牌的处理 if (judgementBLCD.CardHuaSe != Card.Suit.CaoHua) { aData.Take = false; } else { aData.Take = true; } AsynchronousCore.SendMessage( new Beaver("removedebuff", aChief.ChiefName, Card.Cards2Beaver("cards", new Card[] { buff })).ToString()); //new XElement("removedebuff", // new XElement("target", aChief.ChiefName), // Card.Cards2XML("cards", new Card[] { buff }) //)); DropCards(true, CardFrom.JudgementCard, string.Empty, new Card[] { judgementBLCD }, Card.Effect.None, aChief, aChief, null); break; //乐不思蜀 case Card.Effect.LeBuSiShu: //无懈可击的过程 if (WuXieProc(aChief, Card.Effect.LeBuSiShu)) { continue; } //获取判定牌 Card judgementLBSS = popJudgementCard(aChief, buff.CardEffect); //对判定牌的处理 if (judgementLBSS.CardHuaSe != Card.Suit.HongTao) { aData.Lead = false; } else { aData.Lead = true; } AsynchronousCore.SendMessage( new Beaver("removedebuff", aChief.ChiefName, Card.Cards2Beaver("cards", new Card[] { buff })).ToString()); //new XElement("removedebuff", // new XElement("target", aChief.ChiefName), // Card.Cards2XML("cards", new Card[] { buff }) //)); DropCards(true, CardFrom.JudgementCard, string.Empty, new Card[] { judgementLBSS }, Card.Effect.None, aChief, aChief, null); break; //闪电 case Card.Effect.ShanDian: //无懈可击的过程 if (WuXieProc(aChief, Card.Effect.ShanDian)) { //没有费血,把debuff牌从垃圾桶里拣出来 PickRubbish(new Card[] { buff }); //闪电需要挂到下一位武将的判定区,如果下一位的判定区有闪电,那就是再下一位...直到处理到该玩家为之 ChiefBase next = GamePlayers.NextChief(aChief); //指示闪电是否安置好了 bool handle = false; if (next != aChief) { do { //如果这个武将没有闪电,那就把闪电放到他的debuff中 if (!GamePlayers[next].HasDebuff(Card.Effect.ShanDian)) { GamePlayers[next].Debuff.Push(buff); AsynchronousCore.SendMessage( new Beaver("sd.moved", aChief.ChiefName, next.ChiefName, Card.Cards2Beaver("cards", new Card[] { buff })).ToString()); //new XElement("sd.moved", // new XElement("from", aChief.ChiefName), // new XElement("to", next.ChiefName), // Card.Cards2XML("cards", new Card[] { buff }) //)); //闪电已安置 handle = true; break; } } while (aChief != (next = GamePlayers.NextChief(next))); } //如果闪电没有安置,那就挂到玩家的新debuff栈中 if (!handle) { gData.stkNewBuff.Push(buff.GetOriginalCard()); } continue; } //取出判定牌 Card judgementSD = popJudgementCard(aChief, buff.CardEffect); //费血 if (judgementSD.CardHuaSe == Card.Suit.HeiTao && judgementSD.CardNumber > 1 && judgementSD.CardNumber < 10) { AsynchronousCore.SendMessage( new Beaver("removedebuff", aChief.ChiefName, Card.Cards2Beaver("cards", new Card[] { buff })).ToString() //new XElement("removedebuff", // new XElement("target", aChief.ChiefName), // Card.Cards2XML("cards", new Card[] { buff })) ); if (GamePlayers[aChief].Armor != null) { DamageHealth(aChief, Armor.CalcDamage(3, new Card[] { buff }, GamePlayers[aChief].Armor.CardEffect), null, new EventRecoard(null, aChief, null, new Card[] { buff }, Card.Effect.ShanDian, string.Empty)); } else { DamageHealth(aChief, 3, null, new EventRecoard(null, aChief, null, new Card[] { buff }, Card.Effect.ShanDian, string.Empty)); } } else { //没有费血,把debuff牌从垃圾桶里拣出来 PickRubbish(new Card[] { buff }); //闪电需要挂到下一位武将的判定区,如果下一位的判定区有闪电,那就是再下一位...直到处理到该玩家为之 ChiefBase next = GamePlayers.NextChief(aChief); //指示闪电是否安置好了 bool handle = false; if (next != aChief) { do { //如果这个武将没有闪电,那就把闪电放到他的debuff中 if (!GamePlayers[next].HasDebuff(Card.Effect.ShanDian)) { GamePlayers[next].Debuff.Push(buff); AsynchronousCore.SendMessage( new Beaver("sd.moved", aChief.ChiefName, next.ChiefName, Card.Cards2Beaver("cards", new Card[] { buff })).ToString() //new XElement("sd.moved", // new XElement("from", aChief.ChiefName), // new XElement("to", next.ChiefName), // Card.Cards2XML("cards", new Card[] { buff })) ); //闪电已安置 handle = true; break; } } while (aChief != (next = GamePlayers.NextChief(next))); } //如果闪电没有安置,那就挂到玩家的新debuff栈中 if (!handle) { gData.stkNewBuff.Push(buff.GetOriginalCard()); } } //判定牌加入子事件节点 DropCards(true, CardFrom.JudgementCard, string.Empty, new Card[] { judgementSD }, Card.Effect.None, aChief, aChief, null); break; } //清除子事件 lstRecoard.Clear(); } //设置玩家的debuff栈 GamePlayers[aChief].Debuff = gData.stkNewBuff; //清除事件记录 FreeCardBin(); queRecoard.Clear(); lstRecoard.Clear(); }
/// <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); }