Exemple #1
0
        public async Task <IList <GameViewModel> > FetchMapDataAsync(GameContinentType continent, GameSubjectType subject)
        {
            IList <GameViewModel> data = new List <GameViewModel>();

            if (subject == GameSubjectType.UsaStates || subject == GameSubjectType.UsaStateCapitals)
            {
                data = await this.client.GetAllUsaStatesAsync();
            }
            else if (subject == GameSubjectType.AllStates || subject == GameSubjectType.AllStateCapitals)
            {
                data = await this.client.GetAllStatesAsync();
            }
            else
            {
                if (continent == GameContinentType.SouthAmerica)
                {
                    data = await this.client.GetAllCountriesPerContinentAsync("South America");
                }
                else
                {
                    data = await this.client.GetAllCountriesPerContinentAsync(continent.ToString());
                }
            }

            return(data);
        }
Exemple #2
0
        // ToDo: Add Exception handling.
        public async Task <IList <GameElement> > FetchGameDataAsync(GameContinentType continent, GameSubjectType subject, bool shortGame)
        {
            IList <GameElement> elements = new List <GameElement>();

            if (continent == GameContinentType.NorthAmerica)
            {
                switch (subject)
                {
                case GameSubjectType.UsaStates:
                    elements = await this.GetStatesAsync("Usa", "state", shortGame);

                    break;

                case GameSubjectType.UsaStateCapitals:
                    elements = await this.GetStatesAsync("Usa", "capital", shortGame);

                    break;

                case GameSubjectType.AllStates:
                    elements = await this.GetStatesAsync("All", "state", shortGame);

                    break;

                case GameSubjectType.AllStateCapitals:
                    elements = await this.GetStatesAsync("All", "capital", shortGame);

                    break;
                }
            }
            else
            {
                elements = await this.GetCountriesInContinentAsync(continent, subject, shortGame);
            }

            return(elements);
        }
Exemple #3
0
        /// <summary>
        /// Fetch Game Elements for Countries based Games.
        /// </summary>
        /// <param name="continent">Name of the Continent.</param>
        /// <param name="subject">Game type.</param>
        /// <param name="shortGame">Is it short Game.</param>
        /// <returns>List of GameElement.</returns>
        private async Task <IList <GameElement> > GetCountriesInContinentAsync(GameContinentType continent, GameSubjectType subject, bool shortGame)
        {
            IList <GameElement>   elements = new List <GameElement>();
            IList <GameViewModel> modelList;

            if (shortGame)
            {
                if (continent == GameContinentType.SouthAmerica)
                {
                    modelList =
                        await this.client.GetCountAmountCountriesPerContinentAsync("South America", ElementsAmountInShortGame);
                }
                else
                {
                    modelList =
                        await this.client.GetCountAmountCountriesPerContinentAsync(continent.ToString(), ElementsAmountInShortGame);
                }
            }
            else
            {
                if (continent == GameContinentType.SouthAmerica)
                {
                    modelList = await this.client.GetAllCountriesPerContinentAsync("South America");
                }
                else
                {
                    modelList = await this.client.GetAllCountriesPerContinentAsync(continent.ToString());
                }
            }

            foreach (var model in modelList)
            {
                GameElement element = new GameElement
                {
                    State    = GameState.Unanswered,
                    Question = subject == GameSubjectType.Countries ? model.Name : model.Capital,
                };

                elements.Add(element);
            }

            return(elements);
        }