protected void MoveAllCardsFrom(CollectionCards other)
        {
            for (int index = 0; index < this.mapGameCardIndexToCount.Length; ++index)
            {
                this.mapGameCardIndexToCount[index] += other.mapGameCardIndexToCount[index];

                var parent = this.parent;
                while (parent != null)
                {
                    parent.mapGameCardIndexToCount[index] += other.mapGameCardIndexToCount[index];
                    parent = parent.parent;
                }
            }

            this.count += other.count;
            {
                var parent = this.parent;
                while (parent != null)
                {
                    parent.count += other.count;
                    parent        = parent.parent;
                }
            }

            other.Clear();
        }
示例#2
0
 public void AddAllCardsFromInSomeOrder(CollectionCards other)
 {
     base.AddAllCardsFrom(other);
     foreach (Card card in other.AllTypes)
     {
         int count = other.CountOf(card);
         for (int i = 0; i < count; ++i)
         {
             this.cards.Add(card);
         }
     }
 }
        public bool IsSubsetOf(CollectionCards other)
        {
            for (int index = 0; index < this.mapGameCardIndexToCount.Length; ++index)
            {
                if (this.mapGameCardIndexToCount[index] > other.mapGameCardIndexToCount[index])
                {
                    return(false);
                }
            }

            return(true);
        }
示例#4
0
        private void WriteAllCards(CollectionCards cards)
        {
            bool needComma = false;

            foreach (Card currentCard in cards.AllTypes.OrderBy(card => card.name))
            {
                int cardCount = cards.CountOf(currentCard);
                if (!needComma)
                {
                    needComma = true;
                }
                else
                {
                    this.textWriter.Write(", ");
                }
                this.textWriter.Write("{0} {1}", cardCount, cardCount > 1 ? currentCard.pluralName : currentCard.name);
            }
            this.textWriter.WriteLine();
        }
示例#5
0
        public GameState(
            IPlayerAction[] playerActions,
            int[] playerPositions,
            Game game)
        {
            if (playerActions.Length != playerPositions.Length)
            {
                throw new Exception();
            }

            this.game = game;
            GameConfig gameConfig = game.GameConfig;

            this.emptyCardCollection = new CollectionCards(this.CardGameSubset, null);

            int playerCount = playerActions.Length;

            this.supplyPiles    = gameConfig.GetSupplyPiles(playerCount, game.random);
            this.nonSupplyPiles = gameConfig.GetNonSupplyPiles(playerCount);

            this.mapCardToPile = new MapOfCardsForGameSubset <PileOfCards>(this.CardGameSubset);
            this.BuildMapOfCardToPile();

            this.players = new PlayerCircle(playerCount, playerActions, playerPositions, game);

            this.hasPileEverBeenGained = new MapPileOfCards <bool>(this.supplyPiles);
            this.pileEmbargoTokenCount = new MapPileOfCards <int>(this.supplyPiles);
            this.trash = new BagOfCards(this.CardGameSubset);

            this.cardContextStack = new CardContextStack();

            this.GainStartingCards(gameConfig);

            foreach (PileOfCards cardPile in this.supplyPiles)
            {
                cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this);
            }

            this.players.AllPlayersDrawInitialCards(gameConfig, this);
        }
        protected void AddAllCardsFrom(CollectionCards other)
        {
            for (int index = 0; index < this.mapGameCardIndexToCount.Length; ++index)
            {
                int count = other.mapGameCardIndexToCount[index];
                if (count == 0)
                {
                    continue;
                }

                this.mapGameCardIndexToCount[index] += count;
                this.count += count;

                var parent = this.parent;
                while (parent != null)
                {
                    parent.mapGameCardIndexToCount[index] += count;
                    parent.count += count;
                    parent        = parent.parent;
                }
            }
        }
示例#7
0
 internal new void MoveAllCardsFrom(CollectionCards other)
 {
     base.MoveAllCardsFrom(other);
 }
 protected void CopyFrom(CollectionCards other)
 {
     Array.Copy(other.mapGameCardIndexToCount, this.mapGameCardIndexToCount, other.mapGameCardIndexToCount.Length);
     this.count = other.count;
 }
示例#9
0
 public virtual Card GetCardFromHandToTrash(GameState gameState, CardPredicate acceptableCard, bool isOptional, CollectionCards cardsTrashedSoFar)
 {
     return(this.playerAction.GetCardFromHandToTrash(gameState, acceptableCard, isOptional, cardsTrashedSoFar));
 }
示例#10
0
 virtual public Card GetCardFromHandToTrash(GameState gameState, CardPredicate acceptableCard, bool isOptional, CollectionCards cardsTrashedSoFar)
 {
     return(PlayerMustMakeCardChoice());
 }
        // always optional
        public Card GetCardFromHandToTrash(GameState gameState, CardPredicate acceptableCard, bool isOptional, CollectionCards cardsTrashedSoFar)
        {
            var saved = gameState.self;

            gameState.self = this.self;
            var result = this.playerAction.GetCardFromHandToTrash(gameState, acceptableCard, isOptional, cardsTrashedSoFar);

            gameState.self = saved;
            return(result);
        }