Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public bool Equals(FastFoldKey key)
 {
     return(key != null && key.GameType == GameType && key.TableName == TableName);
 }