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); }
private string GetCombinationStringFull( CardCombination combination ) { StringBuilder sb = new StringBuilder(); foreach ( Card card in combination.Cards ) { sb.Append( card.ToString() + " " ); } return sb.ToString(); }
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); }
public override bool AnnounceCombination( CardCombination combination ) { //TODO implement whether player wants to announce this combination RaiseCardCombinationAnnounced( combination ); return true; }
public override bool AnnounceCombination( CardCombination combination ) { return RaiseCardCombinationAnnouncing( combination ); }
/// <summary> /// Raises the CardCombinationAnnouncing event /// </summary> protected bool RaiseCardCombinationAnnouncing( CardCombination combination ) { if ( CardCombinationAnnouncing != null ) { return CardCombinationAnnouncing( this, combination ); } else { return false; } }
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; }
/// <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; }
private void CombinationAnnounced( Player player, CardCombination combination ) { _passedAnnouncesForm.AddMessage( player.Name, GetCombinationString( combination ), false ); _dealResultForm.AddCombination( player, combination ); }
public void AddCombination( Player player, CardCombination combination ) { _mapCombinationToPlayer.Add( combination, player ); }
/// <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);
/// <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 );