Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. javascript: /* @name: Rooftochten @author: Warre @description: Stuur je rooftochten snel en slim */
  2.  
  3. /* Instellingen */
  4. // Maximale looptijd van de rooftochten voor elk soort dorp uitgedrukt in uren
  5. var runtimes = {
  6. 'off' : 4,
  7. 'def': 4
  8. };
  9.  
  10. // De eenheden die gebruikt mogen worden om te versturen met de nodige informatie (haul = hoe veel gs een eenheid kan dragen, type = off / def)
  11. var units = {
  12. 'sword': {'haul': 15, 'type': 'def'},
  13. 'spear': {'haul': 25, 'type': 'def'},
  14. 'axe': {'haul': 10, 'type': 'off'},
  15. 'archer': {'haul': 10, 'type': 'def'},
  16. 'heavy': {'haul': 50, 'type': 'def'},
  17. 'light': {'haul': 80, 'type': 'off'},
  18. 'marcher': {'haul': 50, 'type': 'off'}
  19. };
  20. /* Einde Instellingen */
  21.  
  22. var $content = $('#scavenge_screen');
  23. if ($content.length > 0) {
  24. var $btns = $content.find('.btn-default').not('.btn-disabled, .unlock-button');
  25. var haul = 0;
  26. var type = {'off': 0, 'def': 0};
  27.  
  28. for (var prop in units) {
  29. var amount = parseInt($content.find('.units-entry-all[data-unit="' + prop + '"]').text().match(/\d+/));
  30.  
  31. haul = haul + parseInt(amount * units[prop].haul);
  32. type[units[prop].type] = type[units[prop].type] + amount;
  33. }
  34.  
  35. if ($btns.length > 0 && haul > 0) {
  36. var $btn = $btns.last();
  37. var current = $btn.closest('.scavenge-option').find('.title').text().trim();
  38. var scavengeObject = JSON.parse($('html').find('script:contains("ScavengeScreen")').html().match(/\{.*\:\{.*\:.*\}\}/g)[0]);
  39. var scavengeIndex = {'Flegmatische Fielt': '1', 'Bescheiden Bandieten': '2', 'Slimme Speurders': '3', 'Reuze Rovers': '4'};
  40. var scavangeInfo = scavengeObject[scavengeIndex[current]];
  41. var troop_type = (type.off > type.def) ? 'off' : 'def';
  42. var runtime = runtimes[troop_type] * 60 * 60;
  43. var loot = Math.pow(Math.pow(((runtime / scavangeInfo.duration_factor) - scavangeInfo.duration_initial_seconds), (1 / scavangeInfo.duration_exponent)) / 100, 1/2) / scavangeInfo.loot_factor;
  44. var send = 0;
  45.  
  46. for (var prop in units) {
  47. var ui = $('.unitsInput[name="' + prop + '"]');
  48. var needed = Math.round(loot / units[prop].haul);
  49. var max = parseInt($content.find('.units-entry-all[data-unit="' + prop + '"]').text().match(/\d+/));
  50.  
  51. if (needed > max) {
  52. ui.val(max).trigger('change');
  53. loot = loot - (max * units[prop].haul);
  54. send = send + max;
  55. } else {
  56. ui.val(needed).trigger('change');
  57. send = send + needed;
  58. break;
  59. }
  60. }
  61.  
  62. if (send >= 10) {
  63. $btn.trigger('click');
  64. } else {
  65. $('.arrowRight, .groupRight').trigger('click');
  66. }
  67. } else {
  68. $('.arrowRight, .groupRight').trigger('click');
  69. }
  70. } else {
  71. location.href = game_data.link_base_pure + 'place&mode=scavenge';
  72. }
  73. void(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement