Exemplo n.º 1
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            Hero heroFilter = Activator.CreateInstance <Hero>();
            Q    damege     = GameActivator <Q> .CreateInstance();

            var heros = actionParameter.GameContext.DeskCards.Where(heroFilter.Filter(actionParameter));

            foreach (Card card in heros)
            {
                BaseHero hero = card as BaseHero;
                //将护甲削减为0
                int ammo = hero.Ammo;
                hero.Ammo = 0;
                ActionParameter para = new ActionParameter
                {
                    PrimaryCard   = hero,
                    GameContext   = actionParameter.GameContext,
                    DamageOrHeal  = damege.GetNumber(actionParameter),
                    SecondaryCard = actionParameter.PrimaryCard
                };
                CardActionFactory.CreateAction(hero, ActionType.受到伤害).Action(para);
                hero.Ammo = ammo;
            }
            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);
        }
Exemplo n.º 3
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            ActionParameter para        = actionParameter as ActionParameter;
            BaseHero        baseHero    = para.PrimaryCard as BaseHero;
            GameContext     gameContext = para.GameContext;
            int             damage      = para.DamageOrHeal;

            //计算法术强度类技能
            var biologys = gameContext.DeskCards.GetDeskCardsByEnemyCard(baseHero).Where(c => c != null);

            damage += biologys.Sum(c => c.SpellPower);
            if (biologys.Any(c => c.CardType == CardType.英雄 && (c as BaseHero).Equip != null))
            {
                damage += (biologys.First(c => c.CardType == CardType.英雄) as BaseHero).Equip.SpellPower;
            }

            var damagePara = new ActionParameter
            {
                PrimaryCard   = baseHero,
                GameContext   = actionParameter.GameContext,
                DamageOrHeal  = damage,
                SecondaryCard = actionParameter.PrimaryCard
            };

            CardActionFactory.CreateAction(baseHero, ActionType.受到伤害).Action(damagePara);
            return(new IntParameter()
            {
                Value = damage
            });
        }
Exemplo n.º 4
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            TAG tag = Activator.CreateInstance <TAG>();
            NUM num = GameActivator <NUM> .CreateInstance();

            QAT qat = GameActivator <QAT> .CreateInstance();

            D direction      = Activator.CreateInstance <D>();
            F locationFilter = GameActivator <F> .CreateInstance();

            for (int i = 0; i < qat.GetNumber(actionParameter); i++)
            {
                foreach (BaseBiology biology in actionParameter.GameContext.AllCard.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex))
                {
                    biology.BuffLife += direction.SetNumber(num);
                    biology.Life     += direction.SetNumber(num);
                    biology.Damage   += direction.SetNumber(num);


                    ActionParameter para = new ActionParameter
                    {
                        PrimaryCard = biology,
                        GameContext = actionParameter.GameContext
                    };
                    CardActionFactory.CreateAction(biology, ActionType.重置攻击次数).Action(para);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            TAG tag        = Activator.CreateInstance <TAG>();
            DT  damageType = GameActivator <DT> .CreateInstance();

            DMG dmg = GameActivator <DMG> .CreateInstance();

            QAT qat = GameActivator <QAT> .CreateInstance();

            for (int i = 0; i < qat.GetNumber(actionParameter); i++)
            {
                foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex))
                {
                    var para = new ActionParameter
                    {
                        PrimaryCard   = biology,
                        GameContext   = actionParameter.GameContext,
                        DamageOrHeal  = dmg.GetNumber(actionParameter),
                        SecondaryCard = actionParameter.PrimaryCard
                    };
                    CardActionFactory.CreateAction(biology, damageType.ActionType).Action(para);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            BaseHero    baseHero    = actionParameter.Hero;
            GameContext gameContext = actionParameter.GameContext;
            BaseEquip   equip       = actionParameter.Equip;

            if (baseHero.Equip != null)
            {
                var oldEquip = baseHero.Equip;

                UnloadAction unloadAction = new UnloadAction();
                var          equipPara    = new ActionParameter()
                {
                    GameContext = gameContext,
                    Equip       = oldEquip,
                };
                unloadAction.Action(equipPara);
            }
            baseHero.Equip = equip;

            var user = gameContext.GetUserContextByMyCard(equip);

            gameContext.CastCardCount++;
            equip.CastIndex    = gameContext.CastCardCount;
            equip.CardLocation = CardLocation.场上;

            ActionParameter resetPara = new ActionParameter
            {
                PrimaryCard = baseHero,
                GameContext = actionParameter.GameContext
            };

            CardActionFactory.CreateAction(baseHero, ActionType.重置攻击次数).Action(resetPara);
            return(null);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            GameContext context      = actionParameter.GameContext;
            bool        isActivation = actionParameter.IsActivation;

            T servant = Activator.CreateInstance <T>();

            var player = context.Players.First(c => c.IsActivation == isActivation);

            servant.IsFirstPlayerCard = player.IsFirst;

            int deskIndex   = -1;
            int searchCount = 0;

            for (int i = player.IsFirst ? 0 : 8; i < context.DeskCards.Count; i++)
            {
                searchCount++;
                if (searchCount > 8)
                {
                    break;
                }
                if (context.DeskCards[i] == null)
                {
                    deskIndex = i;
                    break;
                }
            }
            if (deskIndex < 0)
            {
                return(null);
            }
            context.CastCardCount++;
            servant.CastIndex = context.CastCardCount;
            //context.AllCard.Add(servant);
            servant.DeskIndex            = deskIndex;
            servant.CardInGameCode       = context.AllCard.Count().ToString();
            context.DeskCards[deskIndex] = servant;
            player.AllCards.Add(servant);

            ActionParameter castPara = new ActionParameter()
            {
                PrimaryCard = servant,
                GameContext = actionParameter.GameContext,
                DeskIndex   = deskIndex
            };

            CardActionFactory.CreateAction(servant, ActionType.进场).Action(castPara);
            //servant.Cast(context, deskIndex, -1);

            context.EventQueue.AddLast(new ServantInDeskEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            return(servant);
        }
Exemplo n.º 9
0
        public void TurnStart()
        {
            var cap = new ActionParameter()
            {
                GameContext = GameContext,
                PrimaryCard = GameContext.GetHeroByActivation()
            };

            GameContext.EventQueue.AddLast(new MyTurnStartEvent()
            {
                Parameter = cap
            });

            var uc = GameContext.GetActivationUserContext();

            if (uc.FullPower < 10)
            {
                uc.FullPower += 1;
            }
            uc.Power = uc.FullPower;

            //抽牌
            var para = new ActionParameter()
            {
                DrawCount   = 1,
                GameContext = GameContext,
                UserContext = uc
            };

            new DrawCardAction().Action(para);

            //GameContext.DrawCard();

            //将英雄技能可用次数重置为1次
            uc.RemainingHeroPowerCastCount = 1;

            var activationDeskCards = GameContext.DeskCards.GetDeskCardsByIsFirst(uc.IsFirst);

            //让场上的随从或英雄获取攻击次数
            foreach (var card in activationDeskCards.Where(c => c != null))
            {
                card.CanAttack = true;
                ActionParameter resetPara = new ActionParameter()
                {
                    PrimaryCard = card,
                    GameContext = GameContext
                };
                CardActionFactory.CreateAction(card, ActionType.重置攻击次数).Action(resetPara);
            }
            GameContext.Settlement();
            _gameCache.SetContext(GameContext);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 随从攻击进行阶段
        /// </summary>
        /// <param name="servant"></param>
        /// <param name="target"></param>
        public void ServantAttack(BaseServant servant, int target)
        {
            ActionParameter para = new ActionParameter()
            {
                PrimaryCard   = servant,
                GameContext   = GameContext,
                SecondaryCard = GameContext.DeskCards[target]
            };

            CardActionFactory.CreateAction(servant, ActionType.攻击).Action(para);
            // GameContext.AddEndOfPlayerActionEvent();
            GameContext.Settlement();
            _gameCache.SetContext(GameContext);
        }
Exemplo n.º 11
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            var uc   = actionParameter.GameContext.GetActivationUserContext();
            var hero = actionParameter.PrimaryCard as BaseHero;

            ActionParameter para = new ActionParameter
            {
                PrimaryCard   = actionParameter.SecondaryCard,
                GameContext   = actionParameter.GameContext,
                DamageOrHeal  = 1,
                SecondaryCard = hero
            };

            CardActionFactory.CreateAction(actionParameter.SecondaryCard, ActionType.受到伤害).Action(para);
            return(null);
        }
Exemplo n.º 12
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(Activator.CreateInstance <TAG>().Filter(actionParameter)).OrderBy(c => c.CastIndex))
            {
                biology.Damage += GameActivator <Q> .CreateInstance().GetNumber(actionParameter);

                ActionParameter para = new ActionParameter()
                {
                    PrimaryCard = biology,
                    GameContext = actionParameter.GameContext
                };;

                CardActionFactory.CreateAction(biology, ActionType.重置攻击次数).Action(para);
            }
            return(null);
        }
