From ed18d1015a6f5cc78a521156d5ef7bce4024d308 Mon Sep 17 00:00:00 2001 From: DilatoryCheetah Date: Tue, 2 Aug 2016 14:40:45 -0700 Subject: [PATCH] Dump all wild pokemon encounters to dump folder The dump file can be parsed to be used for other apps or just to get historical data on all pokemon encountered including those being sniped --- PoGo.PokeMobBot.CLI/ConsoleEventListener.cs | 12 +++++++++++ .../Event/PokemonEncounterEvent.cs | 14 +++++++++++++ .../PoGo.PokeMobBot.Logic.csproj | 1 + .../Tasks/CatchPokemonTask.cs | 20 +++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 PoGo.PokeMobBot.Logic/Event/PokemonEncounterEvent.cs diff --git a/PoGo.PokeMobBot.CLI/ConsoleEventListener.cs b/PoGo.PokeMobBot.CLI/ConsoleEventListener.cs index c1cd3b9..a39246d 100644 --- a/PoGo.PokeMobBot.CLI/ConsoleEventListener.cs +++ b/PoGo.PokeMobBot.CLI/ConsoleEventListener.cs @@ -214,6 +214,18 @@ public void HandleEvent(SnipeScanEvent evt, ISession session) $"{evt.Bounds.Latitude},{evt.Bounds.Longitude}")); } + public void HandleEvent(PokemonEncounterEvent evt, ISession session) + { + Logger.Write( + $"{evt.WildPokemon.PokemonId.ToString().PadRight(16, ' ')} | " + + $"Lvl: {Logic.PoGoUtils.PokemonInfo.GetLevel(evt.WildPokemon),2:#0} | " + + $"CP: {evt.WildPokemon.Cp,4:###0}/{Logic.PoGoUtils.PokemonInfo.CalculateMaxCp(evt.WildPokemon),4:###0} | " + + $"IV: {Logic.PoGoUtils.PokemonInfo.CalculatePokemonPerfection(evt.WildPokemon),6:##0.00}% | " + + $"[{evt.WildPokemon.IndividualAttack,2:#0}/{evt.WildPokemon.IndividualDefense,2:#0}/{evt.WildPokemon.IndividualStamina,2:#0}] | " + + $"Location: {evt.MapPokemon.Latitude},{evt.MapPokemon.Longitude}", + LogLevel.Caught, ConsoleColor.Green); + } + public void HandleEvent(DisplayHighestsPokemonEvent evt, ISession session) { string strHeader; diff --git a/PoGo.PokeMobBot.Logic/Event/PokemonEncounterEvent.cs b/PoGo.PokeMobBot.Logic/Event/PokemonEncounterEvent.cs new file mode 100644 index 0000000..6160e9b --- /dev/null +++ b/PoGo.PokeMobBot.Logic/Event/PokemonEncounterEvent.cs @@ -0,0 +1,14 @@ +#region using directives + +using POGOProtos.Enums; + +#endregion + +namespace PoGo.PokeMobBot.Logic.Event +{ + public class PokemonEncounterEvent : IEvent + { + public POGOProtos.Data.PokemonData WildPokemon { get; set; } + public POGOProtos.Map.Pokemon.MapPokemon MapPokemon { get; set; } + } +} \ No newline at end of file diff --git a/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj b/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj index bb1cfe3..4e86c3a 100644 --- a/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj +++ b/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj @@ -61,6 +61,7 @@ + diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchPokemonTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchPokemonTask.cs index 97d6c99..1b567b4 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchPokemonTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchPokemonTask.cs @@ -29,6 +29,26 @@ public static async Task Execute(ISession session, dynamic encounter, MapPokemon throw new ArgumentException("Parameter pokemon must be set, if encounter is of type EncounterResponse", "pokemon"); + if (encounter is EncounterResponse) + { + session.EventDispatcher.Send(new PokemonEncounterEvent + { + WildPokemon = encounter.WildPokemon?.PokemonData, + MapPokemon = pokemon + }); + + DataDumper.Dumper.Dump(session, + $"[{DateTime.Now.ToString("HH:mm:ss")}] | " + + $"{encounter.WildPokemon?.PokemonData?.PokemonId.ToString().PadRight(16, ' ')} | " + + $"Lvl: {PokemonInfo.GetLevel(encounter.WildPokemon?.PokemonData),2:#0} | " + + $"CP: {encounter.WildPokemon?.PokemonData?.Cp,4:###0}/{PokemonInfo.CalculateMaxCp(encounter.WildPokemon?.PokemonData),4:###0} | " + + $"IV: {PokemonInfo.CalculatePokemonPerfection(encounter.WildPokemon?.PokemonData),6:##0.00}% | " + + $"[{encounter.WildPokemon?.PokemonData?.IndividualAttack,2:#0}/{encounter.WildPokemon?.PokemonData?.IndividualDefense,2:#0}/{encounter.WildPokemon?.PokemonData?.IndividualStamina,2:#0}] | " + + $"Location: {pokemon.Latitude},{pokemon.Longitude} | " + + $"EncounterId: {pokemon.EncounterId}", + "encounters"); + } + CatchPokemonResponse caughtPokemonResponse; var attemptCounter = 1; do