Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 67.06 KB | None | 0 0
  1. /*Global save of a file.*/
  2. /*jshint -W004 */
  3. var xmlConfig;
  4.  
  5. /*
  6. Changelog:
  7. 2018-08-11 2.0.1:
  8. - Fix typo in catapult calculation
  9. 2015-10-16 2.0:
  10. - Re-organised all the code.
  11. */
  12.  
  13. /*The standard data.*/
  14. var serverTimezones = {"en" : " GMT+0000", "zz" : " GMT+0100", "no" : " GMT+0100"};
  15. var resourceRates = [0, 30, 35, 41, 47, 55, 64, 74, 86, 100, 117, 136, 158, 184, 214, 249, 289, 337, 391, 455, 530, 616, 717, 833, 969, 1127, 1311, 1525, 1774, 2063, 2400];
  16. var warehouseCapacity = [0, 1000, 1229, 1512, 1859, 2285, 2810, 3454, 4247, 5222, 6420, 7893, 9705, 11932, 14670, 18037, 22177, 27266, 33523, 41217, 50675, 62305, 76604, 94184, 115798, 142373, 175047, 215219, 264611, 325337, 400000];
  17. var unitCarry = {"spear": 25, "sword": 15, "axe": 10, "archer": 10, "spy": 0, "light": 80, "marcher": 50, "heavy": 50, "ram": 0, "catapult": 0, "knight": 100};
  18. var unitSpeed = {"spear": 18, "sword": 22, "axe": 18, "archer": 18, "spy": 9, "light": 10, "marcher": 10, "heavy": 11, "ram": 30, "catapult": 30};
  19.  
  20. var speedGroups = [["spy", "light", "marcher", "heavy"], ["spear", "sword", "axe", "archer"], ["ram", "catapult"]];
  21. var slowestSpeedofGroups = [11, 22, 30];
  22.  
  23. var troopList = ["spear", "sword", "axe", "archer", "spy", "light", "marcher", "heavy", "ram", "catapult", "knight"]; /*Ignore snob*/
  24. var commonTroopNames = [["spearman", "spear"], ["swordman", "sword"], ["axeman", "axe"], ["scout", "spy"], ["lc", "light"], ["light cavalry", "light"], ["ma", "marcher"], ["mounted archer", "marcher"], ["heavy cavalry", "heavy"], ["hc", "heavy"], ["cat", "catapult"], ["paladin", "knight"]];
  25.  
  26. var ramsRequired = [0, 2, 4, 7, 10, 14, 19, 24, 30, 37, 45, 55, 65, 77, 91, 106, 124, 143, 166, 191, 219]; /* to break a wall at [i] level to 0.*/
  27. var ramsMin = [0, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6]; /*to break a wall at [i] level by 1 level*/
  28. var catsRequiredToBreak = [
  29. /*[0,30] = from 30 to 0*/
  30. /*From:[0,1,2, 3, 4, 5, 6, 7, 8, 9,10,11,12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]*/
  31. /*To:*/
  32. /* 0*/ [0,2,6,10,15,21,28,36,45,56,68,82,98,115,136,159,185,215,248,286,328,376,430,490,558,634,720,815,922,1041,1175],
  33. /* 1*/ [0,0,2, 6,11,17,23,31,39,49,61,74,89,106,126,148,173,202,234,270,312,358,410,469,534,508,691,784,888,1005,1135],
  34. /* 2*/ [0,0,0, 2, 7,12,18,25,33,43,54,66,81, 97,116,137,161,189,220,255,295,340,390,447,511,583,663,754,855, 968,1095],
  35. /* 3*/ [0,0,0, 0, 3, 7,13,20,27,36,47,59,72, 88,106,126,149,176,206,240,278,321,370,425,487,557,635,723,821, 932,1055],
  36. /* 4*/ [0,0,0, 0, 0, 3, 8,14,21,30,40,51,64, 79, 96,115,137,163,192,224,261,303,350,403,463,531,607,692,788, 895,1015],
  37. /* 5*/ [0,0,0, 0, 0, 0, 3, 9,15,23,32,43,55, 69, 86,104,126,150,177,209,244,285,330,382,440,505,579,661,754, 859, 976],
  38. /* 6*/ [0,0,0, 0, 0, 0, 0, 3, 9,17,25,35,47, 60, 76, 93,114,137,163,193,227,266,310,360,416,479,550,631,721, 822, 936],
  39. /* 7*/ [0,0,0, 0, 0, 0, 0, 0, 3,10,18,28,38, 51, 66, 82,102,124,149,178,211,248,290,338,392,453,522,600,687, 786, 896],
  40. /* 8*/ [0,0,0, 0, 0, 0, 0, 0, 0, 4,11,20,30, 42, 56, 72, 90,111,135,162,194,230,270,316,368,427,494,569,654, 749, 856],
  41. /* 9*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 4,12,22, 33, 46, 61, 78, 98,121,147,177,211,250,294,345,401,466,538,620, 713, 816],
  42. /*10*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 4,13, 23, 36, 50, 66, 85,107,132,160,193,230,273,321,376,438,508,587, 676, 777],
  43. /*11*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 14, 26, 39, 54, 72, 92,116,143,175,210,251,297,350,409,477,553, 640, 737],
  44. /*12*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 16, 28, 42, 59, 78,101,127,156,190,229,273,324,381,446,520, 603, 697],
  45. /*13*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 17, 30, 46, 64, 85,110,138,170,207,250,298,353,415,486, 567, 657],
  46. /*14*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 18, 33, 50, 70, 93,120,150,186,226,272,325,385,453, 530, 617],
  47. /*15*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 20, 36, 54, 76,101,130,164,202,246,297,354,419, 493, 578],
  48. /*16*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 22, 39, 59, 83,110,142,178,220,268,323,386, 457, 538],
  49. /*17*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 24, 43, 65, 90,120,155,195,240,292,352, 420, 498],
  50. /*18*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 26, 46, 70, 98,131,169,212,262,319, 384, 458],
  51. /*19*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 28, 50, 77,107,143,184,231,285, 347, 418],
  52. /*20*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 30, 55, 84,117,156,200,252, 311, 379],
  53. /*21*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 33, 60, 91,127,170,218, 274, 339],
  54. /*22*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 36, 65, 99,139,185, 238, 299],
  55. /*23*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 39, 71,108,151, 201, 259],
  56. /*24*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 43, 77,118, 165, 219],
  57. /*25*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 47, 84, 128, 180],
  58. /*26*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 51, 92, 140],
  59. /*27*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 55, 100],
  60. /*28*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 60],
  61. /*29*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20],
  62. /*30*/ [0,0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  63. ];
  64. var catsMin = [0,2,2,2,3,3,3,3,3,4,4,4,5,5,6,6,6,7,8,8,9,10,10,11,12,13,15,16,17,19,20]; /*to break a building at level [i] by 1*/
  65. var months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]; /*To get UTC-ize dates!*/
  66. var _a = { /*translations. Duh*/
  67. "en" : {
  68. "Headquarters" : "Headquarters",
  69. "Barracks" : "Barracks",
  70. "Stable" : "Stable",
  71. "Workshop" : "Workshop",
  72. "Church" : "Church",
  73. "First church" : "First church",
  74. "Academy" : "Academy",
  75. "Smithy" : "Smithy",
  76. "Rally point" : "Rally point",
  77. "Statue" : "Statue",
  78. "Market" : "Market",
  79. "Timber camp" : "Timber camp",
  80. "Clay pit" : "Clay pit",
  81. "Iron mine" : "Iron mine",
  82. "Farm" : "Farm",
  83. "Warehouse" : "Warehouse",
  84. "Hiding place" : "Hiding place",
  85. "Wall" : "Wall",
  86. "Please run this from the 'attacks' menu!" : "Please run this from the 'attacks' menu on the reports page (not all)!",
  87. "SAVED" : "SAVED",
  88. "Saved" : "Saved",
  89. "NOT SAVED" : "NOT SAVED (Village disabled?)",
  90. "Are you sure you've imported some reports?" : "Are you sure you've imported some reports?",
  91. "Changed" : "Changed",
  92. "Attack on" : "Attack on",
  93. "No villages left to attack! Either add more villages, or wait for the attacks to complete." : "No villages left to attack! Either add more villages, or wait for the attacks to complete.",
  94. "Add to farm list for " : "Add to farm list for ",
  95. "Enable farm for " : "Enable farm for ",
  96. "Disable farm for " : "Disable farm for ",
  97. "Added" : "Added",
  98. "Enabled" : "Enabled",
  99. "Disabled" : "Disabled",
  100. "Level" : "Level",
  101. "jan" : "Jan",
  102. "feb" : "Feb",
  103. "mar" : "Mar",
  104. "apr" : "Apr",
  105. "may" : "May",
  106. "jun" : "Jun",
  107. "jul" : "Jul",
  108. "aug" : "Aug",
  109. "sep" : "Sep",
  110. "oct" : "Oct",
  111. "nov" : "Nov",
  112. "dec" : "Dec",
  113. "Coordinates" : "Coordinates",
  114. "Tribe" : "Tribe",
  115. "Actions" : "Actions",
  116. "Defender" : "Defender"
  117. },
  118. "no" : {
  119. "Headquarters" : "Hovedkvarter",
  120. "Barracks" : "Brakker",
  121. "Stable" : "Stall",
  122. "Workshop" : "Verksted",
  123. "Church" : "Kirke",
  124. "First church" : "Første Kirke",
  125. "Academy" : "Akademi",
  126. "Smithy" : "Smie",
  127. "Rally point" : "Samlingsplass",
  128. "Statue" : "Statue",
  129. "Market" : "Marked",
  130. "Timber camp" : "Hogstfelt",
  131. "Clay pit" : "Leirgrav",
  132. "Iron mine" : "Jerngruve",
  133. "Farm" : "Gård",
  134. "Warehouse" : "Varehus",
  135. "Hiding place" : "Skjulested",
  136. "Wall" : "Mur",
  137. "Please run this from the 'attacks' menu!" : "Vennligst kjør dette scrtiptet fra 'angrep' menyen på rapport siden (ikke alle).",
  138. "SAVED" : "LAGRET",
  139. "Saved" : "Lagret",
  140. "NOT SAVED" : "IKKE LAGRET (Landsby deaktivert?)",
  141. "Are you sure you've imported some reports?" : "Er du sikker på at du har importert rapporter?",
  142. "Changed" : "Endret",
  143. "Attack on" : "Angrep på",
  144. "No villages left to attack! Either add more villages, or wait for the attacks to complete." : "Ingen flere byer igjen til å angripe! Vennligst legg til flere byer, eller vent til angrepene har truffet.",
  145. "Add to farm list for " : "Legg til i listen over farms for ",
  146. "Enable farm for " : "Aktiver farm for ",
  147. "Disable farm for " : "Deaktiver farm for ",
  148. "Added" : "Lagt til",
  149. "Enabled" : "Aktivert",
  150. "Disabled" : "Deaktivert",
  151. "Level" : "Nivå",
  152. "jan" : "Jan",
  153. "feb" : "Feb",
  154. "mar" : "Mar",
  155. "apr" : "Apr",
  156. "may" : "Mai",
  157. "jun" : "Juni",
  158. "jul" : "Juli",
  159. "aug" : "Aug",
  160. "sep" : "Sep",
  161. "oct" : "Okt",
  162. "nov" : "Nov",
  163. "dec" : "Des",
  164. "Coordinates" : "Koordinater",
  165. "Tribe" : "Stamme",
  166. "Actions" : "Handlinger",
  167. "Defender" : "Forsvarer"
  168. }
  169. };
  170.  
  171. /*The two letter acronym (typically) for the world. e.g. en, zz, no, de.*/
  172. var worldLetters = window.location.host.split(/\W+/)[0].substring(0, 2);
  173.  
  174. /*Temporary local copy.*/
  175. var settings;
  176.  
  177. /*Fetch local storage*/
  178. function getLocalStorage() {
  179. if (!localStorage){ alert("Local storage doesn't seem to be enabled. NAFS won't function without it!"); throw "Whoops. Local storage isn't enabled, apparently."; }
  180. if (!localStorage.NAFSData) localStorage.NAFSData = '{"villages":{}, "settings":{}}';
  181. if (typeof settings === "undefined") settings = JSON.parse(localStorage.NAFSData);
  182. return settings;
  183. }
  184.  
  185. /*Save local storage*/
  186. function setLocalStorage(data){
  187. if (typeof data === "undefined") data = settings;
  188. localStorage.NAFSData = JSON.stringify(data);
  189. }
  190.  
  191. /*Fetch the language from the localStorage settings.*/
  192. function getCurrentLang() {
  193. return getSetting("lang", _a[worldLetters] && worldLetters || "en");
  194. /*Return the "lang" setting, or else if there's a translation for the current world's code, return that, or else "en".*/
  195. }
  196.  
  197. /*Return the localised version.*/
  198. function _(translateID){
  199. return (typeof _a[getCurrentLang()] !== "undefined" && _a[getCurrentLang()][translateID]) || translateID;
  200. /*If there are translations for the current language, and there exists a translation for this thing, use that. Else, return the translation's ID.*/
  201. }
  202.  
  203. /*HQ (1), Barracks (0), Stable (0), Workshop (0), Church (0), Academy (0), Smithy (0), Rally Point (0), Statue (0), Market (0), Timber Camp (leave), Clay Pit (leave), Iron Mine (leave), Farm (1), Warehouse (leave), Hiding Place (impossible), Wall (0)*/
  204. var catables = [
  205. {"name" : _("Farm"), "lowest" : (getSetting("catFarmToZero", false) ? 1 : 12), "id" : "farm"},
  206. {"name" : _("Headquarters"), "lowest" : 1, "id" : "main"},
  207. {"name" : _("Barracks"), "lowest" : 0, "id" : "barracks"},
  208. {"name" : _("Stable"), "lowest" : 0, "id" : "stable"},
  209. {"name" : _("Workshop"), "lowest" : 0, "id" : "garage"},
  210. {"name" : _("Academy"), "lowest" : 0, "id" : "snob"},
  211. {"name" : _("Smithy"), "lowest" : 0, "id" : "smith"},
  212. {"name" : _("Rally point"), "lowest" : 0, "id" : "place"},
  213. {"name" : _("Statue"), "lowest" : 0, "id" : "statue"},
  214. {"name" : _("Market"), "lowest" : 0, "id" : "market"}
  215. ];
  216.  
  217. var buildingList = ["barracks", "rally", "stable", "garage", "snob", "smith", "statue", "market", "main", "farm", "wall"];
  218.  
  219. function getQuery(name) {
  220. name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  221. var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  222. results = regex.exec(location.search);
  223. return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  224. }
  225.  
  226. function getQueryFromHaystack(haystack, name){
  227. name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  228. var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  229. results = regex.exec(haystack);
  230. return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  231. }
  232.  
  233. function getXML() {
  234. if (typeof xmlConfig === "undefined"){
  235. if (window.XMLHttpRequest){
  236. xmlhttp = new XMLHttpRequest();
  237. } else {
  238. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  239. }
  240. xmlhttp.open("GET", window.location.protocol + "//" + window.location.host + "/interface.php?func=get_config", false);
  241. xmlhttp.send();
  242. xmlConfig = xmlhttp.responseXML;
  243. }
  244. return xmlConfig;
  245. }
  246.  
  247. function getWorldSpeed() {
  248. return parseFloat(getXML().getElementsByTagName("speed")[0].childNodes[0].nodeValue);
  249. }
  250.  
  251. function getUnitSpeed() {
  252. return parseFloat(getXML().getElementsByTagName("unit_speed")[0].childNodes[0].nodeValue);
  253. }
  254.  
  255. function getLocalCoords() {
  256. var temp = $("#menu_row2 b.nowrap").text();
  257. temp = splitOutCoords(temp, true);
  258. temp = temp.split("|").length > 1 && temp.split("|");
  259. /*Split "VillName (XXX|YYY) into ("XXX","YYY")*/
  260. return temp;
  261. }
  262.  
  263. function getLocalName() {
  264. return $("#menu_row2 a.nowrap").text().trim();
  265. }
  266.  
  267. /*Fetch a setting from the localStorage*/
  268. function getSetting(name, def){
  269. var nafsData = getLocalStorage();
  270. if (typeof nafsData.settings !== "undefined" && typeof nafsData.settings[name] !== "undefined") {
  271. var tempData = nafsData.settings[name];
  272. if (tempData === "true") tempData = true;
  273. if (tempData === "false") tempData = false;
  274. return tempData;
  275. } /*If settings exist, and setting exists, return it (slightly modified).*/
  276. return def; /*Else, return default.*/
  277. }
  278.  
  279. /*Save a setting to the localStorage*/
  280. function setSetting(name, val){
  281. var nafsData = getLocalStorage();
  282. if (typeof nafsData.settings === "undefined") nafsData.settings = {};
  283.  
  284. if (val === "true") val = true;
  285. if (val === "false") val = false;
  286.  
  287. nafsData.settings[name] = val;
  288. setLocalStorage(nafsData);
  289.  
  290. return true;
  291. }
  292.  
  293. function objectifySetting(settingValues, settingKeys) {
  294. var nafsData = getLocalStorage();
  295. if (!nafsData.settings) nafsData.settings = {};
  296. var settingName;
  297.  
  298. if (typeof settingValues === "string") {
  299. settingName = settingValues;
  300. settingValues = nafsData.settings[settingValues];
  301. }
  302. if (typeof settingValues === "undefined") return false;
  303.  
  304. if (typeof settingKeys === "undefined") settingKeys = nafsData.settings[settingName + "Key"];
  305. else if (typeof settingKeys === "string") {
  306. var settingKeyName = settingKeys;
  307. settingKeys = nafsData.settings[settingKeys];
  308. }
  309.  
  310. if (typeof settingKeys === "undefined") return false;
  311.  
  312. if (typeof settingKeys === "string") settingKeys = settingKeys.split(",");
  313. if (typeof settingValues === "string") settingValues = settingValues.split(",");
  314.  
  315. var settingsObject = {};
  316. for (var settingKeyIndex in settingKeys) {
  317. settingsObject[settingKeys[settingKeyIndex]] = settingValues[settingKeyIndex];
  318. }
  319.  
  320. return settingsObject;
  321. }
  322.  
  323. function objectifyTroopSettings(settingValues, settingKeys) {
  324. var objectedSettings = objectifySetting(settingValues, settingKeys);
  325. for (var settingKey in objectedSettings){
  326. objectedSettings[settingKey] = parseInt(objectedSettings[settingKey]);
  327. if (fixTroopName(settingKey) && fixTroopName(settingKey) !== settingKey) {
  328. objectedSettings[fixTroopName(settingKey)] = parseInt(objectedSettings[settingKey]);
  329. delete objectedSettings[settingKey];
  330. }
  331. }
  332. return objectedSettings;
  333. }
  334.  
  335. function changeConfig() {
  336. /*
  337. Config Data:
  338. {rescout {minScout, hoursToRescout, hoursToStale}, farm {minFarmTroops (,), maxFarmTroops (,), leaveFarmTroops (,)}, shape {catapult {catFarmToZero}, [catapultWalls, ram] {minWallLevel}, minShapeTroops (,), maxShapeTroops (,), leaveShapeTroops (,)}, playerImport}
  339. */
  340. function clearDisabledFarms(coords) {
  341. var nafsData = getLocalStorage();
  342.  
  343. if (typeof coords === "undefined") {
  344. for (var villageIndex in nafsData.villages) {
  345. if (villageIndex.indexOf("|") !== -1) {
  346. clearDisabledFarms(villageIndex);
  347. }
  348. }
  349. } else {
  350. if (coords.indexOf("|") !== -1 && typeof nafsData.villages[coords] !== "undefined") {
  351. var village = nafsData.villages[coords];
  352. for (var i=0; i < village.length; i++){
  353. if (village[i].disabled) {
  354. village.splice(i, 1);
  355. i--;
  356. }
  357. }
  358. nafsData.villages[coords] = village;
  359. }
  360. }
  361.  
  362. setLocalStorage(nafsData);
  363. }
  364.  
  365. alert("We will now change the settings of this farming script! Please do not CANCEL, nor type in random stuff, as you will have to redo this!");
  366.  
  367. setSetting("rescout", prompt("Should we re-scout farms with old/stale reports? (If you disable this, automatic values will likely be wrong!) (true/false)", getSetting("rescout", true)) == "true");
  368.  
  369. if (getSetting("rescout", true) === true) setSetting("minScout", parseInt(prompt("How many scouts to send at a minimum per attack?", getSetting("minScout", 1))));
  370.  
  371. if (getSetting("rescout", true) === true) setSetting("hoursToRescout", parseInt(prompt("How many hours until a report 'expires' and may no longer be used for data? You will want to adjust this based on the world speed.", getSetting("hoursToRescout", 36))));
  372.  
  373. if (getSetting("rescout", true) === true) setSetting("hoursToStale", parseInt(prompt("How many hours until a report becomes 'stale' and /may/ be rescouted? You will want to adjust this based on the world speed.", getSetting("hoursToStale", 10))));
  374.  
  375. setSetting("farm", prompt("Should we farm villages? (true/false)", getSetting("farm", true)) == "true");
  376.  
  377. if (getSetting("farm", true) === true) {
  378. setSetting("minFarmTroops", prompt("If the troop is used, how many of each troop should be sent at a minimum per farming attack? (spear, sword, axe, archer, lc, ma, hc, paladin - separate by commas, no spaces)", getSetting("minFarmTroops", "0,0,0,0,5,0,0,0")));
  379. setSetting("minFarmTroopsKey", "spear,sword,axe,archer,lc,ma,hc,paladin");
  380.  
  381. setSetting("maxFarmTroops", prompt("If the troop is used, how many of each troop should be sent at a maximum per farming attack? (spear, sword, axe, archer, lc, ma, hc, paladin - separate by commas, no spaces; -1 means no limit, 0 disables the troop)", getSetting("maxFarmTroops", "0,0,0,0,-1,0,0,0")));
  382. setSetting("maxFarmTroopsKey", "spear,sword,axe,archer,lc,ma,hc,paladin");
  383.  
  384. setSetting("leaveFarmTroops", prompt("How many troops to leave, at a minimum, within the village? (spear, sword, axe, archer, scout, lc, ma, hc, paladin - separate by commas, no spaces)", getSetting("leaveFarmTroops", "0,0,0,0,0,0,0,0,0")));
  385. setSetting("leaveFarmTroopsKey", "spear,sword,axe,archer,scout,lc,ma,hc,paladin");
  386. }
  387.  
  388. setSetting("shape", prompt("Should we knock down walls and/or shape villages?", getSetting("shape", true)) == "true");
  389.  
  390. if (getSetting("shape", true) === true) {
  391. setSetting("catapult", prompt("Should we use catapults to shape villages? (true/false)", getSetting("catapult", true)) == "true");
  392.  
  393. if (getSetting("catapult", true) === true)
  394. setSetting("catFarmToZero", prompt("Should we catapult farms to zero? (Otherwise about level 12 - true/false)", getSetting("catFarmToZero", false)) == "true");
  395.  
  396. setSetting("catapultWalls", prompt("Should we use catapults to knock down walls (after rams)? (true/false)", getSetting("catapultWalls", true)) == "true");
  397.  
  398. setSetting("ram", prompt("Should we use rams to knock down farm walls? (true/false)", getSetting("ram", true)) == "true");
  399.  
  400. if (getSetting("catapultWalls", true) || getSetting("ram", true)) setSetting("minWallLevel", parseInt(prompt("What should the minimum wall level required to send rams (or catapults, if applicable) be?", getSetting("minWallLevel", 1))));
  401. }
  402.  
  403. if (getSetting("shape", true) === true && (getSetting("catapult", true) === true || getSetting("ram", true) === true)){
  404. setSetting("minShapeTroops", prompt("If the troop is used, how many of each should be sent at a minimum per shaping attack? (spear, sword, axe, archer, lc, ma, hc, ram, catapult, paladin - separate by commas, no spaces)", getSetting("minShapeTroops", "50,50,50,50,0,0,0,2,2,0")));
  405. setSetting("minShapeTroopsKey", "spear,sword,axe,archer,lc,ma,hc,ram,catapult,paladin");
  406.  
  407. setSetting("maxShapeTroops", prompt("If the troop is used, how many of each should be sent at a maximum per shaping attack? (spear, sword, axe, archer, lc, ma, hc, ram, catapult, paladin - separate by commas, no spaces; -1 means no limit, 0 disables the troop)", getSetting("maxShapeTroops", "100,100,100,100,0,0,0,-1,-1,0")));
  408. setSetting("maxShapeTroopsKey", "spear,sword,axe,archer,lc,ma,hc,ram,catapult,paladin");
  409.  
  410. setSetting("leaveShapeTroops", prompt("How many troops to leave, at a minimum, within the village after shaping attacks? (spear, sword, axe, archer, scout, lc, ma, hc, ram, catapult, paladin - separate by commas, no spaces)", getSetting("leaveShapeTroops", "50,50,50,50,5,0,0,0,0,0,0")));
  411. setSetting("leaveShapeTroopsKey", "spear,sword,axe,archer,scout,lc,ma,ha,ram,catapult,paladin");
  412. }
  413.  
  414. setSetting("playerImport", prompt("Should we import reports with players as the defenders? (true/false)", getSetting("playerImport", true)) == "true");
  415.  
  416. if (prompt("Clear disabled villages from the farm list? (true/false)", "false") == "true") clearDisabledFarms();
  417. }
  418.  
  419. function addReport(reportID, localCoords, vilCoords, wood, clay, iron, battleTime, buildings){
  420. if (typeof vilCoords === "object") vilCoords = vilCoords[0] + "|" + vilCoords[1];
  421. if (typeof localCoords === "object") localCoords = localCoords[0] + "|" + localCoords[1];
  422. var nafsData = getLocalStorage();
  423. if (!nafsData.villages) nafsData.villages = {};
  424. if (!nafsData.villages[localCoords]) nafsData.villages[localCoords] = [];
  425.  
  426.  
  427. var vilIndex;
  428. nafsData.villages[localCoords].forEach(function(element, index) {
  429. if (element.coords === vilCoords) vilIndex = index;
  430. });
  431.  
  432. if (typeof vilIndex === "undefined"){
  433. vilIndex = nafsData.villages[localCoords].push({
  434. coords: vilCoords,
  435. disabled: false,
  436. distance: (Math.floor(Math.sqrt(Math.pow(parseInt(vilCoords.split("|")[0])-localCoords.split("|")[0],2)+Math.pow(parseInt(vilCoords.split("|")[1])-localCoords.split("|")[1],2))*100)/100),
  437. reports: [ ]
  438. });
  439. nafsData.villages[localCoords].sort(function(a, b){
  440. return a.distance - b.distance;
  441. });
  442. nafsData.villages[localCoords].forEach(function(element, index) {
  443. if (element.coords === vilCoords) vilIndex = index;
  444. });
  445. }
  446.  
  447. if (typeof vilIndex === "undefined"){
  448. /*Something has gone wrong! Not there even after we created it!*/
  449. throw "Something has gone seriously wrong. Pushing an item to an array didn't result in said item being in said array. Since when? Broken Javascript?";
  450. }
  451.  
  452. if (nafsData.villages[localCoords][vilIndex].disabled){
  453. return "Disabled";
  454. }
  455.  
  456. buildingList.forEach(function(element, index){
  457. if (typeof buildings[element] === "undefined") buildings[element] = 0;
  458. });
  459.  
  460. battleTime = Number(battleTime);
  461. var reportIndex = false;
  462. nafsData.villages[localCoords][vilIndex].reports.forEach(function(element, index) {
  463. if (element.reportID === reportID) reportIndex = index;
  464. });
  465.  
  466. if (reportIndex) return "Report already imported.";
  467.  
  468. nafsData.villages[localCoords][vilIndex].reports.push({
  469. "reportID" : reportID,
  470. "battleTime" : battleTime,
  471. "wood" : wood,
  472. "clay" : clay,
  473. "iron" : iron,
  474. "buildings" : buildings
  475. });
  476.  
  477. nafsData.villages[localCoords][vilIndex].reports.sort(function(a, b) {
  478. return b.battleTime - a.battleTime;
  479. });
  480.  
  481. /*If we have more than one report in the list, delete the others. (o.e?)*/
  482. while (nafsData.villages[localCoords][vilIndex].reports.length > 1) {
  483. nafsData.villages[localCoords][vilIndex].reports.pop();
  484. }
  485.  
  486. setLocalStorage(nafsData);
  487. return true;
  488. }
  489.  
  490. function fixTroopName(troopName) {
  491. troopName = troopName.toLowerCase().trim();
  492. for (var troopNameID in commonTroopNames){
  493. if (troopName.indexOf(commonTroopNames[troopNameID][0].toLowerCase().trim()) !== -1) {
  494. troopName = commonTroopNames[troopNameID][1];
  495. }
  496. }
  497. return troopName;
  498. }
  499.  
  500. function getMaxTroops() {
  501. if (getQuery("screen") !== "place"){
  502. console.log("Wrong screen. Should be at rally point.");
  503. return "Wrong screen.";
  504. }
  505.  
  506. var troopCounts = {};
  507. for (var troopID in troopList) {
  508. var troopInput = $("#unit_input_" + troopList[troopID]);
  509. if (troopInput.length > 0) {
  510. var parentText = troopInput.parent().text();
  511. var meaningful = false;
  512. if (parentText.split("(").length > 1){
  513. parentText = parentText.split("(")[1];
  514. if (parentText.split(")").length > 1) {
  515. parentText = parentText.split(")")[0];
  516. if (parseInt(parentText).toString() == parentText){
  517. troopCounts[troopList[troopID]] = parseInt(parentText);
  518. meaningful = true;
  519. }
  520. }
  521. }
  522. if (!meaningful){
  523. console.log("Something seems to be wrong with the max number of " + troopList[troopID] + ".");
  524. }
  525. }
  526. }
  527. return troopCounts;
  528. }
  529.  
  530. function getMaxTroop(troopName) {
  531. return getMaxTroops()[fixTroopName(troopName)];
  532. }
  533.  
  534. function errorBox(msg){
  535. if (getQuery("screen") === "place" && ($("#units_form").length > 0 || $("#command-data-form").length > 0)) {
  536. /*Regular rally page.*/
  537. if ($("#nafserror").length > 0) {
  538. $("#nafserror").text($("#nafserror").text() + "\n" + msg);
  539. } else {
  540. var errorBo = $("<span id='nafserror'></span>").css("color", "#F00");
  541. errorBo.text(msg);
  542. $($("#units_form table, #command-data-form table").get(0)).before(errorBo);
  543. }
  544. } else if (getQuery("screen") === "report" && getQuery("view") === "") {
  545. var warning = ($("#nafswarning").length > 0 ? $("#nafswarning") : $("<span id='nafswarning'>")).css({"color":"#F00","font-weight":"bold"}).text(msg);
  546. $("#report_list").before(warning);
  547. }
  548. }
  549.  
  550. function splitOutCoords(str, num, removeBrackets){
  551. str = str.trim();
  552. if (typeof num === "boolean"){
  553. if (typeof removeBrackets === "undefined") {
  554. removeBrackets = num;
  555. num = undefined;
  556. } else if (typeof removeBrackets === "number"){
  557. temp = removeBrackets;
  558. removeBrackets = num;
  559. num = temp;
  560. }
  561. }
  562. if (typeof num === "undefined") num = 1;
  563.  
  564. if (typeof removeBrackets === "undefined") removeBrackets = false;
  565. num = parseInt(num);
  566.  
  567. var results = str.match(/\((\d{2}|\d{3})\|(\d{2}|\d{3})\)/g);
  568. if (typeof results !== "object") return false;
  569.  
  570. var index = num > 0 ? num-1 : num === 0 ? 0 : results.length+num;
  571. if (0 <= index && index < results.length)
  572. return removeBrackets ? results[index].split("(")[1].split(")")[0] : results[index];
  573. else return false;
  574. }
  575.  
  576. function insertTroops(troops) {
  577. $("[id*='unit_input_']").val("");
  578. for (var troop in troops) {
  579. var troopName = "";
  580. for (var troopID in troopList) {
  581. if (fixTroopName(troop) === troopList[troopID]) {
  582. troopName = troopList[troopID];
  583. }
  584. }
  585. $("#unit_input_" + troopName).val(troops[troop]);
  586. }
  587. }
  588.  
  589. function targetVil(vilCoords){
  590. if (vilCoords.indexOf(")") !== -1) vilCoords = vilCoords.match(/(\d{2}|\d{3})\|(\d{2}|\d{3})/g)[0];
  591. $("#inputx").val(vilCoords.split("|")[0]);
  592. $("#inputy").val(vilCoords.split("|")[1]);
  593. $("#unit_input_spear").focus();
  594. }
  595.  
  596. function def() {
  597. var nafsData = getLocalStorage();
  598. var localCoords = getLocalCoords();
  599. var localData = nafsData.villages[localCoords] || nafsData.villages[localCoords[0] + "|" + localCoords[1]];
  600.  
  601. /*Assume we're not gonna try AJAX-ing a report list page. It probably wouldn't be sensible, if the user wants any feedback.*/
  602. if (getQuery("screen") === "report"){
  603. if (getQuery("view") === "" && getQuery("mode") === "attack") {
  604.  
  605. let fetch = i => {
  606. let index = i
  607. let element = $("#report_list tr:has(td) .quickedit-content").eq(i)
  608. if (!element) return;
  609. var reportURL = element.find("a")
  610. if (reportURL.length < 1) {
  611. /*This report has no URL. Woo?*/
  612. element.innerHTML += " - no report URL";
  613. } else {
  614. reportURL = reportURL.attr("href");
  615. console.log(reportURL)
  616. var reportElement = element.get(0);
  617.  
  618. var ajx = jQuery.ajax(reportURL,
  619. {type: "GET",
  620. dataType: "html",
  621. async: true,
  622. error: function(jqXHR, textStatus, errorThrown) {
  623. reportElement.innerHTML += " - report failed to load (see console for more info)";
  624. console.log("Report failed to load via AJAX. Status: " + textStatus + "; error: " + errorThrown);
  625. },
  626. success: function(responseData, textStatus, jqXHR) {
  627. var fakeDOM = $("<div>");
  628. fakeDOM.get(0).class = "NAFSReportDOM";
  629. fakeDOM.html(responseData);
  630.  
  631. var progressReport = processReport(fakeDOM, getQueryFromHaystack(reportURL, "view"));
  632.  
  633. if (progressReport === true) {
  634. reportElement.innerHTML += " - " + _("Saved");
  635.  
  636. var reportCheckbox = $("input[type='checkbox']", $(reportElement).parents("#report_list tr"));
  637. if (reportCheckbox.length === 1) {
  638. reportCheckbox.prop("checked", true);
  639. } else {
  640. console.log("Couldn't check box of element " + index);
  641. }
  642. } else {
  643. reportElement.innerHTML += " - " + progressReport;
  644. }
  645. /*Cleanup*/
  646. fakeDOM.html("");
  647. fetch(i + 1)
  648. }
  649. });
  650. }
  651. }
  652. fetch(0)
  653. } else if (getQuery("view") !== "") {
  654. /*We're on an individual report!*/
  655. processReport(document, getQuery("view"));
  656. } else if (getQuery("view") === "" && (getQuery("mode") === "all" || getQuery("mode") === "")) {
  657. errorBox(_("Please run this from the 'attacks' menu!"));
  658. }
  659. } else if (getQuery("screen") === "place" && $("#units_form").length === 0 && $("#command-data-form").length === 0) {
  660. /*Rally confirm page.*/
  661. if (!localData) {
  662. errorBox(_("Are you sure you've imported some reports?"));
  663. return;
  664. }
  665.  
  666. var targetCoords = splitOutCoords($(".village_anchor").text(), true);
  667. var vilIndex;
  668. localData.forEach(function(element, index) {
  669. if (element.coords === targetCoords) vilIndex = index;
  670. });
  671. if (typeof vilIndex === "undefined") {
  672. errorBox(_("Are you sure this village is in the NAFS list?"));
  673. $("#troop_confirm_go").focus();
  674. return;
  675. }
  676. var nafsLocalData = localData;
  677. var targetVillage = nafsLocalData[vilIndex];
  678. var latestReport = targetVillage && targetVillage.reports && targetVillage.reports[0];
  679. if (latestReport) {
  680. var catTarget;
  681. catables.forEach(function(element, index) {
  682. if (catTarget) return;
  683. if (latestReport.buildings && latestReport.buildings[element.id] && latestReport.buildings[element.id] > element.lowest) {
  684. catTarget = element.id;
  685. }
  686. });
  687. if (catTarget) {
  688. $("select[name='building']").val(catTarget);
  689. $("select[name='building']").after($("#nafsMsg") || $("<span id='nafsMsg' style='color:#0A0;'>" + _("Changed") + "</span>"));
  690. }
  691. }
  692. $("#troop_confirm_go").focus();
  693. } else if (getQuery("screen") === "place" && ($("#units_form").length > 0 || $("#command-data-form").length > 0)) {
  694. /*Rally page.*/
  695. if (!localData) {
  696. errorBox(_("Are you sure you've imported some reports?"));
  697. return;
  698. }
  699.  
  700. var errorBo = $(".error_box");
  701. if (errorBo.length > 0) {
  702. if (errorBo.text().trim().indexOf("can only attack each other when the bigger player's") !== -1 || errorBo.text().trim().indexOf("has been banned and cannot be attacked") !== -1) {
  703. var vilCoords = $(".village-name");
  704. var coordsFound = false;
  705. if (vilCoords.length > 0) {
  706. vilCoords = splitOutCoords(vilCoords.text(), true);
  707. if (vilCoords){
  708. var vilIndex;
  709. localData.forEach(function(element, index) {
  710. if (element.coords === vilCoords) vilIndex = index;
  711. });
  712. if (typeof vilIndex !== "undefined") {
  713. coordsFound = true;
  714. localData[vilIndex].disabled = true;
  715. $(".error_box").html("Previous farm disabled. Please <a href='" + window.location.href.replace("&try=confirm", "") .replace(/\&target\=\d*/, "") + "'>reopen the rally point</a>)");
  716. }
  717. }
  718. }
  719. if (!coordsFound) {
  720. errorBox("Unable to disable village. Is it in the NAFS list?");
  721. }
  722. }
  723. } else {
  724. var troopsEntered = false;
  725.  
  726. var rescout = getSetting("rescout", true);
  727. var minScout = getSetting("minScout", 1);
  728. var hoursToRescout = getSetting("hoursToRescout", 36);
  729. var hoursToStale = getSetting("hoursToStale", 12); /*?*/
  730.  
  731. var farm = getSetting("farm", true);
  732. var minFarmTroops = objectifyTroopSettings("minFarmTroops");
  733. var maxFarmTroops = objectifyTroopSettings("maxFarmTroops");
  734. var leaveFarmTroops = objectifyTroopSettings("leaveFarmTroops");
  735.  
  736. var shape = getSetting("shape", true);
  737. var catapult = getSetting("catapult", true);
  738. var catFarmToZero = getSetting("catFarmToZero", false);
  739. var catapultWalls = getSetting("catapultWalls", true);
  740. var ramWalls = getSetting("ram", true);
  741. var minWallLevel = getSetting("minWallLevel", 1);
  742. var minShapeTroops = objectifyTroopSettings("minShapeTroops");
  743. var maxShapeTroops = objectifyTroopSettings("maxShapeTroops");
  744. var leaveShapeTroops = objectifyTroopSettings("leaveShapeTroops");
  745.  
  746. var troopsEntered = false;
  747.  
  748. localData.forEach(function(element, index, array) {
  749. if (troopsEntered) return false;
  750. var alreadyAttacking = false;
  751. $(".quickedit-content span").each(function() {
  752. if ($(this).text().indexOf(_("Attack on")) !== -1 && splitOutCoords($(this).text(), true) === element.coords) alreadyAttacking = true;
  753. });
  754. if (!alreadyAttacking && !element.disabled) {
  755. var latestReport = element.reports && element.reports[0];
  756. var targetCoords = element.coords;
  757. if (!latestReport) {
  758. if (getMaxTroop("spy") > leaveShapeTroops.spy) {
  759. troops = {spy: minScout};
  760. console.log("No reports available! Scouting Village " + targetCoords);
  761. insertTroops(troops);
  762. targetVil(targetCoords);
  763.  
  764. troopsEntered = true;
  765. return false;
  766. }
  767. else {
  768. errorBox(_("No villages left to attack! Either add more villages, or wait for the attacks to complete."));
  769. return false;
  770. }
  771. }
  772. /*{rescout {minScout, hoursToRescout, hoursToStale}, farm {minFarmTroops (sp,sw,ax,ar,lc,ma,hc), maxFarmTroops (sp,sw,ax,ar,lc,ma,hc), leaveFarmTroops (sp,sw,ax,ar,sc,lc,ma,hc,pa)}, shape {catapult {catFarmToZero}, [catapultWalls, ram] {minWallLevel}, minShapeTroops (sp,sw,ax,ar,lc,ma,hc,pa), maxShapeTroops (sp,sw,ax,ar,lc,ma,hc,pa), leaveShapeTroops (sp,sw,ax,ar,sc,lc,ma,hc,pa)}, playerImport}*/
  773.  
  774. var minimumAchieved = false;
  775. var troops = {spy: minScout};
  776. /*Shaping is allowed, we have building data, and either we're not rescouting or it's under the hours to rescout value.*/
  777. if (shape && latestReport.buildings && (!rescout || (Number(new Date()) - latestReport.battleTime) <= hoursToRescout * 60 * 60 * 1000) && getMaxTroop("spy") > leaveShapeTroops.spy) {
  778. var wallLevel = latestReport.buildings.wall;
  779.  
  780. if ((ramWalls || catapultWalls) && wallLevel && wallLevel >= minWallLevel) {
  781. /*We're ramming or catting walls. We have a wall that's greater than or equal to the minimum level.*/
  782. for (var speedGroupID = speedGroups.length-1; speedGroupID>=0; speedGroupID--) {
  783. /*Group 0 is the fasters, therefore this goes slowest first.*/
  784. for (var unitID in speedGroups[speedGroupID]){
  785. if (minimumAchieved) break;
  786.  
  787. var unit = speedGroups[speedGroupID][unitID];
  788. if (unitCarry[fixTroopName(unit)] === 0) continue;
  789. var troopCount = Math.min(getMaxTroop(unit) - leaveShapeTroops[unit], maxShapeTroops[unit] === -1 ? getMaxTroop(unit) : maxShapeTroops[unit]);
  790. if (troopCount >= minShapeTroops[unit] && troopCount > 0) {
  791. minimumAchieved = true;
  792. troops[unit] = troopCount;
  793. }
  794. }
  795. }
  796.  
  797. if (minimumAchieved) {
  798. if (ramWalls && getMaxTroop("ram") - leaveShapeTroops.ram >= minShapeTroops.ram && getMaxTroop("ram") - leaveShapeTroops.ram >= ramsMin[wallLevel]) {
  799. /*Ram walls, and we have enough to fulfill the min criteria (user-set and to take a wall)*/
  800. var ramCount = Math.min(ramsRequired[wallLevel], getMaxTroop("ram") - leaveShapeTroops.ram, maxShapeTroops.ram === -1 ? getMaxTroop("ram") : maxShapeTroops.ram);
  801. if (ramCount >= ramsMin[wallLevel] && ramCount >= minShapeTroops.ram && ramCount > 0) {
  802. /*Enough for minimum. Enough for leaving. Under the max. Ready to ram with these rams.*/
  803. if (ramCount < ramsRequired[wallLevel]) {
  804. /*We should really use catapults to supplement this... Oh well.*/
  805. }
  806.  
  807. troops.ram = ramCount;
  808.  
  809. console.log("Ram wall shaping! Village " + targetCoords);
  810. insertTroops(troops);
  811. targetVil(targetCoords);
  812.  
  813. troopsEntered = true;
  814. return false;
  815. }
  816. }
  817. if (catapultWalls && getMaxTroop("catapult") - leaveShapeTroops.catapult >= minShapeTroops.catapult && getMaxTroop("catapult") - leaveShapeTroops.catapult >= catsMin[wallLevel]) {
  818. var catCount = Math.min(catsRequiredToBreak[0][wallLevel], getMaxTroop("catapult") - leaveShapeTroops.catapult, maxShapeTroops.catapult === -1 ? getMaxTroop("catapult") : maxShapeTroops.catapult);
  819. if (catCount >= catsMin[wallLevel] && catCount >= minShapeTroops.catapult && catCount > 0) {
  820. /*Enough for minimum. Enough for leaving. Under the max. Ready to ram with these rams.*/
  821. /*For now we'll just deal with cats and rams separately, m'kay? Rams take priority.*/
  822.  
  823. troops.catapult = catCount;
  824.  
  825. console.log("Catapult wall shaping! Village " + targetCoords);
  826. insertTroops(troops);
  827. targetVil(targetCoords);
  828.  
  829. troopsEntered = true;
  830. return false;
  831. }
  832. }
  833. }
  834. }
  835.  
  836. minimumAchieved = false;
  837. troops = {spy: minScout};
  838. if (catapult) {
  839. for (var speedGroupID = speedGroups.length-1; speedGroupID>=0; speedGroupID--) {
  840. /*Group 0 is the fasters, therefore this goes slowest first.*/
  841. for (var unitID in speedGroups[speedGroupID]){
  842. if (minimumAchieved) break;
  843.  
  844. var unit = speedGroups[speedGroupID][unitID];
  845. var troopCount = Math.min(getMaxTroop(unit) - leaveShapeTroops[unit], maxShapeTroops[unit] === -1 ? getMaxTroop(unit) : maxShapeTroops[unit]);
  846. if (troopCount >= minShapeTroops[unit] && troopCount > 0) {
  847. minimumAchieved = true;
  848. troops[unit] = troopCount;
  849. }
  850. }
  851. }
  852.  
  853. if (minimumAchieved) {
  854. var catTarget;
  855. var catTargetLevel;
  856. var catTargetMin;
  857. catables.forEach(function(element, index) {
  858. if (catTarget) return false;
  859. if (latestReport.buildings[element.id] && latestReport.buildings[element.id] > element.lowest) {
  860. catTarget = element.id;
  861. catTargetLevel = latestReport.buildings[element.id];
  862. catTargetMin = element.lowest;
  863. }
  864. });
  865.  
  866. /*catapultWalls && getMaxTroop("catapult") - leaveShapeTroops.catapult >= minShapeTroops.catapult && getMaxTroop("catapult") - leaveShapeTroops.catapult >= catsMin[wallLevel]) {
  867. var catCount = Math.min(catsRequiredToBreak[0][wallLevel], getMaxTroop("catapult") - leaveShapeTroops.catapult, maxShapeTroops.catapult === -1 ? getMaxTroop("catapult") : maxShapeTroops.catapult);
  868. if (catCount >= catsMin[wallLevel] && catCount >= minShapeTroops.catapult) {*/
  869. if (getMaxTroop("catapult") - leaveShapeTroops.catapult >= minShapeTroops.catapult && getMaxTroop("catapult") - leaveShapeTroops.catapult >= catsMin[catTargetLevel]) {
  870. var catCount = Math.min(catsRequiredToBreak[catTargetMin][catTargetLevel], getMaxTroop("catapult") - leaveShapeTroops.catapult, maxShapeTroops.catapult === -1 ? getMaxTroops("catapult") : maxShapeTroops.catapult);
  871. if (catCount >= catsMin[catTargetLevel] && catCount >= minShapeTroops.catapult && catCount > 0) {
  872. troops.catapult = catCount;
  873.  
  874. console.log("Catapult shaping! Village " + targetCoords);
  875. insertTroops(troops);
  876. targetVil(targetCoords);
  877.  
  878. troopsEntered = true;
  879. return false;
  880. }
  881. }
  882. }
  883. }
  884. }
  885.  
  886. minimumAchieved = false;
  887. troops = {spy: minScout};
  888. if (farm && (!rescout || (Number(new Date()) - latestReport.battleTime) <= hoursToRescout * 60 * 60 * 1000) && getMaxTroop("spy") > leaveShapeTroops.spy) {
  889. var hoursAgo = (Number(new Date()) - latestReport.battleTime) / 60 / 60 / 1000;
  890. var origWood = latestReport.wood,
  891. origClay = latestReport.clay,
  892. origIron = latestReport.iron;
  893. var woodCamp = latestReport.buildings.woodcamp,
  894. clayCamp = latestReport.buildings.claycamp,
  895. ironCamp = latestReport.buildings.ironcamp,
  896. warehouse = latestReport.buildings.warehouse;
  897. var currWood = Math.min(origWood + (resourceRates[woodCamp] * hoursAgo * getWorldSpeed()), warehouseCapacity[warehouse]),
  898. currClay = Math.min(origClay + (resourceRates[clayCamp] * hoursAgo * getWorldSpeed()), warehouseCapacity[warehouse]),
  899. currIron = Math.min(origIron + (resourceRates[ironCamp] * hoursAgo * getWorldSpeed()), warehouseCapacity[warehouse]);
  900.  
  901. var distance = element.distance;
  902.  
  903. var sendingTroops = false;
  904. for (var speedGroupID = 0; speedGroupID<speedGroups.length; speedGroupID++) {
  905. /*Group 0 is the fasters, therefore this goes fastest first.*/
  906. var slowestSpeedofGroup = slowestSpeedofGroups[speedGroupID];
  907. var hours = distance * (slowestSpeedofGroup / getUnitSpeed()) / 60;
  908. var newWood = currWood + (resourceRates[woodCamp] * hours * getWorldSpeed()),
  909. newClay = currClay + (resourceRates[clayCamp] * hours * getWorldSpeed()),
  910. newIron = currIron + (resourceRates[ironCamp] * hours * getWorldSpeed());
  911. var possibleHaul = newWood + newClay + newIron;
  912. for (var unitID in speedGroups[speedGroupID]){
  913. var unit = speedGroups[speedGroupID][unitID];
  914. var troopCount = Math.min(getMaxTroop(unit) - leaveFarmTroops[unit], maxFarmTroops[unit] === -1 ? getMaxTroop(unit) : maxFarmTroops[unit], Math.ceil(possibleHaul / unitCarry[unit]));
  915. if (troopCount >= minFarmTroops[unit] && troopCount > 0) {
  916. possibleHaul -= unitCarry[unit] * troopCount;
  917. sendingTroops = true;
  918. troops[unit] = troopCount;
  919. }
  920. }
  921. if (sendingTroops) break;
  922. }
  923.  
  924. if (sendingTroops) {
  925. console.log("Farming! Village " + targetCoords);
  926. insertTroops(troops);
  927. targetVil(targetCoords);
  928.  
  929. troopsEntered = true;
  930. return false;
  931. }
  932. }
  933.  
  934. minimumAchieved = false; /*Unnecessary, but oh well.*/
  935. troops = {spy: minScout};
  936. if (rescout && (Number(new Date()) - latestReport.battleTime) > hoursToRescout * 60 * 60 * 1000 && getMaxTroop("spy") > leaveShapeTroops.spy) {
  937. /*It's time to rescout. We also have at least 1 scout "available".*/
  938. console.log("Rescouting! Village " + targetCoords);
  939. insertTroops(troops);
  940. targetVil(targetCoords);
  941.  
  942. troopsEntered = true;
  943. return false;
  944. }
  945. }
  946. if (index === array.length - 1) {
  947. errorBox(_("No villages left to attack! Either add more villages, or wait for the attacks to complete."));
  948. }
  949. });
  950. }
  951. } else if (getQuery("screen") === "info_village"){
  952. /*Probably incomplete! FIX IT TOMORROW! TODO: Fix this better tomorrow!!!!*/
  953. var vilTable = $("#content_value table table[width='100%']");
  954. var vilCoords = $("tr:contains('" + _("Coordinates") + "')", vilTable).text().split(":")[1].split("|");
  955. var localCoords = getLocalCoords();
  956. var tribe = $("tr:contains('" + _("Tribe") + "')", vilTable);
  957.  
  958. var vilIndex;
  959. localData.forEach(function(element, index) {
  960. if (element.coords === (vilCoords[0] + "|" + vilCoords[1])) vilIndex = index;
  961. });
  962. var clickText = "";
  963. var type = -2;
  964. if (typeof vilIndex === "undefined"){
  965. clickText = _("Add to farm list for ") + getLocalName();
  966. type = -1;
  967. } else if (localData[vilIndex].disabled){
  968. clickText = _("Enable farm for ") + getLocalName();
  969. type = 1;
  970. } else {
  971. clickText = _("Disable farm for ") + getLocalName();
  972. type = 0;
  973. }
  974. var thingy = $("<tr><td colspan='2'></td></tr>");
  975. var thingy2 = $("<tr><td colspan='2'></td></tr>").css("display", "none");
  976. $("td", thingy).append($("<a style='cursor:pointer;'>» " + clickText + "</a>").on("click", function() {
  977. var nafsData = getLocalStorage();
  978. if (type === -1){
  979. vilIndex = localData.push({
  980. coords: (vilCoords[0] + "|" + vilCoords[1]),
  981. disabled: false,
  982. distance: (Math.floor(Math.sqrt(Math.pow(vilCoords[0]-localCoords[0],2)+Math.pow(vilCoords[1]-localCoords[1],2))*100)/100),
  983. reports: [ ]
  984. });
  985. localData.sort(function(a, b){
  986. return a.distance - b.distance;
  987. });
  988. $("td", thingy2).text(_("Added"));
  989. } else {
  990. var vilIndex;
  991. localData.forEach(function(element, index) {
  992. if (element.coords === (vilCoords[0] + "|" + vilCoords[1])) vilIndex = index;
  993. });
  994. if (type === 0){
  995. localData[vilIndex].disabled = true;
  996. $("td", thingy2).text(_("Disabled"));
  997. } else {
  998. localData[vilIndex].disabled = false;
  999. $("td", thingy2).text(_("Enabled"));
  1000. }
  1001. }
  1002. setLocalStorage(nafsData);
  1003. thingy.css("display", "none");
  1004. thingy2.css("display", "");
  1005. }));
  1006. ($("tr:contains('" + _("Actions") + "')", vilTable).length > 0 ? $("tr:contains('" + _("Actions") + "')", vilTable) : tribe).after(thingy).after(thingy2);
  1007. }
  1008. setLocalStorage(nafsData);
  1009. }
  1010.  
  1011. /*Returns either a boolean ("It went well!") or a message of what went wrong.*/
  1012. /*Returns: WENTWELL (boolean) - used to decide whether to add "SAVED" onto the end or not...*/
  1013. function processReport(doc, reportID){
  1014. /*We're on *a* report screen.*/
  1015. var espionage = $("#attack_spy_resources, #attack_spy_buildings_left", doc);
  1016. if (espionage.length >= 1) {
  1017. /* NEW REPORT STYUHL */
  1018. var repTable = espionage.closest("tbody");
  1019. var defender = $("#attack_info_def th:not(:contains('" + _("Defender") + "'))", repTable);
  1020. if (!getSetting("playerImport", true) && defender.length >= 1 && !defender.text().match("---")){
  1021. var linkd = $("<span>" + _("Saved") + "</span>");
  1022. repTable.parent().before(linkd);
  1023. linkd.text("Defender seems to be a player, and config says not to import - not saved");
  1024. return "The defender appears to be a player.";
  1025. }
  1026.  
  1027. var attackerVillage = $("#attack_info_att th:not(:contains('" + _("Attacker") + "'))", repTable).closest("tbody").find("tr:contains('Origin') td:not(:contains('Origin'))");
  1028. var localCoords = splitOutCoords(attackerVillage.text(), true).split("|");
  1029.  
  1030. var defenderVillage = $("#attack_info_def th:not(:contains('" + _("Defender") + "'))", repTable).closest("tbody").find("tr:contains('Destination') td:not(:contains('Destination'))");
  1031. var vilCoords = splitOutCoords(defenderVillage.text(), true).split("|");
  1032.  
  1033. var resources = $("#attack_spy_resources td", repTable);
  1034. var resz = resources.text().trim().split(/\s+/);
  1035. if (resources.get(0).innerHTML.indexOf("wood") === -1){
  1036. resz.unshift("0");
  1037. }
  1038. if (resources.get(0).innerHTML.indexOf("stone") === -1){
  1039. if (resz[1]) { resz.push(resz[1]); resz[1] = "0"; }
  1040. else resz.push("0");
  1041. }
  1042. if (resources.get(0).innerHTML.indexOf("iron") === -1){
  1043. resz.push("0");
  1044. }
  1045. var wood = parseInt(resz[0].replace(".", "")),
  1046. clay = parseInt(resz[1].replace(".", "")),
  1047. iron = parseInt(resz[2].replace(".", ""));
  1048. var battleTimeText = $($("tr td", repTable).get(1)).text().trim().replace(/:\d{3}/, "") + serverTimezones[window.location.host.split(/\W+/)[0].substring(0, 2)];
  1049. /* Format: MMM(M?) D(D), YYYY HH:mm:ss:mmm GMT+HHmm */
  1050. var timeThings = battleTimeText.match(/[\w-+]+/g);
  1051. var month = 0;
  1052. for (var i=0; i<months.length; i++){
  1053. if (timeThings[0].match(new RegExp(_(months[i]),"i"))) {
  1054. month = i+1;
  1055. }
  1056. }
  1057. var date = parseInt(timeThings[1]);
  1058. var year = parseInt(timeThings[2]);
  1059. var hour = parseInt(timeThings[3]);
  1060. var minute = parseInt(timeThings[4]);
  1061. var second = parseInt(timeThings[5]);
  1062. var offsets = timeThings[6].replace("GMT", "");
  1063. var offsetz = [];
  1064. offsetz[0] = offsets.substring(0, 1);
  1065. offsetz[1] = offsets.substring(1, 3);
  1066. offsetz[2] = offsets.substring(3, 5);
  1067. var offset = ((offsetz[0] === "+") ? -1 : 1) * (parseInt(offsetz[1])*60 + parseInt(offsetz[2]));
  1068. minute += offset;
  1069.  
  1070. var day = new Date();
  1071. day.setUTCFullYear(year);
  1072. day.setUTCMonth(month-1);
  1073. day.setUTCDate(date);
  1074. day.setUTCHours(hour);
  1075. day.setUTCMinutes(minute);
  1076. day.setUTCSeconds(second);
  1077.  
  1078. var battleTime = day;
  1079. var buildings;
  1080. var woodCamp, clayCamp, ironCamp, warehouse;
  1081. if ($("#attack_spy_building_data", repTable).length >= 1){
  1082. buildings = JSON.parse($("#attack_spy_building_data", repTable).val());
  1083. buildings.forEach(function(element, index, array){
  1084. if (element.id === "wood") woodCamp = parseInt(element.level);
  1085. if (element.id === "stone") clayCamp = parseInt(element.level);
  1086. if (element.id === "iron") ironCamp = parseInt(element.level);
  1087. if (element.id === "storage") warehouse = parseInt(element.level);
  1088. if (element.id === "wall") wall = parseInt(element.level);
  1089. });
  1090. woodCamp = (isNaN(woodCamp)) ? 0 : woodCamp;
  1091. clayCamp = (isNaN(clayCamp)) ? 0 : clayCamp;
  1092. ironCamp = (isNaN(ironCamp)) ? 0 : ironCamp;
  1093. warehouse = (isNaN(warehouse)) ? 0 : warehouse;
  1094. wall = (isNaN(wall)) ? 0 : wall;
  1095. } else {
  1096. woodCamp = 5;
  1097. clayCamp = 5;
  1098. ironCamp = 5;
  1099. warehouse = 10;
  1100. wall = 0;
  1101. }
  1102. var buildz = {};
  1103. buildz.woodcamp = woodCamp;
  1104. buildz.claycamp = clayCamp;
  1105. buildz.ironcamp = ironCamp;
  1106. buildz.warehouse = warehouse;
  1107. buildz.wall = wall;
  1108.  
  1109. if (buildings) {
  1110. buildings.forEach(function(element, index, array){
  1111. buildz[element.id] = parseInt(element.level);
  1112. });
  1113. }
  1114.  
  1115. buildz.barracks = buildz.barracks || 0;
  1116. buildz.place = buildz.place || 0;
  1117. buildz.stable = buildz.stable || 0;
  1118. buildz.garage = buildz.garage || 0;
  1119. buildz.snob = buildz.snob || 0;
  1120. buildz.smith = buildz.smith || 0;
  1121. buildz.statue = buildz.statue || 0;
  1122. buildz.market = buildz.market || 0;
  1123. buildz.main = buildz.main || 0;
  1124. buildz.farm = buildz.farm || 0;
  1125.  
  1126. var linkd = $("<span>" + _("Saved") + "</span>");
  1127. linkd.css("display", "none");
  1128.  
  1129. repTable.parent().before(linkd);
  1130. var progress = addReport(parseInt(reportID), localCoords, vilCoords, wood, clay, iron, battleTime, buildz);
  1131. if (progress === true){
  1132. linkd.text(_("Saved"));
  1133. linkd.css("display", "block").css("color", "");
  1134. console.log("Saved a report! - " + localCoords[0] + "|" + localCoords[1] + " - " + vilCoords[0] + "|" + vilCoords[1] + " - " + parseInt(reportID));
  1135. return true;
  1136. } else {
  1137. linkd.text("Oops! There was an error.");
  1138. linkd.css("display", "block").css("color", "#F00");
  1139. console.log("Error with a report! - " + localCoords[0] + "|" + localCoords[1] + " - " + vilCoords[0] + "|" + vilCoords[1] + " - " + parseInt(reportID));
  1140. return progress;
  1141. }
  1142. } else if ($("#attack_spy", doc).length >= 1) {
  1143. /*OLD STYLE *BLERGH* */
  1144. var espionage = $("#attack_spy", doc);
  1145. var repTable = espionage.parent().parent().parent();
  1146. var defender = $("#attack_info_def th:not(:contains('" + _("Defender") + "'))", repTable);
  1147. if (!getSetting("playerimport", true) && defender.length >= 1 && !defender.text().match("---")){
  1148. var linkd = $("<span>" + _("Saved") + "</span>");
  1149. repTable.parent().before(linkd);
  1150. linkd.text("Defender seems to be a player, and config says not to import - not saved");
  1151. return "The defender appears to be a player.";
  1152. }
  1153.  
  1154. var attackerVillage = $("#attack_info_att th:not(:contains('" + _("Attacker") + "'))", repTable).closest("tbody").find("tr:contains('Origin') td:not(:contains('Origin'))");
  1155. var localCoords = splitOutCoords(attackerVillage.text(), true).split("|");
  1156.  
  1157. var defenderVillage = $("#attack_info_def th:not(:contains('" + _("Defender") + "'))", repTable).closest("tbody").find("tr:contains('Destination') td:not(:contains('Destination'))");
  1158. var vilCoords = splitOutCoords(defenderVillage.text(), true).split("|");
  1159.  
  1160. var resources = $($("tr td", espionage).get(0));
  1161. var resz = resources.text().trim().split(" ");
  1162. if (resources.get(0).innerHTML.indexOf("wood") === -1){
  1163. resz.unshift("0");
  1164. }
  1165. if (resources.get(0).innerHTML.indexOf("stone") === -1){
  1166. if (resz[1]) { resz.push(resz[1]); resz[1] = "0"; }
  1167. else resz.push("0");
  1168. }
  1169. if (resources.get(0).innerHTML.indexOf("iron") === -1){
  1170. resz.push("0");
  1171. }
  1172. var wood = parseInt(resz[0].replace(".", "")),
  1173. clay = parseInt(resz[1].replace(".", "")),
  1174. iron = parseInt(resz[2].replace(".", ""));
  1175. var battleTimeText = $($("tr td", repTable).get(1)).text().trim().replace(/:\d{3}/, "") + serverTimezones[window.location.host.split(/\W+/)[0].substring(0, 2)];
  1176. /* Format: MMM(M?) D(D), YYYY HH:mm:ss:mmm GMT+HHmm */
  1177. var timeThings = battleTimeText.match(/[\w-+]+/g);
  1178. var month = 0;
  1179. for (var i=0; i<months.length; i++){
  1180. if (timeThings[0].match(new RegExp(_(months[i]),"i"))) {
  1181. month = i+1;
  1182. }
  1183. }
  1184. var date = parseInt(timeThings[1]);
  1185. var year = parseInt(timeThings[2]);
  1186. var hour = parseInt(timeThings[3]);
  1187. var minute = parseInt(timeThings[4]);
  1188. var second = parseInt(timeThings[5]);
  1189. var offsets = timeThings[6].replace("GMT", "");
  1190. var offsetz = [];
  1191. offsetz[0] = offsets.substring(0, 1);
  1192. offsetz[1] = offsets.substring(1, 3);
  1193. offsetz[2] = offsets.substring(3, 5);
  1194. var offset = ((offsetz[0] === "+") ? -1 : 1) * (parseInt(offsetz[1])*60 + parseInt(offsetz[2]));
  1195. minute += offset;
  1196.  
  1197. var day = new Date();
  1198. day.setUTCFullYear(year);
  1199. day.setUTCMonth(month-1);
  1200. day.setUTCDate(date);
  1201. day.setUTCHours(hour);
  1202. day.setUTCMinutes(minute);
  1203. day.setUTCSeconds(second);
  1204.  
  1205. var battleTime = day;
  1206. var buildings;
  1207. var woodCamp, clayCamp, ironCamp, warehouse, wall;
  1208. if ($("tr", espionage).length >= 2){
  1209. buildings = espionage.text();
  1210. woodCamp = parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Timber camp") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, ""));
  1211. clayCamp = parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Clay pit") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, ""));
  1212. ironCamp = parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Iron mine") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, ""));
  1213. warehouse = parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Warehouse") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, ""));
  1214. wall = parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Wall") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, ""));
  1215. woodCamp = (isNaN(woodCamp)) ? 0 : woodCamp;
  1216. clayCamp = (isNaN(clayCamp)) ? 0 : clayCamp;
  1217. ironCamp = (isNaN(ironCamp)) ? 0 : ironCamp;
  1218. warehouse = (isNaN(warehouse)) ? 0 : warehouse;
  1219. wall = (isNaN(wall)) ? 0 : wall;
  1220. } else {
  1221. var woodCamp = 5,
  1222. clayCamp = 5,
  1223. ironCamp = 5,
  1224. warehouse = 10,
  1225. wall = 0;
  1226. }
  1227. var buildz = {};
  1228. buildz.woodcamp = woodCamp;
  1229. buildz.claycamp = clayCamp;
  1230. buildz.ironcamp = ironCamp;
  1231. buildz.warehouse = warehouse;
  1232. buildz.wall = wall;
  1233. /*CHURCH*/
  1234. buildz.barracks = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Barracks") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1235. buildz.place = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Rally point") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1236. buildz.stable = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Stable") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1237. buildz.garage = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Workshop") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1238. buildz.snob = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Academy") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1239. buildz.smith = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Smithy") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1240. buildz.statue = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Statue") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1241. buildz.market = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Market") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1242. buildz.main = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Headquarters") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1243. buildz.farm = buildings && parseInt(buildings.replace(new RegExp("[\\s\\S]*" + _("Farm") + " \\(" + _("Level") + " "), "").replace(/\)[\s\S]*/, "")) || 0;
  1244. var linkd = $("<span>" + _("Saved") + "</span>");
  1245. linkd.css("display", "none");
  1246.  
  1247. repTable.parent().before(linkd);
  1248. var progress = addReport(parseInt(reportID), localCoords, vilCoords, wood, clay, iron, battleTime, buildz);
  1249. if (progress === true){
  1250. linkd.text("Saved");
  1251. linkd.css("display", "block").css("color", "");
  1252. console.log("Saved a report! - " + localCoords[0] + "|" + localCoords[1] + " - " + vilCoords[0] + "|" + vilCoords[1] + " - " + parseInt(reportID));
  1253. return true;
  1254. } else {
  1255. linkd.text("Oops! There was an error.");
  1256. linkd.css("display", "block").css("color", "#F00");
  1257. console.log("Error with a report! - " + localCoords[0] + "|" + localCoords[1] + " - " + vilCoords[0] + "|" + vilCoords[1] + " - " + parseInt(reportID));
  1258. return progress;
  1259. }
  1260. }
  1261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement