Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. javascript:
  2. // Sophie "Shinko to kuma"
  3. //declaring variables
  4. var hours = 4;
  5. var scavengeInfo = JSON.parse($('html').find(
  6. 'script:contains("ScavengeScreen")').html().match(
  7. /\{.*\:\{.*\:.*\}\}/g)[0]);
  8. var duration_factor = scavengeInfo[1].duration_factor;
  9. var duration_exponent = scavengeInfo[1].duration_exponent;
  10. var duration_initial_seconds = scavengeInfo[1]
  11. .duration_initial_seconds;
  12. var lackadaisicalLooters = document.getElementsByClassName("title")[0]
  13. .innerHTML;
  14. var humbleHaulers = document.getElementsByClassName("title")[1]
  15. .innerHTML;
  16. var cleverCollectors = document.getElementsByClassName("title")[2]
  17. .innerHTML;
  18. var greatGatherers = document.getElementsByClassName("title")[3]
  19. .innerHTML;
  20.  
  21. //finding values
  22. spears = $('.units-entry-all[data-unit=spear]').text().match(
  23. /\((\d+)\)/)[1];
  24. swords = $('.units-entry-all[data-unit=sword]').text().match(
  25. /\((\d+)\)/)[1];
  26. axes = $('.units-entry-all[data-unit=axe]').text().match(/\((\d+)\)/)[
  27. 1];
  28. lightC = 0;
  29. heavyC = 0;
  30. if ($('.units-entry-all[data-unit=archer]').text() != "") {
  31. archer = $('.units-entry-all[data-unit=archer]').text().match(
  32. /\((\d+)\)/)[1]
  33. } else archer = 0;
  34.  
  35. if ($('.units-entry-all[data-unit=marcher]').text() != "") {
  36. marcher = $('.units-entry-all[data-unit=marcher]').text().match(
  37. /\((\d+)\)/)[1]
  38. } else marcher = 0;
  39.  
  40. totalLoot = spears * 25 + swords * 15 + axes * 10 + lightC * 80 +
  41. heavyC * 50 + archer * 10 + marcher * 50;
  42. totalSpSwLoot = spears * 25 + swords * 15;
  43. possibleLoot = spears * 25 + swords * 15 + axes * 10 + lightC * 80 +
  44. heavyC * 50 + archer * 10 + marcher * 50;
  45. spearRatio = spears / (spears * 25 + swords * 15);
  46. swordRatio = swords / (spears * 25 + swords * 15);
  47.  
  48. time = hours * 3600;
  49. haul = ((time / duration_factor - duration_initial_seconds) ** (1 / (
  50. duration_exponent)) / 100) ** (1 / 2);
  51. haul1 = haul / 0.1;
  52. haul2 = haul / 0.25;
  53. haul3 = haul / 0.5;
  54. haul4 = haul / 0.75;
  55. totalHaul = haul1 + haul2 + haul3 + haul4;
  56.  
  57. var scavengeOptions = {};
  58. scavengeOptions[greatGatherers] = [{
  59. type: 'spear',
  60. count: (haul4 * (spears / possibleLoot))
  61. },
  62. {
  63. type: 'sword',
  64. count: (haul4 * (swords / possibleLoot))
  65. },
  66. {
  67. type: 'axe',
  68. count: (haul4 * (axes / possibleLoot))
  69. },
  70. {
  71. type: 'light',
  72. count: (haul4 * (lightC / possibleLoot))
  73. },
  74. {
  75. type: 'heavy',
  76. count: (haul4 * (heavyC / possibleLoot))
  77. },
  78. {
  79. type: 'archer',
  80. count: (haul4 * (archer / possibleLoot))
  81. },
  82. {
  83. type: 'marcher',
  84. count: (haul4 * (marcher / possibleLoot))
  85. },
  86. ];
  87. scavengeOptions[cleverCollectors] = [{
  88. type: 'spear',
  89. count: (haul3 * (spears / possibleLoot))
  90. },
  91. {
  92. type: 'sword',
  93. count: (haul3 * (swords / possibleLoot))
  94. },
  95. {
  96. type: 'axe',
  97. count: (haul3 * (axes / possibleLoot))
  98. },
  99. {
  100. type: 'light',
  101. count: (haul3 * (lightC / possibleLoot))
  102. },
  103. {
  104. type: 'heavy',
  105. count: (haul3 * (heavyC / possibleLoot))
  106. },
  107. {
  108. type: 'archer',
  109. count: (haul3 * (archer / possibleLoot))
  110. },
  111. {
  112. type: 'marcher',
  113. count: (haul3 * (marcher / possibleLoot))
  114. },
  115. ];
  116. scavengeOptions[humbleHaulers] = [{
  117. type: 'spear',
  118. count: (haul2 * (spears / possibleLoot))
  119. },
  120. {
  121. type: 'sword',
  122. count: (haul2 * (swords / possibleLoot))
  123. },
  124. {
  125. type: 'axe',
  126. count: (haul2 * (axes / possibleLoot))
  127. },
  128. {
  129. type: 'light',
  130. count: (haul2 * (lightC / possibleLoot))
  131. },
  132. {
  133. type: 'heavy',
  134. count: (haul2 * (heavyC / possibleLoot))
  135. },
  136. {
  137. type: 'archer',
  138. count: (haul2 * (archer / possibleLoot))
  139. },
  140. {
  141. type: 'marcher',
  142. count: (haul2 * (marcher / possibleLoot))
  143. },
  144. ];
  145. scavengeOptions[lackadaisicalLooters] = [{
  146. type: 'spear',
  147. count: (haul1 * (spears / possibleLoot))
  148. },
  149. {
  150. type: 'sword',
  151. count: (haul1 * (swords / possibleLoot))
  152. },
  153. {
  154. type: 'axe',
  155. count: (haul1 * (axes / possibleLoot))
  156. },
  157. {
  158. type: 'light',
  159. count: (haul1 * (lightC / possibleLoot))
  160. },
  161. {
  162. type: 'heavy',
  163. count: (haul1 * (heavyC / possibleLoot))
  164. },
  165. {
  166. type: 'archer',
  167. count: (haul1 * (archer / possibleLoot))
  168. },
  169. {
  170. type: 'marcher',
  171. count: (haul1 * (marcher / possibleLoot))
  172. },
  173. ];
  174.  
  175.  
  176. var unitsCapacity = {
  177. 'spear': 25,
  178. 'sword': 15,
  179. 'archer': 10,
  180. 'axe': 10,
  181. 'heavy': 50,
  182. 'light': 80,
  183. 'marcher': 50,
  184. 'knight': 100
  185. }
  186.  
  187. run();
  188.  
  189. function run() {
  190. let btn = null;
  191. for (const option in scavengeOptions) {
  192. btn = findNextButton(option);
  193. if (btn) {
  194. fillInTroops(option, getAvailableUnits(), btn);
  195. break;
  196. }
  197. }
  198. }
  199.  
  200. function fillInTroops(option, availableUnits, button) {
  201. scavengeOptions[option].forEach(units => {
  202. const type = units.type;
  203. const count = units.count;
  204. let requiredCapacity = availableUnits[type] < count ?
  205. availableUnits[type] : count;
  206. $(`input.unitsInput[name='${type}']`).val(
  207. requiredCapacity).trigger("change");
  208. $(button).focus();
  209. });
  210. }
  211.  
  212. function findNextButton(option) {
  213. let btn = $(`.scavenge-option:contains("${option}")`).find(
  214. 'a:contains("Start")');
  215. if (btn.length > 0 && !$(btn).hasClass('btn-disabled'))
  216. return btn;
  217. }
  218.  
  219. function getAvailableUnits() {
  220. let availableUnits = {};
  221. $('.units-entry-all').each((i, e) => {
  222. const unitName = $(e).attr("data-unit");
  223. const count = $(e).text().replace(/[()]/, '');
  224. availableUnits[unitName] = parseInt(count);
  225. });
  226. return availableUnits;
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement