public static string CardHandName(EvaluatorStrength es) { switch (es.HandType) { case Enums.HandType.StraightFlush: return("poker od " + CardModel.GetNormalize(es.WinCardList.First(), CardModel.NormalizeNominalSize.ONE)); case Enums.HandType.Straight: return("strit od " + CardModel.GetNormalizeNominal(es.WinCardList.First().Face, CardModel.NormalizeNominalSize.ONE)); case Enums.HandType.Flush: return("kolor " + CardModel.GetNormalizeSuit(es.WinCardList.First().Suit) + " do " + CardModel.GetNormalizeNominal(es.WinCardList.First().Face, CardModel.NormalizeNominalSize.ONE)); case Enums.HandType.FullHouse: var kList = es.WinCardList. GroupBy(g => g.Face). OrderBy(g => g.Count()). Select(g => new { Face = g.First().Face, Count = g.Count() }); return("fula " + CardModel.GetNormalizeNominal(kList.First().Face, CardModel.NormalizeNominalSize.MANY) + " na " + CardModel.GetNormalizeNominal(kList.Last().Face, CardModel.NormalizeNominalSize.MANY)); case Enums.HandType.FourOfAKind: return("czwórkę " + CardModel.GetNormalizeNominal(es.WinCardList.First().Face, CardModel.NormalizeNominalSize.MANY)); case Enums.HandType.ThreeOfAKind: return("trójkę " + CardModel.GetNormalizeNominal(es.WinCardList.First().Face, CardModel.NormalizeNominalSize.MANY)); case Enums.HandType.TwoPair: var pList = es.WinCardList. GroupBy(g => g.Face). OrderBy(g => g.Count()). Select(g => new { Face = g.First().Face, Count = g.Count() }); return("dwie pary, " + CardModel.GetNormalizeNominal(pList.First().Face, CardModel.NormalizeNominalSize.MANY) + " oraz " + CardModel.GetNormalizeNominal(pList.Last().Face, CardModel.NormalizeNominalSize.MANY)); case Enums.HandType.Pair: return("parę " + CardModel.GetNormalizeNominal(es.WinCardList.First().Face, CardModel.NormalizeNominalSize.MANY)); case Enums.HandType.HighCard: return("najwyższą kartę " + CardModel.GetNormalizeNominal(es.WinCardList.First().Face, CardModel.NormalizeNominalSize.ONE)); } return("---Błąd---"); }
/// <summary> /// Rozdzielanie puli według układów /// </summary> public void ShowdownPotDistribution() { var gameTable = Game.GameTableModel; //Sortujemy od najsilniejszych układów var evaluatorGroupedList = Evaluator.EvaluatorStrenghtList. GroupBy(c => c.FullPoints). OrderByDescending(e => e.First().FullPoints).ThenBy(e => e.OrderBy(f => f.Contributed)). ToList(); //Suma pinieniędzy decimal totalPot = gameTable.ActionHistory.OfType <BetAction>().Sum(c => c.Bet); //Wszystkie wyniki na jednym poziomie var contributionFlatList = gameTable.ActionHistory.OfType <BetAction>().GroupBy(c => c.Player).Select(c => new PlayerContributed { Player = c.First().Player, Contributed = c.Sum(e => e.Bet) }).ToList(); foreach (var evaluatorItem in evaluatorGroupedList) { foreach (var evaluatorPlayer in evaluatorItem) { decimal winPot = 0; decimal evaluatorPlayerContributed = evaluatorPlayer.Contributed; foreach (var evaluatorContributedPlayer in contributionFlatList) { decimal takenPot = 0; if (evaluatorContributedPlayer.Contributed >= evaluatorPlayerContributed) { takenPot = evaluatorPlayerContributed; } else { takenPot = evaluatorContributedPlayer.Contributed; } evaluatorContributedPlayer.Contributed -= takenPot; winPot += takenPot; } winPot = winPot / (evaluatorItem.Count()); if (winPot == 0) { break; } //Infomracja o wygranej puli string message; if (evaluatorPlayer.IsBest == true) { message = "Gracz " + evaluatorPlayer.Player.User.Username + " wygrywa główną pulę " + CurrencyFormat.Get(gameTable.Currency, winPot); } else { message = "Gracz " + evaluatorPlayer.Player.User.Username + " wygrywa boczną pulę " + CurrencyFormat.Get(gameTable.Currency, winPot); } if (evaluatorPlayer.IsKickerWin) { message += " kickerem " + CardModel.GetNormalizeNominal(evaluatorPlayer.KickerCards.FirstOrDefault().Face, CardModel.NormalizeNominalSize.ONE); } OnShowdownWinnerEvent(evaluatorPlayer); TablePotAction tablePotAction = new TablePotAction() { Stage = Game.GameTableModel.Stage, CreatedAt = DateTime.Now, Player = evaluatorPlayer.Player, Pot = winPot }; Game.GameTableModel.ActionHistory.Add(tablePotAction); Game.SendDealerMessage(message); Console.WriteLine(message); gameTable.ShowSystemMessage("Wygrana " + evaluatorPlayer.Player.User.Username, message); Thread.Sleep(2000); gameTable.HideSystemMessage(); } } }