Exemplo n.º 1
0
        // +2 Coins
        // Each other player discards down to 3 cards in his hand.
        private void ResolveCardMilitia(Player activePlayer, Card cardToResolve)
        {
            activePlayer.AddCoinBonus(2);

            using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1))
            {
                loop.Reset();
                while (loop.MoveNext())
                {
                    var player = loop.Current;
                    if (player != activePlayer && !TryDefendAttack(player))
                    {
                        player.DisplayInfo(writer);
                        while (player.HandCardsCount > 3)
                        {
                            writer.Write("{0}, choose {1} cards to discard:", player.Name, player.HandCardsCount - 3);
                            String discardCards;
                            if (player is AIPlayer)
                            {
                                discardCards = SpecialActionAI.ResolveCardMilitiaAI(player);
                                writer.Write(discardCards);
                                writer.WriteLine();
                            }
                            else
                            {
                                discardCards = reader.ReadLine();
                            }
                            var cardsToDiscard = player.FindCardsOnHand(Texts.SplitCsv(discardCards));
                            if (cardsToDiscard.Length == player.HandCardsCount - 3)
                            {
                                player.DiscardHandCards(cardsToDiscard);
                            }
                            else
                            {
                                writer.WriteLine("You must choose exactly {0} cards to discard", player.HandCardsCount - 3);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        // +1 Action
        // Discard any number of cards. +1 Card per card discard
        private void ResolveCardCellar(Player activePlayer, Card cardToResolve)
        {
            activePlayer.AddAction(1);

            writer.Write("cards to discard:");
            String discardCards;

            if (activePlayer is AIPlayer)
            {
                discardCards = SpecialActionAI.ResolveCardCellarAI(activePlayer);
                writer.Write(discardCards);
                writer.WriteLine();
            }
            else
            {
                discardCards = reader.ReadLine();
            }
            var cardsToDiscard = activePlayer.FindCardsOnHand(Texts.SplitCsv(discardCards));

            activePlayer.DiscardHandCards(cardsToDiscard);
            activePlayer.DrawCards(cardsToDiscard.Length);
        }
Exemplo n.º 3
0
        // Trash a card from your hand. Gain a card costing up to +2 coins more than the trashed card.
        private void ResolveCardRemodel(Player activePlayer, Card cardToResolve)
        {
            Card cardToTrash;

            do
            {
                writer.Write("select a card to trash (empty to skip):");
                string trashCard;
                if (activePlayer is AIPlayer)
                {
                    trashCard = SpecialActionAI.ResolveCardRemodelTrashCardAI(activePlayer);
                    writer.Write(trashCard);
                    writer.WriteLine();
                }
                else
                {
                    trashCard = reader.ReadLine();
                }
                var cardNameToTrash = Texts.Trim(trashCard);
                if (string.IsNullOrEmpty(cardNameToTrash))
                {
                    cardToTrash = null;

                    if (activePlayer.HandCardsCount == 0)
                    {
                        break;
                    }

                    writer.Write("You cannot skip as you have cards in hand");
                }
                else
                {
                    cardToTrash = activePlayer.FindCardOnHand(cardNameToTrash);
                    if (cardToTrash == null)
                    {
                        writer.WriteLine("{0} is not in your hand", cardNameToTrash);
                    }
                }
            } while (cardToTrash == null);

            if (cardToTrash != null)
            {
                activePlayer.TrashHandCard(cardToTrash, trashCards);

                Card cardToGain;
                do
                {
                    writer.Write("select a card to gain (up to {0} coins):", cardToTrash.Info.Cost + 2);
                    string gainCard;
                    if (activePlayer is AIPlayer)
                    {
                        gainCard = SpecialActionAI.ResolveCardRemodelGainCardAI(this, activePlayer, cardToTrash);
                        writer.Write(gainCard);
                        writer.WriteLine();
                    }
                    else
                    {
                        gainCard = reader.ReadLine();
                    }

                    var cardNameToGain = Texts.Trim(gainCard);
                    var cardInfoToGain = CardCentral.Shared.GetCardInfo(cardNameToGain);
                    if (cardInfoToGain == null)
                    {
                        writer.WriteLine("unknown card " + cardNameToGain);
                        cardToGain = null;
                    }
                    else if (cardInfoToGain.Cost > cardToTrash.Info.Cost + 2)
                    {
                        writer.WriteLine("{0} is too expensive to gain", cardInfoToGain.CardName);
                        cardToGain = null;
                    }
                    else
                    {
                        cardToGain = supply.GetCard(cardInfoToGain);
                        if (cardToGain == null)
                        {
                            writer.WriteLine("{0} is not in supply", cardInfoToGain.CardName);
                        }
                    }
                } while (cardToGain == null);

                activePlayer.GainCard(cardToGain);
            }
        }