Beispiel #1
0
        private bool CardAvailableForPurchaseForCurrentPlayer(CardShapedObject cardShapedObject)
        {
            PlayerState currentPlayer = this.players.CurrentPlayer;

            if (cardShapedObject is Card card)
            {
                return(currentPlayer.AvailableCoins >= card.CurrentCoinCost(currentPlayer) &&
                       currentPlayer.AvailablePotions >= card.potionCost &&
                       this.CardGameSubset.HasCard(card) &&
                       this.GetPile(card).Any&&
                       !card.IsRestrictedFromBuy(currentPlayer, this) &&
                       !currentPlayer.turnCounters.cardsBannedFromPurchase.Contains(card));
            }
            else if (cardShapedObject is Event eventCard)
            {
                return(currentPlayer.AvailableCoins >= eventCard.coinCost &&
                       this.CardGameSubset.HasCard(eventCard));
            }
            else if (cardShapedObject is Project project)
            {
                return(currentPlayer.AvailableCoins >= project.coinCost &&
                       this.CardGameSubset.HasCard(project));
            }

            throw new Exception("provided cardshapedobject can not be bought");
        }
        string[] GetSearchWordsForCard(Dominion.CardShapedObject cardShapedObject)
        {
            var result = new List <string>();

            result.Add(cardShapedObject.name);
            result.Add(cardShapedObject.expansion.ExpansionToString());
            result.Add(cardShapedObject.edition.EditionToString());

            if (cardShapedObject is Dominion.Card card)
            {
                result.Add(card.DefaultCoinCost.ToString());

                foreach (Dominion.CardType cardType in card.CardTypes)
                {
                    result.Add(cardType.CardTypeToString());
                    var pluralName = cardType.CardTypeToStringPlural();
                    if (pluralName != null)
                    {
                        result.Add(pluralName);
                    }
                }

                if (card.isDeprecated)
                {
                    result.Add("deprecated");
                }
                if (card.isLooter)
                {
                    result.Add("ruins");
                }
                if (card.requiresSpoils)
                {
                    result.Add("spoils");
                }
                if (card.potionCost != 0)
                {
                    result.Add("potion");
                }
                if (card.debtCost != 0)
                {
                    result.Add("debt");
                }
                if (card.canOverpay)
                {
                    result.Add("overpay");
                }
                if (card.plusBuy > 0)
                {
                    result.Add("buy");
                    result.Add("buys");
                }
            }
            else if (cardShapedObject is Dominion.Event eventCard)
            {
                result.Add(eventCard.coinCost.ToString());
                result.Add("event");
            }
            else
            {
                throw new NotImplementedException();
            }


            if (this.appDataContext.CurrentDeck.CurrentCards.Where(c => c.cardShapedObject == cardShapedObject).Any())
            {
                result.Add("current");
                result.Add("deck");
                result.Add("selected");
            }

            return(result.ToArray());
        }