internal void Add( Player player, Announcement announce )
{
if( !IsValid( player, announce ))
throw new InvalidOperationException( "You cannot bid lower than current" );
if( (_players.Count != 0)&&( player == (Player)_players[_players.Count - 1] ) )
throw new InvalidOperationException( "You cannot bid twice" );
_announces.Add( announce );
_players.Add( player );
if( announce.Type != AnnouncementTypeEnum.Pass )
{
_lastValidAnnouncement = announce;
_lastBidder = player;
}
else
{
//4 successive passes end bidding or 3 passes after a legal bid
if( _announces.Count > 3 )
{
if( ( ( _announces[_announces.Count-1]).Type == AnnouncementTypeEnum.Pass ) &&
( ( _announces[_announces.Count-2]).Type == AnnouncementTypeEnum.Pass ) &&
( ( _announces[_announces.Count-3]).Type == AnnouncementTypeEnum.Pass ) &&
( _lastBidder != null || (_announces[_announces.Count-4]).Type == AnnouncementTypeEnum.Pass ) )
{
this._isBiddingFinished = true;
}
}
}
}