Dominion.PlayerState.RequestPlayerChooseCardFromSupplyToPlay C# (CSharp) Method

RequestPlayerChooseCardFromSupplyToPlay() private method

private RequestPlayerChooseCardFromSupplyToPlay ( GameState gameState, CardPredicate acceptableCard ) : Dominion.Card
gameState GameState
acceptableCard CardPredicate
return Dominion.Card
        internal Card RequestPlayerChooseCardFromSupplyToPlay(GameState gameState, CardPredicate acceptableCard)
        {
            if (!gameState.supplyPiles.Where(pile => acceptableCard(pile.ProtoTypeCard)).Any())
                return null;

            Card cardType = this.actions.GetCardFromSupplyToPlay(gameState, delegate(Card c)
            {
                if (!acceptableCard(c))
                    return false;

                PileOfCards pile = gameState.GetSupplyPile(c);
                if (pile == null || pile.Count == 0)
                {
                    return false;
                }

                return true;
            });

            if (!acceptableCard(cardType))
            {
                throw new Exception("Card did not meet constraint");
            }

            PileOfCards foundPile = gameState.GetSupplyPile(cardType);
            if (foundPile == null || foundPile.Count == 0)
            {
                throw new Exception("Must choose pile from supply");
            }

            return cardType;
        }

Usage Example

Ejemplo n.º 1
0
        public override Card CardToMimick(PlayerState currentPlayer, GameState gameState)
        {
            // TODO:  Lots of edge cases to cover still:
            // Make sure that when BandOfMisfits is played as cards such as hermit or scheme have an effect on cleanup, that effect still happens.
            // Also check interactions when played as a duration after having been throne room, kings court etc ...
            // Check to make sure cards like bridge that provide discount while in play work ...
            // make sure procession BandOfMisfits as fortress causes band of misfits to return to hand (because of fortress effect), but gain a card costing up to 6 (procession effect)
            // make sure can play as Sir Martin when that card is top of the knights

            // throw new NOtImplementedException
            Card cardToMimick = currentPlayer.RequestPlayerChooseCardFromSupplyToPlay(gameState,
                card => card.CurrentCoinCost(currentPlayer) < this.CurrentCoinCost(currentPlayer) &&
                        card.potionCost == 0 &&
                        card.isAction);
            return cardToMimick;
        }
PlayerState