Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. #region
  2.  
  3. using System;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using PokemonGo.RocketAPI.GeneratedCode;
  7.  
  8. #endregion
  9.  
  10. namespace PokemonGo.RocketAPI.Logic.Utils
  11. {
  12. internal class Statistics
  13. {
  14. public static int TotalExperience;
  15. public static int TotalPokemons;
  16. public static int TotalItemsRemoved;
  17. public static int TotalPokemonsTransfered;
  18. public static int TotalStardust;
  19. public static string CurrentLevelInfos;
  20. public static int Currentlevel = -1;
  21. public static string PlayerName;
  22.  
  23. public static DateTime InitSessionDateTime = DateTime.Now;
  24. public static TimeSpan Duration = DateTime.Now - InitSessionDateTime;
  25.  
  26. public static async Task<string> _getcurrentLevelInfos(Inventory inventory)
  27. {
  28. var stats = await inventory.GetPlayerStats();
  29. var output = string.Empty;
  30. var stat = stats.FirstOrDefault();
  31. if (stat != null)
  32. {
  33. var ep = stat.NextLevelXp - stat.PrevLevelXp - (stat.Experience - stat.PrevLevelXp);
  34. var hours = Math.Round(ep/(TotalExperience/_getSessionRuntime()), 2);
  35.  
  36. output =
  37. $"{stat.Level} (next level in {hours}h | {stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level)}/{stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)} XP)";
  38. //output = $"{stat.Level} (LvLUp in {_hours}hours // EXP required: {_ep})";
  39. }
  40. return output;
  41. }
  42.  
  43. public void SetUsername(GetPlayerResponse profile)
  44. {
  45. PlayerName = profile.Profile.Username ?? "";
  46. }
  47. public static double _getSessionRuntime()
  48. {
  49. return (DateTime.Now - InitSessionDateTime).TotalSeconds/3600;
  50. }
  51.  
  52. public static string _getSessionRuntimeInTimeFormat()
  53. {
  54. return (DateTime.Now - InitSessionDateTime).ToString(@"dd\.hh\:mm\:ss");
  55. }
  56.  
  57. public void AddExperience(int xp)
  58. {
  59. TotalExperience += xp;
  60. }
  61.  
  62. public void AddItemsRemoved(int count)
  63. {
  64. TotalItemsRemoved += count;
  65. }
  66.  
  67. public void GetStardust(int stardust)
  68. {
  69. TotalStardust = stardust;
  70. }
  71.  
  72. public static int GetXpDiff(int level)
  73. {
  74. switch (level)
  75. {
  76. case 1:
  77. return 0;
  78. case 2:
  79. return 1000;
  80. case 3:
  81. return 2000;
  82. case 4:
  83. return 3000;
  84. case 5:
  85. return 4000;
  86. case 6:
  87. return 5000;
  88. case 7:
  89. return 6000;
  90. case 8:
  91. return 7000;
  92. case 9:
  93. return 8000;
  94. case 10:
  95. return 9000;
  96. case 11:
  97. return 10000;
  98. case 12:
  99. return 10000;
  100. case 13:
  101. return 10000;
  102. case 14:
  103. return 10000;
  104. case 15:
  105. return 15000;
  106. case 16:
  107. return 20000;
  108. case 17:
  109. return 20000;
  110. case 18:
  111. return 20000;
  112. case 19:
  113. return 25000;
  114. case 20:
  115. return 25000;
  116. case 21:
  117. return 50000;
  118. case 22:
  119. return 75000;
  120. case 23:
  121. return 100000;
  122. case 24:
  123. return 125000;
  124. case 25:
  125. return 150000;
  126. case 26:
  127. return 190000;
  128. case 27:
  129. return 200000;
  130. case 28:
  131. return 250000;
  132. case 29:
  133. return 300000;
  134. case 30:
  135. return 350000;
  136. case 31:
  137. return 500000;
  138. case 32:
  139. return 500000;
  140. case 33:
  141. return 750000;
  142. case 34:
  143. return 1000000;
  144. case 35:
  145. return 1250000;
  146. case 36:
  147. return 1500000;
  148. case 37:
  149. return 2000000;
  150. case 38:
  151. return 2500000;
  152. case 39:
  153. return 1000000;
  154. case 40:
  155. return 1000000;
  156. }
  157. return 0;
  158. }
  159.  
  160. public void IncreasePokemons()
  161. {
  162. TotalPokemons += 1;
  163. }
  164.  
  165. public void IncreasePokemonsTransfered()
  166. {
  167. TotalPokemonsTransfered += 1;
  168. }
  169.  
  170. public override string ToString()
  171. {
  172. return
  173. string.Format(
  174. "[{0}] | [{1:0} - {2}] | [EXP/H: {3:0}] [PKM/H: {4:0}] | +[{5}] XP | +[{6}] Pokémon | -[{7}] Pokémon (Transfer)]",
  175. _getSessionRuntimeInTimeFormat(), CurrentLevelInfos, PlayerName, TotalExperience / _getSessionRuntime(),
  176. TotalPokemons / _getSessionRuntime(), TotalExperience, TotalPokemons, TotalPokemonsTransfered);
  177. }
  178.  
  179. public async void UpdateConsoleTitle(Inventory inventory)
  180. {
  181. CurrentLevelInfos = await _getcurrentLevelInfos(inventory);
  182. Console.Title = ToString();
  183. }
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement