Advertisement
Guest User

Untitled

a guest
Nov 24th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. javascript:
  2.  
  3. var runtimes = {
  4. 'off': 1,
  5. 'def': 1
  6. };
  7.  
  8. var units = {
  9. // Def
  10. 'spear': {'haul': 25, 'type': 'def'},
  11. 'sword': {'haul': 15, 'type': 'def'},
  12. 'archer': {'haul': 10, 'type': 'def'},
  13.  
  14. // ZC
  15. 'heavy': {'haul': 50, 'type': 'def'},
  16.  
  17. // Off
  18. 'axe': {'haul': 10, 'type': 'off'},
  19. 'light': {'haul': 80, 'type': 'off'},
  20. };
  21.  
  22. var $content = $('#scavenge_screen');
  23.  
  24. if ($content.length > 0) {
  25. var $btns = $content.find('.btn-default').not('.btn-disabled, .unlock-button');
  26. var haul = 0;
  27. var type = {'off': 0, 'def': 0};
  28.  
  29. for (var prop in units) {
  30. var amount = parseInt($content.find('.units-entry-all[data-unit="' + prop + '"]').text().match(/\d+/));
  31.  
  32. haul = haul + parseInt(amount * units[prop].haul);
  33. type[units[prop].type] = type[units[prop].type] + amount;
  34. }
  35.  
  36. if ($btns.length > 0 && haul > 0) {
  37. var $btn = $btns.last();
  38. var current = $btn.closest('.scavenge-option').find('.title').text().trim();
  39. var scavengeObject = JSON.parse($('html').find('script:contains("ScavengeScreen")').html().match(/\{.*\:\{.*\:.*\}\}/g)[1]);
  40. var scavengeIndex = {'Flegmatische Fielt': '1', 'Bescheiden Bandieten': '2', 'Slimme Speurders': '3', 'Reuze Rovers': '4'};
  41. var scavangeInfo = scavengeObject[scavengeIndex[current]];
  42. var troop_type = (type.off > type.def) ? 'off' : 'def';
  43. var runtime = runtimes[troop_type] * 60 * 60;
  44. var loot = Math.pow(Math.pow(((runtime / scavangeInfo.duration_factor) - scavangeInfo.duration_initial_seconds), (1 / scavangeInfo.duration_exponent)) / 100, 1/2) / scavangeInfo.loot_factor;
  45. var send = 0;
  46.  
  47. for (var prop in units) {
  48. var ui = $('.unitsInput[name="' + prop + '"]');
  49. var needed = Math.round(loot / units[prop].haul);
  50. var max = parseInt($content.find('.units-entry-all[data-unit="' + prop + '"]').text().match(/\d+/));
  51.  
  52. if (needed > max) {
  53. ui.val(max).trigger('change');
  54. loot = loot - (max * units[prop].haul);
  55. send = send + max;
  56. } else {
  57. ui.val(needed).trigger('change');
  58. send = send + needed;
  59. break;
  60. }
  61. }
  62.  
  63. if (send >= 10) {
  64. $btn.trigger('click');
  65. } else {
  66. $('.arrowRight, .groupRight').trigger('click');
  67. }
  68. } else {
  69. $('.arrowRight, .groupRight').trigger('click');
  70. }
  71. } else {
  72. location.href = game_data.link_base_pure + 'place&mode=scavenge';
  73. }
  74.  
  75. void(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement