Exemplo n.º 1
0
        public virtual void Respond(IEvent @event)
        {
            GameContext gameContext = @event.Parameter.GameContext;

            // foreach (Card card in gameContext.AllCard.Where(c => c.CardInGameCode == "24"))
            // {
            //     bool res = card.CardAbility.TryCapture(card, @event);
            // }

            foreach (Card card in gameContext.AllCard.Where(c => c.CardAbility.TryCapture(c, @event)).OrderBy(c => c.CastIndex))
            {
                @event.Parameter.TertiaryCard = card;
                gameContext.AddActionStatements(card.CardAbility, @event.Parameter);
            }
            foreach (Card card in gameContext.AllCard.Where(c => c.Buffs.Count > 0).OrderBy(c => c.CastIndex))
            {
                @event.Parameter.TertiaryCard = card;
                LinkedListNode <IBuffRestore <ICardLocationFilter, IEvent> > buff = card.Buffs.First;
                while (buff != null && buff.Value.TryCapture(card, @event))
                {
                    gameContext.AddActionStatements(buff.Value, new ActionParameter
                    {
                        GameContext   = @event.Parameter.GameContext,
                        PrimaryCard   = card,
                        SecondaryCard = @event.EventCard,
                        TertiaryCard  = card
                    });
                    card.Buffs.Remove(buff);
                    buff = buff.Next;
                }
            }
        }
        public IActionOutputParameter Action(ActionParameter actionParameter)
        {
            BaseServant servant     = actionParameter.PrimaryCard as BaseServant;
            GameContext gameContext = actionParameter.GameContext;
            Card        triggerCard = actionParameter.SecondaryCard;

            if (servant.HasHolyShield)
            {
                servant.HasHolyShield = false;
            }
            else if (servant.HasPoison)
            {
                servant.IsDeathing = true;
            }
            else
            {
                servant.Life -= actionParameter.DamageOrHeal;
            }

            HurtEvent hurtEvent = new HurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            };

            if (servant.CardAbility.TryCapture(servant, hurtEvent))
            {
                hurtEvent.Parameter.TertiaryCard = servant;
                gameContext.AddActionStatements(servant.CardAbility, hurtEvent.Parameter);
            }

            gameContext.EventQueue.AddLast(new MyServantHurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            gameContext.EventQueue.AddLast(new AnyServantHurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            gameContext.EventQueue.AddLast(new AnyHurtEvent()
            {
                EventCard = servant, Parameter = actionParameter
            });
            return(null);
        }