Exemplo n.º 1
0
            public override void Resolve(TurnContext context)
            {
                var player = context.ActivePlayer;
                var log = context.Game.Log;

                if (player.Hand.OfType<IActionCard>().Any())
                {
                    var activity = new SelectCardsActivity(
                        log, player,
                        "Select an action to play twice",
                        SelectionSpecifications.SelectExactlyXCards(1));

                    activity.Specification.CardTypeRestriction = typeof (IActionCard);
                    activity.AfterCardsSelected = cards =>
                    {
                        var actionCard = cards.OfType<IActionCard>().Single();
                        log.LogMessage("{0} selected {1} to be played twice.", player.Name, actionCard.Name);

                        actionCard.MoveTo(player.PlayArea);

                        actionCard.Play(context);
                        actionCard.Play(context);
                    };

                    _activities.Add(activity);
                }
                    
            }
Exemplo n.º 2
0
            public override void OnTurnStarting(TurnContext context)
            {
                base.OnTurnStarting(context);

                context.DrawCards(1);
                context.Game.Log.LogMessage("Caravan draws an extra card");
            }
Exemplo n.º 3
0
            public override void Resolve(TurnContext context, ICard source)
            {
                var estate = context.ActivePlayer.Hand.OfType<Estate>().FirstOrDefault();

                Action discardAction = () =>
                {
                    context.AvailableSpend += 4;
                    context.DiscardCard(context.ActivePlayer, estate);
                };

                Action gainAction = () => new GainUtility(context, context.ActivePlayer).Gain<Estate>();

                if (estate != null)
                {
                    var activity = Activities.ChooseYesOrNo
                        (context.Game.Log, context.ActivePlayer, "Discard an Estate?",
                         source,
                         discardAction, gainAction);

                    _activities.Add(activity);
                }
                else
                {
                    gainAction();
                }
            }
Exemplo n.º 4
0
            public override void Resolve(TurnContext context, ICard source)
            {
                var upgradeActivity = new SelectCardsActivity(context, "Select a card to Upgrade",
                    SelectionSpecifications.SelectExactlyXCards(1), source);

                upgradeActivity.AfterCardsSelected = cardList =>
                {
                    var player = context.ActivePlayer;
                    var cardToUpgrade = cardList.Single();
                    var upgradeCost = cardToUpgrade.Cost + 1;
                    context.Trash(player, cardToUpgrade);

                    if (context.Game.Bank.Piles.Any(p => !p.IsEmpty && p.TopCard.Cost == upgradeCost))
                    {
                        var gainActivity = Activities.GainACardCostingExactlyX(context.Game.Log, player,
                            upgradeCost, player.Discards, source);
                        _activities.Add(gainActivity);
                    }
                    else
                    {
                        context.Game.Log.LogMessage("{0} could gain no card of appropriate cost", player);
                    }
                };

                _activities.Add(upgradeActivity);
            }
Exemplo n.º 5
0
 public void OnTurnStarting(TurnContext context)
 {
     context.RemainingActions += 1;
     context.AvailableSpend += 1;
     IsFinished = true;
     context.Game.Log.LogMessage("FishingVillage adds one action and one spend");
 }
Exemplo n.º 6
0
        public void Play(TurnContext context)
        {
            context.RemainingActions += 2;
            context.AvailableSpend += 1;

            context.AddLongLivedEffect(new FishingVillageEffect(this));
        }
Exemplo n.º 7
0
 public void Play(TurnContext context)
 {
     context.DrawCards(1);
     context.RemainingActions += 1;
     context.Buys += 1;
     context.AvailableSpend += 1;
 }
Exemplo n.º 8
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                var victoryTypes = victim.Hand.OfType<IVictoryCard>()
                    .WithDistinctTypes()
                    .ToList();

                if(victoryTypes.Count() > 1)
                {
                    var activity = Activities.PutCardOfTypeFromHandOnTopOfDeck(context.Game.Log, victim,
                                                                               "Select a victory card to put on top",
                                                                               typeof (IVictoryCard),
                                                                               source);
                   _activities.Add(activity);
                }
                else if(victoryTypes.Any())
                {
                    var card = victoryTypes.Single();
                    victim.Deck.MoveToTop(card);
                    context.Game.Log.LogMessage("{0} put a {1} on top of the deck.", victim.Name, card.Name);
                }
                else
                {
                    context.Game.Log.LogRevealHand(victim);
                }
            }
