From 5619350a3a469e72d9bdcace1c2e56dff64de1ca Mon Sep 17 00:00:00 2001 From: Snorlax1 Date: Sat, 30 Jul 2016 21:47:37 +0200 Subject: [PATCH 1/2] Adding Candy to pokemon output. --- PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs | 14 ++++++++++++++ .../Tasks/DisplayPokemonStatsTask.cs | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs b/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs index fd531aad2..744130ada 100644 --- a/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs +++ b/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs @@ -3,6 +3,11 @@ using System; using POGOProtos.Data; using POGOProtos.Enums; +using PoGo.NecroBot.Logic.State; +using POGOProtos.Settings.Master; +using System.Collections.Generic; +using POGOProtos.Inventory; +using System.Linq; #endregion @@ -65,6 +70,15 @@ public static PokemonMove GetPokemonMove2(PokemonData poke) return move2; } + public static int GetCandy(PokemonData pokemon, List PokemonFamilies, IEnumerable PokemonSettings) + { + var setting = PokemonSettings.FirstOrDefault(q => pokemon != null && q.PokemonId.Equals(pokemon.PokemonId)); + var family = PokemonFamilies.FirstOrDefault(q => setting != null && q.FamilyId.Equals(setting.FamilyId)); + + return family.Candy_; + + } + public static double CalculateMaxCpMultiplier(PokemonData poke) { var baseStats = GetBaseStats(poke.PokemonId); diff --git a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs index 013dfd41f..764358999 100644 --- a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -16,6 +16,9 @@ public class DisplayPokemonStatsTask { 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))).ToList(); @@ -47,7 +50,8 @@ public static async Task Execute(ISession session) Dumper.ClearDumpFile(session, dumpFileName); foreach (var pokemon in allPokemonInBag) { - Dumper.Dump(session, $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: { PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: { pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: { pokemon.Move1.ToString()}\t\t\tMOVE2: { pokemon.Move2.ToString()}", dumpFileName); + int candy = PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings); + Dumper.Dump(session, $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: { PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: { pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: { PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: { pokemon.Move1.ToString()}\t\t\tMOVE2: { pokemon.Move2.ToString()} \t\tCandy: {candy}", dumpFileName); } } From e766bea2838bb3a292e89d32616dbe2fc441d792 Mon Sep 17 00:00:00 2001 From: Snorlax1 Date: Sat, 30 Jul 2016 22:20:22 +0200 Subject: [PATCH 2/2] Added Candy to console pokemon output and text file dump. --- PoGo.NecroBot.CLI/ConsoleEventListener.cs | 7 +++++-- PoGo.NecroBot.Logic/Common/Translations.cs | 6 ++++-- .../Event/DisplayHighestsPokemonEvent.cs | 4 ++-- PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs | 12 ++++++++++++ PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs | 12 +++++++++--- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/PoGo.NecroBot.CLI/ConsoleEventListener.cs b/PoGo.NecroBot.CLI/ConsoleEventListener.cs index b8ff283be..769c1d257 100644 --- a/PoGo.NecroBot.CLI/ConsoleEventListener.cs +++ b/PoGo.NecroBot.CLI/ConsoleEventListener.cs @@ -197,7 +197,7 @@ public void HandleEvent(SnipeScanEvent evt, ISession session) public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session) { string strHeader; - //PokemonData | CP | IV | Level | MOVE1 | MOVE2 + //PokemonData | CP | IV | Level | MOVE1 | MOVE2 | Candy switch (evt.SortedBy) { case "Level": @@ -215,6 +215,9 @@ public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session) case "MOVE2": strHeader = session.Translation.GetTranslation(TranslationString.DisplayHighestMove2Header); break; + case "Candy": + strHeader = session.Translation.GetTranslation(TranslationString.DisplayHighestCandy); + break; default: strHeader = session.Translation.GetTranslation(TranslationString.DisplayHighestsHeader); break; @@ -225,7 +228,7 @@ public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session) Logger.Write($"====== {strHeader} ======", LogLevel.Info, ConsoleColor.Yellow); foreach (var pokemon in evt.PokemonList) Logger.Write( - $"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% {strPerfect})\t| Lvl {pokemon.Item4.ToString("00")}\t {strName}: {pokemon.Item1.PokemonId.ToString().PadRight(10, ' ')}\t MOVE1: {pokemon.Item5.ToString().PadRight(20, ' ')} MOVE2: {pokemon.Item6}", + $"# CP {pokemon.Item1.Cp.ToString().PadLeft(4, ' ')}/{pokemon.Item2.ToString().PadLeft(4, ' ')} | ({pokemon.Item3.ToString("0.00")}% {strPerfect})\t| Lvl {pokemon.Item4.ToString("00")}\t {strName}: {pokemon.Item1.PokemonId.ToString().PadRight(10, ' ')}\t MOVE1: {pokemon.Item5.ToString().PadRight(20, ' ')} MOVE2: {pokemon.Item6.ToString().PadRight(20, ' ')} Candy: {pokemon.Item7}", LogLevel.Info, ConsoleColor.Yellow); } diff --git a/PoGo.NecroBot.Logic/Common/Translations.cs b/PoGo.NecroBot.Logic/Common/Translations.cs index 748da0952..b26315113 100644 --- a/PoGo.NecroBot.Logic/Common/Translations.cs +++ b/PoGo.NecroBot.Logic/Common/Translations.cs @@ -126,7 +126,8 @@ public enum TranslationString NoPokemonToSnipe, NotEnoughPokeballsToSnipe, DisplayHighestMove1Header, - DisplayHighestMove2Header + DisplayHighestMove2Header, + DisplayHighestCandy } public class Translation : ITranslation @@ -311,7 +312,8 @@ public class Translation : ITranslation new KeyValuePair(TranslationString.NotEnoughPokeballsToSnipe, "Not enough Pokeballs to start sniping! ({0}/{1})"), new KeyValuePair(TranslationString.DisplayHighestMove1Header, "MOVE1"), - new KeyValuePair(TranslationString.DisplayHighestMove2Header, "MOVE2") + new KeyValuePair(TranslationString.DisplayHighestMove2Header, "MOVE2"), + new KeyValuePair(TranslationString.DisplayHighestCandy, "Candy") }; public string GetTranslation(TranslationString translationString, params object[] data) diff --git a/PoGo.NecroBot.Logic/Event/DisplayHighestsPokemonEvent.cs b/PoGo.NecroBot.Logic/Event/DisplayHighestsPokemonEvent.cs index 2f60551ee..f6458f7af 100644 --- a/PoGo.NecroBot.Logic/Event/DisplayHighestsPokemonEvent.cs +++ b/PoGo.NecroBot.Logic/Event/DisplayHighestsPokemonEvent.cs @@ -11,8 +11,8 @@ namespace PoGo.NecroBot.Logic.Event { public class DisplayHighestsPokemonEvent : IEvent { - //PokemonData | CP | IV | Level | MOVE1 | MOVE2 - public List> PokemonList; + //PokemonData | CP | IV | Level | MOVE1 | MOVE2 | Candy + public List> PokemonList; public string SortedBy; } } \ No newline at end of file diff --git a/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs b/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs index 2dd5fb737..669573905 100644 --- a/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs +++ b/PoGo.NecroBot.Logic/PoGoUtils/PokemonInfo.cs @@ -3,6 +3,10 @@ using System; using POGOProtos.Data; using POGOProtos.Enums; +using POGOProtos.Inventory; +using System.Collections.Generic; +using POGOProtos.Settings.Master; +using System.Linq; #endregion @@ -579,6 +583,14 @@ public static PokemonMove GetPokemonMove2(PokemonData poke) return move2; } + public static int GetCandy(PokemonData pokemon, List PokemonFamilies, IEnumerable PokemonSettings) + { + var setting = PokemonSettings.FirstOrDefault(q => pokemon != null && q.PokemonId.Equals(pokemon.PokemonId)); + var family = PokemonFamilies.FirstOrDefault(q => setting != null && q.FamilyId.Equals(setting.FamilyId)); + + return family.Candy_; + } + public static int GetPowerUpLevel(PokemonData poke) { return (int) (GetLevel(poke)*2.0); diff --git a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs index f523fea4d..0e5e31096 100644 --- a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -22,6 +22,9 @@ public class DisplayPokemonStatsTask 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); @@ -31,7 +34,8 @@ public static async Task Execute(ISession session) pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), - PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList(); + PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), + PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); var pokemonPairedWithStatsCpForUpgrade = highestsPokemonCpForUpgrade.Select( pokemon => @@ -46,7 +50,8 @@ public static async Task Execute(ISession session) pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), - PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList(); + PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), + PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); var pokemonPairedWithStatsIvForUpgrade = highestsPokemonIvForUpgrade.Select( pokemon => @@ -104,8 +109,9 @@ public static async Task Execute(ISession session) Dumper.ClearDumpFile(session, dumpFileName); foreach (var pokemon in allPokemonInBag) { + int candy = PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings); Dumper.Dump(session, - $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2}", + $"NAME: {pokemon.PokemonId.ToString().PadRight(16, ' ')}Lvl: {PokemonInfo.GetLevel(pokemon).ToString("00")}\t\tCP: {pokemon.Cp.ToString().PadRight(8, ' ')}\t\t IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00")}%\t\t\tMOVE1: {pokemon.Move1}\t\t\tMOVE2: {pokemon.Move2} \t\tCandy: {candy}", dumpFileName); } }