public Shows(string commandText, Player player, string info) : base(commandText) { Player = player; Info = info; }
public UncalledBetReturn(string commandText, Player player, decimal amount) : base(commandText) { Player = player; Amount = amount; }
public PostSmallBlind(string commandText, Player player, decimal amount) : base(commandText) { Player = player; Amount = amount; }
public Raise(string commandText, Player player, decimal amountInTotal, bool allIn) : base(commandText) { Player = player; AmountInTotal = amountInTotal; AllIn = allIn; }
public DealtTo(string commandText, Player player) : base(commandText) { Player = player; }
public Fold(string commandText, Player player, bool foldAndShow) : base(commandText) { Player = player; FoldAndShow = foldAndShow; }
public CollectFromPot(string commandText, Player player, decimal amount) : base(commandText) { Player = player; Amount = amount; }
public Check(string commandText, Player player) : base(commandText) { Player = player; }
public Call(string commandText, Player player, decimal amount, bool allIn) : base(commandText) { Player = player; Amount = amount; AllIn = allIn; }
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; }
private static bool AnalyzeLine(string text, PokerHand pokerHand) { if (text.Equals("*** SHOW DOWN ***")) { pokerHand.PokerCommands.Add(new PokerCommands.CollectPots(Street.River)); pokerHand.PokerCommands.Add(new PokerCommands.FinalizePots()); pokerHand.Showdown = true; return true; } if (text.Equals("*** HOLE CARDS ***")) return true; if (text.Equals("*** SUMMARY ***")) return true; if (text.StartsWith("Board [")) return true; if (text.StartsWith("Seat ") && (text.Contains("folded") || text.Contains("showed") || text.Contains("collected"))) return true; if (text.Contains("doesn't show hand")) return true; if (text.Contains(" has timed out")) return true; if (text.Contains(" has timed out while being disconnected")) return true; if (text.Contains(" has timed out while disconnected")) return true; if (text.Contains(" is sitting out") && !text.StartsWith("Seat ")) return true; if (text.Contains(" has returned")) return true; if (text.Contains(" is disconnected")) return true; if (text.Contains(" is connected")) return true; if (text.Contains(" sits out")) return true; if (text.Contains(" joins the table at seat #")) return true; if (text.Contains(" will be allowed to play after the button")) return true; if (text.Contains(" leaves the table")) return true; if (text.Contains(" for eliminating ") && text.Contains(" bounty ")) return true; if (text.Contains(" wins an entry to tournament ")) return true; if (text.Contains(" wins the tournament - congratulations!")) return true; if (text.Contains(" re-buys and receives ")) return true; if (text.Contains(" takes the add-on and receives ")) return true; if (text.Contains("also received a Golden Sit & Go reward of ")) return true; Match match; #region 1st Line if (Regex1stLine.Match(text).Success) { if (text.Contains("Tournament #")) { match = RegexHeaderTournament.Match(text); if (!match.Success) throw new NotSupportedException(); pokerHand.IsTournament = true; pokerHand.HandNumber = long.Parse(match.Groups["hand_id"].Value); pokerHand.TournamentNumber = long.Parse(match.Groups["tournament_id"].Value); if (match.Groups["zoom"].Success) pokerHand.IsZoom = true; if (match.Groups["currency"].Success) { switch (match.Groups["currency"].Value) { case "USD": pokerHand.Currency = PokerEnums.Currency.USD; break; case "EUR": pokerHand.Currency = PokerEnums.Currency.EUR; break; case "BGP": pokerHand.Currency = PokerEnums.Currency.GBP; break; case "": pokerHand.Currency = PokerEnums.Currency.PlayMoney; break; default: pokerHand.Currency = PokerEnums.Currency.Unknown; break; } } if (match.Groups["buyin_fpp"].Success) pokerHand.Currency = PokerEnums.Currency.FPP; if (match.Groups["freeroll"].Success) pokerHand.Currency = PokerEnums.Currency.Freeroll; if (match.Groups["buyin"].Success) pokerHand.BuyIn = decimal.Parse(match.Groups["buyin"].Value); if (match.Groups["bounty"].Success) pokerHand.Bounty = decimal.Parse(match.Groups["bounty"].Value); if (match.Groups["rake"].Success) pokerHand.Rake = decimal.Parse(match.Groups["rake"].Value); if (pokerHand.Currency == PokerEnums.Currency.FPP) pokerHand.BuyIn = decimal.Parse(match.Groups["buyin_fpp"].Value); pokerHand.GameType = match.Groups["game_type"].Value; if (match.Groups["additional_info"].Success) pokerHand.AdditionalInfo = match.Groups["additional_info"].Value; pokerHand.LevelNumber = match.Groups["level_number"].Value; pokerHand.LevelSmallBlind = decimal.Parse(match.Groups["level_sb"].Value); pokerHand.LevelBigBlind = decimal.Parse(match.Groups["level_bb"].Value); if (match.Groups["timezone_et_only"].Success) { pokerHand.TimeStampLocal = new DateTime(int.Parse(match.Groups["year_et_only"].Value), int.Parse(match.Groups["month_et_only"].Value), int.Parse(match.Groups["day_et_only"].Value), int.Parse(match.Groups["hour_et_only"].Value), int.Parse(match.Groups["minute_et_only"].Value), int.Parse(match.Groups["second_et_only"].Value)); pokerHand.LocalTimeZoneStr = match.Groups["timezone_et_only"].Value; pokerHand.LocalTimeZone = TimeZone.Parse(pokerHand.LocalTimeZoneStr); pokerHand.TimeStampET = pokerHand.TimeStampLocal; } else { pokerHand.TimeStampLocal = 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)); pokerHand.LocalTimeZoneStr = match.Groups["timezone"].Value; pokerHand.LocalTimeZone = TimeZone.Parse(pokerHand.LocalTimeZoneStr); pokerHand.TimeStampET = 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)); } pokerHand.TotalBuyIn = pokerHand.BuyIn + pokerHand.Bounty + pokerHand.Rake; return true; } else { match = RegexHeaderCash.Match(text); if (!match.Success) throw new NotSupportedException(); if (match.Groups["zoom"].Success) pokerHand.IsZoom = true; pokerHand.HandNumber = long.Parse(match.Groups["hand_id"].Value); pokerHand.GameType = match.Groups["game_type"].Value; pokerHand.LevelSmallBlind = decimal.Parse(match.Groups["level_sb"].Value); pokerHand.LevelBigBlind = decimal.Parse(match.Groups["level_bb"].Value); if (match.Groups["currency"].Success) { switch (match.Groups["currency"].Value) { case "USD": pokerHand.Currency = PokerEnums.Currency.USD; break; case "EUR": pokerHand.Currency = PokerEnums.Currency.EUR; break; case "BGP": pokerHand.Currency = PokerEnums.Currency.GBP; break; default: pokerHand.Currency = PokerEnums.Currency.Unknown; break; } } else { if (match.Groups["level_sb_currency_symbol"].Success) { switch (match.Groups["level_sb_currency_symbol"].Value) { case "$": pokerHand.Currency = PokerEnums.Currency.USD; break; case "€": pokerHand.Currency = PokerEnums.Currency.EUR; break; case "£": pokerHand.Currency = PokerEnums.Currency.GBP; break; default: pokerHand.Currency = PokerEnums.Currency.Unknown; break; } } else { pokerHand.Currency = PokerEnums.Currency.PlayMoney; } } if (match.Groups["timezone_et_only"].Success) { pokerHand.TimeStampLocal = new DateTime(int.Parse(match.Groups["year_et_only"].Value), int.Parse(match.Groups["month_et_only"].Value), int.Parse(match.Groups["day_et_only"].Value), int.Parse(match.Groups["hour_et_only"].Value), int.Parse(match.Groups["minute_et_only"].Value), int.Parse(match.Groups["second_et_only"].Value)); pokerHand.LocalTimeZoneStr = match.Groups["timezone_et_only"].Value; pokerHand.LocalTimeZone = TimeZone.Parse(pokerHand.LocalTimeZoneStr); pokerHand.TimeStampET = pokerHand.TimeStampLocal; } else { pokerHand.TimeStampLocal = 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)); pokerHand.LocalTimeZoneStr = match.Groups["timezone"].Value; pokerHand.LocalTimeZone = TimeZone.Parse(pokerHand.LocalTimeZoneStr); pokerHand.TimeStampET = 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 2nd Line match = RegexSeatMaxButton.Match(text); if (match.Success) { pokerHand.TableName = match.Groups["table_name"].Value; pokerHand.TableSize = (PokerEnums.TableSize)int.Parse(match.Groups["table_size"].Value); pokerHand.ButtonSeatHandHistory = int.Parse(match.Groups["button_seat"].Value); pokerHand.ButtonSeat = pokerHand.ButtonSeatHandHistory - 1; pokerHand.Seats = new Player[(int)pokerHand.TableSize]; return true; } #endregion #region Player match = RegexPlayer.Match(text); if (match.Success) { Player player = new Player(); player.SeatNumberHandHistory = int.Parse(match.Groups["seat_number"].Value); player.SeatNumber = player.SeatNumberHandHistory - 1; player.PlayerName = match.Groups["player_name"].Value; player.Stack = decimal.Parse(match.Groups["stack"].Value); player.IsInPlay = true; pokerHand.Seats[player.SeatNumber] = player; return true; } #endregion // #region Post sb/bb/ante match = RegexPostBlinds.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); decimal amount = decimal.Parse(match.Groups["amount"].Value); switch (match.Groups["type"].Value) { case "the ante": pokerHand.PokerCommands.Add(new PokerCommands.PostAnte(text, player, amount)); break; case "small blind": pokerHand.PokerCommands.Add(new PokerCommands.PostSmallBlind(text, player, amount)); break; case "big blind": pokerHand.PokerCommands.Add(new PokerCommands.PostBigBlind(text, player, amount)); break; } return true; } #endregion #region Dealt to match = RegexDealtTo.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); var cards = new[] { match.Groups["card0"].Value, match.Groups["card1"].Value }; player.PocketCards = cards; player.IsHero = true; pokerHand.PokerCommands.Add(new PokerCommands.DealtTo(text, player)); return true; } #endregion #region Fold match = RegexFold.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); bool foldAndShow = true; if (match.Groups["card1"].Success) { player.PocketCards = new[] { match.Groups["card0"].Value, match.Groups["card1"].Value }; } else if (match.Groups["card0"].Success) { player.PocketCards = new[] { match.Groups["card0"].Value }; } else { foldAndShow = false; } pokerHand.PokerCommands.Add(new PokerCommands.Fold(text, player, foldAndShow)); return true; } #endregion #region Check match = RegexCheck.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); pokerHand.PokerCommands.Add(new PokerCommands.Check(text, player)); return true; } #endregion #region Call match = RegexCall.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); decimal amount = decimal.Parse(match.Groups["amount"].Value); bool allIn = match.Groups["all_in"].Success; pokerHand.PokerCommands.Add(new PokerCommands.Call(text, player, amount, allIn)); return true; } #endregion #region Bet match = RegexBet.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); decimal amount = decimal.Parse(match.Groups["amount"].Value); bool allIn = match.Groups["all_in"].Success; pokerHand.PokerCommands.Add(new PokerCommands.Bet(text, player, amount, allIn)); return true; } #endregion #region Raise match = RegexRaise.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); decimal amountInTotal = decimal.Parse(match.Groups["amount_in_total"].Value); bool allIn = match.Groups["all_in"].Success; pokerHand.PokerCommands.Add(new PokerCommands.Raise(text, player, amountInTotal, allIn)); return true; } #endregion #region Uncalled Bet Return match = RegexUncalledBetReturn.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); decimal amount = decimal.Parse(match.Groups["amount"].Value); pokerHand.PokerCommands.Add(new PokerCommands.UncalledBetReturn(text, player, amount)); return true; } #endregion #region Shows match = RegexShows.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); if (match.Groups["card0"].Success && match.Groups["card1"].Success) { player.PocketCards = new[] { match.Groups["card0"].Value, match.Groups["card1"].Value }; } if (match.Groups["card0one"].Success) { player.PocketCards = new[] { match.Groups["card0one"].Value }; } string info = match.Groups["showdown_info"].Value; pokerHand.PokerCommands.Add(new PokerCommands.Shows(text, player, info)); return true; } #endregion #region Collect From Pot match = RegexCollectFromPot.Match(text); if (match.Success) { if (!pokerHand.PokerCommands.Any(a => a is PokerCommands.FinalizePots)) { pokerHand.PokerCommands.Add(new PokerCommands.CollectPots(Street.Preflop)); pokerHand.PokerCommands.Add(new PokerCommands.FinalizePots()); } var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); decimal amount = decimal.Parse(match.Groups["amount"].Value); pokerHand.PokerCommands.Add(new PokerCommands.CollectFromPot(text, player, amount)); return true; } #endregion #region Muck match = RegexMuck.Match(text); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); pokerHand.PokerCommands.Add(new PokerCommands.Fold(text, player, true)); return true; } #endregion #region Total Pot match = RegexTotalPot.Match(text); if (match.Success) { if (!pokerHand.IsTournament) { pokerHand.Rake = decimal.Parse(match.Groups["rake"].Value); return true; } else { return true; } } #endregion #region MuckedInfo if (text.Contains(" mucked ")) { match = RegexMuckedInfo.Match(text.Replace("(button) ", "").Replace("(small blind) ", "").Replace("(big blind) ", "")); if (match.Success) { var player = pokerHand.Seats.First(o => o != null && o.PlayerName.Equals(match.Groups["player_name"].Value)); player.PocketCards = new[] { match.Groups["card0"].Value, match.Groups["card1"].Value }; return true; } } #endregion #region Flop match = RegexFlop.Match(text); if (match.Success) { string[] cards = { match.Groups["card0"].Value, match.Groups["card1"].Value, match.Groups["card2"].Value }; pokerHand.PokerCommands.Add(new PokerCommands.CollectPots(Street.Preflop)); pokerHand.PokerCommands.Add(new PokerCommands.Flop(text, cards)); return true; } #endregion #region Turn match = RegexTurn.Match(text); if (match.Success) { string card = match.Groups["card3"].Value; pokerHand.PokerCommands.Add(new PokerCommands.CollectPots(Street.Flop)); pokerHand.PokerCommands.Add(new PokerCommands.Turn(text, card)); return true; } #endregion #region River match = RegexRiver.Match(text); if (match.Success) { string card = match.Groups["card4"].Value; pokerHand.PokerCommands.Add(new PokerCommands.CollectPots(Street.Turn)); pokerHand.PokerCommands.Add(new PokerCommands.River(text, card)); return true; } #endregion #region Win Tournament match = RegexWinTournament.Match(text); if (match.Success) { return true; } #endregion #region Finished match = RegexFinished.Match(text); if (match.Success) { return true; } #endregion #region Chat match = RegexChat.Match(text); if (match.Success) { return true; } #endregion return false; }