public IActionOutputParameter Action(ActionParameter actionParameter) { BaseServant servant = actionParameter.PrimaryCard as BaseServant; GameContext gameContext = actionParameter.GameContext; BaseBiology attackCard = actionParameter.SecondaryCard as BaseBiology; int deskIndex = actionParameter.DeskIndex; var user = gameContext.GetUserContextByMyCard(servant); gameContext.CastCardCount++; servant.CastIndex = gameContext.CastCardCount; servant.CardLocation = CardLocation.场上; servant.DeskIndex = deskIndex; servant.CanAttack = true; gameContext.DeskCards[deskIndex] = servant; if (servant.HasCharge) { new ResetServantRemainAttackTimes().Action(actionParameter); } gameContext.EventQueue.AddLast(new ServantInDeskEvent() { EventCard = servant, Parameter = actionParameter }); gameContext.EventQueue.AddLast(new MyServantCastedEvent() { EventCard = servant, Parameter = actionParameter }); gameContext.EventQueue.AddLast(new PrimaryPlayerPlayCardEvent() { EventCard = servant, Parameter = actionParameter }); return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { BaseServant servant = actionParameter.PrimaryCard as BaseServant; GameContext gameContext = actionParameter.GameContext; BaseBiology attackCard = actionParameter.SecondaryCard as BaseBiology; int trueDamege = actionParameter.DamageOrHeal; ActionParameter actionPara = new ActionParameter() { PrimaryCard = attackCard, GameContext = actionParameter.GameContext, DamageOrHeal = trueDamege, SecondaryCard = servant }; CardActionFactory.CreateAction(attackCard, ActionType.受到攻击).Action(actionPara); //自己挨打(如果攻击的是英雄,则不掉血) if (attackCard.CardType == CardType.随从) { ServantUnderAttackAction underAttackAction = new ServantUnderAttackAction(); var underAttackPara = new ActionParameter() { GameContext = gameContext, PrimaryCard = servant, SecondaryCard = attackCard, DamageOrHeal = attackCard.Damage, }; underAttackAction.Action(underAttackPara); } servant.RemainAttackTimes -= 1; servant.CanAttack = servant.RemainAttackTimes > 0 ? true : false; return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { BaseServant servant = actionParameter.PrimaryCard as BaseServant; GameContext gameContext = actionParameter.GameContext; BaseBiology attackCard = actionParameter.SecondaryCard as BaseBiology; int damege = actionParameter.DamageOrHeal; int trueDamege = attackCard.Damage; if (attackCard.CardType == CardType.英雄) { BaseHero attackHero = attackCard as BaseHero; if (attackHero.Equip != null) { trueDamege += attackHero.Equip.Damage; } } ActionParameter underAttackPara = new ActionParameter() { PrimaryCard = servant, GameContext = actionParameter.GameContext, DamageOrHeal = trueDamege, SecondaryCard = attackCard }; CardActionFactory.CreateAction(servant, ActionType.受到伤害).Action(underAttackPara); return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { TAG tag = Activator.CreateInstance <TAG>(); foreach (Card card in actionParameter.GameContext.AllCard.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex)) { BaseBiology baseBiology = card as BaseBiology; baseBiology.IsDeathing = true; } return(null); }
public void SetCardInDesk(BaseBiology biology, int?deskIndex = null) { var userContext = gameContext.GetUserContextByMyCard(biology); if (deskIndex.HasValue == false) { deskIndex = userContext.IsFirst ? 4 : 12; } deskIndex = gameContext.AutoShiftServant(gameContext.ShiftServant(deskIndex.Value)); biology.CardLocation = CardLocation.场上; biology.DeskIndex = deskIndex.Value; gameContext.DeskCards[deskIndex.Value] = biology; }
public IActionOutputParameter Action(ActionParameter actionParameter) { TAG tag = Activator.CreateInstance <TAG>(); foreach (var card in actionParameter.GameContext.DeskCards.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex)) { BaseBiology biology = card as BaseBiology; biology.IsDeathing = true; ActionParameter para = new ActionParameter { PrimaryCard = biology, GameContext = actionParameter.GameContext }; CardActionFactory.CreateAction(biology, ActionType.死亡).Action(para); } return(null); }
/// <summary> /// 打出一张法术牌 /// </summary> /// <param name="gameCode"></param> /// <param name="userCode"></param> /// <param name="cardInGameCode"></param> /// <param name="target"></param> /// <returns></returns> public APIResultBase CastSpell(string gameCode, string userCode, string cardInGameCode, int target) { string res = JsonStringResult.VerifyFail(); Controler_Base ctl = Validate(gameCode, userCode); if (ctl == null) { return(JsonModelResult.PackageFail(OperateResCodeEnum.查询不到需要的数据)); } if (VictoryValidate(ctl.GameContext)) { return(JsonModelResult.PackageFail(OperateResCodeEnum.游戏已经结束)); } var player = ctl.GameContext.GetActivationUserContext(); if (player == null || player.UserCode != userCode) { return(JsonModelResult.PackageFail(OperateResCodeEnum.查询不到需要的数据)); } if (player.HandCards.Any(c => c.CardInGameCode == cardInGameCode) == false) { return(JsonModelResult.PackageFail(OperateResCodeEnum.查询不到需要的数据)); } Card card = player.HandCards.First(c => c.CardInGameCode == cardInGameCode); if (player.Power < card.Cost) { return(JsonModelResult.PackageFail(OperateResCodeEnum.没有足够的法力值)); } if (card.CastCardPrecondition == CastCardPrecondition.健康 && target > -1) { BaseBiology biology = ctl.GameContext.DeskCards[target]; if (biology.Life != biology.BuffLife) { return(JsonModelResult.PackageFail(OperateResCodeEnum.错误的目标)); } } if (card.CastCardPrecondition == CastCardPrecondition.装备有武器 && ctl.GameContext.GetHeroByActivation().Equip == null) { return(JsonModelResult.PackageFail(OperateResCodeEnum.你无法施放这个技能)); } ctl.CastSpell((BaseSpell)card, target); return(JsonModelResult.PackageSuccess(_gameCache.GetContext(ctl.GameContext.GameCode).Output())); }
public Func <Card, bool> Filter(ActionParameter actionParameter) { BaseBiology baseBiology = (BaseBiology)actionParameter.PrimaryCard; string leftCardCode = "", rightCardCode = ""; int left = baseBiology.DeskIndex - 1; int right = baseBiology.DeskIndex + 1; if ((baseBiology.DeskIndex > 1 && baseBiology.DeskIndex < 8) || (baseBiology.DeskIndex > 9 && baseBiology.DeskIndex < 16) && actionParameter.GameContext.DeskCards[left] != null) { leftCardCode = actionParameter.GameContext.DeskCards[left].CardInGameCode; } if ((baseBiology.DeskIndex > 0 && baseBiology.DeskIndex < 7) || (baseBiology.DeskIndex > 8 && baseBiology.DeskIndex < 15) && actionParameter.GameContext.DeskCards[right] != null) { rightCardCode = actionParameter.GameContext.DeskCards[right].CardInGameCode; } return(new Func <Card, bool>(c => c != null && c.CardType == CardType.随从 && (c.CardInGameCode == leftCardCode || c.CardInGameCode == rightCardCode))); }
public IActionOutputParameter Action(ActionParameter actionParameter) { UC uc = GameActivator <UC> .CreateInstance(); var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter)); var filter = Activator.CreateInstance <F>(); CardLocation cardLocation = GameActivator <CardLocation> .CreateInstance(); int num = GameActivator <NUM> .CreateInstance().GetNumber(actionParameter); foreach (UserContext user in users) { foreach (Card card in user.AllCards.Where(c => c.CardType == CardType.英雄 || c.CardType == CardType.随从).Where(x => cardLocation.Filter(x)).Where(filter.Filter(actionParameter))) { BaseBiology baseBiology = card as BaseBiology; baseBiology.Life = num; baseBiology.BuffLife = num; } } return(null); }
private void DisableCardAbility(BaseBiology bio, GameContext gameContext) { bio.CardAbility = null; if (bio.Buffs.Any()) { foreach (var ability in bio.Buffs) { var para = new ActionParameter() { GameContext = gameContext, PrimaryCard = bio, }; ability.Action(para); } } bio.Damage = bio.Damage < bio.InitialDamage ? bio.Damage : bio.InitialDamage; bio.Cost = bio.Cost < bio.InitialCost ? bio.Cost : bio.InitialCost; bio.Life = bio.Life < bio.InitialLife ? bio.Life : bio.InitialLife; bio.BuffLife = bio.InitialLife; bio.Buffs.Clear(); }
public IActionOutputParameter Action(ActionParameter actionParameter) { int returnCount = actionParameter.ReturnCount; UserContext uc = actionParameter.UserContext; GameContext gameContext = actionParameter.GameContext; for (int i = 1; i <= returnCount; i++) { if (uc.HandCards.Count() < 10) { //如果手牌没满则放入手牌中 actionParameter.PrimaryCard.CardLocation = CardLocation.手牌; gameContext.DeskCards[gameContext.DeskCards.FindIndex(c => c != null && c.CardInGameCode == actionParameter.PrimaryCard.CardInGameCode)] = null; } else { //否则标记这张牌为死亡 BaseBiology biology = actionParameter.PrimaryCard as BaseBiology; biology.IsDeathing = true; } } return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { ActionParameter para = actionParameter as ActionParameter; BaseHero baseHero = para.PrimaryCard as BaseHero; GameContext gameContext = para.GameContext; BaseBiology targetCard = para.SecondaryCard as BaseBiology; ActionParameter uaPara = new ActionParameter { PrimaryCard = targetCard, GameContext = actionParameter.GameContext, SecondaryCard = baseHero }; if (baseHero.Equip != null) { baseHero.Equip.Durable -= 1; } CardActionFactory.CreateAction(targetCard, ActionType.受到攻击).Action(uaPara); //自己挨打(如果攻击的是英雄,则不掉血) if (targetCard.CardType == CardType.随从) { HeroUnderAttackAction underAttackAction = new HeroUnderAttackAction(); ActionParameter underAttackPara = new ActionParameter() { GameContext = gameContext, PrimaryCard = baseHero, SecondaryCard = targetCard, }; underAttackAction.Action(underAttackPara); } baseHero.RemainAttackTimes -= 1; baseHero.CanAttack = baseHero.RemainAttackTimes > 0 ? true : false; return(null); }
/// <summary> /// 回合结束 /// </summary> public void TurnEnd(IShortCodeService shortCodeService) { UserContext uc = GameContext.GetActivationUserContext(), next_uc = null; uc.ComboSwitch = false; List <Card> buffCards = new List <Card>(); buffCards.AddRange(GameContext.DeskCards.GetDeskCardsByIsFirst(uc.IsFirst)); buffCards.AddRange(uc.HandCards); buffCards = buffCards.Where(c => c != null && c.Buffs.Count > 0).ToList(); foreach (Card card in buffCards) { LinkedListNode <IBuffRestore <ICardLocationFilter, IEvent> > buff = card.Buffs.First; MyTurnEndEvent myTurnEndEvent = new MyTurnEndEvent() { Parameter = new ActionParameter() { GameContext = GameContext, PrimaryCard = card } }; while (buff != null && buff.Value.TryCapture(card, myTurnEndEvent)) { buff.Value.Action(new ActionParameter() { GameContext = GameContext, PrimaryCard = card }); // card.Buffs.Remove(buff); buff = buff.Next; } } #region 调整玩家对象 if (GameContext.TurnIndex > 0) { next_uc = GameContext.GetNotActivationUserContext(); var para = new ActionParameter() { GameContext = GameContext, PrimaryCard = GameContext.GetHeroByActivation(next_uc.IsFirst) }; GameContext.EventQueue.AddLast(new MyTurnEndEvent() { Parameter = para }); GameContext.EventQueue.AddLast(new TouchOffComboEvent() { Parameter = para }); foreach (var bio in GameContext.DeskCards.Where(c => c != null)) { BaseBiology biology = bio as BaseBiology; biology.RemainAttackTimes = 0; } //在回合交换前结算 GameContext.QueueSettlement(); _gameCache.SetContext(GameContext); //DataExchangeBll.Instance.AsyncInsert("TurnEnd", "Controler_Base", "", JsonConvert.SerializeObject(GameContext), DataSourceEnum.GameControler); uc.IsActivation = false; next_uc.IsActivation = true; } else { //开局换完牌后,设置先手玩家费用=1 uc.FullPower = 1; uc.Power = 1; } #endregion #region 调整游戏环境对象 GameContext.CurrentTurnRemainingSecond = 60; GameContext.CurrentTurnCode = GameContext.NextTurnCode; GameContext.NextTurnCode = shortCodeService.CreateCode(); GameContext.TurnIndex++; #endregion GameContext.Settlement(); _gameCache.SetContext(GameContext); }
public bool True(ActionParameter actionParameter) { BaseBiology baseBiology = actionParameter.SecondaryCard as BaseBiology; return(baseBiology.Life < baseBiology.BuffLife); }