Example #1
0
        public int[] PlayRound()
        {
            var cards = CardCollection.AllCards();

            //Deal cards
            var playerCards = Dealer.Deal(CardCollection.AllCards(), PlayerCount);
            var minHandSize = playerCards.Min(hand => hand.Cards().Count());
            var seats       = Enumerable.Range(0, PlayerCount).Select(i =>
            {
                return(new Seat(i, _players[i], playerCards[i]));
            }).ToArray();

            InitialMove[] initialMoves = DoInitialMoves(playerCards);
            GiveInitialCards(playerCards, initialMoves);

            var         scoreCount     = new ScoreCount(PlayerCount);
            TrickResult previousWinner = null;

            for (int i = 0; i < minHandSize - 1; i++)
            {
                previousWinner = new TrickEngine(seats).PlayTrick(previousWinner);
                scoreCount.Add(previousWinner.Winner.Index, previousWinner.WinnerPrice());
            }

            var bottleTax = initialMoves.Sum(move => move.ToBottle.Score);
            var scores    = Scores(scoreCount, previousWinner.BottleOwner.Index, bottleTax);

            foreach (var player in _players)
            {
                player.RoundEnded(scores);
            }

            return(scores);
        }
Example #2
0
 private static int[] Scores(ScoreCount scoreCount, int bottleOwner, int bottleTax)
 {
     return(Enumerable.Range(0, scoreCount.Players).Select(index =>
     {
         if (index == bottleOwner)
         {
             return -bottleTax;
         }
         return scoreCount.Score(index);
     }).ToArray());
 }