MoveRevealedCardsToDiscard() private method

private MoveRevealedCardsToDiscard ( CardPredicate predicate, GameState gameState ) : void
predicate CardPredicate
gameState GameState
return void
Beispiel #1
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            int countTreasureFound = 0;
            while (countTreasureFound < 2)
            {
                Card card = currentPlayer.DrawAndRevealOneCardFromDeck(gameState);
                if (card == null)
                {
                    break;
                }

                if (card.isTreasure)
                {
                    countTreasureFound += 1;
                    currentPlayer.MoveRevealedCardToHand(card);
                }
            }

            currentPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #2
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card foundCard = null;
            gameState.gameLog.PushScope();
            while (true)
            {
                foundCard = currentPlayer.DrawAndRevealOneCardFromDeck();
                if (foundCard == null)
                    break;

                if (foundCard.isAction || foundCard.isTreasure)
                {
                    break;
                }
            }
            gameState.gameLog.PopScope();

            if (foundCard != null)
            {
                currentPlayer.MoveRevealedCardToHand(foundCard);
            }

            currentPlayer.MoveRevealedCardsToDiscard(cardToMove => true, gameState);
        }
Beispiel #3
0
        public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
        {
            // Each other player reveals cards from the top of his deck
            Card revealedCard = otherPlayer.DrawAndRevealOneCardFromDeck();
            while (revealedCard != null)
            {
                // until he reveals a victory or curse card
                if (revealedCard.isVictory || revealedCard.isCurse)
                {
                    otherPlayer.MoveRevealedCardToTopOfDeck(revealedCard);
                    break;
                }
                revealedCard = otherPlayer.DrawAndRevealOneCardFromDeck();
            }

            otherPlayer.MoveRevealedCardsToDiscard(gameState);
        }
        public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
        {
            otherPlayer.RevealCardsFromDeck(2, gameState);

            if (!otherPlayer.CardsBeingRevealed.AnyWhere(card => card.isTreasure))
            {
                otherPlayer.GainCardFromSupply(Copper.card, gameState);
            }
            else
            {
                CardPredicate acceptableCard = card => card == Silver.card || card == Gold.card;
                Card trashedCard = currentPlayer.RequestPlayerTrashOtherPlayersRevealedCard(gameState, acceptableCard, otherPlayer);
                if (trashedCard != null)
                {
                    Card cardToGain = gameState.trash.RemoveCard(trashedCard);
                    currentPlayer.GainCard(gameState, cardToGain, DeckPlacement.Trash, DeckPlacement.Discard);
                }
            }

            otherPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #5
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            while (currentPlayer.hand.Count < 7)
            {
                Card revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck(gameState);
                if (revealedCard == null)
                {
                    break;
                }

                bool putCardInHand = !revealedCard.isAction || currentPlayer.actions.ShouldPutCardInHand(gameState, revealedCard);

                if (putCardInHand)
                {
                    currentPlayer.MoveRevealedCardToHand(revealedCard);
                }
            }

            currentPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #6
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.LookAtCardsFromDeck(5);
            PlayerActionChoice choice = currentPlayer.RequestPlayerChooseBetween(gameState,
                acceptableChoice => acceptableChoice == PlayerActionChoice.Discard ||
                                    acceptableChoice == PlayerActionChoice.TopDeck);

            if (choice == PlayerActionChoice.TopDeck)
            {
                currentPlayer.RequestPlayerTopDeckRevealedCardsInAnyOrder(gameState);
            }
            else if (choice == PlayerActionChoice.Discard)
            {
                currentPlayer.MoveRevealedCardsToDiscard(gameState);
            }
        }
Beispiel #7
0
        public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
        {
            otherPlayer.RevealCardsFromDeck(2);

            Card cardtoTrash = null;
            CardPredicate acceptableCards = card => card.isTreasure;
            if (otherPlayer.cardsBeingRevealed.HasCard(acceptableCards))
            {
                Card cardTypeToTrash = currentPlayer.actions.GetCardFromRevealedCardsToTrash(gameState, otherPlayer, acceptableCards);

                cardtoTrash = otherPlayer.cardsBeingRevealed.RemoveCard(cardTypeToTrash);
                if (cardtoTrash == null)
                {
                    throw new Exception("Must choose a revealed card to trash");
                }

                if (!acceptableCards(cardtoTrash))
                {
                    throw new Exception("Player Must choose a treasure card to trash");
                }

                otherPlayer.MoveCardToTrash(cardtoTrash, gameState);
            }

            if (cardtoTrash != null)
            {
                if (currentPlayer.actions.ShouldGainCard(gameState, cardtoTrash))
                {
                    Card cardToGain = gameState.trash.RemoveCard(cardtoTrash);
                    currentPlayer.GainCard(gameState, cardToGain, originalLocation:DeckPlacement.Trash, defaultPlacement:DeckPlacement.Discard);
                }
            }

            otherPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #8
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.RevealCardsFromDeck(4);

            while (currentPlayer.cardsBeingRevealed.Any())
            {
                if (currentPlayer.RequestPlayerTopDeckCardFromRevealed(gameState, true) == null)
                {
                    break;
                }
            }

            currentPlayer.MoveRevealedCardsToDiscard(gameState);
        }
 public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
 {
     otherPlayer.RevealCardsFromDeck(3, gameState);
     otherPlayer.MoveRevealedCardsToDiscard(card => card.isAction || card.isTreasure, gameState);
     otherPlayer.RequestPlayerPutRevealedCardsBackOnDeck(gameState);
 }
Beispiel #10
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            while (true)
            {
                Card revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck(gameState);
                if (revealedCard == null)
                    break;
                if (revealedCard.isTreasure)
                {
                    if (currentPlayer.actions.ShouldTrashCard(gameState, revealedCard))
                    {
                        currentPlayer.MoveRevealedCardToTrash(revealedCard, gameState);
                    }
                    else
                    {
                        currentPlayer.MoveRevealedCardToDiscard(revealedCard, gameState);
                    }
                    break;
                }
            }

            currentPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #11
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.RevealCardsFromDeck(3);
     PlayerActionChoice choice = currentPlayer.RequestPlayerChooseBetween(gameState, actionChoice => actionChoice == PlayerActionChoice.Discard || actionChoice == PlayerActionChoice.PutInHand);
     switch (choice)
     {
         case PlayerActionChoice.Discard:
             {
                 currentPlayer.MoveRevealedCardsToDiscard(gameState);
                 currentPlayer.DrawAdditionalCardsIntoHand(3);
                 break;
             }
         case PlayerActionChoice.PutInHand:
             {
                 currentPlayer.MoveAllRevealedCardsToHand();
                 break;
             }
         default:
             throw new Exception();
     }
 }
Beispiel #12
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.RevealCardsFromDeck(3);
     currentPlayer.MoveRevealedCardsToDiscard(card => !card.isAction, gameState);
     currentPlayer.RequestPlayerPutRevealedCardsBackOnDeck(gameState);
 }
Beispiel #13
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     while (true)
     {
         Card card = currentPlayer.DrawAndRevealOneCardFromDeck();
         if (card == null)
             break;
         if (card.CurrentCoinCost(currentPlayer) >= 3 && card.potionCost == 0)
         {
             currentPlayer.MoveRevealedCardToHand(card);
             break;
         }
     }
     currentPlayer.MoveRevealedCardsToDiscard(gameState);
 }
Beispiel #14
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card cardType = currentPlayer.RequestPlayerNameACard(gameState);

            Card foundCard = null;
            gameState.gameLog.PushScope();
            while (true)
            {
                foundCard = currentPlayer.DrawAndRevealOneCardFromDeck();
                if (foundCard == null)
                    break;

                if (foundCard.isVictory && foundCard != cardType)
                {
                    break;
                }
            }
            currentPlayer.MoveRevealedCardsToDiscard(cardToMove => !cardToMove.Equals(foundCard), gameState);
            gameState.gameLog.PopScope();

            if (foundCard != null)
            {
                int cardCost = foundCard.CurrentCoinCost(currentPlayer);
                currentPlayer.MoveRevealedCardToTrash(foundCard, gameState);
                currentPlayer.RequestPlayerGainCardFromSupply(gameState,
                    acceptableCard => acceptableCard.isVictory && acceptableCard.CurrentCoinCost(currentPlayer) <= cardCost + 3 && acceptableCard.potionCost == foundCard.potionCost,
                    "Gain a victory card costing up to 3 more than the trashed card.");
            }
        }
 public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
 {
     otherPlayer.RevealCardsFromDeck(2, gameState);
     PlayerActionChoice choice = currentPlayer.RequestPlayerChooseBetween(gameState, actionChoice => actionChoice == PlayerActionChoice.Discard || actionChoice == PlayerActionChoice.TopDeck);
     switch (choice)
     {
         case PlayerActionChoice.Discard:
             {
                 otherPlayer.MoveRevealedCardsToDiscard(gameState);
                 break;
             }
         case PlayerActionChoice.TopDeck:
             {
                 otherPlayer.RequestPlayerTopDeckRevealedCardsInAnyOrder(gameState);
                 break;
             }
         default:
             throw new Exception();
     }
 }
