Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }