RequestPlayerTrashCardFromHand() private method

private RequestPlayerTrashCardFromHand ( GameState gameState, CardPredicate acceptableCardsToTrash, bool isOptional, CollectionCards cardsTrashedSoFar = null ) : Dominion.Card
gameState GameState
acceptableCardsToTrash CardPredicate
isOptional bool
cardsTrashedSoFar CollectionCards
return Dominion.Card
Beispiel #1
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.victoryTokenCount += 1;
            Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCardsToTrash => true, isOptional: false);
            if (trashedCard != null)
            {
                currentPlayer.victoryTokenCount += trashedCard.CurrentCoinCost(currentPlayer) / 2;
            }

            foreach (PlayerState otherPlayer in gameState.players.OtherPlayers)
            {
                otherPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCardsToTrash => true, isOptional: true);
            }
        }
Beispiel #2
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.GainCardFromSupply(Silver.card, gameState);

            // look at the top card of the deck and discard or put it back
            Card card = currentPlayer.DrawAndLookAtOneCardFromDeck();
            if (card != null)
            {
                if (currentPlayer.actions.ShouldPlayerDiscardCardFromDeck(gameState, currentPlayer, card))
                {
                    currentPlayer.gameLog.PushScope();
                    currentPlayer.MoveLookedAtCardsToDiscard(gameState);
                    currentPlayer.gameLog.PlayerDiscardCard(currentPlayer, card);
                    currentPlayer.gameLog.PopScope();
                }
                else
                {
                    currentPlayer.MoveLookedAtCardToTopOfDeck(card);
                }
            }

            currentPlayer.DrawUntilCountInHand(5);

            currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => !acceptableCard.isTreasure, isOptional: true);
        }
Beispiel #3
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => true, false);

            int trashedCardCost = trashedCard.CurrentCoinCost(currentPlayer);

            currentPlayer.RequestPlayerGainCardFromSupply(gameState, card => card.CurrentCoinCost(currentPlayer) == (trashedCardCost - 1) && card.potionCost == trashedCard.potionCost, "Must gain a card costing one less than the trashed card.", isOptional: false, defaultLocation: DeckPlacement.TopOfDeck);
            currentPlayer.RequestPlayerGainCardFromSupply(gameState, card => card.CurrentCoinCost(currentPlayer) == (trashedCardCost + 1) && card.potionCost == trashedCard.potionCost, "Must gain a card costing exactly one more than the trashed card.", isOptional: false, defaultLocation: DeckPlacement.TopOfDeck);

            // TODO:  put the cards on top of your deck in either order.
            //throw new NotImplementedException();
        }
Beispiel #4
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.AddCoinTokens(2);

            int coinCount = currentPlayer.actions.GetCoinAmountToUseInButcher(gameState);
            if (coinCount > currentPlayer.AvailableCoinTokens)
                throw new Exception("Tried to use too many coins");

            Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => true, isOptional: true);
            if (trashedCard == null)
                return;

            currentPlayer.AddCoinTokens(-coinCount);

            currentPlayer.RequestPlayerGainCardFromSupply(
                gameState,
                card => card.CurrentCoinCost(currentPlayer) == trashedCard.CurrentCoinCost(currentPlayer) + coinCount &&
                        card.potionCost == trashedCard.potionCost,
                "Must gain a card costing exactly equal to the cost of the card trashed plus any coin spent");
        }
