Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.17 KB | None | 0 0
  1. javascript:
  2.  
  3. var gd = game_data;
  4. var perc = 0.01;
  5. var v = gd.village;
  6. var u = {
  7. "spear": 1,
  8. "sword": 1,
  9. "axe": 1,
  10. "archer": 1,
  11. "spy": 2,
  12. "light": 4,
  13. "marcher": 5,
  14. "heavy": 6,
  15. "ram": 5,
  16. "catapult": 8,
  17. "knight": 10,
  18. "snob": 100
  19. }
  20. var left;
  21. try {
  22. if (document.URL.indexOf('try=confirm') != -1 && document.URL.indexOf('target=') == -1);
  23. else if (document.URL.indexOf('screen=place') == -1 || (document.URL.indexOf('mode') != -1 && document.URL.indexOf('mode=command') == -1)) {
  24. location = gd.link_base_pure + "place&mode=command";
  25. } else {
  26. if ($('.jump_link')[0] !== undefined) {
  27. location = $('#village_switch_right')[0].href;
  28. } else {
  29. var ul = $('.unit_link');
  30. for (var i = 0; i < ul.length; i++)
  31. $('#unit_input_' + $(ul[i]).attr('data-unit'))[0].value = "";
  32. var coords = "580|621 580|626 581|625 581|627 582|618 582|628 583|624 583|625 583|626 584|622 584|623 584|626 584|628 585|621 585|622 585|624 585|625 585|628 586|618 586|625 586|626 587|617 587|625 588|617 588|621 588|623 588|626 588|627 589|621 589|622 589|623 589|627 590|617 590|619 590|620 590|622 590|625 590|628 591|619 591|622 578|631 578|633 580|631 581|633 582|629 583|630 583|633 584|630 586|631 586|633 587|629 587|630 587|631 588|630 588|633 572|611 574|612 576|616 578|620 579|611 579|612 579|613 580|612 580|614 580|615 581|616 582|614 582|615 583|610 584|612 584|613 584|614 585|614 586|613 586|614 586|615 586|616 587|615 587|616 588|613 588|615 588|616 589|611 590|616 591|612 592|613 592|616 592|621 593|613 593|614 593|622 575|599 575|602 575|603 575|605 576|603 576|605 577|600 577|607 578|602 578|608 579|599 579|601 579|605 579|609 581|600 581|608 582|601 582|603 582|606 582|608 583|605 583|608 583|609 584|599 584|600 584|602 584|603 584|607 585|603 586|601 586|602 586|604 586|605 586|606 586|607 567|599 567|609 568|600 568|601 569|599 569|601 569|603 570|603 572|601 572|604 572|605 573|600 573|603 574|601 574|604 574|609 563|599 563|609 565|599 565|610 566|599 566|605 566|608 566|609 566|610 572|592 572|593 577|594 577|597 578|592 578|597 578|598 579|596 579|598 581|595 581|597 582|593 583|598 572|585 572|587 572|590 572|591 573|584 573|585 573|586 573|587 575|584 575|585 576|585 576|590 577|587 577|588 577|589 578|584 578|587 580|590 581|586 582|584 582|585 582|590 583|584 583|587 583|589 584|591 585|587 585|591 585|592 585|595 586|587 586|593 587|586 587|591 587|593 587|597 589|591 589|592 589|593 589|597 575|583 577|580 577|583 578|580 578|581 578|582 579|578 579|579 579|580 579|581 579|582 580|580 580|581 581|579 581|581 581|582 581|583 583|582 584|583 584|585 585|579 585|583 585|584 586|581 586|583 586|585 568|583 568|584 568|593 568|594 569|583 569|594 570|590 570|594 571|583 571|588 571|590 571|594 566|593 566|594 567|593 567|594 567|598 571|596 558|587 558|588 558|589 559|587 559|588 559|591 560|587 560|588 561|591 562|592 562|595 563|588 563|590 563|591 563|592 563|593 563|595 564|591 564|592 564|593 565|587 565|590 566|587 566|589 564|586 562|581 562|582 562|583 563|580 563|581 563|583 564|580 564|585 565|580 565|583 565|584 566|582 566|585 567|585 568|580 571|582 530|672 534|672 537|677 538|671 541|675 541|677 542|674 542|675 542|676 542|678 543|671 543|674 543|678 544|677 544|679 544|680 545|674 545|675 545|677 546|675 546|680 547|675 548|673 552|679 548|672 552|672 553|673 553|675 554|682 555|672 555|676 555|677 555|678 556|679 556|681 556|682 557|673 542|669 542|670 543|669 543|670 544|668 544|669 545|669 545|670 547|670 548|671 549|671 551|667 551|671 539|668 540|668 540|669 543|666 545|665 545|666 548|666 544|662 548|662 549|662 550|663 550|664 550|666 551|660 551|665 552|661 552|663 552|665 553|660 554|664 554|668 554|671 555|662 555|664 555|665 555|666 555|667 555|670 555|671 558|681 559|672 560|673 560|678 560|679 560|680 545|658 547|659 548|655 549|653 551|653 551|656 552|654 552|655 553|656 553|657 554|653 554|655 554|656 554|658 555|656 556|657 556|659 553|650 555|650 555|652 557|653 557|654 558|650 558|654 558|656 559|650 559|657 559|660 559|661 547|641 547|642 548|642 549|640 551|649 552|642 552|647 552|649 553|643 553|648 553|649 554|643 555|641 555|643 555|645 556|640 556|642 557|647 557|648 541|641 542|641 544|641 545|640 547|639 550|637 551|636 551|637 547|632 549|633 552|637 554|639 555|636 555|638 556|637 556|638 556|639 558|635 558|638 558|641 559|635 559|636 559|638 559|640 559|645 560|637 560|641 561|640 561|642 562|634 562|635 562|639 563|635 563|637 563|639 563|640 563|641 563|644 563|645 564|635 564|639 564|641 564|642 564|643 565|634 565|635 565|637 565|645 561|647 562|646 563|646 564|646 566|647 567|641 567|643 567|644 568|638 568|641 568|642 568|644 568|646 569|644 569|645 569|647 570|641 570|642 571|647 567|649 569|648 571|648 572|639 572|640 572|643 572|649 573|642 573|645 573|648 574|639 574|641 574|645 574|648 575|644 575|645 575|647 575|649 576|644 576|646 576|648 577|645 558|648 558|649 559|646 559|647 561|649 561|652 563|651 565|649 567|650 568|651 569|652 570|650 578|641 578|643 578|646 579|639 579|645 579|647 579|649 581|639 581|641 581|648 581|649 575|637 578|631 578|633 580|631 581|633 581|634 583|630 583|633 583|636 584|630 584|635 584|638 584|641 585|634 585|639 585|640 586|631 586|633 576|622 580|626 581|625 581|627 582|628 582|629 583|624 583|625 583|626 584|622 584|623 584|626 584|628 585|622 585|624 585|625 585|628 586|625 586|626".split(" ");
  33.  
  34. var selected = [];
  35. for (var i = 0; i < coords.length; ++i)
  36. if (isSelected(coords[i]))
  37. selected.push(coords[i]);
  38.  
  39. console.log(selected);
  40. if (selected.length != 0) {
  41. left = Math.floor(v.points * perc);
  42. var index = Math.round(Math.random() * (selected.length - 1));
  43. $(".target-input-field")[0].value = selected[index];
  44. /* CONFIG: wybA3r wojsk */
  45.  
  46.  
  47. units("ram", 1) || units("catapult", 1);
  48. fill("spy:5,axe:40,sword:90,light:15,spear:45,heavy:8,spear:90,heavy:15,spy:45,ram:1,catapult:1");
  49.  
  50. if (left > 0)
  51. UI.ErrorMessage('Za ma3a pula wojsk', 5000);
  52. } else {
  53. UI.ErrorMessage('Nie mo?na wybraa wioski', 5000);
  54. }
  55. }
  56. }
  57. } catch (err) {
  58. var message = "Wyst1pi3 nieoczekiwany b31d";
  59. console.log(err.message);
  60. UI.ErrorMessage(message, 5000);
  61. }
  62.  
  63. function isSelected(coords) {
  64. var days = ["16-16"];
  65. var intervals = ["7:00-12:59"];
  66. var distance = Math.hypot(coords.split("|")[0] - v.x, coords.split("|")[1] - v.y);
  67. var destination = new Date(distance * 1667000 + gd.time_generated);
  68.  
  69. var isInInterval = (intervals, value, predicate) => {
  70. for (var i = 0; i < intervals.length; i++)
  71. if (predicate(value, intervals[i]))
  72. return true;
  73. return false;
  74. };
  75. if (!isInInterval(days, destination, (v, i) => {
  76. v = v.getDate();
  77. i = i.split('-');
  78. return parseInt(i[0]) <= v && v <= parseInt(i[1]);
  79. })) return false;
  80. if (isInInterval(intervals, destination, (v, i) => {
  81. var parseTimer = timer => parseInt(timer[0]) * 60 + parseInt(timer[1]);
  82. v = parseTimer([v.getHours(), v.getMinutes()]);
  83. i = i.split("-");
  84. return 420 <= v && v <= 720;
  85. })) return true;
  86. return false;
  87. }
  88.  
  89. function tryUnits(name, value) {
  90. var mv = $('a#units_entry_all_' + name)[0].innerText.match(/\d+/)[0];
  91. var sv = $('#unit_input_' + name)[0].value;
  92. return mv - sv - value >= 0;
  93. }
  94.  
  95. function units(name, value) {
  96. var mv = $('a#units_entry_all_' + name)[0].innerText.match(/\d+/)[0];
  97. var sv = $('#unit_input_' + name)[0].value;
  98. sv = sv == "" ? 0 : parseInt(sv);
  99. mv -= sv;
  100. if (value > mv)
  101. value = mv;
  102. left -= u[name] * value;
  103. $('#unit_input_' + name)[0].value = sv + value;
  104. return value > 0;
  105. }
  106.  
  107. function fill(names) {
  108. if (left <= 0) return;
  109. names = names.split(',');
  110. var name, quantity;
  111. for (var i = 0; i < names.length; ++i) {
  112. name = names[i];
  113. quantity = NaN;
  114. if (name.indexOf(':') != -1) {
  115. quantity = parseInt(name.split(':')[1]);
  116. name = name.split(':')[0];
  117. }
  118. units(name, Math.ceil((isNaN(quantity) ? left : (quantity * u[name] >= left ? left : quantity * u[name])) / u[name]));
  119. if (left <= 0) return;
  120. }
  121. }
  122.  
  123. document.getElementById('target_attack').click()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement