private static bool AnalyzeLine(string text, PokerTournamentSummary pts) { if (text.Equals("Freeroll")) { pts.CurrencyBuyIn = PokerEnums.Currency.Freeroll; return true; } if (text.Equals("Super Satellite")) { pts.IsSatellite = true; return true; } if (text.Equals("You are still playing in this tournament.")) return true; if (text.Equals("Statistics for this tournament are not available.")) return true; if (text.Equals("We currently do not record hands in freeroll tournaments.")) return true; Match match; #region Header match = RegexHeader.Match(text); if (match.Success) { pts.TournamentNumber = long.Parse(match.Groups["tournament_number"].Value); pts.GameType = match.Groups["game_type"].Value; return true; } #endregion #region BuyIn match = RegexBuyIn.Match(text); if (match.Success) { if (match.Groups["buyin_currency_symbol"].Success) { switch (match.Groups["buyin_currency_symbol"].Value) { case "$": pts.CurrencyBuyIn = PokerEnums.Currency.USD; break; case "€": pts.CurrencyBuyIn = PokerEnums.Currency.EUR; break; case "£": pts.CurrencyBuyIn = PokerEnums.Currency.GBP; break; default: pts.CurrencyBuyIn = PokerEnums.Currency.Unknown; break; } } else { pts.CurrencyBuyIn = PokerEnums.Currency.PlayMoney; } pts.BuyIn = decimal.Parse(match.Groups["buyin"].Value); pts.Rake = decimal.Parse(match.Groups["rake"].Value); pts.TotalBuyIn = pts.BuyIn + pts.Rake; return true; } #endregion #region PlayerCount match = RegexPlayerCount.Match(text); if (match.Success) { pts.PlayerCount = int.Parse(match.Groups["player_count"].Value); return true; } #endregion #region PrizePool match = RegexPrizePool.Match(text); if (match.Success) { if (match.Groups["prize_currency_symbol"].Success) { switch (match.Groups["prize_currency_symbol"].Value) { case "$": pts.CurrencyPrizePool = PokerEnums.Currency.USD; break; case "€": pts.CurrencyPrizePool = PokerEnums.Currency.EUR; break; case "£": pts.CurrencyPrizePool = PokerEnums.Currency.GBP; break; default: pts.CurrencyPrizePool = PokerEnums.Currency.Unknown; break; } } else { pts.CurrencyPrizePool = PokerEnums.Currency.PlayMoney; } pts.PrizePool = decimal.Parse(match.Groups["prize"].Value); return true; } #endregion #region TargetTournament match = RegexTargetTournament.Match(text); if (match.Success) { if (match.Groups["tournament_currency_symbol"].Success) { switch (match.Groups["tournament_currency_symbol"].Value) { case "$": pts.CurrencyTargetBuyIn = PokerEnums.Currency.USD; break; case "€": pts.CurrencyTargetBuyIn = PokerEnums.Currency.EUR; break; case "£": pts.CurrencyTargetBuyIn = PokerEnums.Currency.GBP; break; default: pts.CurrencyTargetBuyIn = PokerEnums.Currency.Unknown; break; } } else { pts.CurrencyTargetBuyIn = PokerEnums.Currency.PlayMoney; } pts.TargetTournamentBuyIn = decimal.Parse(match.Groups["tournament_buyin"].Value); return true; } #endregion #region TournamentStarted match = RegexTournamentStarted.Match(text); if (match.Success) { pts.TournamentStartedLocal = new DateTime(int.Parse(match.Groups["year"].Value), int.Parse(match.Groups["month"].Value), int.Parse(match.Groups["day"].Value), int.Parse(match.Groups["hour"].Value), int.Parse(match.Groups["minute"].Value), int.Parse(match.Groups["second"].Value)); pts.TournamentStartedLocalTimeZone = match.Groups["timezone"].Value; pts.TournamentStartedET = new DateTime(int.Parse(match.Groups["year_et"].Value), int.Parse(match.Groups["month_et"].Value), int.Parse(match.Groups["day_et"].Value), int.Parse(match.Groups["hour_et"].Value), int.Parse(match.Groups["minute_et"].Value), int.Parse(match.Groups["second_et"].Value)); return true; } #endregion #region TournamentFinished match = RegexTournamentFinished.Match(text); if (match.Success) { pts.TournamentFinishedLocal = new DateTime(int.Parse(match.Groups["year"].Value), int.Parse(match.Groups["month"].Value), int.Parse(match.Groups["day"].Value), int.Parse(match.Groups["hour"].Value), int.Parse(match.Groups["minute"].Value), int.Parse(match.Groups["second"].Value)); pts.TournamentFinishedLocalTimeZone = match.Groups["timezone"].Value; pts.TournamentFinishedET = new DateTime(int.Parse(match.Groups["year_et"].Value), int.Parse(match.Groups["month_et"].Value), int.Parse(match.Groups["day_et"].Value), int.Parse(match.Groups["hour_et"].Value), int.Parse(match.Groups["minute_et"].Value), int.Parse(match.Groups["second_et"].Value)); return true; } #endregion #region Player match = RegexPlayer.Match(text); if (match.Success) { var player = new Player { Place = int.Parse(match.Groups["place"].Value), PlayerName = match.Groups["player_name"].Value, }; if (match.Groups["country"].Success) player.Country = match.Groups["country"].Value; if (match.Groups["still_playing"].Success) player.StillPlaying = true; if (match.Groups["qualified"].Success) player.QualifiedForTournament = true; if (match.Groups["prize"].Success) { player.Prize = decimal.Parse(match.Groups["prize"].Value); if (match.Groups["prize_currency_symbol"].Success) { switch (match.Groups["prize_currency_symbol"].Value) { case "$": pts.CurrencyPrizePool = PokerEnums.Currency.USD; break; case "€": pts.CurrencyPrizePool = PokerEnums.Currency.EUR; break; case "£": pts.CurrencyPrizePool = PokerEnums.Currency.GBP; break; default: pts.CurrencyPrizePool = PokerEnums.Currency.Unknown; break; } } else { pts.CurrencyPrizePool = PokerEnums.Currency.PlayMoney; } } pts.Players.Add(player); return true; } #endregion #region FinishedPlace match = RegexFinishedPlace.Match(text); if (match.Success) { pts.HeroPlace = int.Parse(match.Groups["place"].Value); return true; } #endregion return false; }
public static PokerTournamentSummary FromTournamentSummary(string tournamentSummary) { PokerTournamentSummary pts = new PokerTournamentSummary(); foreach (var line in tournamentSummary.Split(new[] { Environment.NewLine, "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)) { AnalyzeLine(line.TrimStart(' ').TrimEnd(' '), pts); } pts.TournamentSummary = tournamentSummary; return pts; }