private void handHistoryParser_GameDiscovered(string game)
{
Trace.WriteLine(String.Format("Game discovered! {0}", game));
// Find to what game this game string corresponds
Game = pokerClient.GetPokerGameFromGameDescription(game);
bool foundParser = false;
// Holdem?
if (foundParser = (Game == PokerGame.Holdem))
{
handHistoryParser = new HoldemHHParser(pokerClient, System.IO.Path.GetFileName(handHistoryFilePath));
statistics = new HoldemTableStatistics(this);
}
else if (Game == PokerGame.Unknown)
{
Trace.WriteLine("We weren't able to find a better parser for this Game");
}
// If we replaced our parser, we need to register the event handlers
if (foundParser)
{
// Generic handlers (all game types)
handHistoryParser.PlayerIsSeated += new HHParser.PlayerIsSeatedHandler(handHistoryParser_PlayerIsSeated);
handHistoryParser.RoundHasTerminated += new HHParser.RoundHasTerminatedHandler(handHistoryParser_RoundHasTerminated);
handHistoryParser.NewTableHasBeenCreated += new HHParser.NewTableHasBeenCreatedHandler(handHistoryParser_NewTableHasBeenCreated);
handHistoryParser.FoundTableMaxSeatingCapacity += new HHParser.FoundTableMaxSeatingCapacityHandler(handHistoryParser_FoundTableMaxSeatingCapacity);
handHistoryParser.HeroNameFound += new HHParser.HeroNameFoundHandler(handHistoryParser_HeroNameFound);
// Game specific handlers
if (Game == PokerGame.Holdem)
{
((HoldemHHParser)handHistoryParser).FinalBoardAvailable += new HoldemHHParser.FinalBoardAvailableHandler(handHistoryParser_FinalBoardAvailable);
statistics.RegisterParserHandlers(handHistoryParser);
}
// Also, resend the last line to the new parser!
hhMonitor.ResendLastLine();
}
if (Game != PokerGame.Unknown)
{
// Close temporary window
if (displayWindow != null)
{
displayWindow.Dispose();
}
Globals.Director.RunFromGUIThread(
(Action) delegate()
{
if (displayWindow != null)
{
displayWindow = TableDisplayWindow.CreateForTable(this);
displayWindow.Show();
}
}, false
);
}
}