Exemplo n.º 1
0
        private static void AddToPokerHandDictionary(string stringRepresentations, PokerHandGeneratorDelegate generator)
        {
            string[] representations = stringRepresentations.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            foreach (string r in representations)
            {
                try
                {
                    _generatorDictionary.Add(r.Trim(), generator);
                }
                catch (ArgumentException)
                {
                    PokerHandGeneratorDelegate g = _generatorDictionary[r.Trim()];
                    string error = "Cannot add the string representation: " + r.Trim() + " for the generator: " + generator + ". It is already mapped to a poker hand generator: " + g;
                    Logger.Instance.WriteError(error);
                    MessageBox.Show("There was a problem with a poker hand file token: " + r.Trim() + ".  Please refer to the error log: " + Logger.Instance.LogPath);
                }
            }
        }
Exemplo n.º 2
0
        private bool TryGetBestHand(string[] inTokens, int numCards, out string bestHand, out string hand)
        {
            bestHand = "";
            hand     = "";

            if (inTokens.Length >= 2)
            {
                if (!_generatorDictionary.ContainsKey(inTokens[1]))
                {
                    return(false);
                }

                PokerHandGeneratorDelegate d = _generatorDictionary[inTokens[1]];
                PokerHand pokerHand          = d.Invoke(numCards);
                hand     = pokerHand.ToString();
                bestHand = pokerHand.MaxRank.ToString();
                return(true);
            }

            return(false);
        }