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)
        {
            GameContext context = actionParameter.GameContext;
            UC          uc      = GameActivator <UC> .CreateInstance();

            var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));

            foreach (UserContext user in users)
            {
                C card = Activator.CreateInstance <C>();
                card.IsFirstPlayerCard = user.IsFirst;
                //context.AllCard.Add(card);
                card.CardInGameCode = context.AllCard.Count().ToString();
                context.Players.First(c => c == user).AllCards.Add(card);

                if (user.HandCards.Count() < 10)
                {
                    //如果手牌没满则放入手牌中
                    //userContext.HandCards.Add(card);
                    card.CardLocation = CardLocation.手牌;
                }
                else
                {
                    //否则撕了这张牌
                    card.CardLocation = CardLocation.坟场;
                    //userContext.GraveyardCards.Add(card);
                }
            }
            return(null);
        }
Example #3
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);
        }
Example #4
0
        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();
            List <Card> summonCards = new List <Card>();

            // CardPick cardPick = Activator.CreateInstance<CardPick>();
            summonCards.AddRange(actionParameter.GameContext.GameCache.GetAllCard().Where(filter.Filter(actionParameter)));

            NUM num = GameActivator <NUM> .CreateInstance();

            foreach (UserContext user in users)
            {
                //summonCards = cardPick.Filter(summonCards.Where(c => user.AllCards.Where(x => cardLocation.Filter(x)).Any(z => z.CardCode == c.CardCode)).ToList(), actionParameter).ToList();
                foreach (Card card in summonCards)
                {
                    for (int i = 0; i < num.GetNumber(actionParameter); i++)
                    {
                        var newCard = Activator.CreateInstance(card.GetType()) as Card;
                        CreateNewCardInDeskAction action = new CreateNewCardInDeskAction();
                        var para = new ActionParameter()
                        {
                            GameContext  = actionParameter.GameContext,
                            IsActivation = user.IsActivation,
                            PrimaryCard  = newCard
                        };
                        action.Action(para);
                    }
                }
            }
            return(null);
        }
Example #5
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);
        }
Example #6
0
        public bool TryCapture(Card card, IEvent @event)
        {
            F locationFilter = GameActivator <F> .CreateInstance();

            ICardLocationFilter filter = GameActivator <F> .CreateInstance();

            return(filter.Filter(card) && Activator.CreateInstance <EVENT>().Compare(@event) && @event.Parameter.GameContext.IsThisActivationUserCard(card));
        }
Example #7
0
        public bool True(ActionParameter actionParameter)
        {
            NumOne one = GameActivator <NumOne> .CreateInstance();

            NumTwo two = GameActivator <NumTwo> .CreateInstance();

            return(one.GetNumber(actionParameter) > two.GetNumber(actionParameter));
        }
Example #8
0
        public override IActionOutputParameter Action(ActionParameter actionParameter)
        {
            IAura aura = (IAura)Activator.CreateInstance(typeof(T), AuraCard);

            aura.LocationFilter = GameActivator <F> .CreateInstance();

            return(aura.Action(actionParameter));
        }
        //public override List<SpellCardAbilityTime> SpellCardAbilityTimes { get; set; } = new List<SpellCardAbilityTime>() { SpellCardAbilityTime.己方回合开始 };
        public override bool TryCapture(Card card, IEvent @event)
        {
            ICardLocationFilter filter = GameActivator <F> .CreateInstance();

            UserContext uc = @event.Parameter.GameContext.GetUserContextByMyCard(card);

            return(filter.Filter(card) && @event.GetType() == typeof(MyTurnStartEvent) && uc.IsActivation);
        }
Example #10
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            UC uc = GameActivator <UC> .CreateInstance();

            var user = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter)).First();

            actionParameter.GameContext.GameStatus = user.IsFirst ? GameStatus.先手胜利 : GameStatus.后手胜利;
            return(null);
        }
Example #11
0
        public void CreateInstance_NoWorldImplementation_Exception()
        {
            var actual = Assert.Catch <InvalidOperationException>(() =>
            {
                GameActivator.CreateInstance(typeof(GameActivatorTest).Assembly);
            });

            Assert.AreEqual("Could not find a class that inherits from Doog.World class.", actual.Message);
        }
        public Func <Card, bool> Filter(ActionParameter actionParameter)
        {
            Q qat = GameActivator <Q> .CreateInstance();

            List <Card> lstCardLib = actionParameter.GameContext.GameCache.GetAllCard();
            List <Card> servants   = lstCardLib.Where(c => c.Cost == qat.Number && c.CardType == CardType.随从 && c.Profession == Profession.Neutral && c.IsDerivative == false).ToList();
            BaseServant servant    = servants[RandomUtil.CreateRandomInt(0, servants.Count - 1)] as BaseServant;

            return(new Func <Card, bool>(c => c.CardCode == servant.CardCode));
        }