Exemplo n.º 13
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            var uc   = actionParameter.GameContext.GetActivationUserContext();
            var hero = actionParameter.GameContext.DeskCards.GetHeroByIsFirst(uc.IsFirst);

            hero.Ammo   += 1;
            hero.Damage += 1;
            ActionParameter para = new ActionParameter
            {
                PrimaryCard = actionParameter.PrimaryCard,
                GameContext = actionParameter.GameContext
            };

            CardActionFactory.CreateAction(actionParameter.PrimaryCard, ActionType.重置攻击次数).Action(para);

            return(null);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            TAG tag = Activator.CreateInstance <TAG>();
            C   qat = GameActivator <C> .CreateInstance();

            foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex))
            {
                var para = new ActionParameter
                {
                    PrimaryCard   = biology,
                    GameContext   = actionParameter.GameContext,
                    DamageOrHeal  = qat.GetNumber(actionParameter),
                    SecondaryCard = actionParameter.PrimaryCard
                };
                CardActionFactory.CreateAction(biology, ActionType.受到治疗).Action(para);
            }
            return(null);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 阶段检索,即在每一个结算队列结算完之后,开始的检索,包括死亡检索、受伤检索等
        /// </summary>
        /// <param name="context"></param>
        public static void StageRetrieval(this GameContext context)
        {
            bool hasQueueSettlement = false;

            if (context.DeskCards.Any(c => c != null && (c.Life < 1 || c.IsDeathing)))
            {
                //先按入场顺序排列
                var lstBiology = context.DeskCards.Where(c => c != null && (c.Life < 1 || c.IsDeathing)).OrderBy(x => x.CastIndex);
                foreach (var bio in lstBiology)
                {
                    ActionParameter para = new ActionParameter()
                    {
                        PrimaryCard = bio,
                        GameContext = context
                    };
                    CardActionFactory.CreateAction(bio, ActionType.死亡).Action(para);
                }
                hasQueueSettlement = true;
            }
            if (context.DeskCards.Any(c => c != null && c.CardType == CardType.英雄 && (c as BaseHero).Equip != null && (c as BaseHero).Equip.Durable < 1))
            {
                var heros = context.DeskCards.Where(c => c != null && c.CardType == CardType.英雄 && (c as BaseHero).Equip != null && (c as BaseHero).Equip.Durable < 1);
                foreach (var hero in heros)
                {
                    UnloadAction    unloadAction = new UnloadAction();
                    ActionParameter equipPara    = new ActionParameter()
                    {
                        GameContext = context,
                        Equip       = (hero as BaseHero).Equip,
                    };
                    unloadAction.Action(equipPara);
                }
                hasQueueSettlement = true;
            }
            if (hasQueueSettlement)
            {
                QueueSettlement(context);
            }
        }
Exemplo n.º 17
0
        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);
        }