Advertisement
Guest User

BKF

a guest
Jul 28th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. javascript: units = {
  2. 'spear': false,
  3. 'sword': false,
  4. 'axe': false,
  5. 'archer': false,
  6. 'spy': false,
  7. 'light': false,
  8. 'marcher': false,
  9. 'heavy': false,
  10. 'catapult': false,
  11. 'ram': 1,
  12. 'knight': false,
  13. 'snob': false,
  14. };
  15. coords = "567|384 571|387 567|389 569|389 568|394 568|397 570|397 572|401 573|401 572|402 574|401 574|399 569|411 574|411 570|412 571|411 573|415 577|422 576|423 579|422 578|420 577|430 582|432 584|431 581|427 584|431 589|440 593|440 594|444 598|441 598|442 599|428 598|427 599|424 599|418 595|422 588|446 588|449 589|447 591|447 591|450 595|455 596|455 598|454 597|460 599|457 612|464 601|466 601|467 602|462 602|463 602|476 600|477 602|479 593|482 610|481 607|487 626|470 640|472 631|480 602|452 603|453 603|452 603|450 603|447 605|447 604|455 606|454 607|453 606|456 607|458 607|459 608|461 608|463 608|468 610|468 611|470 608|425 606|416 580|408 581|408 582|406 578|411 578|408 578|405 577|406 576|410";
  16. name = "fakes";
  17. msg = {
  18. target: "Objetivo numero",
  19. total: "Total:",
  20. error: "Tropas insuficientes!",
  21. end: "Final de la lista!"
  22. };
  23. var b = document;
  24.  
  25. function e(a) {
  26. return b.getElementsByName(a)[0];
  27. }
  28.  
  29. function h(a) {
  30. return Number(UnitPopup.unit_data[a].pop);
  31. }
  32.  
  33. function k(a) {
  34. return Number(e(a).nextSibling.nextSibling.innerHTML.match(/\d+/));
  35. }
  36.  
  37. function n() {
  38. var a = p,
  39. t = q;
  40.  
  41. function D(a, d) {
  42. a.push("\n");
  43. for (var c = 0; c < a.length; c++) {
  44. if (0 < d) {
  45. if (a[c][1]) {
  46. k(a[c][0]) > a[c][1] ? (a[c][1] += 1, d -= h(a[c][0]), m += h(a[c][0]), insertUnit(e(a[c][0]), a[c][1])) : (a.splice(c, 1), c = -1);
  47. } else {
  48. if (1 == a.length) break;
  49. c = -1;
  50. }
  51. } else break;
  52. }
  53. 0 < d && (e(name).innerHTML = " " + msg.error, e(name).style.color = "red");
  54. }
  55. var v = [],
  56. m = t,
  57. f = [
  58. ["main", 10, [1.17, 5]],
  59. ["farm", 5, [1.172102, -240]],
  60. ["storage", 6, [1, 0]],
  61. ["place", 0, [1, 0]],
  62. ["barracks", 16, [1.17, 7]],
  63. ["church", 10, [1.55, 5E3]],
  64. ["church_f", 10, [1, 5]],
  65. ["smith", 19, [1.17, 20]],
  66. ["wood", 6, [1.155, 5]],
  67. ["stone", 6, [1.14, 10]],
  68. ["iron", 6, [1.17, 10]],
  69. ["market", 10, [1.17, 20]],
  70. ["stable", 20, [1.17, 8]],
  71. ["wall", 8, [1.17, 5]],
  72. ["garage", 24, [1.17, 8]],
  73. ["hide", 5, [1.17, 2]],
  74. ["snob", 512, [1.17, 80]],
  75. ["statue", 24, [1, 10]]
  76. ],
  77. a = a.reverse(),
  78. w = f.map(function (a) {
  79. return Number(game_data.village.buildings[a[0]]);
  80. }),
  81. f = f.map(function (a, d) {
  82. return 0 == w[d] ? 0 : Math.round(a[1] * Math.pow(1.2, w[d] - 1));
  83. }),
  84. f = Math.floor(function (a) {
  85. var d = 0;
  86. a.forEach(function (a) {
  87. d += a;
  88. });
  89. return d;
  90. }(f) / 100);
  91. if (!(0 > f - t)) {
  92. for (x = 0; a.length > x;) e(a[x]) && 1 > k(a[x]) ? a.splice(x, 1) : x++;
  93. for (var g = 0; g < a.length; g++) {
  94. var l = Math.ceil((f - t) / a.length / h(a[g])),
  95. l = l + Number(e(a[g]).value);
  96. l > k(a[g]) ? l = k(a[g]) : v.push([a[g], l]);
  97. m += h(a[g]) * l;
  98. insertUnit(e(a[g]), l);
  99. }
  100. f > m && D(v.reverse(), f - m);
  101. }
  102. }
  103. if (e("x") && "" == e("x").value) {
  104. e(name) || $("h3").append('<span name="' + name + '" style="color:green;font-size:11px;"></span>');
  105. var r = eval(String.fromCharCode(108, 111, 99, 97, 108, 83, 116, 111, 114, 97, 103, 101)),
  106. s = coords.split(" "),
  107. u = 0,
  108. p = [],
  109. q = 0,
  110. y = r[name];
  111. /^-?[\d.]+(?:e-?\d+)?$/.test(y) && (u = Number(y));
  112. e(name).innerHTML = " " + msg.target + " " + (u + 1) + " (" + s[u] + "). " + msg.total + " " + s.length;
  113. u >= s.length ? (u = 0, e(name).style.color = "red", e(name).innerHTML = " " + msg.end) : e(name).style.color = "green";
  114. e("x").value = s[u];
  115. u++;
  116. r[name] = u;
  117. for (var z in units) {
  118. if (e(z)) {
  119. var A = units[z],
  120. B = Number(A),
  121. C = k(z) + B;
  122. "boolean" == typeof A && A ? insertUnit(e(z), k(z)) : "boolean" != typeof A || A ? 0 > B ? 0 < C && insertUnit(e(z), C) : k(z) >= A && insertUnit(e(z), B) : p.push(z);
  123. q += e(z).value * h(z);
  124. }
  125. }
  126. 0 < p.length && n();
  127. }
  128. xProcess("inputx", "inputy");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement