Summary description for CardCombination.
Inheritance: IComparable
Ejemplo n.º 1
0
        private void PlayerHasTurn(Player player)
        {
            #region Announce combinations on first hand

            if (_playingManager.IsFirstHand && _currentAnnouncement.Type != AnnouncementTypeEnum.NoTrumps)
            {
                CombinationFinder finder = new CombinationFinder(player.Cards);
                foreach (CardCombination combination in finder.Combinations)
                {
                    bool isValidCombination = false;

                    if (combination is SequentialCombination)
                    {
                        Player          biggest            = FindBiggestSequentialCombinationHolder();
                        CardCombination biggestCombination = null;

                        foreach (DictionaryEntry de in _mapSequentialCombinationToPlayer)
                        {
                            if (biggest == de.Value as Player)
                            {
                                biggestCombination = de.Key as CardCombination;
                                break;
                            }
                        }

                        if ((biggest == null) ||
                            (combination.Points >= biggestCombination.Points) ||
                            (player.Position == biggest.Position || player.Position == _game.GetTeamPlayer(biggest).Position))
                        {
                            isValidCombination = true;
                        }
                    }
                    else
                    {
                        isValidCombination = true;
                    }

                    if (isValidCombination && player.AnnounceCombination(combination))
                    {
                        if (combination is SequentialCombination)
                        {
                            _mapSequentialCombinationToPlayer.Add(combination, player);
                        }
                        if (combination is FourEqualsCombination)
                        {
                            _mapEqualCombinationToPlayer.Add(combination, player);
                        }
                    }
                }
            }

            #endregion

            foreach (Card card in player.Cards)
            {
                card.IsSelectable = _playingManager.IsValid(player, card);
            }

            player.PlayCard(_playingManager);
        }
Ejemplo n.º 2
0
        private string GetCombinationStringFull( CardCombination combination )
        {
            StringBuilder sb = new StringBuilder();

            foreach ( Card card in combination.Cards )
            {
                sb.Append( card.ToString() + " " );
            }

            return sb.ToString();
        }
Ejemplo n.º 3
0
        private Player FindBiggestSequentialCombinationHolder( )
        {
            CardCombination biggest = null;
            CardCombination second  = null;

            Player biggestPlayer = null;
            Player secondPlayer  = null;

            foreach (DictionaryEntry de in _mapSequentialCombinationToPlayer)
            {
                CardCombination current = de.Key as CardCombination;

                if (biggest != null)
                {
                    if (current.CompareTo(biggest) > 0)
                    {
                        biggest       = current;
                        biggestPlayer = de.Value as Player;
                    }
                    else if (current.CompareTo(biggest) == 0)
                    {
                        second       = current;
                        secondPlayer = de.Value as Player;
                    }
                }
                else
                {
                    biggest       = current;
                    biggestPlayer = de.Value as Player;
                }
            }

            if (biggest != null && second != null)
            {
                if (biggestPlayer == secondPlayer || biggestPlayer == _game.GetTeamPlayer(secondPlayer))
                {
                    return(biggestPlayer);
                }
            }
            else if (biggest != null)
            {
                return(biggestPlayer);
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override bool AnnounceCombination( CardCombination combination )
        {
            //TODO implement whether player wants to announce this combination

            RaiseCardCombinationAnnounced( combination );
            return true;
        }
Ejemplo n.º 5
0
 public override bool AnnounceCombination( CardCombination combination )
 {
     return RaiseCardCombinationAnnouncing( combination );
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Raises the CardCombinationAnnouncing event
 /// </summary>
 protected bool RaiseCardCombinationAnnouncing( CardCombination combination )
 {
     if ( CardCombinationAnnouncing != null )
     {
         return CardCombinationAnnouncing( this, combination );
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 7
0
        private bool HumanCardCombinationAnnouncing( Player player, CardCombination combination )
        {
            bool isAnnounced = false;

            _combinationForm.Combination = combination;
            isAnnounced = ( _combinationForm.ShowDialog() == DialogResult.OK );

            if ( isAnnounced )
            {
                CombinationAnnounced( player, combination );
            }

            return isAnnounced;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets a string representation of a Combination
        /// </summary>
        private string GetCombinationString( CardCombination combination )
        {
            string str = "";

            if ( combination is FourEqualsCombination )
            {
                str = StringResources.fourEqual;
            }

            if ( combination is BelotCombination )
            {
                str = StringResources.belot;
            }

            if ( combination is SequentialCombination )
            {
                if ( combination.Points == 20 )
                {
                    str = StringResources.threeSeq;
                }

                if ( combination.Points == 50 )
                {
                    str = StringResources.fourSeq;
                }

                if ( combination.Points == 100 )
                {
                    str = StringResources.fiveSeq;
                }
            }

            return str;
        }
Ejemplo n.º 9
0
        private void CombinationAnnounced( Player player, CardCombination combination )
        {
            _passedAnnouncesForm.AddMessage( player.Name, GetCombinationString( combination ), false );

            _dealResultForm.AddCombination( player, combination );
        }
Ejemplo n.º 10
0
 public void AddCombination( Player player, CardCombination combination )
 {
     _mapCombinationToPlayer.Add( combination, player );
 }
Ejemplo n.º 11
0
 /// <summary>
 /// The player has a combination in his cards.
 /// </summary>
 /// <param name="combination">The combination of cards tha player has</param>
 /// <returns>true if player wants to announce this combination</returns>
 public abstract bool AnnounceCombination(CardCombination combination);
Ejemplo n.º 12
0
 /// <summary>
 /// The player has a combination in his cards.
 /// </summary>
 /// <param name="combination">The combination of cards tha player has</param>
 /// <returns>true if player wants to announce this combination</returns>
 public abstract bool AnnounceCombination( CardCombination combination );