public async Task <ServiceResponse <IGym> > GetGymAsync(Type textResource, string name, int interactiveLimit, Func <int, Task <ServiceResponse> > interactiveCallbackAction, FenceConfiguration[] fences = null) { return(await InteractiveServiceHelper.GenericGetEntityWithCallback( GetGymsByNameAsync(name, fences), list => list.Where(e => e.Name.ToLowerInvariant().Trim() == name.ToLowerInvariant().Trim()).ToList(), interactiveLimit, interactiveCallbackAction, gym => gym.Id, GetGymNameWithAdditionAsync, gym => gym.Name, () => LocalizationService.Get(textResource, "Gyms_Errors_NothingFound", name), list => LocalizationService.Get(textResource, "Gyms_Errors_ToManyFound", list.Count, name, interactiveLimit), list => LocalizationService.Get(textResource, "Gyms_Errors_InteractiveMode", list.Count, name) )); }
public async Task <ServiceResponse <RaidbossPokemon> > GetPokemonAndRaidbossAsync(Type textResource, string name, int interactiveLimit, Func <string, Task <ServiceResponse> > interactiveCallback) { return(await InteractiveServiceHelper.GenericGetEntityWithCallback( GetPossibleRaidbossPokemonAsync(name), list => list.Where(e => e.Pokemon.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)).ToList(), interactiveLimit, interactiveCallback, pokemon => pokemon.Pokemon.Name, (pokemon, list) => Task.FromResult(pokemon.Pokemon.Name), pokemon => pokemon.Pokemon.Name, () => LocalizationService.Get(textResource, "Pokemon_Errors_NothingFound", name, "raidboss-"), list => LocalizationService.Get(textResource, "Pokemon_Errors_ToManyFound", list.Count, name, interactiveLimit, "raidboss-"), list => LocalizationService.Get(textResource, "Pokemon_Errors_InteractiveMode", list.Count, name, "raidboss-") )); }
public async Task <ServiceResponse> AddAsync(string pokestopName, string questNameOrAlias, int interactiveLimit, FenceConfiguration[] fences = null) { var quests = GetQuestList(); var quest = quests.FirstOrDefault(e => e.Key.ToLowerInvariant().Contains(questNameOrAlias.ToLowerInvariant())); return(new ServiceResponse(true, quest.Value)); //throw new NotImplementedException(); var pokestopResult = await PokestopService.GetBySimilarNameAsync(pokestopName, fences, interactiveLimit * 2); if (InteractiveServiceHelper.UseInteractiveMode(pokestopResult.ToArray())) { } throw new NotImplementedException(); }
private async Task <ServiceResponse> InteractivePokemonResolve(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, TimeSpan timeLeft, RaidOcrResult raidOcrResult, FenceConfiguration[] fences, int interactiveLimit) { if (UseInteractiveMode(raidOcrResult.Pokemon)) { var pokemonCallbacks = InteractiveServiceHelper.GenericCreateCallbackAsync(interactiveLimit, (selectedPokemon) => InteractiveGymResolve(textResource, requestStartInUtc, userZone, timeLeft, GetRaidbossPokemonById(selectedPokemon, raidOcrResult).Raidboss.Level, GetRaidbossPokemonById(selectedPokemon, raidOcrResult), raidOcrResult, fences, interactiveLimit), pokemon => pokemon.Pokemon.Id, (pokemon, list) => Task.FromResult(pokemon.Pokemon.Name), list => LocalizationService.Get(textResource, "Pokemon_Errors_ToManyFound", list.Count, raidOcrResult.Pokemon.OcrValue, interactiveLimit, "raidboss-"), list => LocalizationService.Get(textResource, "Pokemon_Errors_InteractiveMode", list.Count, raidOcrResult.Pokemon.OcrValue, "raidboss-"), raidOcrResult.Pokemon.Results.Select(e => e.Key).ToList()); return(await pokemonCallbacks); } var raidbossPokemon = raidOcrResult.Pokemon.GetFirst(); return(await InteractiveGymResolve(textResource, requestStartInUtc, userZone, timeLeft, raidbossPokemon.Raidboss.Level, raidbossPokemon, raidOcrResult, fences, interactiveLimit)); }
private async Task <ServiceResponse> InteractiveGymResolve(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, TimeSpan timeLeft, int level, RaidbossPokemon raidbossPokemon, RaidOcrResult raidOcrResult, FenceConfiguration[] fences, int interactiveLimit) { if (!UseInteractiveMode(raidOcrResult.Gym)) { return(await AddRaidAsync(textResource, requestStartInUtc, userZone, raidOcrResult.Gym.GetFirst().Id, level, raidbossPokemon, timeLeft, raidOcrResult, fences, interactiveLimit)); } if (raidOcrResult.Gym.Results == null || raidOcrResult.Gym.Results.Length == 0) { return(new ServiceResponse(false, LocalizationService.Get(textResource, "Gyms_Errors_NothingFound", raidOcrResult.Gym.OcrValue))); } // If the interactive response limit is reached try to select the all gyms with the same name as from the ocr result var gyms = raidOcrResult.Gym.Results.Select(e => e.Key).ToList(); if (gyms.Count > interactiveLimit) { var ocrString = raidOcrResult.Gym.OcrValue.Trim().ToLowerInvariant(); gyms = gyms.Where(e => e.Name.Trim().ToLowerInvariant() == ocrString).ToList(); // If we didn't found any return to the precious state if (gyms.Count == 0) { gyms = raidOcrResult.Gym.Results.Select(e => e.Key).ToList(); } } var gymCallbacks = InteractiveServiceHelper.GenericCreateCallbackAsync(interactiveLimit, (selectedGym) => AddRaidAsync(textResource, requestStartInUtc, userZone, selectedGym, level, raidbossPokemon, timeLeft, raidOcrResult, fences, interactiveLimit), gym => gym.Id, (gym, list) => GymService.GetGymNameWithAdditionAsync(gym, list), list => LocalizationService.Get(textResource, "Gyms_Errors_ToManyFound", list.Count, raidOcrResult.Gym.OcrValue, interactiveLimit), list => LocalizationService.Get(textResource, "Gyms_Errors_InteractiveMode", list.Count, raidOcrResult.Gym.OcrValue), gyms); return(await gymCallbacks); }
private async Task <ServiceResponse> InteractiveGymResolve(Type textResource, ZonedDateTime requestStartInUtc, DateTimeZone userZone, TimeSpan timeLeft, int level, RaidbossPokemon raidbossPokemon, RaidOcrResult raidOcrResult, FenceConfiguration[] fences, int interactiveLimit) { if (!InteractiveServiceHelper.UseInteractiveMode(raidOcrResult.Gym.Results)) { return(await AddRaidAsync(textResource, requestStartInUtc, userZone, raidOcrResult.Gym.GetFirst().Id, level, raidbossPokemon, timeLeft, raidOcrResult, fences, interactiveLimit)); } if (raidOcrResult.Gym.Results == null || raidOcrResult.Gym.Results.Length == 0) { return(new ServiceResponse(false, LocalizationService.Get(textResource, "Gyms_Errors_NothingFound", raidOcrResult.Gym.OcrValue))); } var gymCallbacks = InteractiveServiceHelper.GenericCreateCallbackAsync(interactiveLimit, (selectedGym) => AddRaidAsync(textResource, requestStartInUtc, userZone, selectedGym, level, raidbossPokemon, timeLeft, raidOcrResult, fences, interactiveLimit), gym => gym.Id, (gym, list) => GymService.GetGymNameWithAdditionAsync(gym, list), list => LocalizationService.Get(textResource, "Gyms_Errors_ToManyFound", list.Count, raidOcrResult.Gym.OcrValue, interactiveLimit), list => LocalizationService.Get(textResource, "Gyms_Errors_InteractiveMode", list.Count, raidOcrResult.Gym.OcrValue), raidOcrResult.Gym.Results.Select(e => e.Key).ToList()); return(await gymCallbacks); }