private OverviewDetails LoadCashOverview() { OverviewDetails details = new OverviewDetails(); IAggregateFluent <HandHistory> cashGameHands = handCollection.Aggregate().Match(h => h.GameDescription.PokerFormat == PokerFormat.CashGame && h.GameDescription.Limit.Currency != Currency.PlayMoney); IAggregateFluent <UnwoundHand> actions = cashGameHands .Unwind <HandHistory, UnwoundHand>(h => h.HandActions) .Match(h => PlayerNames.Contains(h.HandActions.PlayerName)); if (!cashGameHands.Any()) { return(details); // Return empty result set if there are no hands available } details.Hands = cashGameHands.Count().First().Count; foreach (var profit in actions.Group(h => h.HandId, h => new { sum = h.Sum(h2 => h2.HandActions.Amount * h2.GameDescription.Limit.BigBlind) }).ToEnumerable()) { if (profit.sum > 0) { details.Winnings += profit.sum; } else { details.Losses += profit.sum; } } return(details); }
public void LoadOverview() { OverviewDetails cashGameDetails = LoadCashOverview(); AddStatistic("cashHands", cashGameDetails.Hands.ToString()); AddStatistic("cashWinnings", cashGameDetails.Winnings.ToString(dollarPattern)); AddStatistic("cashLosses", cashGameDetails.Losses.ToString(dollarPattern)); OverviewDetails tournamentDetails = LoadTournamentOverview(false); AddStatistic("tournamentHands", tournamentDetails.Hands.ToString()); AddStatistic("tournamentWinnings", tournamentDetails.Winnings.ToString(dollarPattern)); AddStatistic("freerollWinnings", () => tournamentCollection.Aggregate().Match(t => t.Buyin.Total == 0) .Group(t => t.SitAndGo, t => new { sum = t.Sum(t2 => t2.Winnings) }).First().sum.ToString(dollarPattern)); AddStatistic("tournamentCosts", tournamentDetails.Losses.ToString(dollarPattern)); AddStatistic("tournamentsPlayed", tournamentDetails.Tournaments.ToString()); OverviewDetails sitAndGoDetails = LoadTournamentOverview(true); AddStatistic("sitAndGoHands", sitAndGoDetails.Hands.ToString()); AddStatistic("sitAndGoWinnings", sitAndGoDetails.Winnings.ToString(dollarPattern)); AddStatistic("sitAndGoCosts", sitAndGoDetails.Losses.ToString(dollarPattern)); AddStatistic("sitAndGosPlayed", sitAndGoDetails.Tournaments.ToString()); decimal totalProfit = cashGameDetails.Winnings + tournamentDetails.Winnings + sitAndGoDetails.Winnings + cashGameDetails.Losses + tournamentDetails.Losses + sitAndGoDetails.Losses; long totalHands = cashGameDetails.Hands + tournamentDetails.Hands + sitAndGoDetails.Hands; AddStatistic("handsPlayed", totalHands.ToString()); AddStatistic("profit", totalProfit.ToString(dollarPattern)); }
private OverviewDetails LoadTournamentOverview(bool sitAndGo) { OverviewDetails details = new OverviewDetails(); PokerFormat format = sitAndGo ? PokerFormat.SitAndGo : PokerFormat.MultiTableTournament; IAggregateFluent <HandHistory> hands = handCollection.Aggregate().Match(h => h.GameDescription.PokerFormat == format); if (!hands.Any()) { return(details); } details.Hands = hands.Count().First().Count; IAggregateFluent <TournamentSummary> tournaments = tournamentCollection.Aggregate() .Match(t => t.SitAndGo == sitAndGo && t.Buyin.Currency != Currency.PlayMoney); details.Winnings = tournaments.Group(t => t.SitAndGo, t => new { sum = t.Sum(t2 => t2.Winnings) }).First().sum; details.Losses = -tournaments.Group(t => t.SitAndGo, t => new { sum = t.Sum(t2 => t2.Buyin.Total + t2.Rebuy.Total * t2.RebuyCount + t2.AddOn.Total) }).First().sum; details.Tournaments = tournaments.Count().First().Count; return(details); }