示例#1
0
            public override void Resolve(TurnContext context, ICard source)
            {
                var deck       = context.ActivePlayer.Deck;
                var revealZone = new RevealZone(context.ActivePlayer);

                while (deck.TopCard != null && MatchingCards(revealZone).Count() < 2)
                {
                    deck.TopCard.MoveTo(revealZone);
                }

                revealZone.LogReveal(context.Game.Log);
                var revealedTreasure = MatchingCards(revealZone).ToList();

                var discards = revealZone.Where(c => !revealedTreasure.Cast <ICard>().Contains(c)).ToList();

                foreach (var card in discards)
                {
                    card.MoveTo(context.ActivePlayer.Discards);
                }

                foreach (var card in revealedTreasure)
                {
                    card.MoveTo(context.ActivePlayer.Hand);
                }
            }
示例#2
0
        public void Play(TurnContext context)
        {
            var leftPlayer = context.Opponents.FirstOrDefault();

            if (leftPlayer != null)
            {
                var revealZone = new RevealZone(leftPlayer);
                leftPlayer.Deck.MoveTop(2, revealZone);
                revealZone.LogReveal(context.Game.Log);

                foreach (var card in revealZone.WithDistinctTypes())
                {
                    if (card is IActionCard)
                    {
                        context.RemainingActions += 2;
                    }
                    if (card is ITreasureCard)
                    {
                        context.AvailableSpend += 2;
                    }
                    if (card is IVictoryCard)
                    {
                        context.DrawCards(2);
                    }
                }

                revealZone.MoveAll(leftPlayer.Discards);
            }
        }
示例#3
0
            public override void Resolve(TurnContext context, ICard source)
            {
                var deck       = context.ActivePlayer.Deck;
                var revealZone = new RevealZone(context.ActivePlayer);

                while (deck.TopCard != null && MatchingActions(revealZone).Count() < 2)
                {
                    deck.TopCard.MoveTo(revealZone);
                }

                revealZone.LogReveal(context.Game.Log);
                var actionsToPlay = MatchingActions(revealZone).ToList();

                var discards = revealZone.Where(c => !actionsToPlay.Cast <ICard>().Contains(c))
                               .ToList();

                foreach (var card in discards)
                {
                    card.MoveTo(context.ActivePlayer.Discards);
                }

                var playUtil = new PlayCardUtility(context);

                if (actionsToPlay.AllSame(a => a.Name))
                {
                    playUtil.Play(actionsToPlay);
                }
                else
                {
                    _activities.Add(CreateChooseActionActivity(context, revealZone, source));
                }
            }
示例#4
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                var revealZone = new RevealZone(victim);

                victim.Deck.MoveTop(2, revealZone);
                revealZone.LogReveal(context.Game.Log);

                var revealedTreasures = revealZone.OfType <ITreasureCard>().WithDistinctTypes();

                switch (revealedTreasures.Count())
                {
                case 0:
                    revealZone.MoveAll(victim.Discards);
                    return;

                case 1:
                    var trashedCard        = TrashAndDiscard(context, revealZone, revealedTreasures);
                    var gainChoiceActivity = Activities.GainOpponentsCardChoice(context, trashedCard, revealZone.Owner, source);
                    _activities.Add(gainChoiceActivity);
                    break;

                default:
                    var chooseTreasureActivity = CreateChooseTreasureActivity(context, revealZone, source);
                    _activities.Add(chooseTreasureActivity);
                    break;
                }
            }
示例#5
0
        public SelectFromRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ISelectionSpecification selectionSpecification, ICard source)
            : base(log, player, message, selectionSpecification, source)
        {
            RevealedCards = revealZone;

            // HACK. I'm ignoring the activity type on the selection specification. Not sure what to do here.
            Type = ActivityType.SelectFromRevealed;
        }
示例#6
0
 public static IActivity SelectARevealedCardToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, string message)
 {
     return new SelectFromRevealedCardsActivity(log, player, revealZone, message,
                                                SelectionSpecifications.SelectExactlyXCards(1))
     {
         AfterCardsSelected = cards => player.Deck.MoveToTop(cards.Single())
     };
 }
示例#7
0
 public static IEnumerable<IActivity> SelectMultipleRevealedCardsToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone)
 {
     var count = revealZone.Count();
     return count.Items(
         (i) => SelectARevealedCardToPutOnTopOfDeck(log, player, revealZone,
             string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count))
     );               
 }
        public SelectFromRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ISelectionSpecification selectionSpecification)
            : base(log, player, message, selectionSpecification)
        {
            RevealedCards = revealZone;

            // HACK. I'm ignoring the activity type on the selection specification. Not sure what to do here.
            Type = ActivityType.SelectFromRevealed;
        }
示例#9
0
            private Card TrashAndDiscard(TurnContext context, RevealZone revealZone, IEnumerable <ITreasureCard> revealedTreasures)
            {
                var trashedCard = revealedTreasures.Single();

                trashedCard.MoveTo(context.Game.Trash);
                context.Game.Log.LogTrash(revealZone.Owner, trashedCard);
                revealZone.MoveAll(revealZone.Owner.Discards);
                return((Card)trashedCard);
            }
示例#10
0
            private IActivity CreateChooseCardActivity(TurnContext context, RevealZone revealZone, Player player, ICard source)
            {
                var selectTreasure = new SelectFromRevealedCardsActivity(context.Game.Log, player, revealZone,
                                                                         string.Format("Select the card you do NOT want {0} to draw.", revealZone.Owner.Name), SelectionSpecifications.SelectExactlyXCards(1), source);

                selectTreasure.AfterCardsSelected = cards =>
                {
                    var discardingCard = cards.Single();
                    discardingCard.MoveTo(context.ActivePlayer.Discards);
                    revealZone.MoveAll(context.ActivePlayer.Hand);
                };

                return(selectTreasure);
            }
示例#11
0
            private IActivity CreateChooseTreasureActivity(TurnContext context, RevealZone revealZone, ICard source)
            {
                var selectTreasure = new SelectFromRevealedCardsActivity(context.Game.Log, context.ActivePlayer, revealZone,
                                                                         "Select a treasure to trash (you will have the opportunity to gain it).", SelectionSpecifications.SelectExactlyXCards(1), source);

                selectTreasure.AfterCardsSelected = cards =>
                {
                    var trashedCard         = TrashAndDiscard(context, revealZone, cards.OfType <ITreasureCard>());
                    var gainOrTrashActivity = Activities.GainOpponentsCardChoice(context, trashedCard, revealZone.Owner, source);
                    _activities.Insert(0, gainOrTrashActivity);
                };

                return(selectTreasure);
            }
示例#12
0
            public override void Resolve(TurnContext context, ICard source)
            {
                var leftPlayer = context.Opponents.FirstOrDefault();

                if (leftPlayer != null)
                {
                    var revealZone = new RevealZone(context.ActivePlayer);
                    context.ActivePlayer.Deck.MoveTop(5, revealZone);
                    revealZone.LogReveal(context.Game.Log);

                    if (revealZone.CardCount > 0)
                    {
                        var activity = CreateChooseCardActivity(context, revealZone, leftPlayer, source);
                        _activities.Add(activity);
                    }
                }
            }
示例#13
0
            private IActivity CreateChooseActionActivity(TurnContext context, RevealZone revealZone, ICard source)
            {
                var selectTreasure = new SelectFromRevealedCardsActivity(context.Game.Log, context.ActivePlayer, revealZone,
                                                                         "Select the action to play first.", SelectionSpecifications.SelectExactlyXCards(1), source);

                selectTreasure.AfterCardsSelected = cards =>
                {
                    var first  = cards.OfType <IActionCard>().Single();
                    var second = revealZone.OfType <IActionCard>().Single(c => c != first);

                    // Reverse order because we're on a stack.
                    context.AddEffect(source, new PlayCardEffect(second));
                    context.AddEffect(source, new PlayCardEffect(first));
                };

                return(selectTreasure);
            }