Beispiel #5
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => acceptableCard.isTreasure, isOptional: true);

            PlayerState.AttackAction attackAction = this.DoEmptyAttack;

            if (trashedCard != null)
            {
                attackAction = delegate(PlayerState currentPlayer2, PlayerState otherPlayer, GameState gameState2)
                {
                    if (otherPlayer.Hand.Count >= 5)
                    {
                        otherPlayer.DiscardCardFromHand(gameState, trashedCard);
                    }
                };

                currentPlayer.RequestPlayerGainCardFromSupply(gameState,
                    acceptableCard => acceptableCard.isTreasure &&
                                      acceptableCard.CurrentCoinCost(currentPlayer) <= trashedCard.CurrentCoinCost(currentPlayer) + 3 &&
                                      acceptableCard.potionCost == 0,
                    "Gain a card costing up to 3 more than the trashed card",
                    isOptional: false,
                    defaultLocation: DeckPlacement.TopOfDeck);
            }

            currentPlayer.AttackOtherPlayers(gameState, attackAction);
        }
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => true, false);

            int trashedCardCost = trashedCard.CurrentCoinCost(currentPlayer);

            CardPredicate validCard = card => (card.CurrentCoinCost(currentPlayer) == (trashedCardCost - 1)
                ^ card.CurrentCoinCost(currentPlayer) == (trashedCardCost + 1)) && card.potionCost == trashedCard.potionCost;

            Card gainedCard = currentPlayer.RequestPlayerGainCardFromSupply(gameState, validCard, "Must gain a card costing one less or one more than the trashed card.", isOptional: false, defaultLocation: DeckPlacement.TopOfDeck);
            if (gainedCard != null)
            {
                validCard = card => card.CurrentCoinCost(currentPlayer) == 2 * trashedCardCost - gainedCard.CurrentCoinCost(currentPlayer)
                    && card.potionCost == trashedCard.potionCost;

                currentPlayer.RequestPlayerGainCardFromSupply(gameState, validCard, "Must gain a card with the right cost.", isOptional: false, defaultLocation: DeckPlacement.TopOfDeck);
            }
        }
Beispiel #7
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     Card card = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => true, isOptional: false);
     if (card != null)
     {
         currentPlayer.AddCoins(card.CurrentCoinCost(currentPlayer));
     }
 }
Beispiel #8
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => true, isOptional: false);

            if (trashedCard.isAction)
                currentPlayer.GainCardFromSupply(Duchy.card, gameState);

            if (trashedCard.isTreasure)
                currentPlayer.GainCardFromSupply(Transmute.card, gameState);

            if (trashedCard.isVictory)
                currentPlayer.GainCardFromSupply(Gold.card, gameState);
        }
Beispiel #9
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => true, isOptional: false);
 }
Beispiel #10
0
        private new DeckPlacement DoSpecializedActionOnBuyWhileInHand(PlayerState currentPlayer, GameState gameState, Card gainedCard)
        {
            if (gainedCard.isVictory)
            {
                currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => card == Hovel.card, isOptional: true);
            }

            return DeckPlacement.Default;
        }
Beispiel #11
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => true, isOptional: false);
     currentPlayer.AddCoins(CurrentCoinValue(gameState));
 }
Beispiel #12
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     Card cardToTrash = currentPlayer.RequestPlayerTrashCardFromHand(gameState,
         card => card.isAction,
         true);
     if (cardToTrash == null)
     {
         currentPlayer.MoveCardFromPlayToTrash(gameState);
     }
 }
Beispiel #13
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.GainCardFromSupply(Cards.Rats, gameState);
     CardPredicate cardsToTrash = card => card != Rats.card;
     if (currentPlayer.Hand.HasCard(cardsToTrash))
     {
         currentPlayer.RequestPlayerTrashCardFromHand(gameState, cardsToTrash, isOptional: false);
     }
     else
     {
         currentPlayer.RevealHand();
     }
 }
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            currentPlayer.GainCardFromSupply(Silver.card, gameState);

            // look at the top card of the deck and discard or put it back
            currentPlayer.RequestPlayerInspectTopOfDeckForDiscard(currentPlayer, gameState, shouldReveal: false);
            currentPlayer.DrawUntilCountInHand(5, gameState);

            currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => !acceptableCard.isTreasure, isOptional: true);
        }
Beispiel #15
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            if (currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => card.isTreasure, isOptional:true) != null)
            {
                PlayerActionChoice choice = currentPlayer.RequestPlayerChooseBetween(
                    gameState,
                    acceptableChoice => acceptableChoice == PlayerActionChoice.PlusCard || acceptableChoice == PlayerActionChoice.PlusCoin);

                switch (choice)
                {
                    case PlayerActionChoice.PlusCard:
                    {
                        currentPlayer.DrawAdditionalCardsIntoHand(2);
                        currentPlayer.AddActions(1);
                        break;
                    }
                    case PlayerActionChoice.PlusCoin:
                    {
                        currentPlayer.AddCoins(2);
                        currentPlayer.AddBuys(1);
                        break;
                    }
                    default:
                        throw new Exception();
                }
            }
        }
