Exemple #1
0
 public CardCollectionModel(GameSets allowedSets)
 {
     this.SelectedCards = new ObservableCollection<CardViewModel>();
     this.CardCollections = new ObservableCollection<CardCollection>();
     Dictionary<string, CardCollection> lookup = new Dictionary<string,CardCollection>();
     CardCollection all = new CardCollection("All");
     foreach (CardModel card in CardModelFactory.AllCards)
     {
         if (card.IsKingdomCard && (card.GameSet & allowedSets) != 0)
         {
             CardCollection collection;
             if (!lookup.TryGetValue(card.Expansion, out collection))
             {
                 collection = new CardCollection(card.Expansion);
                 lookup[card.Expansion] = collection;
                 this.CardCollections.Add(collection);
             }
             this.InsertSorted(collection.Cards, new CardViewModel(card));
             this.InsertSorted(all.Cards, new CardViewModel(card));
         }
     }
     this.CardCollections.Add(all);
 }
Exemple #2
0
        public CardSetsModel(GameSets allowedSets)
        {
            this.CardSetGroups = new ObservableCollection<CardSetGroup>();

            if ((allowedSets & GameSets.Base) != 0)
            {
                CardSetGroup baseSet = new CardSetGroup(new GameSet(GameSets.Base, false));
                foreach (CardSet cardSet in baseCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        baseSet.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(baseSet);
            }

            if ((allowedSets & GameSets.Intrigue) != 0)
            {
                CardSetGroup intrigue = new CardSetGroup(new GameSet(GameSets.Intrigue, false));
                foreach (CardSet cardSet in intrigueCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        intrigue.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(intrigue);
            }

            if ((allowedSets & GameSets.Seaside) != 0)
            {
                CardSetGroup seaside = new CardSetGroup(new GameSet(GameSets.Seaside, false));
                foreach (CardSet cardSet in seasideCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        seaside.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(seaside);
            }

            if ((allowedSets & GameSets.Alchemy) != 0)
            {
                CardSetGroup alchemy = new CardSetGroup(new GameSet(GameSets.Alchemy, false));
                foreach (CardSet cardSet in alchemyCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        alchemy.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(alchemy);
            }

            if ((allowedSets & GameSets.Prosperity) != 0)
            {
                CardSetGroup prosperity = new CardSetGroup(new GameSet(GameSets.Prosperity, false));
                foreach (CardSet cardSet in prosperityCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        prosperity.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(prosperity);
            }

            if ((allowedSets & GameSets.Cornucopia) != 0)
            {
                CardSetGroup cornucopia = new CardSetGroup(new GameSet(GameSets.Cornucopia, false));
                foreach (CardSet cardSet in cornucopiaCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        cornucopia.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(cornucopia);
            }

            if ((allowedSets & GameSets.Hinterlands) != 0)
            {
                CardSetGroup hinterlands = new CardSetGroup(new GameSet(GameSets.Hinterlands, false));
                foreach (CardSet cardSet in hinterlandsCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        hinterlands.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(hinterlands);
            }

            if ((allowedSets & GameSets.DarkAges) != 0)
            {
                CardSetGroup darkAges = new CardSetGroup(new GameSet(GameSets.DarkAges, false));
                foreach (CardSet cardSet in darkAgesCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        darkAges.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(darkAges);
            }

            if ((allowedSets & GameSets.Guilds) != 0)
            {
                CardSetGroup guilds = new CardSetGroup(new GameSet(GameSets.Guilds, false));
                foreach (CardSet cardSet in guildsCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        guilds.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(guilds);
            }

            if((allowedSets & GameSets.Adventures) != 0)
            {
                CardSetGroup adventures = new CardSetGroup(new GameSet(GameSets.Adventures, false));
                foreach (CardSet cardSet in adventuresCardSets)
                {
                    if ((cardSet.GameSet & allowedSets) == cardSet.GameSet)
                    {
                        adventures.AddCardSet(cardSet);
                    }
                }
                this.CardSetGroups.Add(adventures);
            }

            CardSetGroup custom = new CardSetGroup(new GameSet(GameSets.None, false));
            custom.AddCardSet(new RandomAllCardSet(allowedSets));
            this.CardSetGroups.Add(custom);

            this.CardSetLookup = new Dictionary<string, CardSetViewModel>();
            foreach(CardSetGroup group in this.CardSetGroups)
            {
                foreach(CardSetViewModel set in group.CardSets)
                {
                    this.CardSetLookup[set.CardSetName] = set;
                }
            }

            this.CardSetGroupLookup = new Dictionary<string, CardSetGroup>();
            foreach (CardSetGroup group in this.CardSetGroups)
            {
                this.CardSetGroupLookup[group.GameSet.SetName] = group;
            }
        }
Exemple #3
0
        public RandomAllCardSet(GameSets allowedSets)
        {
            if (allowedSets == GameSets.None || allowedSets == GameSets.Promo)
            {
                allowedSets |= GameSets.Base;
            }

            foreach (CardModel card in RandomCardIDs.OrderBy(card => Randomizer.Next()))
            {
                if((card.GameSet & allowedSets) != 0)
                {
                    this.cardCollection.Add(card);
                }
                if (this.cardCollection.Count == 10)
                {
                    break;
                }
            }
        }
Exemple #4
0
 public GameSet(GameSets gameSet, bool selected)
 {
     this.Selected = selected;
     this.Set = gameSet;
     this.SetName = Enum.GetName(typeof(GameSets), gameSet);
 }
Exemple #5
0
        public Kingdom(IList<CardModel> cards, IList<CardModel> prohibitedCards, CardModel bane, GameSets allowedSets, int numPlayers, CardUseType usesColonies, CardUseType usesShelters, StartingHandType startingHandType, bool useRandomCardsFromChosenSetsOnly)
        {
            this.Bane = bane;
            this.NumPlayers = numPlayers;
            this.AllowedSets = allowedSets;
            if (prohibitedCards == null)
            {
                prohibitedCards = new List<CardModel>();
            }
            List<CardModel> newCards = new List<CardModel>();
            if (cards != null)
            {
                newCards.AddRange(cards);
            }
            this.Cards = newCards;

            int need = 10 - this.Cards.Count;
            if (need > 0)
            {
                IEnumerable<CardModel> randomFilteredCards = RandomAllCardSet.RandomCardIDs.Where(c => !this.Cards.Any(cc => cc.Name == c.Name) && !prohibitedCards.Any(cc => cc.Name == c.Name) && (this.Bane == null || this.Bane.Name != c.Name) && (c.GameSet & this.AllowedSets) != 0).OrderBy(c => Randomizer.Next());
                newCards.AddRange(randomFilteredCards.Take(need));
                need = 10 - this.Cards.Count;
                if (need > 0)
                {
                    IEnumerable<CardModel> randomAllCards = RandomAllCardSet.RandomCardIDs.Where(c => !this.Cards.Any(cc => cc.Name == c.Name) && (this.Bane == null || this.Bane.Name != c.Name)).OrderBy(c => Randomizer.Next());
                    newCards.AddRange(randomAllCards.Take(need));
                }
            }

            this.InitializeBlackMarket(useRandomCardsFromChosenSetsOnly, prohibitedCards);
            if (this.Cards.Any(card => card is YoungWitch))
            {
                if (this.Bane == null)
                {
                    // add a bane card if it hasn't been set already
                    IEnumerable<CardModel> baneCards = RandomAllCardSet.RandomCardIDs.Where(c => (c.GetBaseCost() == 2 || c.GetBaseCost() == 3) && !c.CostsPotion && !this.Cards.Any(cc => cc.Name == c.Name) && (this.BlackMarketDeck == null || !this.BlackMarketDeck.Any(cc => cc.Name == c.Name)) && (c.GameSet & this.AllowedSets) != 0);
                    if (useRandomCardsFromChosenSetsOnly)
                    {
                        IEnumerable<CardModel> filteredBaneCards = baneCards.Where(c => this.Cards.Any(cc => c.GameSet == cc.GameSet) && !prohibitedCards.Any(cc => cc.Name == c.Name));
                        if(filteredBaneCards.Any())
                        {
                            baneCards = filteredBaneCards;
                        }
                    }

                    CardModel baneChoice = baneCards.ElementAt(Randomizer.Next(baneCards.Count()));
                    this.Bane = baneChoice;
                }
                if (this.Bane is BlackMarket)
                {
                    this.InitializeBlackMarket(useRandomCardsFromChosenSetsOnly, prohibitedCards);
                }
                this.Cards.Add(this.Bane);
            }

            newCards.Sort(new Comparison<CardModel>((CardModel lhs, CardModel rhs) =>
            {
                if (lhs.CostsPotion && !rhs.CostsPotion) return 1;
                if (rhs.CostsPotion && !lhs.CostsPotion) return -1;
                if (lhs.GetBaseCost() != rhs.GetBaseCost()) return lhs.GetBaseCost() - rhs.GetBaseCost();
                return lhs.Name.CompareTo(rhs.Name);
            }));

            switch (usesColonies)
            {
                case CardUseType.Random:
                    this.UsesColonies = Randomizer.Next(2) == 1;
                    break;

                case CardUseType.RandomByCardsFromSet:
                    this.UsesColonies = this.Cards.Count(card => card is ProsperityCardModel) > Randomizer.Next(10);
                    break;

                case CardUseType.Use:
                    this.UsesColonies = true;
                    break;

                case CardUseType.DoNotUse:
                    this.UsesColonies = false;
                    break;
            }

            switch (usesShelters)
            {
                case CardUseType.Random:
                    this.UsesShelters = Randomizer.Next(2) == 1;
                    break;

                case CardUseType.RandomByCardsFromSet:
                    this.UsesShelters = this.Cards.Count(card => card is DarkAgesCardModel) > Randomizer.Next(10);
                    break;

                case CardUseType.Use:
                    this.UsesShelters = true;
                    break;

                case CardUseType.DoNotUse:
                    this.UsesShelters = false;
                    break;
            }

            this.CreateStartingDecks(startingHandType);

            this.VictoryCardCount = this.NumPlayers < 3 ? 8 : 12;
        }
Exemple #6
0
 public Kingdom(IList<CardModel> cards, IList<CardModel> prohibitedCards, CardModel bane, GameSets allowedSets, int numPlayers, CardUseType usesColonies, CardUseType usesShelters, StartingHandType startingHandType)
     : this(cards, prohibitedCards, bane, allowedSets, numPlayers, usesColonies, usesShelters, startingHandType, false)
 {
 }
Exemple #7
0
 public Kingdom(IList<CardModel> cards, IList<CardModel> prohibitedCards, CardModel bane, GameSets allowedSets, int numPlayers)
     : this(cards, prohibitedCards, bane, allowedSets, numPlayers, CardUseType.RandomByCardsFromSet, CardUseType.RandomByCardsFromSet, StartingHandType.Random, false)
 {
 }