public GameElement Compare(GameElement element) { element.State = element.Question.Equals(element.Answer, StringComparison.OrdinalIgnoreCase) ? GameState.Correct : GameState.False; return(element); }
/// <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); }
/// <summary> /// Fetch Elements for State based Games. /// </summary> /// <param name="country">Is it All we have or just a specific Country.</param> /// <param name="type">Game Type.</param> /// <param name="shortGame">Is it short Game.</param> /// <returns>List of GameElement.</returns> private async Task <IList <GameElement> > GetStatesAsync(string country, string type, bool shortGame) { IList <GameElement> elements = new List <GameElement>(); IList <GameViewModel> modelList; if (country == "Usa" && shortGame) { modelList = await this.client.GetCountAmountUsaStatesAsync(ElementsAmountInShortGame); } else if (country == "Usa" && !shortGame) { modelList = await this.client.GetAllUsaStatesAsync(); } else if (country == "All" && shortGame) { modelList = await this.client.GetCountAmountStatesAsync(ElementsAmountInShortGame); } else { modelList = await this.client.GetAllStatesAsync(); } foreach (var model in modelList) { GameElement element = new GameElement { State = GameState.Unanswered, Question = type == "state" ? model.Name : model.Capital, }; elements.Add(element); } return(elements); }