Beispiel #16
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card namedCard = currentPlayer.RequestPlayerNameACard(gameState);

            int cardFoundCount = 0;
            while(true)
            {
                Card revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck(gameState);
                if (revealedCard == null)
                    break;
                if (revealedCard == namedCard)
                    continue;
                cardFoundCount++;
                if (cardFoundCount >= 3)
                    break;
            }

            currentPlayer.MoveRevealedCardsToHand(card => card != namedCard);
            currentPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #17
0
        public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
        {
            otherPlayer.RevealCardsFromDeck(2);

            Card cardtoTrash = null;
            CardPredicate acceptableCards = card => card == Silver.card || card == Gold.card;
            if (otherPlayer.cardsBeingRevealed.HasCard(acceptableCards))
            {
                Card cardTypeToTrash = currentPlayer.actions.GetCardFromRevealedCardsToTrash(gameState, otherPlayer, acceptableCards);

                cardtoTrash = otherPlayer.cardsBeingRevealed.RemoveCard(cardTypeToTrash);
                if (cardtoTrash == null)
                {
                    throw new Exception("Must choose a revealed card to trash");
                }

                if (!acceptableCards(cardtoTrash))
                {
                    throw new Exception("Player Must choose a treasure card to trash");
                }

                otherPlayer.MoveCardToTrash(cardtoTrash, gameState);
            }

            if (!otherPlayer.CardsBeingRevealed.Where(card => card.isTreasure).Any())
            {
                otherPlayer.GainCardFromSupply(Copper.card, gameState);
            }

            if (cardtoTrash != null)
            {
                Card cardToGain = gameState.trash.RemoveCard(cardtoTrash);
                currentPlayer.GainCard(gameState, cardToGain, DeckPlacement.Trash, DeckPlacement.Discard);
            }

            otherPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #18
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card cardToPlay = null;
            while (true)
            {
                Card revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck(gameState);
                if (revealedCard == null)
                {
                    break;
                }
                if (revealedCard.isTreasure)
                {
                    cardToPlay = currentPlayer.cardsBeingRevealed.RemoveCard(revealedCard);
                    break;
                }
            }
            currentPlayer.MoveRevealedCardsToDiscard(gameState);

            if (cardToPlay != null)
            {
                currentPlayer.DoPlayTreasure(cardToPlay, gameState);
            }
        }
Beispiel #19
0
 private static void ApplySpyEffect(PlayerState playerAffected, PlayerState decidingPlayer, GameState gameState)
 {
     Card revealedCard = playerAffected.DrawAndRevealOneCardFromDeck();
     if (revealedCard != null)
     {
         if (decidingPlayer.actions.ShouldPlayerDiscardCardFromDeck(gameState, playerAffected, revealedCard))
         {
             playerAffected.MoveRevealedCardsToDiscard(gameState);
         }
         else
         {
             playerAffected.MoveRevealedCardToTopOfDeck(revealedCard);
         }
     }
 }