Exemplo n.º 9
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                var swindledCard = victim.Deck.TopCard;
                if(swindledCard == null)
                {
                    context.Game.Log.LogMessage("{0} did not have any cards to be swindled.", victim.Name);
                    return;
                }
                
                context.Trash(victim, swindledCard);
                var candidates = context.Game.Bank.Piles.Where(p => p.IsEmpty == false && p.TopCard.Cost == swindledCard.Cost);                

                if(candidates.Count() == 0)
                {
                    context.Game.Log.LogMessage("There are no cards of cost {0}.", swindledCard.Cost);
                }
                else if (candidates.Count() == 1)
                {
                    var pile = candidates.Single();
                    var card = pile.TopCard;
                    card.MoveTo(victim.Discards);
                    context.Game.Log.LogGain(victim, card);
                }
                else
                {
                    var activity = Activities.SelectACardForOpponentToGain(context, context.ActivePlayer, victim, swindledCard.Cost, source);
                    _activities.Add(activity);    
                }
            }
Exemplo n.º 10
0
            public override void Resolve(TurnContext context, ICard source)
            {
                base.Resolve(context, source);

                if(context.ActivePlayer.Deck.TopCard != null)
                    _activities.Add(Activities.ChooseWhetherToMillTopCard(context, context.ActivePlayer, context.ActivePlayer, source));
            }
Exemplo n.º 11
0
        public void Play(TurnContext context)
        {
            context.DrawCards(1);
            context.RemainingActions += 1;

            context.AddEffect(this, new UpgradeEffect());
        }
Exemplo n.º 12
0
        public void Play(TurnContext context)
        {
            context.RemainingActions += 1;
            context.DrawCards(1);

            context.AddLongLivedEffect(new CaravanEffect(this));
        }
Exemplo n.º 13
0
        public void Play(TurnContext context)
        {
            context.DrawCards(4);
            context.Buys += 1;

            foreach (var opponent in context.Opponents)
                opponent.DrawCards(1);
        }
Exemplo n.º 14
0
 private void DoTrash(TurnContext context, ICard source)
 {
     if (context.ActivePlayer.Hand.CardCount > 0)
     {
         var activity = Activities.SelectUpToXCardsToTrash(context, context.ActivePlayer, 1, source);
         _activities.Add(activity);
     }
 }
Exemplo n.º 15
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                if (victim.Deck.CardCount + victim.Discards.CardCount > 0)
                    victim.Deck.MoveTop(1, victim.Discards);

                var gainUtil = new GainUtility(context, victim);
                gainUtil.Gain<Curse>(c => victim.Deck.MoveToTop(c));
            }
Exemplo n.º 16
0
 public override void Attack(Player victim, TurnContext context, ICard source)
 {
     if (victim.Hand.CardCount > 4)
     {
         context.DiscardCards(victim, victim.Hand);
         victim.DrawCards(4);
     }
 }
Exemplo n.º 17
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                int cardsToPutBack = victim.Hand.CardCount - 3;

                var activities = Activities.PutMultipleCardsFromHandOnTopOfDeck(context.Game.Log, victim, cardsToPutBack, source);
                foreach(var activity in activities)
                    _activities.Add(activity);
            }
Exemplo n.º 18
0
            public override void Attack(Player player, TurnContext context, ICard source)
            {
                if (player.Deck.CardCount + player.Discards.CardCount > 0)
                    player.Deck.MoveTop(1, player.Discards);

                var gainUtil = new GainUtility(context, player);
                gainUtil.Gain<Curse>(c => player.Deck.MoveToTop(c));
            }
Exemplo n.º 19
0
 public virtual void BeginResolve(TurnContext currentTurn)
 {
     if (!_isResolved)
     {
         _isResolved = true;
         Resolve(currentTurn);
     }
 }
Exemplo n.º 20
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;
 }
Exemplo n.º 21
0
            public override void OnTurnStarting(TurnContext context)
            {
                base.OnTurnStarting(context);

                context.RemainingActions += 1;
                context.AvailableSpend += 1;
                context.Game.Log.LogMessage("FishingVillage adds one action and one spend");
            }
Exemplo n.º 22
0
 public override void Resolve(TurnContext context, ICard source)
 {
     if (context.ActivePlayer.Hand.OfType<Copper>().Any())
     {
         var copperCard = context.ActivePlayer.Hand.OfType<Copper>().FirstOrDefault();
         context.Trash(context.ActivePlayer, copperCard);
         context.AvailableSpend += 3;
     };
 }
Exemplo n.º 23
0
            public override void OnTurnStarting(TurnContext context)
            {
                base.OnTurnStarting(context);

                context.DrawCards(5);
                context.RemainingActions += 1;
                context.Buys += 1;
                context.Game.Log.LogMessage("Tactician gives {0} +5 cards, +1 action and +1 buy.", context.ActivePlayer.Name);
            }
Exemplo n.º 24
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                var copper = victim.Hand.FirstOrDefault(c => c is Copper);

                if (copper != null)
                    context.DiscardCard(victim, copper);
                else
                    context.Game.Log.LogRevealHand(victim);
            }
Exemplo n.º 25
0
            public override void Resolve(TurnContext context)
            {
                var choiceActivity = new ChoiceActivity(context, context.ActivePlayer, 
                    "Choose from: Draw 3 cards, gain 2 actions", 
                    Choice.DrawCards, Choice.GainActions);
                choiceActivity.ActOnChoice = c => Execute(context, c);

                _activities.Add(choiceActivity);
            }
Exemplo n.º 26
0
        public void Play(TurnContext context)
        {
            context.RemainingActions += 2;

            context.Game.Log.LogRevealHand(context.ActivePlayer);
            
            if (context.ActivePlayer.Hand.OfType<IActionCard>().Count() == 0) 
                context.DrawCards(2);
        }
Exemplo n.º 27
0
        public override void Resolve(TurnContext context)
        {
            foreach(var opponent in context.Opponents)
            {
                var reactions = opponent.Hand.OfType<IReactionCard>();

                if(reactions.Count() > 0)
                    _activities.Add(new SelectReactionActivity(context, opponent, _attackEffect));                
            }
        }
Exemplo n.º 28
0
            public override void Attack(Player victim, TurnContext context, ICard source)
            {
                var numberToDiscard = victim.Hand.CardCount - 3;

                if (numberToDiscard > 0)
                    _activities.Add(Activities.DiscardCards(context, victim, numberToDiscard, source));
                else
                {
                    context.Game.Log.LogMessage("{0} did not have to discard any cards.", victim.Name);
                }
            }            
Exemplo n.º 29
0
            public override void Attack(Player player, TurnContext context)
            {
                var numberToDiscard = player.Hand.CardCount - 3;

                if (numberToDiscard > 0)
                    _activities.Add(Activities.DiscardCards(context, player, numberToDiscard));
                else
                {
                    context.Game.Log.LogMessage("{0} did not have to discard any cards.", player.Name);
                }
            }            
Exemplo n.º 30
0
            public override void Attack(Player player, TurnContext context)
            {
                var revealZone = new RevealZone(player);
                player.Deck.MoveTop(3, revealZone);

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

                foreach (var activity in Activities.SelectMultipleRevealedCardsToPutOnTopOfDeck(context.Game.Log, player, revealZone))
                    _activities.Add(activity);
            }
Exemplo n.º 31
0
        public TurnContext BeginTurn(Game game)
        {
            var context = new TurnContext(this, game);

            return(context);
        }
Exemplo n.º 32
0
 public abstract void Attack(Player victim, TurnContext context, ICard source);
Exemplo n.º 33
0
 public abstract void Resolve(TurnContext context, ICard source);
Exemplo n.º 34
0
 public override void Resolve(TurnContext context, ICard source)
 {
     DistributeAttacks(context, source);
 }
Exemplo n.º 35
0
 public override void Resolve(TurnContext context, ICard source)
 {
     _activities.Add(_activity);
 }