Esempio n. 1
0
        // +1 Action
        // +1 Card
        // Each player (including you) reveals the top card of his deck and either discards it or puts it back,
        // your choice.
        private void ResolveCardSpy(Player activePlayer, Card cardToResolve)
        {
            activePlayer.DrawCards(1);
            activePlayer.AddAction(1);

            using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1))
            {
                loop.Reset();
                while (loop.MoveNext())
                {
                    var player = loop.Current;

                    if (player == activePlayer || !TryDefendAttack(player))
                    {
                        var revealedCard = player.RevealTopCardFromDeck();
                        if (revealedCard != null)
                        {
                            writer.WriteLine("{0} revealed {1}", player.Name, revealedCard.Info.CardName);
                            writer.Write("Would you like to discard it?");
                            if (Texts.ParseBoolean(reader.ReadLine()) ?? true)
                            {
                                player.DiscardRevealCard(revealedCard);
                            }
                            else
                            {
                                player.UnrevealCardToTopDeck(revealedCard);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        // +1 Buy
        // +4 Cards
        // Each other player draws a card
        private void ResolveCardCouncilRoom(Player activePlayer, Card cardToResolve)
        {
            activePlayer.DrawCards(4);
            activePlayer.AddBuy(1);

            using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1))
            {
                loop.Reset();
                while (loop.MoveNext())
                {
                    var player = loop.Current;
                    if (player != activePlayer)
                    {
                        player.DrawCards(1);
                    }
                }
            }
        }
Esempio n. 3
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);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        // +2 Cards
        // Each other player gains a Curse
        private void ResolveCardWitch(Player activePlayer, Card cardToResolve)
        {
            activePlayer.DrawCards(2);

            using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1))
            {
                loop.Reset();
                while (loop.MoveNext())
                {
                    var player = loop.Current;
                    if (player != activePlayer && !TryDefendAttack(player))
                    {
                        var cardToGain = supply.GetCard(CardCentral.Shared.GetCardInfo("Curse"));
                        if (cardToGain != null)
                        {
                            player.GainCard(cardToGain);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        // Gain a silver. Put it on top of your deck
        // Each other player reveals a Victory card from his hand and puts it on his deck
        // (or reveals a hand with no Victory cards)
        private void ResolveCardBureaucrat(Player activePlayer, Card cardToResolve)
        {
            var cardToGain = supply.GetCard(CardCentral.Shared.GetCardInfo("Silver"));

            if (cardToGain != null)
            {
                activePlayer.GainCardOnDeck(cardToGain);
            }

            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);

                        Card cardToReveal;
                        do
                        {
                            writer.Write("{0}, select a victory card to reveal (empty to skip and reveal the whole hand):", player.Name);
                            var cardNameToReveal = Texts.Trim(reader.ReadLine());
                            if (string.IsNullOrEmpty(cardNameToReveal))
                            {
                                cardToReveal = null;

                                if (!player.HasVictoryCardOnHand())
                                {
                                    break;
                                }

                                writer.Write("You cannot skip as you have victory cards in hand");
                            }
                            else
                            {
                                cardToReveal = player.FindCardOnHand(cardNameToReveal);
                                if (cardToReveal == null)
                                {
                                    writer.WriteLine("{0} is not in your hand", cardNameToReveal);
                                }
                                else if (!cardToReveal.Info.IsVictoryCard)
                                {
                                    writer.WriteLine("{0} is not a victory card", cardToReveal.Info.CardName);
                                    cardToReveal = null;
                                }
                            }
                        } while (cardToReveal == null);

                        if (cardToReveal != null)
                        {
                            player.RevealHandCard(cardToReveal);
                            player.DisplayRevealCards(writer);
                            player.UnrevealCardToTopDeck(cardToReveal);
                        }
                        else
                        {
                            var handCards = player.RevealAllHandCards();
                            player.DisplayRevealCards(writer);
                            player.UnrevealCardsToHand(handCards);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        // Each other player reveals the top 2 cards of his deck.
        // If they revealed any Treasure cards, they trash one of them that you choose.
        // You may gain any or all of these trashed cards. They discard the other revealed cards.
        private void ResolveCardThief(Player activePlayer, Card cardToResolve)
        {
            var tempTrashCards = new List <Card>();

            using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1))
            {
                loop.Reset();
                while (loop.MoveNext())
                {
                    var player = loop.Current;
                    if (player != activePlayer && !TryDefendAttack(player))
                    {
                        var treasureCards = new List <Card>();
                        var revealedCards = new List <Card>(2);
                        while (revealedCards.Count < 2)
                        {
                            var revealedCard = player.RevealTopCardFromDeck();
                            if (revealedCard == null)
                            {
                                break;
                            }

                            revealedCards.Add(revealedCard);

                            if (revealedCard.Info.IsTreasureCard)
                            {
                                treasureCards.Add(revealedCard);
                            }
                        }

                        if (treasureCards.Count > 0)
                        {
                            writer.Write("{0} has revealed {1} treasure cards:", player.Name, treasureCards.Count);
                            foreach (var card in treasureCards)
                            {
                                writer.Write(card.Info.CardName);
                                writer.Write(", ");
                            }
                            writer.WriteLine();

                            Card cardToTrash;
                            do
                            {
                                writer.Write("Choose one to trash:");
                                var cardNameToTrash = Texts.Trim(reader.ReadLine());
                                cardToTrash = Card.FindCard(cardNameToTrash, treasureCards);

                                if (cardToTrash == null)
                                {
                                    writer.WriteLine("{0} is not in the options", cardNameToTrash);
                                }
                            } while (cardToTrash == null);

                            player.TrashRevealCard(cardToTrash, tempTrashCards);
                            revealedCards.Remove(cardToTrash);
                        }

                        player.DiscardRevealCards(revealedCards.ToArray());
                    }
                }
            }

            if (tempTrashCards.Count > 0)
            {
                writer.Write("Trash cards to gain:");
                foreach (var card in tempTrashCards)
                {
                    writer.Write(card.Info.CardName);
                    writer.Write(", ");
                }
                writer.WriteLine();

                writer.Write("Choose which to gain (type all to gain all):");
                var    cardNamesToGain = Texts.SplitCsv(reader.ReadLine());
                Card[] cardsToGain;
                if (cardNamesToGain.Length == 1 && "all".Equals(cardNamesToGain[0], StringComparison.OrdinalIgnoreCase))
                {
                    cardsToGain = tempTrashCards.ToArray();
                }
                else
                {
                    cardsToGain = Card.FindCards(cardNamesToGain, tempTrashCards);
                }

                activePlayer.GainCards(cardsToGain);
                tempTrashCards.RemoveRange(cardsToGain);
            }

            trashCards.AddRange(tempTrashCards);
        }