예제 #1
0
        private PileOfCards[] GetNonSupplyPiles(CardGameSubset gameSubset)
        {
            var nonSupplyCardPiles = new List <PileOfCards>();

            if (this.useShelters)
            {
                gameSubset.AddCard(Cards.Necropolis);
                gameSubset.AddCard(Cards.Hovel);
                gameSubset.AddCard(Cards.OvergrownEstate);
            }

            if (this.kingdomPiles.Where(card => card.requiresSpoils).Any())
            {
                Add(gameSubset, nonSupplyCardPiles, 16, Cards.Spoils);
            }

            if (this.kingdomPiles.Where(card => card == Cards.Hermit).Any())
            {
                Add(gameSubset, nonSupplyCardPiles, 10, Cards.Madman);
            }

            if (this.kingdomPiles.Where(card => card == Cards.Urchin).Any())
            {
                Add(gameSubset, nonSupplyCardPiles, 10, Cards.Mercenary);
            }

            if (this.kingdomPiles.Where(card => card == Cards.Tournament).Any())
            {
                Add(gameSubset, nonSupplyCardPiles, 10, Cards.Mercenary);
            }

            return(nonSupplyCardPiles.ToArray());
        }
예제 #2
0
        private static PileOfCards CreateRuins(CardGameSubset gameSubset, int ruinsCount, Random random)
        {
            int ruinCountPerPile = 10;
            var allRuinsCards    = new ListOfCards(gameSubset);

            allRuinsCards.AddNCardsToTop(Cards.AbandonedMine, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.RuinedMarket, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.RuinedLibrary, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.RuinedVillage, ruinCountPerPile);
            allRuinsCards.AddNCardsToTop(Cards.Survivors, ruinCountPerPile);

            allRuinsCards.Shuffle(random);

            var result = new PileOfCards(gameSubset, Cards.Ruins);

            for (int i = 0; i < ruinsCount; ++i)
            {
                Card card = allRuinsCards.DrawCardFromTop();
                if (card == null)
                {
                    throw new Exception("Not enough ruins available.");
                }
                result.AddCardToTop(card);
            }
            result.EraseKnownCountKnowledge();

            return(result);
        }
예제 #3
0
 private static void Add(CardGameSubset gameSubset, List <PileOfCards> cardPiles, int initialCount, Card protoType)
 {
     if (gameSubset.isInitializing)
     {
         gameSubset.AddCard(protoType);
     }
     else
     {
         cardPiles.Add(new PileOfCards(gameSubset, protoType, initialCount));
     }
 }
예제 #4
0
        private PileOfCards[] GetSupplyPiles(int playerCount, Random random, CardGameSubset gameSubset)
        {
            var supplyCardPiles = new List <PileOfCards>(capacity: 20);

            int curseCount   = (playerCount - 1) * 10;
            int ruinsCount   = curseCount;
            int victoryCount = (playerCount == 2) ? 8 : 12;

            // cards always in the supply
            Add(gameSubset, supplyCardPiles, 60, Cards.Copper);
            Add(gameSubset, supplyCardPiles, 40, Cards.Silver);
            Add(gameSubset, supplyCardPiles, 30, Cards.Gold);
            Add(gameSubset, supplyCardPiles, curseCount, Cards.Curse);
            Add(gameSubset, supplyCardPiles, victoryCount + (!this.useShelters ? playerCount * 3 : 0), Cards.Estate);
            Add(gameSubset, supplyCardPiles, victoryCount, Cards.Duchy);
            Add(gameSubset, supplyCardPiles, victoryCount, Cards.Province);

            if (this.useColonyAndPlatinum)
            {
                Add(gameSubset, supplyCardPiles, victoryCount, Cards.Colony);
                Add(gameSubset, supplyCardPiles, 20, Cards.Platinum);
            }

            if (this.kingdomPiles.Where(card => card.potionCost != 0).Any())
            {
                Add(gameSubset, supplyCardPiles, 16, Cards.Potion);
            }

            if (this.kingdomPiles.Where(card => card.requiresRuins).Any())
            {
                supplyCardPiles.Add(CreateRuins(gameSubset, ruinsCount, random));
            }

            foreach (Card card in this.kingdomPiles)
            {
                if (card.isVictory)
                {
                    Add(gameSubset, supplyCardPiles, victoryCount, card);
                }
                else
                {
                    Add(gameSubset, supplyCardPiles, card.defaultSupplyCount, card);
                }
            }

            return(supplyCardPiles.ToArray());
        }
