CompareTo() private method

private CompareTo ( AnnouncementTypeEnum type ) : int
type AnnouncementTypeEnum
return int
Ejemplo n.º 1
0
        /// <summary>
        /// If announcement made by this player is valid according to game rules
        /// </summary>
        public bool IsValid(Player player, AnnouncementTypeEnum type, bool isDoubled, bool isRedoubled)
        {
            //no player
            if (player == null)
            {
                throw new ArgumentNullException("Player", "Bidding player cannot be null");
            }

            //legal pass
            if (type == AnnouncementTypeEnum.Pass)
            {
                if (!isDoubled && !isRedoubled)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (_lastValidAnnouncement.CompareTo(type) < 0 && !isDoubled && !isRedoubled)
            {
                return(true);
            }

            if (_lastValidAnnouncement.CompareTo(type) == 0 && !IsLastValidBidByTeam(player) && !_lastValidAnnouncement.IsReDoubled)
            {
                if (!_lastValidAnnouncement.IsDoubled && isDoubled && !isRedoubled)
                {
                    return(true);
                }
                if (_lastValidAnnouncement.IsDoubled && !isDoubled && isRedoubled)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        private void CompPlayerBidded( Player player, Announcement currentAnnounce )
        {
            SetPlayerActive( null );

            bool isActive = currentAnnounce.CompareTo( _game.CurrentDeal.CurrentAnnouncement ) > 0;
            _passedAnnouncesForm.AddMessage( player.Name, GetAnnouncementString( currentAnnounce ), isActive );

            Thread.Sleep( 1000 - Properties.Settings.Default.Speed*50 );

            this.Text = StringResources.lastBid;
            this.Text += GetAnnouncementString( currentAnnounce );
            this.Text += StringResources.saidBy;
            this.Text += player.Name;
        }