示例#14
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                var revealZone = new RevealZone(victim);

                victim.Deck.MoveTop(3, revealZone);

                revealZone.LogReveal(context.Game.Log);
                revealZone.MoveWhere(c => c is IActionCard || c is ITreasureCard, victim.Discards);

                if (revealZone.CardCount == 1)
                {
                    victim.Deck.MoveToTop(revealZone.Single());
                }

                foreach (var activity in Activities.SelectMultipleRevealedCardsToPutOnTopOfDeck(context.Game.Log, victim, revealZone, source))
                {
                    _activities.Add(activity);
                }
            }
示例#15
0
            public override void Resolve(TurnContext context, ICard source)
            {
                var revealZone = new RevealZone(context.ActivePlayer);

                context.ActivePlayer.Deck.MoveTop(4, revealZone);

                revealZone.LogReveal(context.Game.Log);
                revealZone.MoveWhere(c => c is Copper || c is Potion, context.ActivePlayer.Hand);

                if (revealZone.CardCount == 1)
                {
                    context.ActivePlayer.Deck.MoveToTop(revealZone.Single());
                }

                foreach (var activity in Activities.SelectMultipleRevealedCardsToPutOnTopOfDeck(context.Game.Log, context.ActivePlayer, revealZone, source))
                {
                    _activities.Add(activity);
                }
            }
示例#16
0
        public static IActivity ChooseWhetherToMillTopCard(TurnContext context, Player choosingPlayer, Player targetPlayer, ICard source)
        {
            var revealZone = new RevealZone(targetPlayer);

            targetPlayer.Deck.TopCard.MoveTo(revealZone);
            revealZone.LogReveal(context.Game.Log);

            var otherPlayerMessage = string.Format("Put {0}'s card in the discard pile?", targetPlayer.Name);
            var selfMessage        = "Put your own card in the discard pile?";

            var activity = new ChooseBasedOnRevealedCardsActivity(
                context.Game.Log,
                choosingPlayer,
                revealZone,
                choosingPlayer == targetPlayer ? selfMessage : otherPlayerMessage,
                source,
                Choice.Yes,
                Choice.No
                );

            activity.ActOnChoice = choice =>
            {
                var    card = revealZone.Single();
                string actionDescription;
                if (choice == Choice.Yes)
                {
                    actionDescription = "into the discard pile";
                    card.MoveTo(targetPlayer.Discards);
                }
                else
                {
                    actionDescription = "back on top";
                    targetPlayer.Deck.MoveToTop(card);
                }

                var message = string.Format("{0} put {1}'s {2} {3}.", context.ActivePlayer, targetPlayer, card.Name, actionDescription);
                context.Game.Log.LogMessage(message);
            };

            return(activity);
        }
示例#17
0
        public static IEnumerable<IActivity> SelectMultipleRevealedCardsToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, ICard source)
        {            
            var count = revealZone.Count();
            if (count == 1)
                throw new ArgumentException("The reveal zone only contains one card. Cannot select multiples.");

            return count.Items(
                (i) => SelectARevealedCardToPutOnTopOfDeck(log, player, revealZone,
                    string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count), source)
            ).Take(count - 1);               
        }
示例#18
0
 public static IActivity SelectARevealedCardToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, string message, ICard source)
 {
     return(new SelectFromRevealedCardsActivity(log, player, revealZone, message,
                                                SelectionSpecifications.SelectExactlyXCards(1), source)
     {
         AfterCardsSelected = cards =>
         {
             player.Deck.MoveToTop(cards.Single());
             if (revealZone.CardCount == 1)
             {
                 var lastCard = revealZone.Single();
                 player.Deck.MoveToTop(lastCard);
                 //log.LogMessage("{0} put a {1} on top.", player.Name, lastCard.Name);
             }
         },
         Hint = ActivityHint.RedrawCards
     });
 }