Example #13
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            UC uc = GameActivator <UC> .CreateInstance();

            var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));

            foreach (UserContext user in users)
            {
                user.Power += GameActivator <Q> .CreateInstance().GetNumber(actionParameter);
            }
            return(null);
        }
Example #14
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            UC uc = GameActivator <UC> .CreateInstance();

            var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));

            foreach (UserContext user in users)
            {
                BaseHero hero = actionParameter.GameContext.DeskCards.GetHeroByIsFirst(user.IsFirst);
                hero.Ammo += GameActivator <Q> .CreateInstance().GetNumber(actionParameter);
            }
            return(null);
        }
Example #15
0
        private World CreateWorld()
        {
            var world = GameActivator.CreateInstance(_gameAssembly);

            world.Initialize(
                Substitute.For <IGraphicSystem>(),
                Substitute.For <IPhysicSystem>(),
                Substitute.For <ITextSystem>(),
                Substitute.For <IInputSystem>(),
                () => { });

            return(world);
        }
Example #16
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(Activator.CreateInstance <TAG>().Filter(actionParameter)))
            {
                BaseHero hero = biology as BaseHero;
                if (hero.Equip != null)
                {
                    hero.Equip.Damage += GameActivator <Damage> .CreateInstance().GetNumber(actionParameter);

                    hero.Equip.Durable += GameActivator <Durable> .CreateInstance().GetNumber(actionParameter);
                }
            }
            return(null);
        }
        public IEnumerable <Card> Filter(IList <Card> cards, ActionParameter baseActionParameter)
        {
            int num = GameActivator <NUM> .CreateInstance().GetNumber(baseActionParameter);

            num = num > cards.Count ? cards.Count : num;
            List <int>  indexs      = RandomUtil.CreateRandomInt(0, cards.Count - 1, num);
            List <Card> resultCards = new List <Card>();

            foreach (int i in indexs)
            {
                resultCards.Add(cards[i]);
            }
            return(resultCards);
        }
Example #18
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);
        }
Example #19
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            D   direction = Activator.CreateInstance <D>();
            UC  uc        = Activator.CreateInstance <UC>();
            var users     = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));

            foreach (UserContext user in users)
            {
                foreach (BaseBiology biology in user.HandCards.Where(Activator.CreateInstance <TAG>().Filter(actionParameter)))
                {
                    int Number = direction.SetNumber(GameActivator <Q> .CreateInstance());
                    biology.Cost += Number;
                }
            }
            return(null);
        }
Example #20
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);
        }
Example #21
0
        public override bool TryCapture(Card card, IEvent @event)
        {
            TouchOffComboEvent touchOffComboEvent = Activator.CreateInstance <TouchOffComboEvent>();

            touchOffComboEvent.Parameter = @event.Parameter;
            bool isCapture = GameActivator <F> .CreateInstance().Filter(card) && touchOffComboEvent.Compare(@event);

            if (isCapture)
            {
                CastCrosshairStyle = CastCrosshairStyle.单个;
            }
            else
            {
                CastCrosshairStyle = CastCrosshairStyle.无;
            }

            return(false);
        }
Example #22
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            UC uc = GameActivator <UC> .CreateInstance();

            var enemy = actionParameter.GameContext.Players.First(uc.Filter(actionParameter));
            var user  = actionParameter.GameContext.Players.First(c => c.IsFirst != enemy.IsFirst);

            foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(Activator.CreateInstance <TAG>().Filter(actionParameter)))
            {
                BaseServant rndServant = biology as BaseServant;
                enemy.AllCards.RemoveAt(enemy.AllCards.FindIndex(c => c.CardInGameCode == rndServant.CardInGameCode));
                user.AllCards.Add(rndServant);

                actionParameter.GameContext.DeskCards[rndServant.DeskIndex] = null;

                if (rndServant.DeskIndex > 8)
                {
                    for (int i = 1; i < 8; i++)
                    {
                        if (actionParameter.GameContext.DeskCards[i] == null)
                        {
                            rndServant.DeskIndex = i;
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 9; i < 16; i++)
                    {
                        if (actionParameter.GameContext.DeskCards[i] == null)
                        {
                            rndServant.DeskIndex = i;
                            break;
                        }
                    }
                }

                actionParameter.GameContext.DeskCards[rndServant.DeskIndex] = rndServant;
            }
            return(null);
        }
