Advertisement
Guest User

pueblo6

a guest
Jul 26th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.95 KB | None | 0 0
  1. #region
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Net;
  8. using System.Reflection;
  9. using System.Text.RegularExpressions;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using AllEnum;
  13. using PokemonGo.RocketAPI.Enums;
  14. using PokemonGo.RocketAPI.Exceptions;
  15. using PokemonGo.RocketAPI.Extensions;
  16. using PokemonGo.RocketAPI.GeneratedCode;
  17. using System.Net.Http;
  18. using System.Text;
  19. using Google.Protobuf;
  20. using PokemonGo.RocketAPI.Helpers;
  21. using System.IO;
  22.  
  23. #endregion
  24.  
  25. namespace PokemonGo.RocketAPI.Console
  26. {
  27. internal class Program
  28. {
  29. private static readonly ISettings ClientSettings = new Settings();
  30. static int Currentlevel = -1;
  31. static IEnumerable<PokemonData> POKEMONS;
  32. public static void CheckVersion()
  33. {
  34. try
  35. {
  36. var match =
  37. new Regex(
  38. @"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]")
  39. .Match(DownloadServerVersion());
  40.  
  41. if (!match.Success) return;
  42. var gitVersion =
  43. new Version(
  44. string.Format(
  45. "{0}.{1}.{2}.{3}",
  46. match.Groups[1],
  47. match.Groups[2],
  48. match.Groups[3],
  49. match.Groups[4]));
  50. if (gitVersion <= Assembly.GetExecutingAssembly().GetName().Version)
  51. {
  52. ColoredConsoleWrite(ConsoleColor.Yellow, "Awesome! You have already got the newest version! " + Assembly.GetExecutingAssembly().GetName().Version);
  53. return;
  54. }
  55. ;
  56.  
  57. ColoredConsoleWrite(ConsoleColor.White, "There is a new Version available: " + gitVersion + " downloading.. ");
  58. Thread.Sleep(1000);
  59. Process.Start("");
  60. }
  61. catch (Exception)
  62. {
  63. ColoredConsoleWrite(ConsoleColor.White, "Unable to check for updates now...");
  64. }
  65. }
  66.  
  67. private static string DownloadServerVersion()
  68. {
  69. using (var wC = new WebClient())
  70. return
  71. wC.DownloadString(
  72. "");
  73. }
  74.  
  75. public static void ColoredConsoleWrite(ConsoleColor color, string text)
  76. {
  77. ConsoleColor originalColor = System.Console.ForegroundColor;
  78. System.Console.ForegroundColor = color;
  79. System.Console.WriteLine(text);
  80. System.Console.ForegroundColor = originalColor;
  81. }
  82.  
  83.  
  84. private static async Task EvolveAllGivenPokemons(Client client, IEnumerable<PokemonData> pokemonToEvolve)
  85. {
  86. ColoredConsoleWrite(ConsoleColor.Cyan,
  87. $"[{DateTime.Now.ToString("HH:mm:ss")}] Attempting to evolve pokemons");
  88. foreach (var pokemon in pokemonToEvolve)
  89. {
  90. if (pokemon.PokemonId != PokemonId.Pidgey &&
  91. pokemon.PokemonId != PokemonId.Weedle &&
  92. pokemon.PokemonId != PokemonId.Zubat &&
  93. pokemon.PokemonId != PokemonId.Voltorb &&
  94. pokemon.PokemonId != PokemonId.Magnemite &&
  95. pokemon.PokemonId != PokemonId.Caterpie &&
  96. pokemon.PokemonId != PokemonId.Rattata)
  97. continue;
  98.  
  99.  
  100. var countOfEvolvedUnits = 0;
  101. var xpCount = 0;
  102.  
  103. EvolvePokemonOut evolvePokemonOutProto;
  104. do
  105. {
  106. evolvePokemonOutProto = await client.EvolvePokemon(pokemon.Id);
  107. //todo: someone check whether this still works
  108.  
  109. if (evolvePokemonOutProto.Result == 1)
  110. {
  111. ColoredConsoleWrite(ConsoleColor.Cyan,
  112. $"[{DateTime.Now.ToString("HH:mm:ss")}] Evolved {pokemon.PokemonId} successfully for {evolvePokemonOutProto.ExpAwarded}xp");
  113.  
  114. countOfEvolvedUnits++;
  115. xpCount += evolvePokemonOutProto.ExpAwarded;
  116. }
  117. else
  118. {
  119. var result = evolvePokemonOutProto.Result;
  120. /*
  121. ColoredConsoleWrite(ConsoleColor.White, $"Failed to evolve {pokemon.PokemonId}. " +
  122. $"EvolvePokemonOutProto.Result was {result}");
  123.  
  124. ColoredConsoleWrite(ConsoleColor.White, $"Due to above error, stopping evolving {pokemon.PokemonId}");
  125. */
  126. }
  127. } while (evolvePokemonOutProto.Result == 1);
  128. if (countOfEvolvedUnits > 0)
  129. ColoredConsoleWrite(ConsoleColor.Cyan,
  130. $"[{DateTime.Now.ToString("HH:mm:ss")}] Evolved {countOfEvolvedUnits} pieces of {pokemon.PokemonId} for {xpCount}xp");
  131. await Task.Delay(3000);
  132.  
  133. }
  134. }
  135.  
  136. private static async void Execute()
  137. {
  138. var client = new Client(ClientSettings);
  139. try
  140. {
  141. if (ClientSettings.AuthType == AuthType.Ptc)
  142. await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
  143. else if (ClientSettings.AuthType == AuthType.Google)
  144. await client.DoGoogleLogin();
  145.  
  146. await client.SetServer();
  147. var profile = await client.GetProfile();
  148. var settings = await client.GetSettings();
  149. var mapObjects = await client.GetMapObjects();
  150. var inventory = await client.GetInventory();
  151. var pokemons =
  152. inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
  153. .Where(p => p != null && p?.PokemonId > 0);
  154. POKEMONS = pokemons;
  155. ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
  156. ColoredConsoleWrite(ConsoleColor.Cyan, "Account: " + ClientSettings.PtcUsername);
  157. ColoredConsoleWrite(ConsoleColor.Cyan, "Password: " + ClientSettings.PtcPassword + "\n");
  158. ColoredConsoleWrite(ConsoleColor.DarkGray, "Latitude: " + ClientSettings.DefaultLatitude);
  159. ColoredConsoleWrite(ConsoleColor.DarkGray, "Longitude: " + ClientSettings.DefaultLongitude);
  160. ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
  161. ColoredConsoleWrite(ConsoleColor.DarkGray, "Your Account:\n");
  162. ColoredConsoleWrite(ConsoleColor.DarkGray, "Name: " + profile.Profile.Username);
  163. ColoredConsoleWrite(ConsoleColor.DarkGray, "Team: " + profile.Profile.Team);
  164. ColoredConsoleWrite(ConsoleColor.DarkGray, "Stardust: " + profile.Profile.Currency.ToArray()[1].Amount);
  165.  
  166. ColoredConsoleWrite(ConsoleColor.Cyan, "\nFarming Started");
  167. ColoredConsoleWrite(ConsoleColor.Yellow, "----------------------------");
  168. if (ClientSettings.TransferType == "leaveStrongest")
  169. await TransferAllButStrongestUnwantedPokemon(client);
  170. else if (ClientSettings.TransferType == "all")
  171. await TransferAllGivenPokemons(client, pokemons);
  172. else if (ClientSettings.TransferType == "duplicate")
  173. await TransferDuplicatePokemon(client);
  174. else if (ClientSettings.TransferType == "cp")
  175. await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
  176. else
  177. ColoredConsoleWrite(ConsoleColor.DarkGray, $"[{DateTime.Now.ToString("HH:mm:ss")}] Transfering pokemon disabled");
  178. if (ClientSettings.EvolveAllGivenPokemons)
  179. await EvolveAllGivenPokemons(client, pokemons);
  180.  
  181. client.RecycleItems(client);
  182.  
  183. await Task.Delay(5000);
  184. PrintLevel(client);
  185. ConsoleLevelTitle(profile.Profile.Username, client);
  186. await ExecuteFarmingPokestopsAndPokemons(client);
  187. ColoredConsoleWrite(ConsoleColor.Red, $"[{DateTime.Now.ToString("HH:mm:ss")}] No nearby usefull locations found. Please wait 10 seconds.");
  188. await Task.Delay(10000);
  189. Execute();
  190. }
  191. catch (TaskCanceledException tce) { ColoredConsoleWrite(ConsoleColor.White, "Task Canceled Exception - Restarting"); Execute(); }
  192. catch (UriFormatException ufe) { ColoredConsoleWrite(ConsoleColor.White, "System URI Format Exception - Restarting"); Execute(); }
  193. catch (ArgumentOutOfRangeException aore) { ColoredConsoleWrite(ConsoleColor.White, "ArgumentOutOfRangeException - Restarting"); Execute(); }
  194. catch (ArgumentNullException ane) { ColoredConsoleWrite(ConsoleColor.White, "Argument Null Refference - Restarting"); Execute(); }
  195. catch (NullReferenceException nre) { ColoredConsoleWrite(ConsoleColor.White, "Null Refference - Restarting"); Execute(); }
  196. //await ExecuteCatchAllNearbyPokemons(client);
  197. }
  198.  
  199. private static async Task ExecuteCatchAllNearbyPokemons(Client client)
  200. {
  201. var mapObjects = await client.GetMapObjects();
  202.  
  203. var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons);
  204.  
  205. var inventory2 = await client.GetInventory();
  206. var pokemons2 = inventory2.InventoryDelta.InventoryItems
  207. .Select(i => i.InventoryItemData?.Pokemon)
  208. .Where(p => p != null && p?.PokemonId > 0)
  209. .ToArray();
  210.  
  211. foreach (var pokemon in pokemons)
  212. {
  213. var update = await client.UpdatePlayerLocation(pokemon.Latitude, pokemon.Longitude);
  214. var encounterPokemonResponse = await client.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnpointId);
  215. var pokemonCP = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
  216. CatchPokemonResponse caughtPokemonResponse;
  217. do
  218. {
  219. caughtPokemonResponse =
  220. await
  221. client.CatchPokemon(pokemon.EncounterId, pokemon.SpawnpointId, pokemon.Latitude,
  222. pokemon.Longitude, MiscEnums.Item.ITEM_POKE_BALL, pokemonCP);
  223. ; //note: reverted from settings because this should not be part of settings but part of logic
  224. } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed);
  225. string pokemonName;
  226. if (ClientSettings.Language == "german")
  227. {
  228. string name_english = Convert.ToString(pokemon.PokemonId);
  229. var request = (HttpWebRequest)WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" + name_english);
  230. var response = (HttpWebResponse)request.GetResponse();
  231. pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
  232. }
  233. else
  234. pokemonName = Convert.ToString(pokemon.PokemonId);
  235. if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
  236. {
  237. ColoredConsoleWrite(ConsoleColor.Green, $"[{DateTime.Now.ToString("HH:mm:ss")}] We caught a {pokemonName} with {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} CP");
  238. }
  239. else
  240. ColoredConsoleWrite(ConsoleColor.Red, $"[{DateTime.Now.ToString("HH:mm:ss")}] {pokemonName} with {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} CP got away..");
  241.  
  242. if (ClientSettings.TransferType == "leaveStrongest")
  243. await TransferAllButStrongestUnwantedPokemon(client);
  244. else if (ClientSettings.TransferType == "all")
  245. await TransferAllGivenPokemons(client, pokemons2);
  246. else if (ClientSettings.TransferType == "duplicate")
  247. await TransferDuplicatePokemon(client);
  248. else if (ClientSettings.TransferType == "cp")
  249. await TransferAllWeakPokemon(client, ClientSettings.TransferCPThreshold);
  250.  
  251. await Task.Delay(3000);
  252. }
  253. }
  254.  
  255. private static async Task ExecuteFarmingPokestopsAndPokemons(Client client)
  256. {
  257. var mapObjects = await client.GetMapObjects();
  258.  
  259. var pokeStops = mapObjects.MapCells.SelectMany(i => i.Forts).Where(i => i.Type == FortType.Checkpoint && i.CooldownCompleteTimestampMs < DateTime.UtcNow.ToUnixTime());
  260. int initCounter = 0;
  261. foreach (var pokeStop in pokeStops)
  262. {
  263. var update = await client.UpdatePlayerLocation(pokeStop.Latitude, pokeStop.Longitude);
  264. var fortInfo = await client.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
  265. var fortSearch = await client.SearchFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);
  266.  
  267. ColoredConsoleWrite(ConsoleColor.Cyan,
  268. $"[{DateTime.Now.ToString("HH:mm:ss")}] PokeStop XP: {fortSearch.ExperienceAwarded}, Gems: {fortSearch.GemsAwarded}, Eggs: {fortSearch.PokemonDataEgg} Items: {GetFriendlyItemsString(fortSearch.ItemsAwarded)}");
  269.  
  270. await Task.Delay(15000);
  271. await ExecuteCatchAllNearbyPokemons(client);
  272. initCounter++;
  273. if (initCounter >= 10)
  274. {
  275. initCounter = 0;
  276. if (POKEMONS != null && ClientSettings.EvolveAllGivenPokemons)
  277. await EvolveAllGivenPokemons(client, POKEMONS);
  278.  
  279. }
  280. }
  281. }
  282.  
  283. private static string GetFriendlyItemsString(IEnumerable<FortSearchResponse.Types.ItemAward> items)
  284. {
  285. var enumerable = items as IList<FortSearchResponse.Types.ItemAward> ?? items.ToList();
  286.  
  287. if (!enumerable.Any())
  288. return string.Empty;
  289.  
  290. return
  291. enumerable.GroupBy(i => i.ItemId)
  292. .Select(kvp => new { ItemName = kvp.Key.ToString(), Amount = kvp.Sum(x => x.ItemCount) })
  293. .Select(y => $"{y.Amount} x {y.ItemName}")
  294. .Aggregate((a, b) => $"{a}, {b}");
  295. }
  296.  
  297. private static void Main(string[] args)
  298. {
  299. Task.Run(() =>
  300. {
  301. try
  302. {
  303. //ColoredConsoleWrite(ConsoleColor.White, "Coded by Ferox - edited by NecronomiconCoding");
  304. //CheckVersion();
  305. Execute();
  306. }
  307. catch (PtcOfflineException)
  308. {
  309. ColoredConsoleWrite(ConsoleColor.Red, "PTC Servers are probably down OR your credentials are wrong. Try google");
  310. }
  311. catch (Exception ex)
  312. {
  313. ColoredConsoleWrite(ConsoleColor.Red, $"[{DateTime.Now.ToString("HH:mm:ss")}] Unhandled exception: {ex}");
  314. }
  315. });
  316. System.Console.ReadLine();
  317. }
  318.  
  319. private static async Task TransferAllButStrongestUnwantedPokemon(Client client)
  320. {
  321. //ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] Firing up the meat grinder");
  322.  
  323. var unwantedPokemonTypes = new[]
  324. {
  325. PokemonId.Pidgey,
  326. PokemonId.Rattata,
  327. PokemonId.Weedle,
  328. PokemonId.Zubat,
  329. PokemonId.Caterpie,
  330. PokemonId.Pidgeotto,
  331. PokemonId.NidoranFemale,
  332. PokemonId.Paras,
  333. PokemonId.Venonat,
  334. PokemonId.Psyduck,
  335. PokemonId.Poliwag,
  336. PokemonId.Slowpoke,
  337. PokemonId.Drowzee,
  338. PokemonId.Gastly,
  339. PokemonId.Goldeen,
  340. PokemonId.Staryu,
  341. PokemonId.Magikarp,
  342. PokemonId.Clefairy,
  343. PokemonId.Eevee,
  344. PokemonId.Tentacool,
  345. PokemonId.Dratini,
  346. PokemonId.Ekans,
  347. PokemonId.Jynx,
  348. PokemonId.Lickitung,
  349. PokemonId.Spearow,
  350. PokemonId.NidoranFemale,
  351. PokemonId.NidoranMale
  352. };
  353.  
  354. var inventory = await client.GetInventory();
  355. var pokemons = inventory.InventoryDelta.InventoryItems
  356. .Select(i => i.InventoryItemData?.Pokemon)
  357. .Where(p => p != null && p?.PokemonId > 0)
  358. .ToArray();
  359.  
  360. foreach (var unwantedPokemonType in unwantedPokemonTypes)
  361. {
  362. var pokemonOfDesiredType = pokemons.Where(p => p.PokemonId == unwantedPokemonType)
  363. .OrderByDescending(p => p.Cp)
  364. .ToList();
  365.  
  366. var unwantedPokemon =
  367. pokemonOfDesiredType.Skip(1) // keep the strongest one for potential battle-evolving
  368. .ToList();
  369.  
  370. //ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] Grinding {unwantedPokemon.Count} pokemons of type {unwantedPokemonType}");
  371. await TransferAllGivenPokemons(client, unwantedPokemon);
  372. }
  373.  
  374. //ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] Finished grinding all the meat");
  375. }
  376.  
  377. public static float Perfect(PokemonData poke)
  378. {
  379. return ((float)(poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina) / (3.0f * 15.0f)) * 100.0f;
  380. }
  381.  
  382. private static async Task TransferAllGivenPokemons(Client client, IEnumerable<PokemonData> unwantedPokemons, float keepPerfectPokemonLimit = 80.0f)
  383. {
  384. foreach (var pokemon in unwantedPokemons)
  385. {
  386. if (Perfect(pokemon) >= keepPerfectPokemonLimit) continue;
  387. ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] Pokemon {pokemon.PokemonId} with {pokemon.Cp} CP has IV percent less than {keepPerfectPokemonLimit}%");
  388. if (pokemon.Favorite > 0)
  389. {
  390. ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] Pokemon {pokemon.PokemonId} with {pokemon.Cp} CP is favorited, skipping transfer");
  391. continue;
  392. }
  393. var transferPokemonResponse = await client.TransferPokemon(pokemon.Id);
  394.  
  395. /*
  396. ReleasePokemonOutProto.Status {
  397. UNSET = 0;
  398. SUCCESS = 1;
  399. POKEMON_DEPLOYED = 2;
  400. FAILED = 3;
  401. ERROR_POKEMON_IS_EGG = 4;
  402. }*/
  403.  
  404. if (transferPokemonResponse.Status == 1)
  405. {
  406. ColoredConsoleWrite(ConsoleColor.Magenta, $"[{DateTime.Now.ToString("HH:mm:ss")}] Transferred {pokemon.PokemonId} with {pokemon.Cp} CP");
  407. }
  408. else
  409. {
  410. var status = transferPokemonResponse.Status;
  411.  
  412. ColoredConsoleWrite(ConsoleColor.Red, $"[{DateTime.Now.ToString("HH:mm:ss")}] Somehow failed to transfer {pokemon.PokemonId} with {pokemon.Cp} CP. " +
  413. $"ReleasePokemonOutProto.Status was {status}");
  414. }
  415.  
  416. await Task.Delay(3000);
  417. }
  418. }
  419.  
  420. private static async Task TransferDuplicatePokemon(Client client)
  421. {
  422. //ColoredConsoleWrite(ConsoleColor.White, $"Check for duplicates");
  423. var inventory = await client.GetInventory();
  424. var allpokemons =
  425. inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
  426. .Where(p => p != null && p.Cp < ClientSettings.TransferCPThreshold && p?.PokemonId > 0);
  427.  
  428. var dupes = allpokemons.OrderBy(x => x.Cp).Select((x, i) => new { index = i, value = x })
  429. .GroupBy(x => x.value.PokemonId)
  430. .Where(x => x.Skip(1).Any());
  431.  
  432. for (var i = 0; i < dupes.Count(); i++)
  433. {
  434. for (var j = 0; j < dupes.ElementAt(i).Count() - 1; j++)
  435. {
  436. var dubpokemon = dupes.ElementAt(i).ElementAt(j).value;
  437. var transfer = await client.TransferPokemon(dubpokemon.Id);
  438. ColoredConsoleWrite(ConsoleColor.DarkGreen,
  439. $"[{DateTime.Now.ToString("HH:mm:ss")}] Transferred {dubpokemon.PokemonId} with {dubpokemon.Cp} CP (Highest is {dupes.ElementAt(i).Last().value.Cp})");
  440. }
  441. }
  442. }
  443.  
  444. private static async Task TransferAllWeakPokemon(Client client, int cpThreshold)
  445. {
  446. //ColoredConsoleWrite(ConsoleColor.White, $"[{DateTime.Now.ToString("HH:mm:ss")}] Firing up the meat grinder");
  447.  
  448. var doNotTransfer = new[] //these will not be transferred even when below the CP threshold
  449. {
  450. //PokemonId.Pidgey,
  451. //PokemonId.Rattata,
  452. //PokemonId.Weedle,
  453. //PokemonId.Zubat,
  454. //PokemonId.Caterpie,
  455. //PokemonId.Pidgeotto,
  456. //PokemonId.NidoranFemale,
  457. //PokemonId.Paras,
  458. //PokemonId.Venonat,
  459. //PokemonId.Psyduck,
  460. //PokemonId.Poliwag,
  461. //PokemonId.Slowpoke,
  462. //PokemonId.Drowzee,
  463. //PokemonId.Gastly,
  464. //PokemonId.Goldeen,
  465. //PokemonId.Staryu,
  466. PokemonId.Magikarp,
  467. PokemonId.Eevee//,
  468. //PokemonId.Dratini
  469. };
  470.  
  471. var inventory = await client.GetInventory();
  472. var pokemons = inventory.InventoryDelta.InventoryItems
  473. .Select(i => i.InventoryItemData?.Pokemon)
  474. .Where(p => p != null && p?.PokemonId > 0)
  475. .ToArray();
  476.  
  477. //foreach (var unwantedPokemonType in unwantedPokemonTypes)
  478. {
  479. var pokemonToDiscard = pokemons.Where(p => !doNotTransfer.Contains(p.PokemonId) && p.Cp < cpThreshold)
  480. .OrderByDescending(p => p.Cp)
  481. .ToList();
  482.  
  483. //var unwantedPokemon = pokemonOfDesiredType.Skip(1) // keep the strongest one for potential battle-evolving
  484. // .ToList();
  485. ColoredConsoleWrite(ConsoleColor.Gray, $"[{DateTime.Now.ToString("HH:mm:ss")}] Grinding {pokemonToDiscard.Count} pokemon below {cpThreshold} CP.");
  486. await TransferAllGivenPokemons(client, pokemonToDiscard);
  487.  
  488. }
  489.  
  490. ColoredConsoleWrite(ConsoleColor.Gray, $"[{DateTime.Now.ToString("HH:mm:ss")}] Finished grinding all the meat");
  491. }
  492.  
  493. public static async Task PrintLevel(Client client)
  494. {
  495. var inventory = await client.GetInventory();
  496. var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PlayerStats).ToArray();
  497. foreach (var v in stats)
  498. if (v != null)
  499. {
  500. int XpDiff = GetXpDiff(client, v.Level);
  501. if (ClientSettings.LevelOutput == "time")
  502. ColoredConsoleWrite(ConsoleColor.Yellow, $"[{DateTime.Now.ToString("HH:mm:ss")}] Current Level: " + v.Level + " (" + (v.Experience - XpDiff) + "/" + (v.NextLevelXp - XpDiff) + ")");
  503. else if (ClientSettings.LevelOutput == "levelup")
  504. if (Currentlevel != v.Level)
  505. {
  506. Currentlevel = v.Level;
  507. ColoredConsoleWrite(ConsoleColor.Magenta, $"[{DateTime.Now.ToString("HH:mm:ss")}] Current Level: " + v.Level + ". XP needed for next Level: " + (v.NextLevelXp - v.Experience));
  508. }
  509. }
  510.  
  511. await Task.Delay(ClientSettings.LevelTimeInterval * 1000);
  512. PrintLevel(client);
  513. }
  514.  
  515. public static async Task ConsoleLevelTitle(string Username, Client client)
  516. {
  517. var inventory = await client.GetInventory();
  518. var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PlayerStats).ToArray();
  519. foreach (var v in stats)
  520. if (v != null)
  521. {
  522. int XpDiff = GetXpDiff(client, v.Level);
  523. System.Console.Title = string.Format(Username + " | Level {0:0} - ({1:0} / {2:0})", v.Level, (v.Experience - v.PrevLevelXp - XpDiff), (v.NextLevelXp - v.PrevLevelXp - XpDiff));
  524. }
  525. await Task.Delay(1000);
  526. ConsoleLevelTitle(Username, client);
  527. }
  528.  
  529. public static int GetXpDiff(Client client, int Level)
  530. {
  531. switch (Level)
  532. {
  533. case 1:
  534. return 0;
  535. case 2:
  536. return 1000;
  537. case 3:
  538. return 2000;
  539. case 4:
  540. return 3000;
  541. case 5:
  542. return 4000;
  543. case 6:
  544. return 5000;
  545. case 7:
  546. return 6000;
  547. case 8:
  548. return 7000;
  549. case 9:
  550. return 8000;
  551. case 10:
  552. return 9000;
  553. case 11:
  554. return 10000;
  555. case 12:
  556. return 10000;
  557. case 13:
  558. return 10000;
  559. case 14:
  560. return 10000;
  561. case 15:
  562. return 15000;
  563. case 16:
  564. return 20000;
  565. case 17:
  566. return 20000;
  567. case 18:
  568. return 20000;
  569. case 19:
  570. return 25000;
  571. case 20:
  572. return 25000;
  573. case 21:
  574. return 50000;
  575. case 22:
  576. return 75000;
  577. case 23:
  578. return 100000;
  579. case 24:
  580. return 125000;
  581. case 25:
  582. return 150000;
  583. case 26:
  584. return 190000;
  585. case 27:
  586. return 200000;
  587. case 28:
  588. return 250000;
  589. case 29:
  590. return 300000;
  591. case 30:
  592. return 350000;
  593. case 31:
  594. return 500000;
  595. case 32:
  596. return 500000;
  597. case 33:
  598. return 750000;
  599. case 34:
  600. return 1000000;
  601. case 35:
  602. return 1250000;
  603. case 36:
  604. return 1500000;
  605. case 37:
  606. return 2000000;
  607. case 38:
  608. return 2500000;
  609. case 39:
  610. return 1000000;
  611. case 40:
  612. return 1000000;
  613. }
  614. return 0;
  615. }
  616. }
  617. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement