public IsValid ( |
||
player | ||
announce | ||
Résultat | bool |
public override Announcement MakeAnnouncement( AnnouncementManager manager ) { _allAnnounces = manager.GetAllAnnouncements(); Announcement announce = null; bool isValidFound = false; int sum = 0; int count = 0; const int MIN_FOR_TRUMP = 34; const int MIN_FOR_NOTRUMPS = 34; const int MIN_FOR_ALLTRUMPS = 60; //const int POINTS_TO_ADD = 5; // add 5 or 10 points if player has 4 or 5 cards of same color #region Check Clubs if ( !isValidFound ) { foreach ( Card card in this.Cards ) { sum += CardPointEvaluator.EvaluateCard( AnnouncementTypeEnum.Clubs, card ); if ( card.CardColor == CardColor.Clubs ) { count++; } } if ( sum > MIN_FOR_TRUMP && count > 2 ) { if ( AnnouncementTypeEnum.Clubs == manager.GetLastValidAnnouncement().Type ) { announce = new Announcement( AnnouncementTypeEnum.Clubs, true, false ); } else { announce = new Announcement( AnnouncementTypeEnum.Clubs, false, false ); } isValidFound = manager.IsValid( this, announce ); } } #endregion #region Check Diamonds sum = 0; count = 0; if ( !isValidFound ) { foreach ( Card card in this.Cards ) { sum += CardPointEvaluator.EvaluateCard( AnnouncementTypeEnum.Diamonds, card ); if ( card.CardColor == CardColor.Diamonds ) { count++; } } if ( sum > MIN_FOR_TRUMP && count > 2 ) { if ( AnnouncementTypeEnum.Diamonds == manager.GetLastValidAnnouncement().Type ) { announce = new Announcement( AnnouncementTypeEnum.Diamonds, true, false ); } else { announce = new Announcement( AnnouncementTypeEnum.Diamonds, false, false ); } isValidFound = manager.IsValid( this, announce ); } } #endregion #region Check Hearts sum = 0; count = 0; if ( !isValidFound ) { foreach ( Card card in this.Cards ) { sum += CardPointEvaluator.EvaluateCard( AnnouncementTypeEnum.Hearts, card ); if ( card.CardColor == CardColor.Hearts ) { count++; } } if ( sum > MIN_FOR_TRUMP && count > 2 ) { if ( AnnouncementTypeEnum.Hearts == manager.GetLastValidAnnouncement().Type ) { announce = new Announcement( AnnouncementTypeEnum.Hearts, true, false ); } else { announce = new Announcement( AnnouncementTypeEnum.Hearts, false, false ); } isValidFound = manager.IsValid( this, announce ); } } #endregion #region Check Spades sum = 0; count = 0; if ( !isValidFound ) { foreach ( Card card in this.Cards ) { sum += CardPointEvaluator.EvaluateCard( AnnouncementTypeEnum.Spades, card ); if ( card.CardColor == CardColor.Spades ) { count++; } } if ( sum > MIN_FOR_TRUMP && count > 2 ) { if ( AnnouncementTypeEnum.Spades == manager.GetLastValidAnnouncement().Type ) { announce = new Announcement( AnnouncementTypeEnum.Spades, true, false ); } else { announce = new Announcement( AnnouncementTypeEnum.Spades, false, false ); } isValidFound = manager.IsValid( this, announce ); } } #endregion #region Check No Trumps sum = 0; if ( !isValidFound ) { foreach ( Card card in this.Cards ) { sum += CardPointEvaluator.EvaluateCard( AnnouncementTypeEnum.NoTrumps, card ); } if ( sum > MIN_FOR_NOTRUMPS ) { if ( AnnouncementTypeEnum.NoTrumps == manager.GetLastValidAnnouncement().Type ) { announce = new Announcement( AnnouncementTypeEnum.NoTrumps, true, false ); } else { announce = new Announcement( AnnouncementTypeEnum.NoTrumps, false, false ); } isValidFound = manager.IsValid( this, announce ); } } #endregion #region Check All Trumps sum = 0; count = 0; if ( !isValidFound ) { foreach ( Card card in this.Cards ) { sum += CardPointEvaluator.EvaluateCard( AnnouncementTypeEnum.AllTrumps, card ); } if ( sum > MIN_FOR_ALLTRUMPS ) { if ( AnnouncementTypeEnum.AllTrumps == manager.GetLastValidAnnouncement().Type ) { announce = new Announcement( AnnouncementTypeEnum.AllTrumps, true, false ); } else { announce = new Announcement( AnnouncementTypeEnum.AllTrumps, false, false ); } isValidFound = manager.IsValid( this, announce ); } } #endregion if ( !isValidFound ) { announce = new Announcement( AnnouncementTypeEnum.Pass, false, false ); } RaiseAnnounceMade( announce ); return announce; }