Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
        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;
                }
            }
        }
Ejemplo n.º 7
0
 internal new void MoveAllCardsFrom(CollectionCards other)
 {
     base.MoveAllCardsFrom(other);
 }
Ejemplo n.º 8
0
 protected void CopyFrom(CollectionCards other)
 {
     Array.Copy(other.mapGameCardIndexToCount, this.mapGameCardIndexToCount, other.mapGameCardIndexToCount.Length);
     this.count = other.count;
 }
Ejemplo n.º 9
0
 public virtual Card GetCardFromHandToTrash(GameState gameState, CardPredicate acceptableCard, bool isOptional, CollectionCards cardsTrashedSoFar)
 {
     return(this.playerAction.GetCardFromHandToTrash(gameState, acceptableCard, isOptional, cardsTrashedSoFar));
 }
Ejemplo n.º 10
0
 virtual public Card GetCardFromHandToTrash(GameState gameState, CardPredicate acceptableCard, bool isOptional, CollectionCards cardsTrashedSoFar)
 {
     return(PlayerMustMakeCardChoice());
 }
Ejemplo n.º 11
0
        // 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);
        }