Esempio n. 1
0
        private Dictionary <string, List <string> > LoadThemes()
        {
            var dictionaryOfThemes = new Dictionary <string, List <string> >();
            // ReSharper disable StringLiteralTypo
            GoogleSheet sheet = new GoogleSheet()
            {
                GoogleSheetKey = "1ZJmh_woTIRDW1lspRX728GdkUc81J1K_iYeOoPYNfcA"
            };
            // ReSharper restore StringLiteralTypo

            List <Dictionary <int, string> > findRelatedWords = sheet.ExecuteQuery(@"SELECT *");

            foreach (var dictionary in findRelatedWords)
            {
                if (!dictionary.ContainsKey(0))
                {
                    continue;
                }

                string theme = dictionary[0];
                if (!dictionaryOfThemes.ContainsKey(theme))
                {
                    dictionaryOfThemes.Add(theme, new List <string>());
                }

                List <string> wordsForTheme = dictionaryOfThemes[theme];

                if (string.IsNullOrWhiteSpace(theme))
                {
                    continue;
                }
                if (!dictionary.ContainsKey(1))
                {
                    continue;
                }

                string wordToAdd = dictionary[1];
                if (string.IsNullOrWhiteSpace(wordToAdd))
                {
                    continue;
                }

                wordToAdd = wordToAdd.ToLower();
                if (!wordsForTheme.Contains(wordToAdd)) //skip any duplicates
                {
                    wordsForTheme.Add(wordToAdd);
                }
            }

            return(dictionaryOfThemes);
        }
        public List <Player> GetPlayers(string month = null)
        {
            var players            = new List <Player>();
            var results            = _sheet.ExecuteQuery("SELECT *", month);
            var puzzleTypeIndicies = GetPuzzleTypeIndiciesFromTypeRowInSheet(results[1]);

            foreach (var playerRow in results)
            {
                Player playerToAdd = new Player(playerRow, puzzleTypeIndicies);
                if (!string.IsNullOrWhiteSpace(playerToAdd.TwitterHandle))
                {
                    players.Add(playerToAdd);
                }
            }

            return(players);
        }
Esempio n. 3
0
        public void LoadAllWordsWithCategories()
        {
            const int WORD_INDEX     = 0;
            const int CATEGORY_INDEX = 1;
            const int HINT_INDEX     = 3;

            GoogleSheet sheet = new GoogleSheet()
            {
                GoogleSheetKey = "1XHFx8xwOJFWUMAB9wrVmG10MFw4EHazeUnrrKBvpzY4", IgnoreCache = IgnoreCache
            };
            var results = sheet.ExecuteQuery("SELECT *");

            foreach (var result in results)
            {
                if (!result.ContainsKey(WORD_INDEX))
                {
                    continue;
                }
                string currentWord = result[WORD_INDEX];

                if (result.ContainsKey(CATEGORY_INDEX))
                {
                    WordCategory category;
                    string       categoryAsString = result[CATEGORY_INDEX];
                    if (Enum.TryParse(categoryAsString, out category))
                    {
                        if (!CategoriesToInclude.Contains(category))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        Debug.WriteLine($"Unable to parse category {categoryAsString}");
                    }
                }

                switch (currentWord.Length)
                {
                case 3:
                    _threeLetterWords.Add(currentWord);
                    break;

                case 4:
                    _fourLetterWords.Add(currentWord);
                    break;

                case 5:
                    _fiveLetterWords.Add(currentWord);
                    break;

                case 6:
                    _sixLetterWords.Add(currentWord);
                    break;

                case 7:
                    _sevenLetterWords.Add(currentWord);
                    break;

                case 8:
                    _eightLetterWords.Add(currentWord);
                    break;

                case 10:
                    _tenLetterWords.Add(currentWord);
                    break;
                }

                if (result.ContainsKey(HINT_INDEX))
                {
                    string hintForCurrentWord = result[HINT_INDEX];
                    if (!string.IsNullOrWhiteSpace(hintForCurrentWord))
                    {
                        if (!DictionaryOfClues.ContainsKey(currentWord))
                        {
                            DictionaryOfClues.Add(currentWord, hintForCurrentWord);
                        }
                    }
                }
            }
            AlreadyLoaded = true;
        }