public static string GetServiceName(EnumPokerSites site) { switch (site) { case EnumPokerSites.Adda52: case EnumPokerSites.GGN: case EnumPokerSites.PokerBaazi: case EnumPokerSites.PPPoker: case EnumPokerSites.PokerKing: case EnumPokerSites.PokerMaster: case EnumPokerSites.RedDragon: return(DriveHUD); case EnumPokerSites.AmericasCardroom: case EnumPokerSites.BlackChipPoker: case EnumPokerSites.TruePoker: case EnumPokerSites.YaPoker: case EnumPokerSites.WinningPokerNetwork: return(WPN); case EnumPokerSites.Ignition: case EnumPokerSites.Bodog: case EnumPokerSites.Bovada: case EnumPokerSites.BetOnline: case EnumPokerSites.SpartanPoker: case EnumPokerSites.SportsBetting: case EnumPokerSites.TigerGaming: return(CustomIPoker); default: return(Common); } }
protected virtual Dictionary <int, int> GetAutoCenterSeats(EnumPokerSites pokerSite) { switch (pokerSite) { case EnumPokerSites.GGN: return(new Dictionary <int, int> { { 4, 3 }, { 6, 4 }, { 9, 6 } }); case EnumPokerSites.PokerMaster: return(new Dictionary <int, int> { { 2, 2 }, { 3, 2 }, { 4, 3 }, { 5, 3 }, { 6, 4 }, { 7, 4 }, { 8, 5 }, { 9, 5 } }); default: return(new Dictionary <int, int>()); } }
private HandHistoryObject CreateHandHistoryObject(string fileName, EnumPokerSites pokerSite, string playerName) { var handHistoryFileFullName = Path.Combine(TestDataFolder, fileName); var handHistoryFileInfo = new FileInfo(handHistoryFileFullName); Assert.That(handHistoryFileInfo.Exists, $"{handHistoryFileFullName} doesn't exists. Please check."); var handHistoryText = File.ReadAllText(handHistoryFileInfo.FullName); var parsingResult = ParseHandHistory(pokerSite, handHistoryText); var player = parsingResult.Players.FirstOrDefault(x => x.Playername == playerName); Assert.IsNotNull(player, $"Player {playerName} has not been found"); var playerStatisticCalculator = ServiceLocator.Current.GetInstance <IPlayerStatisticCalculator>(); var creationInfo = new PlayerStatisticCreationInfo { ParsingResult = parsingResult, Player = player, EquityData = new Dictionary <string, Model.Solvers.EquityData>() }; var stat = playerStatisticCalculator.CalculateStatistic(creationInfo); return(new HandHistoryObject { HandHistory = parsingResult.Source, Stat = stat }); }
public HandHistory GetHandById(string id, string pokerSite) { EnumPokerSites site = EnumPokerSites.Unknown; long parsedId = 0; if (!long.TryParse(id, out parsedId)) { throw new WebFaultException <string>("Cannot parse hand id", System.Net.HttpStatusCode.BadRequest); } if (Enum.TryParse(pokerSite, out site)) { // Return hand for currently selected user if (site == EnumPokerSites.Unknown) { site = storageModel.PlayerSelectedItem?.PokerSite ?? EnumPokerSites.Unknown; } return(dataService.GetGame(parsedId, (short)site)); } else { throw new WebFaultException <string>($"Cannot recognise site {pokerSite}", System.Net.HttpStatusCode.BadRequest); } }
public TableDescription(int hash, EnumTableType tableType, EnumPokerSites pokerSite, EnumGameType gameType) { Hash = hash; TableType = tableType; PokerSite = pokerSite; GameType = gameType; }
/// <summary> /// Initializes position and size for the current <see cref="HudPlainStatBoxViewModel"/> for the specified <see cref="EnumPokerSites"/> and <see cref="EnumGameType"/> /// </summary> /// <param name="pokerSite"><see cref="EnumPokerSites"/></param> /// <param name="gameType"><see cref="EnumGameType"/></param> /// <exception cref="DHBusinessException" /> public override void InitializePositions(EnumPokerSites pokerSite, EnumTableType tableType, EnumGameType gameType) { if (!(Tool is T tool)) { return; } var seats = (int)tableType; var currentSeat = Parent.Seat - 1; var uiPosition = tool.UIPositions.FirstOrDefault(x => x.Seat == Parent.Seat); if (uiPosition == null) { LogProvider.Log.Warn($"Could not find UI positions for {pokerSite}, {gameType}, {Parent.Seat}, {tool.ToolType}"); } var positionInfo = tool.Positions.FirstOrDefault(x => x.PokerSite == pokerSite && x.GameType == gameType); var hudPositionInfo = positionInfo?.HudPositions.FirstOrDefault(x => x.Seat == Parent.Seat); if (hudPositionInfo == null) { var positionProvider = ServiceLocator.Current.GetInstance <IPositionProvider>(pokerSite.ToString()); if (!positionProvider.Positions.ContainsKey(seats)) { throw new DHBusinessException(new NonLocalizableString($"Could not find predefined positions for {pokerSite}, {gameType}, {Parent.Seat}")); } var playerLabelClientPosition = positionProvider.Positions[seats]; var playerLabelPosition = HudDefaultSettings.TablePlayerLabelPositions[seats]; var offsetX = playerLabelClientPosition[currentSeat, 0] - playerLabelPosition[currentSeat, 0]; var offsetY = playerLabelClientPosition[currentSeat, 1] - playerLabelPosition[currentSeat, 1]; var positionX = uiPosition != null ? uiPosition.Position.X : default(double); var positionY = uiPosition != null ? uiPosition.Position.Y : default(double); // do not change position if element is inside or above player label if (positionY > playerLabelPosition[currentSeat, 1] + HudDefaultSettings.TablePlayerLabelActualHeight) { offsetY += positionProvider.PlayerLabelHeight - HudDefaultSettings.TablePlayerLabelHeight; } hudPositionInfo = new HudPositionInfo { Seat = Parent.Seat, Position = new Point(positionX + offsetX, positionY + offsetY) }; } Position = hudPositionInfo.Position; Opacity = Parent.Opacity; Width = uiPosition != null && uiPosition.Width != 0 && !UseDefaultSizesOnly ? uiPosition.Width : DefaultWidth; Height = uiPosition != null && uiPosition.Height != 0 && !UseDefaultSizesOnly ? uiPosition.Height : DefaultHeight; }
public IHandHistoryParser GetFullHandHistoryParser(EnumPokerSites siteName, string handText = null) { switch (siteName) { case EnumPokerSites.PartyPoker: return(new PartyPokerFastParserImpl(siteName)); case EnumPokerSites.PokerStars: return(new PokerStarsFastParserImpl(siteName)); case EnumPokerSites.IPoker: return(new IPokerFastParserImpl()); case EnumPokerSites.Bodog: case EnumPokerSites.Ignition: case EnumPokerSites.Bovada: case EnumPokerSites.BetOnline: case EnumPokerSites.SportsBetting: case EnumPokerSites.TigerGaming: case EnumPokerSites.SpartanPoker: return(new IPokerBovadaFastParserImpl()); case EnumPokerSites.Poker888: return(new Poker888FastParserImpl()); case EnumPokerSites.WinningPokerNetwork: case EnumPokerSites.AmericasCardroom: case EnumPokerSites.BlackChipPoker: case EnumPokerSites.TruePoker: case EnumPokerSites.YaPoker: if (handText != null && (handText.StartsWith("<Game Information>", StringComparison.OrdinalIgnoreCase) || handText.StartsWith("Game Hand", StringComparison.OrdinalIgnoreCase))) { return(new WinningPokerSnG2FastParserImpl()); } return(new WinningPokerNetworkFastParserImpl()); case EnumPokerSites.GGN: case EnumPokerSites.PokerMaster: case EnumPokerSites.PokerKing: case EnumPokerSites.Adda52: case EnumPokerSites.PPPoker: case EnumPokerSites.RedDragon: case EnumPokerSites.PokerBaazi: return(new CommonHandHistoryParser(siteName)); case EnumPokerSites.Horizon: return(new HorizonFastParserImpl()); case EnumPokerSites.Winamax: return(new WinamaxFastParserImpl()); default: throw new NotImplementedException("GetFullHandHistoryParser: No parser for " + siteName); } }
public GameDescriptor(EnumPokerSites siteName, GameType gameType, Limit limit, TableType tableType, SeatType seatType, TournamentDescriptor tournament) : this(PokerFormat.CashGame, siteName, gameType, limit, tableType, seatType, tournament) { }
/// <summary> /// Get site configuration /// </summary> /// <param name="site">Site</param> /// <returns>Site configuration</returns> public ISiteConfiguration Get(EnumPokerSites site) { var configuration = configurations.FirstOrDefault(x => x.Site == site); if (configuration == null) { throw new DHInternalException(new NonLocalizableString("Not supported site")); } return(configuration); }
public IHandHistoryParser GetFullHandHistoryParser(string handText) { if (EnumPokerSitesExtension.TryParse(handText, out EnumPokerSites siteName)) { LastSelected = siteName; var parser = GetFullHandHistoryParser(siteName, handText); return(parser); } throw new DHBusinessException(new NonLocalizableString("Unknown hand format")); }
private IList <StatInfo> GetHudStats(EnumPokerSites pokerSite, EnumGameType gameType, EnumTableType tableType) { var activeLayout = hudLayoutsService.GetActiveLayout(pokerSite, tableType, gameType); if (activeLayout == null) { LogProvider.Log.Error("Could not find active layout"); return(null); } return(activeLayout.LayoutTools.OfType <HudLayoutPlainBoxTool>().SelectMany(x => x.Stats).ToArray()); }
private Point GetOffset(EnumPokerSites pokerSite, EnumGameType gameType, EnumTableType tableType, int seat) { if (pokerSite == EnumPokerSites.Ignition || pokerSite == EnumPokerSites.Bovada || pokerSite == EnumPokerSites.Bodog) { return(new Point(0, -27)); } var hudPanelService = ServiceLocator.Current.GetInstance <IHudPanelService>(pokerSite.ToString()); var shifts = hudPanelService.GetPositionShift(tableType, seat); return(shifts); }
public void ShowHUD(EnumPokerSites site, int windowHandle, string text) { var gameInfo = new GameInfo { PokerSite = site, TableType = EnumTableType.Nine, WindowHandle = windowHandle }; var eventArgs = new PreImportedDataEventArgs(gameInfo, text); importer.eventAggregator.GetEvent <PreImportedDataEvent>().Publish(eventArgs); }
private void UpdateTableTypeDictionary(EnumPokerSites pokerSite) { try { var configuration = ServiceLocator.Current.GetInstance <ISiteConfigurationService>().Get(pokerSite); TableTypeDictionary = configuration.TableTypes.ToDictionary(x => x, x => GetTableTypeString(x)); SelectedTableType = TableTypeDictionary.FirstOrDefault().Key; } catch (Exception ex) { LogProvider.Log.Error(this, $"Failed to load configuration for {pokerSite}.", ex); } }
public override string PrepareHand(string hand, EnumPokerSites site) { var parserFactory = ServiceLocator.Current.GetInstance <IHandHistoryParserFactory>(); var parser = parserFactory.GetFullHandHistoryParser(site); var handHistory = parser.ParseFullHandHistory(hand); var convert = ServiceLocator.Current.GetInstance <IHandHistoryToIPokerConverter>(); hand = convert.Convert(handHistory); return(hand); }
public int GetHash(EnumPokerSites pokerSite, EnumGameType gameType, EnumTableType tableType) { unchecked { var hashCode = (int)2166136261; hashCode = (hashCode * 16777619) ^ pokerSite.GetHashCode(); hashCode = (hashCode * 16777619) ^ gameType.GetHashCode(); hashCode = (hashCode * 16777619) ^ tableType.GetHashCode(); return(hashCode); } }
protected override bool TryGetPokerSiteName(string handText, out EnumPokerSites siteName) { if (!base.TryGetPokerSiteName(handText, out siteName)) { return(false); } if (siteName == EnumPokerSites.WinningPokerNetwork) { siteName = this.Site; } return(true); }
/// <summary> /// Gets the network of the specified site /// </summary> /// <param name="site"></param> /// <returns></returns> public static EnumPokerNetworks GetSiteNetwork(EnumPokerSites site) { var networks = GetNetworkSites(); foreach (var network in networks.Keys) { if (networks[network].Contains(site)) { return(network); } } return(EnumPokerNetworks.Unknown); }
protected virtual HandInfo PrepareHandInfo(string hand, EnumPokerSites site) { // insert pokersite tag if (!hand.ContainsIgnoreCase("<pokersite")) { var closeGeneralTagIndex = hand.IndexOf("</general>", StringComparison.OrdinalIgnoreCase); if (closeGeneralTagIndex > 0) { hand = hand.Insert(closeGeneralTagIndex, $"<pokersite>{site}</pokersite>{Environment.NewLine}"); } } var handInfo = new HandInfo(); // need to adjust fast fold hands if (TryParseFastFoldPokerPrefix(hand, site, out string adjustedHand)) { hand = AdjustFastFoldHand(adjustedHand); handInfo.IsFastFold = true; } handInfo.Session = hand.TakeBetween("sessioncode=\"", "\"", stringComparison: StringComparison.OrdinalIgnoreCase); handInfo.GameType = hand.TakeBetween("<gametype>", "</gametype>", stringComparison: StringComparison.OrdinalIgnoreCase); handInfo.TableName = hand.TakeBetween("<tablename>", "</tablename>", stringComparison: StringComparison.OrdinalIgnoreCase); handInfo.HandText = hand; handInfo.GameText = hand.TakeBetween("</general>", "</session>", stringComparison: StringComparison.OrdinalIgnoreCase).Trim(); if (handInfo.IsSessionEmpty && handInfo.IsFastFold) { var fastFoldKey = new FastFoldKey { GameType = handInfo.GameType, TableName = handInfo.TableName }; if (!fastFoldSessions.TryGetValue(fastFoldKey, out string session)) { var random = RandomProvider.GetThreadRandom(); session = random.Next(100000, 999999).ToString(); fastFoldSessions.Add(fastFoldKey, session); } handInfo.Session = session; } return(handInfo); }
public void TestPredefinedNotes(string handHistoryFile, EnumPokerSites pokerSite, string playerName, string noteName, bool expected) { var handHistoryObject = CreateHandHistoryObject(handHistoryFile, pokerSite, playerName); var noteProcessingService = new NoteProcessingService(); var note = ReadNote(noteName); Assert.IsNotNull(note, $"Note [{noteName}] must be in predefined data set."); var playernotes = noteProcessingService.ProcessHand(new[] { note }, handHistoryObject.Stat, handHistoryObject.HandHistory); Assert.IsNotNull(playernotes, "Notes must be not null"); Assert.That(playernotes.Any(), Is.EqualTo(expected)); }
/// <summary> /// Clear resources /// </summary> private void Clear() { lockObject.EnterWriteLock(); try { handlesHandHistoryId.Clear(); players.Clear(); site = EnumPokerSites.Unknown; } finally { lockObject.ExitWriteLock(); } }
public GameDescriptor(PokerFormat pokerFormat, EnumPokerSites siteName, GameType gameType, Limit limit, TableType tableType, SeatType seatType, TournamentDescriptor tournament) { PokerFormat = pokerFormat; Site = siteName; GameType = gameType; Limit = limit; TableType = tableType; SeatType = seatType; Tournament = tournament; }
/// <summary> /// Get prize pool multiplier for tournament /// </summary> /// <returns>Dictionary where key is number of players in SnG and value is array of ordered prize rates starting from the 1st place</returns> public static Dictionary <int, decimal[]> GetWinningsMultiplier(EnumPokerSites pokerSite, bool isBeginner = false, bool isBounty = false) { switch (pokerSite) { case EnumPokerSites.Unknown: break; case EnumPokerSites.IPoker: return(IPokerSnGWinningsMultiplierDictionary); case EnumPokerSites.Ignition: case EnumPokerSites.Bovada: case EnumPokerSites.Bodog: return(isBeginner ? BovadaBeginnerSnGWinningsMultiplierDictionary : BovadaSnGWinningsMultiplierDictionary); case EnumPokerSites.BetOnline: case EnumPokerSites.SportsBetting: case EnumPokerSites.TigerGaming: case EnumPokerSites.SpartanPoker: return(BetOnlineSnGWinningsMultiplierDictionary); case EnumPokerSites.WinningPokerNetwork: case EnumPokerSites.AmericasCardroom: case EnumPokerSites.BlackChipPoker: case EnumPokerSites.TruePoker: case EnumPokerSites.YaPoker: return(WinningPokerNetworkSnGWinningsMultiplierDictionary); case EnumPokerSites.Horizon: return(isBounty ? HorizonBountySnGWinningsMultiplierDictionary : HorizonSnGWinningsMultiplierDictionary); case EnumPokerSites.Winamax: return(WinamaxSnGWinningsMultiplierDictionary); case EnumPokerSites.Adda52: return(Adda52SnGWinningsMultiplierDictionary); case EnumPokerSites.PokerStars: return(PokerStarsSnGWinningsMultiplierDictionary); default: break; } return(null); }
public void TestSecondPreflopPlayerAction(string handHistoryFile, EnumPokerSites pokerSite, string playerName, ActionTypeEnum actionType, double min, double max, bool expected) { var handHistoryObject = CreateHandHistoryObject(handHistoryFile, pokerSite, playerName); var note = new NoteObject(); note.Settings.PreflopActions.SecondType = actionType; note.Settings.PreflopActions.SecondMaxValue = max; note.Settings.PreflopActions.SecondMinValue = min; var noteProcessingService = new NoteProcessingService(); var playernotes = noteProcessingService.ProcessHand(new[] { note }, handHistoryObject.Stat, handHistoryObject.HandHistory); Assert.IsNotNull(playernotes, "Notes must be not null"); Assert.That(playernotes.Any(), Is.EqualTo(expected)); }
public void GetFullHandHistoryParserReturnsExpectedParser(string fileName, EnumPokerSites expectedSite) { var file = Path.Combine(testFolder, fileName); if (!File.Exists(file)) { throw new Exception(string.Format("Test file '{0}' doesn't exist", file)); } var handText = File.ReadAllText(file); var handHistoryParserFactory = new HandHistoryParserFactoryImpl(); var parser = handHistoryParserFactory.GetFullHandHistoryParser(handText); Assert.That(parser.SiteName, Is.EqualTo(expectedSite)); }
public static PreferredSeatModel GetSeatSetting(EnumTableType tableType, EnumPokerSites pokerSite) { var settings = settingsService.GetSettings(); var preferredSettings = settings.SiteSettings.SitesModelList.FirstOrDefault(x => x.PokerSite == pokerSite); var currentSeatSetting = preferredSettings?.PrefferedSeats?.FirstOrDefault(x => x.TableType == tableType); if (currentSeatSetting == null) { return(new PreferredSeatModel() { IsPreferredSeatEnabled = false, PreferredSeat = -1, TableType = tableType }); } return(currentSeatSetting); }
public void PlayerStatisticIsCalculated(EnumPokerSites pokerSite, string playerName) { using (var perfScope = new PerformanceMonitor("PlayerStatisticIsCalculated")) { Playerstatistic playerstatistic = null; var playerStatisticRepository = ServiceLocator.Current.GetInstance <IPlayerStatisticRepository>(); playerStatisticRepository.Store(Arg.Is <Playerstatistic>(x => GetCombinedPlayerstatisticFromStoreCall(ref playerstatistic, x, playerName))); var testDataDirectory = new DirectoryInfo(TestDataFolder); Assert.True(testDataDirectory.Exists, $"Directory '{TestDataFolder}' has not been found"); foreach (var file in testDataDirectory.GetFiles()) { FillDatabaseFromSingleFile(file.Name, pokerSite); } Assert.IsNotNull(playerstatistic, $"Player '{playerName}' has not been found"); Assert.That(playerstatistic.LimpCalled, Is.EqualTo(3), nameof(playerstatistic.LimpCalled)); Assert.That(playerstatistic.LimpSb, Is.EqualTo(1), nameof(playerstatistic.LimpSb)); Assert.That(playerstatistic.LimpEp, Is.EqualTo(3), nameof(playerstatistic.LimpEp)); Assert.That(playerstatistic.LimpMp, Is.EqualTo(1), nameof(playerstatistic.LimpMp)); Assert.That(playerstatistic.LimpCo, Is.EqualTo(1), nameof(playerstatistic.LimpCo)); Assert.That(playerstatistic.LimpBtn, Is.EqualTo(0), nameof(playerstatistic.LimpBtn)); Assert.That(playerstatistic.LimpPossible, Is.EqualTo(11), nameof(playerstatistic.LimpPossible)); Assert.That(playerstatistic.DidColdCallInSb, Is.EqualTo(0), nameof(playerstatistic.DidColdCallInSb)); Assert.That(playerstatistic.DidColdCallInBb, Is.EqualTo(0), nameof(playerstatistic.DidColdCallInBb)); Assert.That(playerstatistic.DidColdCallInEp, Is.EqualTo(3), nameof(playerstatistic.DidColdCallInEp)); Assert.That(playerstatistic.DidColdCallInMp, Is.EqualTo(1), nameof(playerstatistic.DidColdCallInMp)); Assert.That(playerstatistic.DidColdCallInCo, Is.EqualTo(0), nameof(playerstatistic.DidColdCallInCo)); Assert.That(playerstatistic.DidColdCallInBtn, Is.EqualTo(1), nameof(playerstatistic.DidColdCallInBtn)); Assert.That(playerstatistic.Couldcoldcall, Is.EqualTo(13), nameof(playerstatistic.Couldcoldcall)); Assert.That(playerstatistic.DidColdCallThreeBet, Is.EqualTo(0), nameof(playerstatistic.DidColdCallThreeBet)); Assert.That(playerstatistic.DidColdCallFourBet, Is.EqualTo(0), nameof(playerstatistic.DidColdCallFourBet)); Assert.That(playerstatistic.DidColdCallVsOpenRaiseSb, Is.EqualTo(0), nameof(playerstatistic.DidColdCallVsOpenRaiseSb)); Assert.That(playerstatistic.DidColdCallVsOpenRaiseCo, Is.EqualTo(0), nameof(playerstatistic.DidColdCallVsOpenRaiseCo)); Assert.That(playerstatistic.DidColdCallVsOpenRaiseBtn, Is.EqualTo(0), nameof(playerstatistic.DidColdCallVsOpenRaiseBtn)); } }
private static bool TryParseSite(XElement xElement, string siteTag, out EnumPokerSites pokerSite, EnumPokerSites defaultSite = EnumPokerSites.Unknown) { pokerSite = defaultSite; var siteNode = xElement.Descendants(siteTag).FirstOrDefault(); if (siteNode == null) { return(false); } if (!Enum.TryParse(siteNode.Value, out pokerSite)) { return(false); } return(true); }
/// <summary> /// Starts background process /// </summary> public void Start() { if (isRunning) { return; } cancellationTokenSource = new CancellationTokenSource(); site = EnumPokerSites.Unknown; // start main job Task.Run(() => { isRunning = true; ProcessTableWindows(); }, cancellationTokenSource.Token); }
/// <summary> /// Gets the list of <see cref="HudPositionInfo"/> of element for the specified <see cref="EnumPokerSites"/>, <see cref="EnumTableType"/> /// </summary> /// <param name="pokerSite"></param> /// <param name="tableType"></param> /// <param name="position"></param> /// <returns></returns> private List <HudPositionInfo> GetHudPositionInfo(EnumPokerSites pokerSite, EnumTableType tableType, Point position) { var positionsInfo = new List <HudPositionInfo>(); // in designer only 2-max and 1st seat are available var labelPositions = HudDefaultSettings.TablePlayerLabelPositions[(int)EnumTableType.HU]; var labelPositionX = labelPositions[0, 0]; var labelPositionY = labelPositions[0, 1]; var offsetX = position.X - labelPositionX; var offsetY = position.Y - labelPositionY; var positionProvider = ServiceLocator.Current.GetInstance <IPositionProvider>(pokerSite.ToString()); var seats = (int)tableType; var tableTypeSize = (int)tableType; if (!positionProvider.Positions.ContainsKey(tableTypeSize)) { return(positionsInfo); } var positions = positionProvider.Positions[tableTypeSize]; for (var seat = 0; seat < seats; seat++) { var positionX = positions[seat, 0]; var positionY = positions[seat, 1]; var positionInfo = new HudPositionInfo { Seat = seat + 1, Position = new Point(positionX + offsetX, positionY + offsetY) }; positionsInfo.Add(positionInfo); } return(positionsInfo); }