private void PlayPropertyFlippingRound()
        {
            _state.ChequesOnTable = _state.ChequeDeck.Draw(Players.Count()).OrderBy(c => c.Value).ToList();

            foreach (var player in Players)
            {
                var turn = new ForSaleGameTurn {
                    CurrentPlayerId = player.Id, State = _state
                };
                player.GetTurn(turn);
                ProcessTurn(turn);
            }

            // give cheques out to players
            var chequesInOrder            = _state.ChequesOnTable.OrderByDescending(c => c.Value).ToList();
            var flippingPropertiesInOrder = _state.PlayerStates
                                            .Select(p => p.Value.PropertySelling.Value)
                                            .OrderByDescending(p => p)
                                            .ToList();

            foreach (var propertyToFlip in flippingPropertiesInOrder)
            {
                var flippingPlayer = _state.PlayerStates
                                     .SingleOrDefault(p => p.Value.PropertySelling.Value == propertyToFlip);
                var chequeToAllocate = chequesInOrder[0];
                if (chequesInOrder.Remove(chequeToAllocate))
                {
                    flippingPlayer.Value.ChequeCards.Add(chequeToAllocate);
                }
            }
        }
        private void PlayPropertyBidRound()
        {
            _state.PropertyCardsOnTable = _state.PropertyDeck.Draw(Players.Count()).OrderBy(c => c.Value).ToList();

            _logger.Information($"Property cards drawn for bidding round");

            var passedPlayers = new List <int>();

            while (_state.PropertyCardsOnTable.Any())
            {
                foreach (var player in Players.Where(p => !passedPlayers.Contains(p.Id)))
                {
                    var turn = new ForSaleGameTurn {
                        CurrentPlayerId = player.Id, State = _state
                    };

                    if (_state.PropertyCardsOnTable.Count() == 1)
                    {
                        PlayerPaysForLastPropertyCard(turn);
                        // TODO this player gos first in next round
                    }
                    else
                    {
                        player.GetTurn(turn);
                        ProcessTurn(turn);
                        if (turn.Passed)
                        {
                            passedPlayers.Add(player.Id);
                        }
                    }
                }
            }
        }
        private void ProcessPropertyFlippingTurn(ForSaleGameTurn turn)
        {
            var playerState          = _state.PlayerStates[turn.CurrentPlayerId];
            var propertyBeingFlipped = playerState.PropertyCards.SingleOrDefault(p => p.Value == turn.PropertyToFlip.Value);

            if (propertyBeingFlipped != null && playerState.PropertyCards.Remove(propertyBeingFlipped))
            {
                playerState.PropertySelling = propertyBeingFlipped;
            }
        }
 private void ProcessPropertyBidTurn(ForSaleGameTurn turn)
 {
     if (turn.Passed)
     {
         ProcessPassingTurn(turn.CurrentPlayerId);
     }
     else
     {
         ProcessBiddingTurn(turn.CurrentPlayerId, turn.BidAmount);
     }
 }
 private void ProcessTurn(ForSaleGameTurn turn)
 {
     if (_state.PropertyCardsOnTable.Any())
     {
         ProcessPropertyBidTurn(turn);
     }
     else
     {
         ProcessPropertyFlippingTurn(turn);
     }
 }
        private void PlayerPaysForLastPropertyCard(ForSaleGameTurn turn)
        {
            var playerState  = _state.PlayerStates[turn.CurrentPlayerId];
            var cardsOnTable = _state.PropertyCardsOnTable.ToList();
            var cardToTake   = cardsOnTable[0];

            if (cardsOnTable.Remove(cardToTake))
            {
                playerState.PropertyCards.Add(cardToTake);
                playerState.CoinsBid        = 0;
                _state.PropertyCardsOnTable = cardsOnTable;
            }
        }