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); }
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))); } } }
public PokerPlayer AssignNextTurn() { PokerPlayer nextTurn = Players.Next(); if (nextTurn == null) { return(null); } if (nextTurn.RequestLeave) { Players.Push(nextTurn); nextTurn.BetStart = DateTime.UtcNow; nextTurn.Action = PlayerAction.Fold; return(nextTurn); } if (nextTurn.IsAllIn) { Players.Push(nextTurn); nextTurn.BetStart = DateTime.UtcNow; nextTurn.Action = PlayerAction.AllIn; return(nextTurn); } if (nextTurn.LonePlayer) { Players.Push(nextTurn); nextTurn.BetStart = DateTime.UtcNow; nextTurn.Action = PlayerAction.Check; return(nextTurn); } bool canCall = false; PokerPlayer currentTurn = Players.Peek(); if (currentTurn != null && currentTurn.Action != PlayerAction.Check && currentTurn.Action != PlayerAction.Fold) { canCall = true; } if (currentTurn == null && State == PokerGameState.PreFlop) { canCall = true; } Players.Push(nextTurn); nextTurn.BetStart = DateTime.UtcNow; var entry = new ResultEntry(nextTurn); List <Card> bestCards; entry.Rank = nextTurn.GetBestHand(CommunityCards, out bestCards); entry.BestCards = bestCards; nextTurn.SendMessage(0x22, String.Format("You have {0}.", HandRanker.RankString(entry))); nextTurn.CloseGump(typeof(PokerBetGump)); nextTurn.SendGump(new PokerBetGump(this, nextTurn, canCall)); NeedsGumpUpdate = true; return(nextTurn); }
public static void AwardJackpot() { if (m_JackpotWinners != null && m_JackpotWinners.Winners != null && m_JackpotWinners.Winners.Count > 0) { int award = m_Jackpot / m_JackpotWinners.Winners.Count; if (award <= 0) { return; } foreach (PokerPlayer m in m_JackpotWinners.Winners) { if (m != null && m.Mobile != null && m.Mobile.BankBox != null) { m.Mobile.BankBox.DropItem(new BankCheck(award)); World.Broadcast(1161, true, "{0} has won the poker jackpot of {1} gold with {2}", m.Mobile.Name, award.ToString("#,###"), HandRanker.RankString(m_JackpotWinners.Hand)); } } m_Jackpot = 0; m_JackpotWinners = null; } }
public HandRank GetBestHand(List <Card> communityCards, out List <Card> bestCards) { return(HandRanker.GetBestHand(GetAllCards(communityCards), out bestCards)); }
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); }