Represents a hand of 4 cards.
Inheritance: CardsCollection
        /// <summary>
        /// Constructor for the class
        /// </summary>
        internal PlayingManager( Announcement current, BelotGame game, CardsCollection _allCards )
        {
            _game = game;
            _playedHands = new List< Hand >();
            _cardToPlayerMap = new Dictionary<Card, Player>();
            _currentAnnouncement = current;
            _currentHand = new Hand();
            _isHandClosed = false;
            _cardComparer = new CardComparer( current.Type );

            _playedCards = new CardsCollection();
            _remainingCards = new CardsCollection();

            foreach( Card card in _allCards )
            {
                _remainingCards.Add( card );
            }
        }
 /// <summary>
 /// Raises the HandClosed event
 /// </summary>
 protected void RaiseHandClosed( Hand hand )
 {
     if( HandClosed != null )
         {
             HandClosed( hand );
         }
 }
 internal void HandIsClosed( Hand hand )
 {
     RaiseHandClosed( hand );
 }
        private void HandClosed( Hand hand )
        {
            Thread.Sleep( 1000 - Properties.Settings.Default.Speed * 20 );

            _game.CurrentDeal.PauseAfterHand = true;

            AnimateHand( hand.Winner.Position );

            _dealResultForm.AddHand( hand );
        }
 public void AddHand( Hand hand )
 {
     _hands.Add( hand );
 }
Exemple #6
0
 private void CalculatePoints( Hand lastHand )
 {
     PlayerPosition pos = lastHand.Winner.Position;
     if( pos == PlayerPosition.East || pos == PlayerPosition.West )
     {
         foreach( Card card in lastHand )
         {
             _eastWestPoints += CardPointEvaluator.EvaluateCard( this._currentAnnouncement.Type, card );
         }
     }
     else
     {
         foreach( Card card in lastHand )
         {
             _northSouthPoints += CardPointEvaluator.EvaluateCard( this._currentAnnouncement.Type, card );
         }
     }
 }
 private CardColor GetPlayingColor( Hand currentHand )
 {
     return currentHand[0].CardColor;
 }
        private Card GetBiggestCard( Hand currentHand, CardColor trumpColor )
        {
            CardColor wantedColor = GetPlayingColor( currentHand );
            Card biggest = currentHand[0];
            bool trumped = false;

            foreach( Card card in currentHand )
            {
                if( !trumped )
                {
                    if( card.CardColor == trumpColor )
                    {
                        trumped = true;
                        if( biggest.CardColor == trumpColor )
                        {
                            if( _cardComparer.Compare( card, biggest ) > 0 )
                            {
                                biggest = card;
                            }
                        }
                        else
                        {
                            biggest = card;
                        }
                    }
                    else if( card.CardColor == wantedColor )
                    {
                        if( _cardComparer.Compare( card, biggest ) > 0 )
                        {
                            biggest = card;
                        }
                    }
                }
                else
                {
                    if( card.CardColor == trumpColor )
                    {
                        if( _cardComparer.Compare( card, biggest ) > 0 )
                        {
                            biggest = card;
                        }
                    }
                }
            }
            return biggest;
        }
 private Card GetBiggestCard( Hand currentHand )
 {
     CardColor wantedColor = GetPlayingColor( currentHand );
     Card biggest = currentHand[0];
     foreach( Card card in currentHand )
     {
         if( card.CardColor == wantedColor )
         {
             if( _cardComparer.Compare( card, biggest ) > 0 )
             {
                 biggest = card;
             }
         }
     }
     return biggest;
 }
        internal void Add( Player player, Card card )
        {
            _cardToPlayerMap.Add( card, player );
            _currentHand.Add( card );

            _playedCards.Add( card );
            _remainingCards.Remove( card );

            CheckForBelotCombination ( player, card );

            if( _currentHand.Count < 4 ) // current hand is open
            {
                _isHandClosed = false;
            }
            else // current hand is closed
            {
                _currentHand.SetWinner( DetermineCurrentHandWinner() );
                _playedHands.Add( _currentHand );
                _currentHand = new Hand();
                _isHandClosed = true;
            }
        }