PokemonsTransfered state now count correct again
PokemonsTransfered state now count correct again
Added LvLUp in {_hours}hours // EXP required: {_ep}
diff --git a/PokemonGo.RocketAPI.Logic/Inventory.cs b/PokemonGo.RocketAPI.Logic/Inventory.cs
index b4129e3..a0dcffa 100644
--- a/PokemonGo.RocketAPI.Logic/Inventory.cs
+++ b/PokemonGo.RocketAPI.Logic/Inventory.cs
@@ -121,6 +121,14 @@ namespace PokemonGo.RocketAPI.Logic
return pokemonToEvolve;
}
+ public async Task<IEnumerable<PlayerStats>> GetPlayerStats()
+ {
+ var inventory = await _client.GetInventory();
+ return inventory.InventoryDelta.InventoryItems
+ .Select(i => i.InventoryItemData?.PlayerStats)
+ .Where(p => p != null);
+ }
+
public async Task<IEnumerable<Item>> GetItems()
{
var inventory = await _client.GetInventory();
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 4ed5af4..5b9ebd9 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -71,10 +71,11 @@ namespace PokemonGo.RocketAPI.Logic
{
await _client.SetServer();
- var inventory = await _client.GetInventory();
- var playerStats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData).FirstOrDefault(i => i.PlayerStats != null);
+ //var inventory = await _client.GetInventory();
+ //var playerStats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData).FirstOrDefault(i => i.PlayerStats != null);
+
var profile = await _client.GetProfile();
- var _currentLevelInfos = await Statistics._getcurrentLevelInfos(_client);
+ var _currentLevelInfos = await Statistics._getcurrentLevelInfos(_inventory);
Logger.Normal(ConsoleColor.Yellow, "----------------------------");
if (_clientSettings.AuthType == AuthType.Ptc)
@@ -141,7 +142,7 @@ namespace PokemonGo.RocketAPI.Logic
var fortSearch = await _client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
_stats.addExperience(fortSearch.ExperienceAwarded);
- _stats.updateConsoleTitle(_client);
+ _stats.updateConsoleTitle(_inventory);
Logger.Normal(ConsoleColor.Cyan, $"Using Pokestop: {fortInfo.Name} in {Math.Round(distance)}m distance");
Logger.Normal(ConsoleColor.Cyan, $"Received XP: {fortSearch.ExperienceAwarded}, Gems: { fortSearch.GemsAwarded}, Eggs: {fortSearch.PokemonDataEgg} Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}");
@@ -202,7 +203,7 @@ namespace PokemonGo.RocketAPI.Logic
var profile = await _client.GetProfile();
_stats.getStardust(profile.Profile.Currency.ToArray()[1].Amount);
}
- _stats.updateConsoleTitle(_client);
+ _stats.updateConsoleTitle(_inventory);
Logger.Normal(ConsoleColor.Yellow,
caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess
? $"We caught a {pokemon.PokemonId} with CP {encounter?.WildPokemon?.PokemonData?.Cp} and CaptureProbability: {encounter?.CaptureProbability.CaptureProbability_.First()}, used {bestPokeball} in {Math.Round(distance)}m distance and received XP {caughtPokemonResponse.Scores.Xp.Sum()}"
@@ -245,6 +246,10 @@ namespace PokemonGo.RocketAPI.Logic
{
var bestPokemonOfType = await _inventory.GetHighestCPofType(duplicatePokemon);
var transfer = await _client.TransferPokemon(duplicatePokemon.Id);
+
+ _stats.increasePokemonsTransfered();
+ _stats.updateConsoleTitle(_inventory);
+
Logger.Normal(ConsoleColor.DarkYellow, $"Transfer {duplicatePokemon.PokemonId} with {duplicatePokemon.Cp} CP (Best: {bestPokemonOfType})");
await Task.Delay(500);
}
@@ -260,7 +265,7 @@ namespace PokemonGo.RocketAPI.Logic
Logger.Normal(ConsoleColor.DarkCyan, $"Recycled {item.Count}x {(AllEnum.ItemId)item.Item_}");
_stats.addItemsRemoved(item.Count);
- _stats.updateConsoleTitle(_client);
+ _stats.updateConsoleTitle(_inventory);
await Task.Delay(500);
}
@@ -272,9 +277,9 @@ namespace PokemonGo.RocketAPI.Logic
var items = await _inventory.GetItems();
var balls = items.Where(i => (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_POKE_BALL
- || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_MASTER_BALL
- || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_ULTRA_BALL
- || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_GREAT_BALL).GroupBy(i => ((MiscEnums.Item)i.Item_)).ToList();
+ || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_MASTER_BALL
+ || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_ULTRA_BALL
+ || (MiscEnums.Item)i.Item_ == MiscEnums.Item.ITEM_GREAT_BALL).GroupBy(i => ((MiscEnums.Item)i.Item_)).ToList();
if (balls.Count == 0) return MiscEnums.Item.ITEM_UNKNOWN;
var pokeBalls = balls.Any(g => g.Key == MiscEnums.Item.ITEM_POKE_BALL);
@@ -309,6 +314,14 @@ namespace PokemonGo.RocketAPI.Logic
{
var pokemonCp = pokemon?.PokemonData?.Cp;
+ var items = await _inventory.GetItems();
+ var berries = items.Where(i => (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemRazzBerry
+ || (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemBlukBerry
+ || (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemNanabBerry
+ || (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemWeparBerry
+ || (AllEnum.ItemId)i.Item_ == AllEnum.ItemId.ItemPinapBerry).GroupBy(i => ((AllEnum.ItemId)i.Item_)).ToList();
+ if (berries.Count == 0) return AllEnum.ItemId.ItemUnknown;
+
var razzBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_RAZZ_BERRY);
var blukBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_BLUK_BERRY);
var nanabBerryCount = await _inventory.GetItemAmountByType(MiscEnums.Item.ITEM_NANAB_BERRY);
@@ -332,18 +345,7 @@ namespace PokemonGo.RocketAPI.Logic
if (blukBerryCount > 0 && pokemonCp >= 350)
return AllEnum.ItemId.ItemBlukBerry;
- if (razzBerryCount > 0)
- return AllEnum.ItemId.ItemRazzBerry;
- if (blukBerryCount > 0)
- return AllEnum.ItemId.ItemBlukBerry;
- if (nanabBerryCount > 0)
- return AllEnum.ItemId.ItemNanabBerry;
- if (weparBerryCount > 0)
- return AllEnum.ItemId.ItemWeparBerry;
- if (pinapBerryCount > 0)
- return AllEnum.ItemId.ItemPinapBerry;
-
- return AllEnum.ItemId.ItemUnknown;
+ return berries.OrderBy(g => g.Key).First().Key;
}
}
}
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs b/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
index d16f40b..b2649c8 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
@@ -3,22 +3,28 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using PokemonGo.RocketAPI.Enums;
+using PokemonGo.RocketAPI.Exceptions;
+using PokemonGo.RocketAPI.Extensions;
+using PokemonGo.RocketAPI.GeneratedCode;
+using PokemonGo.RocketAPI.Logic.Utils;
+using PokemonGo.RocketAPI.Helpers;
namespace PokemonGo.RocketAPI.Logic.Utils
{
class Statistics
{
- private int _totalExperience;
- private int _totalPokemons;
- private int _totalItemsRemoved;
- private int _totalPokemonsTransfered;
- private int _totalStardust;
- public static string _getLevelInfos;
+ public static int _totalExperience;
+ public static int _totalPokemons;
+ public static int _totalItemsRemoved;
+ public static int _totalPokemonsTransfered;
+ public static int _totalStardust;
+ public static string _currentLevelInfos;
public static int Currentlevel = -1;
- private DateTime _initSessionDateTime = DateTime.Now;
+ public static DateTime _initSessionDateTime = DateTime.Now;
- private double _getSessionRuntime()
+ public static double _getSessionRuntime()
{
return ((DateTime.Now - _initSessionDateTime).TotalSeconds) / 3600;
}
@@ -28,17 +34,18 @@ namespace PokemonGo.RocketAPI.Logic.Utils
_totalExperience += xp;
}
- public static async Task<string> _getcurrentLevelInfos(Client _client)
+ public static async Task<string> _getcurrentLevelInfos(Inventory _inventory)
{
- var inventory = await _client.GetInventory();
- var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PlayerStats).ToArray();
+ var stats = await _inventory.GetPlayerStats();
var output = string.Empty;
- foreach (var v in stats)
- if (v != null)
- {
- Currentlevel = v.Level;
- output = $"{v.Level} ({v.Experience}/{v.NextLevelXp})";
- }
+ PlayerStats stat = stats.FirstOrDefault();
+ if (stat != null)
+ {
+ var _ep = (stat.NextLevelXp - stat.PrevLevelXp) - (stat.Experience - stat.PrevLevelXp);
+ var _hours = Math.Round(_ep / (_totalExperience / _getSessionRuntime()),2);
+
+ output = $"{stat.Level} (LvLUp in {_hours}hours // EXP required: {_ep})";
+ }
return output;
}
@@ -62,15 +69,15 @@ namespace PokemonGo.RocketAPI.Logic.Utils
_totalPokemonsTransfered += 1;
}
- public async void updateConsoleTitle(Client _client)
+ public async void updateConsoleTitle(Inventory _inventory)
{
- _getLevelInfos = await _getcurrentLevelInfos(_client);
+ _currentLevelInfos = await _getcurrentLevelInfos(_inventory);
Console.Title = ToString();
}
public override string ToString()
{
- return string.Format("{0} - LvL: {1:0} EXP Exp/H: {2:0.0} EXP P/H: {3:0.0} Pokemon(s) Stardust: {4:0} Pokemon Transfered: {5:0} Items Removed: {6:0}", "Statistics", _getLevelInfos, _totalExperience / _getSessionRuntime(), _totalPokemons / _getSessionRuntime(), _totalStardust, _totalPokemonsTransfered, _totalItemsRemoved);
+ return string.Format("{0} - LvL: {1:0} EXP/H: {2:0.0} EXP P/H: {3:0.0} Pokemon(s) Stardust: {4:0} Pokemon Transfered: {5:0} Items Removed: {6:0}", "Statistics", _currentLevelInfos, _totalExperience / _getSessionRuntime(), _totalPokemons / _getSessionRuntime(), _totalStardust, _totalPokemonsTransfered, _totalItemsRemoved);
}
}
}
\ No newline at end of file
You may download the files in Public Git.