/// <summary> /// Evaluate and place the specified bid. Checks if the last 3 bids are Pass /// or a Pass and Double or Re-double is placed, the last bid is the winner and /// the bidding is closed. /// </summary> public void PlaceBid(Bid bid) { if (!IsClosed) { if (gameSession.GetPlayer(CurrentTurn) == bid.Player) { //TODO: handle pass&double and re-double bids Bid lastBid = GetLastNonPassBid(); if (bid.IsPass || lastBid == null || (lastBid != null && bid.CompareTo(lastBid) > 0)) { Bids.Add(bid); if (bid.IsPass && GetNumberOfPassBids() >= 3) { IsClosed = true; gameSession.BiddingComplete(); } else { NextTurn(); } } else { throw new ArgumentException("The placed bid is less than the last bid"); } } else { throw new InvalidOperationException("The player placed a bit not in the right turn"); } } else { throw new InvalidOperationException("Cannot place bids when the bidding is closed"); } }