Example #23
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            D drawCount = GameActivator <D> .CreateInstance();

            UC uc = GameActivator <UC> .CreateInstance();

            var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));

            foreach (UserContext user in users)
            {
                var para = new ActionParameter()
                {
                    DrawCount   = drawCount.GetNumber(actionParameter),
                    GameContext = actionParameter.GameContext,
                    UserContext = user
                };
                new DrawCardAction().Action(para);
            }
            return(null);
        }
Example #24
0
        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);
        }
Example #25
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            UC uc = GameActivator <UC> .CreateInstance();

            var                users      = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));
            var                filter     = Activator.CreateInstance <F>();
            CardPick           cardPick   = Activator.CreateInstance <CardPick>();
            List <BaseServant> servants   = new List <BaseServant>();
            List <Card>        lstCardLib = actionParameter.GameContext.GameCache.GetAllCard();

            foreach (UserContext user in users)
            {
                List <Card> deadCards    = user.GraveyardCards.Where(filter.Filter(actionParameter)).ToList();
                List <Card> waitingCards = new List <Card>();
                foreach (Card card in deadCards)
                {
                    Card libCard = lstCardLib.First(c => c.CardCode == card.CardCode);
                    var  newCard = Activator.CreateInstance(libCard.GetType()) as Card;
                    waitingCards.Add(newCard);
                }
                var resurrectionCards = cardPick.Filter(waitingCards, actionParameter);
                foreach (var card in resurrectionCards)
                {
                    //if (user.GraveyardCards.Any(c => c.CardCode == card.CardCode))
                    //{
                    //    user.GraveyardCards.RemoveAt(user.GraveyardCards.FindIndex(c => c.CardCode == card.CardCode));
                    //}
                    CreateNewCardInDeskAction action = new CreateNewCardInDeskAction();
                    var para = new ActionParameter()
                    {
                        GameContext  = actionParameter.GameContext,
                        IsActivation = user.IsActivation,
                        PrimaryCard  = card
                    };
                    action.Action(para);
                }
            }
            return(null);
        }
Example #26
0
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            Q dropCount = GameActivator <Q> .CreateInstance();

            P pickType = GameActivator <P> .CreateInstance();

            UC uc = GameActivator <UC> .CreateInstance();

            var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter));

            foreach (UserContext user in users)
            {
                var para = new ActionParameter()
                {
                    PrimaryCard  = actionParameter.PrimaryCard,
                    DropCount    = dropCount.GetNumber(actionParameter),
                    GameContext  = actionParameter.GameContext,
                    UserContext  = user,
                    DropCardType = pickType.PickType
                };
                new DropCardAction().Action(para);
            }
            return(null);
        }
Example #27
0
 public override bool TryCapture(Card card, IEvent @event)
 {
     return(GameActivator <F> .CreateInstance().Filter(card) && Activator.CreateInstance <E>().Compare(@event) && @event.EventCard.IsFirstPlayerCard == card.IsFirstPlayerCard);
 }
        //public override List<SpellCardAbilityTime> SpellCardAbilityTimes { get; set; } = new List<SpellCardAbilityTime>() { SpellCardAbilityTime.己方随从受到伤害后 };
        public override bool TryCapture(Card card, IEvent @event)
        {
            ICardLocationFilter filter = GameActivator <F> .CreateInstance();

            return(filter.Filter(card) && @event.GetType() == typeof(MyServantHurtEvent) && @event.EventCard.IsFirstPlayerCard == card.IsFirstPlayerCard);
        }
Example #29
0
 public Func <Card, bool> Filter(ActionParameter baseActionParameter)
 {
     return(new Func <Card, bool>(c => c != null && c.CardType == CardType.随从 && (c as BaseServant).Race == GameActivator <RaceEnum> .CreateInstance().Race));
 }
Example #30
0
        public void CreateInstance_WorldImplementation_World()
        {
            var actual = GameActivator.CreateInstance(_gameAssembly);

            Assert.IsTrue(actual is World);
        }