예제 #1
0
        public static ICollection <IDevelopmentCard> GenerateDevelopmentCards()
        {
            int[] developmentCardsTypesCount    = new int[] { NumberOfKnightCard, NumberOfVictoryPointCard, NumberOfRoadBuildCard, NumberOfResourceGetCard };
            IDevelopmentCard[] developmentCards = new IDevelopmentCard[CommonConstants.DevelopmentCardsNumber];
            Random             rand             = new Random();

            for (int i = 0; i < CommonConstants.DevelopmentCardsNumber; i++)
            {
                int cardType = rand.Next(developmentCardsTypesCount.Length);
                while (developmentCardsTypesCount[cardType] <= 0)
                {
                    cardType = (cardType + 1) % developmentCardsTypesCount.Length;
                }
                developmentCardsTypesCount[cardType]--;
                IDevelopmentCard card = null;
                switch (cardType)
                {
                case 0: card = new KnightCard(); break;

                case 1: card = new VictoryPointCard(); break;

                case 2: card = new RoadBuildCard(); break;

                case 3: card = new ResourceGetCard(); break;

                default: throw new ArgumentOutOfRangeException("Such development card type does not exist");
                }
                developmentCards[i] = card;
            }
            return(developmentCards);
        }
예제 #2
0
        public PlayDevelopmentCardCommand(IPlayer player, IGame game, IDevelopmentCard card)
        {
            if (player == null)
                throw new ArgumentNullException(nameof(player));
            if (game == null)
                throw new ArgumentNullException(nameof(game));
            if (card == null)
                throw new ArgumentNullException(nameof(card));

            Player = player;
            this.game = game;
            this.card = card;
        }
예제 #3
0
 public void PushDevelopmentCard(IDevelopmentCard card)
 {
     this.developmentCards.Enqueue(card);
 }
예제 #4
0
파일: Game.cs 프로젝트: Corne/VOC
 public void PlayDevelopmentCard(IDevelopmentCard card)
 {
     var gameturn = currentTurn as IGameTurn;
     if (gameturn == null)
         throw new InvalidOperationException("Can't play a development card in current turn");
     gameturn.PlayDevelopmentCard(card);
 }
예제 #5
0
파일: Player.cs 프로젝트: Corne/VOC
 public void AddCard(IDevelopmentCard developmentCard)
 {
     if (developmentCard == null)
         throw new ArgumentNullException(nameof(developmentCard));
     cards.Add(developmentCard);
 }