Beispiel #20
0
        public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
        {
            // Each other player reveals cards from the top of his deck
            Card revealedCard = otherPlayer.DrawAndRevealOneCardFromDeck();
            while (revealedCard != null)
            {
                // until revealing one costing 3 or more
                if (revealedCard.CurrentCoinCost(otherPlayer) >= 3)
                {
                    break;
                }
                revealedCard = otherPlayer.DrawAndRevealOneCardFromDeck();
            }

            if (revealedCard != null)
            {
                // He trashess that card and
                otherPlayer.MoveRevealedCardToTrash(revealedCard, gameState);
                // may gain a card costing at most 2 less than it.
                otherPlayer.RequestPlayerGainCardFromSupply(
                    gameState,
                    acceptableCard => acceptableCard.CurrentCoinCost(currentPlayer) <= revealedCard.CurrentCoinCost(currentPlayer) - 2 &&
                                      acceptableCard.potionCost <= revealedCard.potionCost,
                    "Must gain a card costing at most 2 less than the trashed card",
                    isOptional: true);
            }

            // he discards the other revealed cards
            otherPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #21
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            gameState.gameLog.PushScope();

            Card actionOne = DrawAndRevealTillFindAnActionIsntGolem(currentPlayer, gameState);
            Card actionTwo = DrawAndRevealTillFindAnActionIsntGolem(currentPlayer, gameState);

            currentPlayer.MoveRevealedCardsToDiscard(cardToMove => !cardToMove.Equals(actionOne) && !cardToMove.Equals(actionTwo), gameState);
            // set the cards asside in case golem plays other cards that also must be revealed.
            currentPlayer.MoveRevealedCardsToSetAside();

            if (actionOne != null && actionTwo != null)
            {
                Card cardToPlayFirst = currentPlayer.actions.ChooseCardToPlayFirst(gameState, actionOne, actionTwo);
                if (cardToPlayFirst != actionOne && cardToPlayFirst != actionTwo)
                {
                    throw new Exception("Must pick one of the actions to player first");
                }

                // swap order;
                if (cardToPlayFirst == actionTwo)
                {
                    actionTwo = actionOne;
                    actionOne = cardToPlayFirst;
                }
            }

            if (actionOne != null)
            {
                currentPlayer.cardsSetAside.RemoveCard(actionOne);
                currentPlayer.DoPlayAction(actionOne, gameState);
            }

            if (actionTwo != null)
            {
                currentPlayer.cardsSetAside.RemoveCard(actionTwo);
                currentPlayer.DoPlayAction(actionTwo, gameState);
            }

            gameState.gameLog.PopScope();
        }
Beispiel #22
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card cardType = currentPlayer.GuessCardTopOfDeck(gameState);

            Card revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck();
            if (revealedCard != cardType)
            {
                currentPlayer.MoveAllRevealedCardsToHand();
            }
            else
            {
                currentPlayer.MoveRevealedCardsToDiscard(gameState);
            }
        }
Beispiel #23
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.RevealCardsFromDeck(4);
     currentPlayer.AddCoins(currentPlayer.cardsBeingRevealed.CountTypes);
     currentPlayer.MoveRevealedCardsToDiscard(gameState);
 }
Beispiel #24
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.RevealHand();

            Card revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck();
            while (revealedCard != null)
            {
                if (!currentPlayer.Hand.HasCard(revealedCard))
                {
                    currentPlayer.MoveRevealedCardToHand(revealedCard);
                    break;
                }
                revealedCard = currentPlayer.DrawAndRevealOneCardFromDeck();
            }

            currentPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #25
0
        public override void DoSpecializedAttack(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
        {
            otherPlayer.RevealCardsFromDeck(2, gameState);

            Card trashedCard = currentPlayer.RequestPlayerTrashOtherPlayersRevealedCard(gameState, card => card.isTreasure, otherPlayer);

            if (trashedCard != null)
            {
                if (currentPlayer.actions.ShouldGainCard(gameState, trashedCard))
                {
                    Card cardToGain = gameState.trash.RemoveCard(trashedCard);
                    currentPlayer.GainCard(gameState, cardToGain, originalLocation:DeckPlacement.Trash, defaultPlacement:DeckPlacement.Discard);
                }
            }

            otherPlayer.MoveRevealedCardsToDiscard(gameState);
        }
Beispiel #26
0
 private static void AttackAction(PlayerState currentPlayer, PlayerState otherPlayer, GameState gameState)
 {
     otherPlayer.RevealCardsFromDeck(2, gameState);
     otherPlayer.RequestPlayerTrashRevealedCard(gameState, card => Card.DoesCardCost3To6(card, otherPlayer));
     otherPlayer.MoveRevealedCardsToDiscard(gameState);
 }