private void getPokemons(Boolean Iv = false) { List <PokemonListe> pokemonlist = new List <PokemonListe>(); List <PokemonData> Pokemons = pokemonDisplay.Liste; if (Pokemons == null) { return; } List <POGOProtos.Inventory.Candy> myPokemonFamilies = pokemonDisplay.FamilieListe; IEnumerable <POGOProtos.Settings.Master.PokemonSettings> myPokeSettings = pokemonDisplay.PokeSettingListe; foreach (var Poke in Pokemons) { PokemonListe pok = new PokemonListe(); pok.setCp(Poke.Cp, PokemonInfo.CalculateMaxCp(Poke)); pok.setId(Poke.Id); string pfad = pokemonNameToId[Poke.PokemonId.ToString()].ToString(); pok.setIcon("Images/Models/" + pfad + ".png"); pok.Name = session.Translation.GetPokemonTranslation(Poke.PokemonId).ToString(); pok.Move1 = session.Translation.GetPokemonMovesetTranslation(Poke.Move1).ToString(); pok.Move2 = session.Translation.GetPokemonMovesetTranslation(Poke.Move2).ToString(); pok.setIv(PokemonInfo.CalculatePokemonPerfection(Poke)); pok.Bonbon = PokemonInfo.GetCandy(Poke, myPokemonFamilies, myPokeSettings).ToString(); pokemonlist.Add(pok); } GraphicalInterface.PokemonList = pokemonlist; }
//this task is duplicated, may need remove to clean up. public static async Task Execute(ISession session, ulong pokemonId) { using (var blocker = new BlockableScope(session, BotActions.Upgrade)) { if (!await blocker.WaitToRun().ConfigureAwait(false)) { return; } var all = await session.Inventory.GetPokemons().ConfigureAwait(false); var pokemons = all.OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax); var pokemon = pokemons.FirstOrDefault(p => p.Id == pokemonId); if (pokemon == null) { return; } var upgradeResult = await session.Inventory.UpgradePokemon(pokemon.Id).ConfigureAwait(false); if (upgradeResult.Result.ToString().ToLower().Contains("success")) { var stardust = -PokemonCpUtils.GetStardustCostsForPowerup(pokemon.CpMultiplier); //+ pokemon.AdditionalCpMultiplier); var totalStarDust = session.Inventory.UpdateStarDust(stardust); Logger.Write($"LevelUpSpecificPokemonTasks: SD: {stardust} | CP: {-PokemonCpUtils.GetStardustCostsForPowerup(pokemon.CpMultiplier + pokemon.AdditionalCpMultiplier)}", LogLevel.Info); Logger.Write($"LevelUpSpecificPokemonTasks: {session.Translation.GetPokemonTranslation(upgradeResult.UpgradedPokemon.PokemonId)} | CP: {upgradeResult.UpgradedPokemon.Cp}", LogLevel.Info); session.EventDispatcher.Send(new PokemonLevelUpEvent { Id = upgradeResult.UpgradedPokemon.PokemonId, Cp = upgradeResult.UpgradedPokemon.Cp, UniqueId = pokemon.Id, PSD = stardust, PCandies = await PokemonInfo.GetCandy(session, pokemon).ConfigureAwait(false), Lvl = upgradeResult.UpgradedPokemon.Level(), }); } await DelayingUtils.DelayAsync(session.LogicSettings.DelayBetweenPlayerActions, 0, session.CancellationTokenSource.Token).ConfigureAwait(false); } }
public static async Task Execute(ISession session) { var myPokemonFamilies = await session.Inventory.GetPokemonFamilies(); var myPokeSettings = await session.Inventory.GetPokemonSettings(); var highestsPokemonCp = await session.Inventory.GetHighestsCp(session.LogicSettings.AmountOfPokemonToDisplayOnStart); var pokemonPairedWithStatsCp = highestsPokemonCp.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); var highestsPokemonPerfect = await session.Inventory.GetHighestsPerfect(session.LogicSettings.AmountOfPokemonToDisplayOnStart); var pokemonPairedWithStatsIv = highestsPokemonPerfect.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "CP", PokemonList = pokemonPairedWithStatsCp }); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "IV", PokemonList = pokemonPairedWithStatsIv }); var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000) : await session.Inventory.GetHighestsCp(1000); if (session.LogicSettings.DumpPokemonStats) { const string dumpFileName = "PokeBagStats"; try { Dumper.ClearDumpFile(session, dumpFileName); Dumper.Dump(session, "pokemonid,pokemonlevel,cp,perfection,stamina,staminamax,move1,move2,candy,ownername,origin,heightm,weightkg,individualattack,individualdefense,individualstamina,cpmultiplier,battlesattacked,battlesdefended,creationtimems,numupgrades,additionalcpmultiplier,favorite,nickname", dumpFileName); foreach (var pokemon in allPokemonInBag) { Dumper.Dump(session, $"{session.Translation.GetPokemonTranslation(pokemon.PokemonId)},{PokemonInfo.GetLevel(pokemon)},{pokemon.Cp},{PokemonInfo.CalculatePokemonPerfection(pokemon)},{pokemon.Stamina},{pokemon.StaminaMax},{pokemon.Move1},{pokemon.Move2},{PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings)},{pokemon.OwnerName},{pokemon.Origin},{pokemon.HeightM},{pokemon.WeightKg},{pokemon.IndividualAttack},{pokemon.IndividualDefense},{pokemon.IndividualStamina},{pokemon.CpMultiplier},{pokemon.BattlesAttacked},{pokemon.BattlesDefended},{pokemon.CreationTimeMs},{pokemon.NumUpgrades},{pokemon.AdditionalCpMultiplier},{pokemon.Favorite},{pokemon.Nickname}", dumpFileName); } } catch (IOException) { session.EventDispatcher.Send(new ErrorEvent { Message = $"Could not write {dumpFileName} dump file." }); } } }
public static async Task Execute(ISession session) { var myPokemonFamilies = await session.Inventory.GetPokemonFamilies(); var myPokeSettings = await session.Inventory.GetPokemonSettings(); var highestsPokemonCp = await session.Inventory.GetHighestsCp(session.LogicSettings.AmountOfPokemonToDisplayOnStart); var pokemonPairedWithStatsCp = highestsPokemonCp.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); var highestsPokemonPerfect = await session.Inventory.GetHighestsPerfect(session.LogicSettings.AmountOfPokemonToDisplayOnStart); var pokemonPairedWithStatsIv = highestsPokemonPerfect.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "CP", PokemonList = pokemonPairedWithStatsCp }); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "IV", PokemonList = pokemonPairedWithStatsIv }); var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000) : await session.Inventory.GetHighestsCp(1000); if (session.LogicSettings.DumpPokemonStats) { const string dumpFileName = "PokeBagStats"; try { Dumper.ClearDumpFile(session, dumpFileName); string[] data = { "pokemonid", "pokemonlevel", "cp", "perfection", "stamina", "staminamax", "move1", "move2", "candy", "ownername", "origin", "heightm", "weightkg", "individualattack", "individualdefense", "individualstamina", "cpmultiplier", "battlesattacked", "battlesdefended", "creationtimems", "numupgrades", "additionalcpmultiplier", "favorite", "nickname" }; Dumper.Dump(session, data, dumpFileName); // set culture to OS default CultureInfo prevCulture = Thread.CurrentThread.CurrentCulture; CultureInfo culture = CultureInfo.CurrentUICulture; Thread.CurrentThread.CurrentCulture = culture; foreach (var pokemon in allPokemonInBag) { string[] pokemonData = { session.Translation.GetPokemonTranslation(pokemon.PokemonId), PokemonInfo.GetLevel(pokemon).ToString(), pokemon.Cp.ToString(), PokemonInfo.CalculatePokemonPerfection(pokemon).ToString(), pokemon.Stamina.ToString(), pokemon.StaminaMax.ToString(), pokemon.Move1.ToString(), pokemon.Move2.ToString(), PokemonInfo.GetCandy(pokemon, myPokemonFamilies,myPokeSettings).ToString(), pokemon.OwnerName, pokemon.Origin.ToString(), pokemon.HeightM.ToString(), pokemon.WeightKg.ToString(), pokemon.IndividualAttack.ToString(), pokemon.IndividualDefense.ToString(), pokemon.IndividualStamina.ToString(), pokemon.CpMultiplier.ToString(), pokemon.BattlesAttacked.ToString(), pokemon.BattlesDefended.ToString(), pokemon.CreationTimeMs.ToString(), pokemon.NumUpgrades.ToString(), pokemon.AdditionalCpMultiplier.ToString(), pokemon.Favorite.ToString(), pokemon.Nickname }; Dumper.Dump(session, pokemonData, dumpFileName); } // restore culture Thread.CurrentThread.CurrentCulture = prevCulture; } catch (System.IO.IOException) { session.EventDispatcher.Send(new ErrorEvent { Message = $"Could not write {dumpFileName} dump file." }); } } }
public static async Task Execute(ISession session) { var highestsPokemonCp = await session.Inventory.GetHighestsCp(session.LogicSettings.AmountOfPokemonToDisplayOnStart).ConfigureAwait(false); var pokemonPairedWithStatsCp = highestsPokemonCp.Select( pokemon => Tuple.Create( pokemon, PokemonInfo.CalculateMaxCp(pokemon.PokemonId), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(session, pokemon).Result ) ) .ToList(); var highestsPokemonPerfect = await session.Inventory.GetHighestsPerfect(session.LogicSettings.AmountOfPokemonToDisplayOnStart).ConfigureAwait(false); var pokemonPairedWithStatsIv = highestsPokemonPerfect.Select( pokemon => Tuple.Create( pokemon, PokemonInfo.CalculateMaxCp(pokemon.PokemonId), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(session, pokemon).Result ) ) .ToList(); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "CP", PokemonList = pokemonPairedWithStatsCp }); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "IV", PokemonList = pokemonPairedWithStatsIv }); var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000).ConfigureAwait(false) : await session.Inventory.GetHighestsCp(1000).ConfigureAwait(false); if (session.LogicSettings.DumpPokemonStats) { _MultiAccountManager = new MultiAccountManager(); var account = _MultiAccountManager.GetCurrentAccount(); string dumpFileName = account.Nickname; // "-PokeBagStats"; //If user dump file exists then cancel file dump if (File.Exists(Path.Combine(Path.Combine(session.LogicSettings.ProfilePath, "Dumps"), $"{dumpFileName}-NecroBot2 DumpFile.csv"))) { return; } try { Dumper.ClearDumpFile(session, dumpFileName); string[] data = { "Pokemon", "Candies", "Slashed", "Nickname", "Level", "CP", "IV", "Power Ups", "Favorite", "Stamina", "Stamina Max", "Move1", "Move2", "Owner Name", "Origin", "Height(M)", "Weight(KG)", "Attack", "Defense", "Stamina", "CP Multi", "Gyms Attacked", "Gyms Defended", "Creationtimems", "Add CP Multi" }; Dumper.Dump(session, data, dumpFileName); // set culture to OS default CultureInfo prevCulture = Thread.CurrentThread.CurrentCulture; CultureInfo culture = CultureInfo.CurrentUICulture; Thread.CurrentThread.CurrentCulture = culture; foreach (var pokemon in allPokemonInBag) { string[] pokemonData = { session.Translation.GetPokemonTranslation(pokemon.PokemonId).Replace(' ', '_'), session.Inventory.GetCandyCount(pokemon.PokemonId).ToString(), // PokemonInfo.GetCandy(session, pokemon.PokemonId).ToString(), pokemon.IsBad.ToString(), pokemon.Nickname.Replace(' ', '_'), PokemonInfo.GetLevel(pokemon).ToString(), pokemon.Cp.ToString(), PokemonInfo.CalculatePokemonPerfection(pokemon).ToString(), pokemon.NumUpgrades.ToString(), pokemon.Favorite.ToString(), pokemon.Stamina.ToString(), pokemon.StaminaMax.ToString(), pokemon.Move1.ToString(), pokemon.Move2.ToString(), pokemon.OwnerName, pokemon.Origin.ToString(), pokemon.HeightM.ToString(), pokemon.WeightKg.ToString(), pokemon.IndividualAttack.ToString(), pokemon.IndividualDefense.ToString(), pokemon.IndividualStamina.ToString(), pokemon.CpMultiplier.ToString(), pokemon.BattlesAttacked.ToString(), pokemon.BattlesDefended.ToString(), pokemon.CreationTimeMs.ToString(), pokemon.AdditionalCpMultiplier.ToString() }; Dumper.Dump(session, pokemonData, dumpFileName); } // restore culture Thread.CurrentThread.CurrentCulture = prevCulture; } catch (IOException) { session.EventDispatcher.Send( new ErrorEvent { Message = $"Could not write {dumpFileName} dump file." } ); } } }
public static async Task Execute(ISession session) { var myPokemonFamilies = await session.Inventory.GetPokemonFamilies(); var myPokeSettings = await session.Inventory.GetPokemonSettings(); var highestsPokemonCp = await session.Inventory.GetHighestsCp(session.LogicSettings.AmountOfPokemonToDisplayOnStart); var highestsPokemonCpForUpgrade = await session.Inventory.GetHighestsCp(50); var highestsPokemonIvForUpgrade = await session.Inventory.GetHighestsPerfect(50); var pokemonPairedWithStatsCp = highestsPokemonCp.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); var pokemonPairedWithStatsCpForUpgrade = highestsPokemonCpForUpgrade.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList(); var highestsPokemonPerfect = await session.Inventory.GetHighestsPerfect(session.LogicSettings.AmountOfPokemonToDisplayOnStart); var pokemonPairedWithStatsIv = highestsPokemonPerfect.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); var pokemonPairedWithStatsIvForUpgrade = highestsPokemonIvForUpgrade.Select( pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList(); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "CP", PokemonList = pokemonPairedWithStatsCp }); await Task.Delay(500); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent { SortedBy = "IV", PokemonList = pokemonPairedWithStatsIv }); foreach (var pokemon in pokemonPairedWithStatsIvForUpgrade) { var dgdfs = pokemon.ToString(); var tokens = dgdfs.Split(new[] { "id" }, StringSplitOptions.None); var splitone = tokens[1].Split('"'); var iv = session.Inventory.GetPerfect(pokemon.Item1); if (iv >= session.LogicSettings.UpgradePokemonIvMinimum) { PokemonId.Add(ulong.Parse(splitone[2])); } } foreach (var t in pokemonPairedWithStatsCpForUpgrade) { var dgdfs = t.ToString(); var tokens = dgdfs.Split(new[] { "id" }, StringSplitOptions.None); var splitone = tokens[1].Split('"'); var tokensSplit = tokens[1].Split(new[] { "cp" }, StringSplitOptions.None); var tokenSplitAgain = tokensSplit[1].Split(' '); var tokenSplitAgain2 = tokenSplitAgain[1].Split(','); if (float.Parse(tokenSplitAgain2[0]) >= session.LogicSettings.UpgradePokemonCpMinimum) { PokemonIdcp.Add(ulong.Parse(splitone[2])); } } var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000) : await session.Inventory.GetHighestsCp(1000); if (session.LogicSettings.DumpPokemonStats) { const string dumpFileName = "PokeBagStats"; Dumper.ClearDumpFile(session, dumpFileName); Dumper.Dump(session, "pokemonid,pokemonlevel,cp,perfection,stamina,staminamax,move1,move2,candy,ownername,origin,heightm,weightkg,individualattack,individualdefense,individualstamina,cpmultiplier,battlesattacked,battlesdefended,creationtimems,numupgrades,additionalcpmultiplier,favorite,nickname", dumpFileName); foreach (var pokemon in allPokemonInBag) { Dumper.Dump(session, $"{pokemon.PokemonId},{PokemonInfo.GetLevel(pokemon)},{pokemon.Cp},{PokemonInfo.CalculatePokemonPerfection(pokemon)},{pokemon.Stamina},{pokemon.StaminaMax},{pokemon.Move1},{pokemon.Move2},{PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings)},{pokemon.OwnerName},{pokemon.Origin},{pokemon.HeightM},{pokemon.WeightKg},{pokemon.IndividualAttack},{pokemon.IndividualDefense},{pokemon.IndividualStamina},{pokemon.CpMultiplier},{pokemon.BattlesAttacked},{pokemon.BattlesDefended},{pokemon.CreationTimeMs},{pokemon.NumUpgrades},{pokemon.AdditionalCpMultiplier},{pokemon.Favorite},{pokemon.Nickname}", dumpFileName); } } await Task.Delay(500); }