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); }
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; }
public void PushDevelopmentCard(IDevelopmentCard card) { this.developmentCards.Enqueue(card); }
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); }
public void AddCard(IDevelopmentCard developmentCard) { if (developmentCard == null) throw new ArgumentNullException(nameof(developmentCard)); cards.Add(developmentCard); }