Пример #1
0
        public static GameGeneratorParameters GetInstance()
        {
            var parms = new GameGeneratorParameters();

            // Add Card Sets
            var cardSets = Enum <CardSet> .GetNames();

            foreach (var cardSet in cardSets)
            {
                parms.Sets.Add(new GameGeneratorSet {
                    Key = cardSet, Name = ExtensionMethods.CamelCaseToProperSpace(cardSet), IsSet = (cardSet == "Dominion")
                });
            }

            //Add Game Rules
            var rules = Enum <GameRules> .GetNames();

            foreach (var rule in rules)
            {
                parms.Rules.Add(new GameGeneratorRule {
                    Key = rule, Name = ExtensionMethods.CamelCaseToProperSpace(rule), IsSet = false
                });
            }

            // parms.Rules.Add(new GameGeneratorRule() { Key = "RequireTwoToFiveCostCards", Name = "Require Two To Five Cost Cards", IsSet = false });
            // parms.Rules.Add(new GameGeneratorRule() { Key = "RequireReactionToAttack", Name = "Require Reaction To Attack", IsSet = false });

            return(parms);
        }
Пример #2
0
        private static List <Card> GetAvailableCards(GameGeneratorParameters parameters)
        {
            var cards          = new Cards();
            var availableCards = new List <Card>();

            // Regular Sets
            if (parameters.FindSet("Alchemy").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Alchemy));
            }
            if (parameters.FindSet("Dominion").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Dominion));
            }
            if (parameters.FindSet("Intrigue").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Intrigue));
            }
            if (parameters.FindSet("Prosperity").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Prosperity));
            }
            if (parameters.FindSet("Seaside").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Seaside));
            }
            if (parameters.FindSet("Cornucopia").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Cornucopia));
            }
            if (parameters.FindSet("Hinterlands").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Hinterlands));
            }
            if (parameters.FindSet("DarkAges").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.DarkAges));
            }

            // Promo Cards
            if (parameters.FindSet("BlackMarket").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.BlackMarket));
            }
            if (parameters.FindSet("Envoy").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Envoy));
            }
            if (parameters.FindSet("Stash").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.Stash));
            }
            if (parameters.FindSet("WalledVillage").IsSet)
            {
                availableCards.AddRange(cards.Where(x => x.Set == CardSet.WalledVillage));
            }

            return(availableCards);
        }
Пример #3
0
        public List <Card> GetGameCards(GameGeneratorParameters gameGeneratorParameters)
        {
            var parameters = gameGeneratorParameters;

            var gameCards      = new List <Card>();
            var remainingCards = 10;

            var availableCards = GetAvailableCards(parameters);

            if (availableCards.Count == 0)
            {
                return(gameCards);
            }

            if (parameters.FindRule("RequireTwoToFiveCostCards").IsSet)
            {
                var twoToFiveCostCards = GetTwoToFiveCostCards(availableCards);
                gameCards.AddRange(twoToFiveCostCards);
                RemoveFromAvailableCards(availableCards, twoToFiveCostCards);
                remainingCards = remainingCards - twoToFiveCostCards.Count();
            }

            var nextCards = GetRandomCards(availableCards, remainingCards - 1);

            gameCards.AddRange(nextCards);

            gameCards.Add(GetLastCard(availableCards, gameCards, parameters));

            // check for young witch and add the card at this time
            var yw = gameCards.Any(card => card.Name == "Young Witch");

            if (yw)
            {
                var ywCard = GetRandomCards(availableCards, 1).Single();
                gameCards.Add(ywCard);
            }

            return(gameCards);
        }
Пример #4
0
        public Card GetReplacementCard(IEnumerable <Card> cards, GameGeneratorParameters parameters)
        {
            // TODO: Need to figure out how to keep track of previosly selected cards

            // get the set of available cards for current parameters
            var availableCards = GetAvailableCards(parameters);

            // remove the cards already in the selected deck
            RemoveFromAvailableCards(availableCards, cards);

            // retrieve a card
            var newCard = this.GetRandomCardFromList(availableCards);

            var card       = newCard;
            var duplicates = cards.Where(c => c.Id == card.Id);

            while (duplicates.Count() > 0)
            {
                newCard = this.GetRandomCardFromList(availableCards);
                var card1 = newCard;
                duplicates = cards.Where(c => c.Id == card1.Id);
            }
            return(newCard);
        }
Пример #5
0
        private Card GetLastCard(IEnumerable <Card> availableCards, IEnumerable <Card> gameCards, GameGeneratorParameters parameters)
        {
            Card lastCard;
            int  reactionCardCount = availableCards.Where(x => x.Type == CardType.Reaction).Count();

            if (parameters.FindRule("RequireReactionToAttack").IsSet&& reactionCardCount != 0)
            {
                lastCard = GetReactionCard(availableCards, gameCards);
            }
            else
            {
                lastCard = GetRandomCardFromList(availableCards);
            }

            return(lastCard);
        }