Inheritance: ListOfCards
Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public Card PlayerGainCardFromSupply(Card cardType, PlayerState playerState, DeckPlacement defaultLocation = DeckPlacement.Discard, GainReason gainReason = GainReason.Gain)
        {
            PileOfCards pile = this.GetPile(cardType);

            if (pile == null)
            {
                return(null);
            }

            if (GetPile(this.supplyPiles, cardType) != null)
            {
                this.hasPileEverBeenGained[pile] = true;
            }

            Card card = pile.DrawCardFromTop();

            if (card == null)
            {
                return(null);
            }

            playerState.GainCard(this, card, DeckPlacement.Supply, defaultLocation, gainReason);

            return(card);
        }
Exemplo n.º 3
0
        public bool CanGainCardFromSupply(Card cardType)
        {
            PileOfCards pile = this.GetPile(cardType);

            if (pile == null)
            {
                return(false);
            }

            return(pile.TopCard() == cardType);
        }
Exemplo n.º 4
0
        public bool CanGainCardFromSupply(Card cardType)
        {
            PileOfCards pile = this.GetPile(cardType);

            if (pile == null)
            {
                return(false);
            }

            return(IsCardEqualOrOfType(pile.TopCard(), cardType));
        }
Exemplo n.º 5
0
        private int GetIndexForPile(PileOfCards pile)
        {
            for (int index = 0; index < this.supplyPiles.Length; ++index)
            {
                if (object.ReferenceEquals(pile, this.supplyPiles[index]))
                {
                    return(index);
                }
            }

            throw new Exception("Pile not a part of supply");
        }
Exemplo n.º 6
0
        public T this[PileOfCards pileOfCards]
        {
            get
            {
                return(this.array[this.GetIndexForPile(pileOfCards)]);
            }

            set
            {
                this.array[this.GetIndexForPile(pileOfCards)] = value;
            }
        }
Exemplo n.º 7
0
        private static PileOfCards GetPile(PileOfCards[] piles, Card cardType)
        {
            for (int i = 0; i < piles.Length; ++i)
            {
                PileOfCards cardPile = piles[i];
                if (cardPile.IsType(cardType))
                {
                    return(cardPile);
                }
            }

            return(null);
        }
Exemplo n.º 8
0
        private PileOfCards GetPile(Card cardType)
        {
            for (int i = 0; i < this.supplyPiles.Length; ++i)
            {
                PileOfCards cardPile = this.supplyPiles[i];
                if (cardPile.IsType(cardType))
                {
                    return(cardPile);
                }
            }

            return(null);
        }
Exemplo n.º 9
0
        public Card PlayerGainCardFromSupply(Card cardType, PlayerState playerState, DeckPlacement defaultLocation = DeckPlacement.Discard, GainReason gainReason = GainReason.Gain)
        {
            bool        canGainCardFromSupply = CanGainCardFromSupply(cardType);
            PileOfCards pile = this.GetPile(cardType);

            if (pile == null)
            {
                System.Diagnostics.Debug.Assert(!canGainCardFromSupply);
                return(null);
            }

            if (GetPile(this.supplyPiles, cardType) != null)
            {
                this.hasPileEverBeenGained[pile] = true;
            }

            if (pile.TopCard() != cardType)
            {
                System.Diagnostics.Debug.Assert(!canGainCardFromSupply);
                return(null);
            }

            Card card = pile.DrawCardFromTop();

            if (card == null)
            {
                System.Diagnostics.Debug.Assert(!canGainCardFromSupply);
                return(null);
            }

            System.Diagnostics.Debug.Assert(canGainCardFromSupply);

            playerState.GainCard(this, card, DeckPlacement.Supply, defaultLocation, gainReason);


            return(card);
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        private static PileOfCards CreateRuins(CardGameSubset gameSubset, int ruinsCount, Random random)
        {
            if (gameSubset.isInitializing)
            {
                gameSubset.AddCard(Cards.Ruins);
                gameSubset.AddCard(Cards.AbandonedMine);
                gameSubset.AddCard(Cards.RuinedMarket);
                gameSubset.AddCard(Cards.RuinedLibrary);
                gameSubset.AddCard(Cards.RuinedVillage);
                gameSubset.AddCard(Cards.Survivors);
                return null;
            }
            else
            {
                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;
            }
        }
Exemplo n.º 12
0
 internal bool HasCardEverBeenGainedFromPile(PileOfCards pile)
 {
     return(this.hasPileEverBeenGained[pile]);
 }
Exemplo n.º 13
0
 internal void AddEmbargoTokenToPile(PileOfCards pile)
 {
     this.pileEmbargoTokenCount[pile] += 1;
 }
Exemplo n.º 14
0
        private static PileOfCards GetPile(PileOfCards[] piles, Card cardType)
        {
            for (int i = 0; i < piles.Length; ++i)
            {
                PileOfCards cardPile = piles[i];
                if (cardPile.IsType(cardType))
                {
                    return cardPile;
                }
            }

            return null;
        }
Exemplo n.º 15
0
 internal bool HasCardEverBeenGainedFromPile(PileOfCards pile)
 {
     return this.hasPileEverBeenGained[pile];
 }
Exemplo n.º 16
0
 internal void AddEmbargoTokenToPile(PileOfCards pile)
 {
     this.pileEmbargoTokenCount[pile] += 1;
 }