예제 #5
0
        public GameConfig(
            GameDescription gameDescription,
            MapPlayerGameConfigToCardSet startingDecks = null,
            MapPlayerGameConfigToCardSet startingHands = null)
        {
            this.gameDescription = gameDescription;
            this.startingDeck    = startingDecks;
            this.startingHand    = startingHands;


            this.cardGameSubset = new CardGameSubset();
            var availabilities = GetCardAvailability(1, CardAvailabilityType.AllPossibleCardsInGame);

            foreach (var availability in availabilities)
            {
                this.cardGameSubset.AddCard(availability.card);
            }
        }
예제 #6
0
        public GameConfig(
            Card[] supplyPiles,
            bool useShelters,
            bool useColonyAndPlatinum,
            MapPlayerGameConfigToCardSet startingDecks = null,
            MapPlayerGameConfigToCardSet startingHands = null)
        {
            this.useShelters          = useShelters;
            this.useColonyAndPlatinum = useColonyAndPlatinum;
            this.kingdomPiles         = supplyPiles;
            this.startingDeck         = startingDecks;
            this.startingHand         = startingHands;
            this.cardGameSubset       = new CardGameSubset();

            GetSupplyPiles(1, null, this.cardGameSubset);
            GetNonSupplyPiles(this.cardGameSubset);

            this.cardGameSubset.isInitializing = false;
        }
예제 #7
0
        public GameConfig(
            Card[] kingdomPiles,
            Card baneCard,
            bool useShelters,
            bool useColonyAndPlatinum,
            MapPlayerGameConfigToCardSet startingDecks = null,
            MapPlayerGameConfigToCardSet startingHands = null)
        {
            this.useShelters          = useShelters;
            this.useColonyAndPlatinum = useColonyAndPlatinum;
            this.kingdomPiles         = kingdomPiles;
            this.startingDeck         = startingDecks;
            this.startingHand         = startingHands;
            this.baneCard             = baneCard;

            this.cardGameSubset = new CardGameSubset();
            var availabilities = GetCardAvailability(1, CardAvailabilityType.AllPossibleCardsInGame);

            foreach (var availability in availabilities)
            {
                this.cardGameSubset.AddCard(availability.card);
            }
        }
예제 #8
0
        private static PileOfCards CreateTournamentPrizes(CardGameSubset gameSubset)
        {
            Card[] prizes = { Cards.BagOfGold, Cards.Diadem, Cards.Followers, Cards.Princess, Cards.TrustySteed };

            if (gameSubset.isInitializing)
            {
                gameSubset.AddCard(Cards.Prize);
                foreach (Card prize in prizes)
                {
                    gameSubset.AddCard(prize);
                }
                return(null);
            }
            else
            {
                var result = new PileOfCards(gameSubset, Cards.Prize);
                foreach (Card prize in prizes)
                {
                    result.AddCardToTop(prize);
                }

                return(result);
            }
        }
예제 #9
0
 public PileOfCards(CardGameSubset gameSubset, Card protoType)
     : base(gameSubset)
 {
     this.protoType = protoType;
 }
예제 #10
0
 public PileOfCards(CardGameSubset gameSubset, Card protoType, int count)
     : base(gameSubset)
 {
     this.AddNCardsToTop(protoType, count);
     this.protoType = protoType;
 }
예제 #11
0
 public ListOfCards(CardGameSubset gameSubset)
     : base(gameSubset, null)
 {
 }
예제 #12
0
 public CollectionCards(CardGameSubset gameSubset, BagOfCards parent)
 {
     this.parent     = parent;
     this.gameSubset = gameSubset;
     this.mapGameCardIndexToCount = new int[this.gameSubset.CountOfCardTypesInGame];
 }
예제 #13
0
 internal PlayerTurnCounters(CardGameSubset gameSubset)
 {
     cardsBannedFromPurchase = new SetOfCards(gameSubset);
     cardsBoughtThisTurn     = new SetOfCards(gameSubset);
     cardsGainedThisTurn     = new SetOfCards(gameSubset);
 }
예제 #14
0
 public Enumerator(CardGameSubset cardGameSubset)
 {
     this.currentIndex   = -1;
     this.cardGameSubset = cardGameSubset;
 }
예제 #15
0
 public BagOfCards(CardGameSubset gameSubset)
     : this(gameSubset, null)
 {
 }
예제 #16
0
 public BagOfCards(CardGameSubset gameSubset, BagOfCards parent)
     : base(gameSubset, parent)
 {
 }
 public MapOfCardsForGameSubset(CardGameSubset gameSubset)
 {
     this.gameSubset           = gameSubset;
     this.mapCardIndexToResult = new T[gameSubset.CountOfCardTypesInGame];
 }