Level now showen in the TopBar Statistics

Spegeli [2016-07-22 05:51:21]
Level now showen in the TopBar Statistics
Filename
PokemonGo.RocketAPI.Logic/Logic.cs
PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 2431b18..0568e58 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -53,17 +53,23 @@ namespace PokemonGo.RocketAPI.Logic
                 {
                     await _client.SetServer();
                     var profile = await _client.GetProfile();
+                    var inventory = await _client.GetInventory();
+                    var _currentLevelInfos = await Statistics._getcurrentLevelInfos(_client);
+
                     Logger.Normal(ConsoleColor.Yellow, "----------------------------");
                     if (_clientSettings.AuthType == AuthType.Ptc)
-                        Logger.Normal(ConsoleColor.Cyan, "PTC Account: " + _clientSettings.PtcUsername + "\n");
+                        Logger.Normal(ConsoleColor.Cyan, $"PTC Account: {_clientSettings.PtcUsername}\n");
                     //Logger.Normal(ConsoleColor.Cyan, "Password: " + _clientSettings.PtcPassword + "\n");
-                    Logger.Normal(ConsoleColor.DarkGray, "Latitude: " + _clientSettings.DefaultLatitude);
-                    Logger.Normal(ConsoleColor.DarkGray, "Longitude: " + _clientSettings.DefaultLongitude);
+                    Logger.Normal(ConsoleColor.DarkGray, $"Latitude: {_clientSettings.DefaultLatitude}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Longitude: {_clientSettings.DefaultLongitude}");
                     Logger.Normal(ConsoleColor.Yellow, "----------------------------");
                     Logger.Normal(ConsoleColor.DarkGray, "Your Account:\n");
-                    Logger.Normal(ConsoleColor.DarkGray, "Name: " + profile.Profile.Username);
-                    Logger.Normal(ConsoleColor.DarkGray, "Team: " + profile.Profile.Team);
-                    Logger.Normal(ConsoleColor.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount);
+                    Logger.Normal(ConsoleColor.DarkGray, $"Name: {profile.Profile.Username}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Team: {profile.Profile.Team}");
+
+                    Logger.Normal(ConsoleColor.DarkGray, $"Level: {_currentLevelInfos}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Team: {profile.Profile.Team}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Stardust: {profile.Profile.Currency.ToArray()[1].Amount}");
                     Logger.Normal(ConsoleColor.Yellow, "----------------------------");

                     await TransferDuplicatePokemon(false);
@@ -110,7 +116,7 @@ namespace PokemonGo.RocketAPI.Logic
                 var fortSearch = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

                 _stats.addExperience(fortSearch.ExperienceAwarded);
-                _stats.updateConsoleTitle();
+                _stats.updateConsoleTitle(_client);

                 Logger.Normal(ConsoleColor.Cyan, $"Using Pokestop: {fortInfo.Name}");
                 Logger.Normal(ConsoleColor.Cyan, $"Received XP: {fortSearch.ExperienceAwarded}, Gems: { fortSearch.GemsAwarded}, Eggs: {fortSearch.PokemonDataEgg} Items: {StringUtils.GetSummedFriendlyNameOfItemAwardList(fortSearch.ItemsAwarded)}");
@@ -167,7 +173,7 @@ namespace PokemonGo.RocketAPI.Logic
                     _stats.getStardust(profile.Profile.Currency.ToArray()[1].Amount);
                 }

-                _stats.updateConsoleTitle();
+                _stats.updateConsoleTitle(_client);

                 Logger.Normal(ConsoleColor.Yellow, caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"We caught a {pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp}, used {balls_used} x {pokeball} and received XP {caughtPokemonResponse.Scores.Xp.Sum()}" : $"{pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} got away while using a {pokeball}..");

@@ -197,7 +203,7 @@ namespace PokemonGo.RocketAPI.Logic
                 while (evolvePokemonOutProto.Result == EvolvePokemonOut.Types.EvolvePokemonStatus.PokemonEvolvedSuccess);

                 _stats.increasePokemonsTransfered();
-                _stats.updateConsoleTitle();
+                _stats.updateConsoleTitle(_client);

                 await Task.Delay(3000);
             }
@@ -227,7 +233,7 @@ namespace PokemonGo.RocketAPI.Logic
                 Logger.Normal(ConsoleColor.DarkCyan, $"Recycled {item.Count}x {(AllEnum.ItemId)item.Item_}");

                 _stats.addItemsRemoved(item.Count);
-                _stats.updateConsoleTitle();
+                _stats.updateConsoleTitle(_client);

                 await Task.Delay(500);
             }
diff --git a/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs b/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
index ffac44e..f649c25 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
@@ -13,6 +13,8 @@ namespace PokemonGo.RocketAPI.Logic.Utils
         private int _totalItemsRemoved;
         private int _totalPokemonsTransfered;
         private int _totalStardust;
+        public static string _getLevelInfos;
+        public static int Currentlevel = -1;

         private DateTime _initSessionDateTime = DateTime.Now;

@@ -26,6 +28,20 @@ namespace PokemonGo.RocketAPI.Logic.Utils
             _totalExperience += xp;
         }

+        public static async Task<string> _getcurrentLevelInfos(Client _client)
+        {
+            var inventory = await _client.GetInventory();
+            var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PlayerStats).ToArray();
+            var output = string.Empty;
+            foreach (var v in stats)
+                if (v != null)
+                {
+                    Currentlevel = v.Level;
+                    output = $"{v.Level} ({v.Experience}/{v.NextLevelXp})";
+                }
+            return output;
+        }
+
         public void increasePokemons()
         {
             _totalPokemons += 1;
@@ -46,14 +62,15 @@ namespace PokemonGo.RocketAPI.Logic.Utils
             _totalPokemonsTransfered += 1;
         }

-        public void updateConsoleTitle()
+        public async void updateConsoleTitle(Client _client)
         {
+            _getLevelInfos = await _getcurrentLevelInfos(_client);
             Console.Title = ToString();
         }

         public override string ToString()
         {
-            return string.Format("{0} - Exp/H: {1:0.0} EXP   P/H: {2:0.0} Pokemon(s)   Stardust: {3:0}   Pokemon Transfered: {4:0}   Items Removed: {5:0}", "Statistics", _totalExperience / _getSessionRuntime(), _totalPokemons / _getSessionRuntime(), _totalStardust, _totalPokemonsTransfered, _totalItemsRemoved);
+            return string.Format("{0} - LvL: Exp/H: {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);
         }
     }
 }
\ No newline at end of file
You may download the files in Public Git.