public async void NicknamePokemon(IEnumerable <PokemonData> pokemons, string nickname) { SetState(false); var pokemonDatas = pokemons as IList <PokemonData> ?? pokemons.ToList(); foreach (var pokemon in pokemonDatas) { var newName = new StringBuilder(nickname); newName.Replace("{Name}", Convert.ToString(pokemon.PokemonId)); newName.Replace("{CP}", Convert.ToString(pokemon.Cp)); newName.Replace("{IV}", Convert.ToString(Math.Round(_session.Inventory.GetPerfect(pokemon)), CultureInfo.InvariantCulture)); newName.Replace("{IA}", Convert.ToString(pokemon.IndividualAttack)); newName.Replace("{ID}", Convert.ToString(pokemon.IndividualDefense)); newName.Replace("{IS}", Convert.ToString(pokemon.IndividualStamina)); if (nickname.Length > 12) { Logger.Write($"\"{newName}\" is too long, please choose another name"); if (pokemonDatas.Count() == 1) { SetState(true); return; } continue; } await RenameSpecificPokemonTask.Execute(_session, pokemon, nickname); } await ReloadPokemonList(); }
private static void RenamePokemon(Queue <PokemonUiData> pokemonQueue, string name = null, bool toDefault = false) { if (pokemonQueue == null) { return; } if (name == null) { return; } while (pokemonQueue.Count > 0) { var pokemon = pokemonQueue.Dequeue(); if (pokemon == null) { continue; } if (pokemon.OwnerBot != null && pokemon.OwnerBot.Started || _debugMode) { pokemon.OwnerBot.Session.AddActionToQueue( async() => { await RenameSpecificPokemonTask.Execute(pokemon.OwnerBot.Session, pokemon.Id, pokemon.OwnerBot.CancellationToken, name, toDefault); return(true); }, $"{TranslationEngine.GetDynamicTranslationString("%RENAME_POKE%", "Rename poke")}: {pokemon.Name}", pokemon.Id); pokemon.InAction = true; } } }
private async void RenamePokemon(Queue <PokemonUiData> pokemonQueue, ListBox pokeListBox, string name = null, bool toDefault = false) { if (pokemonQueue == null) { return; } if (name == null) { return; } pokeListBox.IsEnabled = false; while (pokemonQueue.Count > 0) { var pokemon = pokemonQueue.Dequeue(); if (pokemon?.OwnerBot != null && pokemon.OwnerBot.Started) { await RenameSpecificPokemonTask.Execute(pokemon.OwnerBot.Session, pokemon.Id, name, toDefault); } } pokeListBox.IsEnabled = true; }