示例#19
0
        public static IEnumerable <IActivity> SelectMultipleRevealedCardsToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, ICard source)
        {
            var count = revealZone.Count();

            if (count == 1)
            {
                throw new ArgumentException("The reveal zone only contains one card. Cannot select multiples.");
            }

            return(count.Items(
                       (i) => SelectARevealedCardToPutOnTopOfDeck(log, player, revealZone,
                                                                  string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count), source)
                       ).Take(count - 1));
        }
 public ChooseBasedOnRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ICard source, params Choice[] options) 
     : base(log, player, message, source, options)
 {
     RevealedCards = revealZone;
 }
 public ChooseBasedOnRevealedCardsActivity(TurnContext context, Player player, RevealZone revealZone, string message, ICard source, params Choice[] options) 
     : base(context, player, message, source, options)
 {
     RevealedCards = revealZone;                        
 }
示例#22
0
 private IEnumerable <ITreasureCard> MatchingCards(RevealZone zone)
 {
     return(zone.OfType <ITreasureCard>());
 }
示例#23
0
 private IEnumerable <IActionCard> MatchingActions(RevealZone zone)
 {
     return(zone.OfType <IActionCard>().Where(c => !(c is Golem)));
 }
示例#24
0
 public ChooseBasedOnRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ICard source, params Choice[] options)
     : base(log, player, message, source, options)
 {
     RevealedCards = revealZone;
 }
示例#25
0
 public ChooseBasedOnRevealedCardsActivity(TurnContext context, Player player, RevealZone revealZone, string message, ICard source, params Choice[] options)
     : base(context, player, message, source, options)
 {
     RevealedCards = revealZone;
 }
示例#26
0
 public static IActivity SelectARevealedCardToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, string message, ICard source)
 {
     return new SelectFromRevealedCardsActivity(log, player, revealZone, message,
                                                SelectionSpecifications.SelectExactlyXCards(1), source)
     {
         AfterCardsSelected = cards =>
         {
             player.Deck.MoveToTop(cards.Single());
             if(revealZone.CardCount == 1)
             {
                 var lastCard = revealZone.Single();
                 player.Deck.MoveToTop(lastCard);
                 //log.LogMessage("{0} put a {1} on top.", player.Name, lastCard.Name);
             }
         },
         Hint = ActivityHint.RedrawCards
     };
 }
示例#27
0
        public static IActivity ChooseWhetherToMillTopCard(TurnContext context, Player choosingPlayer, Player targetPlayer, ICard source)
        {
            var revealZone = new RevealZone(targetPlayer);
            targetPlayer.Deck.TopCard.MoveTo(revealZone);
            revealZone.LogReveal(context.Game.Log);

            var otherPlayerMessage = string.Format("Put {0}'s card in the discard pile?", targetPlayer.Name);
            var selfMessage = "Put your own card in the discard pile?";

            var activity = new ChooseBasedOnRevealedCardsActivity(
                context.Game.Log,
                choosingPlayer,
                revealZone,
                choosingPlayer == targetPlayer ? selfMessage : otherPlayerMessage,
                source,
                Choice.Yes,
                Choice.No
                );

            activity.ActOnChoice = choice =>
            {
                var card = revealZone.Single();
                string actionDescription;
                if (choice == Choice.Yes)
                {
                    actionDescription = "into the discard pile";
                    card.MoveTo(targetPlayer.Discards);
                }
                else
                {
                    actionDescription = "back on top";
                    targetPlayer.Deck.MoveToTop(card);
                }

                var message = string.Format("{0} put {1}'s {2} {3}.", context.ActivePlayer, targetPlayer, card.Name, actionDescription);
                context.Game.Log.LogMessage(message);
            };

            return activity;
        }