示例#1
0
        public int CompareTo(object obj)
        {
            if (obj is ResultEntry)
            {
                var        entry  = (ResultEntry)obj;
                RankResult result = HandRanker.IsBetterThan(this, entry);

                if (result == RankResult.Better)
                {
                    return(-1);
                }
                if (result == RankResult.Worse)
                {
                    return(1);
                }
            }

            return(0);
        }
示例#2
0
        public void GetWinners(bool silent)
        {
            var results = new List <ResultEntry>();

            SplitPots();
            foreach (ResultEntry entry in Players.Round.Select(p => new ResultEntry(p)))
            {
                List <Card> bestCards;

                entry.Rank      = HandRanker.GetBestHand(entry.Player.GetAllCards(CommunityCards), out bestCards);
                entry.BestCards = bestCards;

                results.Add(entry);
            }

            results.Sort();

            foreach (PokerPot pokerPot in PokerPots)
            {
                List <ResultEntry> elligiblehands = results;
                elligiblehands.RemoveAll(x => !pokerPot.ContributionToPot.ContainsKey(x.Player));
                pokerPot.winners =
                    elligiblehands.Where(
                        t =>
                        (HandRanker.IsBetterThan(t, results[0]) == RankResult.Same ||
                         pokerPot.ContributionToPot.Count == 1) && pokerPot.ContributionToPot.ContainsKey(t.Player))
                    .Select(t => t.Player)
                    .ToList();
            }

            //IF NOT SILENT
            if (!silent)
            {
                /*//Only hands that have made it past the showdown may be considered for the jackpot
                 * foreach (ResultEntry r in results.Where(t => winners.Contains(t.Player)))
                 * {
                 *  if (PokerDealer.JackpotWinners != null)
                 *  {
                 *      if (HandRanker.IsBetterThan(r, PokerDealer.JackpotWinners.Hand) == RankResult.Better)
                 *      {
                 *          PokerDealer.JackpotWinners = null;
                 *          PokerDealer.JackpotWinners = new PokerDealer.JackpotInfo(winners, r, DateTime.UtcNow,
                 *              TypeOfCurrency);
                 *
                 *          break;
                 *      }
                 *  }
                 *  else
                 *  {
                 *      PokerDealer.JackpotWinners = new PokerDealer.JackpotInfo(winners, r, DateTime.UtcNow,
                 *          TypeOfCurrency);
                 *      break;
                 *  }
                 * }*/

                results.Reverse();

                foreach (ResultEntry entry in results)
                {
                    PokerMessage(entry.Player.Mobile, String.Format("I have {0}.", HandRanker.RankString(entry)));
                }
            }
        }
示例#3
0
        public List <PokerPlayer> GetWinners(bool silent)
        {
            List <ResultEntry> results = new List <ResultEntry>();

            for (int i = 0; i < m_Players.Round.Count; ++i)
            {
                ResultEntry entry     = new ResultEntry(m_Players.Round[i]);
                List <Card> bestCards = new List <Card>();

                entry.Rank      = HandRanker.GetBestHand(entry.Player.GetAllCards(m_CommunityCards), out bestCards);
                entry.BestCards = bestCards;

                results.Add(entry);

                /*if ( !silent )
                 * {
                 *      //Check if kickers needed
                 *      PokerMessage( entry.Player.Mobile, string.Format( "I have {0}.", HandRanker.RankString( entry ) ) );
                 * }*/
            }

            results.Sort();

            if (results.Count < 1)
            {
                return(null);
            }

            List <PokerPlayer> winners = new List <PokerPlayer>();

            for (int i = 0; i < results.Count; ++i)
            {
                if (HandRanker.IsBetterThan(results[i], results[0]) == RankResult.Same)
                {
                    winners.Add(results[i].Player);
                }
            }

            //IF NOT SILENT
            if (!silent)
            {
                //Only hands that have made it past the showdown may be considered for the jackpot
                for (int i = 0; i < results.Count; ++i)
                {
                    if (winners.Contains(results[i].Player))
                    {
                        if (PokerDealer.JackpotWinners != null)
                        {
                            if (HandRanker.IsBetterThan(results[i], PokerDealer.JackpotWinners.Hand) == RankResult.Better)
                            {
                                PokerDealer.JackpotWinners = null;
                                PokerDealer.JackpotWinners = new PokerDealer.JackpotInfo(winners, results[i], DateTime.Now);

                                break;
                            }
                        }
                        else
                        {
                            PokerDealer.JackpotWinners = new PokerDealer.JackpotInfo(winners, results[i], DateTime.Now);
                            break;
                        }
                    }
                }

                results.Reverse();

                foreach (ResultEntry entry in results)
                {
                    //if ( !winners.Contains( entry.Player ) )
                    PokerMessage(entry.Player.Mobile, string.Format("I have {0}.", HandRanker.RankString(entry)));

                    /*else
                     * {
                     *      if ( !HandRanker.UsesKicker( entry.Rank ) )
                     *              PokerMessage( entry.Player, string.Format( "I have {0}.", HandRanker.RankString( entry ) ) );
                     *      else //Hand rank uses a kicker
                     *      {
                     *              switch ( entry.Rank )
                     *              {
                     *              }
                     *      }
                     * }*/
                }
            }

            return(winners);
        }