Beispiel #1
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);
        }
        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);
        }