Greasy Fork is available in English.

PathCreator

Create path never been so easy

目前为 2018-01-26 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name PathCreator
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Create path never been so easy
  6. // @author Drigtime
  7. // @match https://dofus-map.com/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var icon = [
  15. L.icon({
  16. iconUrl: 'https://svgshare.com/i/54N.svg', // Top
  17. className: 'top-arrow'
  18. }),
  19. L.icon({
  20. iconUrl: 'https://svgshare.com/i/54m.svg', // Left
  21. className: 'left-arrow'
  22. }),
  23. L.icon({
  24. iconUrl: 'https://svgshare.com/i/51x.svg', // Bottom
  25. className: 'bottom-arrow'
  26. }),
  27. L.icon({
  28. iconUrl: 'https://svgshare.com/i/53t.svg', // Right
  29. className: 'right-arrow'
  30. }),
  31. L.icon({
  32. iconUrl: 'https://svgshare.com/i/556.svg', // Top Gather
  33. className: 'top-arrow'
  34. }),
  35. L.icon({
  36. iconUrl: 'https://svgshare.com/i/555.svg', // Left Gather
  37. className: 'left-arrow'
  38. }),
  39. L.icon({
  40. iconUrl: 'https://svgshare.com/i/54b.svg', // Bottom Gather
  41. className: 'bottom-arrow'
  42. }),
  43. L.icon({
  44. iconUrl: 'https://svgshare.com/i/54p.svg', // Right Gather
  45. className: 'right-arrow'
  46. }),
  47. L.icon({
  48. iconUrl: 'https://svgshare.com/i/53n.svg', // Top Fight
  49. className: 'top-arrow'
  50. }),
  51. L.icon({
  52. iconUrl: 'https://svgshare.com/i/54H.svg', // Left Fight
  53. className: 'left-arrow'
  54. }),
  55. L.icon({
  56. iconUrl: 'https://svgshare.com/i/54o.svg', // Bottom Fight
  57. className: 'bottom-arrow'
  58. }),
  59. L.icon({
  60. iconUrl: 'https://svgshare.com/i/527.svg', // Right Fight
  61. className: 'right-arrow'
  62. }),
  63. L.icon({
  64. iconUrl: 'https://svgshare.com/i/54G.svg', // Top Bank
  65. className: 'top-arrow'
  66. }),
  67. L.icon({
  68. iconUrl: 'https://svgshare.com/i/54w.svg', // Right Bank
  69. className: 'right-arrow'
  70. }),
  71. L.icon({
  72. iconUrl: 'https://svgshare.com/i/54v.svg', // Left Bank
  73. className: 'left-arrow'
  74. }),
  75. L.icon({
  76. iconUrl: 'https://svgshare.com/i/53x.svg', // Bottom Bank
  77. className: 'bottom-arrow'
  78. }),
  79. L.icon({
  80. iconUrl: 'https://svgshare.com/i/54x.svg', // Top Phenix
  81. className: 'top-arrow'
  82. }),
  83. L.icon({
  84. iconUrl: 'https://svgshare.com/i/557.svg', // Left Phenix
  85. className: 'left-arrow'
  86. }),
  87. L.icon({
  88. iconUrl: 'https://svgshare.com/i/54q.svg', // Bottom Phenix
  89. className: 'bottom-arrow'
  90. }),
  91. L.icon({
  92. iconUrl: 'https://svgshare.com/i/543.svg', // Right Phenix
  93. className: 'right-arrow'
  94. }),
  95. L.icon({
  96. iconUrl: 'https://svgshare.com/i/58M.svg', // Havenbag Move
  97. className: 'havenbag-icon'
  98. }),
  99. L.icon({
  100. iconUrl: 'https://svgshare.com/i/58N.svg', // Havenbag Gather
  101. className: 'havenbag-icon'
  102. }),
  103. L.icon({
  104. iconUrl: 'https://svgshare.com/i/5BW.svg', // Havenbag Fight
  105. className: 'havenbag-icon'
  106. }),
  107. L.icon({
  108. iconUrl: 'https://svgshare.com/i/5BL.svg', // Havenbag Bank
  109. className: 'havenbag-icon'
  110. }),
  111. L.icon({
  112. iconUrl: 'https://svgshare.com/i/5BB.svg', // Havenbag Phoenix
  113. className: 'havenbag-icon'
  114. }),
  115. ];
  116.  
  117. var actualMap;
  118. var pathData = [];
  119. var bankData = [];
  120. var phenixData = [];
  121. var havenBagData = [];
  122.  
  123. var ressources = [
  124. [1, "Frêne"],
  125. [8, "Chêne"],
  126. [17, "Fer"],
  127. [24, "Argent"],
  128. [25, "Or"],
  129. [26, "Pierre de Bauxite"],
  130. [28, "If"],
  131. [29, "Ebène"],
  132. [30, "Orme"],
  133. [31, "Erable"],
  134. [32, "Charme"],
  135. [33, "Châtaignier"],
  136. [34, "Noyer"],
  137. [35, "Merisier"],
  138. [37, "Pierre de Kobalte"],
  139. [38, "Blé"],
  140. [39, "Houblon"],
  141. [42, "Lin"],
  142. [43, "Orge"],
  143. [44, "Seigle"],
  144. [45, "Avoine"],
  145. [46, "Chanvre"],
  146. [47, "Malt"],
  147. [48, "Tas de patates"],
  148. [52, "Etain"],
  149. [53, "Pierre Cuivrée"],
  150. [54, "Manganèse"],
  151. [55, "Bronze"],
  152. [61, "Edelweiss"],
  153. [63, "Froment"],
  154. [64, "Epeautre"],
  155. [65, "Sorgho"],
  156. [66, "Menthe Sauvage"],
  157. [67, "Trèfle à 5 feuilles"],
  158. [68, "Orchidée Freyesque"],
  159. [71, "Greuvette"],
  160. [72, "Somoon Agressif"],
  161. [73, "Pwoulpe"],
  162. [74, "Truite"],
  163. [75, "Goujon"],
  164. [76, "Poisson-Chaton"],
  165. [77, "Crabe"],
  166. [78, "Poisson Pané"],
  167. [79, "Carpe d'Iem"],
  168. [80, "Truite Vaseuse"],
  169. [81, "Sardine Brillante"],
  170. [82, "Coton"],
  171. [84, "Puits"],
  172. [98, "Bombu"],
  173. [99, "Ombre étrange"],
  174. [100, "Pichon"],
  175. [101, "Oliviolet"],
  176. [102, "Machine de force"],
  177. [104, "Koinkoin"],
  178. [108, "Bambou"],
  179. [109, "Bambou sombre"],
  180. [110, "Bambou sacré"],
  181. [111, "Riz"],
  182. [112, "Pandouille"],
  183. [113, "Dolomite"],
  184. [114, "Silicate"],
  185. [121, "Kaliptus"],
  186. [131, "Perce-neige"],
  187. [132, "Poisskaille"],
  188. [133, "Tremble"],
  189. [134, "Frostiz"],
  190. [135, "Obsidienne"],
  191. [136, "Coquillage"],
  192. [137, "Machine à coudre de Poss'Ybel"],
  193. [138, "Fabrique"],
  194. [141, "Établi de mauvaise qualité"],
  195. [142, "Machine à coudre de mauvaise qualité"],
  196. [143, "Machine à jouets"],
  197. [144, "Pressoir à poisson"],
  198. [146, "Paquet Cadeau"],
  199. [167, "Arène"],
  200. [168, "Banque"],
  201. [169, "Bar Akouda"],
  202. [170, "Bibliothèque"],
  203. [171, "Boutiques de Nowel"],
  204. [172, "Dojo"],
  205. [173, "Église"],
  206. [174, "Épicerie"],
  207. [175, "Fabricant de skis"],
  208. [176, "Hôtel de ville"],
  209. [177, "Hôtel des métiers"],
  210. [178, "Kanojedo"],
  211. [179, "Kolizéum"],
  212. [180, "Milice"],
  213. [181, "Médecin de Frigost"],
  214. [206, "Sous-marin Steamer"],
  215. [207, "Autel"],
  216. [208, "Krosmaster"],
  217. [219, "Métier d'Avenir"],
  218. [220, "Tonneau d'explosifs"],
  219. [221, "Fleur de Sutol"],
  220. [222, "Barbecue"],
  221. [223, "Cawotte fraîche"],
  222. [224, "Alambic patiné de l'hôtel des métiers"],
  223. [225, "Bouteille de Rhum"],
  224. [226, "Ascenseur"],
  225. [227, "Champignon"],
  226. [230, "Portail des Bworks"],
  227. [231, "Distributeur de missions"],
  228. [232, "Portail"],
  229. [234, "Glaçon"],
  230. [235, "Aller vers"],
  231. [236, "Pupitre"],
  232. [253, "Portail Eliotrope"],
  233. [254, "Ortie"],
  234. [255, "Sauge"],
  235. [256, "Ginseng"],
  236. [257, "Belladone"],
  237. [258, "Mandragore"],
  238. [259, "Noisetier"],
  239. [260, "Maïs"],
  240. [261, "Millet"],
  241. [262, "Bloc de pierre"],
  242. [263, "Brochet"],
  243. [264, "Kralamoure"],
  244. [265, "Anguille"],
  245. [266, "Dorade Grise"],
  246. [267, "Perche"],
  247. [268, "Raie"],
  248. [269, "Lotte"],
  249. [270, "Requin Marteau-Faucille"],
  250. [271, "Bar Rikain"],
  251. [272, "Morue"],
  252. [273, "Tanche"],
  253. [274, "Espadon"],
  254. [275, "Enclume de Mulic Bere"],
  255. [276, "Établi de Mulic Bere"],
  256. [278, "Assembleur de Mulic Bere"],
  257. [280, "Plate-forme Huppermage"],
  258. [281, "Trèfle à 4 feuilles"],
  259. [282, "Indiquer une sortie"],
  260. [283, "Chathon"],
  261. [284, "Escalier"],
  262. [285, "Porte blindée"],
  263. [287, "Aquajou"],
  264. [288, "Salikrone"],
  265. [289, "Quisnoa"],
  266. [290, "Patelle"],
  267. [291, "Écume de mer"],
  268. [293, "Écume de mer"],
  269. [294, "Aquajou"],
  270. [295, "Salikrone"],
  271. [296, "Quisnoa"],
  272. [297, "Patelle"],
  273. [299, "Œufs frais"]
  274. ];
  275. var picker = 4;
  276. var gatherData = [];
  277. var loadingFile = false;
  278. var havenToggle = false;
  279.  
  280. var script = document.createElement('script');
  281. script.type = 'text/javascript';
  282. script.src = 'https://code.jquery.com/jquery-3.2.1.slim.min.js';
  283. document.getElementsByTagName('head')[0].appendChild(script);
  284. setTimeout(function () {
  285. var script2 = document.createElement('script');
  286. script2.type = 'text/javascript';
  287. script2.src = 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.3/js/bootstrap.js';
  288. document.getElementsByTagName('head')[0].appendChild(script2);
  289. }, 500);
  290. var script1 = document.createElement('script');
  291. script1.type = 'text/javascript';
  292. script1.src = 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js';
  293. document.getElementsByTagName('head')[0].appendChild(script1);
  294. var css = document.createElement('style');
  295. css.type = 'text/css';
  296. css.textContent = '.checkbox.checkbox-inline,.radio.radio-inline{margin-top:0}#pathcreator{background:#212121;border-radius:5px;padding:10px;color:#fff;box-shadow:0 0 10px 0 rgba(0,0,0,.6);font-family:arial;opacity:.95}.row{padding-top:.5rem;padding-left:1rem}.checkbox{padding-left:20px}.checkbox label{display:inline-block;position:relative;padding-left:5px}.checkbox label::after,.checkbox label::before{position:absolute;margin-left:-20px;display:inline-block;left:0}.checkbox label::before{content:"";width:17px;height:17px;border:1px solid #ccc;border-radius:3px;background-color:#fff;-webkit-transition:border .15s ease-in-out,color .15s ease-in-out;-o-transition:border .15s ease-in-out,color .15s ease-in-out;transition:border .15s ease-in-out,color .15s ease-in-out}.checkbox label::after{width:16px;height:16px;top:0;padding-left:3px;padding-top:1px;font-size:11px;color:#555}.checkbox input[type=checkbox]{opacity:0}.checkbox input[type=checkbox]:checked+label::after{font-family:FontAwesome;content:"\\f00c"}.checkbox input[type=checkbox]:disabled+label{opacity:.65}.checkbox input[type=checkbox]:disabled+label::before{background-color:#eee;cursor:not-allowed}.checkbox.checkbox-circle label::before{border-radius:50%}.checkbox-primary input[type=checkbox]:checked+label::before{background-color:#428bca;border-color:#428bca}.checkbox-primary input[type=checkbox]:checked+label::after{color:#fff}.radio{padding-left:20px}.radio label{display:inline-block;position:relative;padding-left:5px}.radio label::after,.radio label::before{display:inline-block;position:absolute;margin-left:-20px}.radio label::before{content:"";width:17px;height:17px;left:0;border:1px solid #ccc;border-radius:50%;background-color:#fff;-webkit-transition:border .15s ease-in-out;-o-transition:border .15s ease-in-out;transition:border .15s ease-in-out}.radio label::after{content:" ";width:11px;height:11px;left:3px;top:3px;border-radius:50%;background-color:#555;-webkit-transform:scale(0,0);-ms-transform:scale(0,0);-o-transform:scale(0,0);transform:scale(0,0);-webkit-transition:-webkit-transform .1s cubic-bezier(.8,-.33,.2,1.33);-moz-transition:-moz-transform .1s cubic-bezier(.8,-.33,.2,1.33);-o-transition:-o-transform .1s cubic-bezier(.8,-.33,.2,1.33);transition:transform .1s cubic-bezier(.8,-.33,.2,1.33)}.radio-primary input[type=radio]+label::after,.radio-primary input[type=radio]:checked+label::after{background-color:#428bca}.radio input[type=radio]{opacity:0}.radio input[type=radio]:checked+label::after{-webkit-transform:scale(1,1);-ms-transform:scale(1,1);-o-transform:scale(1,1);transform:scale(1,1)}.radio input[type=radio]:disabled+label{opacity:.65}.radio input[type=radio]:disabled+label::before{cursor:not-allowed}.radio-primary input[type=radio]:checked+label::before{border-color:#428bca}.radio-phenix input[type=radio]+label::after,.radio-phenix input[type=radio]:checked+label::after{background-color:#ab37c8}.radio-phenix input[type=radio]:checked+label::before{border-color:#ab37c8}.radio-danger input[type=radio]+label::after,.radio-danger input[type=radio]:checked+label::after{background-color:#d9534f}.radio-danger input[type=radio]:checked+label::before{border-color:#d9534f}.radio-success input[type=radio]+label::after,.radio-success input[type=radio]:checked+label::after{background-color:#5cb85c}.radio-success input[type=radio]:checked+label::before{border-color:#5cb85c}.btn-secondary{color:#bfbfbf;background-color:#0d0d0d;border-color:#1a1a1a}.btn-secondary.active,.btn-secondary:active,.btn-secondary:focus,.btn-secondary:hover,.open .dropdown-toggle.btn-secondary{color:#bfbfbf;background-color:#1a1a1a;border-color:#0d0d0d}.btn-file{position:relative;overflow:hidden}.btn-file input[type=file]{position:absolute;top:0;right:0;min-width:100%;min-height:100%;font-size:100px;text-align:right;filter:alpha(opacity=0);opacity:0;outline:0;background:#fff;cursor:inherit;display:block}#mapContainer[data-zoom="7"] .top-arrow{width:145px;margin-left:528.5px}#mapContainer[data-zoom="6"] .top-arrow{width:75px;margin-left:262.5px}#mapContainer[data-zoom="5"] .top-arrow{width:36px;margin-left:131.5px}#mapContainer[data-zoom="4"] .top-arrow{width:19px;margin-left:65.75px}#mapContainer[data-zoom="3"] .top-arrow{width:15px;margin-left:30.13px}#mapContainer[data-zoom="2"] .top-arrow{width:9.9px;margin-left:13.86px}#mapContainer[data-zoom="1"] .top-arrow{width:7px;margin-left:5.91px}#mapContainer[data-zoom="0"] .top-arrow{width:5.38px;margin-left:5.01px}#mapContainer[data-zoom="7"] .havenbag-icon{width:500.83px;margin-left:350.5833333px;margin-top:135.8px}#mapContainer[data-zoom="6"] .havenbag-icon{width:250px;margin-left:175px;margin-top:67.5px}#mapContainer[data-zoom="5"] .havenbag-icon{width:124.58px;margin-left:87.20833333px;margin-top:33.35px}#mapContainer[data-zoom="4"] .havenbag-icon{width:61.88px;margin-left:43.3125px;margin-top:16.28px}#mapContainer[data-zoom="3"] .havenbag-icon{width:30.52px;margin-left:21.36458333px;margin-top:7.74px}#mapContainer[data-zoom="2"] .havenbag-icon{width:14.84px;margin-left:10.390625px;margin-top:3.47px}#mapContainer[data-zoom="1"] .havenbag-icon{width:7.01px;margin-left:4.903645833px;margin-top:1.33px}#mapContainer[data-zoom="0"] .havenbag-icon{width:3.09px;margin-left:2.16015625px;margin-top:.27px}#mapContainer[data-zoom="7"] .left-arrow{width:324.26px;margin-top:356.5px}#mapContainer[data-zoom="6"] .left-arrow{width:161.59px;margin-top:177.75px}#mapContainer[data-zoom="5"] .left-arrow{width:80.53px;margin-top:88.38px}#mapContainer[data-zoom="4"] .left-arrow{width:40.13px;margin-top:44.19px}#mapContainer[data-zoom="3"] .left-arrow{width:30.87px;margin-top:19.34px}#mapContainer[data-zoom="2"] .left-arrow{width:23.75px;margin-top:7.42px}#mapContainer[data-zoom="1"] .left-arrow{width:18.27px;margin-top:1.86px}#mapContainer[data-zoom="0"] .left-arrow{width:14.05px;margin-top:1px}#mapContainer[data-zoom="7"] .right-arrow{width:324.26px;margin-left:878.74px;margin-top:356.5px}#mapContainer[data-zoom="6"] .right-arrow{width:161.59px;margin-left:439.41px;margin-top:177.75px}#mapContainer[data-zoom="5"] .right-arrow{width:80.53px;margin-left:219.47px;margin-top:88.38px}#mapContainer[data-zoom="4"] .right-arrow{width:40.13px;margin-left:110.37px;margin-top:44.19px}#mapContainer[data-zoom="3"] .right-arrow{width:30.87px;margin-left:43.38px;margin-top:19.34px}#mapContainer[data-zoom="2"] .right-arrow{width:23.75px;margin-left:12.88px;margin-top:7.42px}#mapContainer[data-zoom="1"] .right-arrow{width:18.27px;margin-left:1px;margin-top:1.86px}#mapContainer[data-zoom="0"] .right-arrow{width:14.05px;margin-left:1px;margin-top:1px}#mapContainer[data-zoom="7"] .bottom-arrow{width:145px;margin-left:528.5px;margin-top:648.2px}#mapContainer[data-zoom="6"] .bottom-arrow{width:75px;margin-left:262.5px;margin-top:319.5px}#mapContainer[data-zoom="5"] .bottom-arrow{width:36px;margin-left:131.5px;margin-top:160.91px}#mapContainer[data-zoom="4"] .bottom-arrow{width:19px;margin-left:65.75px;margin-top:78.02px}#mapContainer[data-zoom="3"] .bottom-arrow{width:15px;margin-left:30.13px;margin-top:31.09px}#mapContainer[data-zoom="2"] .bottom-arrow{width:9.9px;margin-left:13.86px;margin-top:11.59px}#mapContainer[data-zoom="1"] .bottom-arrow{width:7px;margin-left:5.91px;margin-top:3px}#mapContainer[data-zoom="0"] .bottom-arrow{width:5.38px;margin-left:5.01px;margin-top:0}';
  297. document.getElementsByTagName('head')[0].appendChild(css);
  298.  
  299.  
  300. document.getElementById('pickRessourceContainer').innerHTML += '\
  301. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css">\
  302. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css">\
  303. <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.9.0/css/flag-icon.css">\
  304. <div id="pathcreator" class="container">\
  305. <div style="text-align: right;">\
  306. <div class="btn-group">\
  307. <button type="button" class="btn dropdown-toggle btn-dark" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div id="languageDisplayer" class="flag-icon flag-icon-fr"></div>\
  308. </button>\
  309. <div class="dropdown-menu dropdown-menu-right">\
  310. <a class="dropdown-item" href="javascript:languageSelector(\'fr\')" id="fr"><div class="flag-icon flag-icon-fr"></div> Français</a>\
  311. <a class="dropdown-item" href="javascript:languageSelector(\'en\')" id="en"><div class="flag-icon flag-icon-gb"></div> English</a>\
  312. <a class="dropdown-item" href="javascript:languageSelector(\'es\')" id="es"><div class="flag-icon flag-icon-es"></div> Español</a>\
  313. </div>\
  314. </div>\
  315. </div>\
  316. <div class="row no-gutters">\
  317. <div class="col checkbox checkbox-primary">\
  318. <input type="checkbox" id="pathTop" value="option1">\
  319. <label id="top" for="pathTop">Haut</label>\
  320. </div>\
  321. <div class="col checkbox checkbox-primary">\
  322. <input type="checkbox" id="pathBottom" value="option1">\
  323. <label id="bottom" for="pathBottom">Bas</label>\
  324. </div>\
  325. <div class="w-100"></div>\
  326. <div class="col checkbox checkbox-primary">\
  327. <input type="checkbox" id="pathLeft" value="option1">\
  328. <label id="left" for="pathLeft">Gauche</label>\
  329. </div>\
  330. <div class="col checkbox checkbox-primary">\
  331. <input type="checkbox" id="pathRight" value="option1">\
  332. <label id="right" for="pathRight">Droite</label>\
  333. </div>\
  334. <div class="w-100"></div>\
  335. <div class="col checkbox checkbox-primary">\
  336. <input type="checkbox" id="pathHavenBag" value="option1">\
  337. <label id="havenBag" for="pathHavenBag">Havre-sac</label>\
  338. </div>\
  339. </div>\
  340. <hr style="border-top: 3px solid #111;" />\
  341. <form>\
  342. <div class="row no-gutters">\
  343. <div class="col radio radio-success">\
  344. <input type="radio" id="gather" name="radioOption">\
  345. <label id="tdgather" for="gather">Recolte</label>\
  346. </div>\
  347. <div class="col radio radio-danger">\
  348. <input type="radio" id="fight" name="radioOption">\
  349. <label id="tdfight" for="fight">Combat</label>\
  350. </div>\
  351. <div class="w-100"></div>\
  352. <div class="col radio radio-primary">\
  353. <input type="radio" id="bank" name="radioOption">\
  354. <label id="tdbank" for="bank">Banque</label>\
  355. </div>\
  356. <div class="col radio radio-phenix">\
  357. <input type="radio" id="phenix" name="radioOption">\
  358. <label id="tdphoenix" for="phenix">Phenix</label>\
  359. </div>\
  360. <div class="w-100"></div>\
  361. <div class="col radio">\
  362. <input type="radio" id="move" name="radioOption" checked>\
  363. <label id="tdMove" for="move">Deplacement</label>\
  364. </div>\
  365. </div>\
  366. </form>\
  367. <hr style="border-top: 3px solid #111;" />\
  368. <p style="text-align: center;" id="restogather">Ressources à récolter</p>\
  369. <div id="ressourcePickerBot" style="text-align: center;"><span id="ressourcePickerCreator" class="pickRessource" onclick="newRessourcePicker();" style="background-color: #0000008a; background-position: -260px 0px;">+</span></div>\
  370. <hr style="border-top: 3px solid #111;" />\
  371. <div class="btn-group btn-block">\
  372. <button type="button" class="btn btn-dark btn-block" id="saveFile" onclick="generate()">Sauvegarder</button>\
  373. <button type="button" class="btn btn-dark dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\
  374. </button>\
  375. <div class="dropdown-menu dropdown-menu-right">\
  376. <input type="text" placeholder="Nom du trajet" id="fileName">\
  377. </div>\
  378. </div>\
  379. <button class="btn btn-dark btn-block" id="deletePath" onclick="deletePath()">Supprimer</button>\
  380. <label class="btn btn-dark btn-block btn-file"><div id="loadAFile">Charger</div><input id="file" type="file" style="display: none;">\
  381. </label>\
  382. </div>\
  383. <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" style=" top: 300px;">\
  384. <div class="modal-dialog" role="document">\
  385. <div class="modal-content">\
  386. <div class="modal-header">\
  387. <h5 class="modal-title" id="exampleModalLabel">Zaap</h5>\
  388. <button type="button" class="close" data-dismiss="modal" aria-label="Close">\
  389. <span aria-hidden="true">&times;</span>\
  390. </button>\
  391. </div>\
  392. <div class="modal-body">\
  393. <form>\
  394. <div class="form-group">\
  395. <label for="recipient-name" class="form-control-label">Zaap d\'arrivée :</label>\
  396. <select class="form-control" id="sel1">\
  397. <option value="84674563">Astrub | 4,-19</option>\
  398. <option value="147768">Bonta | -32,-56</option>\
  399. <option value="144419">Brâkmar | -26,35</option>\
  400. <option value="88212746">Amakna (Bord de la forêt maléfique) | -1,13</option>\
  401. <option value="68552706">Amakna (Château d\'Amakna) | 3,-5</option>\
  402. <option value="88082704">Amakna (Coins des Bouftous) | 5,7</option>\
  403. <option value="68419587">Amakna (Port de Madrestam) | 7,-4</option>\
  404. <option value="88213271">Amakna (Village d\'Amakna) | -2,0</option>\
  405. <option value="88212481">Amakna (Plaîne des Scarafeuilles) | -1,24</option>\
  406. <option value="88085249">Baie de Sufokia (Rivage Sufokien) | 10,22</option>\
  407. <option value="95422468">Baie de Sufokia (Sufokia) | 13,26</option>\
  408. <option value="154642"le d\'Otomaïl (Village côtier) | -46,18</option>\
  409. <option value="54172969"le de Frigost (La Bourgade) | -79,-41</option>\
  410. <option value="54172489"le de Frigost (Village enseveli) | -77,-73</option>\
  411. <option value="156762120"le de Moon (Plage de la Tortue) | 35,12</option>\
  412. <option value="73400320">Montagne des Koalaks (Village des Eleveurs) | -16,1</option>\
  413. <option value="13605">Pandala Neutre (Faubourgs de Pandala) | 26,-37</option>\
  414. <option value="15153">Pandala Feu (Village de Feudala) | 29,-49</option>\
  415. <option value="142087694">Plaine de Cania (Champs de Cania) | -27,-36</option>\
  416. <option value="156240386">Plaine de Cania (Lac de Cania) | -3,-42</option>\
  417. <option value="165152263">Plaine de Cania (Massif de Cania) | -13,-28</option>\
  418. <option value="84806401">Plaine de Cania (Plaine des Porkass) | -5,-23</option>\
  419. <option value="147590153">Plaine de Cania (Plaines Rocheuses) | -17,-47</option>\
  420. <option value="164364304">Plaine de Cania (Route Rocailleuse) | -20,-20</option>\
  421. <option value="173278210">Saharach (Dunes des ossements) | 15,-58</option>\
  422. <option value="171967506">Landes de Sidimote (Route des Roulottes) | -25,12</option>\
  423. </select>\
  424. </div>\
  425. </form>\
  426. </div>\
  427. <div class="modal-footer">\
  428. <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>\
  429. <button type="button" class="btn btn-primary">Valider</button>\
  430. </div>\
  431. </div>\
  432. </div>\
  433. </div>';
  434.  
  435. function checkMaps(mapcoord, array) {
  436. for (let key = 0; key < array.length; key++) {
  437. if (array[key][0] == mapcoord) {
  438. return true;
  439. }
  440. }
  441. return false;
  442. }
  443.  
  444. function getMapIndex(mapcoord, array) {
  445. for (let key = 0; key < array.length; key++) {
  446. if (array[key][0] == mapcoord) {
  447. return key;
  448. }
  449. }
  450. }
  451.  
  452. function onMapClick() {
  453.  
  454. if (!loadingFile)
  455. actualMap = document.getElementById('mapCoordinates').innerText;
  456.  
  457. if (document.getElementById("pathHavenBag").checked) {
  458. if (!havenToggle) {
  459. if (!checkMaps(actualMap.split(', ')[0] + ',' + actualMap.split(', ')[1], havenBagData)) {
  460. havenToggle = true;
  461. $('#exampleModal').modal('show');
  462. return
  463. } else {
  464. havenBagData.splice(getMapIndex(actualMap.split(', ')[0] + ',' + actualMap.split(', ')[1], havenBagData), 1);
  465. }
  466. } else {
  467. havenToggle = false;
  468. }
  469. }
  470. if (document.getElementById("bank").checked) {
  471. if (!checkMaps(actualMap, bankData)) {
  472. bankData.push([actualMap, false, undefined, false, undefined, false, undefined, false, undefined, false, undefined, false]);
  473. createMarker(getMapIndex(actualMap, bankData), bankData);
  474. deleteEmptyPath(bankData);
  475. } else if (checkMaps(actualMap, bankData)) {
  476. removeArrow(getMapIndex(actualMap, bankData), bankData);
  477. deleteEmptyPath(bankData);
  478. }
  479. console.clear();
  480. for (let key in bankData) {
  481. console.log(key + ', map : ' + bankData[key][0] + ', top : ' + bankData[key][1] + ', bottom : ' + bankData[key][5] + ', right : ' + bankData[key][7] + ', left : ' + bankData[key][3] + ', havenbag : ' + bankData[key][9]);
  482. }
  483. } else if (document.getElementById("phenix").checked) {
  484. if (!checkMaps(actualMap, phenixData)) {
  485. phenixData.push([actualMap, false, undefined, false, undefined, false, undefined, false, undefined, false, undefined, false]);
  486. createMarker(getMapIndex(actualMap, phenixData), phenixData);
  487. deleteEmptyPath(phenixData);
  488. } else if (checkMaps(actualMap, phenixData)) {
  489. removeArrow(getMapIndex(actualMap, phenixData), phenixData);
  490. deleteEmptyPath(phenixData);
  491. }
  492. console.clear();
  493. for (let key in phenixData) {
  494. console.log(key + ', map : ' + phenixData[key][0] + ', top : ' + phenixData[key][1] + ', bottom : ' + phenixData[key][5] + ', right : ' + phenixData[key][7] + ', left : ' + phenixData[key][3] + ', havenbag : ' + phenixData[key][9]);
  495. }
  496. } else {
  497. if (!checkMaps(actualMap, pathData)) {
  498. pathData.push([actualMap, false, undefined, false, undefined, false, undefined, false, undefined, false, undefined, false, false]);
  499. createMarker(getMapIndex(actualMap, pathData), pathData);
  500. deleteEmptyPath(pathData);
  501. } else if (checkMaps(actualMap, pathData)) {
  502. removeArrow(getMapIndex(actualMap, pathData), pathData);
  503. deleteEmptyPath(pathData);
  504. }
  505. console.clear();
  506. for (let key in pathData) {
  507. console.log(key + ', map : ' + pathData[key][0] + ', top : ' + pathData[key][1] + ', bottom : ' + pathData[key][5] + ', right : ' + pathData[key][7] + ', left : ' + pathData[key][3] + ', havenbag : ' + pathData[key][9] + ', gather : ' + pathData[key][11] + ', fight : ' + pathData[key][12]);
  508. }
  509. }
  510. }
  511.  
  512. function deleteEmptyPath(array) {
  513. if (!array[getMapIndex(actualMap, array)][1] && !array[getMapIndex(actualMap, array)][3] && !array[getMapIndex(actualMap, array)][5] && !array[getMapIndex(actualMap, array)][7] && !array[getMapIndex(actualMap, array)][9]) {
  514. array.splice(getMapIndex(actualMap, array), 1);
  515. }
  516. }
  517.  
  518. function removeArrow(key, array) {
  519. removeArrowWay(key, array, "pathTop", 2, 4, 8, 12, 16, 0, 1, 0, 0);
  520. removeArrowWay(key, array, "pathLeft", 4, 5, 9, 14, 17, 1, 3, 0, 0);
  521. removeArrowWay(key, array, "pathBottom", 6, 6, 10, 15, 18, 2, 5, 0, 0);
  522. removeArrowWay(key, array, "pathRight", 8, 7, 11, 13, 19, 3, 7, 0, 0);
  523. removeArrowWay(key, array, "pathHavenBag", 10, 21, 22, 23, 24, 20, 9, 0, 0);
  524. }
  525.  
  526. function removeArrowWay(key, array, className, wayMarker, gatherIcon, fightIcon, bankIcon, phenixIcon, moveIcon, wayToggle, x, y) {
  527. if (document.getElementById(className).checked) {
  528. if (array[key][wayMarker] !== undefined) {
  529. array[key][wayToggle] = false;
  530. map.removeLayer(array[key][wayMarker]);
  531. array[key][wayMarker] = undefined;
  532. } else createMarkerWay(key, array, className, wayMarker, gatherIcon, fightIcon, bankIcon, phenixIcon, moveIcon, wayToggle, x, y)
  533. }
  534. }
  535.  
  536. function createMarker(key, array) {
  537. createMarkerWay(key, array, "pathTop", 2, 4, 8, 12, 16, 0, 1, 0, 0);
  538. createMarkerWay(key, array, "pathLeft", 4, 5, 9, 14, 17, 1, 3, 0, 0);
  539. createMarkerWay(key, array, "pathBottom", 6, 6, 10, 15, 18, 2, 5, 0, 0);
  540. createMarkerWay(key, array, "pathRight", 8, 7, 11, 13, 19, 3, 7, 0, 0);
  541. createMarkerWay(key, array, "pathHavenBag", 10, 21, 22, 23, 24, 20, 9, 0, 0);
  542. }
  543.  
  544. function createMarkerWay(key, array, className, wayMarker, gatherIcon, fightIcon, bankIcon, phenixIcon, moveIcon, wayToggle, x, y) {
  545. if (document.getElementById(className).checked) {
  546. if (document.getElementById("gather").checked) {
  547. array[key][wayMarker] = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 + x, actualMap.split(", ")[1] * 1 + y), {
  548. interactive: false,
  549. zIndexOffset: 5000,
  550. icon: icon[gatherIcon]
  551. }).addTo(map);
  552. array[key][11] = true;
  553. } else if (document.getElementById("fight").checked) {
  554. array[key][wayMarker] = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 + x, actualMap.split(", ")[1] * 1 + y), {
  555. interactive: false,
  556. zIndexOffset: 5000,
  557. icon: icon[fightIcon]
  558. }).addTo(map);
  559. array[key][12] = true;
  560. } else if (document.getElementById("bank").checked) {
  561. array[key][wayMarker] = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 + (x + 0.1), actualMap.split(", ")[1] * 1 + (y + 0.1)), {
  562. interactive: false,
  563. zIndexOffset: 5000,
  564. icon: icon[bankIcon]
  565. }).addTo(map);
  566. array[key][11] = true;
  567. } else if (document.getElementById("phenix").checked) {
  568. array[key][wayMarker] = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 + (x + 0.2), actualMap.split(", ")[1] * 1 + (y + 0.2)), {
  569. interactive: false,
  570. zIndexOffset: 5000,
  571. icon: icon[phenixIcon]
  572. }).addTo(map);
  573. array[key][11] = true;
  574. } else {
  575. array[key][wayMarker] = L.marker(dofusXYToMapXY(actualMap.split(", ")[0] * 1 + x, actualMap.split(", ")[1] * 1 + y), {
  576. interactive: false,
  577. zIndexOffset: 5000,
  578. icon: icon[moveIcon]
  579. }).addTo(map);
  580. }
  581. array[key][wayToggle] = true;
  582. }
  583. }
  584.  
  585. function newRessourcePicker() {
  586. document.getElementById("ressourcePickerBot").innerHTML = '<span id="pickRessource' + picker + '" class="pickRessource ressourceColor1" onclick="clickOnTypePicker(\'' + picker + '\');" data-name="" data-ressourceid=""' +
  587. 'style="background-position: -260px 0px; line-height: 49px !important; width: 49px !important; margin: 2px !important; height: 49px !important;">?</span>' + document.getElementById("ressourcePickerBot").innerHTML;
  588. gatherData.push('pickRessource' + picker);
  589. picker += 1;
  590. }
  591.  
  592. function pathGenerator(index, array) {
  593. var path = "";
  594. if (index !== undefined) {
  595. if (array.length !== 0) {
  596. if (array[index][9])
  597. path = "havenbag";
  598. else {
  599. if (array[index][1])
  600. path = "top";
  601. if (array[index][5])
  602. path += (path === "" ? "" : "|") + "bottom";
  603. if (array[index][3])
  604. path += (path === "" ? "" : "|") + "left";
  605. if (array[index][7])
  606. path += (path === "" ? "" : "|") + "right";
  607. }
  608. return path;
  609. }
  610. }
  611. }
  612.  
  613. function afterPhenix(map) {
  614. for (let index = 0; index < pathData.length; index++) {
  615. if (map == pathData[index][0]) {
  616. return index;
  617. }
  618. }
  619. }
  620.  
  621. function gatherFigh(index) {
  622. var path = "";
  623. if (pathData[index][11])
  624. path = ", gather = true";
  625. if (pathData[index][12])
  626. path += ", fight = true";
  627. return path;
  628. }
  629.  
  630. function addGather() {
  631. let res = "";
  632. for (let index = 0; index < gatherData.length; index++) {
  633. let str = document.getElementById(gatherData[index]).outerHTML;
  634. let regex = /data-name=\"(.*?)\"/g;
  635. let matche = regex.exec(str);
  636. for (let i = 0; i < ressources.length; i++) {
  637. if (ressources[i][1] == matche[1]) {
  638. res += '\t' + ressources[i][0] + ',' + ' -- ' + ressources[i][1] + '\r\n';
  639. }
  640. }
  641. }
  642. return res;
  643. }
  644.  
  645. function havenbagCheck(option) {
  646. for (let index = 0; index < havenBagData.length; index++) {
  647. if (havenBagData[index][option]) {
  648. return true;
  649. }
  650. }
  651. return false;
  652. }
  653.  
  654. function generate() {
  655. var txt = "-- Generated On Dofus-Map with Drigtime's SwiftPath Script Maker --\r\n";
  656. txt += "GATHER = {\r\n";
  657. txt += addGather();
  658. txt += "} -- Les éléments à récolter\r\n" +
  659. "OPEN_BAGS = true -- Ouvrir les sacs de ressources au fur et à mesure\r\n" +
  660. "AUTO_DELETE = { } -- Les éléments à supprimer\r\n\r\n" +
  661. "MAX_MONSTERS = 8 -- Le nombre maximum de monstres dans un groupe à combattre.\r\n" +
  662. "MIN_MONSTERS = 1 -- Le nombre minimum de monstres dans un groupe à combattre.\r\n\r\n" +
  663. "FORBIDDEN_MONSTERS = { } -- Monstres interdits\r\n" +
  664. "FORCE_MONSTERS = { } -- Monstres obligatoires\r\n\r\n" +
  665. "MAX_COMBAT = 800 -- Nombre de combats maximum\r\n" +
  666. "\r\nfunction move()\r\n";
  667. if (havenbagCheck(2)) {
  668. txt += "\tif map:onMap(\"0,0\") then\r\n";
  669. firstIf = false;
  670. for (let index = 0; index < havenBagData.length; index++) {
  671. if (havenBagData[index][2]) {
  672. if (!firstIf) {
  673. txt += "\t\tif actualMap == \"" + havenBagData[index][0] + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index][1] + ")\")\r\n";
  674. firstIf = true;
  675. } else
  676. txt += "\t\telseif actualMap == \"" + havenBagData[index][0] + "\" then\r\n" +
  677. "\t\t\tmap:changeMap(\"zaap(" + havenBagData[0][1] + ")\")\r\n";
  678. }
  679. }
  680. txt += "\t\tend\r\n" +
  681. "\telse\r\n" +
  682. "\t\tactualMap = map:currentMap()\r\n" +
  683. "\tend\r\n";
  684. }
  685. txt += "\treturn {\r\n" +
  686. "\t\t{map = \"83887104\", path = \"396\"}, --Interieur banque Astrub vers Sortie--\r\n" +
  687. "\t\t{map = \"54534165\", path = \"424\"}, --Interieur banque Frigost vers Sortie--\r\n" +
  688. "\t\t{map = \"2885641\", path = \"424\"}, --Interieur banque Bonta vers Sortie--\r\n" +
  689. "\t\t{map = \"99095051\", path = \"410\"}, --Interieur banque Amakna vers Sortie--\r\n" +
  690. "\t\t{map = \"8912911\", path = \"424\"}, --Interieur banque Brakmar vers Sortie--\r\n" +
  691. "\t\t{map = \"91753985\", path = \"396\"}, --Interieur banque Sufokia vers Sortie (Non fait)--\r\n" +
  692. "\t\t{map = \"86511105\", door = \"452\"}, --Interieur banque Ottomaï vers Sortie--\r\n" +
  693. "\t\t{map = \"8129542\", path = \"409\"}, --Interieur banque Pandala vers Sortie--\r\n" +
  694. "\t\t{map = \"84935175\", path = \"425\"}, --Interieur banque Montagne Koalak vers Sortie--\r\n";
  695. for (let key in pathData) {
  696. txt += '\t\t{map = "' + pathData[key][0].replace(" ", "") + '", path = "' + pathGenerator(key, pathData) + '"' + gatherFigh(key) + '},\r\n';
  697. }
  698. txt += "\t}\r\nend\r\n\r\nfunction bank()\r\n";
  699. if (havenbagCheck(3)) {
  700. txt += "\tif map:onMap(\"0,0\") then\r\n";
  701. firstIf = false;
  702. for (let index = 0; index < havenBagData.length; index++) {
  703. if (havenBagData[index][3]) {
  704. if (!firstIf) {
  705. txt += "\t\tif actualMap == \"" + havenBagData[index][0] + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index][1] + ")\")\r\n";
  706. firstIf = true;
  707. } else
  708. txt += "\t\telseif actualMap == \"" + havenBagData[index][0] + "\" then\r\n" +
  709. "\t\t\tmap:changeMap(\"zaap(" + havenBagData[0][1] + ")\")\r\n";
  710. }
  711. }
  712. txt += "\t\tend\r\n" +
  713. "\telse\r\n" +
  714. "\t\tactualMap = map:currentMap()\r\n" +
  715. "\tend\r\n";
  716. }
  717. txt += "\treturn {\r\n";
  718. for (let key in bankData) {
  719. txt += '\t\t{map = "' + bankData[key][0].replace(" ", "") + '", path = "' + pathGenerator(key, bankData) + '"},\r\n';
  720. }
  721. txt += "\t\t{map = \"84674566\", door = \"303\"}, --Devant banque Astrub--\r\n" +
  722. "\t\t{map = \"83887104\", path = \"396\", npcBank = true}, --Banque Astrub--\r\n" +
  723. "\t\t{map = \"54172457\", door = \"358\"}, --Devant banque Frigost--\r\n" +
  724. "\t\t{map = \"54534165\", path = \"424\", npcBank = true}, --Banque Frigost--\r\n" +
  725. "\t\t{map = \"147254\", door = \"383\"}, --Devant banque Bonta--\r\n" +
  726. "\t\t{map = \"2885641\", path = \"424\", npcBank = true}, --Banque Bonta--\r\n" +
  727. "\t\t{map = \"88081177\", door = \"216\"}, --Devant banque Amakna--\r\n" +
  728. "\t\t{map = \"99095051\", path = \"410\", npcBank = true}, --Banque Amakna--\r\n" +
  729. "\t\t{map = \"144931\", door = \"248\"}, --Devant banque Brakmar--\r\n" +
  730. "\t\t{map = \"8912911\", path = \"424\", npcBank = true}, --Banque Brakmar--\r\n" +
  731. "\t\t{map = \"90703872\", door = \"302\"}, --Devant banque Sufokia --\r\n" +
  732. "\t\t{map = \"91753985\", path = \"494\", npcBank = true}, --Banque Sufokia--\r\n" +
  733. "\t\t{map = \"155157\", door = \"355\"}, --Devant banque Ottomaï--\r\n" +
  734. "\t\t{map = \"86511105\", door = \"452\", npcBank = true}, --Banque Ottomaï--\r\n" +
  735. "\t\t{map = \"12580\", door = \"284\"}, --Devant banque Pandala--\r\n" +
  736. "\t\t{map = \"8129542\", path = \"409\", npcBank = true}, --Banque Pandala--\r\n" +
  737. "\t\t{map = \"73400323\", door = \"330\"}, --Devant banque Montagne Koalak--\r\n" +
  738. "\t\t{map = \"84935175\", path = \"425\", npcBank = true}, --Banque Montagne Koalak--\r\n\t}\r\nend\r\n" +
  739. "\r\n\r\nfunction phenix()\r\n";
  740. if (havenbagCheck(4)) {
  741. txt += "\tif map:onMap(\"0,0\") then\r\n";
  742. firstIf = false;
  743. for (let index = 0; index < havenBagData.length; index++) {
  744. if (havenBagData[index][4]) {
  745. if (!firstIf) {
  746. txt += "\t\tif actualMap == \"" + havenBagData[index][0] + "\" then\r\n\t\t\tmap:changeMap(\"zaap(" + havenBagData[index][1] + ")\")\r\n";
  747. firstIf = true;
  748. } else
  749. txt += "\t\telseif actualMap == \"" + havenBagData[index][0] + "\" then\r\n" +
  750. "\t\t\tmap:changeMap(\"zaap(" + havenBagData[0][1] + ")\")\r\n";
  751. }
  752. }
  753. txt += "\t\tend\r\n" +
  754. "\telse\r\n" +
  755. "\t\tactualMap = map:currentMap()\r\n" +
  756. "\tend\r\n";
  757. }
  758. txt += "\treturn {\r\n";
  759. for (let key in phenixData) {
  760. txt += '\t\t{map = "' + phenixData[key][0].replace(" ", "") + '", path = "' + pathGenerator(key, phenixData) + '"},\r\n';
  761. }
  762. txt += "\t\t{map = \"12,12\", phenix = \"184\", path = \"" + pathGenerator(afterPhenix("12, 12"), pathData) + "\"},\r\n" +
  763. "\t\t{map = \"7,36\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("7, 36"), pathData) + "\"},\r\n" +
  764. "\t\t{map = \"22,22\", phenix = \"272\", path = \"" + pathGenerator(afterPhenix("22, 22"), pathData) + "\"},\r\n" +
  765. "\t\t{map = \"10,19\", phenix = \"192\", path = \"" + pathGenerator(afterPhenix("10, 19"), pathData) + "\"},\r\n" +
  766. "\t\t{map = \"5,1\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("5, 1"), pathData) + "\"},\r\n" +
  767. "\t\t{map = \"2,-1\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("2, -1"), pathData) + "\"},\r\n" +
  768. "\t\t{map = \"13,-7\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("13, -7"), pathData) + "\"},\r\n" +
  769. "\t\t{map = \"5,-9\", phenix = \"116\", path = \"" + pathGenerator(afterPhenix("5, -9"), pathData) + "\"},\r\n" +
  770. "\t\t{map = \"2,-12\", phenix = \"272\", path = \"" + pathGenerator(afterPhenix("2, -12"), pathData) + "\"},\r\n" +
  771. "\t\t{map = \"-6,-12\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-6, -12"), pathData) + "\"},\r\n" +
  772. "\t\t{map = \"36,10\", phenix = \"330\", path = \"" + pathGenerator(afterPhenix("36, 10"), pathData) + "\"},\r\n" +
  773. "\t\t{map = \"25,-4\", phenix = \"450\", path = \"" + pathGenerator(afterPhenix("25, -4"), pathData) + "\"},\r\n" +
  774. "\t\t{map = \"27,-33\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("27, -33"), pathData) + "\"},\r\n" +
  775. "\t\t{map = \"24,-43\", phenix = \"245\", path = \"" + pathGenerator(afterPhenix("24, -43"), pathData) + "\"},\r\n" +
  776. "\t\t{map = \"17,-36\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("17, -36"), pathData) + "\"},\r\n" +
  777. "\t\t{map = \"-13,-29\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-13, -29"), pathData) + "\"},\r\n" +
  778. "\t\t{map = \"-10,-54\", phenix = \"342\", path = \"" + pathGenerator(afterPhenix("-10, -54"), pathData) + "\"},\r\n" +
  779. "\t\t{map = \"-33,-56\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-33, -56"), pathData) + "\"},\r\n" +
  780. "\t\t{map = \"-10,13\", phenix = \"354\", path = \"" + pathGenerator(afterPhenix("-10, 13"), pathData) + "\"},\r\n" +
  781. "\t\t{map = \"-14,31\", phenix = \"243\", path = \"" + pathGenerator(afterPhenix("-14, 31"), pathData) + "\"},\r\n" +
  782. "\t\t{map = \"-26,34\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-26, 34"), pathData) + "\"},\r\n" +
  783. "\t\t{map = \"-26,36\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-26, 36"), pathData) + "\"},\r\n" +
  784. "\t\t{map = \"-55,40\", phenix = \"240\", path = \"" + pathGenerator(afterPhenix("-55, 40"), pathData) + "\"},\r\n" +
  785. "\t\t{map = \"-58,18\", phenix = \"354\", path = \"" + pathGenerator(afterPhenix("-58, 18"), pathData) + "\"},\r\n" +
  786. "\t\t{map = \"-60,-3\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-60, -3"), pathData) + "\"},\r\n" +
  787. "\t\t{map = \"-43,0\", phenix = \"259\", path = \"" + pathGenerator(afterPhenix("-43, 0"), pathData) + "\"},\r\n" +
  788. "\t\t{map = \"-41,-17\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-41, -17"), pathData) + "\"},\r\n" +
  789. "\t\t{map = \"-43,-19\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-43, -19"), pathData) + "\"},\r\n" +
  790. "\t\t{map = \"-53,-40\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-53, -40"), pathData) + "\"},\r\n" +
  791. "\t\t{map = \"-67,-44\", phenix = \"219\", path = \"" + pathGenerator(afterPhenix("-67 ,-44"), pathData) + "\"},\r\n" +
  792. "\t\t{map = \"-60,-79\", phenix = \"0\", path = \"" + pathGenerator(afterPhenix("-60, -79"), pathData) + "\"}\r\n\t}\r\nend\r\n";
  793.  
  794. saveTextAsFile(txt);
  795. }
  796.  
  797. function saveTextAsFile(txt) {
  798. var textToSaveAsBlob = new Blob([txt], {
  799. type: "text/plain"
  800. });
  801. var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
  802. if (document.getElementById('fileName').value == "") var fileNameToSaveAs = "Trajet.lua";
  803. else var fileNameToSaveAs = document.getElementById('fileName').value + ".lua";
  804. var downloadLink = document.createElement("a");
  805. downloadLink.download = fileNameToSaveAs;
  806. downloadLink.innerHTML = "Download File";
  807. downloadLink.href = textToSaveAsURL;
  808. downloadLink.style.display = "none";
  809. document.body.appendChild(downloadLink);
  810. downloadLink.click();
  811. }
  812.  
  813. function deletePath() {
  814. for (let index = 0; index < pathData.length; index) {
  815. if (pathData[index][2]) map.removeLayer(pathData[index][2]);
  816. if (pathData[index][4]) map.removeLayer(pathData[index][4]);
  817. if (pathData[index][6]) map.removeLayer(pathData[index][6]);
  818. if (pathData[index][8]) map.removeLayer(pathData[index][8]);
  819. if (pathData[index][10]) map.removeLayer(pathData[index][10]);
  820. pathData.splice(index, 1);
  821. }
  822. for (let index = 0; index < bankData.length; index) {
  823. if (bankData[index][2]) map.removeLayer(bankData[index][2]);
  824. if (bankData[index][4]) map.removeLayer(bankData[index][4]);
  825. if (bankData[index][6]) map.removeLayer(bankData[index][6]);
  826. if (bankData[index][8]) map.removeLayer(bankData[index][8]);
  827. if (bankData[index][10]) map.removeLayer(bankData[index][10]);
  828. bankData.splice(index, 1);
  829. }
  830. for (let index = 0; index < phenixData.length; index) {
  831. if (phenixData[index][2]) map.removeLayer(phenixData[index][2]);
  832. if (phenixData[index][4]) map.removeLayer(phenixData[index][4]);
  833. if (phenixData[index][6]) map.removeLayer(phenixData[index][6]);
  834. if (phenixData[index][8]) map.removeLayer(phenixData[index][8]);
  835. if (phenixData[index][10]) map.removeLayer(phenixData[index][10]);
  836. phenixData.splice(index, 1);
  837. }
  838. console.clear();
  839. }
  840.  
  841. function languageSelector(params) {
  842. switch (params) {
  843. case "fr":
  844. document.getElementById('top').innerHTML = 'Haut';
  845. document.getElementById('bottom').innerHTML = 'Bas';
  846. document.getElementById('left').innerHTML = 'Gauche';
  847. document.getElementById('right').innerHTML = 'Droite';
  848. document.getElementById('havenBag').innerHTML = 'Havre-sac';
  849. document.getElementById('tdgather').innerHTML = 'Récolte';
  850. document.getElementById('tdfight').innerHTML = 'Combat';
  851. document.getElementById('tdbank').innerHTML = 'Banque';
  852. document.getElementById('tdphoenix').innerHTML = 'Phenix';
  853. document.getElementById('tdMove').innerHTML = 'Deplacement';
  854. document.getElementById('restogather').innerText = 'Ressources à récolter :';
  855. document.getElementById('saveFile').innerText = 'Sauvegarder';
  856. document.getElementById('fileName').placeholder = 'Nom du fichier';
  857. document.getElementById('deletePath').innerText = 'Supprimer';
  858. document.getElementById('loadAFile').innerText = 'Charger';
  859. document.getElementById('languageDisplayer').classList.add('flag-icon-fr');
  860. document.getElementById('languageDisplayer').classList.remove('flag-icon-es');
  861. document.getElementById('languageDisplayer').classList.remove('flag-icon-gb');
  862. break;
  863. case "en":
  864. document.getElementById('top').innerHTML = 'Top';
  865. document.getElementById('bottom').innerHTML = 'Bottom';
  866. document.getElementById('left').innerHTML = 'Left';
  867. document.getElementById('right').innerHTML = 'Right';
  868. document.getElementById('havenBag').innerHTML = 'Haven bag';
  869. document.getElementById('tdgather').innerHTML = 'Gather';
  870. document.getElementById('tdfight').innerHTML = 'Fight';
  871. document.getElementById('tdbank').innerHTML = 'Bank';
  872. document.getElementById('tdphoenix').innerHTML = 'Phoenix';
  873. document.getElementById('tdMove').innerHTML = 'Move';
  874. document.getElementById('restogather').innerText = 'Resources to gather :';
  875. document.getElementById('saveFile').innerText = 'Save';
  876. document.getElementById('fileName').placeholder = 'Name of the file';
  877. document.getElementById('deletePath').innerText = 'Delete';
  878. document.getElementById('loadAFile').innerText = 'Load';
  879. document.getElementById('languageDisplayer').classList.remove('flag-icon-fr');
  880. document.getElementById('languageDisplayer').classList.remove('flag-icon-es');
  881. document.getElementById('languageDisplayer').classList.add('flag-icon-gb');
  882. break;
  883. case "es":
  884. document.getElementById('top').innerHTML = 'Arriba';
  885. document.getElementById('bottom').innerHTML = 'Abajo';
  886. document.getElementById('left').innerHTML = 'Izquierda';
  887. document.getElementById('right').innerHTML = 'Derecho';
  888. document.getElementById('havenBag').innerHTML = 'Merkasako';
  889. document.getElementById('tdgather').innerHTML = 'Cosecha';
  890. document.getElementById('tdfight').innerHTML = 'Lucha';
  891. document.getElementById('tdbank').innerHTML = 'Banco';
  892. document.getElementById('tdphoenix').innerHTML = 'Fénix';
  893. document.getElementById('tdMove').innerHTML = 'Desplazamiento';
  894. document.getElementById('restogather').innerText = 'Recursos para cosechar :';
  895. document.getElementById('saveFile').innerText = 'Salvar';
  896. document.getElementById('fileName').placeholder = 'Nombre del archivo';
  897. document.getElementById('deletePath').innerText = 'Borrar';
  898. document.getElementById('loadAFile').innerText = 'Carga';
  899. document.getElementById('languageDisplayer').classList.remove('flag-icon-fr');
  900. document.getElementById('languageDisplayer').classList.add('flag-icon-es');
  901. document.getElementById('languageDisplayer').classList.remove('flag-icon-gb');
  902. break;
  903. default:
  904. document.getElementById('top').innerHTML = 'Haut';
  905. document.getElementById('bottom').innerHTML = 'Bas';
  906. document.getElementById('left').innerHTML = 'Gauche';
  907. document.getElementById('right').innerHTML = 'Droite';
  908. document.getElementById('tdgather').innerHTML = 'Récolte';
  909. document.getElementById('tdfight').innerHTML = 'Combat';
  910. document.getElementById('tdbank').innerHTML = 'Banque';
  911. document.getElementById('tdphoenix').innerHTML = 'Phenix';
  912. document.getElementById('tdMove').innerHTML = 'Deplacement';
  913. document.getElementById('restogather').innerText = 'Ressources à récolter :';
  914. document.getElementById('saveFile').innerText = 'Sauvegarder';
  915. document.getElementById('fileName').placeholder = 'Nom du fichier';
  916. document.getElementById('deletePath').innerText = 'Supprimer';
  917. document.getElementById('loadAFile').innerText = 'Charger';
  918. document.getElementById('languageDisplayer').classList.add('flag-icon-fr');
  919. document.getElementById('languageDisplayer').classList.remove('flag-icon-es');
  920. document.getElementById('languageDisplayer').classList.remove('flag-icon-gb');
  921. break;
  922. }
  923. }
  924.  
  925. document.getElementById('file').onchange = function () {
  926.  
  927. var file = this.files[0];
  928. var content;
  929. var reader = new FileReader();
  930. reader.onload = function (progressEvent) {
  931. // Entire file
  932. content = this.result;
  933. let regexPath = /function move\(\)[\s\S]+?return.*?{\r\n([\s\S]+?)}\r\n.*end/g;
  934. let regexBank = /function bank\(\)[\s\S]+?return.*?{\r\n([\s\S]+?)}\r\n.*end/g;
  935. let regexPhenix = /function phenix\(\)[\s\S]+?return.*?{\r\n([\s\S]+?)}\r\n.*end/g;
  936. let result;
  937. let matche = regexBank.exec(content);
  938. loadingFile = true;
  939. document.getElementById("pathTop").checked = false;
  940. document.getElementById("pathLeft").checked = false;
  941. document.getElementById("pathBottom").checked = false;
  942. document.getElementById("pathRight").checked = false;
  943. document.getElementById("pathHavenBag").checked = false;
  944. if (matche !== null) {
  945. result = matche[1];
  946. result = result.split('\r\n');
  947. for (let index = 0; index < result.length; index++) {
  948. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  949. if (matche !== null) actualMap = matche[1];
  950. actualMap = actualMap.replace(/,/g, ", ");
  951. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  952. matche = /top/g.exec(result[index]);
  953. if (matche !== null) document.getElementById("pathTop").checked = true;
  954. matche = /left/g.exec(result[index]);
  955. if (matche !== null) document.getElementById("pathLeft").checked = true;
  956. matche = /bottom/g.exec(result[index]);
  957. if (matche !== null) document.getElementById("pathBottom").checked = true;
  958. matche = /right/g.exec(result[index]);
  959. if (matche !== null) document.getElementById("pathRight").checked = true;
  960. document.getElementById("bank").checked = true;
  961. onMapClick();
  962. document.getElementById("pathTop").checked = false;
  963. document.getElementById("pathLeft").checked = false;
  964. document.getElementById("pathBottom").checked = false;
  965. document.getElementById("pathRight").checked = false;
  966. }
  967. }
  968. }
  969. matche = regexPath.exec(content);
  970. if (matche !== null) {
  971. result = matche[1];
  972. result = result.split('\r\n');
  973. for (let index = 0; index < result.length; index++) {
  974. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  975. if (matche !== null) actualMap = matche[1];
  976. actualMap = actualMap.replace(/,/g, ", ");
  977. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  978. matche = /top/g.exec(result[index]);
  979. if (matche !== null) document.getElementById("pathTop").checked = true;
  980. matche = /left/g.exec(result[index]);
  981. if (matche !== null) document.getElementById("pathLeft").checked = true;
  982. matche = /bottom/g.exec(result[index]);
  983. if (matche !== null) document.getElementById("pathBottom").checked = true;
  984. matche = /right/g.exec(result[index]);
  985. if (matche !== null) document.getElementById("pathRight").checked = true;
  986. matche = /gather/g.exec(result[index]);
  987. if (matche !== null) document.getElementById("gather").checked = true;
  988. matche = /fight/g.exec(result[index]);
  989. if (matche !== null) document.getElementById("fight").checked = true;
  990. onMapClick();
  991. document.getElementById("pathTop").checked = false;
  992. document.getElementById("pathLeft").checked = false;
  993. document.getElementById("pathBottom").checked = false;
  994. document.getElementById("pathRight").checked = false;
  995. document.getElementById("gather").checked = false;
  996. document.getElementById("fight").checked = false;
  997. }
  998. }
  999. }
  1000. matche = regexPhenix.exec(content);
  1001. if (matche !== null) {
  1002. result = matche[1];
  1003. result = result.split('\r\n');
  1004. for (let index = 0; index < result.length; index++) {
  1005. matche = /map.?=.?"(.*?)"/g.exec(result[index]);
  1006. if (matche !== null) actualMap = matche[1];
  1007. actualMap = actualMap.replace(/,/g, ", ");
  1008. if (/(-|)[0-9]+?,\s(-|)[0-9]+?/g.exec(actualMap)) {
  1009. matche = /top/g.exec(result[index]);
  1010. if (matche !== null) document.getElementById("pathTop").checked = true;
  1011. matche = /left/g.exec(result[index]);
  1012. if (matche !== null) document.getElementById("pathLeft").checked = true;
  1013. matche = /bottom/g.exec(result[index]);
  1014. if (matche !== null) document.getElementById("pathBottom").checked = true;
  1015. matche = /right/g.exec(result[index]);
  1016. if (matche !== null) document.getElementById("pathRight").checked = true;
  1017. document.getElementById("phenix").checked = true;
  1018. onMapClick();
  1019. document.getElementById("pathTop").checked = false;
  1020. document.getElementById("pathLeft").checked = false;
  1021. document.getElementById("pathBottom").checked = false;
  1022. document.getElementById("pathRight").checked = false;
  1023. }
  1024. }
  1025. }
  1026. loadingFile = false;
  1027. };
  1028. reader.readAsText(file);
  1029. };
  1030.  
  1031. function keypressHandler(evt) {
  1032. var keyCode = evt.key;
  1033. switch (keyCode) {
  1034. case "z":
  1035. if (!document.getElementById("pathTop").checked)
  1036. document.getElementById("pathTop").checked = true;
  1037. else
  1038. document.getElementById("pathTop").checked = false;
  1039. break;
  1040. case "q":
  1041. if (!document.getElementById("pathLeft").checked)
  1042. document.getElementById("pathLeft").checked = true;
  1043. else
  1044. document.getElementById("pathLeft").checked = false;
  1045. break;
  1046. case "s":
  1047. if (!document.getElementById("pathBottom").checked)
  1048. document.getElementById("pathBottom").checked = true;
  1049. else
  1050. document.getElementById("pathBottom").checked = false;
  1051. break;
  1052. case "d":
  1053. if (!document.getElementById("pathRight").checked)
  1054. document.getElementById("pathRight").checked = true;
  1055. else
  1056. document.getElementById("pathRight").checked = false;
  1057. break;
  1058. default:
  1059. break;
  1060. }
  1061. }
  1062.  
  1063. setTimeout(function () {
  1064. $('#exampleModal').on('click', '.btn-primary', function () {
  1065. let e = document.getElementById("sel1");
  1066. var zaapMapid = e.options[e.selectedIndex].value;
  1067. if (document.getElementById('move').checked || document.getElementById('gather').checked || document.getElementById('fight').checked)
  1068. havenBagData.push([actualMap.split(", ")[0] + "," + actualMap.split(", ")[1], zaapMapid, true, false, false])
  1069. else if (document.getElementById('bank').checked)
  1070. havenBagData.push([actualMap.split(", ")[0] + "," + actualMap.split(", ")[1], zaapMapid, false, true, false])
  1071. else if (document.getElementById('phenix').checked)
  1072. havenBagData.push([actualMap.split(", ")[0] + "," + actualMap.split(", ")[1], zaapMapid, false, false, true])
  1073. $('#exampleModal').modal('hide');
  1074. onMapClick();
  1075. });
  1076. }, 500);
  1077.  
  1078. setTimeout(function () {
  1079. $('#exampleModal').on('click', '.btn-secondary', function () {
  1080. havenToggle = false;
  1081. $('#exampleModal').modal('hide');
  1082. });
  1083. }, 500);
  1084.  
  1085. setTimeout(function () {
  1086. $('#exampleModal').on('click', '.close', function () {
  1087. havenToggle = false;
  1088. $('#exampleModal').modal('hide');
  1089. });
  1090. }, 500);
  1091.  
  1092. map.on('click', onMapClick);
  1093. document.addEventListener("keypress", keypressHandler, false);
  1094. })();