Beispiel #16
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            int additionalCoins = gameState.supplyPiles.Where(pile => pile.ProtoTypeCard.isVictory && gameState.HasCardEverBeenGainedFromPile(pile)).Count();
            currentPlayer.AddCoins(additionalCoins);

            currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => true, isOptional: false);
        }
Beispiel #17
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, card => true, isOptional: false);
     if (trashedCard != null)
     {
         currentPlayer.GainCardsFromSupply(gameState, Silver.card, trashedCard.CurrentCoinCost(currentPlayer));
     }
 }
Beispiel #18
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            foreach (PlayerState player in gameState.players.AllPlayers)
            {
                player.cardToPass.Set(player.RequestPlayerGiveCardToPassLeft(gameState));
            }

            for (int playerIndex = 0; playerIndex < gameState.players.PlayerCount; ++playerIndex)
            {
                Card card = gameState.players[playerIndex].cardToPass.Card;
                if (card != null)
                {
                    gameState.players[playerIndex + 1].hand.AddCard(card);
                }
            }

            foreach (PlayerState player in gameState.players.AllPlayers)
            {
                player.cardToPass.Clear();
            }

            currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => true, isOptional: true);
        }
Beispiel #19
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card card = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => true, isOptional: false);

            if (card != null)
            {
                int cardsToDraw = card.CurrentCoinCost(currentPlayer) + 2 * card.potionCost;

                currentPlayer.DrawAdditionalCardsIntoHand(cardsToDraw, gameState);
            }
        }
Beispiel #20
0
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     Card card = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCardsToTrash => true, isOptional: false);
     if (card != null)
     {
         for (int i = 0; i < 2; ++i)
         {
             currentPlayer.RequestPlayerGainCardFromSupply(
                 gameState,
                 acceptableCard => acceptableCard.CurrentCoinCost(currentPlayer) < card.CurrentCoinCost(currentPlayer) &&
                                   acceptableCard.potionCost <= card.potionCost,
                 "Must gain 2 cards less than the trashed card");
         }
     }
 }
Beispiel #21
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card trashedCard = null;
            if (currentPlayer.actions.ShouldTrashCard(gameState, Cards.Raze))
            {
                if (currentPlayer.MoveCardFromPlayToTrash(gameState))
                    trashedCard = Cards.Raze;
            }
            else
            {
                trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, c => true, isOptional: false);
            }

            if (trashedCard == null)
                return;

            int cardsToLookAt = trashedCard.CurrentCoinCost(currentPlayer);
            if (cardsToLookAt == 0)
                return;

            currentPlayer.LookAtCardsFromDeck(cardsToLookAt, gameState);
            currentPlayer.RequestPlayerMoveRevealedCardToHand(gameState, c => true);
            currentPlayer.MoveLookedAtCardsToDiscard(gameState);
        }
Beispiel #22
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            PlayerActionChoice choice = currentPlayer.RequestPlayerChooseBetween(gameState,
                acceptableChoice => acceptableChoice == PlayerActionChoice.GainCard || acceptableChoice == PlayerActionChoice.Trash);

            if (choice == PlayerActionChoice.GainCard)
            {
                currentPlayer.RequestPlayerGainCardFromTrash(gameState,
                    acceptableCard => CardValidToGainFromTrash(acceptableCard, currentPlayer),
                    "Must gain a card costing between 3 and 6",
                    defaultLocation: DeckPlacement.TopOfDeck);
            }
            else
            {
                Card trashedCard = currentPlayer.RequestPlayerTrashCardFromHand(gameState, acceptableCard => CardValidToTrash(acceptableCard), isOptional: false);
                if (trashedCard != null)
                {
                    int maxCost = trashedCard.CurrentCoinCost(currentPlayer) + 3;
                    currentPlayer.RequestPlayerGainCardFromSupply(gameState,
                        acceptableCard => acceptableCard.CurrentCoinCost(currentPlayer) <= maxCost && acceptableCard.potionCost <= trashedCard.potionCost,
                        "gain a card costing up to 3 more than the trashed card");
                }
            }
        }