Tout_MZ

Client MountyZilla

当前为 2016-09-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @version 1.2.3.1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. // vérif UTF-8 éê
  11.  
  12. /*******************************************************************************
  13. * This file is part of Mountyzilla. *
  14. * *
  15. * Mountyzilla is free software; you can redistribute it and/or modify *
  16. * it under the terms of the GNU General Public License as published by *
  17. * the Free Software Foundation; either version 2 of the License, or *
  18. * (at your option) any later version. *
  19. * *
  20. * Mountyzilla is distributed in the hope that it will be useful, *
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  23. * GNU General Public License for more details. *
  24. * *
  25. * You should have received a copy of the GNU General Public License *
  26. * along with Mountyzilla; if not, write to the Free Software *
  27. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  28. *******************************************************************************/
  29.  
  30. // V1.1 : regroupement en un gros paquet sale
  31. // V1.2 : toujours un gros paquet sale, passage sous Greasemonkey
  32. // V1.2.1 :
  33. // include des URLs MH alternatives
  34. // regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose
  35. // Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte
  36. // V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues
  37. // V1.2.3 :
  38. // suppression ancien profil
  39. // nettoyage doublon sur getPortee
  40. // adaptation portee TP basée sur les PI
  41. // repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)
  42.  
  43. // URLs externes images (pas de souci CORS)
  44. const URL_MZimg09 = 'http://mountyzilla.tilk.info/scripts_0.9/images/';
  45. const URL_MZimg11 = 'http://mountyzilla.tilk.info/scripts_1.1/images/'
  46. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  47.  
  48. // URLs externes redirection (pas de souci CORS)
  49. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  50. const URL_MZmountyhall = 'http://trolls.ratibus.net/mountyhall/';
  51. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  52. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  53. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  54. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  55. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  56. const URL_ratibus_lien = 'http://trolls.ratibus.net/';
  57. const URL_tilk_js = 'http://mountyzilla.tilk.info/scripts/';
  58. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  59. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  60.  
  61. // URLs externes ajax (nécessite l'entête CORS, solution actuelle : passage chez raistlin)
  62. var URL_MZinfoMonstre = 'http://cdm.mh.raistlin.fr/mz/monstres_0.9_FF.php'; // redirigé vers mountypedia.free.fr
  63. var URL_MZinfoMonstrePost = 'http://cdm.mh.raistlin.fr/mz/monstres_0.9_post_FF.php'; // redirigé vers mountypedia.free.fr
  64. // pour passer en mode IP, commenter les 2 lignes précédentes et décommenter les 2 suivantes
  65. //var URL_MZinfoMonstre = 'http://192.99.225.92/mz/monstres_0.9_FF.php';
  66. //var URL_MZinfoMonstrePost = 'http://192.99.225.92/mz/monstres_0.9_post_FF.php';
  67. // ceux-ci rendent bien les 2 entêtes CORS
  68. const URL_anniv = 'http://mountyzilla.tilk.info/scripts/anniv.php'; // Url de récup des jubilaires:
  69. const URL_rss = 'http://mountyzilla.tilk.info/news/rss.php'; // Flux RSS des news MZ
  70. const URL_trooglebeta = 'http://troogle-beta.aacg.be/view_submission';
  71. // cette URL ne rend pas le 2e entête CORS (peut-être pas grave car il s'agit de l'envoi des CdM, on ignore la réponse)
  72. const URL_pageDispatcher = "http://mountypedia.ratibus.net/mz/cdmdispatcher.php";
  73.  
  74. // x~x Libs
  75.  
  76. /* TODO
  77. * - revoir la gestion des CdM --> nott armure magique
  78. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  79. * - vérfier la gestion des enchants
  80. */
  81.  
  82. // Roule 04/09/2016 switch extern URLs to https if available
  83. var isHTTPS = false;
  84. if ( window.location.protocol.indexOf('https') === 0) {
  85. URL_MZinfoMonstre = URL_MZinfoMonstre.replace(/http:\/\//, 'https://');
  86. URL_MZinfoMonstrePost = URL_MZinfoMonstrePost.replace(/http:\/\//, 'https://');
  87. isHTTPS = true;
  88. }
  89. var MHicons = '/mountyhall/Images/Icones/';
  90. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  91. var MY_DEBUG = false;
  92.  
  93. /* remplacement fonction MZ */
  94. function MY_getValue(key) {
  95. return window.localStorage[key];
  96. }
  97.  
  98. function MY_removeValue(key) {
  99. window.localStorage.removeItem(key);
  100. }
  101.  
  102. function MY_setValue(key, val) {
  103. window.localStorage[key] = val;
  104. }
  105.  
  106. /*---------------- mise à jour de variables globales utiles ------------------*/
  107. // utilisé pour accès bdd (un peu partout) :
  108. var numTroll = MY_getValue('NUM_TROLL');
  109. // utilisé dans vue pour PX :
  110. var nivTroll = MY_getValue('NIV_TROLL');
  111. // utilisés dans actions et vue (calculs SR) :
  112. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  113. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  114.  
  115. /* DEBUG: NETTOYAGE TAGS */
  116. if(MY_getValue(numTroll+'.TAGSURL')) {
  117. MY_removeValue(numTroll+'.TAGSURL');
  118. }
  119.  
  120. /*-[functions]------------ Fonctions durée de script -------------------------*/
  121. var date_debut = null;
  122.  
  123. function start_script(nbJours_exp) {
  124. if(date_debut) return;
  125. date_debut = new Date();
  126. // Créé la variable expdate si demandé
  127. if(nbJours_exp) {
  128. expdate = new Date();
  129. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  130. }
  131. }
  132.  
  133. function displayScriptTime() {
  134. var footerNode = document.getElementById('footer2');
  135. if(!footerNode) return;
  136. try{
  137. var node = document.evaluate(
  138. ".//text()[contains(.,'Page générée en')]/../br",
  139. footerNode,null,9,null).singleNodeValue;
  140. }
  141. catch(e){return;}
  142. insertText(node,
  143. ' - [Script exécuté en '
  144. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  145. }
  146.  
  147. /*---------- regroupement des getPortee() ------------------------------------*/
  148. // issu des script profil et profil2
  149. function getPortee__Profil(param) {
  150. param = Math.max(0,Number(param));
  151. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  152. // ça devrait être floor, +10.25, -2.5
  153. }
  154.  
  155. // issu du script vue
  156. function getPortee__Vue(param) {
  157. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  158. }
  159.  
  160. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  161.  
  162. function debugMZ(str){
  163. if(MY_DEBUG){
  164. window.console.debug('[MY_DEBUG] '+str);
  165. if(typeof str === "object"){
  166. window.console.debug(str);
  167. }
  168. }
  169. }
  170.  
  171. function FF_XMLHttpRequest(MY_XHR_Ob) {
  172. var request = new XMLHttpRequest();
  173. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  174. for(var head in MY_XHR_Ob.headers) {
  175. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  176. }
  177. request.onreadystatechange = function() {
  178. if(request.readyState!=4) { return; }
  179. if(request.error) {
  180. if(MY_XHR_Ob.onerror) {
  181. MY_XHR_Ob.onerror(request);
  182. }
  183. }
  184. else if(MY_XHR_Ob.onload) {
  185. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  186. MY_XHR_Ob.onload(request);
  187. }
  188. };
  189. request.send(MY_XHR_Ob.data);
  190. }
  191.  
  192.  
  193. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  194.  
  195. function avertissement(txt,duree) {
  196. if(!duree) { duree = 5000; }
  197. var div = document.createElement('div');
  198. // On numérote les avertissements pour destruction sélective
  199. var num = document.getElementsByName('avertissement').length;
  200. div.num = num;
  201. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  202. div.setAttribute('name','avertissement');
  203. div.className = 'mh_textbox';
  204. div.style =
  205. 'position:fixed;'+
  206. 'top:'+(10+15*num)+'px;'+
  207. 'left:'+(10+5*num)+'px;'+
  208. 'border:1px solid #000000;'+
  209. 'z-index:'+(2+num)+';'+
  210. 'cursor:crosshair;';
  211. div.innerHTML = txt;
  212. div.onclick=function(){ tueAvertissement(this.num) };
  213. document.body.appendChild(div);
  214. // Destruction automatique de l'avertissement après 3 sec :
  215. window.setTimeout(function(){ tueAvertissement(num) },duree);
  216. }
  217.  
  218. function tueAvertissement(num) {
  219. var divs = document.getElementsByName('avertissement');
  220. if(divs.length==0) { return; }
  221. for(var i=0 ; i<divs.length ; i++) {
  222. if(divs[i].num==num) {
  223. divs[i].parentNode.removeChild(divs[i]);
  224. return;
  225. }
  226. }
  227. }
  228.  
  229.  
  230. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  231.  
  232. function insertBefore(next,el) {
  233. next.parentNode.insertBefore(el,next);
  234. }
  235.  
  236. function appendTr(tbody,clas) {
  237. var tr = document.createElement('tr');
  238. if(clas) tr.className = clas;
  239. tbody.appendChild(tr);
  240. return tr;
  241. }
  242.  
  243. function insertTr(next,clas) {
  244. var tr = document.createElement('tr');
  245. if(clas) tr.className = clas;
  246. insertBefore(next,tr);
  247. return tr;
  248. }
  249.  
  250. function appendTd(tr) {
  251. var td = document.createElement('td');
  252. if(tr) tr.appendChild(td);
  253. return td;
  254. }
  255.  
  256. function insertTd(next) {
  257. var td = document.createElement('td');
  258. insertBefore(next,td);
  259. return td;
  260. }
  261.  
  262. function appendTdCenter(tr,colspan) {
  263. var td = appendTd(tr);
  264. td.align = 'center'; // WARNING - Obsolete
  265. if(colspan) td.colSpan = colspan;
  266. return td;
  267. }
  268.  
  269. function insertTdElement(next,el) {
  270. var td = insertTd(next);
  271. if(el) td.appendChild(el);
  272. return td;
  273. }
  274.  
  275. function appendText(paren,text,bold) {
  276. if(bold) {
  277. var b = document.createElement('b');
  278. b.appendChild(document.createTextNode(text));
  279. paren.appendChild(b);
  280. }
  281. else
  282. paren.appendChild(document.createTextNode(text));
  283. }
  284.  
  285. function insertText(next,text,bold) {
  286. if(bold) {
  287. var b = document.createElement('b');
  288. appendText(b,text);
  289. insertBefore(next,b);
  290. }
  291. else
  292. insertBefore(next,document.createTextNode(text));
  293. }
  294.  
  295. function appendTdText(tr,text,bold) {
  296. var td = appendTd(tr);
  297. appendText(td,text,bold);
  298. return td;
  299. }
  300.  
  301. function insertTdText(next,text,bold) {
  302. var td = insertTd(next);
  303. appendText(td,text,bold);
  304. return td;
  305. }
  306.  
  307. function appendBr(paren) {
  308. paren.appendChild(document.createElement('br'));
  309. }
  310.  
  311. function insertBr(next) {
  312. insertBefore(next,document.createElement('br'));
  313. }
  314.  
  315. function appendLI(ul,text) {
  316. // uniquement utilisé dans les options (crédits)
  317. var li = document.createElement('li');
  318. appendText(li,text);
  319. ul.appendChild(li);
  320. return li;
  321. }
  322.  
  323. function appendTextbox(paren,type,nam,size,maxlength,value) {
  324. var input = document.createElement('input');
  325. input.className = 'TextboxV2';
  326. input.type = type;
  327. input.name = nam;
  328. input.id = nam;
  329. input.size = size;
  330. input.maxLength = maxlength;
  331. if(value) input.value = value;
  332. paren.appendChild(input);
  333. return input;
  334. }
  335.  
  336. function appendCheckBox(paren,nam,checked,onClick) {
  337. var input = document.createElement('input');
  338. input.type = 'checkbox';
  339. input.name = nam;
  340. input.id = nam;
  341. if(checked) input.checked = true;
  342. if(onClick) input.onclick = onClick;
  343. paren.appendChild(input);
  344. return input;
  345. }
  346.  
  347. function appendNobr(paren,id,delgg,text) {
  348. var nobr = document.createElement('nobr');
  349. appendCheckBox(nobr,id,null,delgg);
  350. appendText(nobr,text);
  351. paren.appendChild(nobr);
  352. appendText(paren,' ');
  353. return nobr;
  354. }
  355.  
  356. function appendCheckBoxSpan(paren,id,onClick,text) {
  357. var span = document.createElement('span');
  358. span.style.whiteSpace = 'nowrap';
  359. appendCheckBox(span,id,false,onClick);
  360. appendText(span,text);
  361. paren.appendChild(span);
  362. appendText(paren,' ');
  363. return span;
  364. }
  365.  
  366. function appendOption(select,value,text) {
  367. var option = document.createElement('option');
  368. option.value = value;
  369. appendText(option,text);
  370. select.appendChild(option);
  371. return option;
  372. }
  373.  
  374. function appendHidden(form,nam,value) {
  375. var input = document.createElement('input');
  376. input.type = 'hidden';
  377. input.name = nam;
  378. input.id = nam;
  379. input.value = value;
  380. form.appendChild(input);
  381. }
  382.  
  383. function appendButton(paren,value,onClick) {
  384. var input = document.createElement('input');
  385. input.type = 'button';
  386. input.className = 'mh_form_submit';
  387. input.value = value;
  388. input.onmouseover = function(){this.style.cursor='pointer';};
  389. if(onClick) input.onclick = onClick;
  390. paren.appendChild(input);
  391. return input;
  392. }
  393.  
  394. function insertButton(next,value,onClick) {
  395. var input = document.createElement('input');
  396. input.type = 'button';
  397. input.className = 'mh_form_submit';
  398. input.value = value;
  399. input.onmouseover = function(){this.style.cursor='pointer';};
  400. input.onclick = onClick;
  401. insertBefore(next,input);
  402. return input;
  403. }
  404.  
  405. function appendSubmit(paren,value,onClick) {
  406. var input = document.createElement('input');
  407. input.type = 'submit';
  408. input.className = 'mh_form_submit';
  409. input.value = value;
  410. input.onmouseover = function(){this.style.cursor='pointer';};
  411. if(onClick) input.onclick = onClick;
  412. paren.appendChild(input);
  413. return input;
  414. }
  415.  
  416. function createImage(url,title) {
  417. var img = document.createElement('img');
  418. img.src = url;
  419. img.title = title;
  420. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  421. return img;
  422. }
  423.  
  424. function createAltImage(url,alt,title) {
  425. var img = document.createElement('img');
  426. img.src = url;
  427. img.alt = alt;
  428. img.title = title;
  429. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  430. return img;
  431. }
  432.  
  433. function createImageSpan(url,alt,title,text,bold) {
  434. var span = document.createElement('span');
  435. span.title = title;
  436. var img = document.createElement('img');
  437. img.src = url;
  438. img.alt = alt;
  439. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  440. span.appendChild(img);
  441. appendText(span,text,bold);
  442. return span;
  443. }
  444.  
  445. function createCase(titre,table,width) {
  446. if(!width) width=120;
  447. var tr = appendTr(table,'mh_tdpage');
  448. var td = appendTdText(tr,titre,true);
  449. td.className = 'mh_tdtitre';
  450. td.width = width;
  451. td = appendTdText(tr,'');
  452. td.className = 'mh_tdpage';
  453. return td;
  454. }
  455.  
  456. function getMyID(e) {
  457. var parent = e.parentNode;
  458. for(var i=0 ; i<parent.childNodes.length ; i++) {
  459. if(e==parent.childNodes[i])
  460. return i;
  461. }
  462. return -1;
  463. }
  464.  
  465. function insertAfter(elt,newElt) {
  466. var id = getMyID(elt);
  467. if(id==-1) return;
  468. if(id<elt.parentNode.childNodes.length-1)
  469. insertBefore(elt.nextSibling,newElt);
  470. else
  471. elt.parentNode.appendChild(newElt);
  472. }
  473.  
  474.  
  475. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  476.  
  477. function aff(nb) {
  478. return (nb>=0) ? '+'+nb : nb;
  479. }
  480.  
  481. function getNumber(str) {
  482. var nbr = str.match(/\d+/);
  483. return nbr ? Number(nbr[0]) : Number.NaN;
  484. }
  485.  
  486. function getNumbers(str) {
  487. var nbrs = str.match(/-?\d+/g);
  488. for(var i=0 ; i<nbrs.length ; i++)
  489. nbrs[i] = Number(nbrs[i]);
  490. return nbrs;
  491. }
  492.  
  493. function trim(str) {
  494. return str.replace(/(^\s*)|(\s*$)/g,'');
  495. }
  496.  
  497. String.prototype.trim = function() {
  498. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  499. }
  500.  
  501. function epure(texte) {
  502. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  503. .replace(/[ç]/g,'c')
  504. .replace(/[éêèë]/g,'e')
  505. .replace(/[ïî]/g,'i')
  506. .replace(/[ôöõ]/g,'o')
  507. .replace(/[ùûü]/g,'u');
  508. }
  509.  
  510. String.prototype.epure = function () {
  511. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  512. .replace(/[ç]/g,'c')
  513. .replace(/[éêèë]/g,'e')
  514. .replace(/[ïî]/g,'i')
  515. .replace(/[ôöõ]/g,'o')
  516. .replace(/[ùûü]/g,'u');
  517. }
  518.  
  519. function bbcode(texte) {
  520. return texte.replace(/&/g,'&amp;')
  521. .replace(/"/g,'&quot;')
  522. .replace(/</g,'&lt;')
  523. .replace(/>/g,'&gt;')
  524. .replace(/'/g,'&#146;')
  525. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  526. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  527. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  528. }
  529.  
  530.  
  531. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  532.  
  533. function addZero(i) {
  534. return (i<10) ? '0'+i : i;
  535. }
  536.  
  537. function DateToString(date) {
  538. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  539. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  540. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  541. }
  542.  
  543. function StringToDate(str) {
  544. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  545. }
  546.  
  547.  
  548. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  549.  
  550. function getPXKill(niv) {
  551. return Math.max(0,10+3*niv-2*nivTroll);
  552. }
  553.  
  554. function getPXDeath(niv) {
  555. return Math.max(0,10+3*nivTroll-2*niv);
  556. }
  557.  
  558. function analysePX(niv) {
  559. niv = niv+'';
  560. var i = niv.indexOf('+');
  561. if(i!=-1) // si niv = 'XX+' ??
  562. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  563. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  564. if(i!=-1) {
  565. var max = getPXKill(niv.slice(i+2));
  566. if(max==0)
  567. return ' --> <b>0</b> PX';
  568. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  569. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  570. }
  571. i = niv.indexOf('='); // ???
  572. if(i!=-1) {
  573. var max = getPXKill(niv.slice(i+1));
  574. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  575. }
  576. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  577. }
  578.  
  579. function analysePXTroll(niv) {
  580. var str = analysePX(niv);
  581. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  582. return str;
  583. }
  584.  
  585.  
  586. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  587. // Refonte totale du code de Zorya
  588.  
  589. // Elements à implémenter en dur dans MZ2.0
  590. var numQualite = {
  591. 'Très Mauvaise':1,
  592. 'Mauvaise':2,
  593. 'Moyenne':3,
  594. 'Bonne':4,
  595. 'Très Bonne':5
  596. };
  597.  
  598. var qualiteNum = [
  599. '_dummy_',
  600. 'Très Mauvaise',
  601. 'Mauvaise',
  602. 'Moyenne',
  603. 'Bonne',
  604. 'Très Bonne'
  605. ];
  606.  
  607. var nival = {
  608. 'Abishaii Bleu':19,
  609. 'Abishaii Noir':10,
  610. 'Abishaii Rouge':23,
  611. 'Abishaii Vert':15,
  612. 'Ame-en-peine':8,
  613. 'Amibe Geante':9,
  614. 'Anaconda des Catacombes':8,
  615. 'Ankheg':10,
  616. 'Anoploure Purpurin':36,
  617. 'Araignee Geante':2,
  618. 'Ashashin':35,
  619. 'Balrog':50,
  620. 'Banshee':16,
  621. 'Barghest':36,
  622. 'Basilisk':11,
  623. 'Behemoth':34,
  624. 'Behir':14,
  625. 'Beholder':50,
  626. 'Boggart':3,
  627. 'Bondin':9,
  628. "Bouj'Dla Placide":37,
  629. "Bouj'Dla":19,
  630. 'Bulette':19,
  631. 'Caillouteux':1,
  632. 'Capitan':35,
  633. 'Carnosaure':25,
  634. 'Champi-Glouton':3,
  635. 'Chauve-Souris Geante':4,
  636. 'Cheval a Dents de Sabre':23,
  637. 'Chevalier du Chaos':20,
  638. 'Chimere':13,
  639. 'Chonchon':24,
  640. 'Coccicruelle':22,
  641. 'Cockatrice':5,
  642. 'Crasc Medius':17,
  643. 'Crasc Maexus':25,
  644. 'Crasc':10,
  645. 'Croquemitaine':6,
  646. 'Cube Gelatineux':32,
  647. 'Daemonite':27,
  648. 'Diablotin':5,
  649. 'Dindon du Chaos':1,
  650. 'Djinn':29,
  651. 'Ectoplasme':18,
  652. 'Effrit':27,
  653. "Elementaire d'Air":23,
  654. "Elementaire d'Eau":17,
  655. 'Elementaire de Feu':21,
  656. 'Elementaire de Terre':21,
  657. 'Elementaire du Chaos':26,
  658. 'Erinyes':7,
  659. 'Esprit-Follet':16,
  660. 'Essaim Craterien':30,
  661. 'Essaim Sanguinaire':25,
  662. 'Ettin':8,
  663. 'Familier':1,
  664. 'Fantome':24,
  665. 'Feu Follet':20,
  666. 'Flagelleur Mental':33,
  667. 'Foudroyeur':38,
  668. 'Fumeux':22,
  669. 'Fungus Geant':9,
  670. 'Fungus Violet':4,
  671. 'Furgolin':10,
  672. 'Gargouille':3,
  673. 'Geant de Pierre':13,
  674. 'Geant des Gouffres':22,
  675. "Geck'oo Majestueux":40,
  676. "Geck'oo":15,
  677. 'Glouton':20,
  678. 'Gnoll':5,
  679. 'Gnu Domestique':1,
  680. 'Gnu Sauvage':1,
  681. 'Goblin':4,
  682. 'Goblours':4,
  683. "Golem d'Argile":15,
  684. 'Golem de cuir':1,
  685. 'Golem de Chair':8,
  686. 'Golem de Fer':31,
  687. 'Golem de mithril':1,
  688. 'Golem de metal':1,
  689. 'Golem de papier':1,
  690. 'Golem de Pierre':23,
  691. 'Gorgone':11,
  692. 'Goule':4,
  693. 'Gowap Apprivoise':1,
  694. 'Gowap Sauvage':1,
  695. 'Gremlins':3,
  696. 'Gritche':39,
  697. 'Grouilleux':4,
  698. 'Grylle':31,
  699. 'Harpie':4,
  700. 'Hellrot':18,
  701. 'Homme-Lezard':4,
  702. 'Hurleur':8,
  703. 'Hydre':50,
  704. 'Incube':13,
  705. 'Kobold':2,
  706. 'Labeilleux':26,
  707. 'Lezard Geant':5,
  708. 'Liche':50,
  709. 'Limace Geante':10,
  710. 'Loup-Garou':8,
  711. 'Lutin':4,
  712. 'Mante Fulcreuse':30,
  713. 'Manticore':9,
  714. 'Marilith':33,
  715. 'Meduse':6,
  716. 'Megacephale':38,
  717. 'Mille-Pattes Geant':14,
  718. 'Mimique':6,
  719. 'Minotaure':7,
  720. 'Molosse Satanique':8,
  721. 'Momie':4,
  722. 'Monstre Rouilleur':3,
  723. "Mouch'oo Domestique":14,
  724. "Mouch'oo Majestueux Sauvage":33,
  725. "Mouch'oo Sauvage":14,
  726. 'Na-Haniym-Heee':0,
  727. 'Necrochore':37,
  728. 'Necromant':39,
  729. 'Necrophage':8,
  730. 'Naga':10,
  731. 'Nuee de Vermine':13,
  732. "Nuage d'Insectes":7,
  733. 'Ogre':7,
  734. 'Ombre de Roches':13,
  735. 'Ombre':2,
  736. 'Orque':3,
  737. 'Ours-Garou':18,
  738. 'Palefroi Infernal':29,
  739. 'Phoenix':32,
  740. 'Pititabeille':0,
  741. 'Plante Carnivore':4,
  742. 'Pseudo-Dragon':5,
  743. 'Rat Geant':2,
  744. 'Rat-Garou':3,
  745. 'Rocketeux':5,
  746. 'Sagouin':3,
  747. 'Scarabee Geant':4,
  748. 'Scorpion Geant':10,
  749. 'Shai':28,
  750. 'Sirene':8,
  751. 'Slaad':5,
  752. 'Sorciere':17,
  753. 'Spectre':14,
  754. 'Sphinx':30,
  755. 'Squelette':1,
  756. 'Strige':2,
  757. 'Succube':13,
  758. 'Tertre Errant':20,
  759. 'Thri-kreen':10,
  760. 'Tigre-Garou':12,
  761. 'Titan':26,
  762. 'Trancheur':35,
  763. 'Tubercule Tueur':14,
  764. 'Tutoki':4,
  765. 'Vampire':29,
  766. 'Ver Carnivore Geant':12,
  767. 'Ver Carnivore':11,
  768. 'Veskan Du Chaos':14,
  769. 'Vouivre':33,
  770. 'Worg':5,
  771. 'Xorn':14,
  772. 'Yeti':8,
  773. 'Yuan-ti':15,
  774. 'Zombie':2
  775. }
  776.  
  777. var tabEM = {
  778. //Monstre: [Compo exact, Sort, Position, Localisation]
  779. // AA
  780. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  781. // AE
  782. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  783. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  784. // AdA
  785. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  786. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  787. // AdE
  788. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  789. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  790. // AdD
  791. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  792. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  793. // BAM
  794. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  795. // BuM
  796. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  797. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  798. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  799. // Explo
  800. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  801. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  802. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  803. // FP
  804. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  805. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  806. // FA
  807. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  808. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  809. // Glue
  810. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  811. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  812. // GdS
  813. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  814. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  815. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  816. // Invi
  817. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  818. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  819. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  820. // Lévitation
  821. // ???
  822. // PréM :
  823. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  824. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  825. // Proj
  826. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  827. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  828. // PuM :
  829. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  830. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  831. // Sacro
  832. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  833. // Télék
  834. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  835. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  836. // TP
  837. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  838. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  839. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  840. // VA
  841. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  842. // VL
  843. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  844. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  845. // VlC
  846. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  847. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  848. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  849. // VT
  850. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  851. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  852. // Variables
  853. 'Rat':["d'un"],
  854. 'Rat Géant':["d'un"],
  855. 'Dindon':["d'un"],
  856. 'Goblin':["d'un"],
  857. 'Limace':["d'une"],
  858. 'Limace Géante':["d'une"],
  859. 'Ver':["d'un"],
  860. 'Ver Carnivore':["d'un"],
  861. 'Ver Carnivore Géant':["d'un"],
  862. 'Fungus':["d'un"],
  863. 'Vouivre':["d'une"],
  864. 'Gnu':["d'un"],
  865. 'Scarabée':["d'un"]
  866. };
  867.  
  868. var mundiChampi = {
  869. 'Préscientus Reguis':'du Phoenix',
  870. 'Amanite Trolloïde':'de la Mouche',
  871. 'Girolle Sanglante':'du Dindon',
  872. 'Horreur Des Prés':'du Gobelin',
  873. 'Bolet Péteur':'du Démon',
  874. 'Pied Jaune':'de la Limace',
  875. 'Agaric Sous-Terrain':'du Rat',
  876. 'Suinte Cadavre':"de l'Hydre",
  877. 'Cèpe Lumineux':'du Ver',
  878. 'Fungus Rampant':'du Fungus',
  879. 'Nez Noir':'de la Vouivre',
  880. 'Pleurote Pleureuse':'du Gnu',
  881. 'Phytomassus Xilénique':'du Scarabée'
  882. };
  883.  
  884. function addInfoMM(node,mob,niv,qualite,effetQ) {
  885. appendText(node,' ');
  886. var urlImg = URL_MZimg11
  887. +'Competences/melangeMagique.png';
  888. var text = ' [-'+(niv+effetQ)+' %]';
  889. var str = '';
  890. switch(mob[0]) {
  891. case 'A':
  892. case 'E':
  893. case 'I':
  894. case 'O':
  895. case 'U':
  896. str = "Compo d'";
  897. break;
  898. default:
  899. str = 'Compo de ';
  900. }
  901. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  902. var span = createImageSpan(urlImg,'MM:',title,text);
  903. node.appendChild(span);
  904. }
  905. function addInfoEM(node,mob,compo,qualite,localisation) {
  906. if(!tabEM[mob]) return;
  907. var title = 'Composant variable', texte = 'Variable';
  908. var bold = false;
  909. if(tabEM[mob].length>1) {
  910. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  911. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  912. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  913. if(pc<-20) return;
  914. if(pc>=0) bold = true;
  915. texte = aff(pc)+'%';
  916. title = texte+" pour l'écriture de "+tabEM[mob][1];
  917. }
  918. var urlImg = URL_MZimg09
  919. +'Competences/ecritureMagique.png';
  920. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  921. node.appendChild(span);
  922. }
  923.  
  924. function insererInfosEM(tbody) {
  925. // lancé par equip, equipgowap
  926. var trCompos = document.evaluate(
  927. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  928. tbody,null,7,null);
  929. var strCompos = '';
  930. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  931. var node = trCompos.snapshotItem(i).childNodes[7];
  932. var str = node.firstChild.textContent;
  933. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  934. var mob = trim(str.slice(str.indexOf("d'un")+5));
  935. // Si non-EM on stoppe le traitement
  936. if(!tabEM[mob]) continue;
  937. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  938. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  939. var localisation = trim(str.slice(0,str.indexOf(' |')));
  940. addInfoEM(node,mob,compo,qualite,localisation);
  941. }
  942. }
  943.  
  944. function getQualite(qualite) {
  945. var nb = numQualite[qualite];
  946. return nb ? nb-1 : -1;
  947. }
  948.  
  949. function getEM(nom) {
  950. if(nom.indexOf('[')!=-1)
  951. nom = trim(nom.substring(0,nom.indexOf('[')));
  952. if(tabEM[nom]) return nom;
  953. return '';
  954. }
  955.  
  956. // DEBUG ex-fonction composantEM
  957. function compoMobEM(mob) {
  958. if(!tabEM[mob]) return '';
  959. if(tabEM[mob].length==1)
  960. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  961. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  962. +") pour l'écriture de "+tabEM[mob][1];
  963. }
  964.  
  965. // DEBUG ex-fonction compoEM
  966. function titreCompoEM(mob,compo,localisation,qualite) {
  967. if(!tabEM[mob]) return '';
  968. if(tabEM[mob].length==1) return 'Composant variable';
  969. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  970. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  971. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  972. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  973. return '';
  974. }
  975.  
  976. // DEBUG - rétrocompatibilité
  977. function compoEM(mob) {
  978. // appelé dans libs, vue
  979. return compoMobEM(mob);
  980. }
  981. function composantEM(mob,compo,localisation,qualite) {
  982. // appelé dans libs, tancompo
  983. return titreCompoEM(mob,compo,localisation,qualite);
  984. }
  985. //
  986.  
  987.  
  988. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  989.  
  990. arrayTalents = {
  991. /* Compétences */
  992. 'Acceleration du Metabolisme':'AM',
  993. 'Attaque Precise':'AP',
  994. 'Balayage':'Balayage',
  995. //'Balluchonnage':'Ballu',
  996. 'Baroufle':'Baroufle',
  997. 'Bidouille':'Bidouille',
  998. 'Botte Secrete':'BS',
  999. 'Camouflage':'Camou',
  1000. 'Charger':'Charger',
  1001. 'Connaissance des Monstres':'CdM',
  1002. 'Construire un Piege':'Piege',
  1003. 'Piege a Feu':'PiegeFeu',
  1004. 'Piege a Glue':'PiegeGlue',
  1005. 'Contre-Attaquer':'CA',
  1006. 'Coup de Butoir':'CdB',
  1007. 'Course':'Course',
  1008. 'Deplacement Eclair':'DE',
  1009. 'Dressage':'Dressage',
  1010. 'Ecriture Magique':'EM',
  1011. 'Frenesie':'Frenesie',
  1012. 'Golemologie':'Golemo',
  1013. 'Golem de cuir':'GolemCuir',
  1014. 'Golem de metal':'GolemMetal',
  1015. 'Golem de mithril':'GolemMithril',
  1016. 'Golem de papier':'GolemPapier',
  1017. 'Grattage':'Grattage',
  1018. 'Hurlement Effrayant':'HE',
  1019. 'Identification des Champignons':'IdC',
  1020. 'Insultes':'Insultes',
  1021. 'Lancer de Potions':'LdP',
  1022. 'Marquage':'Marquage',
  1023. 'Melange Magique':'Melange',
  1024. 'Miner':'Miner',
  1025. 'Necromancie':'Necro',
  1026. 'Painthure de Guerre':'PG',
  1027. 'Parer':'Parer',
  1028. 'Pistage':'Pistage',
  1029. 'Planter un Champignon':'PuC',
  1030. 'Regeneration Accrue':'RA',
  1031. 'Reparation':'Reparation',
  1032. 'Retraite':'Retraite',
  1033. 'Rotobaffe':'RB',
  1034. 'Shamaner':'Shamaner',
  1035. "S'interposer":'SInterposer',
  1036. 'Tailler':'Tailler',
  1037. //'Vol':'Vol',
  1038. /* Sortilèges */
  1039. 'Analyse Anatomique':'AA',
  1040. 'Armure Etheree':'AE',
  1041. 'Augmentation de l´Attaque':'AdA',
  1042. 'Augmentation de l´Esquive':'AdE',
  1043. 'Augmentation des Degats':'AdD',
  1044. 'Bulle Anti-Magie':'BAM',
  1045. 'Bulle Magique':'BuM',
  1046. 'Explosion':'Explo',
  1047. 'Faiblesse Passagere':'FP',
  1048. 'Flash Aveuglant':'FA',
  1049. 'Glue':'Glue',
  1050. 'Griffe du Sorcier':'GdS',
  1051. 'Hypnotisme':'Hypno',
  1052. 'Identification des tresors':'IdT',
  1053. 'Invisibilite':'Invi',
  1054. 'Levitation':'Levitation',
  1055. 'Precision Magique':'PreM',
  1056. 'Projectile Magique':'Projo',
  1057. 'Projection':'Proj',
  1058. 'Puissance Magique':'PuM',
  1059. 'Rafale Psychique':'Rafale',
  1060. 'Sacrifice':'Sacro',
  1061. 'Siphon des Ames':'Siphon',
  1062. 'Telekinesie':'Telek',
  1063. 'Teleportation':'TP',
  1064. 'Vampirisme':'Vampi',
  1065. 'Vision Accrue':'VA',
  1066. 'Vision lointaine':'VL',
  1067. 'Voir le Cache':'VlC',
  1068. 'Vue Troublee':'VT'
  1069. //'':''
  1070. }
  1071.  
  1072. // DEBUG - Pour rétrocompatibilité
  1073. function getSortComp(nom,niveau) {
  1074. return getTalent(nom,niveau);
  1075. }
  1076. //
  1077.  
  1078. function getTalent(nom,niveau) {
  1079. var nomEnBase = arrayTalents[epure(nom)];
  1080. if(!nomEnBase) return 0;
  1081. if(!niveau) var niveau = '';
  1082. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1083. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1084. return 0;
  1085. }
  1086.  
  1087. function removeAllTalents() {
  1088. for(var talent in arrayTalents) {
  1089. var nomEnBase = arrayTalents[talent];
  1090. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1091. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1092. continue;
  1093. }
  1094. var niveau = 1;
  1095. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1096. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1097. niveau++;
  1098. }
  1099. }
  1100. }
  1101.  
  1102. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1103. var att = MY_getValue(numTroll+'.caracs.attaque');
  1104. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1105. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1106. var mm = MY_getValue(numTroll+'.caracs.mm');
  1107. var deg = MY_getValue(numTroll+'.caracs.degats');
  1108. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1109. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1110. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1111. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1112. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1113. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1114. return false;
  1115. return true;
  1116. }
  1117.  
  1118.  
  1119. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1120.  
  1121. function getPVsRestants(pv,bless,vue) {
  1122. bless = Number(bless.match(/\d+/)[0]);
  1123. if(bless==0) return null;
  1124. var pvminmax = pv.match(/\d+/g);
  1125. if(bless==95) {
  1126. var pvb = 1;
  1127. var pvh = Math.floor( pvminmax[1]/20 );
  1128. }
  1129. else if(bless==5) {
  1130. var pvb = Math.floor( pvminmax[0]*19/20 );
  1131. var pvh = pvminmax[1];
  1132. }
  1133. else {
  1134. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1135. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1136. }
  1137. return vue ? ' ('+pvb+'-'+pvh+')' :
  1138. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1139. }
  1140.  
  1141. function insertButtonCdm(nextName,onClick,texte) {
  1142. if(texte==null) texte = 'Participer au bestiaire';
  1143. var nextNode = document.getElementsByName(nextName)[0];
  1144.  
  1145. var espace = document.createTextNode('\t');
  1146. insertBefore(nextNode,espace);
  1147.  
  1148. var button = document.createElement('input');
  1149. button.type = 'button';
  1150. button.className = 'mh_form_submit';
  1151. button.value = texte;
  1152. button.onmouseover = function(){this.style.cursor='pointer';};
  1153. if(onClick) button.onclick = onClick;
  1154. insertBefore(espace,button);
  1155. return button;
  1156. }
  1157.  
  1158. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1159. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1160. 'Capacité spéciale','Résistance Magique','Autres'];
  1161.  
  1162. function createImageTactique(url,id,nom) {
  1163. var img = document.createElement('img');
  1164. img.src = url;
  1165. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1166. img.id = id;
  1167. img.nom = nom;
  1168. img.onmouseover = showPopupTactique;
  1169. img.onmouseout = hidePopup;
  1170. return img;
  1171. }
  1172.  
  1173. function createCDMTable(id,nom,donneesMonstre) {
  1174. try {
  1175. var urlImg = URL_MZimg09;
  1176. var table = document.createElement('table');
  1177. var profilActif = isProfilActif();
  1178. table.className = 'mh_tdborder';
  1179. table.border = 0;
  1180. table.cellSpacing = 1;
  1181. table.cellPadding = 4;
  1182. var thead = document.createElement('thead');
  1183. var tr = appendTr(thead,'mh_tdtitre');
  1184. var td = appendTdText(tr,
  1185. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1186. true
  1187. );
  1188. td.colSpan = 2;
  1189. table.appendChild(thead);
  1190. var tbody = document.createElement('tbody');
  1191. table.appendChild(tbody);
  1192. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1193. createCase(listeTitres[i],tbody,80);
  1194. }
  1195. var TypeMonstre = getEM(nom);
  1196. var infosCompo='';
  1197. if(TypeMonstre!='') {
  1198. infosCompo = compoEM(TypeMonstre);
  1199. }
  1200. var nodes = tbody.childNodes;
  1201. nodes[0].childNodes[1].innerHTML =
  1202. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1203. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1204. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1205. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1206. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1207. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1208. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1209. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1210. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1211. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1212. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1213. td = createCase(listeTitres[10],tbody);
  1214. td.innerHTML = bbcode(donneesMonstre[10]);
  1215. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1216. td.appendChild(document.createTextNode(" "));
  1217. if(donneesMonstre[16] == "De zone")
  1218. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1219. else if(donneesMonstre[16] == "Automatique")
  1220. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1221. else if(donneesMonstre[16] == "Au toucher")
  1222. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1223. }
  1224. }
  1225. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1226. {
  1227. td = createCase(listeTitres[11],tbody);
  1228. td.innerHTML = bbcode(donneesMonstre[9]);
  1229. // seuil de résistance du monstre
  1230. var lb = td.getElementsByTagName('b');
  1231. if(lb.length == 1) {
  1232. var mrm = lb[0].firstChild.nodeValue * 1;
  1233. var v = (mrm / mmTroll);
  1234. lb[0].firstChild.nodeValue += " ("
  1235. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1236. }
  1237. }
  1238. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1239. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1240. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1241. {
  1242. td = createCase(listeTitres[12],tbody);
  1243. if(donneesMonstre[12]==1)
  1244. {
  1245. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1246. }
  1247. if(donneesMonstre[13]==1)
  1248. {
  1249. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1250. }
  1251. else if(donneesMonstre[13]==0)
  1252. {
  1253. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1254. }
  1255. if(donneesMonstre[14]==1)
  1256. {
  1257. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1258. }
  1259. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1260. {
  1261. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1262. }
  1263. else if(donneesMonstre[14]>6)
  1264. {
  1265. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1266. }
  1267. if(donneesMonstre[15]=="Lente")
  1268. {
  1269. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1270. }
  1271. else if(donneesMonstre[15]=="Normale")
  1272. {
  1273. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1274. }
  1275. else if(donneesMonstre[15]=="Rapide")
  1276. {
  1277. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1278. }
  1279. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1280. {
  1281. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1282. }
  1283. if(infosCompo.length>0)
  1284. {
  1285. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1286. }
  1287. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1288. {
  1289. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1290. }
  1291. }
  1292. // pourcentage de blessure
  1293. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1294. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1295. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1296. if(pvs)
  1297. lb[0].firstChild.nodeValue += pvs;
  1298. }
  1299. return table;
  1300. }
  1301. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  1302. }
  1303.  
  1304.  
  1305. /*-[functions]------------ Gestion des enchantements -------------------------*/
  1306.  
  1307. var listeMonstreEnchantement = null,
  1308. listeEquipementEnchantement = null,
  1309. listeInfoEnchantement = null;
  1310.  
  1311. function computeCompoEnchantement()
  1312. {
  1313. listeMonstreEnchantement = new Array();
  1314. listeInfoEnchantement = new Array();
  1315. listeEquipementEnchantement = new Array();
  1316. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  1317. for(var i=0;i<liste.length;i++)
  1318. {
  1319. var idEquipement = liste[i]*1;
  1320. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  1321. continue;
  1322. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  1323. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  1324. var texteGlobal='';
  1325. for(var j=0;j<3;j++)
  1326. {
  1327. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  1328. listeMonstreEnchantement[infoComposant[2]] = 1;
  1329. var array = new Array();
  1330. array[0]=infoComposant[0].replace("Ril","Œil");
  1331. array[1]=infoComposant[1];
  1332. array[2]=infoComposant[2];
  1333. array[3]=getQualite(infoComposant[3]);
  1334. var texte = infoComposant[4].replace("Ril","Œil");
  1335. for(var k=5;k<infoComposant.length;k++)
  1336. {
  1337. texte += ";"+infoComposant[k].replace("Ril","Œil");
  1338. }
  1339. texteGlobal+=texte+'\n';
  1340. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1341. array[4]=texte;
  1342. listeInfoEnchantement.push(array);
  1343. }
  1344. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1345. listeEquipementEnchantement[idEquipement] = texteGlobal;
  1346. }
  1347. }
  1348.  
  1349. function isEnchant(nom) {
  1350. var monstreEnchant = '';
  1351. for(j in listeInfoEnchantement) {
  1352. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1353. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1354. monstreEnchant=monstre;
  1355. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  1356. }
  1357. }
  1358. return trim(monstreEnchant);
  1359. }
  1360.  
  1361. function getInfoEnchantementFromMonstre(nom)
  1362. {
  1363. try
  1364. {
  1365. if(!listeMonstreEnchantement)
  1366. {
  1367. computeCompoEnchantement();
  1368. }
  1369. var infosEnchant = '';
  1370. for(j in listeInfoEnchantement) {
  1371. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1372. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1373. if(infosEnchant=='')
  1374. infosEnchant=listeInfoEnchantement[j][4];
  1375. else
  1376. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  1377. }
  1378. }
  1379. return trim(infosEnchant);
  1380. }
  1381. catch(e)
  1382. {
  1383. window.alert(e);
  1384. }
  1385. }
  1386.  
  1387. function composantEnchant(Monstre,composant,localisation,qualite) {
  1388. var compo='';
  1389. for(var i=0; i<listeInfoEnchantement.length; i++) {
  1390. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  1391. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  1392. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  1393. listeInfoEnchantement[i][3]<=qualite
  1394. ) {
  1395. return listeInfoEnchantement[i][4];
  1396. }
  1397. }
  1398. return compo;
  1399. }
  1400.  
  1401. function insertEnchantInfos(tbody) {
  1402. try
  1403. {
  1404. if(!listeMonstreEnchantement)
  1405. computeCompoEnchantement();
  1406. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  1407. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1408. if(nodes.snapshotLength == 0)
  1409. return false;
  1410. var urlImg = URL_MZimg09 + 'enchant.png';
  1411. for(var i = 0; i < nodes.snapshotLength; i++) {
  1412. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  1413. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  1414. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  1415. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  1416. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  1417. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  1418. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  1419. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  1420. if(isEnchant(nomMonstre).length>0)
  1421. {
  1422. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  1423. if(infos.length>0)
  1424. {
  1425. if(link.parentNode == link.nextSibling.parentNode)
  1426. {
  1427. var tmp = link.nextSibling;
  1428. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  1429. }
  1430. else
  1431. {
  1432. link.parentNode.appendChild(createImage(urlImg,infos));
  1433. }
  1434. }
  1435. }
  1436. }
  1437. }
  1438. catch(e)
  1439. {
  1440. window.alert(e);
  1441. }
  1442. }
  1443.  
  1444. function computeEnchantementEquipement(fontionTexte,formateTexte)
  1445. {
  1446. try
  1447. {
  1448. if(!listeMonstreEnchantement)
  1449. computeCompoEnchantement();
  1450. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  1451. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1452. if(nodes.snapshotLength == 0)
  1453. return false;
  1454. var urlImg = URL_MZimg09 + 'enchant.png';
  1455. for(var i = 0; i < nodes.snapshotLength; i++)
  1456. {
  1457. var link = nodes.snapshotItem(i);
  1458. var idEquipement = link.getAttribute('href');
  1459. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  1460. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  1461. var nomEquipement = trim(link.firstChild.nodeValue);
  1462. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  1463. if(!enchanteur || enchanteur == '')
  1464. continue;
  1465. var infos = listeEquipementEnchantement[idEquipement];
  1466. infos=formateTexte(infos);
  1467. if(infos.length>0)
  1468. {
  1469. if(link.parentNode == link.nextSibling.parentNode)
  1470. {
  1471. var tmp = link.nextSibling;
  1472. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  1473. }
  1474. else
  1475. {
  1476. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  1477. }
  1478. }
  1479. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  1480. }
  1481. }
  1482. catch(e)
  1483. {
  1484. window.alert(e);
  1485. }
  1486. }
  1487.  
  1488. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  1489.  
  1490.  
  1491. // Les % de toucher
  1492. var c = new Array();
  1493.  
  1494. // coefficients binomiaux
  1495. function cnp(n,k)
  1496. {
  1497. if(c[n] != null && c[n][k] != null)
  1498. return c[n][k];
  1499. if(c[n] == null)
  1500. c[n] = new Array();
  1501. if(k==0)
  1502. {
  1503. c[n][k] = 1;
  1504. return 1;
  1505. }
  1506. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  1507. c[n][k] = result;
  1508. // Roule debug
  1509. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  1510. return result;
  1511. }
  1512.  
  1513. // by Dab, à comparer
  1514. function binom(n,p) {
  1515. if(p<0 || p>n) return 0;
  1516. if(c[n])
  1517. if(c[n][p]) return c[n][p];
  1518. else {
  1519. c[n]=[1];
  1520. c[n][n]=1;
  1521. if(p==0 || p==n) return 1;
  1522. }
  1523. if(2*p>n)
  1524. c[n][p]=binom(n,n-p);
  1525. else
  1526. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  1527. return c[n][p];
  1528. }
  1529.  
  1530. var coeff = new Array();
  1531.  
  1532. function coef(n,p)
  1533. {
  1534. if(n==0 && p==0)
  1535. return 1;
  1536. if(p>n*3.5)
  1537. p = 7*n-p
  1538. // roule désactive cache
  1539. if(coeff[n] != null && coeff[n][p] !=null)
  1540. return coeff[n][p];
  1541. if(coeff[n] == null)
  1542. coeff[n] = new Array();
  1543. var kmax = Math.floor((p-n)/6);
  1544. var x=0;
  1545. for(var k=0;k<=kmax;k++)
  1546. {
  1547. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  1548. }
  1549. coeff[n][p] = x;
  1550. // Roule debug
  1551. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  1552. return x;
  1553. }
  1554.  
  1555. function chanceEsquiveParfaite(a,d,ba,bd)
  1556. {
  1557. var win = 0;
  1558. var los = 0;
  1559. if(ba==null)
  1560. ba=0;
  1561. if(bd==null)
  1562. bd=0;
  1563. /* if(6*a+ba<2*(d+bd))
  1564. return 100;
  1565. if(a+ba>2*(6*d+bd))
  1566. return 0;*/
  1567. for(var ds=d;ds<=6*d;ds++)
  1568. {
  1569. var cd = coef(d,ds);
  1570. for(var as=a;as<=6*a;as++)
  1571. {
  1572. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  1573. win += cd * coef(a,as);
  1574. else
  1575. los += cd * coef(a,as);
  1576. }
  1577. }
  1578. // roule debug
  1579. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  1580. return Math.round(100*win/(win+los));
  1581. }
  1582.  
  1583. function chanceTouche(a,d,ba,bd)
  1584. {
  1585. var win = 0;
  1586. var los = 0;
  1587. if(ba==null)
  1588. ba=0;
  1589. if(bd==null)
  1590. bd=0;
  1591. if(a+ba>6*d+bd)
  1592. return 100;
  1593. if(6*a+ba<d+bd)
  1594. return 0;
  1595. for(var ds=d;ds<=6*d;ds++)
  1596. {
  1597. var cd = coef(d,ds);
  1598. for(var as=a;as<=6*a;as++)
  1599. {
  1600. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  1601. win += cd * coef(a,as);
  1602. else
  1603. los += cd * coef(a,as);
  1604. }
  1605. }
  1606. return Math.round(100*win/(win+los));
  1607. }
  1608.  
  1609. function chanceCritique(a,d,ba,bd)
  1610. {
  1611. var win = 0;
  1612. var los = 0;
  1613. if(ba==null)
  1614. ba=0;
  1615. if(bd==null)
  1616. bd=0;
  1617. if(a+ba>2*(6*d+bd))
  1618. return 100;
  1619. if(6*a+ba<2*(d+bd))
  1620. return 0;
  1621. for(var ds=d;ds<=6*d;ds++)
  1622. {
  1623. var cd = coef(d,ds);
  1624. for(var as=a;as<=6*a;as++)
  1625. {
  1626. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  1627. win += cd * coef(a,as);
  1628. else
  1629. los += cd * coef(a,as);
  1630. }
  1631. }
  1632. return Math.round(100*win/(win+los));
  1633. }
  1634.  
  1635. /***********************************************
  1636. Analyse tactique
  1637. ***********************************************/
  1638.  
  1639. function getTexteAnalyse(modificateur,chiffre)
  1640. {
  1641. if(chiffre==0)
  1642. return chiffre;
  1643. return modificateur+chiffre;
  1644. }
  1645.  
  1646. function getAnalyseTactique(id,nom)
  1647. {
  1648. var donneesMonstre = listeCDM[id];
  1649. var needAutres=false;
  1650. var i;
  1651. if(donneesMonstre == null)
  1652. return;
  1653. var array = analyseTactique(donneesMonstre,nom);
  1654. if(array==null)
  1655. return "";
  1656. var str = "<table class='mh_tdborder' border='0' cellspacing='1' cellpadding='4'><tr class='mh_tdtitre'><td>Attaque</td><td>Esq. Parfaite</td><td>Touché</td><td>Critique</td><td>Dégâts</td></tr>";
  1657. for(i=0;i<array.length;i++)
  1658. {
  1659. if(array[i][1]==100 && i>0)
  1660. {
  1661. needAutres=true;
  1662. break;
  1663. }
  1664. if(i==1 && array[i][4]>0)
  1665. str+= "<tr class=mh_tdpage><td><b>"+array[i][0]+"</b></td><td><b>"+getTexteAnalyse(array[i][5],array[i][1])+"%</b></td><td><b>"+getTexteAnalyse(array[i][5],array[i][2])+"%</b></td><td><b>"+getTexteAnalyse(array[i][5],array[i][3])+"%</b></td><td><b>"+getTexteAnalyse(array[i][6],array[i][4])+"</b></td></tr>";
  1666. else if(i==0)
  1667. str+= "<tr class=mh_tdpage><td><i>"+array[i][0]+"</i></td><td><i>"+getTexteAnalyse(array[i][5],array[i][1])+"%</i></td><td><i>"+getTexteAnalyse(array[i][5],array[i][2])+"%</i></td><td><i>"+getTexteAnalyse(array[i][5],array[i][3])+"%<i></td><td><b><i>"+getTexteAnalyse(array[i][6],array[i][4])+"<i></b></td></tr>";
  1668. else
  1669. str+= "<tr class=mh_tdpage><td>"+array[i][0]+"</td><td>"+getTexteAnalyse(array[i][5],array[i][1])+"%</td><td>"+getTexteAnalyse(array[i][5],array[i][2])+"%</td><td>"+getTexteAnalyse(array[i][5],array[i][3])+"%</td><td><b>"+getTexteAnalyse(array[i][6],array[i][4])+"</b></td></tr>";
  1670. }
  1671. if(needAutres)
  1672. {
  1673. if(i==array.length-1)
  1674. str+= "<tr class=mh_tdpage><td>"+array[i][0]+"</td><td>"+getTexteAnalyse(array[i][5],array[i][1])+"%</td><td>"+getTexteAnalyse(array[i][5],array[i][2])+"%</td><td>"+getTexteAnalyse(array[i][5],array[i][3])+"%</td><td><b>"+getTexteAnalyse(array[i][6],array[i][4])+"</b></td></tr>";
  1675. else if(i==1)
  1676. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  1677. else
  1678. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  1679. }
  1680. return str+"</table>";
  1681. }
  1682.  
  1683. function analyseTactique(donneesMonstre,nom) {
  1684. try
  1685. {
  1686. var listeAttaques = [];
  1687. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  1688. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  1689. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  1690. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  1691. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  1692. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  1693. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  1694. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  1695. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  1696. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  1697. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  1698. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  1699. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  1700. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  1701. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  1702. var modificateurEsquive = '';
  1703. var modificateurArmure = '';
  1704. var modificateurMagie = '';
  1705. var modificateurEsquiveM = '';
  1706. var modificateurArmureM = '';
  1707. var pasDeSR=false;
  1708. var esqM,attM,armM,degM;
  1709. if(donneesMonstre==null || att==null || attbmp==null || attbmm==null || mm==null || deg==null || degbmp==null || degbmm==null || vue==null ||pv==null || esq==null || arm==null)
  1710. return null;
  1711. var td = document.createElement('td')
  1712. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  1713. var esqM = 0;
  1714. try
  1715. {
  1716. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1717. }
  1718. catch(e)
  1719. {
  1720. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1721. modificateurEsquive = '<';
  1722. modificateurArmure = '<';
  1723. modificateurMagie = '<';
  1724. }
  1725. td.innerHTML = bbcode(donneesMonstre[3]);
  1726. var attM = 0;
  1727. try
  1728. {
  1729. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1730. }
  1731. catch(e)
  1732. {
  1733. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1734. modificateurEsquiveM = '>';
  1735. modificateurArmureM = '>';
  1736. }
  1737. td.innerHTML = bbcode(donneesMonstre[5]);
  1738. var degM = 0;
  1739. try
  1740. {
  1741. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1742. }
  1743. catch(e)
  1744. {
  1745. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1746. modificateurArmureM = '>';
  1747. }
  1748. td.innerHTML = bbcode(donneesMonstre[7]);
  1749. var armM = 0;
  1750. try
  1751. {
  1752. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1753. }
  1754. catch(e)
  1755. {
  1756. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1757. modificateurArmure = '<';
  1758. }
  1759. var coeffSeuil = 0.95;
  1760. try
  1761. {
  1762. td.innerHTML = bbcode(donneesMonstre[9]);
  1763. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1764. var v = (rm / mm);
  1765. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  1766. coeffSeuil = (200-seuil)/200;
  1767. }
  1768. catch(e)
  1769. {
  1770. modificateurMagie = '<';
  1771. pasDeSR = true;
  1772. }
  1773. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  1774. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  1775. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  1776. // roule debug
  1777. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  1778. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  1779. var degats = (((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmp+degbmm-armM,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmp+degbmm-armM,1))/100);
  1780. //str += "Attaque normale : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmp+degbmm-arm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmp+degbmm-arm,1))/100);
  1781. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1782. if(getSortComp("Vampirisme")>0)
  1783. {
  1784. var pour = getSortComp("Vampirisme");
  1785. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  1786. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  1787. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  1788. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  1789. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1790. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  1791. }
  1792. if(getSortComp("Botte Secrète")>0)
  1793. {
  1794. var pour = getSortComp("Botte Secrète");
  1795. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  1796. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  1797. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  1798. degats = Math.round(((chanceDeTouche-chanceDeCritique)*Math.max(Math.floor(deg/2)*2+Math.floor((degbmp+degbmm)/2)-Math.floor(armM/2),1)+chanceDeCritique*Math.max(Math.floor(deg*1.5/2)*2+Math.floor((degbmp+degbmm)/2)-Math.floor(armM/2),1)))/100;
  1799. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1800. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1801. }
  1802. if(getSortComp("Rafale Psychique")>0)
  1803. {
  1804. var pour = getSortComp("Rafale Psychique");
  1805. chanceDEsquiveParfaite = 0;
  1806. chanceDeTouche = Math.round(100*pour/100);
  1807. chanceDeCritique = Math.round(0*pour/100);
  1808. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  1809. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1810. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  1811. }
  1812. if(getSortComp("Explosion")>0)
  1813. {
  1814. var pour = getSortComp("Explosion");
  1815. chanceDEsquiveParfaite = 0;
  1816. chanceDeTouche = Math.round(100*pour/100);
  1817. chanceDeCritique = Math.round(0*pour/100);
  1818. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(Math.floor(1+deg/2+pv/20)*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(Math.floor(1+deg/2+pv/20)*1.5)*2+degbmm,1)))/100;
  1819. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1820. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  1821. }
  1822. if(getSortComp("Projectile Magique")>0)
  1823. {
  1824. var pour = getSortComp("Projectile Magique");
  1825. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  1826. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  1827. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  1828. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(Math.floor(vue/2)*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(Math.floor(vue/2)*1.5)*2+degbmm,1)))/100;
  1829. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1830. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  1831. }
  1832. if(getSortComp("Frénésie")>0)
  1833. {
  1834. var pour = getSortComp("Frénésie");
  1835. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  1836. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  1837. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  1838. degats = Math.round(((chanceDeTouche-chanceDeCritique)*2*Math.max((deg*2+degbmp+degbmm-armM),1)+chanceDeCritique*2*Math.max(Math.floor(deg*1.5)*2+degbmm+degbmp-armM,1)))/100;
  1839. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1840. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1841. }
  1842. if(getSortComp("Charger")>0)
  1843. {
  1844. var pour = getSortComp("Charger");
  1845. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  1846. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  1847. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  1848. var degats = Math.round(((chanceDeTouche-chanceDeCritique)*Math.max((deg*2+degbmp+degbmm-armM),1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm+degbmp-armM,1)))/100;
  1849. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1850. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1851. }
  1852. if(getSortComp("Griffe du Sorcier")>0)
  1853. {
  1854. var pour = getSortComp("Griffe du Sorcier");
  1855. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  1856. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  1857. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  1858. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(Math.floor(deg/2)*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(Math.floor(deg/2)*1.5)*2+degbmm,1)))/100;
  1859. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1860. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  1861. }
  1862. if(getSortComp("Attaque Précise",1)>0)
  1863. {
  1864. var niveau = 5;
  1865. var oldPour = 0;
  1866. var chanceDEsquiveParfaite = 0;
  1867. var chanceDeTouche = 0;
  1868. var chanceDeCritique = 0;
  1869. degats = 0;
  1870. while(niveau>0)
  1871. {
  1872. var pour = getSortComp("Attaque Précise",niveau);
  1873. if(pour>oldPour)
  1874. {
  1875. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1876. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1877. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1878. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  1879. chanceDeTouche += chanceDeToucheNiveau;
  1880. chanceDeCritique += chanceDeCritiqueNiveau;
  1881. degats += (((chanceDeToucheNiveau-chanceDeCritiqueNiveau)*Math.max((deg*2+degbmp+degbmm-armM),1)+chanceDeCritiqueNiveau*Math.max(Math.floor(deg*1.5)*2+degbmm+degbmp-armM,1))/100);
  1882. oldPour = pour;
  1883. }
  1884. niveau--;
  1885. }
  1886. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  1887. listeAttaques.push(new Array("Attaque Précise",chanceDEsquiveParfaite,Math.round(chanceDeTouche*100)/100,Math.round(chanceDeCritique*100)/100,Math.round(degats*100)/100,modificateurEsquive,modificateurArmure));
  1888. }
  1889. if(getSortComp("Coup de Butoir",1)>0)
  1890. {
  1891. var niveau = 5;
  1892. var oldPour =0;
  1893. var chanceDEsquiveParfaite = 0;
  1894. var chanceDeTouche=0;
  1895. var chanceDeCritique=0;
  1896. degats=0;
  1897. while(niveau>0)
  1898. {
  1899. var pour = getSortComp("Coup de Butoir",niveau);
  1900. if(pour>oldPour)
  1901. {
  1902. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1903. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1904. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1905. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  1906. chanceDeTouche += chanceDeToucheNiveau;
  1907. chanceDeCritique += chanceDeCritiqueNiveau;
  1908. degats += (((chanceDeToucheNiveau-chanceDeCritiqueNiveau)*Math.max((Math.min(Math.floor(deg*1.5),deg+3*niveau)*2+degbmp+degbmm-armM),1)+chanceDeCritiqueNiveau*Math.max(Math.floor(Math.min(Math.floor(deg*1.5),deg+3*niveau)*1.5)*2+degbmm+degbmp-armM,1))/100);
  1909. oldPour = pour;
  1910. }
  1911. niveau--;
  1912. }
  1913. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  1914. listeAttaques.push(new Array("Coup de Butoir",chanceDEsquiveParfaite,Math.round(chanceDeTouche*100)/100,Math.round(chanceDeCritique*100)/100,Math.round(degats*100)/100,modificateurEsquive,modificateurArmure));
  1915. }
  1916. listeAttaques.sort(function(a,b){var diff = parseInt(100*b[4])-parseInt(100*a[4]);if(diff==0) return parseInt(b[1])-parseInt(a[1]); return diff;});
  1917. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  1918. {
  1919. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  1920. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  1921. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  1922. }
  1923. else
  1924. {
  1925. chanceDEsquiveParfaite = 0;
  1926. chanceDeTouche = 100;
  1927. chanceDeCritique = 0;
  1928. }
  1929. degats = Math.round(((chanceDeTouche-chanceDeCritique)*Math.max(Math.floor(degM)*2-arm,1)+chanceDeCritique*Math.max(Math.floor(Math.floor(degM)*1.5)*2-arm*2-armbmm-armbmp,1)))/100;
  1930.  
  1931. listeAttaques.unshift(new Array("Monstre",Math.round(chanceDEsquiveParfaite*100)/100,Math.round(chanceDeTouche*100)/100,Math.round(chanceDeCritique*100)/100,Math.round(degats*100)/100,modificateurEsquive,modificateurArmure));
  1932. return listeAttaques;
  1933. }
  1934. catch(e) { window.alert(e);}
  1935. }
  1936.  
  1937. // x~~x marque pour s'y retrouver sous l'éditeur
  1938.  
  1939. /*
  1940. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  1941. * published under GNU License v2.
  1942. *
  1943. * Patch :
  1944. * gestion des missions terminées
  1945. */
  1946. // x~x mission_liste
  1947.  
  1948. function checkLesMimis() {
  1949. try {
  1950. var titresMimis = document.evaluate(
  1951. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  1952. document, null, 7, null
  1953. );
  1954. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  1955. } catch(e) {
  1956. window.console.error('[MZ mission_liste] Erreur initialisation:\n'+e);
  1957. return;
  1958. }
  1959. var enCours = {};
  1960. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  1961. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  1962. enCours[num] = true;
  1963. }
  1964. for(var numMimi in obMissions) {
  1965. if(!enCours[numMimi]) {
  1966. delete obMissions[numMimi];
  1967. }
  1968. }
  1969. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  1970. }
  1971.  
  1972. function do_mission_liste() {
  1973. checkLesMimis();
  1974. }
  1975.  
  1976. /*******************************************************************************
  1977. * This file is part of Mountyzilla. *
  1978. * *
  1979. * Mountyzilla is free software; you can redistribute it and/or modify *
  1980. * it under the terms of the GNU General Public License as published by *
  1981. * the Free Software Foundation; either version 2 of the License, or *
  1982. * (at your option) any later version. *
  1983. * *
  1984. * Mountyzilla is distributed in the hope that it will be useful, *
  1985. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  1986. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  1987. * GNU General Public License for more details. *
  1988. * *
  1989. * You should have received a copy of the GNU General Public License *
  1990. * along with Mountyzilla; if not, write to the Free Software *
  1991. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  1992. *******************************************************************************/
  1993.  
  1994. // x~x actions
  1995.  
  1996. /* TODO
  1997. * getLvl pour Explo, Rotobaffe et cie
  1998. */
  1999.  
  2000.  
  2001.  
  2002. /* Page de combat */
  2003.  
  2004. function getLevel() {
  2005. var divList = document.getElementsByTagName('div');
  2006. if(divList.length <= 2)
  2007. return;
  2008. // On essaie de voir si cette action était une attaque
  2009. var pList = document.getElementsByTagName('p');
  2010. var nomM = '';
  2011. // Modification pour Frénésie by TetDure
  2012. var numAtt = 0;
  2013. for (var i = 0; i < pList.length; i++) {
  2014. if(pList[i].firstChild) {
  2015. nomM = pList[i].firstChild.nodeValue;
  2016. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2017. numAtt++;
  2018. }
  2019. }
  2020. if(nomM == '')
  2021. return;
  2022. // Si c'est une attaque normale, un seul PX
  2023. var comPX = 1;
  2024. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2025. comPX++;
  2026.  
  2027. // Extraction des infos du monstre attaqué
  2028. var idM;
  2029. var male;
  2030. if(nomM.slice(20, 21) == 'e') {
  2031. male = false;
  2032. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2033. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2034. }
  2035. else {
  2036. male = true;
  2037. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2038. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2039. }
  2040. if(idM == '')
  2041. return;
  2042. var bList = document.getElementsByTagName('b');
  2043. var niveau = '';
  2044. for (var i = 0; i < bList.length; i++) {
  2045. var b = bList[i];
  2046. if(b.childNodes[0].nodeValue != "TUÉ")
  2047. continue;
  2048. var nbPX = "";
  2049. for (i++; i < bList.length; i++) {
  2050. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2051. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2052. return;
  2053. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2054. nbPX = bList[i].childNodes[0].nodeValue;
  2055. break;
  2056. }
  2057. }
  2058. if(nbPX == '')
  2059. return;
  2060. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2061. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2062. if(!nbPX)
  2063. nbPX = 0;
  2064. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2065. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2066. if(comPX > nbPX) {
  2067. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2068. niveau = "";
  2069. } else if(Math.floor(niveau) == niveau) {
  2070. chaine += niveau + ".";
  2071. } else {
  2072. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2073. niveau = "";
  2074. }
  2075. insertBr(b.nextSibling.nextSibling.nextSibling);
  2076. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2077. }
  2078.  
  2079. if(niveau != '') {
  2080. var button = insertButtonCdm('as_Action');
  2081. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2082. + escape(nomM) + "&niveau=" + escape(niveau)
  2083. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2084. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2085. }
  2086. }
  2087.  
  2088.  
  2089. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2090.  
  2091. function insertInfoMagie(node, intitule, magie) {
  2092. if(node.nextSibling) {
  2093. node = node.nextSibling;
  2094. insertBr(node);
  2095. insertText(node, intitule);
  2096. insertText(node, magie, true);
  2097. } else {
  2098. node = node.parentNode;
  2099. appendBr(node);
  2100. appendText(node, intitule);
  2101. appendText(node, magie, true);
  2102. }
  2103. }
  2104.  
  2105. function getMM(sr) {
  2106. if(rmTroll<=0) {
  2107. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2108. }
  2109. sr = Number(sr.match(/\d+/)[0]);
  2110. if(sr==10) {
  2111. return '\u2265 '+5*rmTroll;
  2112. }
  2113. if(sr<=50) {
  2114. return Math.round(50*rmTroll/sr);
  2115. }
  2116. if(sr<90) {
  2117. return Math.round((100-sr)*rmTroll/50);
  2118. }
  2119. return '\u2264 '+Math.round(rmTroll/5);
  2120. }
  2121.  
  2122. function traiteMM() {
  2123. var node = document.evaluate(
  2124. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2125. document, null, 9, null).singleNodeValue;
  2126. if(node) {
  2127. var mm = getMM(node.nodeValue);
  2128. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2129. } else {
  2130. var node = document.evaluate(
  2131. "//p/text()[contains(., 'Seuil de Résistance')]",
  2132. document, null, 9, null).singleNodeValue;
  2133. if(!node) {
  2134. return;
  2135. }
  2136. var mm = getMM(node.nodeValue);
  2137. node = node.nextSibling.nextSibling;
  2138. }
  2139. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2140. }
  2141.  
  2142. function getRM(sr) {
  2143. if(mmTroll<=0) {
  2144. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2145. }
  2146. sr = Number(sr.match(/\d+/)[0]);
  2147. if(sr==10) {
  2148. return '\u2264 '+Math.round(mmTroll/5);
  2149. }
  2150. if(sr<=50) {
  2151. return Math.round(sr*mmTroll/50);
  2152. }
  2153. if(sr<90) {
  2154. return Math.round(50*mmTroll/(100-sr));
  2155. }
  2156. return '\u2265 '+5*mmTroll;
  2157. }
  2158.  
  2159. function traiteRM() {
  2160. var nodes = document.evaluate(
  2161. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2162. document, null, 7, null);
  2163. if(nodes.snapshotLength==0) {
  2164. return;
  2165. }
  2166. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2167. var node = nodes.snapshotItem(i);
  2168. var rm = getRM(node.nodeValue);
  2169. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2170. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2171. }
  2172. }
  2173.  
  2174.  
  2175. /* Fonction stats IdT par Raistlin */
  2176. /*function getIdt() {
  2177. if(MY_getValue("SEND_IDT") == "non")
  2178. return false;
  2179. var regExpBeginning = /^\s+/;
  2180. var regExpEnd = /\s+$/;
  2181.  
  2182. var nomIdt = document.evaluate(
  2183. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2184. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2185. if(!nomIdt)
  2186. return false;
  2187.  
  2188. var caracIdt;
  2189. if(nomIdt.indexOf("Malédiction !") != -1) {
  2190. caracIdt = "";
  2191. nomIdt = "Mission maudite";
  2192. } else {
  2193. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2194. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2195. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2196. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2197. }
  2198. FF_XMLHttpRequest({
  2199. method: 'GET',
  2200. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2201. headers : {
  2202. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2203. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2204. }
  2205. });
  2206. return true;
  2207. }*/
  2208.  
  2209.  
  2210. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2211.  
  2212. function confirmeDecalage() {
  2213. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2214. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2215. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2216. var newDLA = new Date( oldDLA );
  2217. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2218. return window.confirm(
  2219. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2220. +'\nConfirmez-vous ce décalage ?'
  2221. );
  2222. }
  2223.  
  2224. function newsubmitDLA(evt) {
  2225. evt.stopPropagation();
  2226. evt.preventDefault();
  2227. if(confirmeDecalage()) {
  2228. this.submit();
  2229. }
  2230. }
  2231.  
  2232. function changeActionDecalage() {
  2233. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2234. return;
  2235. }
  2236. try {
  2237. // On récupère le contenu du script JS MH de calcul du décalage
  2238. var scriptTxt = document.evaluate(
  2239. ".//script[ not(@src) ]",
  2240. document, null, 9, null
  2241. ).singleNodeValue.textContent;
  2242. // On en extrait la DLA courante
  2243. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2244. scriptTxt = scriptTxt.split('\n')[0];
  2245. var nbs = scriptTxt.match(/\d+/g);
  2246. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2247. } catch(e) {
  2248. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2249. window.console.error('[changeActionDecalage] DLA non trouvée',e);
  2250. return;
  2251. }
  2252. var form = document.getElementsByName('ActionForm')[0];
  2253. if(form) {
  2254. form.addEventListener('submit', newsubmitDLA, true);
  2255. } else {
  2256. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2257. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2258. }
  2259. }
  2260.  
  2261. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2262.  
  2263. function prochainMundi() {
  2264. try {
  2265. var node = document.evaluate(
  2266. "//div[@class='dateAction']/b",
  2267. document, null, 9, null
  2268. ).singleNodeValue;
  2269. } catch(e) {
  2270. window.console.error('[prochainMundi] Date introuvable',e);
  2271. return;
  2272. }
  2273. if(!node) { return; }
  2274. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2275. var jour = longueurMois+1-getNumber(node.textContent);
  2276. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2277. var txt = '[Prochain Mundidey ';
  2278. if(jour>1) {
  2279. txt += 'dans '+jour+' jours]';
  2280. } else {
  2281. txt += 'demain]';
  2282. }
  2283. insertText(node.parentNode.nextSibling,txt,true);
  2284. }
  2285.  
  2286.  
  2287. /* Fonction principale */
  2288.  
  2289. function dispatch() {
  2290. if(isPage('MH_Play/Play_action')) {
  2291. prochainMundi();
  2292. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2293. var oldDLA;
  2294. changeActionDecalage();
  2295. } else if(isPage('MH_Play/Actions')) {
  2296. if(document.evaluate(
  2297. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  2298. document, null, 2, null
  2299. ).stringValue) {
  2300. traiteMM();
  2301. } else if(document.evaluate(
  2302. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  2303. document, null, 2, null
  2304. ).stringValue) {
  2305. //getIdt();
  2306. traiteRM();
  2307. } /*else {
  2308. // Est censé se lancer sur quoi *précisément* ?
  2309. traiteRM();
  2310. getLevel();
  2311. }*/
  2312. } else {
  2313. /* Traitement des messages du bot */
  2314. var messageTitle = document.evaluate(
  2315. "//form/table/tbody/tr[1]/td[1]/"
  2316. +"descendant::text()[contains(.,'[MountyHall]')]",
  2317. document, null, 2, null
  2318. ).stringValue;
  2319. if(messageTitle.indexOf('Attaquant') != -1 &&
  2320. messageTitle.indexOf('sur') != -1) {
  2321. getLevel();
  2322. traiteRM();
  2323. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  2324. messageTitle.indexOf('Défenseur') != -1) {
  2325. traiteMM();
  2326. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  2327. // à replacer avec Attaque après révision getLvl :
  2328. messageTitle.indexOf('Explosion') != -1 ||
  2329. messageTitle.indexOf('Insulte') != -1) {
  2330. traiteRM();
  2331. }
  2332. }
  2333. }
  2334.  
  2335. function do_actions() {
  2336. start_script(31);
  2337. dispatch();
  2338. displayScriptTime();
  2339. }
  2340.  
  2341. /*********************************************************************************
  2342. * This file is part of Mountyzilla. *
  2343. * *
  2344. * Mountyzilla is free software; you can redistribute it and/or modify *
  2345. * it under the terms of the GNU General Public License as published by *
  2346. * the Free Software Foundation; either version 2 of the License, or *
  2347. * (at your option) any later version. *
  2348. * *
  2349. * Mountyzilla is distributed in the hope that it will be useful, *
  2350. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2351. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2352. * GNU General Public License for more details. *
  2353. * *
  2354. * You should have received a copy of the GNU General Public License *
  2355. * along with Mountyzilla; if not, write to the Free Software *
  2356. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2357. *********************************************************************************/
  2358.  
  2359. // x~x pre-enchant
  2360.  
  2361. /* 2013-08-19 : correction auto syntaxe alert */
  2362.  
  2363. var combobox=null;
  2364.  
  2365. function changeObject()
  2366. {
  2367. if(!combobox)
  2368. return ;
  2369. var id = combobox.options[combobox.selectedIndex].value;
  2370. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  2371. if(!id || id=="")
  2372. {
  2373. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2374. return;
  2375. }
  2376. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  2377. }
  2378.  
  2379. function treatePreEnchantement() {
  2380. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2381. if(!input || input.getAttribute("type")=="hidden")
  2382. {
  2383. return false;
  2384. }
  2385. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  2386. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2387. if(!combobox)
  2388. {
  2389. return true;
  2390. }
  2391. combobox.addEventListener('change', changeObject, true);
  2392. return true;
  2393. }
  2394.  
  2395. function treateEnchantement() {
  2396. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2397. if(!input || input.getAttribute("type")!="hidden")
  2398. {
  2399. return false;
  2400. }
  2401. var idEquipement = input.getAttribute("value");
  2402. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  2403. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  2404. if(enchanteur && enchanteur != null)
  2405. return true;
  2406. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2407. if(!input || input.getAttribute("type")!="hidden")
  2408. {
  2409. return false;
  2410. }
  2411. var idEnchanteur = input.getAttribute("value");
  2412. var nodes = document.evaluate(
  2413. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2414. if (nodes.snapshotLength != 3)
  2415. return;
  2416. for(var i=0;i<3;i++)
  2417. {
  2418. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2419. texte = texte.replace(" d'une "," d'un ");
  2420. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2421. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2422. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2423. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2424. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2425. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2426. }
  2427. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2428. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2429. var liste = MY_getValue(numTroll+".enchantement.liste");
  2430. if(!liste || liste=="")
  2431. {
  2432. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2433. }
  2434. else
  2435. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2436. }
  2437.  
  2438. function do_pre_enchant() {
  2439. start_script(60);
  2440. if(!treatePreEnchantement())
  2441. treateEnchantement();
  2442. displayScriptTime();
  2443. }
  2444.  
  2445. /*********************************************************************************
  2446. * This file is part of Mountyzilla. *
  2447. * *
  2448. * Mountyzilla is free software; you can redistribute it and/or modify *
  2449. * it under the terms of the GNU General Public License as published by *
  2450. * the Free Software Foundation; either version 2 of the License, or *
  2451. * (at your option) any later version. *
  2452. * *
  2453. * Mountyzilla is distributed in the hope that it will be useful, *
  2454. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2455. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2456. * GNU General Public License for more details. *
  2457. * *
  2458. * You should have received a copy of the GNU General Public License *
  2459. * along with Mountyzilla; if not, write to the Free Software *
  2460. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2461. *********************************************************************************/
  2462.  
  2463. // x~x enchant
  2464.  
  2465. /* 2013-08-19 : correction auto syntaxe alert */
  2466.  
  2467. function treateEnchantement() {
  2468. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  2469. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  2470. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  2471. return;
  2472. var tab = infoEquipement.split(";");
  2473. if(tab.length<2)
  2474. return;
  2475. var idEquipement = tab[0];
  2476. var nomEquipement = tab[1];
  2477. for(var i=2;i<tab.length;i++)
  2478. nomEquipement += ";"+tab[i];
  2479. var nodes = document.evaluate(
  2480. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2481. if (nodes.snapshotLength != 3)
  2482. return;
  2483. for(var i=0;i<3;i++)
  2484. {
  2485. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2486. texte = texte.replace(" d'une "," d'un ");
  2487. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2488. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2489. monstre = monstre.replace(/ Géante?/,"");
  2490. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2491. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2492. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2493. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2494. }
  2495. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2496. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2497. var liste = MY_getValue(numTroll+".enchantement.liste");
  2498. if(!liste || liste=="")
  2499. {
  2500. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2501. }
  2502. else
  2503. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2504. }
  2505.  
  2506. function do_enchant() {
  2507. start_script(60);
  2508.  
  2509. treateEnchantement();
  2510. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2511. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  2512. displayScriptTime();
  2513. }
  2514.  
  2515. /*********************************************************************************
  2516. * This file is part of Mountyzilla. *
  2517. * *
  2518. * Mountyzilla is free software; you can redistribute it and/or modify *
  2519. * it under the terms of the GNU General Public License as published by *
  2520. * the Free Software Foundation; either version 2 of the License, or *
  2521. * (at your option) any later version. *
  2522. * *
  2523. * Mountyzilla is distributed in the hope that it will be useful, *
  2524. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2525. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2526. * GNU General Public License for more details. *
  2527. * *
  2528. * You should have received a copy of the GNU General Public License *
  2529. * along with Mountyzilla; if not, write to the Free Software *
  2530. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2531. *********************************************************************************/
  2532.  
  2533. // x~x myevent
  2534.  
  2535. // Script désactivé en attendant la màj vers le nouveau système de missions.
  2536. function do_myevent() {
  2537. }
  2538.  
  2539. /*********************************************************************************
  2540. * This file is part of Mountyzilla. *
  2541. * *
  2542. * Mountyzilla is free software; you can redistribute it and/or modify *
  2543. * it under the terms of the GNU General Public License as published by *
  2544. * the Free Software Foundation; either version 2 of the License, or *
  2545. * (at your option) any later version. *
  2546. * *
  2547. * Mountyzilla is distributed in the hope that it will be useful, *
  2548. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2549. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2550. * GNU General Public License for more details. *
  2551. * *
  2552. * You should have received a copy of the GNU General Public License *
  2553. * along with Mountyzilla; if not, write to the Free Software *
  2554. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2555. *********************************************************************************/
  2556.  
  2557. // x~x malus
  2558.  
  2559. /* v1.4 - 2014-01-06
  2560. * - Gestion des sorts double composante
  2561. * v1.4.1 - 2014-01-22
  2562. * - Correction décumul
  2563. * TODO
  2564. * - Identifier la position de "PV" dans l'ordre MH
  2565. */
  2566.  
  2567. var listeBM;
  2568.  
  2569.  
  2570. /* [functions] Utilitaires */
  2571.  
  2572. function decumul(bmt,nbr) {
  2573. var bmr;
  2574. if(!nbr || nbr<2) bmr = bmt;
  2575. else if(nbr==2) bmr = parseInt(0.67*bmt);
  2576. else if(nbr==3) bmr = parseInt(0.40*bmt);
  2577. else if(nbr==4) bmr = parseInt(0.25*bmt);
  2578. else if(nbr==5) bmr = parseInt(0.15*bmt);
  2579. else bmr = parseInt(0.1*bmt);
  2580. if(bmt<0) return Math.min(-1,bmr);
  2581. return Math.max(1,bmr);
  2582. }
  2583.  
  2584. function triecaracs(a,b) { // version Yoyor, mod by Dab
  2585. switch( a ) {
  2586. case 'ATT':
  2587. return -1;
  2588. case 'ESQ':
  2589. if(b=='ATT') return 1;
  2590. return -1;
  2591. case 'DEG':
  2592. switch( b ) {
  2593. case 'ATT':
  2594. case 'ESQ':
  2595. return 1;
  2596. default:
  2597. return -1;
  2598. }
  2599. case 'REG':
  2600. switch( b ) {
  2601. case 'ATT':
  2602. case 'ESQ':
  2603. case 'DEG':
  2604. return 1;
  2605. default:
  2606. return -1;
  2607. }
  2608. case 'Vue':
  2609. switch( b ) {
  2610. case 'ATT':
  2611. case 'ESQ':
  2612. case 'DEG':
  2613. case 'REG':
  2614. return 1;
  2615. default:
  2616. return -1;
  2617. }
  2618. case 'TOUR':
  2619. switch( b ) {
  2620. case 'ATT':
  2621. case 'ESQ':
  2622. case 'DEG':
  2623. case 'REG':
  2624. case 'Vue':
  2625. return 1;
  2626. default:
  2627. return -1;
  2628. }
  2629. case 'Armure':
  2630. switch( b ) {
  2631. case 'ATT':
  2632. case 'ESQ':
  2633. case 'DEG':
  2634. case 'REG':
  2635. case 'Vue':
  2636. case 'TOUR':
  2637. return 1;
  2638. default:
  2639. return -1;
  2640. }
  2641. case 'RM':
  2642. switch( b ) {
  2643. case 'ATT':
  2644. case 'ESQ':
  2645. case 'DEG':
  2646. case 'REG':
  2647. case 'Vue':
  2648. case 'TOUR':
  2649. case 'Armure':
  2650. return 1;
  2651. default:
  2652. return -1;
  2653. }
  2654. case 'MM':
  2655. switch( b ) {
  2656. case 'ATT':
  2657. case 'ESQ':
  2658. case 'DEG':
  2659. case 'REG':
  2660. case 'Vue':
  2661. case 'TOUR':
  2662. case 'Armure':
  2663. case 'RM':
  2664. return 1;
  2665. default:
  2666. return -1;
  2667. }
  2668. case 'Concentration':
  2669. switch( b ) {
  2670. case 'ATT':
  2671. case 'ESQ':
  2672. case 'DEG':
  2673. case 'REG':
  2674. case 'Vue':
  2675. case 'TOUR':
  2676. case 'Armure':
  2677. case 'RM':
  2678. case 'MM':
  2679. return 1;
  2680. default:
  2681. return -1;
  2682. }
  2683. case 'Fatigue':
  2684. switch( b ) {
  2685. case 'ATT':
  2686. case 'ESQ':
  2687. case 'DEG':
  2688. case 'REG':
  2689. case 'Vue':
  2690. case 'TOUR':
  2691. case 'Armure':
  2692. case 'RM':
  2693. case 'MM':
  2694. case 'Concentration':
  2695. return 1;
  2696. default:
  2697. return -1;
  2698. }
  2699. case "Dés d'attaque":
  2700. switch( b ) {
  2701. case 'ATT':
  2702. case 'ESQ':
  2703. case 'DEG':
  2704. case 'REG':
  2705. case 'Vue':
  2706. case 'TOUR':
  2707. case 'Armure':
  2708. case 'RM':
  2709. case 'MM':
  2710. case 'Concentration':
  2711. case 'Fatigue':
  2712. return 1;
  2713. default:
  2714. return -1;
  2715. }
  2716. case 'Dés de dégâts':
  2717. switch( b ) {
  2718. case 'ATT':
  2719. case 'ESQ':
  2720. case 'DEG':
  2721. case 'REG':
  2722. case 'Vue':
  2723. case 'TOUR':
  2724. case 'Armure':
  2725. case 'RM':
  2726. case 'MM':
  2727. case 'Concentration':
  2728. case 'Fatigue':
  2729. case "Dés d'attaque":
  2730. return 1;
  2731. default:
  2732. return -1;
  2733. }
  2734. default :
  2735. switch( b ) {
  2736. case 'ATT':
  2737. case 'ESQ':
  2738. case 'DEG':
  2739. case 'REG':
  2740. case 'Vue':
  2741. case 'TOUR':
  2742. case 'Armure':
  2743. case 'RM':
  2744. case 'MM':
  2745. case 'Concentration':
  2746. case 'Fatigue':
  2747. case "Dés d'attaque":
  2748. case 'Dés de dégâts':
  2749. return 1;
  2750. default:
  2751. return -1;
  2752. }
  2753. }
  2754. }
  2755.  
  2756.  
  2757. /* [functions] Fonctions hide / display */
  2758.  
  2759. function toggleDetails() {
  2760. if(MY_getValue('BMDETAIL')!='false') {
  2761. MY_setValue('BMDETAIL','false');
  2762. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  2763. for(var i=0 ; i<trlist.length ; i++)
  2764. trlist[i].style.display = 'none';
  2765. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  2766. for(var i=0 ; i<trlist.length ; i++)
  2767. trlist[i].style = '';
  2768. }
  2769. else {
  2770. MY_setValue('BMDETAIL','true');
  2771. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  2772. for(var i=0 ; i<trlist.length ; i++)
  2773. trlist[i].style.display = 'none';
  2774. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  2775. for(var i=0 ; i<trlist.length ; i++)
  2776. trlist[i].style = '';
  2777. }
  2778. }
  2779.  
  2780. function toggleBMList() {
  2781. if(MY_getValue('BMHIDELIST')=='true') {
  2782. MY_setValue('BMHIDELIST','false');
  2783. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  2784. listeBM.snapshotItem(i).style = '';
  2785. document.getElementsByTagName('thead')[0].style = '';
  2786. document.getElementById('trhelp').style = '';
  2787. }
  2788. else {
  2789. MY_setValue('BMHIDELIST','true');
  2790. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  2791. listeBM.snapshotItem(i).style.display = 'none';
  2792. document.getElementsByTagName('thead')[0].style.display = 'none';
  2793. document.getElementById('trhelp').style.display = 'none';
  2794. }
  2795. }
  2796.  
  2797. function setDisplayBM() {
  2798. if(!listeBM) return;
  2799. var titre = document.getElementById('titre2');
  2800. if(titre) {
  2801. titre.style.cursor = 'pointer';
  2802. titre.onclick = toggleBMList;
  2803. }
  2804. var tfoot = document.getElementsByTagName('tfoot')[0];
  2805. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  2806. tfoot, null, 9, null).singleNodeValue;
  2807. tr.id = 'trhelp';
  2808. if(MY_getValue('BMHIDELIST')=='true') {
  2809. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  2810. listeBM.snapshotItem(i).style.display = 'none';
  2811. document.getElementsByTagName('thead')[0].style.display = 'none';
  2812. tr.style.display = 'none';
  2813. }
  2814. }
  2815.  
  2816.  
  2817. /* [functions] Fonction principale */
  2818.  
  2819. function traiteMalus() {
  2820. var mainTab = document.getElementsByTagName('table')[0];
  2821. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  2822. if(listeBM.snapshotLength==0) return;
  2823. /* Suppression des BM de fatigue stockés */
  2824. if(MY_getValue(numTroll+'.bm.fatigue'))
  2825. MY_removeValue(numTroll+'.bm.fatigue');
  2826. /* Extraction des données */
  2827. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  2828. var nb = 0;
  2829. while(nb<listeBM.snapshotLength) {
  2830. tr = listeBM.snapshotItem(nb); nb++;
  2831. var effetsT = tr.childNodes[5].textContent.split(' | ');
  2832. var phymag = tr.childNodes[9].textContent;
  2833. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  2834. var type = tr.childNodes[3].textContent, nom;
  2835. // si c'est un type à décumul
  2836. switch(type) {
  2837. case 'Potion':
  2838. case 'Parchemin':
  2839. case 'Sortilège':
  2840. case 'Capacité Spéciale':
  2841. nom = tr.childNodes[1].textContent+phymag;
  2842. break;
  2843. default:
  2844. nom = 'pasdedecumul';
  2845. }
  2846. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  2847. nom = 'pasdedecumul';
  2848. uniListe[nb] = {
  2849. 'duree':duree,
  2850. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  2851. 'caracs':{}
  2852. }
  2853. for(var i=0 ; i<effetsT.length ; i++) {
  2854. if(effetsT[i].indexOf(':')==-1) continue;
  2855. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  2856. // nom = 'pasdedecumul' si pas de décumul
  2857. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  2858. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  2859. uniListe[nb]['type'] = phymag;
  2860. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  2861. uniListe[nb]['caracs'][carac] = bm;
  2862. listeDurees[duree] = true;
  2863. }
  2864. }
  2865. /* Gestion des décumuls et cumuls des durées */
  2866. var toursGeres = [];
  2867. for(var d in listeDurees) toursGeres.push(d);
  2868. toursGeres.sort( function (a,b){return b-a;} );
  2869. // pour sauvegarder les bm de fatigue
  2870. var strfat = '';
  2871. // Pour affichage & adpatation à footable.js (statique)
  2872. var thead = document.getElementsByTagName('thead')[0];
  2873. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  2874. thead, null, 7, null).snapshotLength;
  2875. var tfoot = document.getElementsByTagName('tfoot')[0];
  2876. for(var i=0 ; i<toursGeres.length ; i++) {
  2877. var tour = toursGeres[i];
  2878. var effetsCeTour = {}; decumulsCeTour = {};
  2879. for(var nb=1 ; nb<uniListe.length ; nb++) {
  2880. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  2881. continue;
  2882. var nom = uniListe[nb]['nom'];
  2883. if(nom!='pasdedecumul') {
  2884. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  2885. decumulsCeTour[nom]++;
  2886. }
  2887. for(var carac in uniListe[nb]['caracs']) {
  2888. var bm = uniListe[nb]['caracs'][carac];
  2889. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  2890. var type = uniListe[nb]['type'];
  2891. if(!effetsCeTour[carac])
  2892. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  2893. if(nom=='pasdedecumul')
  2894. effetsCeTour[carac][type] += bm;
  2895. else
  2896. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  2897. }
  2898. else {
  2899. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  2900. if(nom=='pasdedecumul' || carac=='Fatigue')
  2901. effetsCeTour[carac] += bm;
  2902. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  2903. effetsCeTour[carac] += decumul(2*bm,decumulsCeTour[nom])/2;
  2904. else
  2905. effetsCeTour[carac] += decumul(bm,decumulsCeTour[nom]);
  2906. }
  2907. }
  2908. }
  2909. /* Création du bilan du tour */
  2910. var texteD = '', texteS = '';
  2911. var caracGerees = [];
  2912. for(var k in effetsCeTour) caracGerees.push(k);
  2913. caracGerees.sort( triecaracs );
  2914. for(var j=0 ; j<caracGerees.length ; j++) {
  2915. var carac = caracGerees[j], str = '';
  2916. switch( carac ) {
  2917. case 'ATT':
  2918. case 'DEG':
  2919. case 'Armure':
  2920. var phy = effetsCeTour[carac]['Physique'];
  2921. var mag = effetsCeTour[carac]['Magie'];
  2922. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  2923. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  2924. break;
  2925. case 'TOUR':
  2926. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  2927. break;
  2928. case 'Fatigue':
  2929. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  2930. case 'PV':
  2931. case 'ESQ':
  2932. case 'REG':
  2933. case 'Vue':
  2934. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  2935. break;
  2936. default:
  2937. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  2938. }
  2939. if(str) {
  2940. texteD += str;
  2941. texteS += str;
  2942. }
  2943. }
  2944. /* Affichage */
  2945. // Si rien à afficher on passe
  2946. if(!texteD) continue;
  2947. // Si BMM+BMP=0
  2948. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  2949. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  2950. if(MY_getValue('BMDETAIL')=='false')
  2951. tr.style.display = 'none';
  2952. var td = appendTdText(tr,texteD.substring(3));
  2953. td.colSpan = 5-nbHidden;
  2954. var txttour = toursGeres[i]+' Tour';
  2955. if(toursGeres[i]>1) txttour += 's';
  2956. appendTdText(tr,txttour);
  2957. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  2958. if(MY_getValue('BMDETAIL')!='false')
  2959. tr.style.display = 'none';
  2960. td = appendTdText(tr,texteS);
  2961. td.colSpan = 5-nbHidden;
  2962. appendTdText(tr,txttour);
  2963. }
  2964. /* mise en place toggleDetails */
  2965. tfoot.style.cursor = 'pointer';
  2966. tfoot.onclick = toggleDetails;
  2967. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  2968. if(strfat)
  2969. MY_setValue(numTroll+'.bm.fatigue',strfat);
  2970. }
  2971.  
  2972. function do_malus() {
  2973. try {
  2974. start_script();
  2975. traiteMalus();
  2976. setDisplayBM();
  2977. displayScriptTime();
  2978. }
  2979. catch(e) {window.alert(e)};
  2980. }
  2981.  
  2982. /*******************************************************************************
  2983. * This file is part of Mountyzilla. *
  2984. * *
  2985. * Mountyzilla is free software; you can redistribute it and/or modify *
  2986. * it under the terms of the GNU General Public License as published by *
  2987. * the Free Software Foundation; either version 2 of the License, or *
  2988. * (at your option) any later version. *
  2989. * *
  2990. * Mountyzilla is distributed in the hope that it will be useful, *
  2991. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2992. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2993. * GNU General Public License for more details. *
  2994. * *
  2995. * You should have received a copy of the GNU General Public License *
  2996. * along with Mountyzilla; if not, write to the Free Software *
  2997. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2998. *******************************************************************************/
  2999.  
  3000. // x~x mouches
  3001.  
  3002. var mainTab, tr_mouches;
  3003.  
  3004. function initialiseMouches() {
  3005. // Lanceur global
  3006. try {
  3007. mainTab = document.getElementById('mouches');
  3008. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3009. } catch(e) {
  3010. avertissement('Erreur MZ:<br />Consulter la console.');
  3011. window.console.error('Erreur MZ mouches:\n'+e);
  3012. return;
  3013. }
  3014. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3015. setDisplayMouches();
  3016. traiteMouches();
  3017. }
  3018.  
  3019. function setDisplayMouches() {
  3020. // Initialise l'affichage / l'effacement du détail des mouches
  3021. var titre = document.getElementById('titre2');
  3022. if(titre) {
  3023. titre.style.cursor = 'pointer';
  3024. titre.onclick = toggleMouches;
  3025. }
  3026. var tfoot = document.getElementsByTagName('tfoot')[0];
  3027. if(tfoot) {
  3028. tfoot.style.cursor = 'pointer';
  3029. tfoot.onclick = toggleMouches;
  3030. }
  3031. if(MY_getValue('HIDEMOUCHES')=='true') {
  3032. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3033. tr_mouches.snapshotItem(i).style.display = 'none';
  3034. }
  3035. document.getElementsByTagName('thead')[0].style.display = 'none';
  3036. }
  3037. }
  3038.  
  3039. function toggleMouches() {
  3040. // Handler pour afficher / masquer les détasil
  3041. if(MY_getValue('HIDEMOUCHES')=='true') {
  3042. MY_setValue('HIDEMOUCHES','false');
  3043. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3044. tr_mouches.snapshotItem(i).style.display = '';
  3045. }
  3046. document.getElementsByTagName('thead')[0].style.display = '';
  3047. } else {
  3048. MY_setValue('HIDEMOUCHES','true');
  3049. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3050. tr_mouches.snapshotItem(i).style.display = 'none';
  3051. }
  3052. document.getElementsByTagName('thead')[0].style.display = 'none';
  3053. }
  3054. }
  3055.  
  3056. function traiteMouches() {
  3057. // Traitement complet: présence et effets des mouches
  3058. var listeTypes = {}, effetsActifs = {};
  3059. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3060. var tr = tr_mouches.snapshotItem(i);
  3061. // La mouche est-elle présente?
  3062. var etat = document.evaluate(
  3063. './img',
  3064. tr.cells[6], null, 9, null
  3065. ).singleNodeValue.alt;
  3066. if(etat!='La Mouche est là') { continue; }
  3067. // Extraction du type de mouche
  3068. var type = trim(tr.cells[3].textContent);
  3069. if(!listeTypes[type]) {
  3070. listeTypes[type] = 1;
  3071. } else {
  3072. listeTypes[type]++;
  3073. }
  3074. // La mouche a-t-elle un effet?
  3075. var effet = trim(tr.cells[2].textContent);
  3076. if(etat!='La Mouche est là' || !effet) { continue; }
  3077. // Si oui, extraction des effets (multiples pour pogées)
  3078. var caracs = effet.split(' | ');
  3079. for(var j=0 ; j<caracs.length ; j++) {
  3080. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3081. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3082. if(effetsActifs[carac]===void(0)) {
  3083. effetsActifs[carac] = valeur;
  3084. } else {
  3085. effetsActifs[carac] += valeur;
  3086. }
  3087. }
  3088. }
  3089. // Extraction Effet total et affichage des différences à la normale
  3090. var tfoot = document.getElementsByTagName('tfoot')[0];
  3091. if(!tfoot) { return; }
  3092. var nodeTotal = document.evaluate(
  3093. ".//b[contains(./text(),'Effet total')]",
  3094. tfoot, null, 9, null
  3095. ).singleNodeValue.nextSibling;
  3096. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3097. var texte = ' ';
  3098. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3099. if(texte.length>1) { texte += ' | '; }
  3100. var carac = trim(
  3101. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3102. );
  3103. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3104. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3105. texte += effetsTheoriques[i];
  3106. } else {
  3107. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3108. if(carac=='TOUR') { texte += ' min'; }
  3109. texte += '</b>';
  3110. }
  3111. }
  3112. var span = document.createElement('span');
  3113. span.innerHTML = texte;
  3114. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3115. // Affichage des différences du nombre de mouches de chaque type
  3116. var mouchesParType = document.evaluate(
  3117. "./tr/td/ul/li/text()",
  3118. tfoot, null, 7, null
  3119. );
  3120. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3121. var node = mouchesParType.snapshotItem(i);
  3122. var mots = node.nodeValue.split(' ');
  3123. var type = mots.pop();
  3124. if(!listeTypes[type]) {
  3125. node.nodeValue += ' (0 présente)';
  3126. } else if(mots[0]!=listeTypes[type]) {
  3127. if(listeTypes[type]==1) {
  3128. node.nodeValue += ' (1 présente)';
  3129. } else {
  3130. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3131. }
  3132. }
  3133. }
  3134. }
  3135.  
  3136. function do_mouches() {
  3137. start_script();
  3138. initialiseMouches();
  3139. displayScriptTime();
  3140. }
  3141.  
  3142. /*********************************************************************************
  3143. * This file is part of Mountyzilla. *
  3144. * *
  3145. * Mountyzilla is free software; you can redistribute it and/or modify *
  3146. * it under the terms of the GNU General Public License as published by *
  3147. * the Free Software Foundation; either version 2 of the License, or *
  3148. * (at your option) any later version. *
  3149. * *
  3150. * Mountyzilla is distributed in the hope that it will be useful, *
  3151. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3152. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3153. * GNU General Public License for more details. *
  3154. * *
  3155. * You should have received a copy of the GNU General Public License *
  3156. * along with Mountyzilla; if not, write to the Free Software *
  3157. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3158. *********************************************************************************/
  3159.  
  3160. // x~x equipgowap
  3161.  
  3162. var popup;
  3163.  
  3164. function initPopupEquipgowap() {
  3165. popup = document.createElement('div');
  3166. popup.setAttribute('id', 'popup');
  3167. popup.setAttribute('class', 'mh_textbox');
  3168. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3169. 'display: inline; z-index: 3; max-width: 400px;');
  3170. document.body.appendChild(popup);
  3171. }
  3172.  
  3173. function showPopupEquipgowap(evt) {
  3174. var texte = this.getAttribute("texteinfo");
  3175. popup.innerHTML = texte;
  3176. popup.style.left = evt.pageX + 15 + 'px';
  3177. popup.style.top = evt.pageY + 'px';
  3178. popup.style.visibility = "visible";
  3179. }
  3180.  
  3181. function hidePopup() {
  3182. popup.style.visibility = "hidden";
  3183. }
  3184.  
  3185. function createPopupImage(url, text)
  3186. {
  3187. var img = document.createElement('img');
  3188. img.setAttribute('src',url);
  3189. img.setAttribute('align','ABSMIDDLE');
  3190. img.setAttribute("texteinfo",text);
  3191. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3192. img.addEventListener("mouseout", hidePopup,true);
  3193. return img;
  3194. }
  3195.  
  3196. function formateTexte(texte)
  3197. {
  3198. texte = texte.replace(/\n/g,"<br/>");
  3199. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3200. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3201. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3202. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3203. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3204. return texte;
  3205. }
  3206.  
  3207.  
  3208. function treateGowaps() {
  3209. //On récupère les gowaps possédants des composants
  3210. var tbodys = document.evaluate(
  3211. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3212. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3213. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3214. var tbody = tbodys.snapshotItem(j);
  3215. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3216. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3217. if(MY_getValue("NOINFOEM") != "true")
  3218. insertEMInfos(tbody);
  3219. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3220. insertEnchantInfos(tbody);
  3221. }
  3222. }
  3223.  
  3224. function treateChampi() {
  3225. if(MY_getValue("NOINFOEM") == "true")
  3226. return false;
  3227. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3228. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3229. if (nodes.snapshotLength == 0)
  3230. return false;
  3231.  
  3232. for (var i = 0; i < nodes.snapshotLength; i++) {
  3233. var node = nodes.snapshotItem(i);
  3234. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3235. if(texte.indexOf("*")!=-1)
  3236. texte = texte.substring(0,texte.lastIndexOf(" "));
  3237. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3238. if(moisChampi[nomChampi])
  3239. {
  3240. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3241. }
  3242. }
  3243. }
  3244.  
  3245. function do_equipgowap() {
  3246. start_script();
  3247.  
  3248. treateGowaps();
  3249. treateChampi();
  3250. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3251. {
  3252. initPopupEquipgowap();
  3253. computeEnchantementEquipement(createPopupImage,formateTexte);
  3254. }
  3255.  
  3256. displayScriptTime();
  3257. }
  3258.  
  3259. /*********************************************************************************
  3260. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3261. *********************************************************************************/
  3262.  
  3263. // x~x ordresgowap
  3264.  
  3265. /* v0.2 by Dab - 2013-08-31
  3266. * - correction acquisition posale initiale
  3267. * - correction tare et affichage mire
  3268. */
  3269.  
  3270. function setCarteGogo() {
  3271. try {
  3272. var pars = document.getElementsByTagName('p');
  3273. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]",
  3274. pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3275. }
  3276. catch(e) {return;}
  3277. var serv_img_trou = URL_MZimg09 + "carte_trou.png";
  3278. var serv_img_cible = URL_MZimg09 + "rep.png";
  3279.  
  3280. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  3281. var lignes = pars[0].getElementsByTagName('tr');
  3282. var nbpt = 0;
  3283. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  3284. for(var i=0 ; i<lignes.length ; i++) {
  3285. if(lignes[i].className == 'mh_tdpage_fo') {
  3286. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  3287. if(point) {
  3288. nbpt++;
  3289. trajet += point[1]+','+point[2]+','+point[3]+',';
  3290. }
  3291. }
  3292. }
  3293. var nvdiv = "<div class='mh_tdpage' style='width:510px;height:455px;'><img src='"+serv_img_trou+"' style='position:relative;top:0px;left:0px;z-index:100;border-width:0px' usemap='#coord_trou'/>";
  3294. var base = [-229,-5];
  3295. if (nbpt>0) {
  3296. base = [-684,-5];
  3297. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  3298. }
  3299. nvdiv += "<img src='"+serv_img_cible+"' style='position:relative;top:"+(base[0]-2*pos[1])+"px;left:"+(base[1]+2*pos[0])+"px;z-index:100;'/>";
  3300.  
  3301. nvdiv += '<map name="coord_trou"><area shape="circle" href="#" coords="260,333,3" title="X=5, Y=-49" ><area shape="circle" href="#" coords="262,335,3" title="X=6, Y=-50" ><area shape="circle" href="#" coords="260,335,3" title="X=5, Y=-50" ><area shape="circle" href="#" coords="262,333,3" title="X=6, Y=-49" ><area shape="circle" href="#" coords="294,163,3" title="X=22, Y=36" ><area shape="circle" href="#" coords="292,163,3" title="X=21, Y=36" ><area shape="circle" href="#" coords="294,165,3" title="X=22, Y=35" ><area shape="circle" href="#" coords="292,165,3" title="X=21, Y=35" ><area shape="circle" href="#" coords="124,217,3" title="X=-63, Y=9" ><area shape="circle" href="#" coords="122,217,3" title="X=-64, Y=9" ><area shape="circle" href="#" coords="124,219,3" title="X=-63, Y=8" ><area shape="circle" href="#" coords="122,219,3" title="X=-64, Y=8" ><area shape="circle" href="#" coords="378,95,3" title="X=64, Y=70" ><area shape="circle" href="#" coords="146,121,3" title="X=-52, Y=57" ><area shape="circle" href="#" coords="346,313,3" title="X=48, Y=-39" ><area shape="circle" href="#" coords="310,339,3" title="X=30, Y=-52" ><area shape="circle" href="#" coords="274,265,3" title="X=12, Y=-15" ><area shape="circle" href="#" coords="360,95,3" title="X=55, Y=70" ><area shape="circle" href="#" coords="224,91,3" title="X=-13, Y=72" ><area shape="circle" href="#" coords="226,91,3" title="X=-12, Y=72" ><area shape="circle" href="#" coords="224,89,3" title="X=-13, Y=73" ><area shape="circle" href="#" coords="226,89,3" title="X=-12, Y=73" ><area shape="circle" href="#" coords="148,281,3" title="X=-51, Y=-23" ><area shape="circle" href="#" coords="150,281,3" title="X=-50, Y=-23" ><area shape="circle" href="#" coords="148,279,3" title="X=-51, Y=-22" ><area shape="circle" href="#" coords="150,279,3" title="X=-50, Y=-22" ><area shape="circle" href="#" coords="130,301,3" title="X=-60, Y=-33" ><area shape="circle" href="#" coords="132,301,3" title="X=-59, Y=-33" ><area shape="circle" href="#" coords="130,299,3" title="X=-60, Y=-32" ><area shape="circle" href="#" coords="132,299,3" title="X=-59, Y=-32" ><area shape="circle" href="#" coords="116,311,3" title="X=-67, Y=-38" ><area shape="circle" href="#" coords="118,311,3" title="X=-66, Y=-38" ><area shape="circle" href="#" coords="116,309,3" title="X=-67, Y=-37" ><area shape="circle" href="#" coords="118,309,3" title="X=-66, Y=-37" ><area shape="circle" href="#" coords="260,173,3" title="X=5, Y=31" ><area shape="circle" href="#" coords="262,173,3" title="X=6, Y=31" ><area shape="circle" href="#" coords="260,171,3" title="X=5, Y=32" ><area shape="circle" href="#" coords="262,171,3" title="X=6, Y=32" ><area shape="circle" href="#" coords="178,339,3" title="X=-36, Y=-52" ><area shape="circle" href="#" coords="180,339,3" title="X=-35, Y=-52" ><area shape="circle" href="#" coords="178,337,3" title="X=-36, Y=-51" ><area shape="circle" href="#" coords="180,337,3" title="X=-35, Y=-51" ><area shape="circle" href="#" coords="182,107,3" title="X=-34, Y=64" ><area shape="circle" href="#" coords="182,105,3" title="X=-34, Y=65" ><area shape="circle" href="#" coords="270,109,3" title="X=10, Y=63" ><area shape="circle" href="#" coords="272,109,3" title="X=11, Y=63" ><area shape="circle" href="#" coords="270,107,3" title="X=10, Y=64" ><area shape="circle" href="#" coords="272,107,3" title="X=11, Y=64" ><area shape="circle" href="#" coords="180,207,3" title="X=-35, Y=14" ><area shape="circle" href="#" coords="182,207,3" title="X=-34, Y=14" ><area shape="circle" href="#" coords="180,205,3" title="X=-35, Y=15" ><area shape="circle" href="#" coords="182,205,3" title="X=-34, Y=15" ><area shape="circle" href="#" coords="398,173,3" title="X=74, Y=31" ><area shape="circle" href="#" coords="400,173,3" title="X=75, Y=31" ><area shape="circle" href="#" coords="398,171,3" title="X=74, Y=32" ><area shape="circle" href="#" coords="400,171,3" title="X=75, Y=32" ><area shape="circle" href="#" coords="342,133,3" title="X=46, Y=51" ><area shape="circle" href="#" coords="344,133,3" title="X=47, Y=51" ><area shape="circle" href="#" coords="342,131,3" title="X=46, Y=52" ><area shape="circle" href="#" coords="344,131,3" title="X=47, Y=52" ><area shape="circle" href="#" coords="180,107,3" title="X=-35, Y=64" ><area shape="circle" href="#" coords="180,105,3" title="X=-35, Y=65" ><area shape="circle" href="#" coords="108,251,3" title="X=-71, Y=-8" ><area shape="circle" href="#" coords="110,251,3" title="X=-70, Y=-8" ><area shape="circle" href="#" coords="108,249,3" title="X=-71, Y=-7" ><area shape="circle" href="#" coords="110,249,3" title="X=-70, Y=-7" ><area shape="circle" href="#" coords="346,191,3" title="X=48, Y=22" ><area shape="circle" href="#" coords="346,189,3" title="X=48, Y=23" ><area shape="circle" href="#" coords="346,187,3" title="X=48, Y=24" ><area shape="circle" href="#" coords="346,185,3" title="X=48, Y=25" ><area shape="circle" href="#" coords="348,195,3" title="X=49, Y=20" ><area shape="circle" href="#" coords="348,193,3" title="X=49, Y=21" ><area shape="circle" href="#" coords="348,191,3" title="X=49, Y=22" ><area shape="circle" href="#" coords="348,189,3" title="X=49, Y=23" ><area shape="circle" href="#" coords="348,187,3" title="X=49, Y=24" ><area shape="circle" href="#" coords="348,185,3" title="X=49, Y=25" ><area shape="circle" href="#" coords="348,183,3" title="X=49, Y=26" ><area shape="circle" href="#" coords="348,181,3" title="X=49, Y=27" ><area shape="circle" href="#" coords="350,199,3" title="X=50, Y=18" ><area shape="circle" href="#" coords="350,197,3" title="X=50, Y=19" ><area shape="circle" href="#" coords="350,195,3" title="X=50, Y=20" ><area shape="circle" href="#" coords="350,193,3" title="X=50, Y=21" ><area shape="circle" href="#" coords="350,191,3" title="X=50, Y=22" ><area shape="circle" href="#" coords="350,189,3" title="X=50, Y=23" ><area shape="circle" href="#" coords="350,187,3" title="X=50, Y=24" ><area shape="circle" href="#" coords="350,185,3" title="X=50, Y=25" ><area shape="circle" href="#" coords="350,183,3" title="X=50, Y=26" ><area shape="circle" href="#" coords="350,181,3" title="X=50, Y=27" ><area shape="circle" href="#" coords="350,179,3" title="X=50, Y=28" ><area shape="circle" href="#" coords="350,177,3" title="X=50, Y=29" ><area shape="circle" href="#" coords="352,201,3" title="X=51, Y=17" ><area shape="circle" href="#" coords="352,199,3" title="X=51, Y=18" ><area shape="circle" href="#" coords="352,197,3" title="X=51, Y=19" ><area shape="circle" href="#" coords="352,195,3" title="X=51, Y=20" ><area shape="circle" href="#" coords="352,193,3" title="X=51, Y=21" ><area shape="circle" href="#" coords="352,191,3" title="X=51, Y=22" ><area shape="circle" href="#" coords="352,189,3" title="X=51, Y=23" ><area shape="circle" href="#" coords="352,187,3" title="X=51, Y=24" ><area shape="circle" href="#" coords="352,185,3" title="X=51, Y=25" ><area shape="circle" href="#" coords="352,183,3" title="X=51, Y=26" ><area shape="circle" href="#" coords="352,181,3" title="X=51, Y=27" ><area shape="circle" href="#" coords="352,179,3" title="X=51, Y=28" ><area shape="circle" href="#" coords="352,177,3" title="X=51, Y=29" ><area shape="circle" href="#" coords="352,175,3" title="X=51, Y=30" ><area shape="circle" href="#" coords="354,201,3" title="X=52, Y=17" ><area shape="circle" href="#" coords="354,199,3" title="X=52, Y=18" ><area shape="circle" href="#" coords="354,197,3" title="X=52, Y=19" ><area shape="circle" href="#" coords="354,195,3" title="X=52, Y=20" ><area shape="circle" href="#" coords="354,193,3" title="X=52, Y=21" ><area shape="circle" href="#" coords="354,191,3" title="X=52, Y=22" ><area shape="circle" href="#" coords="354,189,3" title="X=52, Y=23" ><area shape="circle" href="#" coords="354,187,3" title="X=52, Y=24" ><area shape="circle" href="#" coords="354,185,3" title="X=52, Y=25" ><area shape="circle" href="#" coords="354,183,3" title="X=52, Y=26" ><area shape="circle" href="#" coords="354,181,3" title="X=52, Y=27" ><area shape="circle" href="#" coords="354,179,3" title="X=52, Y=28" ><area shape="circle" href="#" coords="354,177,3" title="X=52, Y=29" ><area shape="circle" href="#" coords="354,175,3" title="X=52, Y=30" ><area shape="circle" href="#" coords="356,203,3" title="X=53, Y=16" ><area shape="circle" href="#" coords="356,201,3" title="X=53, Y=17" ><area shape="circle" href="#" coords="356,199,3" title="X=53, Y=18" ><area shape="circle" href="#" coords="356,197,3" title="X=53, Y=19" ><area shape="circle" href="#" coords="356,195,3" title="X=53, Y=20" ><area shape="circle" href="#" coords="356,193,3" title="X=53, Y=21" ><area shape="circle" href="#" coords="356,191,3" title="X=53, Y=22" ><area shape="circle" href="#" coords="356,189,3" title="X=53, Y=23" ><area shape="circle" href="#" coords="356,187,3" title="X=53, Y=24" ><area shape="circle" href="#" coords="356,185,3" title="X=53, Y=25" ><area shape="circle" href="#" coords="356,183,3" title="X=53, Y=26" ><area shape="circle" href="#" coords="356,181,3" title="X=53, Y=27" ><area shape="circle" href="#" coords="356,179,3" title="X=53, Y=28" ><area shape="circle" href="#" coords="356,177,3" title="X=53, Y=29" ><area shape="circle" href="#" coords="356,175,3" title="X=53, Y=30" ><area shape="circle" href="#" coords="356,173,3" title="X=53, Y=31" ><area shape="circle" href="#" coords="358,203,3" title="X=54, Y=16" ><area shape="circle" href="#" coords="358,201,3" title="X=54, Y=17" ><area shape="circle" href="#" coords="358,199,3" title="X=54, Y=18" ><area shape="circle" href="#" coords="358,197,3" title="X=54, Y=19" ><area shape="circle" href="#" coords="358,195,3" title="X=54, Y=20" ><area shape="circle" href="#" coords="358,193,3" title="X=54, Y=21" ><area shape="circle" href="#" coords="358,191,3" title="X=54, Y=22" ><area shape="circle" href="#" coords="358,189,3" title="X=54, Y=23" ><area shape="circle" href="#" coords="358,187,3" title="X=54, Y=24" ><area shape="circle" href="#" coords="358,185,3" title="X=54, Y=25" ><area shape="circle" href="#" coords="358,183,3" title="X=54, Y=26" ><area shape="circle" href="#" coords="358,181,3" title="X=54, Y=27" ><area shape="circle" href="#" coords="358,179,3" title="X=54, Y=28" ><area shape="circle" href="#" coords="358,177,3" title="X=54, Y=29" ><area shape="circle" href="#" coords="358,175,3" title="X=54, Y=30" ><area shape="circle" href="#" coords="358,173,3" title="X=54, Y=31" ><area shape="circle" href="#" coords="360,205,3" title="X=55, Y=15" ><area shape="circle" href="#" coords="360,203,3" title="X=55, Y=16" ><area shape="circle" href="#" coords="360,201,3" title="X=55, Y=17" ><area shape="circle" href="#" coords="360,199,3" title="X=55, Y=18" ><area shape="circle" href="#" coords="360,197,3" title="X=55, Y=19" ><area shape="circle" href="#" coords="360,195,3" title="X=55, Y=20" ><area shape="circle" href="#" coords="360,193,3" title="X=55, Y=21" ><area shape="circle" href="#" coords="360,191,3" title="X=55, Y=22" ><area shape="circle" href="#" coords="360,189,3" title="X=55, Y=23" ><area shape="circle" href="#" coords="360,187,3" title="X=55, Y=24" ><area shape="circle" href="#" coords="360,185,3" title="X=55, Y=25" ><area shape="circle" href="#" coords="360,183,3" title="X=55, Y=26" ><area shape="circle" href="#" coords="360,181,3" title="X=55, Y=27" ><area shape="circle" href="#" coords="360,179,3" title="X=55, Y=28" ><area shape="circle" href="#" coords="360,177,3" title="X=55, Y=29" ><area shape="circle" href="#" coords="360,175,3" title="X=55, Y=30" ><area shape="circle" href="#" coords="360,173,3" title="X=55, Y=31" ><area shape="circle" href="#" coords="360,171,3" title="X=55, Y=32" ><area shape="circle" href="#" coords="362,205,3" title="X=56, Y=15" ><area shape="circle" href="#" coords="362,203,3" title="X=56, Y=16" ><area shape="circle" href="#" coords="362,201,3" title="X=56, Y=17" ><area shape="circle" href="#" coords="362,199,3" title="X=56, Y=18" ><area shape="circle" href="#" coords="362,197,3" title="X=56, Y=19" ><area shape="circle" href="#" coords="362,195,3" title="X=56, Y=20" ><area shape="circle" href="#" coords="362,193,3" title="X=56, Y=21" ><area shape="circle" href="#" coords="362,191,3" title="X=56, Y=22" ><area shape="circle" href="#" coords="362,189,3" title="X=56, Y=23" ><area shape="circle" href="#" coords="362,187,3" title="X=56, Y=24" ><area shape="circle" href="#" coords="362,185,3" title="X=56, Y=25" ><area shape="circle" href="#" coords="362,183,3" title="X=56, Y=26" ><area shape="circle" href="#" coords="362,181,3" title="X=56, Y=27" ><area shape="circle" href="#" coords="362,179,3" title="X=56, Y=28" ><area shape="circle" href="#" coords="362,177,3" title="X=56, Y=29" ><area shape="circle" href="#" coords="362,175,3" title="X=56, Y=30" ><area shape="circle" href="#" coords="362,173,3" title="X=56, Y=31" ><area shape="circle" href="#" coords="362,171,3" title="X=56, Y=32" ><area shape="circle" href="#" coords="364,205,3" title="X=57, Y=15" ><area shape="circle" href="#" coords="364,203,3" title="X=57, Y=16" ><area shape="circle" href="#" coords="364,201,3" title="X=57, Y=17" ><area shape="circle" href="#" coords="364,199,3" title="X=57, Y=18" ><area shape="circle" href="#" coords="364,197,3" title="X=57, Y=19" ><area shape="circle" href="#" coords="364,195,3" title="X=57, Y=20" ><area shape="circle" href="#" coords="364,193,3" title="X=57, Y=21" ><area shape="circle" href="#" coords="364,191,3" title="X=57, Y=22" ><area shape="circle" href="#" coords="364,189,3" title="X=57, Y=23" ><area shape="circle" href="#" coords="364,187,3" title="X=57, Y=24" ><area shape="circle" href="#" coords="364,185,3" title="X=57, Y=25" ><area shape="circle" href="#" coords="364,183,3" title="X=57, Y=26" ><area shape="circle" href="#" coords="364,181,3" title="X=57, Y=27" ><area shape="circle" href="#" coords="364,179,3" title="X=57, Y=28" ><area shape="circle" href="#" coords="364,177,3" title="X=57, Y=29" ><area shape="circle" href="#" coords="364,175,3" title="X=57, Y=30" ><area shape="circle" href="#" coords="364,173,3" title="X=57, Y=31" ><area shape="circle" href="#" coords="364,171,3" title="X=57, Y=32" ><area shape="circle" href="#" coords="366,205,3" title="X=58, Y=15" ><area shape="circle" href="#" coords="366,203,3" title="X=58, Y=16" ><area shape="circle" href="#" coords="366,201,3" title="X=58, Y=17" ><area shape="circle" href="#" coords="366,199,3" title="X=58, Y=18" ><area shape="circle" href="#" coords="366,197,3" title="X=58, Y=19" ><area shape="circle" href="#" coords="366,195,3" title="X=58, Y=20" ><area shape="circle" href="#" coords="366,193,3" title="X=58, Y=21" ><area shape="circle" href="#" coords="366,191,3" title="X=58, Y=22" ><area shape="circle" href="#" coords="366,189,3" title="X=58, Y=23" ><area shape="circle" href="#" coords="366,187,3" title="X=58, Y=24" ><area shape="circle" href="#" coords="366,185,3" title="X=58, Y=25" ><area shape="circle" href="#" coords="366,183,3" title="X=58, Y=26" ><area shape="circle" href="#" coords="366,181,3" title="X=58, Y=27" ><area shape="circle" href="#" coords="366,179,3" title="X=58, Y=28" ><area shape="circle" href="#" coords="366,177,3" title="X=58, Y=29" ><area shape="circle" href="#" coords="366,175,3" title="X=58, Y=30" ><area shape="circle" href="#" coords="366,173,3" title="X=58, Y=31" ><area shape="circle" href="#" coords="366,171,3" title="X=58, Y=32" ><area shape="circle" href="#" coords="368,203,3" title="X=59, Y=16" ><area shape="circle" href="#" coords="368,201,3" title="X=59, Y=17" ><area shape="circle" href="#" coords="368,199,3" title="X=59, Y=18" ><area shape="circle" href="#" coords="368,197,3" title="X=59, Y=19" ><area shape="circle" href="#" coords="368,195,3" title="X=59, Y=20" ><area shape="circle" href="#" coords="368,193,3" title="X=59, Y=21" ><area shape="circle" href="#" coords="368,191,3" title="X=59, Y=22" ><area shape="circle" href="#" coords="368,189,3" title="X=59, Y=23" ><area shape="circle" href="#" coords="368,187,3" title="X=59, Y=24" ><area shape="circle" href="#" coords="368,185,3" title="X=59, Y=25" ><area shape="circle" href="#" coords="368,183,3" title="X=59, Y=26" ><area shape="circle" href="#" coords="368,181,3" title="X=59, Y=27" ><area shape="circle" href="#" coords="368,179,3" title="X=59, Y=28" ><area shape="circle" href="#" coords="368,177,3" title="X=59, Y=29" ><area shape="circle" href="#" coords="368,175,3" title="X=59, Y=30" ><area shape="circle" href="#" coords="368,173,3" title="X=59, Y=31" ><area shape="circle" href="#" coords="370,203,3" title="X=60, Y=16" ><area shape="circle" href="#" coords="370,201,3" title="X=60, Y=17" ><area shape="circle" href="#" coords="370,199,3" title="X=60, Y=18" ><area shape="circle" href="#" coords="370,197,3" title="X=60, Y=19" ><area shape="circle" href="#" coords="370,195,3" title="X=60, Y=20" ><area shape="circle" href="#" coords="370,193,3" title="X=60, Y=21" ><area shape="circle" href="#" coords="370,191,3" title="X=60, Y=22" ><area shape="circle" href="#" coords="370,189,3" title="X=60, Y=23" ><area shape="circle" href="#" coords="370,187,3" title="X=60, Y=24" ><area shape="circle" href="#" coords="370,185,3" title="X=60, Y=25" ><area shape="circle" href="#" coords="370,183,3" title="X=60, Y=26" ><area shape="circle" href="#" coords="370,181,3" title="X=60, Y=27" ><area shape="circle" href="#" coords="370,179,3" title="X=60, Y=28" ><area shape="circle" href="#" coords="370,177,3" title="X=60, Y=29" ><area shape="circle" href="#" coords="370,175,3" title="X=60, Y=30" ><area shape="circle" href="#" coords="370,173,3" title="X=60, Y=31" ><area shape="circle" href="#" coords="372,201,3" title="X=61, Y=17" ><area shape="circle" href="#" coords="372,199,3" title="X=61, Y=18" ><area shape="circle" href="#" coords="372,197,3" title="X=61, Y=19" ><area shape="circle" href="#" coords="372,195,3" title="X=61, Y=20" ><area shape="circle" href="#" coords="372,193,3" title="X=61, Y=21" ><area shape="circle" href="#" coords="372,191,3" title="X=61, Y=22" ><area shape="circle" href="#" coords="372,189,3" title="X=61, Y=23" ><area shape="circle" href="#" coords="372,187,3" title="X=61, Y=24" ><area shape="circle" href="#" coords="372,185,3" title="X=61, Y=25" ><area shape="circle" href="#" coords="372,183,3" title="X=61, Y=26" ><area shape="circle" href="#" coords="372,181,3" title="X=61, Y=27" ><area shape="circle" href="#" coords="372,179,3" title="X=61, Y=28" ><area shape="circle" href="#" coords="372,177,3" title="X=61, Y=29" ><area shape="circle" href="#" coords="372,175,3" title="X=61, Y=30" ><area shape="circle" href="#" coords="374,201,3" title="X=62, Y=17" ><area shape="circle" href="#" coords="374,199,3" title="X=62, Y=18" ><area shape="circle" href="#" coords="374,197,3" title="X=62, Y=19" ><area shape="circle" href="#" coords="374,195,3" title="X=62, Y=20" ><area shape="circle" href="#" coords="374,193,3" title="X=62, Y=21" ><area shape="circle" href="#" coords="374,191,3" title="X=62, Y=22" ><area shape="circle" href="#" coords="374,189,3" title="X=62, Y=23" ><area shape="circle" href="#" coords="374,187,3" title="X=62, Y=24" ><area shape="circle" href="#" coords="374,185,3" title="X=62, Y=25" ><area shape="circle" href="#" coords="374,183,3" title="X=62, Y=26" ><area shape="circle" href="#" coords="374,181,3" title="X=62, Y=27" ><area shape="circle" href="#" coords="374,179,3" title="X=62, Y=28" ><area shape="circle" href="#" coords="374,177,3" title="X=62, Y=29" ><area shape="circle" href="#" coords="374,175,3" title="X=62, Y=30" ><area shape="circle" href="#" coords="376,199,3" title="X=63, Y=18" ><area shape="circle" href="#" coords="376,197,3" title="X=63, Y=19" ><area shape="circle" href="#" coords="376,195,3" title="X=63, Y=20" ><area shape="circle" href="#" coords="376,193,3" title="X=63, Y=21" ><area shape="circle" href="#" coords="376,191,3" title="X=63, Y=22" ><area shape="circle" href="#" coords="376,189,3" title="X=63, Y=23" ><area shape="circle" href="#" coords="376,187,3" title="X=63, Y=24" ><area shape="circle" href="#" coords="376,185,3" title="X=63, Y=25" ><area shape="circle" href="#" coords="376,183,3" title="X=63, Y=26" ><area shape="circle" href="#" coords="376,181,3" title="X=63, Y=27" ><area shape="circle" href="#" coords="376,179,3" title="X=63, Y=28" ><area shape="circle" href="#" coords="376,177,3" title="X=63, Y=29" ><area shape="circle" href="#" coords="378,195,3" title="X=64, Y=20" ><area shape="circle" href="#" coords="378,193,3" title="X=64, Y=21" ><area shape="circle" href="#" coords="378,191,3" title="X=64, Y=22" ><area shape="circle" href="#" coords="378,189,3" title="X=64, Y=23" ><area shape="circle" href="#" coords="378,187,3" title="X=64, Y=24" ><area shape="circle" href="#" coords="378,185,3" title="X=64, Y=25" ><area shape="circle" href="#" coords="378,183,3" title="X=64, Y=26" ><area shape="circle" href="#" coords="378,181,3" title="X=64, Y=27" ><area shape="circle" href="#" coords="380,191,3" title="X=65, Y=22" ><area shape="circle" href="#" coords="380,189,3" title="X=65, Y=23" ><area shape="circle" href="#" coords="380,187,3" title="X=65, Y=24" ><area shape="circle" href="#" coords="380,185,3" title="X=65, Y=25" ></map>';
  3302.  
  3303. var nvspan = document.createElement('div');
  3304. nvspan.align = 'center';
  3305. nvspan.valign = 'top';
  3306. nvspan.innerHTML += nvdiv;
  3307. pars[1].insertBefore(nvspan,pars[1].firstChild);
  3308. }
  3309.  
  3310. function do_ordresgowap() {
  3311. setCarteGogo(); // Via script des trouillots
  3312. }
  3313.  
  3314. /*********************************************************************************
  3315. * This file is part of Mountyzilla. *
  3316. * *
  3317. * Mountyzilla is free software; you can redistribute it and/or modify *
  3318. * it under the terms of the GNU General Public License as published by *
  3319. * the Free Software Foundation; either version 2 of the License, or *
  3320. * (at your option) any later version. *
  3321. * *
  3322. * Mountyzilla is distributed in the hope that it will be useful, *
  3323. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3324. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3325. * GNU General Public License for more details. *
  3326. * *
  3327. * You should have received a copy of the GNU General Public License *
  3328. * along with Mountyzilla; if not, write to the Free Software *
  3329. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3330. *********************************************************************************/
  3331.  
  3332. // x~x attaque
  3333.  
  3334. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3335.  
  3336. function do_attaque() {
  3337. }
  3338.  
  3339. /*******************************************************************************
  3340. * This file is part of Mountyzilla. *
  3341. * *
  3342. * Mountyzilla is free software; you can redistribute it and/or modify *
  3343. * it under the terms of the GNU General Public License as published by *
  3344. * the Free Software Foundation; either version 2 of the License, or *
  3345. * (at your option) any later version. *
  3346. * *
  3347. * Mountyzilla is distributed in the hope that it will be useful, *
  3348. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3349. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3350. * GNU General Public License for more details. *
  3351. * *
  3352. * You should have received a copy of the GNU General Public License *
  3353. * along with Mountyzilla; if not, write to the Free Software *
  3354. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3355. *******************************************************************************/
  3356.  
  3357. // x~x infomonstre
  3358.  
  3359. // DEBUG
  3360. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  3361. // À corriger, évidemment.
  3362. var listeCDM = {};
  3363. var nomMonstre='';
  3364. var idMonstre=-1;
  3365. var tbody;
  3366. var popup;
  3367.  
  3368. function traiteMonstre() {
  3369. try {
  3370. var nodeTitre = document.evaluate(
  3371. "//div[@class='titre2' and contains(text(),'(')]",
  3372. document, null, 9, null
  3373. ).singleNodeValue;
  3374. var texte = nodeTitre.firstChild.nodeValue;
  3375. } catch(e) {
  3376. window.console.log(e);
  3377. return;
  3378. }
  3379. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  3380. if(nomMonstre.indexOf(']')!=-1) {
  3381. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  3382. }
  3383. idMonstre = texte.match(/\d+/)[0];
  3384. FF_XMLHttpRequest({
  3385. method: 'GET',
  3386. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  3387. +MY_getValue('CDMID')
  3388. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  3389. headers : {
  3390. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3391. 'Accept': 'application/atom+xml,application/xml,text/xml'
  3392. },
  3393. onload: function(responseDetails) {
  3394. try {
  3395. var texte = responseDetails.responseText;
  3396. var lines = texte.split("\n");
  3397. if(lines.length>=1) {
  3398. var infos = lines[0].split(";");
  3399. if(infos.length<4) { return; }
  3400. var idMonstre = infos[0];
  3401. infos=infos.slice(3);
  3402. listeCDM[idMonstre]=infos;
  3403. computeMissionInfomonstre();
  3404. }
  3405. } catch(e) {
  3406. window.alert(e);
  3407. }
  3408. }
  3409. });
  3410. }
  3411.  
  3412. function initPopupInfomonstre() {
  3413. // Initialise le popup tactique (calculs att/deg)
  3414. popup = document.createElement('div');
  3415. popup.id = 'popup';
  3416. popup.className = 'mh_textbox';
  3417. popup.style =
  3418. 'position: absolute;'+
  3419. 'border: 1px solid #000000;'+
  3420. 'visibility: hidden;'+
  3421. 'display: inline;'+
  3422. 'z-index: 3;'+
  3423. 'max-width: 400px;';
  3424. document.body.appendChild(popup);
  3425. }
  3426.  
  3427. function showPopupTactique(evt) {
  3428. try {
  3429. var id = this.id;
  3430. var nom = this.nom;
  3431. var texte = getAnalyseTactique(id,nom);
  3432. if(texte=='') { return; }
  3433. popup.innerHTML = texte;
  3434. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  3435. if(isPage("View/MonsterView")) {
  3436. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  3437. } else {
  3438. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  3439. }
  3440. popup.style.top = evt.pageY+15+'px';
  3441. popup.style.visibility = 'visible';
  3442. } catch(e) {
  3443. window.alert(e);
  3444. }
  3445. }
  3446.  
  3447. // roule 16/03/2016, existe déjà ailleurs
  3448. // function hidePopup() {
  3449. // popup.style.visibility = 'hidden';
  3450. // }
  3451.  
  3452. function toggleTableau() {
  3453. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  3454. }
  3455.  
  3456. function computeMissionInfomonstre() {
  3457. // C'est quoi ce titre de fonction ? (O_o)
  3458. try {
  3459. var nodeInsert = document.evaluate(
  3460. "//div[@class = 'titre3']",
  3461. document, null, 9, null
  3462. ).singleNodeValue;
  3463. } catch(e) {
  3464. window.console.log(e);
  3465. return;
  3466. }
  3467. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  3468. table.align = 'center';
  3469. tbody = table.childNodes[1];
  3470. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  3471. table.firstChild.firstChild.onmouseover = function() {
  3472. this.style.cursor = 'pointer';
  3473. this.className = 'mh_tdpage';
  3474. };
  3475. table.firstChild.firstChild.onmouseout = function() {
  3476. this.className = 'mh_tdtitre';
  3477. };
  3478. tbody.style.display = 'none';
  3479. table.style.width = '350px';
  3480. insertBefore(nodeInsert,table);
  3481. }
  3482.  
  3483. function do_infomonstre() {
  3484. start_script();
  3485. try {
  3486. initPopupInfomonstre();
  3487. traiteMonstre();
  3488. } catch(e) {
  3489. window.alert('Erreur infoMonstre:\n'+e);
  3490. }
  3491. displayScriptTime();
  3492. }
  3493.  
  3494. /*******************************************************************************
  3495. * This file is part of Mountyzilla. *
  3496. * *
  3497. * Mountyzilla is free software; you can redistribute it and/or modify *
  3498. * it under the terms of the GNU General Public License as published by *
  3499. * the Free Software Foundation; either version 2 of the License, or *
  3500. * (at your option) any later version. *
  3501. * *
  3502. * Mountyzilla is distributed in the hope that it will be useful, *
  3503. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3504. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3505. * GNU General Public License for more details. *
  3506. * *
  3507. * You should have received a copy of the GNU General Public License *
  3508. * along with Mountyzilla; if not, write to the Free Software *
  3509. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3510. *******************************************************************************/
  3511.  
  3512. // x~x mission
  3513.  
  3514. /* TODO
  3515. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  3516. *
  3517. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  3518. */
  3519.  
  3520. function saveMission(num,obEtape) {
  3521. var obMissions = {};
  3522. if(MY_getValue(numTroll+'.MISSIONS')) {
  3523. try {
  3524. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3525. } catch(e) {
  3526. window.console.error('[MZ Mission] Erreur parsage:\n'+e);
  3527. return;
  3528. }
  3529. }
  3530. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  3531. if(obEtape) {
  3532. obMissions[num] = obEtape;
  3533. } else if(obMissions[num]) {
  3534. delete obMissions[num];
  3535. }
  3536. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3537. }
  3538.  
  3539. function traiteMission() {
  3540. try {
  3541. var titreMission = document.getElementsByClassName('titre2')[0];
  3542. var numMission = titreMission.textContent.match(/\d+/)[0];
  3543. var missionForm = document.getElementsByName('ActionForm')[0];
  3544. var tdLibelle = document.evaluate(
  3545. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  3546. missionForm, null, 9, null).singleNodeValue;
  3547. } catch(e) {
  3548. window.console.error('[MZ Mission] Erreur récupération mission:\n'+e);
  3549. return;
  3550. }
  3551. if(!numMission) { return; }
  3552. try {
  3553. if(!tdLibelle) {
  3554. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  3555. saveMission(numMission,false);
  3556. return;
  3557. }
  3558.  
  3559. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  3560. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  3561. // debug Roule'
  3562. //for (var i =0; i < tdLibelle.childNodes.length; i++) window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  3563. if(libelle.indexOf('niveau égal à')!=-1) {
  3564. var nbKills = 1, niveau, mod;
  3565. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  3566. // Étape de kill multiple de niveau donné
  3567. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3568. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  3569. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3570. niveau = Number(mod[0]);
  3571. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3572. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  3573. } else {
  3574. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  3575. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3576. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  3577. mod = mod ? Number(mod[0]) : 'plus';
  3578. }
  3579. } else {
  3580. // Étape de kill unique de niveau donné
  3581. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  3582. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3583. mod = mod ? Number(mod[0]) : 'plus';
  3584. }
  3585. // debug Roule'
  3586. //window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + ', libelle=' + libelle);
  3587. saveMission(numMission,{
  3588. type: 'Niveau',
  3589. niveau: niveau,
  3590. mod: mod,
  3591. mundidey: siMundidey,
  3592. libelle: libelle
  3593. });
  3594. } else if(libelle.indexOf('de la race')!=-1) {
  3595. var nbKills = 1, race;
  3596. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  3597. // Étape de kill multiple de race donnée
  3598. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3599. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  3600. } else {
  3601. // Étape de kill unique de race donnée
  3602. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3603. }
  3604. saveMission(numMission,{
  3605. type: 'Race',
  3606. race: race.replace(/\"/g,''),
  3607. mundidey: siMundidey,
  3608. libelle: libelle
  3609. });
  3610. } else if(libelle.indexOf('de la famille')!=-1) {
  3611. var nbKills = 1, famille;
  3612. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  3613. // Étape de kill multiple de famille donnée
  3614. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3615. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  3616. } else {
  3617. // Étape de kill unique de famille donnée
  3618. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3619. }
  3620. saveMission(numMission,{
  3621. type: 'Famille',
  3622. famille: famille,
  3623. mundidey: siMundidey,
  3624. libelle: libelle
  3625. });
  3626. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  3627. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  3628. saveMission(numMission,{
  3629. type: 'Pouvoir',
  3630. pouvoir: pouvoir,
  3631. libelle: libelle
  3632. });
  3633. } else {
  3634. saveMission(numMission,false);
  3635. }
  3636. } catch(e) {
  3637. window.console.error('[MZ Mission] Erreur récupération étape mission:\n'+e);
  3638. return;
  3639. }
  3640. }
  3641.  
  3642. function do_mission() {
  3643. start_script(60);
  3644.  
  3645. traiteMission();
  3646.  
  3647. displayScriptTime();
  3648. }
  3649.  
  3650. /*******************************************************************************
  3651. * This file is part of Mountyzilla. *
  3652. * *
  3653. * Mountyzilla is free software; you can redistribute it and/or modify *
  3654. * it under the terms of the GNU General Public License as published by *
  3655. * the Free Software Foundation; either version 2 of the License, or *
  3656. * (at your option) any later version. *
  3657. * *
  3658. * Mountyzilla is distributed in the hope that it will be useful, *
  3659. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3660. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3661. * GNU General Public License for more details. *
  3662. * *
  3663. * You should have received a copy of the GNU General Public License *
  3664. * along with Mountyzilla; if not, write to the Free Software *
  3665. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3666. *******************************************************************************/
  3667.  
  3668. // x~x move
  3669.  
  3670. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  3671.  
  3672. var petitsTrous = {
  3673. '-52;57': true,
  3674. '55;70': true,
  3675. '64;70': true,
  3676. '12;-15': true,
  3677. '30;-52': true,
  3678. '48;-39': true
  3679. };
  3680.  
  3681. var grosTrous = {
  3682. '-35;65': true,
  3683. '-13;73': true,
  3684. '-64;9': true,
  3685. '-35;15': true,
  3686. '5;32': true,
  3687. '10;64': true,
  3688. '21;36': true,
  3689. '46;52': true,
  3690. '74;32': true,
  3691. '-71;-7': true,
  3692. '-67;-37': true,
  3693. '-60;-32': true,
  3694. '-51;-22': true,
  3695. '-36;-51': true,
  3696. '5;-49': true
  3697. };
  3698.  
  3699. var centreCarmine_X = 56.5;
  3700. var centreCarmine_Y = 23.5;
  3701. var rayonCarmine = 8.7;
  3702.  
  3703. function isTrou(x,y,n) {
  3704. if(petitsTrous[x+';'+y]) {
  3705. return n<0 && n>-60;
  3706. }
  3707. if(grosTrous[x+';'+y]
  3708. || grosTrous[x-1+';'+y]
  3709. || grosTrous[x+';'+y+1]
  3710. || grosTrous[x-1+';'+y+1]) {
  3711. return n<0 && n>-70;
  3712. }
  3713. if(Math.sqrt(
  3714. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  3715. )<=rayonCarmine) {
  3716. return n<0 && n>-100;
  3717. }
  3718. return false;
  3719. }
  3720.  
  3721. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  3722.  
  3723. function validateDestination() {
  3724. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  3725. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  3726. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  3727. var form = document.getElementsByName('ActionForm')[0];
  3728. if(form) {
  3729. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  3730. if(document.getElementsByName('ai_DeplX')[i].checked) {
  3731. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  3732. }
  3733. }
  3734. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  3735. if(document.getElementsByName('ai_DeplY')[i].checked) {
  3736. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  3737. }
  3738. }
  3739. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  3740. if(document.getElementsByName('ai_DeplN')[i].checked) {
  3741. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  3742. }
  3743. }
  3744. if(isTrou(x,y,n)) {
  3745. return window.confirm(
  3746. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  3747. +'Vous allez tomber dans un trou de météorite.\n'
  3748. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  3749. );
  3750. }
  3751. }
  3752. return true;
  3753. }
  3754.  
  3755. function newsubmitDE(event) {
  3756. event.stopPropagation();
  3757. event.preventDefault();
  3758. if(validateDestination()) {
  3759. this.submit();
  3760. }
  3761. }
  3762.  
  3763. function changeValidation() {
  3764. var form = document.getElementsByName('ActionForm')[0];
  3765. if(form) {
  3766. form.addEventListener('submit', newsubmitDE, true);
  3767. }
  3768. }
  3769.  
  3770.  
  3771. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  3772.  
  3773. function validateTPDestination() {
  3774. try {
  3775. var text = document.getElementsByTagName('B')[0];
  3776. var a = text.firstChild.nodeValue.split('|');
  3777. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  3778. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  3779. var pos_n = a[2].substring(5, a[2].length) * 1;
  3780.  
  3781. var nbtrous = 0;
  3782. for(var signX=-1 ; signX<=1 ; signX+=2) {
  3783. for(var x=0 ; x<=2 ; x++) {
  3784. for(var signY=-1 ; signY<=1 ; signY+=2) {
  3785. for(var y=0 ; y<=2 ; y++) {
  3786. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  3787. for(var n = 0 ; n <= 1 ; n++) {
  3788. if(isTrou(
  3789. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  3790. )) {
  3791. nbtrous++;
  3792. }
  3793. }
  3794. }
  3795. }
  3796. }
  3797. }
  3798. }
  3799. if(nbtrous>0 && nbtrous<72) {
  3800. return window.confirm(
  3801. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  3802. +'Vous avez '+Math.floor((100*nbtrous)/144)
  3803. +'% de risque de tomber dans un trou de météorite.\n'
  3804. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  3805. );
  3806. }
  3807. else if(nbtrous>=72) {
  3808. return window.confirm(
  3809. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  3810. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  3811. +'% de risque de tomber dans un trou de météorite !\n'
  3812. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  3813. );
  3814. }
  3815. return true;
  3816. }
  3817. catch(e) {
  3818. window.alert(e)
  3819. }
  3820. }
  3821.  
  3822. function newsubmitTP(event) {
  3823. event.stopPropagation();
  3824. event.preventDefault();
  3825. if(validateTPDestination()) {
  3826. this.submit();
  3827. }
  3828. }
  3829.  
  3830. function changeButtonValidate() {
  3831. var form = document.getElementsByName('Formulaire')[0];
  3832. if(form) {
  3833. if(!form.getAttribute('onsubmit')) {
  3834. form.setAttribute('onsubmit','return true;');
  3835. }
  3836. form.addEventListener('submit', newsubmitTP, true);
  3837. }
  3838. }
  3839.  
  3840.  
  3841. /*-[functions]---------------- Partie Principale -----------------------------*/
  3842.  
  3843. function do_move() {
  3844. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  3845. changeValidation();
  3846. }
  3847. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  3848. changeButtonValidate();
  3849. }
  3850. }
  3851.  
  3852. /*******************************************************************************
  3853. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  3854. * Mountyzilla is free software; provided under the GNU General Public License *
  3855. *******************************************************************************/
  3856.  
  3857. // x~x news
  3858.  
  3859. // Nombre de news à afficher & nb max de caractères par news:
  3860. const nbItems = 5;
  3861. const maxCarDescription = 300;
  3862.  
  3863. /*-[functions]------------------- Utilitaires --------------------------------*/
  3864.  
  3865. // Ne semble avoir strictement aucun effet:
  3866. String.prototype.epureDescription = function() {
  3867. return this.replace(/\\(.)/g,"$1");
  3868. }
  3869.  
  3870. function appendTitledTable(node,titre,description) {
  3871. // Crée les tables contenant les infos (avec titre)
  3872. var table = document.createElement('table');
  3873. table.border = 0;
  3874. table.className = 'mh_tdborder';
  3875. table.cellSpacing = 1;
  3876. table.cellPadding = 1;
  3877. table.style.maxWidth = '98%';
  3878. table.style.marginLeft = 'auto';
  3879. table.style.marginRight = 'auto';
  3880. var tbody = document.createElement('tbody');
  3881. table.appendChild(tbody);
  3882. var tr = appendTr(tbody,'mh_tdtitre');
  3883. var td = appendTdCenter(tr,2);
  3884. var span = document.createElement('span');
  3885. appendText(span,titre,true);
  3886. if(description) {
  3887. span.title = description;
  3888. }
  3889. td.appendChild(span);
  3890. node.appendChild(table);
  3891. return tbody;
  3892. }
  3893.  
  3894.  
  3895. /*-[functions]------------------- Jubilaires ---------------------------------*/
  3896.  
  3897. function traiterJubilaires() {
  3898. try {
  3899. FF_XMLHttpRequest({
  3900. method: 'GET',
  3901. url: URL_anniv,
  3902. headers: {
  3903. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  3904. 'Accept': 'application/xml,text/xml',
  3905. },
  3906. onload: function(responseDetails) {
  3907. var listeTrolls = responseDetails.responseText.split('\n');
  3908. if(!listeTrolls || listeTrolls.length==0) {
  3909. return;
  3910. }
  3911. afficherJubilaires(listeTrolls);
  3912. },
  3913. });
  3914. }
  3915. catch(e) {
  3916. if (isHTTPS) {
  3917. try {
  3918. var rappels = document.evaluate(
  3919. "//p[contains(a/text(),'messagerie')]",
  3920. document, null, 9, null).singleNodeValue;
  3921. }
  3922. catch(e) {
  3923. window.alert('Vous êtes en HTTPS. Pour bénéficier de MoutyZilla, vous devriez débloquer le contenu mixte');
  3924. return;
  3925. }
  3926. var p = document.createElement('div');
  3927. p.innerHTML = 'Vous êtes en <span style="color:blue">HTTPS</span>.<br/>'
  3928. + 'Pour bénéficier de MountyZilla, vous devriez autoriser le contenu mixte.<br />'
  3929. + 'Voir <a href="https://support.mozilla.org/fr/kb/blocage-du-contenu-mixte-avec-firefox#w_daebloquer-le-contenu-mixte" target="_blank">sur cette page</a>';
  3930. p.style.textAlign = 'center';
  3931. p.style.border = 'solid 5px red';
  3932. p.style.width = 'auto';
  3933. p.style.fontSize = 'xx-large';
  3934. insertBefore(rappels,p);
  3935. } else {
  3936. window.alert('Erreur Jubilaires:\n'+e)
  3937. }
  3938. };
  3939. }
  3940.  
  3941. function afficherJubilaires(listeTrolls) {
  3942. try {
  3943. var rappels = document.evaluate(
  3944. "//p[contains(a/text(),'messagerie')]",
  3945. document, null, 9, null).singleNodeValue;
  3946. }
  3947. catch(e) {
  3948. return;
  3949. }
  3950. var p = document.createElement('p');
  3951. var tbody = appendTitledTable(p,
  3952. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  3953. 'Envoyez leur un message ou un cadeau !'
  3954. );
  3955. tr = appendTr(tbody,'mh_tdpage');
  3956. td = appendTdCenter(tr);
  3957. var small = document.createElement('small');
  3958. td.appendChild(small);
  3959. var first = true;
  3960. for(var i=0 ; i<listeTrolls.length ; i++) {
  3961. var infos = listeTrolls[i].split(';');
  3962. if(infos.length!=3 || infos[2]==='0') {
  3963. continue;
  3964. }
  3965. if(first) {
  3966. first = false;
  3967. }
  3968. else {
  3969. appendText(small,', ');
  3970. }
  3971. var a = document.createElement('a');
  3972. a.href = 'javascript:EPV('+infos[0]+')';
  3973. appendText(a,infos[1]);
  3974. small.appendChild(a);
  3975. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  3976. }
  3977. insertBefore(rappels,p);
  3978. }
  3979.  
  3980.  
  3981. /*-[functions]--------------------- News MZ ----------------------------------*/
  3982.  
  3983. function traiterNouvelles() {
  3984. try {
  3985. FF_XMLHttpRequest({
  3986. method: 'GET',
  3987. url: URL_rss,
  3988. headers: {
  3989. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  3990. 'Accept': 'application/xml,text/xml',
  3991. },
  3992. onload: function(responseDetails) {
  3993. responseDetails.responseXML = new DOMParser().parseFromString(
  3994. responseDetails.responseText,
  3995. 'text/xml');
  3996. afficherNouvelles(responseDetails.responseXML);
  3997. }
  3998. });
  3999. }
  4000. catch(e) {
  4001. if (isHTTPS) {
  4002. // ignore
  4003. } else {
  4004. window.alert('Erreur News:\n'+e)
  4005. }
  4006. }
  4007. }
  4008.  
  4009. function afficherNouvelles(xml_data) {
  4010. var footer = document.getElementById('footer1');
  4011. if(!footer) {
  4012. return;
  4013. }
  4014. try {
  4015. var titre = xml_data.evaluate('//channel/title/text()',
  4016. xml_data, null, 9, null).singleNodeValue.nodeValue;
  4017. var description = xml_data.evaluate('//channel/description/text()',
  4018. xml_data, null, 9, null).singleNodeValue.nodeValue;
  4019. var items = xml_data.evaluate('//channel/item',
  4020. xml_data, null, 7, null);
  4021. }
  4022. catch(e) {
  4023. return;
  4024. }
  4025. if(!titre || !description || items.snapshotLength==0) {
  4026. return;
  4027. }
  4028. var p = document.createElement('p');
  4029. var tbody = appendTitledTable(p,titre,description);
  4030. for(var i=0 ; i<Math.min(items.snapshotLength,nbItems) ; i++) {
  4031. var item = items.snapshotItem(i);
  4032. var sousTitre = xml_data.evaluate('title/text()',
  4033. item, null, 9, null).singleNodeValue.nodeValue;
  4034. var details = xml_data.evaluate('description/text()',
  4035. item, null, 9, null).singleNodeValue.nodeValue;
  4036. if(sousTitre && details) {
  4037. var tr = appendTr(tbody,'mh_tdpage');
  4038. var td = appendTdCenter(tr);
  4039. td.style.verticalAlign = 'middle'; // semble sans effet
  4040. appendText(td,sousTitre,true);
  4041. td = appendTd(tr);
  4042. td.innerHTML = details.epureDescription().slice(0,maxCarDescription);
  4043. // DEBUG
  4044. // pourquoi il ajoute une ligne vide sous les listes ??
  4045. // même avec trim(), il vire le textNode mais pas l'espace !
  4046. }
  4047. }
  4048. insertBefore(footer,p);
  4049. }
  4050.  
  4051.  
  4052. /*---------------------------------- Main ------------------------------------*/
  4053.  
  4054. function do_news() {
  4055. start_script();
  4056.  
  4057. traiterJubilaires();
  4058. traiterNouvelles();
  4059.  
  4060. displayScriptTime();
  4061. }
  4062.  
  4063. /*********************************************************************************
  4064. * This file is part of Mountyzilla. *
  4065. * *
  4066. * Mountyzilla is free software; you can redistribute it and/or modify *
  4067. * it under the terms of the GNU General Public License as published by *
  4068. * the Free Software Foundation; either version 2 of the License, or *
  4069. * (at your option) any later version. *
  4070. * *
  4071. * Mountyzilla is distributed in the hope that it will be useful, *
  4072. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4073. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4074. * GNU General Public License for more details. *
  4075. * *
  4076. * You should have received a copy of the GNU General Public License *
  4077. * along with Mountyzilla; if not, write to the Free Software *
  4078. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4079. *********************************************************************************/
  4080.  
  4081. // x~x tabcompo
  4082.  
  4083. var popup;
  4084.  
  4085. function initPopupTabcompo() {
  4086. popup = document.createElement('div');
  4087. popup.setAttribute('id', 'popup');
  4088. popup.setAttribute('class', 'mh_textbox');
  4089. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  4090. + 'display: inline; z-index: 3; max-width: 400px;');
  4091. document.body.appendChild(popup);
  4092. }
  4093.  
  4094. function showPopup(evt) {
  4095. var texte = this.getAttribute("texteinfo");
  4096. popup.innerHTML = texte;
  4097. popup.style.left = evt.pageX + 15 + 'px';
  4098. popup.style.top = evt.pageY + 'px';
  4099. popup.style.visibility = "visible";
  4100. }
  4101.  
  4102. // roule 16/03/2016, existe déjà ailleurs
  4103. // function hidePopup() {
  4104. // popup.style.visibility = 'hidden';
  4105. // }
  4106.  
  4107. function createPopupImage(url, text)
  4108. {
  4109. var img = document.createElement('img');
  4110. img.setAttribute('src',url);
  4111. img.setAttribute('align','ABSMIDDLE');
  4112. img.setAttribute("texteinfo",text);
  4113. img.addEventListener("mouseover", showPopup,true);
  4114. img.addEventListener("mouseout", hidePopup,true);
  4115. return img;
  4116. }
  4117.  
  4118. function formateTexte(texte)
  4119. {
  4120. texte = texte.replace(/\n/g,"<br/>");
  4121. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4122. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4123. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4124. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4125. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4126. return texte;
  4127. }
  4128.  
  4129. function arrondi(x) {
  4130. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  4131. }
  4132.  
  4133. function traiteMinerai() {
  4134. if (currentURL.indexOf("as_type=Divers")==-1) return;
  4135. try {
  4136. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  4137. +" and contains(./tr/th/text(),'Minerai')]",
  4138. document, null, 9, null).singleNodeValue;
  4139. node = node.nextSibling.nextSibling;
  4140. }
  4141. catch(e) {return;}
  4142. var trlist = document.evaluate('./tr', node, null, 7, null);
  4143. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  4144. var node = trlist.snapshotItem(i);
  4145. var nature = node.childNodes[5].textContent;
  4146. var caracs = node.childNodes[7].textContent;
  4147. var taille = caracs.match(/\d+/)[0];
  4148. var coef = 1;
  4149. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  4150. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  4151. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  4152. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  4153. if (nature.indexOf('Mithril')!=-1) {
  4154. coef = 0.2*coef;
  4155. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  4156. }
  4157. else {
  4158. coef = 0.75*coef+1.25;
  4159. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  4160. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  4161. }
  4162. }
  4163. }
  4164.  
  4165. function treateComposants() {
  4166. if (currentURL.indexOf("as_type=Compo")==-1) return;
  4167. //On récupère les composants
  4168. var nodes = document.evaluate(
  4169. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4170. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4171. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  4172. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4173. if (nodes.snapshotLength == 0) {
  4174. // window.alert('treateComposants DOWN');
  4175. return;
  4176. }
  4177. window.alert(nodes.snapshotLength);
  4178.  
  4179. var texte = "";
  4180. for (var i = 0; i < nodes.snapshotLength; i++) {
  4181. var n1 = nodes.snapshotItem(i).childNodes[1];
  4182. var n3 = nodes.snapshotItem(i).childNodes[3];
  4183. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4184. var prix = n3.childNodes[0].nodeValue;
  4185. if (!prix)
  4186. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4187. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4188. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4189. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4190. + prix.replace(/\n/g, '') + "\n";
  4191. }
  4192.  
  4193. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4194. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4195. var id_taniere = c.snapshotItem(0).nodeValue;
  4196. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  4197.  
  4198. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4199. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  4200. if (form)
  4201. {
  4202. if(document.getElementsByTagName('form').length>0)
  4203. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4204. else
  4205. {
  4206. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4207. insertBefore(thisP, form);
  4208. }
  4209. }
  4210. }
  4211.  
  4212. function treateAllComposants() {
  4213. if(currentURL.indexOf("as_type=Compo")==-1) return;
  4214. //On récupère les composants
  4215. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  4216. document, null, 0, null ).numberValue;
  4217. var c = (categ == 0 ? 3 : 4);
  4218. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  4219. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  4220. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  4221. + "td["+c+"]/text()[1] = '\240-\240' "
  4222. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  4223. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  4224. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  4225. + "and td[1]/img/@alt = 'Identifié']",
  4226. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4227. if (nodes.snapshotLength == 0) {
  4228. // window.alert('treateAllComposants DOWN');
  4229. return;
  4230. }
  4231.  
  4232. var texte = "";
  4233. for (var i = 0; i < nodes.snapshotLength; i++) {
  4234. var n1 = nodes.snapshotItem(i).childNodes[1];
  4235. var n3 = nodes.snapshotItem(i).childNodes[3];
  4236. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4237. var prix = n3.childNodes[0].nodeValue;
  4238. if (!prix)
  4239. {
  4240. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  4241. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4242. }
  4243. else
  4244. {
  4245. prix= prix.replace(/[\240 ]/g, "");
  4246. if(prix=="-")
  4247. prix=null;
  4248. }
  4249. if(prix)
  4250. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4251. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4252. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4253. + prix.replace(/\n/g, '') + "\n";
  4254. else
  4255. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4256. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4257. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  4258. }
  4259.  
  4260. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4261. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4262. var id_taniere = c.snapshotItem(0).nodeValue;
  4263. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  4264.  
  4265. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4266. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  4267. if (form)
  4268. {
  4269. if(document.getElementsByTagName('form').length>0)
  4270. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4271. else
  4272. {
  4273. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4274. insertBefore(thisP, form);
  4275. }
  4276. }
  4277. }
  4278.  
  4279. function treateEM()
  4280. {
  4281. if(currentURL.indexOf("as_type=Compo")==-1)
  4282. return false;
  4283. var urlImg = URL_MZimg09 + "Competences/ecritureMagique.png";
  4284. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  4285. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4286. if (nodes.snapshotLength == 0)
  4287. return false;
  4288. for (var i = 0; i < nodes.snapshotLength; i++) {
  4289. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  4290. var link = desc[2].firstChild ;
  4291. var nomCompoTotal = desc[2].textContent ;
  4292. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4293. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4294. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  4295. var locqual = desc[3].textContent ;
  4296. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  4297. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  4298. if(isEM(nomMonstre).length>0)
  4299. {
  4300. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  4301. if(infos.length>0)
  4302. {
  4303. var shortDescr = "Variable";
  4304. var bold = 0;
  4305. if(infos != "Composant variable")
  4306. {
  4307. shortDescr = infos.substring(0,infos.indexOf(" "));
  4308. if(parseInt(shortDescr)>=0)
  4309. bold=1;
  4310. }
  4311. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  4312. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  4313. }
  4314. }
  4315. }
  4316. }
  4317.  
  4318. function treateChampi() {
  4319. if (currentURL.indexOf('as_type=Champi')==-1)
  4320. return false;
  4321. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  4322. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4323. if (nodes.snapshotLength == 0)
  4324. return false;
  4325.  
  4326. for (var i = 0; i < nodes.snapshotLength; i++) {
  4327. var node = nodes.snapshotItem(i);
  4328. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  4329. if (moisChampi[nomChampi])
  4330. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  4331. }
  4332. }
  4333.  
  4334. function treateEnchant()
  4335. {
  4336. if(currentURL.indexOf("as_type=Compo")==-1)
  4337. return false;
  4338. try
  4339. {
  4340. if(!listeMonstreEnchantement)
  4341. computeCompoEnchantement();
  4342. var nodes = document.evaluate(
  4343. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4344. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4345. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4346. if (nodes.snapshotLength == 0)
  4347. return false;
  4348. var urlImg = URL_MZimg09 + "enchant.png";
  4349. for (var i = 0; i < nodes.snapshotLength; i++) {
  4350. var link = nodes.snapshotItem(i);
  4351. var nomCompoTotal = link.firstChild.nodeValue;
  4352. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4353. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4354. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  4355. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  4356. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  4357. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  4358. if(isEnchant(nomMonstre).length>0)
  4359. {
  4360. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  4361. if(infos.length>0)
  4362. {
  4363. link.parentNode.appendChild(createImage(urlImg,infos));
  4364. }
  4365. }
  4366. }
  4367. }
  4368. catch(e)
  4369. {
  4370. window.alert(e);
  4371. }
  4372. }
  4373.  
  4374. function treateEquipEnchant()
  4375. {
  4376. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  4377. return false;
  4378. initPopupTabcompo();
  4379. computeEnchantementEquipement(createPopupImage,formateTexte);
  4380. }
  4381.  
  4382. function do_tancompo() {
  4383. start_script();
  4384.  
  4385. treateAllComposants();
  4386. treateComposants();
  4387. traiteMinerai();
  4388. if (MY_getValue('NOINFOEM')!='true') {
  4389. treateChampi();
  4390. treateEM();
  4391. }
  4392. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  4393. treateEnchant();
  4394. treateEquipEnchant();
  4395. }
  4396.  
  4397. displayScriptTime();
  4398. }
  4399.  
  4400. /*******************************************************************************
  4401. * This file is part of Mountyzilla. *
  4402. * *
  4403. * Mountyzilla is free software; you can redistribute it and/or modify *
  4404. * it under the terms of the GNU General Public License as published by *
  4405. * the Free Software Foundation; either version 2 of the License, or *
  4406. * (at your option) any later version. *
  4407. * *
  4408. * Mountyzilla is distributed in the hope that it will be useful, *
  4409. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4410. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4411. * GNU General Public License for more details. *
  4412. * *
  4413. * You should have received a copy of the GNU General Public License *
  4414. * along with Mountyzilla; if not, write to the Free Software *
  4415. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4416. *******************************************************************************/
  4417.  
  4418. // x~x pjview
  4419.  
  4420. /* TODO
  4421. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  4422. */
  4423.  
  4424. // Bulle d'infos
  4425. var DivInfo;
  4426. // Booléen stockant l'état de freezing de la bulle
  4427. var freezed = false;
  4428.  
  4429. // liste du matos
  4430. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  4431. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4432. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  4433. var mh_caracs = {
  4434. 'anneau de protection':
  4435. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  4436. "armure d'anneaux":
  4437. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  4438. 'armure de bois':
  4439. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  4440. 'armure de cuir':
  4441. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  4442. 'armure de peaux':
  4443. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  4444. 'armure de pierre':
  4445. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  4446. 'armure de plates':
  4447. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  4448. 'baton lesté':
  4449. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4450. 'bâtons de parade':
  4451. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4452. 'bottes':
  4453. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4454. 'bouclier à pointes':
  4455. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4456. 'boulet et chaîne':
  4457. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4458. 'cagoule':
  4459. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  4460. 'casque à cornes':
  4461. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4462. 'casque à pointes':
  4463. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  4464. 'casque en cuir':
  4465. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  4466. 'casque en métal':
  4467. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4468. 'chaîne cloutée':
  4469. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4470. 'chapeau pointu':
  4471. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  4472. 'collier de dents':
  4473. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  4474. 'collier de pierre':
  4475. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4476. 'collier à pointes':
  4477. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4478. 'cotte de mailles':
  4479. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  4480. 'couronne de cristal':
  4481. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  4482. "couronne d'obsidienne":
  4483. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  4484. "coutelas d'obsidienne":
  4485. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  4486. 'coutelas en os':
  4487. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  4488. 'crochet':
  4489. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4490. 'cuir bouilli':
  4491. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  4492. "cuirasse d'ossements":
  4493. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  4494. "cuirasse d'écailles":
  4495. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  4496. 'culotte en cuir':
  4497. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4498. 'dague':
  4499. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4500. 'epée courte':
  4501. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4502. 'epée longue':
  4503. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4504. 'espadon':
  4505. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4506. 'fouet':
  4507. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4508. 'fourrures':
  4509. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  4510. 'gantelet':
  4511. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4512. 'gorgeron en cuir':
  4513. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4514. 'gorgeron en métal':
  4515. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  4516. 'gourdin':
  4517. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4518. 'gourdin clouté':
  4519. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4520. 'grimoire':
  4521. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  4522. "gros'porte":
  4523. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  4524. 'grosse racine':
  4525. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  4526. 'grosse stalagmite':
  4527. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  4528. 'hache de bataille':
  4529. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4530. 'hache de guerre en os':
  4531. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  4532. 'hache de guerre en pierre':
  4533. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  4534. "hache à deux mains d'obsidienne":
  4535. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  4536. 'hallebarde':
  4537. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  4538. "haubert d'écailles":
  4539. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  4540. 'haubert de mailles':
  4541. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  4542. 'heaume':
  4543. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  4544. 'jambières en cuir':
  4545. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  4546. 'jambières en fourrure':
  4547. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  4548. 'jambières en maille':
  4549. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  4550. 'jambières en métal':
  4551. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  4552. 'jambières en os':
  4553. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  4554. "lame d'obsidienne":
  4555. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  4556. 'lame en os':
  4557. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4558. 'lame en pierre':
  4559. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4560. 'lorgnons':
  4561. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  4562. 'machette':
  4563. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4564. "masse d'arme":
  4565. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4566. 'pagne de mailles':
  4567. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4568. 'pagne en cuir':
  4569. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4570. 'robe de mage':
  4571. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  4572. 'rondache en bois':
  4573. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4574. 'rondache en métal':
  4575. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  4576. 'sandales':
  4577. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4578. 'souliers dorés':
  4579. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4580. "talisman d'obsidienne":
  4581. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  4582. 'talisman de pierre':
  4583. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  4584. 'targe':
  4585. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4586. 'torche':
  4587. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  4588. 'torque de pierre':
  4589. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  4590. 'tunique':
  4591. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4592. "tunique d'écailles":
  4593. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  4594. 'turban':
  4595. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  4596. }
  4597.  
  4598. // liste des templates
  4599. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  4600. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4601. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  4602. var mh_templates = {
  4603. 'de Feu':
  4604. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4605. 'de Résistance':
  4606. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  4607. "de l'Aigle":
  4608. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  4609. 'de la Salamandre':
  4610. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  4611. 'des Cyclopes':
  4612. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  4613. 'des Enragés':
  4614. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  4615. 'des Tortues':
  4616. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  4617. 'des Vampires':
  4618. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  4619. 'du Glacier':
  4620. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  4621. 'du Rat':
  4622. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  4623. 'du Roc':
  4624. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  4625. 'du Temps':
  4626. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  4627. 'du Vent':
  4628. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  4629. 'en Mithril':
  4630. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4631. 'des Anciens':
  4632. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4633. 'des Champions':
  4634. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4635. 'des Duellistes':
  4636. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4637. 'de la Terre':
  4638. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  4639. "de l'Orage":
  4640. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  4641. "de l'Ours":
  4642. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  4643. 'des Béhémoths':
  4644. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  4645. 'des Mages':
  4646. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  4647. 'du Pic':
  4648. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  4649. 'du Sable':
  4650. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  4651. 'acéré':
  4652. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4653. 'acérée':
  4654. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4655. 'équilibré':
  4656. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4657. 'équilibrée':
  4658. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4659. 'léger':
  4660. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  4661. 'légère':
  4662. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  4663. 'renforcé':
  4664. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  4665. 'renforcée':
  4666. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  4667. 'robuste':
  4668. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  4669. }
  4670.  
  4671. function clone(arr) {
  4672. // Clonage rapide
  4673. return arr.slice(0);
  4674. }
  4675.  
  4676. function addArray(arr1,arr2) {
  4677. // Somme matricielle
  4678. var res = clone(arr1);
  4679. for(i=res.length-1 ; i>=0 ; i--) {
  4680. res[i] += arr2[i];
  4681. }
  4682. return res;
  4683. }
  4684.  
  4685. function getTemplates(nomItem) {
  4686. // Déstructure le nom de l'item en array [nom, template1, ...]
  4687. var tempFound = true;
  4688. var str = nomItem.trim();
  4689. var arr = [];
  4690. while(tempFound) {
  4691. tempFound = false;
  4692. for(var temp in mh_templates) {
  4693. // on teste la fin du nom contre chaque template
  4694. if(str.slice(-temp.length)!=temp) { continue; }
  4695. tempFound = true;
  4696. str = str.slice(0,-temp.length-1);
  4697. arr.unshift(temp);
  4698. if(str.slice(-3)==' et') {
  4699. str = str.slice(0,-3);
  4700. }
  4701. }
  4702. }
  4703. arr.unshift(str);
  4704. return arr;
  4705. }
  4706.  
  4707. function addMithril(arrayCaracs,typeItem) {
  4708. // Ajoute l'effet du Mithril sur les caracs
  4709. if(typeItem=='arme') {
  4710. if(arrayCaracs[0]<0) {
  4711. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  4712. }
  4713. }
  4714. else {
  4715. if(arrayCaracs[4]<0) {
  4716. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  4717. }
  4718. }
  4719. arrayCaracs[15] /= 2;
  4720. arrayCaracs[16] /= 2;
  4721. return arrayCaracs;
  4722. }
  4723.  
  4724. function addRenfort(arrayCaracs,template) {
  4725. // Ajoute l'effet des pseudo-templates sur les caracs
  4726. // S'applique APRÈS le mithril
  4727. // WARNING - Cette formule n'a rien d'officiel, gare !
  4728. var coef = 0;
  4729. if(/^lég[e,è]re?$/.test(template)) {
  4730. coef = -1;
  4731. }
  4732. else if(/^renforcée?$/.test(template)
  4733. || template==='robuste') {
  4734. coef = 1;
  4735. }
  4736. if(coef) {
  4737. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  4738. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  4739. }
  4740. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  4741. return arrayCaracs;
  4742. }
  4743.  
  4744. function getCaracs(item) {
  4745. // Calcule les caractéristiques de l'item
  4746. var templates = getTemplates(item);
  4747. if(!mh_caracs[templates[0]]) {
  4748. // Si l'item est inconnu
  4749. return [];
  4750. }
  4751. var caracs = clone(mh_caracs[templates[0]]);
  4752. var typeItem = caracs[0];
  4753. caracs.shift();
  4754. templates.shift();
  4755. if(templates[templates.length-1]=='en Mithril') {
  4756. caracs = addMithril(caracs,typeItem);
  4757. templates.pop();
  4758. }
  4759. if(/^acérée?$/.test(templates[0])
  4760. || /^équilibrée?$/.test(templates[0])
  4761. || /^lég[e,è]re?$/.test(templates[0])
  4762. || /^renforcée?$/.test(templates[0])
  4763. || templates[0]=='robuste') {
  4764. caracs = addRenfort(caracs,templates[0]);
  4765. templates.shift();
  4766. }
  4767. for(var i=templates.length-1 ; i>=0 ; i--) {
  4768. caracs = addArray(caracs,mh_templates[templates[i]]);
  4769. }
  4770. return caracs;
  4771. }
  4772.  
  4773. function getLine(tab) {
  4774. // Préparation de la ligne à afficher lors d'un mouseover
  4775. var str = '';
  4776. if(tab[0]!=0 || tab[1]!=0) {
  4777. str += '<b>Att : </b>'+aff(tab[0]);
  4778. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  4779. str += ' | ';
  4780. }
  4781. if(tab[4]!=0) {
  4782. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  4783. }
  4784. if(tab[2]!=0 || tab[3]!=0) {
  4785. str += '<b>Deg : </b>'+aff(tab[2]);
  4786. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  4787. str += ' | ';
  4788. }
  4789. if(tab[8]!=0) {
  4790. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  4791. }
  4792. if(tab[7]!=0) {
  4793. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  4794. }
  4795. if(tab[5]!=0 || tab[6]!=0) {
  4796. str += '<b>Arm : </b>'+aff(tab[5]);
  4797. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  4798. str += ' | ';
  4799. }
  4800. if(tab[9]!=0 || tab[10]!=0) {
  4801. str += '<b>RM : </b>'+aff(tab[9])+'%';
  4802. if(tab[9]!=tab[10]) {
  4803. str += '/'+aff(tab[10])+'%';
  4804. }
  4805. str += ' | ';
  4806. }
  4807. if(tab[11]!=0 || tab[12]!=0) {
  4808. str += '<b>MM : </b>'+aff(tab[11])+'%';
  4809. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  4810. str += ' | ';
  4811. }
  4812. if(tab[13]!=0) {
  4813. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  4814. }
  4815. if(tab[14]!=0) {
  4816. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  4817. }
  4818. str += '<b>Poids : </b>'+tab[15]+' min';
  4819. if(tab[15]!=tab[16]) {
  4820. str += ' / '+tab[16]+' min';
  4821. }
  4822. return str;
  4823. }
  4824.  
  4825. function toolTipInit() {
  4826. DivInfo = document.createElement('div');
  4827. DivInfo.id = 'infosVue';
  4828. DivInfo.className = 'mh_textbox';
  4829. DivInfo.style =
  4830. 'position: absolute;'
  4831. +'border: 1px solid #000000;'
  4832. +'visibility:hidden;'
  4833. +'display:inline;'
  4834. +'z-index:99;';
  4835. document.body.appendChild(DivInfo);
  4836. document.onmousemove = getXY;
  4837. document.onclick = changeFreezeStatus;
  4838. }
  4839.  
  4840. function getXY(evt) {
  4841. if(!freezed && DivInfo.style.visibility=='visible') {
  4842. DivInfo.style.left = evt.pageX+'px';
  4843. DivInfo.style.top = evt.pageY+10+'px';
  4844. }
  4845. }
  4846.  
  4847. function changeFreezeStatus() {
  4848. if(DivInfo.style.visibility=='visible') {
  4849. freezed = !freezed;
  4850. if(!freezed) { hideInfos(); }
  4851. }
  4852. }
  4853.  
  4854. function showInfos() {
  4855. if(freezed) { return; }
  4856. var currentInfos = this.infos;
  4857. DivInfo.innerHTML = currentInfos;
  4858. DivInfo.style.visibility = 'visible';
  4859. }
  4860.  
  4861. function hideInfos() {
  4862. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  4863. }
  4864.  
  4865. function treateEquipement() {
  4866. // Extrait les données du matos et réinjecte les infos déduites
  4867. if(MY_getValue('INFOCARAC')=='false') { return; }
  4868. var faireLigne = false;
  4869. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  4870. var nodes = document.evaluate(
  4871. "//td/b[text()='Equipement Utilisé']/../../"
  4872. +"td[2]/img[contains(@src,bullet)]",
  4873. document, null, 7, null);
  4874. if(nodes.snapshotLength>0) {
  4875. // Si CSS de base
  4876. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  4877. var node = nodes.snapshotItem(i);
  4878. var next = node.nextSibling;
  4879. var nnext = next.nextSibling;
  4880. var nom = next.nodeValue.toLowerCase();
  4881. if(nnext.childNodes.length==1) {
  4882. nom += nnext.firstChild.nodeValue;
  4883. }
  4884. nom = nom.trim();
  4885. // gestion winpostrophe
  4886. var c = String.fromCharCode(180);
  4887. while(nom.indexOf(c)!=-1) {
  4888. nom = nom.replace(c,"'");
  4889. }
  4890. var arr = getCaracs(nom);
  4891. if(arr.length>0) {
  4892. faireLigne = true;
  4893. caracs = addArray(caracs,arr);
  4894. var span = document.createElement('span');
  4895. span.appendChild(next);
  4896. span.appendChild(nnext);
  4897. span.infos = getLine(arr);
  4898. span.onmouseover = showInfos;
  4899. span.onmouseout = hideInfos;
  4900. insertBefore(node.nextSibling,span);
  4901. }
  4902. }
  4903. if(faireLigne) {
  4904. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  4905. document, null, 9, null).singleNodeValue;
  4906. node.infos = getLine(caracs);
  4907. node.onmouseover = showInfos;
  4908. node.onmouseout = hideInfos;
  4909. }
  4910. }
  4911. else {
  4912. // Si CSS avancée
  4913. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  4914. document, null, 7, null);
  4915. if(nodes.snapshotLength>0) {
  4916. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  4917. var node = nodes.snapshotItem(i);
  4918. var nom = node.firstChild.nodeValue.toLowerCase();
  4919. if(node.childNodes.length>1) {
  4920. nom += node.childNodes[1].firstChild.nodeValue;
  4921. }
  4922. nom = nom.trim();
  4923. // gestion winpostrophe
  4924. var c = String.fromCharCode(180);
  4925. while(nom.indexOf(c)!=-1) {
  4926. nom = nom.replace(c,"'");
  4927. }
  4928. var arr = getCaracs(nom);
  4929. if(arr.length!=0) {
  4930. caracs = addArray(caracs,arr);
  4931. node.infos = getLine(arr);
  4932. node.onmouseover = showInfos;
  4933. node.onmouseout = hideInfos;
  4934. }
  4935. }
  4936. var nodes = document.evaluate("//dt[@class='equipement']",
  4937. document, null, 7, null);
  4938. var node = nodes.snapshotItem(0);
  4939. node.infos = getLine(caracs);
  4940. node.onmouseover = showInfos;
  4941. node.onmouseout = hideInfos;
  4942. }
  4943. }
  4944. }
  4945.  
  4946. function do_pjview() {
  4947. treateEquipement();
  4948. toolTipInit();
  4949. }
  4950.  
  4951. /*******************************************************************************
  4952. * This file is part of Mountyzilla. *
  4953. * *
  4954. * Mountyzilla is free software; you can redistribute it and/or modify *
  4955. * it under the terms of the GNU General Public License as published by *
  4956. * the Free Software Foundation; either version 2 of the License, or *
  4957. * (at your option) any later version. *
  4958. * *
  4959. * Mountyzilla is distributed in the hope that it will be useful, *
  4960. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4961. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4962. * GNU General Public License for more details. *
  4963. * *
  4964. * You should have received a copy of the GNU General Public License *
  4965. * along with Mountyzilla; if not, write to the Free Software *
  4966. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4967. *******************************************************************************/
  4968.  
  4969. // x~x option
  4970.  
  4971. /* TODO
  4972. * Passer le HTML injecté aux conventions HTML5
  4973. */
  4974.  
  4975.  
  4976. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  4977.  
  4978. function saveITData() {
  4979. var IT = document.getElementById('itSelect').value;
  4980. if(IT=='bricol') {
  4981. var system = document.getElementById('urlbricol').value;
  4982. var login = document.getElementById('loginbricol').value;
  4983. var pass = document.getElementById('passbricol').value;
  4984. if(system && login && pass) {
  4985. MY_setValue(numTroll+'.INFOSIT',
  4986. 'bricol$'+system+'$'+login+'$'+hex_md5(pass) );
  4987. }
  4988. }
  4989. else {
  4990. MY_removeValue(numTroll+'.INFOSIT');
  4991. }
  4992. }
  4993.  
  4994. function saveLinks() {
  4995. var numLinks = document.getElementById('linksBody').childNodes.length;
  4996. var data=[ [] ];
  4997. /* Récupération et tri des liens */
  4998. for(var i=1 ; i<=numLinks ; i++) {
  4999. MY_removeValue('URL'+i);
  5000. MY_removeValue('URL'+i+'.nom');
  5001. MY_removeValue('URL'+i+'.ico');
  5002. var url = document.getElementById('url'+i).value;
  5003. var nom = document.getElementById('nom'+i).value;
  5004. var ico = document.getElementById('ico'+i).value;
  5005. if(url && (nom || ico) ) {
  5006. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5007. }
  5008. }
  5009. /* Sauvegarde */
  5010. for(var i=1 ; i<data.length ; i++) {
  5011. MY_setValue('URL'+i,data[i][0]);
  5012. MY_setValue('URL'+i+'.nom',data[i][1]);
  5013. MY_setValue('URL'+i+'.ico',data[i][2]);
  5014. }
  5015. }
  5016.  
  5017. function saveAll() {
  5018. var urlIco = document.getElementById('icoMenuIco').value;
  5019. if(urlIco) {
  5020. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5021. }
  5022. else {
  5023. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5024. document.getElementById('icoMenuIco').value = '';
  5025. }
  5026. saveLinks();
  5027. refreshLinks();
  5028. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5029. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5030. if(maxcdm) {
  5031. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5032. }
  5033. else {
  5034. MY_removeValue(numTroll+'.MAXCDM');
  5035. document.getElementById('maxcdm').value = '';
  5036. }
  5037.  
  5038. MY_setValue('NOINFOEM',
  5039. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5040. // Pourquoi Tilk stockait-il tout en str ?
  5041. // -> parce que les booléens c'est foireux (vérifié)
  5042. MY_setValue(numTroll+'.USECSS',
  5043. document.getElementById('usecss').checked ? 'true':'false');
  5044. MY_setValue('INFOCARAC',
  5045. document.getElementById('infocarac').checked ? 'true' : 'false');
  5046. //MY_setValue(numTroll+'.SEND_IDT',
  5047. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  5048. // Fonctionnalité désactivée
  5049.  
  5050. MY_setValue(numTroll+'.AUTOCDM',
  5051. document.getElementById('autoCdM').checked ? 'true' : 'false');
  5052. MY_setValue('VUECARAC',
  5053. document.getElementById('vueCarac').checked ? 'true' : 'false');
  5054. MY_setValue('CONFIRMEDECALAGE',
  5055. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  5056. MY_setValue(numTroll+".OLDSCHOOL",
  5057. document.getElementById("oldShoolStyle").checked ? "true" : "false");
  5058.  
  5059. saveITData();
  5060. var bouton = document.getElementById('saveAll');
  5061. bouton.value = (bouton.value=='Sauvegardé !') ?
  5062. 'Re-sauvegardé !' : 'Sauvegardé !';
  5063. }
  5064.  
  5065.  
  5066. /*-[functions]----------------- EventListeners -------------------------------*/
  5067.  
  5068. function onChangeIT() {
  5069. var IT = document.getElementById('itSelect').value;
  5070. var itBody = document.getElementById('itBody');
  5071. itBody.innerHTML = '';
  5072. if(IT=='bricol') {
  5073. var tr = appendTr(itBody,'mh_tdpage')
  5074. var td = appendTd(tr);
  5075. var str = MY_getValue(numTroll+'.INFOSIT');
  5076. if(str) {
  5077. var arr = str.split('$');
  5078. var system = arr[1];
  5079. var login = arr[2];
  5080. }
  5081. appendText(td,'Nom du système : ');
  5082. appendTextbox(td,'text','urlbricol',20,50,system);
  5083. td = appendTd(tr);
  5084. appendText(td,'Login du compte : ');
  5085. appendTextbox(td,'text','loginbricol',20,50,login);
  5086. td = appendTd(tr);
  5087. appendText(td,'Mot de passe du compte : ');
  5088. appendTextbox(td,'password','passbricol',20,50);
  5089. }
  5090. }
  5091.  
  5092. function refreshLinks() {
  5093. document.getElementById('linksBody').innerHTML = '';
  5094. var anotherURL = MY_getValue('URL1');
  5095. if(!anotherURL) { addLinkField(); }
  5096. var i=1;
  5097. while(anotherURL && i<99) {
  5098. addLinkField(i,anotherURL,
  5099. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  5100. i++;
  5101. anotherURL = MY_getValue('URL'+i);
  5102. }
  5103. }
  5104.  
  5105. function addLinkField(i,url,nom,ico) {
  5106. var linksBody = document.getElementById('linksBody');
  5107. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  5108. var tr = appendTr(linksBody);
  5109. var td = appendTdCenter(tr);
  5110. appendText(td,'Lien '+i+' : ');
  5111. appendTextbox(td,'text','url'+i,40,150,url);
  5112. td = appendTdCenter(tr);
  5113. appendText(td,'Nom : ');
  5114. appendTextbox(td,'text','nom'+i,20,150,nom);
  5115. td = appendTdCenter(tr);
  5116. appendText(td,'Icône : ');
  5117. appendTextbox(td,'text','ico'+i,40,150,ico);
  5118. }
  5119.  
  5120. function removeLinkField() {
  5121. var linksBody = document.getElementById('linksBody');
  5122. var i = linksBody.childNodes.length;
  5123. MY_removeValue('URL'+i);
  5124. MY_removeValue('URL'+i+'.nom');
  5125. MY_removeValue('URL'+i+'.ico');
  5126. linksBody.removeChild(linksBody.lastChild);
  5127. if(linksBody.childNodes.length==0) { addLinkField(); }
  5128. }
  5129.  
  5130. function resetMainIco() {
  5131. document.getElementById('icoMenuIco').value=
  5132. URL_MZimg09 + 'MY_logo_small.png';
  5133. }
  5134.  
  5135.  
  5136. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  5137.  
  5138. function insertTitle(next,txt) {
  5139. var div = document.createElement('div');
  5140. div.className = 'titre2';
  5141. appendText(div,txt);
  5142. insertBefore(next,div);
  5143. }
  5144.  
  5145. function insertMainTable(next) {
  5146. var table = document.createElement('table');
  5147. table.width = '98%';
  5148. table.border = 0;
  5149. table.align = 'center';
  5150. table.cellPadding = 2;
  5151. table.cellSpacing = 1;
  5152. table.className = 'mh_tdborder';
  5153. var tbody = document.createElement('tbody');
  5154. table.appendChild(tbody);
  5155. insertBefore(next,table);
  5156. return tbody;
  5157. }
  5158.  
  5159. function appendSubTable(node) {
  5160. var table = document.createElement('table');
  5161. table.width = '100%';
  5162. var tbody = document.createElement('tbody');
  5163. table.appendChild(tbody);
  5164. node.appendChild(table);
  5165. return tbody;
  5166. }
  5167.  
  5168. function insertOptionTable(insertPt) {
  5169. var mainBody = insertMainTable(insertPt);
  5170. /* Liens dans le Menu */
  5171. var tr = appendTr(mainBody,'mh_tdtitre');
  5172. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  5173. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5174. appendText(td,'Icône du Menu: ');
  5175. var url = MY_getValue(numTroll+'.ICOMENU');
  5176. if(!url) {
  5177. url = URL_MZimg09 + 'MY_logo_small.png';
  5178. }
  5179. appendTextbox(td,'text','icoMenuIco',50,200,url);
  5180. appendButton(td,'Réinitialiser',resetMainIco);
  5181. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5182. var tbody = appendSubTable(td);
  5183. tbody.id = 'linksBody';
  5184. refreshLinks();
  5185. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  5186. appendButton(td,'Ajouter',addLinkField);
  5187. appendButton(td,'Supprimer',removeLinkField);
  5188. /* Options de la Vue : vue externe, nb de CdM, etc */
  5189. tr = appendTr(mainBody,'mh_tdtitre');
  5190. appendTdText(tr,'Options de la Vue :',true);
  5191. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5192. tbody = appendSubTable(td);
  5193. tr = appendTr(tbody);
  5194. td = appendTdText(tr,'Vue externe : ');
  5195. var select = document.createElement('select');
  5196. select.id = 'vueext';
  5197. td.appendChild(select);
  5198. var listeVues2D = [
  5199. 'Bricol\' Vue',
  5200. 'Vue du CCM',
  5201. 'Vue Gloumfs 2D',
  5202. 'Vue Gloumfs 3D',
  5203. 'Grouky Vue!'
  5204. ];
  5205. for(var i=0 ; i<listeVues2D.length ; i++) {
  5206. appendOption(select,listeVues2D[i],listeVues2D[i]);
  5207. }
  5208. if(MY_getValue('VUEEXT')) {
  5209. select.value = MY_getValue('VUEEXT');
  5210. }
  5211. td = appendTd(tr);
  5212. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  5213. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  5214. tr = appendTr(tbody);
  5215. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  5216. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  5217. td = appendTd(tr);
  5218. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  5219. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  5220. /* Interface Tactique */
  5221. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5222. appendText(td,'Interface Tactique : ',true);
  5223. select = document.createElement('select');
  5224. select.id = 'itSelect';
  5225. appendOption(select,'none','Aucune');
  5226. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  5227. // seule interface supportée !
  5228. td.appendChild(select);
  5229. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5230. tbody = appendSubTable(td);
  5231. tbody.id = 'itBody';
  5232. select.onchange = onChangeIT;
  5233. var str = MY_getValue(numTroll+'.INFOSIT');
  5234. if(str) {
  5235. select.value = str.slice(0,str.indexOf('$'));
  5236. onChangeIT();
  5237. }
  5238. /* Options diverses */
  5239. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5240. appendText(td,'Options diverses :',true);
  5241. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5242. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  5243. appendText(td,
  5244. ' Afficher les caractéristiques des équipements des autres Trõlls');
  5245. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5246. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  5247. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  5248. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5249. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  5250. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  5251. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5252. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  5253. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  5254. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5255. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  5256. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  5257. td = appendTd(appendTr(mainBody,"mh_tdpage"));
  5258. appendCheckBox(td,"oldShoolStyle",MY_getValue(numTroll+".OLDSCHOOL")=="true");
  5259. appendText(td," Ouvrir l'ancien profil par défaut");
  5260. /* Bouton SaveAll */
  5261. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  5262. input = appendButton(td,'Sauvegarder',saveAll);
  5263. input.id = 'saveAll';
  5264. }
  5265.  
  5266. function insertCreditsTable(insertPt) {
  5267. var tbody = insertMainTable(insertPt);
  5268. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  5269. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  5270. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  5271.  
  5272. var ul = document.createElement('ul');
  5273. td.appendChild(ul);
  5274. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  5275. appendLI(ul,'Reivax (4234) pour les infos bulles');
  5276. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  5277. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  5278. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  5279. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  5280. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  5281. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer '
  5282. +'à Mountyzilla');
  5283. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites '
  5284. +'du raisonnable avec sa vue de barbare');
  5285. appendLI(ul,'TuttiRikikiMaoussKosTroll (61214) pour le script '
  5286. +'sur les caracs de l\'équipement');
  5287. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, '
  5288. +'des scripts, et beaucoup de choses à venir');
  5289. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  5290. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233)... '
  5291. +'et tous les participants au projet ZoryaZilla');
  5292. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  5293. appendLI(ul,'Rokü Menton-brûlant (108387) pour m\'avoir incité à passer '
  5294. +'sur GitHub');
  5295. appendLI(ul,'Rouletabille (91305) & Marmotte (93138) pour leur support '
  5296. +'technique récurrent');
  5297. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  5298. appendLI(ul,'Tous les testeurs de la nouvelle génération '
  5299. +'oubliés par Dabihul');
  5300. }
  5301.  
  5302.  
  5303. /* [functions] Obsolètes */
  5304. function deleteEnchantement()
  5305. {
  5306. try
  5307. {
  5308. var idEquipement = this.getAttribute('name');
  5309. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  5310. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  5311. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  5312. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  5313. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  5314. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5315. var string = "";
  5316. for(var i=0;i<listeEquipement.length;i++)
  5317. {
  5318. if(listeEquipement[i]!=idEquipement)
  5319. if(string=="")
  5320. string = listeEquipement[i];
  5321. else
  5322. string += ";"+listeEquipement[i];
  5323. }
  5324. if(string=="")
  5325. {
  5326. MY_removeValue(numTroll+".enchantement.liste");
  5327. var table = this.parentNode.parentNode.parentNode.parentNode;
  5328. var parent = table.parentNode;
  5329. for(var i=0;i<parent.childNodes.length;i++)
  5330. {
  5331. if(parent.childNodes[i]==table)
  5332. {
  5333. parent.removeChild(parent.childNodes[i-1]);
  5334. parent.removeChild(parent.childNodes[i-1]);
  5335. parent.removeChild(parent.childNodes[i-1]);
  5336. break;
  5337. }
  5338. }
  5339. }
  5340. else
  5341. {
  5342. MY_getValue(numTroll+".enchantement.liste",string);
  5343. this.parentNode.parentNode.parentNode
  5344. .removeChild(this.parentNode.parentNode);
  5345. }
  5346. }
  5347. catch(e)
  5348. {
  5349. window.alert(e);
  5350. }
  5351. }
  5352. /* [functions] fin Obsolètes */
  5353.  
  5354. /*-[functions]---------------- Partie principale -----------------------------*/
  5355.  
  5356. function do_option() {
  5357. start_script(712);
  5358.  
  5359. // Pour cryptage des mdp IT
  5360. appendNewScript(URL_tilk_js + 'md5.js');
  5361.  
  5362. var insertPoint = document.getElementById('footer1');
  5363. insertBefore(insertPoint,document.createElement('p'));
  5364. insertTitle(insertPoint,'Mountyzilla : Options');
  5365. insertOptionTable(insertPoint);
  5366. /* insertion enchantements ici
  5367. if(...)
  5368. insertEnchantementTable();
  5369. */
  5370. insertBefore(insertPoint,document.createElement('p'));
  5371. insertTitle(insertPoint,'Mountyzilla : Crédits');
  5372. insertCreditsTable(insertPoint);
  5373. insertBefore(insertPoint,document.createElement('p'));
  5374.  
  5375. /* [zone] Obsolète ?? */
  5376. if(MY_getValue(numTroll+".enchantement.liste")
  5377. && MY_getValue(numTroll+".enchantement.liste")!="" )
  5378. {
  5379. insertTitle(insertPoint, 'Les Enchantements en cours');
  5380. table = document.createElement('table');
  5381. table.setAttribute('width', '98%');
  5382. table.setAttribute('border', '0');
  5383. table.setAttribute('align', 'center');
  5384. table.setAttribute('cellpadding', '2');
  5385. table.setAttribute('cellspacing', '1');
  5386. table.setAttribute('class', 'mh_tdborder');
  5387.  
  5388. tbody = document.createElement('tbody');
  5389. table.appendChild(tbody);
  5390. tr = appendTr(tbody, 'mh_tdtitre');
  5391. appendTdText(tr, 'Equipement',1);
  5392. appendTdText(tr, 'Composants',1);
  5393. appendTdText(tr, 'Enchanteur',1);
  5394. appendTdText(tr, 'Action',1);
  5395. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5396. for(var i=0;i<listeEquipement.length;i++)
  5397. {
  5398. try
  5399. {
  5400. var idEquipement = listeEquipement[i];
  5401. var nomEquipement = MY_getValue(numTroll+".enchantement."
  5402. +idEquipement+".objet");
  5403. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  5404. +idEquipement+".enchanteur").split(";");
  5405. var ul = document.createElement('UL');
  5406. for(var j=0;j<3;j++)
  5407. {
  5408. var infoComposant = MY_getValue(numTroll+".enchantement."
  5409. +idEquipement+".composant."+j).split(";");
  5410. var texte = infoComposant[4].replace("Ril ","Œil ");
  5411. for(var k=5;k<infoComposant.length;k++)
  5412. {
  5413. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  5414. }
  5415. li = appendLI(ul,texte);
  5416. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  5417. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  5418. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  5419. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  5420. string+= '<input type="hidden" name="q" value="min" />';
  5421. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  5422. string+= ' &nbsp; <input type="button" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" onClick="javascript:window.open(&quot;' + URL_cyclotrolls + 'wakka.php?wiki=TroOGle&trooglephr=base%3Amonstres+tag%3Anom+%22'+infoComposant[2]+'%22&quot;)" value="Localiser le monstre grâce à Troogle" /></form>';
  5423.  
  5424. string+= '</form>';
  5425. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  5426. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  5427. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  5428. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  5429. li.innerHTML += string;
  5430. }
  5431. tr = appendTr(tbody, 'mh_tdpage');
  5432. td = appendTdText(tr, nomEquipement);
  5433. td.setAttribute('valign', 'center');
  5434. td = document.createElement('td');
  5435. td.appendChild(ul);
  5436. tr.appendChild(td);
  5437. td.setAttribute('valign', 'center');
  5438. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  5439. td.setAttribute('valign', 'center');
  5440. td = document.createElement('td');
  5441. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  5442. input.setAttribute('name', idEquipement);
  5443. tr.appendChild(td);
  5444. td.setAttribute('valign', 'center');
  5445. }
  5446. catch(e)
  5447. {
  5448. }
  5449. }
  5450. insertBefore(insertPoint, table);
  5451. insertBefore(insertPoint, document.createElement('p'));
  5452. }
  5453. /* [zone] fin Obsolète ?? */
  5454.  
  5455.  
  5456. displayScriptTime();
  5457. }
  5458.  
  5459. /*******************************************************************************
  5460. * This file is part of Mountyzilla. *
  5461. * *
  5462. * Mountyzilla is free software; you can redistribute it and/or modify *
  5463. * it under the terms of the GNU General Public License as published by *
  5464. * the Free Software Foundation; either version 2 of the License, or *
  5465. * (at your option) any later version. *
  5466. * *
  5467. * Mountyzilla is distributed in the hope that it will be useful, *
  5468. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5469. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5470. * GNU General Public License for more details. *
  5471. * *
  5472. * You should have received a copy of the GNU General Public License *
  5473. * along with Mountyzilla; if not, write to the Free Software *
  5474. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5475. *******************************************************************************/
  5476.  
  5477. // x~x equip
  5478.  
  5479. /**
  5480. * 2014-02-08 - v2.0a (from scratch)
  5481. * 2014-02-18 - v2.0a0
  5482. * - ajout calcul Carats / UM des minerais + totaux
  5483. * 2014-03-06 - v2.0a1
  5484. * - retour Infos EM des Champis
  5485. * TODO
  5486. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  5487. */
  5488.  
  5489. function traiteChampis() {
  5490. try{
  5491. var tr = document.getElementById('mh_objet_hidden_Champignon');
  5492. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  5493. }
  5494. catch(e){return;}
  5495. if(trlist.length<=0) return;
  5496. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  5497. var node = trlist.snapshotItem(i).childNodes[7];
  5498. var str = node.textContent.trim();
  5499. var type = str.slice(0,str.lastIndexOf(' '));
  5500. var mundi = mundiChampi[type];
  5501. if(!mundi) continue;
  5502. var urlImg = URL_MZimg09
  5503. +'Competences/ecritureMagique.png';
  5504. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  5505. appendText(node,' ');
  5506. node.appendChild(img);
  5507. }
  5508. }
  5509.  
  5510. function traiteCompos() {
  5511. try {
  5512. var tr = document.getElementById('mh_objet_hidden_Composant');
  5513. var tbody = document.evaluate("./td/table/tbody",
  5514. tr, null, 9, null).singleNodeValue;
  5515. }
  5516. catch(e) {return;}
  5517. insererInfosEM(tbody);
  5518. }
  5519.  
  5520. function traiteMinerai() {
  5521. try{
  5522. var tr = document.getElementById('mh_objet_hidden_Minerai');
  5523. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  5524. }
  5525. catch(e){return;}
  5526. if(trlist.length<=0) return;
  5527. var totaux = {};
  5528. var str;
  5529. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  5530. var node = trlist.snapshotItem(i);
  5531. var nature = node.childNodes[7].textContent,
  5532. caracs = node.childNodes[9].textContent;
  5533. var taille = Number(caracs.match(/\d+/)[0]);
  5534. var coef = 1;
  5535. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  5536. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  5537. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  5538. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5539. if(nature.indexOf('Mithril')!=-1) {
  5540. coef = 0.2*coef;
  5541. str = ' | UM: ';
  5542. }
  5543. else {
  5544. coef = 0.75*coef+1.25;
  5545. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5546. str = ' | Carats: ';
  5547. }
  5548. var carats = Math.round(taille*coef)
  5549. appendText(node.childNodes[9], str+carats );
  5550. if(!totaux[nature]) {
  5551. totaux[nature] = [taille,carats];
  5552. }
  5553. else {
  5554. totaux[nature][0] += taille;
  5555. totaux[nature][1] += carats;
  5556. }
  5557. }
  5558. str = 'Total : ';
  5559. for(var nature in totaux) {
  5560. if(str.length>8) str += ', ';
  5561. if(nature.indexOf('Mithril')!=-1) {
  5562. str += nature+totaux[nature][1]+' UM';
  5563. }
  5564. else {
  5565. str += nature+totaux[nature][0]+'U/'
  5566. +totaux[nature][1]+'c';
  5567. }
  5568. }
  5569. /*var node = document.getElementById('mh_plus_Minerai');
  5570. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  5571. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  5572. if(!titre) return;*/
  5573. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  5574. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  5575. td.colSpan = 7;
  5576. }
  5577.  
  5578. function do_equip() {
  5579. start_script();
  5580.  
  5581. traiteChampis();
  5582. traiteCompos();
  5583. traiteMinerai();
  5584.  
  5585. displayScriptTime();
  5586. }
  5587.  
  5588. /*******************************************************************************
  5589. * This file is part of Mountyzilla. *
  5590. * *
  5591. * Mountyzilla is free software; you can redistribute it and/or modify *
  5592. * it under the terms of the GNU General Public License as published by *
  5593. * the Free Software Foundation; either version 2 of the License, or *
  5594. * (at your option) any later version. *
  5595. * *
  5596. * Mountyzilla is distributed in the hope that it will be useful, *
  5597. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5598. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5599. * GNU General Public License for more details. *
  5600. * *
  5601. * You should have received a copy of the GNU General Public License *
  5602. * along with Mountyzilla; if not, write to the Free Software *
  5603. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5604. *******************************************************************************/
  5605.  
  5606. // x~x diplo
  5607.  
  5608. /*
  5609. TODO:
  5610. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  5611. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  5612. V Étape 3: Ajout de la diplo perso
  5613. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  5614. V Étape 5: Ajout des fioritures (preview de la couleur...)
  5615. Options Globales:
  5616. Actuelles:
  5617. numTroll.USECSS,
  5618. numTroll.NODIPLO
  5619. NOMYTH
  5620. Nouvelles:
  5621. TODO numTroll.USECSS
  5622. numTroll.diplo.off (remplace NODIPLO)
  5623. numTroll.diplo.guilde
  5624. numTroll.diplo.perso
  5625. Structure de diplo.guilde:
  5626. isOn: 'true' ou 'false'
  5627. isDetailOn: 'true' ou 'false'
  5628. guilde
  5629. > id
  5630. > couleur
  5631. AllAmis,AllEnnemis: couleur
  5632. Amis0,...,Ennemis5
  5633. > Troll: idTroll1;...;
  5634. > Guilde: idGuilde1;...;
  5635. > titre
  5636. > couleur
  5637. Structure de diplo.perso:
  5638. isOn: 'true' ou 'false'
  5639. mythiques: couleur
  5640. Troll,Guilde,Monstre:
  5641. > id
  5642. > couleur
  5643. > description
  5644. */
  5645.  
  5646. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  5647.  
  5648. function couleurAleatoire() {
  5649. var alph = '0123456789ABCDEF'.split('');
  5650. var clr = '#';
  5651. for (var i=0; i<6; i++) {
  5652. clr+=alph[ Math.floor(16*Math.random()) ];
  5653. }
  5654. return clr;
  5655. }
  5656.  
  5657. function isCouleur(str) {
  5658. return /^#[0-9A-F]{6}$/i.test(str);
  5659. }
  5660.  
  5661. /*-[functions]---------------- Analyse de la page ----------------------------*/
  5662.  
  5663. function appendChoixCouleur(node,id) {
  5664. var span = document.createElement('span');
  5665. span.id = 'span'+id;
  5666. if(isDetailOn) {
  5667. span.style.display = 'none';
  5668. }
  5669. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  5670. if(diploGuilde[id]) {
  5671. couleur = diploGuilde[id];
  5672. }
  5673. appendText(span,' - Couleur HTML: ');
  5674. var input = appendTextbox(span,'text',id,7,7,couleur);
  5675. input.onkeyup = previewCouleur;
  5676. input.onchange = previewCouleur;
  5677. input.onkeyup();
  5678. node.appendChild(span);
  5679. }
  5680.  
  5681. function insertChoixCouleur(node,id) {
  5682. var span = document.createElement('span');
  5683. span.id = 'span'+id;
  5684. // La couleur détaillée passera à une valeur aléatoire
  5685. // si toggle vers isDetailOn
  5686. var couleur = couleurAleatoire();
  5687. if(!isDetailOn) {
  5688. span.style.display = 'none';
  5689. } else if(diploGuilde[id]) {
  5690. couleur = diploGuilde[id].couleur;
  5691. }
  5692. appendText(span,' - Couleur HTML: ');
  5693. var input = appendTextbox(span,'text',id,7,7,couleur);
  5694. input.onkeyup = previewCouleur;
  5695. input.onchange = previewCouleur;
  5696. input.onkeyup();
  5697. insertBefore(node,span);
  5698. }
  5699.  
  5700. function setChoixCouleurs() {
  5701. try {
  5702. var form = document.getElementsByName('ActionForm')[0];
  5703. var nodesAE = document.evaluate(
  5704. "./table/tbody/tr/td[@class='mh_tdtitre']",
  5705. form, null, 7, null
  5706. );
  5707. var nodes = document.evaluate(
  5708. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  5709. form, null, 7, null
  5710. );
  5711. } catch(e) {
  5712. window.console.error('[Diplomatie] Structure de la page non reconnue');
  5713. return false;
  5714. };
  5715. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  5716. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  5717. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  5718. for(var i=0 ; i<5 ; i++) {
  5719. nodes.snapshotItem(i).id = 'tdAmis'+i;
  5720. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  5721. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  5722. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  5723. }
  5724. return true;
  5725. }
  5726.  
  5727. function fetchDiploGuilde() {
  5728. try {
  5729. for(var AE in {Amis:0,Ennemis:0}) {
  5730. for(var i=0 ; i<5 ; i++) {
  5731. /* Récup des A/E de rang i */
  5732. var td = document.getElementById('td'+AE+i);
  5733. var ligne = td.getElementsByTagName('table')[0].rows;
  5734. var titre = trim(td.firstChild.textContent);
  5735. // On laisse la gestion des couleurs à setChoixCouleurs:
  5736. var couleur = document.getElementById(AE+i).value;
  5737. diploGuilde[AE+i] = {
  5738. Troll:'',
  5739. Guilde:'',
  5740. titre: titre,
  5741. couleur: couleur
  5742. };
  5743. for(var j=1 ; j<ligne.length ; j++) {
  5744. var str = trim(ligne[j].cells[0].textContent);
  5745. var idx = str.lastIndexOf('(');
  5746. var num = str.slice(idx+1,-1);
  5747. var type = trim(ligne[j].cells[1].textContent);
  5748. diploGuilde[AE+i][type] += num+';';
  5749. }
  5750. }
  5751. }
  5752. } catch(e) {
  5753. window.console.error('[Diplomatie] Échec de récupération de la diplo\n'+e);
  5754. return false;
  5755. }
  5756. return true;
  5757. }
  5758.  
  5759.  
  5760. /*-[functions]--------------------- Handlers ---------------------------------*/
  5761.  
  5762. function toggleDetails() {
  5763. isDetailOn = !isDetailOn;
  5764. for(var AE in {Amis:0,Ennemis:0}) {
  5765. document.getElementById('spanAll'+AE).style.display =
  5766. (isDetailOn?'none':'');
  5767. for(var i=0 ; i<5 ; i++) {
  5768. document.getElementById('span'+AE+i).style.display =
  5769. (isDetailOn?'':'none');
  5770. }
  5771. }
  5772. }
  5773.  
  5774. function toggleMythiques() {
  5775. isMythiquesOn = !isMythiquesOn;
  5776. document.getElementById('spanMythiques').style.display =
  5777. (isMythiquesOn?'':'none');
  5778. }
  5779.  
  5780. function previewCouleur() {
  5781. var value = this.value;
  5782. if(isCouleur(value)) {
  5783. this.style.backgroundColor = value;
  5784. this.title = '';
  5785. } else {
  5786. this.style.backgroundColor = '';
  5787. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  5788. }
  5789. }
  5790.  
  5791. function appendMenuType(node,duType) {
  5792. var select = document.createElement('select');
  5793. select.className = 'SelectboxV2';
  5794. var type = ['Guilde','Troll','Monstre'];
  5795. for(var i=0 ; i<3 ; i++) {
  5796. appendOption(select,type[i],type[i]);
  5797. if(type[i]==duType) { select.selectedIndex=i; }
  5798. }
  5799. node.appendChild(select);
  5800. }
  5801.  
  5802. function ajouteChamp(type,num,couleur,descr) {
  5803. var champs = document.getElementById('diploPerso');
  5804. var nb = champs.rows.length;
  5805. var tr = champs.insertRow(-1);
  5806. var td = appendTd(tr);
  5807. appendMenuType(td,type);
  5808. td = appendTd(tr);
  5809. appendText(td,' n°');
  5810. appendTextbox(td,'text','num'+nb,6,15,num);
  5811. td = appendTd(tr);
  5812. appendText(td,' couleur HTML:');
  5813. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  5814. input.onkeyup = previewCouleur;
  5815. input.onchange = previewCouleur;
  5816. input.onkeyup();
  5817. td = appendTd(tr);
  5818. appendText(td,' Description:');
  5819. appendTextbox(td,'text','descr'+nb,30,150,descr);
  5820. td = appendTd(tr);
  5821. var span = document.createElement('span');
  5822. appendText(span,'[ok!]',true);
  5823. span.style.visibility = 'hidden';
  5824. td.appendChild(span);
  5825. td = appendTd(tr);
  5826. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  5827. }
  5828.  
  5829. function retireCeChamp() {
  5830. var thisTr = this.parentNode.parentNode;
  5831. thisTr.parentNode.removeChild(thisTr);
  5832. var champs = document.getElementById('diploPerso');
  5833. if(champs.rows.length==0) { ajouteChamp(); }
  5834. }
  5835.  
  5836. function valideChamp(champ) {
  5837. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  5838. isCouleur(champ.cells[2].childNodes[1].value);
  5839. if(isValide) {
  5840. champ.cells[4].firstChild.style.visibility = 'visible';
  5841. } else {
  5842. champ.cells[4].firstChild.style.visibility = 'hidden';
  5843. }
  5844. return isValide;
  5845. }
  5846.  
  5847. function sauvegarderTout() {
  5848. /* Diplo de guilde */
  5849. diploGuilde.isOn =
  5850. document.getElementById('isGuildeOn').checked?'true':'false';
  5851. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  5852. var numGuilde = Number(document.getElementById('numGuilde').value);
  5853. var couleur = document.getElementById('couleurGuilde').value;
  5854. if(numGuilde) {
  5855. diploGuilde.guilde = {
  5856. id: numGuilde,
  5857. couleur: couleur
  5858. };
  5859. } else {
  5860. delete diploGuilde.guilde;
  5861. }
  5862. for(var AE in {Amis:0,Ennemis:0}) {
  5863. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  5864. for(var i=0 ; i<5 ; i++) {
  5865. if(isDetailOn) {
  5866. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  5867. } else {
  5868. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  5869. }
  5870. }
  5871. }
  5872. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  5873. /* Diplo personnelle (ex-fonction saveChamps) */
  5874. var champs = document.getElementById('diploPerso');
  5875. diploPerso = {
  5876. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  5877. Guilde: {},
  5878. Troll: {},
  5879. Monstre: {}
  5880. };
  5881. if(isMythiquesOn &&
  5882. isCouleur(document.getElementById('couleurMythiques').value)) {
  5883. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  5884. }
  5885. for(var i=0 ; i<champs.rows.length ; i++) {
  5886. if(valideChamp(champs.rows[i])) {
  5887. var type = champs.rows[i].cells[0].firstChild.value;
  5888. var num = champs.rows[i].cells[1].childNodes[1].value;
  5889. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  5890. var descr = champs.rows[i].cells[3].childNodes[1].value;
  5891. diploPerso[type][num] = {
  5892. couleur: couleur
  5893. };
  5894. if(descr) {
  5895. diploPerso[type][num].titre = descr;
  5896. }
  5897. }
  5898. }
  5899. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  5900.  
  5901. avertissement('Données sauvegardées');
  5902. }
  5903.  
  5904.  
  5905. /*-[functions]------------- Modifications de la page -------------------------*/
  5906.  
  5907. function creeTablePrincipale() {
  5908. var insertPt = document.getElementById('insertPt');
  5909. /* Titre + bouton de Sauvegarde */
  5910. var tr = insertTr(insertPt,'mh_tdtitre');
  5911. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  5912. appendButton(td,'Sauvegarder',sauvegarderTout);
  5913. /* Options fixes */
  5914. tr = insertTr(insertPt,'mh_tdpage');
  5915. td = appendTdText(tr,'Diplomatie de guilde:',true);
  5916. appendBr(td);
  5917. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  5918. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  5919. appendBr(td);
  5920. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  5921. appendText(td,'Utiliser des couleurs détaillées (10)');
  5922. /* Diplo personnelle */
  5923. tr = insertTr(insertPt,'mh_tdpage');
  5924. td = appendTdText(tr,'Diplomatie personnelle:',true);
  5925. appendBr(td);
  5926. // Diplo Mythiques
  5927. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  5928. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  5929. var span = document.createElement('span');
  5930. span.id = 'spanMythiques';
  5931. if(!isMythiquesOn) {
  5932. span.style.display = 'none';
  5933. }
  5934. var couleur = '#FFAAAA';
  5935. if(diploPerso.mythiques) {
  5936. couleur = diploPerso.mythiques;
  5937. }
  5938. appendText(span,' - couleur HTML:');
  5939. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  5940. input.onkeyup = previewCouleur;
  5941. input.onchange = previewCouleur;
  5942. input.onkeyup();
  5943. td.appendChild(span);
  5944. appendBr(td);
  5945. // Diplo éditable
  5946. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  5947. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  5948. appendBr(td);
  5949. var table = document.createElement('table');
  5950. table.id = 'diploPerso'
  5951. td.appendChild(table);
  5952. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  5953. for(var num in diploPerso[type]) {
  5954. ajouteChamp(
  5955. type,
  5956. num,
  5957. diploPerso[type][num].couleur,
  5958. diploPerso[type][num].titre
  5959. );
  5960. }
  5961. }
  5962. if(table.rows.length==0) {
  5963. ajouteChamp();
  5964. }
  5965. appendButton(td,'Ajouter',ajouteChamp)
  5966. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  5967. appendText(td,' ');
  5968. appendButton(td,
  5969. 'Exemples de couleur',
  5970. function() {
  5971. var fenetre = window.open(
  5972. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  5973. 'Divers',
  5974. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  5975. 'status=0,menubar=0,resizable=1,scrollbars=1'
  5976. );
  5977. fenetre.focus();
  5978. }
  5979. );
  5980. /* Couleur de Guilde */
  5981. tr = insertTr(insertPt,'mh_tdtitre');
  5982. td = appendTdText(tr,'GUILDE',true);
  5983. appendText(td,' - n°');
  5984. appendTextbox(td,'text','numGuilde',5,10,
  5985. diploGuilde.guilde && diploGuilde.guilde.id ?
  5986. diploGuilde.guilde.id : ''
  5987. );
  5988. appendText(td,' - Couleur HTML: ');
  5989. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  5990. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  5991. diploGuilde.guilde.couleur : '#BBBBFF'
  5992. );
  5993. input.onkeyup = previewCouleur;
  5994. input.onchange = previewCouleur;
  5995. input.onkeyup();
  5996. }
  5997.  
  5998.  
  5999. /*-[functions]----------------------- Main -----------------------------------*/
  6000.  
  6001. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6002. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6003. var isDetailOn = diploGuilde.isDetailOn=='true';
  6004. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6005. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6006. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6007.  
  6008. function do_diplo() {
  6009. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6010. creeTablePrincipale();
  6011. }
  6012. }
  6013.  
  6014. /*******************************************************************************
  6015. * This file is part of Mountyzilla. *
  6016. * *
  6017. * Mountyzilla is free software; you can redistribute it and/or modify *
  6018. * it under the terms of the GNU General Public License as published by *
  6019. * the Free Software Foundation; either version 2 of the License, or *
  6020. * (at your option) any later version. *
  6021. * *
  6022. * Mountyzilla is distributed in the hope that it will be useful, *
  6023. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6024. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6025. * GNU General Public License for more details. *
  6026. * *
  6027. * You should have received a copy of the GNU General Public License *
  6028. * along with Mountyzilla; if not, write to the Free Software *
  6029. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6030. *******************************************************************************/
  6031.  
  6032. // x~x cdmcomp
  6033.  
  6034. var cdm = '';
  6035.  
  6036. function getNonNegInts(str) {
  6037. var nbrs = str.match(/\d+/g);
  6038. for(var i=0 ; i<nbrs.length ; i++) {
  6039. nbrs[i] = Number(nbrs[i]);
  6040. }
  6041. return nbrs;
  6042. }
  6043.  
  6044. function traiteCdM() {
  6045. try {
  6046. var msgEffet = document.getElementById('msgEffet');
  6047. } catch(e) {
  6048. window.console.log('[traiteCdM] msgEffet non trouvé');
  6049. return;
  6050. }
  6051.  
  6052. // Teste si ce message du bot est un message de CdM
  6053. if(!document.evaluate(
  6054. "./p/b/text()[contains(.,'fait partie')]",
  6055. msgEffet, null, 9, null
  6056. ).singleNodeValue) {
  6057. return;
  6058. }
  6059. // Début de récupération de la CdM
  6060. cdm = document.evaluate(
  6061. "./p/b/text()[contains(.,'fait partie')]",
  6062. msgEffet, null, 9, null
  6063. ).singleNodeValue.nodeValue+'\n';
  6064. var tbody = document.evaluate(
  6065. "descendant::table/tbody",
  6066. msgEffet, null, 9, null
  6067. ).singleNodeValue;
  6068. var nomStat = document.evaluate(
  6069. "./tr/td[1]/b/text()",
  6070. tbody, null, 7, null
  6071. );
  6072. var valStat = document.evaluate(
  6073. "./tr/td[2]/descendant::text()",
  6074. tbody, null, 7, null
  6075. );
  6076. var i=0;
  6077. while(i<nomStat.snapshotLength) {
  6078. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  6079. cdm += 'Armure : ';
  6080. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  6081. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  6082. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  6083. armp = [0,armp[0]];
  6084. }
  6085. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  6086. armm = [0,armm[0]];
  6087. }
  6088. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  6089. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  6090. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  6091. } else {
  6092. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6093. }
  6094. cdm += ')\n';
  6095. i++;
  6096. } else {
  6097. cdm += nomStat.snapshotItem(i).nodeValue+
  6098. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  6099. }
  6100. i++;
  6101. }
  6102. // Envoi auto ou insertion bouton envoi (suivant option)
  6103. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  6104. sendInfoCDM();
  6105. var p = document.createElement('p');
  6106. p.style.color = 'green';
  6107. appendText(p,'CdM envoyée vers la base MountyZilla !');
  6108. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  6109. } else {
  6110. insertButtonCdm('as_Action', sendInfoCDM);
  6111. }
  6112.  
  6113. // Insertion de l'estimation des PV restants
  6114. var pv = valStat.snapshotItem(1).nodeValue;
  6115. if(pv.indexOf("entre")==-1) {
  6116. return;
  6117. }
  6118. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  6119. if(pv) {
  6120. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  6121. appendTdText(tr, pv[0], true);
  6122. appendTdText(tr, pv[1], true);
  6123. }
  6124. }
  6125.  
  6126. function sendInfoCDM() {
  6127. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  6128. var buttonCDM = this;
  6129. var texte = '';
  6130. FF_XMLHttpRequest({
  6131. method: 'GET',
  6132. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6133. headers : {
  6134. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6135. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6136. },
  6137. onload: function(responseDetails) {
  6138. texte = responseDetails.responseText;
  6139. buttonCDM.value = texte;
  6140. buttonCDM.disabled = true;
  6141. }
  6142. });
  6143. }
  6144.  
  6145. function do_cdmcomp() {
  6146. start_script(31);
  6147. traiteCdM();
  6148. displayScriptTime();
  6149. }
  6150.  
  6151. /*********************************************************************************
  6152. * This file is part of Mountyzilla. *
  6153. * *
  6154. * Mountyzilla is free software; you can redistribute it and/or modify *
  6155. * it under the terms of the GNU General Public License as published by *
  6156. * the Free Software Foundation; either version 2 of the License, or *
  6157. * (at your option) any later version. *
  6158. * *
  6159. * Mountyzilla is distributed in the hope that it will be useful, *
  6160. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6161. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6162. * GNU General Public License for more details. *
  6163. * *
  6164. * You should have received a copy of the GNU General Public License *
  6165. * along with Mountyzilla; if not, write to the Free Software *
  6166. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6167. *********************************************************************************/
  6168.  
  6169. // x~x cmdbot
  6170.  
  6171. /* v0.2 by Dab - 2013-08-20
  6172. * - patch dégueu pour gérer la décomposition P/M de l'armure
  6173. */
  6174.  
  6175. var buttonCDM;
  6176.  
  6177. /*******************************************************************************************
  6178. CDM :
  6179. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  6180.  
  6181. Il ne vous est pas possible d'améliorer cette compétence.
  6182.  
  6183. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  6184. Niveau : Inimaginable (entre 49 et 51)
  6185. Points de Vie : Surtrollesque (entre 450 et 470)
  6186. Blessure (Approximatif) : 0 %
  6187. Dés d'Attaque : Impressionnant (entre 30 et 32)
  6188. Dés d'Esquive : Impressionnant (entre 28 et 30)
  6189. Dés de Dégat : Très Fort (entre 18 et 20)
  6190. Dés de Régénération : Excellent (égal à 13)
  6191. Armure Physique : Moyen (entre 10 et 12)
  6192. Armure Magique : Faible (inférieur à 6)
  6193. Vue : Moyen (entre 9 et 11)
  6194. Maitrise Magique : Inimaginable (supérieur à 6000)
  6195. Résistance Magique : Inimaginable (supérieur à 6000)
  6196. Nombre d'attaques : 1
  6197. Vitesse de Déplacement : Normale
  6198. Voir le Caché : Oui
  6199. Attaque à distance : Non
  6200. Attaque magique : Oui
  6201. Vole : Non
  6202. Sang froid : Inexistant
  6203. DLA : Milieu
  6204. Durée Tour : Remarquable (entre 9 et 11)
  6205. Chargement : Vide
  6206. Bonus Malus : Aucun
  6207.  
  6208. Vous avez également gagné 1 PX pour la réussite.
  6209. *******************************************************************************************
  6210. BOT :
  6211. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  6212.  
  6213. Le Monstre ciblé fait partie des : Mort-Vivant
  6214.  
  6215. Niveau : Incroyable (entre 36 et 38)
  6216. *******************************************************************************************/
  6217.  
  6218. function getNNInt(str) {
  6219. var nbrs = str.match(/\d+/g);
  6220. for (var i=0 ; i<nbrs.length ; i++)
  6221. nbrs[i] = parseInt(nbrs[i]);
  6222. return nbrs;
  6223. }
  6224.  
  6225. function sendCDM() {
  6226. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6227. document, null, 9, null).singleNodeValue;
  6228. cdm = td.innerHTML;
  6229. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  6230. "$3$4 ($1 - N°$2)<br>");
  6231. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  6232. 'Blessure : XX % (approximativement)');
  6233. // Supprime la décomposition P/M de l'Armure
  6234. var bgn = cdm.indexOf('Armure Physique');
  6235. if (bgn!=-1) {
  6236. var end = cdm.indexOf('Vue')-2;
  6237. var lines = cdm.substring(bgn,end).split('<br>');
  6238. var armp = getNNInt(lines[0]);
  6239. var armm = getNNInt(lines[1]);
  6240. if (lines[0].indexOf('(inf')!=-1)
  6241. armp = [0,armp[0]];
  6242. if (lines[1].indexOf('(inf')!=-1)
  6243. armm = [0,armm[0]];
  6244. var insrt = 'Armure : ';
  6245. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  6246. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  6247. else
  6248. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6249. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  6250. }
  6251. cdm = cdm.replace(/<br>/g,'\n');
  6252. FF_XMLHttpRequest({
  6253. method: 'GET',
  6254. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6255. headers : {
  6256. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6257. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6258. },
  6259. onload: function(responseDetails) {
  6260. buttonCDM.value=responseDetails.responseText;
  6261. buttonCDM.disabled = true;
  6262. }
  6263. });
  6264. }
  6265.  
  6266. function traiteCdM() {
  6267. // Teste si ce message du bot est un message de CdM
  6268. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6269. document, null, 9, null).singleNodeValue;
  6270. if (!td) return false;
  6271. cdm = td.innerHTML;
  6272. // Insertion de l'estimation des PV restants
  6273. var des = cdm.indexOf('Dés');
  6274. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  6275. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  6276. if(pv)
  6277. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  6278.  
  6279. // Insertion bouton envoi + espace
  6280. buttonCDM = insertButtonCdm('bClose',sendCDM);
  6281. }
  6282.  
  6283. /*function traitePouvoir() {
  6284. // Teste si ce message du bot est un message de CdM
  6285. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  6286. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  6287. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6288. if (!td)
  6289. return false;
  6290. var infos = td.innerHTML;
  6291. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  6292. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  6293. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  6294. var date = /alors : ([^<]+)\./.exec(infos)[1];
  6295. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  6296. var effetPouvoir="";
  6297. var full=false;
  6298. if(infos.indexOf("REDUIT")!=-1) {
  6299. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  6300. }
  6301. else {
  6302. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  6303. full=true;
  6304. }
  6305. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  6306. // On insère le bouton et un espace
  6307. //var url = pageEffetDispatcher + "?pouv="+escape(nomPouvoir)+"&monstre="+escape(nomMonstre)+"&id="+escape(id)+"&effet="+escape(effetPouvoir)+"&duree="+escape(dureePouvoir)+"&date="+escape(Math.round(date.getTime()/1000));
  6308. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  6309. if(!MY_getValue('AUTOSENDPOUV'))
  6310. {
  6311. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  6312. button.setAttribute("onClick", "window.open('" + url
  6313. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  6314. + "this.value='Merci de votre participation'; this.disabled = true;");
  6315. }
  6316. else
  6317. {
  6318. FF_XMLHttpRequest({
  6319. method: 'GET',
  6320. url: url,
  6321. headers : {
  6322. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6323. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6324. }});
  6325. }
  6326. }*/
  6327.  
  6328. traiteCdM();
  6329. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  6330.  
  6331. /*******************************************************************************
  6332. * This file is part of Mountyzilla. *
  6333. * *
  6334. * Mountyzilla is free software; you can redistribute it and/or modify *
  6335. * it under the terms of the GNU General Public License as published by *
  6336. * the Free Software Foundation; either version 2 of the License, or *
  6337. * (at your option) any later version. *
  6338. * *
  6339. * Mountyzilla is distributed in the hope that it will be useful, *
  6340. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6341. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6342. * GNU General Public License for more details. *
  6343. * *
  6344. * You should have received a copy of the GNU General Public License *
  6345. * along with Mountyzilla; if not, write to the Free Software *
  6346. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6347. *******************************************************************************/
  6348.  
  6349. // x~x menu
  6350. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  6351.  
  6352. var menuRac, mainIco;
  6353.  
  6354. function updateData() {
  6355. var inputs = document.getElementsByTagName('input');
  6356. var divs = document.getElementsByTagName('div');
  6357. numTroll = inputs[0].value;
  6358. MY_setValue('NUM_TROLL', numTroll);
  6359. MY_setValue('NIV_TROLL',inputs[1].value);
  6360. if(!MY_getValue(numTroll+'.caracs.rm')) {
  6361. MY_setValue(numTroll+'.caracs.rm',0);
  6362. // assure l'init des 4 var de libs
  6363. }
  6364. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  6365. var DLA = new Date(
  6366. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  6367. );
  6368. if(MY_getValue(numTroll+'.DLA.encours')) {
  6369. var DLAstockee = new Date(
  6370. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  6371. );
  6372. if(DLA>DLAstockee) {
  6373. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  6374. // Pose un pb en cas de décalage de DLA
  6375. }
  6376. }
  6377. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  6378. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  6379. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  6380. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  6381. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  6382. }
  6383.  
  6384. function initRaccourcis() {
  6385. var anotherURL = MY_getValue('URL1');
  6386. if(!anotherURL) { return; }
  6387. /* Création de l'icône faisant apparaître le menu */
  6388. mainIco = document.createElement('img');
  6389. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  6390. if(!urlIco) {
  6391. urlIco =
  6392. URL_MZimg09 + 'MY_logo_small.png';
  6393. }
  6394. mainIco.src = urlIco;
  6395. mainIco.alt = 'MZ';
  6396. mainIco.style = 'position:fixed; top:0px; left:0px';
  6397. mainIco.onmouseover = afficheMenu;
  6398. document.body.appendChild(mainIco);
  6399. /* Création du menu des Raccourcis */
  6400. menuRac = document.createElement('div');
  6401. menuRac.className = 'mh_textbox';
  6402. menuRac.style =
  6403. 'position:fixed; top:10px; left:10px;'+
  6404. 'max-width:190px;'+
  6405. 'border-radius: 4px; padding: 4px;'+
  6406. 'z-index: 500;'+
  6407. 'visibility: hidden;';
  6408. document.body.appendChild(menuRac);
  6409. document.addEventListener('mousemove',cacheMenu,false);
  6410. var i=1;
  6411. while(anotherURL) {
  6412. var a = document.createElement('a');
  6413. var url = MY_getValue('URL'+i);
  6414. var nom = MY_getValue('URL'+i+'.nom');
  6415. var ico = MY_getValue('URL'+i+'.ico');
  6416. a.href = url;
  6417. a.target = '_blank';
  6418. if(ico) {
  6419. var txt = nom ? nom : '';
  6420. var img = createImage(ico,txt);
  6421. a.appendChild(img);
  6422. }
  6423. else {
  6424. appendText(a,'['+nom+']');
  6425. }
  6426. menuRac.appendChild(a);
  6427. appendBr(menuRac);
  6428. i++;
  6429. anotherURL = MY_getValue('URL'+i);
  6430. }
  6431. }
  6432.  
  6433. function afficheMenu() {
  6434. menuRac.style.visibility = 'visible';
  6435. }
  6436.  
  6437. function cacheMenu(e) {
  6438. if(menuRac.style.visibility=='hidden') { return; }
  6439. // Position souris
  6440. var ptX = e.clientX;
  6441. var ptY = e.clientY;
  6442. // On recalcule en live les BoundingBox pour mainIco et menuRac
  6443. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  6444. var menuRect = menuRac.getBoundingClientRect();
  6445. var icoRect = mainIco.getBoundingClientRect();
  6446. if((ptX>icoRect.width || ptY>icoRect.height) &&
  6447. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  6448. menuRac.style.visibility = 'hidden';
  6449. }
  6450. }
  6451.  
  6452. function oldSchoolProfile() {
  6453. try {
  6454. var lienProfil = document.getElementById("Image1").parentNode;
  6455. lienProfil.href = "Play_profil.php";
  6456. } catch(e) {
  6457. avertissement();
  6458. window.console.log("[MZ menu] Lien vers le profil non trouvé",e);
  6459. }
  6460. }
  6461.  
  6462. function do_menu() {
  6463. updateData();
  6464. initRaccourcis();
  6465. if(MY_getValue(numTroll+".OLDSCHOOL")=="true") {
  6466. oldSchoolProfile();
  6467. }
  6468. }
  6469.  
  6470. /*******************************************************************************
  6471. * This file is part of Mountyzilla. *
  6472. * *
  6473. * Mountyzilla is free software; you can redistribute it and/or modify *
  6474. * it under the terms of the GNU General Public License as published by *
  6475. * the Free Software Foundation; either version 2 of the License, or *
  6476. * (at your option) any later version. *
  6477. * *
  6478. * Mountyzilla is distributed in the hope that it will be useful, *
  6479. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6480. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6481. * GNU General Public License for more details. *
  6482. * *
  6483. * You should have received a copy of the GNU General Public License *
  6484. * along with Mountyzilla; if not, write to the Free Software *
  6485. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6486. *******************************************************************************/
  6487.  
  6488. // x~x vue
  6489.  
  6490. /* TODO
  6491. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  6492. * prévoir fix ("delete infos")
  6493. */
  6494.  
  6495. /*--------------------------- Variables Globales -----------------------------*/
  6496.  
  6497. // Infos remplies par des scripts extérieurs
  6498. var listeCDM = [], listeLevels = [];
  6499.  
  6500. // Position actuelle
  6501. var currentPosition=[0,0,0];
  6502.  
  6503. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  6504. var porteeVue=[0,0,0,0];
  6505.  
  6506. // Fenêtres déplaçables
  6507. var winCurr = null;
  6508. var offsetX, offsetY;
  6509. document.onmousemove = drag;
  6510.  
  6511. // Diplomatie
  6512. var Diplo = {
  6513. Guilde: {},
  6514. Troll: {},
  6515. Monstre: {}
  6516. // .mythiques: uniquement si option activée
  6517. };
  6518. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  6519.  
  6520. // Infos tactiques
  6521. var popup;
  6522.  
  6523. // Gère l'affichage en cascade des popups de CdM
  6524. var nbCDM = 0;
  6525.  
  6526. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  6527.  
  6528. // Utilisé pour supprimer les monstres "engagés"
  6529. var listeEngages = {};
  6530. var isEngagesComputed = false;
  6531. var cursorOnLink = false; // DEBUG: wtf ?
  6532.  
  6533. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  6534. && MY_getValue(numTroll+'.enchantement.liste')!='';
  6535.  
  6536. // Checkboxes de filtrage
  6537. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  6538. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  6539. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  6540. comboBoxNiveauMin, comboBoxNiveauMax;
  6541.  
  6542. /* Acquisition & Stockage des données de DB */
  6543. const typesAFetcher = {
  6544. 'monstres':1,
  6545. 'trolls':1,
  6546. 'tresors':1,
  6547. 'champignons':1,
  6548. 'lieux':1
  6549. }
  6550. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  6551. tr_champignons = {}, tr_lieux = {};
  6552. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  6553. nbChampignons = 0, nbLieux = 0;
  6554.  
  6555. function fetchData(type) {
  6556. try {
  6557. var node = document.getElementById('mh_vue_hidden_'+type);
  6558. // this = MZ.global = sandBox de travail de MZ
  6559. // On définit donc des variables MZ-globales
  6560. this['tr_'+type] = node.getElementsByTagName('tr');
  6561. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  6562. } catch(e) {
  6563. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  6564. }
  6565. }
  6566.  
  6567.  
  6568. /*---------------------------------- DEBUG -----------------------------------*/
  6569. var mainTabs = document.getElementsByClassName('mh_tdborder');
  6570. var x_monstres = tr_monstres;
  6571. var x_trolls = tr_trolls;
  6572. var x_tresors = tr_tresors;
  6573. var x_champis = tr_champignons;
  6574. var x_lieux = tr_lieux;
  6575. /*-------------------------------- FIN DEBUG ---------------------------------*/
  6576.  
  6577.  
  6578. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6579.  
  6580. function positionToString(arr) {
  6581. return arr.join(';');
  6582. }
  6583.  
  6584. function savePosition() {
  6585. // Stocke la position (à jour) de la vue pour les autres scripts
  6586. // DEBUG: Lesquels et pourquoi?
  6587. var pos = getPosition();
  6588. MY_setValue(numTroll+'.position.X',pos[0]);
  6589. MY_setValue(numTroll+'.position.Y',pos[1]);
  6590. MY_setValue(numTroll+'.position.N',pos[2]);
  6591. }
  6592.  
  6593.  
  6594. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  6595. /* INFOS :
  6596. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  6597. * sont identifiables via leur Name
  6598. * les tables-listings sont identifiables via l'ID du tr conteneur
  6599. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  6600. */
  6601.  
  6602. /* [functions] Récup données Utilisateur */
  6603. function getPosition() {
  6604. // Pour rétrocompatibilité
  6605. return currentPosition;
  6606. }
  6607.  
  6608. function getPorteVue() {
  6609. // Pour rétrocompatibilité
  6610. return porteeVue;
  6611. }
  6612.  
  6613. function getVue() {
  6614. // Retourne [vueHpure, vueVpure]
  6615. var vues = getPorteVue();
  6616. return [ vues[0], vues[1] ];
  6617. }
  6618.  
  6619. // Roule 11/03/2016
  6620. /* [functions] Récup données monstres, trolls, etc. */
  6621. function getXxxDistance(xxx, i) {
  6622. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  6623. }
  6624. function getXxxPosition(xxx, i) {
  6625. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  6626. var l = tds.length;
  6627. return [
  6628. parseInt(tds[l-3].textContent),
  6629. parseInt(tds[l-2].textContent),
  6630. parseInt(tds[l-1].textContent)
  6631. ];
  6632. }
  6633.  
  6634.  
  6635. /* [functions] Récup données monstres */
  6636. function getMonstreDistance(i) {
  6637. return parseInt(tr_monstres[i].cells[0].textContent);
  6638. }
  6639.  
  6640. function getMonstreID(i) {
  6641. return tr_monstres[i].cells[2].firstChild.nodeValue;
  6642. }
  6643.  
  6644. function getMonstreIDByTR(tr) {
  6645. return tr.cells[2].firstChild.nodeValue;
  6646. }
  6647.  
  6648. function getMonstreLevelNode(i) {
  6649. return tr_monstres[i].cells[3];
  6650. }
  6651.  
  6652. function getMonstreLevel(i) {
  6653. if(!isCDMsRetrieved) return -1;
  6654. var donneesMonstre = listeCDM[getMonstreID(i)];
  6655. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  6656. }
  6657.  
  6658. function getMonstreNomNode(i) {
  6659. try {
  6660. var td = document.evaluate(
  6661. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  6662. tr_monstres[i], null, 9, null
  6663. ).singleNodeValue;
  6664. return td;
  6665. } catch(e) {
  6666. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  6667. window.console.error(e);
  6668. }
  6669. }
  6670.  
  6671. function getMonstreNom(i) {
  6672. return getMonstreNomByTR(tr_monstres[i]);
  6673. }
  6674.  
  6675. function getMonstreNomByTR(tr) {
  6676. try {
  6677. var nom = document.evaluate(
  6678. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  6679. tr, null, 2, null
  6680. ).stringValue;
  6681. return nom;
  6682. } catch(e) {
  6683. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  6684. window.console.error(e);
  6685. }
  6686. }
  6687.  
  6688. function getMonstrePosition(i) {
  6689. var tds = tr_monstres[i].childNodes;
  6690. var l = tds.length;
  6691. return [
  6692. parseInt(tds[l-3].textContent),
  6693. parseInt(tds[l-2].textContent),
  6694. parseInt(tds[l-1].textContent)
  6695. ];
  6696. }
  6697.  
  6698. function appendMonstres(txt) {
  6699. for(var i=1; i<=nbMonstres ; i++)
  6700. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  6701. return txt;
  6702. }
  6703.  
  6704. function getMonstres() {
  6705. var vue = getVue();
  6706. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  6707. }
  6708.  
  6709. function bddMonstres(start,stop) {
  6710. if(!start) { var start = 1; }
  6711. if(!stop) { var stop = nbMonstres; }
  6712. stop = Math.min(nbMonstres,stop);
  6713. var txt='';
  6714. for(var i=start ; i<=stop ; i++) {
  6715. txt += getMonstreID(i)+';'+
  6716. getMonstreNom(i)+';'+
  6717. positionToString(getMonstrePosition(i))+'\n';
  6718. }
  6719. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  6720. }
  6721.  
  6722. /* [functions] Récup données Trolls */
  6723. function getTrollDistance(i) {
  6724. return parseInt(tr_trolls[i].cells[0].textContent);
  6725. }
  6726.  
  6727. function getTrollID(i) {
  6728. return parseInt(tr_trolls[i].cells[2].textContent);
  6729. }
  6730.  
  6731. function getTrollNomNode(i) {
  6732. var isEnvoiOn =
  6733. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  6734. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  6735. }
  6736.  
  6737. function getTrollNivNode(i) {
  6738. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  6739. return tr_trolls[i].cells[4];
  6740. }
  6741.  
  6742. function getTrollGuilde(i) {
  6743. return trim(tr_trolls[i].cells[6].textContent);
  6744. }
  6745.  
  6746. function getTrollGuildeID(i) {
  6747. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  6748. var href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  6749. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  6750. }
  6751. return -1;
  6752. }
  6753.  
  6754. function getTrollPosition(i) {
  6755. var tds = tr_trolls[i].childNodes;
  6756. var l = tds.length;
  6757. return [
  6758. parseInt(tds[l-3].textContent),
  6759. parseInt(tds[l-2].textContent),
  6760. parseInt(tds[l-1].textContent)
  6761. ];
  6762. }
  6763.  
  6764. function bddTrolls() {
  6765. var txt='#DEBUT TROLLS\n'+
  6766. numTroll+';'+positionToString(getPosition())+'\n';
  6767. for(var i=1 ; i<=nbTrolls ; i++) {
  6768. txt += getTrollID(i)+';'+
  6769. positionToString(getTrollPosition(i))+'\n';
  6770. }
  6771. return txt+'#FIN TROLLS';
  6772. }
  6773.  
  6774. /* [functions] Récup données Trésors */
  6775. function getTresorDistance(i) {
  6776. return tr_tresors[i].cells[0].firstChild.nodeValue;
  6777. }
  6778.  
  6779. function getTresorID(i) {
  6780. return trim(tr_tresors[i].cells[2].textContent);
  6781. }
  6782.  
  6783. function getTresorNom(i) {
  6784. // Utilisation de textContent pour régler le "bug de Pollux"
  6785. return trim(tr_tresors[i].cells[3].textContent);
  6786. }
  6787.  
  6788. function getTresorPosition(i) {
  6789. var tds = tr_tresors[i].childNodes;
  6790. var l = tds.length;
  6791. return [
  6792. parseInt(tds[l-3].textContent),
  6793. parseInt(tds[l-2].textContent),
  6794. parseInt(tds[l-1].textContent),
  6795. ];
  6796. }
  6797.  
  6798. function bddTresors(dmin,start,stop) {
  6799. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  6800. if(!dmin) { var dmin = 0; }
  6801. if(!start) { var start = 1; }
  6802. if(!stop) { var stop = nbTresors; }
  6803. stop = Math.min(nbTresors,stop);
  6804. var txt='';
  6805. for(var i=start ; i<=stop ; i++) {
  6806. if(getTresorDistance(i)>=dmin) {
  6807. txt += getTresorID(i)+';'+
  6808. getTresorNom(i)+';'+
  6809. positionToString(getTresorPosition(i))+'\n';
  6810. }
  6811. }
  6812. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  6813. }
  6814.  
  6815. /* [functions] Récup données Champignons */
  6816. // DEBUG: Pas de colonne "Référence" sur serveur de test
  6817. function getChampignonNom(i) {
  6818. return trim(tr_champignons[i].cells[2].textContent);
  6819. }
  6820.  
  6821. function getChampignonPosition(i) {
  6822. var tds = tr_champignons[i].childNodes;
  6823. var l = tds.length;
  6824. return [
  6825. parseInt(tds[l-3].textContent),
  6826. parseInt(tds[l-2].textContent),
  6827. parseInt(tds[l-1].textContent)
  6828. ];
  6829. }
  6830.  
  6831. function bddChampignons() {
  6832. var txt='';
  6833. for(var i=1 ; i<=nbChampignons ; i++) {
  6834. txt += ';'+ // Les champis n'ont pas de Référence
  6835. getChampignonNom(i)+';'+
  6836. positionToString(getChampignonPosition(i))+'\n';
  6837. }
  6838. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  6839. }
  6840.  
  6841. /* [functions] Récup données Lieux */
  6842. function getLieuDistance(i) {
  6843. return parseInt(tr_lieux[i].cells[0].textContent);
  6844. }
  6845.  
  6846. function getLieuID(i) {
  6847. return parseInt(tr_lieux[i].cells[2].textContent);
  6848. }
  6849.  
  6850. function getLieuNom(i) {
  6851. // Conversion ASCII pour éviter les bugs des Vues externes
  6852. return trim(tr_lieux[i].cells[3].textContent);
  6853. }
  6854.  
  6855. function getLieuPosition(i) {
  6856. var tds = tr_lieux[i].childNodes;
  6857. var l = tds.length;
  6858. return [
  6859. parseInt(tds[l-3].textContent),
  6860. parseInt(tds[l-2].textContent),
  6861. parseInt(tds[l-1].textContent)
  6862. ];
  6863. }
  6864.  
  6865. function appendLieux(txt) {
  6866. for(var i = 1; i < nbLieux+1; i++) {
  6867. var tds = x_lieux[i].childNodes;
  6868. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  6869. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  6870. }
  6871. return txt;
  6872. }
  6873.  
  6874. function getLieux() {
  6875. var vue = getVue();
  6876. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  6877. }
  6878.  
  6879. function bddLieux(start,stop) {
  6880. if(!start) { var start = 1; }
  6881. if(!stop) { var stop = nbLieux; }
  6882. stop = Math.min(nbLieux,stop);
  6883. var txt='';
  6884. for(var i=start ; i<=stop ; i++) {
  6885. txt += getLieuID(i)+';'+
  6886. epure(getLieuNom(i))+';'+
  6887. positionToString(getLieuPosition(i))+'\n';
  6888. }
  6889. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  6890. }
  6891.  
  6892.  
  6893. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  6894.  
  6895. function saveCheckBox(chkbo, pref) {
  6896. // Enregistre et retourne l'état d'une CheckBox
  6897. var etat = chkbo.checked;
  6898. MY_setValue(pref, etat ? 'true' : 'false' );
  6899. return etat;
  6900. }
  6901.  
  6902. function recallCheckBox(chkbox, pref) {
  6903. // Restitue l'état d'une CheckBox
  6904. chkbox.checked = (MY_getValue(pref)=='true');
  6905. }
  6906.  
  6907. function saveComboBox(cbb, pref) {
  6908. // Enregistre et retourne l'état d'une ComboBox
  6909. var etat = cbb.selectedIndex;
  6910. MY_setValue(pref, etat);
  6911. return etat;
  6912. }
  6913.  
  6914. function recallComboBox(cbb, pref) {
  6915. // Restitue l'état d'une ComboBox
  6916. var nb = MY_getValue(pref);
  6917. if(nb) cbb.value = nb;
  6918. return nb;
  6919. }
  6920.  
  6921. function synchroniseFiltres() {
  6922. // Récupération de toutes les options de la vue
  6923. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  6924. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  6925. if(numBool) {
  6926. debutFiltrage('Monstres');
  6927. }
  6928. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  6929. recallCheckBox(checkBoxMythiques,'NOMYTH');
  6930. recallCheckBox(checkBoxEngages,'NOENGAGE');
  6931. recallCheckBox(checkBoxLevels,'NOLEVEL');
  6932. recallCheckBox(checkBoxIntangibles,'NOINT');
  6933. recallCheckBox(checkBoxGG,'NOGG');
  6934. recallCheckBox(checkBoxCompos,'NOCOMP');
  6935. recallCheckBox(checkBoxBidouilles,'NOBID');
  6936. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  6937. recallCheckBox(checkBoxTrou,'NOTROU');
  6938. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  6939. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  6940. if(MY_getValue('NOINFOEM')!='true')
  6941. recallCheckBox(checkBoxEM,'NOEM');
  6942. }
  6943.  
  6944.  
  6945. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  6946.  
  6947. /* [functions] Menu Vue 2D */
  6948. var vue2Ddata = {
  6949. 'Bricol\' Vue': {
  6950. url: URL_MZmountyhall + 'vue_form.php',
  6951. paramid: 'vue',
  6952. func: getVueScript,
  6953. extra_params: {
  6954. 'mode': 'vue_SP_Vue2',
  6955. 'screen_width': window.screen.width
  6956. }
  6957. },
  6958. 'Vue du CCM': {
  6959. url: URL_vue_CCM,
  6960. paramid: 'vue',
  6961. func: getVueScript,
  6962. extra_params: {
  6963. 'id': numTroll+';'+positionToString(getPosition())
  6964. }
  6965. },
  6966. 'Vue Gloumfs 2D': {
  6967. url: URL_vue_Gloumfs2D,
  6968. paramid: 'vue_mountyzilla',
  6969. func: getVueScript,
  6970. extra_params: {}
  6971. },
  6972. 'Vue Gloumfs 3D': {
  6973. url: URL_vue_Gloumfs3D,
  6974. paramid: 'vue_mountyzilla',
  6975. func: getVueScript,
  6976. extra_params: {}
  6977. },
  6978. 'Grouky Vue!': {
  6979. url: URL_vue_Grouky,
  6980. paramid: 'vue',
  6981. func: getVueScript,
  6982. extra_params: {
  6983. 'type_vue': 'V5b1'
  6984. }
  6985. },
  6986. /*'DEBUG': {
  6987. url: 'http://weblocal/testeur.php',
  6988. paramid: 'vue',
  6989. func: getVueScript,
  6990. extra_params: {}
  6991. }*/
  6992. };
  6993.  
  6994. function getVueScript() {
  6995. try {
  6996. var txt = bddTrolls()+
  6997. bddMonstres()+
  6998. bddChampignons()+
  6999. bddTresors()+
  7000. bddLieux()+
  7001. '#DEBUT ORIGINE\n'+
  7002. getPorteVue()[2]+';'+positionToString(getPosition())+
  7003. '\n#FIN ORIGINE\n';
  7004. return txt;
  7005. } catch(e) {
  7006. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7007. window.console.error('[MZ getVueScript]\n',e)
  7008. }
  7009. }
  7010.  
  7011. function refresh2DViewButton() {
  7012. // = EventListener menu+bouton vue 2D
  7013. var vueext = document.getElementById('selectVue2D').value;
  7014. MY_setValue('VUEEXT',vueext);
  7015. var form = document.getElementById('viewForm');
  7016. form.innerHTML = '';
  7017. form.method = 'post';
  7018. form.action = vue2Ddata[vueext].url;
  7019. form.target = '_blank';
  7020. appendHidden(form, vue2Ddata[vueext].paramid, '');
  7021. for(var key in vue2Ddata[vueext].extra_params) {
  7022. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  7023. }
  7024. appendSubmit(form, 'Voir',
  7025. function() {
  7026. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  7027. vue2Ddata[vueext].func();
  7028. }
  7029. );
  7030. }
  7031.  
  7032. function set2DViewSystem() {
  7033. // Initialise le système de vue 2D
  7034. // Recherche du point d'insertion
  7035. try {
  7036. var center = document.evaluate(
  7037. "//h2[@id='titre2']/following-sibling::center",
  7038. document, null, 9, null
  7039. ).singleNodeValue;
  7040. } catch(e) {
  7041. avertissement("Erreur d'initialisation du système de vue 2D");
  7042. window.console.error("[MZ] set2DViewSystem",e);
  7043. return;
  7044. }
  7045. // Récupération de la dernière vue utilisée
  7046. var vueext = MY_getValue('VUEEXT');
  7047. if(!vueext || !vue2Ddata[vueext]) {
  7048. // sinon, la vue Bricol'Trolls est employée par défaut
  7049. vueext = 'Bricol\' Vue';
  7050. }
  7051. // Création du sélecteur de vue externe
  7052. selectVue2D = document.createElement('select');
  7053. selectVue2D.id = 'selectVue2D';
  7054. selectVue2D.className = 'SelectboxV2';
  7055. for(var view in vue2Ddata) {
  7056. appendOption(selectVue2D, view, view);
  7057. }
  7058. selectVue2D.value = vueext;
  7059. selectVue2D.onchange = refresh2DViewButton;
  7060. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  7061. var form = document.createElement('form');
  7062. form.id = 'viewForm';
  7063. // Insertion du système de vue
  7064. var table = document.createElement('table');
  7065. var tr = appendTr(table);
  7066. var td = appendTd(tr);
  7067. td.appendChild(selectVue2D);
  7068. td = appendTd(tr);
  7069. td.style.fontSize = '0px'; // gère le bug de l'extra character
  7070. td.appendChild(form);
  7071. center.insertBefore(table,center.firstChild);
  7072. insertBr(center.childNodes[1]);
  7073. // Appelle le handler pour initialiser le bouton de submit
  7074. refresh2DViewButton();
  7075. }
  7076.  
  7077. /* [functions] Tableau d'Infos */
  7078. function initialiseInfos() {
  7079. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  7080. var
  7081. infoTab = document.getElementsByName('LimitViewForm')[0].
  7082. getElementsByTagName('table')[0],
  7083. tbody = infoTab.tBodies[0],
  7084. thead = infoTab.createTHead(),
  7085. tr = appendTr(thead,'mh_tdtitre'),
  7086. td = appendTdText(tr,'INFORMATIONS',true),
  7087. span = document.createElement('span');
  7088. // Récupération de la position du joueur
  7089. try {
  7090. var strPos = document.evaluate(
  7091. ".//li/b/text()[contains(.,'X = ')]",
  7092. infoTab, null, 9, null
  7093. ).singleNodeValue.nodeValue;
  7094. // ***INIT GLOBALE*** currentPosition
  7095. currentPosition = getNumbers(strPos);
  7096. debugMZ("retrievePosition(): "+currentPosition);
  7097. } catch(e) {
  7098. // Si on ne trouve pas le "X ="
  7099. window.console.error("[MZ Vue] Position joueur non trouvée",e);
  7100. }
  7101. // Récupération des portées (max et limitée) de la vue
  7102. try {
  7103. var
  7104. nodes = document.evaluate(
  7105. ".//li/b/text()[contains(.,'horizontalement') "+
  7106. "or contains(.,'verticalement')]",
  7107. infoTab, null, 7, null
  7108. ),
  7109. array = [];
  7110. for(var i=0 ; i<4 ; i++) {
  7111. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  7112. }
  7113. // ***INIT GLOBALE*** porteeVue
  7114. porteeVue = array;
  7115. } catch(e) {
  7116. window.console.error("[MZ Vue] Portées Vue non trouvées",e);
  7117. }
  7118.  
  7119. infoTab.id = 'infoTab'; // Pour scripts externes
  7120. tbody.id = 'corpsInfoTab';
  7121. tbody.rows[0].cells[0].colSpan = 2;
  7122. td.colSpan = 3;
  7123. td.onmouseover = function() {
  7124. this.style.cursor = 'pointer';
  7125. this.className = 'mh_tdpage';
  7126. };
  7127. td.onmouseout = function() {
  7128. this.className = 'mh_tdtitre';
  7129. };
  7130. td.onclick = function() {
  7131. toggleTableauInfos(false);
  7132. };
  7133. span.id = 'msgInfoTab';
  7134. span.style.display = 'none';
  7135. appendText(
  7136. span,
  7137. ' => Position : X = '+currentPosition[0]+
  7138. ', Y = '+currentPosition[1]+
  7139. ', N = '+currentPosition[2]+
  7140. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  7141. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  7142. true
  7143. );
  7144. td.appendChild(span);
  7145. tr = appendTr(tbody,'mh_tdpage');
  7146. td = appendTdText(tr,'EFFACER : ',true);
  7147. td.align = 'center';
  7148. td.className = 'mh_tdtitre';
  7149. td.width = 100;
  7150. td = appendTdCenter(tr,2);
  7151. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  7152. checkBoxGG = appendCheckBoxSpan(
  7153. td,'delgg',filtreTresors," Les GG'"
  7154. ).firstChild;
  7155. checkBoxCompos = appendCheckBoxSpan(
  7156. td,'delcomp',filtreTresors,' Les Compos'
  7157. ).firstChild;
  7158. checkBoxBidouilles = appendCheckBoxSpan(
  7159. td,'delbid',filtreTresors,' Les Bidouilles'
  7160. ).firstChild;
  7161. checkBoxIntangibles = appendCheckBoxSpan(
  7162. td,'delint',filtreTrolls,' Les Intangibles'
  7163. ).firstChild;
  7164. checkBoxGowaps = appendCheckBoxSpan(
  7165. td,'delgowap',filtreMonstres,' Les Gowaps'
  7166. ).firstChild;
  7167. checkBoxEngages = appendCheckBoxSpan(
  7168. td,'delengage',filtreMonstres,' Les Engagés'
  7169. ).firstChild;
  7170. checkBoxLevels = appendCheckBoxSpan(
  7171. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  7172. ).firstChild;
  7173. checkBoxDiplo = appendCheckBoxSpan(
  7174. td,'delDiplo',refreshDiplo,' La Diplomatie'
  7175. ).firstChild;
  7176. checkBoxTrou = appendCheckBoxSpan(
  7177. td,'deltrou',filtreLieux,' Les Trous'
  7178. ).firstChild;
  7179. checkBoxMythiques = appendCheckBoxSpan(
  7180. td,'delmyth',filtreMonstres,' Les Mythiques'
  7181. ).firstChild;
  7182. if(MY_getValue('NOINFOEM')!='true') {
  7183. checkBoxEM = appendCheckBoxSpan(
  7184. td,'delem',filtreMonstres,' Les Composants EM'
  7185. ).firstChild;
  7186. }
  7187. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  7188. td,'deltres',filtreTresors,' Les Trésors non libres'
  7189. ).firstChild;
  7190. checkBoxTactique = appendCheckBoxSpan(
  7191. td,'deltactique',updateTactique,' Les Infos tactiques'
  7192. ).firstChild;
  7193. if(MY_getValue('INFOPLIE')) {
  7194. toggleTableauInfos(true);
  7195. }
  7196. }
  7197.  
  7198. function toggleTableauInfos(firstRun) {
  7199. var
  7200. msg = document.getElementById('msgInfoTab'),
  7201. corps = document.getElementById('corpsInfoTab'),
  7202. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7203. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  7204. if(!firstRun) {
  7205. infoplie = !infoplie;
  7206. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7207. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  7208. }
  7209. if(infoplie) {
  7210. msg.style.display = '';
  7211. corps.style.display = 'none';
  7212. } else {
  7213. msg.style.display = 'none';
  7214. corps.style.display = '';
  7215. }
  7216. }
  7217.  
  7218. /* [functions] Filtres */
  7219. function prepareFiltrage(ref,width) {
  7220. // = Initialise le filtre 'ref'
  7221. try {
  7222. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  7223. } catch(e) {
  7224. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  7225. return false;
  7226. }
  7227. if(width) { tdTitre.width = width; }
  7228. // Ajout du tr de Filtrage (masqué)
  7229. var tbody = tdTitre.parentNode.parentNode;
  7230. var tr = appendTr(tbody,'mh_tdpage');
  7231. tr.style.display = 'none';
  7232. tr.id = 'trFiltre'+ref;
  7233. var td = appendTd(tr);
  7234. td.colSpan = 5;
  7235. // Ajout du bouton de gestion de Filtrage
  7236. var tdBtn = insertTd(tdTitre.nextSibling);
  7237. tdBtn.id = 'tdInsert'+ref;
  7238. var btn = appendButton(tdBtn,'Filtrer');
  7239. btn.id = 'btnFiltre'+ref;
  7240. btn.onclick = function() {
  7241. debutFiltrage(ref)
  7242. };
  7243. return td;
  7244. }
  7245.  
  7246. function debutFiltrage(ref) {
  7247. // = Handler de début de filtrage (filtre 'ref')
  7248. document.getElementById('trFiltre'+ref).style.display = '';
  7249. var btn = document.getElementById('btnFiltre'+ref);
  7250. btn.value = 'Annuler Filtre';
  7251. btn.onclick = function() {
  7252. finFiltrage(ref);
  7253. };
  7254. }
  7255.  
  7256. function finFiltrage(ref) {
  7257. // = Handler de fin de filtrage (filtre 'ref')
  7258. /* On réassigne le bouton 'Filtrer' */
  7259. document.getElementById('trFiltre'+ref).style.display = 'none';
  7260. var btn = document.getElementById('btnFiltre'+ref);
  7261. btn.value = 'Filtrer';
  7262. btn.onclick = function() {
  7263. debutFiltrage(ref);
  7264. };
  7265. /* Réinitialisation filtres */
  7266. document.getElementById('str'+ref).value = '';
  7267. switch(ref) {
  7268. case 'Monstres':
  7269. document.getElementById('nivMinMonstres').value = 0;
  7270. document.getElementById('nivMaxMonstres').value = 0;
  7271. break;
  7272. case 'Trolls':
  7273. document.getElementById('strGuildes').value = '';
  7274. }
  7275. /* Nettoyage (=lance le filtre) */
  7276. // Ici this = MZ.global = sandBox de travail de MZ
  7277. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  7278. //this['filtre'+ref]();
  7279. switch (ref) {
  7280. case 'Monstres':
  7281. filtreMonstres();
  7282. break;
  7283. case 'Trolls':
  7284. filtreTrolls();
  7285. break;
  7286. case 'Tresors':
  7287. filtreTresors();
  7288. break;
  7289. case 'Lieux':
  7290. filtreLieux();
  7291. break;
  7292. default:
  7293. window.console.log('cas incongru dans finFiltrage : ' + ref);
  7294. break;
  7295. }
  7296. }
  7297.  
  7298. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  7299. var bouton = appendButton(td,nomBouton,onClick);
  7300. appendText(td,'\u00a0');
  7301. var textbox = appendTextbox(td,'text',id,15,30);
  7302. textbox.onkeypress = function(event) {
  7303. try {
  7304. if(event.keyCode==13) {
  7305. event.preventDefault();
  7306. bouton.click();
  7307. }
  7308. }
  7309. catch(e){
  7310. window.alert(e)
  7311. }
  7312. };
  7313. }
  7314.  
  7315. function ajoutFiltreMenu(tr,id,onChange) {
  7316. var select = document.createElement('select');
  7317. select.id = id;
  7318. select.onchange = onChange;
  7319. appendOption(select,0,'Aucun');
  7320. for(var i=1 ; i<=60 ; i++) {
  7321. appendOption(select,i,i);
  7322. }
  7323. tr.appendChild(select);
  7324. return select;
  7325. }
  7326.  
  7327. function ajoutDesFiltres() {
  7328. /* Monstres */
  7329. var td = prepareFiltrage('Monstres',120);
  7330. if(td) {
  7331. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  7332. appendText(td,'\u00a0\u00a0\u00a0');
  7333. appendText(td,'Niveau Min: ');
  7334. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  7335. appendText(td,'\u00a0');
  7336. appendText(td,'Niveau Max: ');
  7337. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  7338. }
  7339. /* Trõlls */
  7340. td = prepareFiltrage('Trolls',50);
  7341. if(td) {
  7342. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  7343. appendText(td,'\u00a0\u00a0\u00a0');
  7344. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  7345. }
  7346. /* Trésors */
  7347. td = prepareFiltrage('Tresors',55);
  7348. if(td) {
  7349. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  7350. }
  7351. /* Lieux */
  7352. td = prepareFiltrage('Lieux',40);
  7353. if(td) {
  7354. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  7355. }
  7356. }
  7357.  
  7358. /* [functions] Bouton d'envoi vers Troogle */
  7359. // WARNING - Nécessite que le Filtre Monstres ait été mis en place
  7360. function envoiVersTroogle() {
  7361. // = 1er Handler bouton Troogle
  7362. try {
  7363. var bouton = document.getElementById('bouton_Troogle');
  7364. } catch(e) {
  7365. window.console.log('Bouton d\'envoi non trouvé.');
  7366. return;
  7367. }
  7368. bouton.onclick = lireInfosTroogle;
  7369. bouton.value = 'Envoi en cours';
  7370. var responses = {}, erreur = false;
  7371. var maxDonnees = Math.max(
  7372. nbMonstres,
  7373. nbTresors,
  7374. nbLieux
  7375. );
  7376. var parLot = 100;
  7377. var lotStop = Math.ceil(maxDonnees/parLot);
  7378. for(var i=0 ; i<lotStop ; i++) {
  7379. var debutLot = parLot*i+1;
  7380. var finLot = parLot*(i+1);
  7381. var data = //'#'+numTroll+
  7382. bddMonstres(debutLot,finLot)+'\n'+
  7383. bddTresors(1,debutLot,finLot)+'\n'+
  7384. bddLieux(debutLot,finLot);
  7385. FF_XMLHttpRequest({
  7386. method: 'POST',
  7387. url: URL_trooglebeta,
  7388. //url: 'http://weblocal/POST_RESULT/index.php',
  7389. headers : {
  7390. 'Content-type': 'application/x-www-form-urlencoded'
  7391. },
  7392. data: 'view='+encodeURIComponent(data), //+'&from='+debutLot,
  7393. lot: i,
  7394. debutLot: debutLot,
  7395. finLot: finLot,
  7396. onload: function(responseDetails) {
  7397. try {
  7398. var resp = responseDetails.responseText;
  7399. responses[this.lot] = 'Envoi des éléments '+this.debutLot+
  7400. ' à '+Math.min(maxDonnees,this.finLot)+' :\n'+resp;
  7401. if(resp.indexOf('succès')==-1) {
  7402. erreur = true;
  7403. }
  7404. } catch(e) {
  7405. console.error(e);
  7406. return;
  7407. }
  7408. var txt = '';
  7409. var fini = true;
  7410. for(var j=0 ; j<lotStop ; j++) {
  7411. if(responses[j]) {
  7412. txt += txt ? '\n'+responses[j] : responses[j];
  7413. } else {
  7414. fini = false;
  7415. }
  7416. }
  7417. bouton.info = txt;
  7418. if(fini) {
  7419. bouton.value = erreur ? 'Erreur' : 'Envoi réussi';
  7420. }
  7421. }
  7422. });
  7423. }
  7424. }
  7425.  
  7426. function lireInfosTroogle() {
  7427. // = 2e Handler bouton Troogle
  7428. try {
  7429. var infos = document.getElementById('bouton_Troogle').info;
  7430. } catch(e) {
  7431. avertissement('[lireInfosTroogle] Bouton Troogle non trouvé');
  7432. window.console.error('[lireInfosTroogle]\n'+e);
  7433. return;
  7434. }
  7435. window.alert(infos);
  7436. }
  7437.  
  7438. function putBoutonTroogle() {
  7439. var td = document.getElementById('tdInsertMonstres');
  7440. td = insertTd(td.nextSibling);
  7441. td.style.fontSize = '0px';
  7442. var bouton = document.createElement('input');
  7443. bouton.type = 'button';
  7444. bouton.id = 'bouton_Troogle';
  7445. bouton.className = 'mh_form_submit';
  7446. bouton.value = 'Envoyer les données vers Troogle';
  7447. bouton.onmouseover = function(){
  7448. this.style.cursor='pointer';
  7449. };
  7450. bouton.onclick = envoiVersTroogle;
  7451. td.appendChild(bouton);
  7452. }
  7453.  
  7454.  
  7455. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  7456.  
  7457. /* [functions] Affichage de la colonne des niveaux */
  7458. function insertLevelColumn() {
  7459. // Déclenché si bascule vers affichage des niveaux des mobs
  7460. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7461. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  7462. td.width = 25;
  7463. for(var i=1 ; i<=nbMonstres ; i++) {
  7464. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7465. td = insertTdText(getMonstreLevelNode(i), '-');
  7466. td.onclick = function() {
  7467. basculeCDM(
  7468. getMonstreNomByTR(this.parentNode),
  7469. getMonstreIDByTR(this.parentNode)
  7470. );
  7471. };
  7472. td.onmouseover = function() {
  7473. this.style.cursor = 'pointer';
  7474. this.className = 'mh_tdtitre';
  7475. };
  7476. td.onmouseout = function() {
  7477. if(this.parentNode.diploActive=='oui') {
  7478. this.className = '';
  7479. } else {
  7480. this.className = 'mh_tdpage';
  7481. }
  7482. };
  7483. td.style = 'font-weight:bold;text-align:center;';
  7484. if(isCDMsRetrieved) {
  7485. // Rappel des niveaux si mémorisés
  7486. td.innerHTML = listeLevels[i];
  7487. }
  7488. }
  7489. }
  7490.  
  7491. function toggleLevelColumn() {
  7492. // = Handler checkBox noLevel
  7493. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  7494. insertLevelColumn();
  7495. if(!isCDMsRetrieved) { retrieveCDMs(); }
  7496. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  7497. for(var i=0 ; i<=nbMonstres ; i++) {
  7498. if(isCDMsRetrieved) {
  7499. // Mémorisation des niveaux pour rappel éventuel
  7500. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  7501. }
  7502. // Suppression du td Niveau
  7503. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  7504. }
  7505. }
  7506. }
  7507.  
  7508. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  7509. function basculeCDM(nom,id) {
  7510. // = Bascule l'affichage des popups CdM
  7511. if(listeCDM[id]) {
  7512. if(!document.getElementById('popupCDM'+id)) {
  7513. afficherCDM(nom, id);
  7514. } else {
  7515. cacherPopupCDM('popupCDM'+id);
  7516. }
  7517. }
  7518. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  7519. }
  7520.  
  7521. function cacherPopupCDM(titre) {
  7522. var popup = document.getElementById(titre);
  7523. popup.parentNode.removeChild(popup);
  7524. }
  7525.  
  7526. /* DEBUG: Section à mettre à jour */
  7527. var selectionFunction;
  7528.  
  7529. function startDrag(evt) {
  7530. winCurr = this.parentNode;
  7531. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  7532. offsetX = evt.pageX - parseInt( winCurr.style.left );
  7533. offsetY = evt.pageY - parseInt( winCurr.style.top );
  7534. selectionFunction = document.body.style.MozUserSelect;
  7535. document.body.style.MozUserSelect = 'none';
  7536. winCurr.style.MozUserSelect = 'none';
  7537. return false;
  7538. }
  7539.  
  7540. function stopDrag(evt) {
  7541. winCurr.style.MozUserSelect = selectionFunction;
  7542. document.body.style.MozUserSelect = selectionFunction;
  7543. winCurr = null;
  7544. }
  7545.  
  7546. function drag(evt) {
  7547. if(winCurr==null) { return; }
  7548. evt = evt || window.event;
  7549. winCurr.style.left = (evt.pageX - offsetX)+'px';
  7550. winCurr.style.top = (evt.pageY - offsetY)+'px';
  7551. return false;
  7552. }
  7553. /* FIN DEBUG */
  7554.  
  7555. function afficherCDM(nom,id) {
  7556. // Crée la table de CdM du mob n° id
  7557. var donneesMonstre = listeCDM[id];
  7558. /* Début création table */
  7559. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  7560. table.id = 'popupCDM'+id;
  7561. table.style =
  7562. 'position:fixed;'+
  7563. 'z-index:1;'+
  7564. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  7565. 'left:'+(window.innerWidth-365)+'px;'+
  7566. 'width:300px;'+
  7567. 'height:200px;';
  7568. /* Ajout du titre avec gestion Drag & Drop */
  7569. var tr = table.firstChild;
  7570. tr.style.cursor = 'move';
  7571. tr.onmousedown = startDrag;
  7572. tr.onmouseup = stopDrag;
  7573. /* Ajout du bouton "Fermer" */
  7574. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  7575. tr.onmouseover = function() {
  7576. this.style.cursor = 'pointer';
  7577. this.className = 'mh_tdpage';
  7578. };
  7579. tr.onmouseout = function() {
  7580. this.className = 'mh_tdtitre';
  7581. };
  7582. tr.idcdm = id;
  7583. tr.onclick = function() {
  7584. cacherPopupCDM('popupCDM'+this.idcdm);
  7585. this.className = 'mh_tdtitre';
  7586. };
  7587. td = appendTdText(tr,'Fermer',true);
  7588. td.colSpan = 2;
  7589. td.style = 'text-align:center;';
  7590. nbCDM++;
  7591. /* Fin création table & Affichage */
  7592. document.body.appendChild(table);
  7593. }
  7594.  
  7595. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  7596. function initPopupVue() {
  7597. popup = document.createElement('div');
  7598. popup.id = 'popup';
  7599. popup.className = 'mh_textbox';
  7600. popup.style =
  7601. 'position: absolute;'+
  7602. 'border: 1px solid #000000;'+
  7603. 'visibility: hidden;'+
  7604. 'display: inline;'+
  7605. 'z-index: 3;'+
  7606. 'max-width: 400px;';
  7607. document.body.appendChild(popup);
  7608. }
  7609.  
  7610. // roule 16/03/2016 supprimé, existe déjà dans vue
  7611. // function showPopupTactique(evt) {
  7612. // var id = this.id;
  7613. // var nom = this.nom;
  7614. // var texte = getAnalyseTactique(id,nom);
  7615. // if(texte=='') { return; }
  7616. // popup.innerHTML = texte;
  7617. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  7618. // popup.style.top = (evt.pageY+15)+'px';
  7619. // popup.style.visibility = 'visible';
  7620. // }
  7621.  
  7622. // roule 16/03/2016, existe déjà ailleurs
  7623. // function hidePopup() {
  7624. // popup.style.visibility = 'hidden';
  7625. // }
  7626.  
  7627. /* [functions] Récupération / Computation des Infos Tactiques */
  7628. // TODO à revoir
  7629. function retireMarquage(nom) {
  7630. var i = nom.indexOf(']');
  7631. switch(i) {
  7632. case -1:
  7633. case nom.length-1:
  7634. return nom;
  7635. default:
  7636. return nom.slice(0,i+1);
  7637. }
  7638. }
  7639.  
  7640. function retrieveCDMs() {
  7641. // Récupère les CdM disponibles dans la BDD
  7642. // Lancé uniquement sur toggleLevelColumn
  7643. if(checkBoxLevels.checked) { return; }
  7644. var str = '';
  7645. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  7646. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  7647. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  7648. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  7649. for(var i=1 ; i<=cdmMax ; i++) {
  7650. var nomMonstre = retireMarquage(getMonstreNom(i));
  7651. if(nomMonstre.indexOf(']') != -1) {
  7652. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  7653. }
  7654. // *** WARNING : PROXY RATIBUS ***
  7655. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  7656. str += 'nom[]='+escape(nomMonstre)+'$'+(
  7657. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  7658. )+'&';
  7659. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  7660. FF_XMLHttpRequest({
  7661. method: 'POST',
  7662. url: URL_MZinfoMonstrePost,
  7663. headers : {
  7664. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7665. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7666. 'Content-type':'application/x-www-form-urlencoded'
  7667. },
  7668. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  7669. onload: function(responseDetails) {
  7670. try {
  7671. var texte = responseDetails.responseText;
  7672. var lines = texte.split('\n');
  7673. if(lines.length==0) { return; }
  7674. var begin2, end2, index;
  7675. for(var j=0 ; j<lines.length ; j++) {
  7676. var infos = lines[j].split(';');
  7677. if(infos.length<4) { continue; }
  7678. var idMonstre=infos[0];
  7679. var isCDM = infos[1];
  7680. index = parseInt(infos[2]);
  7681. var level = infos[3];
  7682. infos = infos.slice(3);
  7683. if(begin2==null) { begin2 = index; }
  7684. end2 = index;
  7685. listeCDM[idMonstre] = infos;
  7686. if(isCDM==1) {
  7687. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  7688. } else {
  7689. getMonstreLevelNode(index).innerHTML = level;
  7690. }
  7691. }
  7692. computeMission(begin2,end2);
  7693. } catch(e) {
  7694. window.console.error(
  7695. '[retrieveCDMs]\n'+e+'\n'+URL_MZinfoMonstrePost+'\n'+texte
  7696. );
  7697. }
  7698. }
  7699. });
  7700. str = '';
  7701. begin = i+1;
  7702. }
  7703. }
  7704. isCDMsRetrieved=true;
  7705. }
  7706.  
  7707. function computeMission(begin,end) {
  7708. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  7709. computeVLC(begin,end);
  7710. if(!begin) begin=1;
  7711. if(!end) end=nbMonstres;
  7712. var str = MY_getValue(numTroll+'.MISSIONS');
  7713. if(!str) { return; }
  7714. var urlImg = URL_MZimg09+'mission.png';
  7715. var obMissions = JSON.parse(str);
  7716. for(var i=end ; i>=begin ; i--) {
  7717. var mess = '';
  7718. for(var num in obMissions) {
  7719. var mobMission = false;
  7720. switch(obMissions[num].type) {
  7721. case 'Race':
  7722. var race = epure(obMissions[num].race.toLowerCase());
  7723. var nom = epure(getMonstreNom(i).toLowerCase());
  7724. if(nom.indexOf(race)!=-1) {
  7725. mobMission = true;
  7726. }
  7727. break;
  7728. case 'Niveau':
  7729. var donneesMonstre = listeCDM[getMonstreID(i)];
  7730. if(donneesMonstre) {
  7731. var nivMob = Number(donneesMonstre[0]);
  7732. var nivMimi = Number(obMissions[num].niveau),
  7733. mod = obMissions[num].mod;
  7734. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  7735. || (isNaN(mod) && nivMob>=nivMimi)) {
  7736. mobMission = true;
  7737. }
  7738. }
  7739. break;
  7740. case 'Famille':
  7741. var donneesMonstre = listeCDM[getMonstreID(i)];
  7742. if(donneesMonstre) {
  7743. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  7744. var familleMob = epure(donneesMonstre[1].toLowerCase());
  7745. if(familleMob.indexOf(familleMimi)!=-1) {
  7746. mobMission = true;
  7747. }
  7748. }
  7749. break;
  7750. case 'Pouvoir':
  7751. var donneesMonstre = listeCDM[getMonstreID(i)];
  7752. if(donneesMonstre) {
  7753. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  7754. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  7755. if(pvrMob.indexOf(pvrMimi)!=-1) {
  7756. mobMission = true;
  7757. }
  7758. }
  7759. }
  7760. if(mobMission) {
  7761. mess += mess ? '\n\n' : '';
  7762. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  7763. }
  7764. }
  7765. if(mess) {
  7766. var td = getMonstreNomNode(i);
  7767. appendText(td,' ');
  7768. td.appendChild(createImage(urlImg,mess));
  7769. }
  7770. }
  7771. }
  7772.  
  7773. function computeVLC(begin,end) {
  7774. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  7775. computeTactique(begin,end);
  7776. if(!begin) begin=1;
  7777. if(!end) end=nbMonstres;
  7778. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  7779. if(!cache)
  7780. return false;
  7781. var urlImg = URL_MZimg09 + "oeil.png";
  7782. for(var i = end; i >= begin;i--)
  7783. {
  7784. var id = getMonstreID(i);
  7785. var donneesMonstre = listeCDM[id];
  7786. if(donneesMonstre && donneesMonstre.length>12)
  7787. {
  7788. if(donneesMonstre[12]==1)
  7789. {
  7790. var td = getMonstreNomNode(i);
  7791. td.appendChild(document.createTextNode(" "));
  7792. td.appendChild(createImage(urlImg, "Voit le caché"));
  7793. }
  7794. }
  7795. }
  7796. }
  7797.  
  7798. function computeTactique(begin, end) {
  7799. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  7800. try {
  7801. if(!begin) begin = 1;
  7802. if(!end) end = nbMonstres;
  7803. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  7804. if(noTactique || !isProfilActif()) return;
  7805. for(var j=end ; j>=begin ; j--) {
  7806. var id = getMonstreID(j);
  7807. var nom = getMonstreNom(j);
  7808. var donneesMonstre = listeCDM[id];
  7809. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  7810. var td = getMonstreNomNode(j);
  7811. appendText(td,' ');
  7812. td.appendChild(
  7813. createImageTactique(URL_MZimg09+'calc2.png', id, nom)
  7814. );
  7815. }
  7816. }
  7817. }
  7818. catch(e) {
  7819. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  7820. }
  7821. filtreMonstres();
  7822. }
  7823.  
  7824. function updateTactique() {
  7825. // = Handler checkBox noTactique
  7826. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  7827. if(!isCDMsRetrieved) return;
  7828. if(noTactique) {
  7829. for(var i=nbMonstres ; i>0 ; i--) {
  7830. var tr = getMonstreNomNode(i);
  7831. var img = document.evaluate("img[@src='"+URL_MZimg09+"calc2.png']",
  7832. tr, null, 9, null).singleNodeValue;
  7833. if(img) {
  7834. img.parentNode.removeChild(img.previousSibling);
  7835. img.parentNode.removeChild(img);
  7836. }
  7837. }
  7838. }
  7839. else
  7840. computeTactique();
  7841. }
  7842.  
  7843. function filtreMonstres() {
  7844. // = Handler universel pour les fonctions liées aux monstres
  7845. var urlImg = URL_MZimg09+'Competences/ecritureMagique.png',
  7846. urlEnchantImg = URL_MZimg09+'images/enchant.png';
  7847. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  7848. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  7849. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  7850. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  7851. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  7852. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  7853. // old/new : détermine s'il faut ou non nettoyer les tr
  7854. var oldNOEM = true, noEM = true;
  7855. if(MY_getValue('NOINFOEM')!='true') {
  7856. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  7857. }
  7858. // Filtrage par nom
  7859. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  7860. // Génère la liste des mobs engagés (si filtrés)
  7861. if(noEngages && !isEngagesComputed) {
  7862. for(var i=nbTrolls ; i>0 ; i--) {
  7863. var pos = getTrollPosition(i);
  7864. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  7865. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  7866. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  7867. }
  7868. isEngagesComputed = true;
  7869. }
  7870. /*** FILTRAGE ***/
  7871. /* À computer :
  7872. * - EM (nom suffit)
  7873. * - Enchant (nom suffit)
  7874. * - Mission (nécessite CdM)
  7875. * - mob VlC (nécessite CdM)
  7876. * Sans computation :
  7877. * - Gowap ? engagé ?
  7878. */
  7879. for(var i=nbMonstres ; i>0 ; i--) {
  7880. var pos = getMonstrePosition(i);
  7881. var nom = getMonstreNom(i).toLowerCase();
  7882. if(noEM!=oldNOEM) {
  7883. if(noEM) {
  7884. // Si noEM passe de false à true, on nettoie les td "Nom"
  7885. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  7886. var tr = getMonstreNomNode(i);
  7887. while(tr.childNodes.length>1) {
  7888. tr.removeChild(tr.childNodes[1]);
  7889. }
  7890. } else {
  7891. var tr = getMonstreNomNode(i);
  7892. var TypeMonstre=getEM(nom);
  7893. if(TypeMonstre!='') {
  7894. var infosCompo=compoMobEM(TypeMonstre);
  7895. if(infosCompo.length>0) {
  7896. tr.appendChild(document.createTextNode(' '));
  7897. tr.appendChild(createImage(urlImg, infosCompo));
  7898. }
  7899. }
  7900. }
  7901. }
  7902. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  7903. var texte = getInfoEnchantementFromMonstre(nom);
  7904. if(texte!='') {
  7905. var td = getMonstreNomNode(i);
  7906. td.appendChild(document.createTextNode(' '));
  7907. td.appendChild(createImage(urlEnchantImg, texte));
  7908. }
  7909. }
  7910. tr_monstres[i].style.display = (
  7911. noGowaps &&
  7912. nom.indexOf('gowap apprivoisé')!=-1 &&
  7913. getMonstreDistance(i)>1
  7914. ) || (
  7915. noEngages &&
  7916. getMonstreDistance(i)!=0 &&
  7917. listeEngages[pos[0]] &&
  7918. listeEngages[pos[0]][pos[1]] &&
  7919. listeEngages[pos[0]][pos[1]][pos[2]]
  7920. ) || (
  7921. strMonstre!='' &&
  7922. nom.indexOf(strMonstre)==-1
  7923. ) || (
  7924. nivMin>0 &&
  7925. getMonstreLevel(i)!=-1 &&
  7926. getMonstreLevel(i)<nivMin &&
  7927. getMonstreDistance(i)>1 &&
  7928. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  7929. ) || (
  7930. nivMax>0 &&
  7931. getMonstreLevel(i)>nivMax &&
  7932. getMonstreDistance(i)>1 &&
  7933. nom.toLowerCase().indexOf("kilamo")==-1
  7934. ) ? 'none' : '';
  7935. }
  7936. if(MY_getValue('NOINFOEM')!='true') {
  7937. if(noEM != oldNOEM) {
  7938. if(noEM && isCDMsRetrieved) computeMission();
  7939. }
  7940. oldNOEM = noEM;
  7941. }
  7942. needComputeEnchantement = false;
  7943. }
  7944.  
  7945.  
  7946. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  7947.  
  7948. function filtreTrolls() {
  7949. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  7950. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  7951. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  7952. for(var i=1 ; i<=nbTrolls ; i++) {
  7953. tr_trolls[i].style.display = (
  7954. noIntangibles &&
  7955. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  7956. ) || (
  7957. strTroll!='' &&
  7958. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  7959. ) || (
  7960. strGuilde!='' &&
  7961. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  7962. ) ? 'none' : '';
  7963. }
  7964. }
  7965.  
  7966. /* [functions] Bulle PX Trolls */
  7967. var bulle;
  7968.  
  7969. function initPXTroll() {
  7970. bulle = document.createElement('div');
  7971. bulle.id = 'bulle';
  7972. bulle.className = 'mh_textbox';
  7973. bulle.style =
  7974. 'position: absolute;'+
  7975. 'border: 1px solid #000000;'+
  7976. 'visibility: hidden;'+
  7977. 'display: inline;'+
  7978. 'z-index: 2;';
  7979. document.body.appendChild(bulle);
  7980.  
  7981. for(var i=nbTrolls ; i>0 ; i--) {
  7982. var td_niv = getTrollNivNode(i);
  7983. td_niv.onmouseover = showPXTroll;
  7984. td_niv.onmouseout = hidePXTroll;
  7985. }
  7986. }
  7987.  
  7988. function showPXTroll(evt) {
  7989. var lvl = this.firstChild.nodeValue;
  7990. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  7991. bulle.style.left = evt.pageX+15+'px';
  7992. bulle.style.top = evt.pageY+'px';
  7993. bulle.style.visibility = 'visible';
  7994. }
  7995.  
  7996. function hidePXTroll() {
  7997. bulle.style.visibility = 'hidden';
  7998. }
  7999.  
  8000. /* [functions] Envoi PX / MP */
  8001. function putBoutonPXMP() {
  8002. // Bouton d'initialisation du mode Envoi
  8003. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8004. var td = document.getElementById('tdInsertTrolls');
  8005. if(!td) { return; }
  8006. td.width = 100;
  8007. td = insertTd(td.nextSibling);
  8008. td.style.verticalAlign = 'top';
  8009. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8010. bouton.id = 'btnEnvoi';
  8011. }
  8012.  
  8013. function prepareEnvoi() {
  8014. // = 1er Handler du bouton d'envoi
  8015. /* Ajout de la colonne des CheckBoxes */
  8016. var td = insertTdText(getTrollNomNode(0),'');
  8017. td.width = 5;
  8018. for(var i=nbTrolls ; i>0 ; i--) {
  8019. td = insertTd(getTrollNomNode(i));
  8020. appendCheckBox(td,'envoi'+i);
  8021. }
  8022. /* Ajout du radio de choix PX ou MP */
  8023. var btnEnvoi = document.getElementById('btnEnvoi');
  8024. if(!btnEnvoi) { return; }
  8025. var tdEnvoi = btnEnvoi.parentNode;
  8026. appendText(tdEnvoi,' ');
  8027. var span = document.createElement('span');
  8028. span.style.whiteSpace = 'nowrap';
  8029. var radioElt = document.createElement('input');
  8030. radioElt.type = 'radio';
  8031. radioElt.name = 'envoiPXMP';
  8032. radioElt.id = 'radioPX';
  8033. span.appendChild(radioElt);
  8034. appendText(span,' des PX ');
  8035. radioElt = document.createElement('input');
  8036. radioElt.type = 'radio';
  8037. radioElt.name = 'envoiPXMP';
  8038. radioElt.checked = true;
  8039. span.appendChild(radioElt);
  8040. appendText(span,' un MP');
  8041. tdEnvoi.appendChild(span);
  8042. /* Insertion du bouton Annuler */
  8043. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8044. /* Modification de l'effet du bouton Envoi */
  8045. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8046. }
  8047.  
  8048. function annuleEnvoi() {
  8049. // = Handler bouton Annuler
  8050. /* Nettoyage du td du bouton Envoi */
  8051. var btnEnvoi = document.getElementById('btnEnvoi');
  8052. var tdEnvoi = btnEnvoi.parentNode;
  8053. while(tdEnvoi.firstChild) {
  8054. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8055. }
  8056. /* Retour à l'effet de base du bouton Envoi */
  8057. btnEnvoi.onclick = prepareEnvoi;
  8058. tdEnvoi.appendChild(btnEnvoi);
  8059. /* Suppression CheckBoxes */
  8060. for(var i=nbTrolls ; i>=0 ; i--) {
  8061. var td = getTrollNomNode(i);
  8062. td.parentNode.removeChild(td);
  8063. }
  8064. }
  8065.  
  8066. function effectueEnvoi() {
  8067. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  8068. var str='';
  8069. for(var i=nbTrolls ; i>0 ; i--) {
  8070. var chb = document.getElementById('envoi'+i);
  8071. if(chb.checked) {
  8072. str += (str?',':'')+getTrollID(i);
  8073. }
  8074. }
  8075. var PXchecked = document.getElementById('radioPX').checked;
  8076. if(PXchecked) {
  8077. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  8078. } else {
  8079. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  8080. }
  8081. }
  8082.  
  8083. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  8084.  
  8085. function filtreTresors() {
  8086. // += Handler checkboxes : gg, compos, bidouilles, non libres
  8087. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  8088. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  8089. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  8090. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8091. if(noEngages && !isEngagesComputed) {
  8092. for(var i=nbTrolls ; i>0 ; i--) {
  8093. var pos = getTrollPosition(i);
  8094. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  8095. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  8096. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  8097. }
  8098. isEngagesComputed = true;
  8099. }
  8100. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  8101. for(var i=nbTresors ; i>0 ; i--) {
  8102. var nom = getTresorNom(i);
  8103. var pos = getTresorPosition(i);
  8104. tr_tresors[i].style.display = (
  8105. noGG &&
  8106. nom.indexOf('Gigots de Gob')!=-1
  8107. ) || (
  8108. noCompos &&
  8109. nom.indexOf('Composant')!=-1
  8110. ) || (
  8111. noEngages &&
  8112. listeEngages[pos[2]] &&
  8113. listeEngages[pos[2]][pos[1]] &&
  8114. listeEngages[pos[2]][pos[1]][pos[0]] &&
  8115. getTresorDistance(i)>0
  8116. ) || (
  8117. strTresor!='' &&
  8118. nom.toLowerCase().indexOf(strTresor)==-1
  8119. ) || (
  8120. noBidouilles &&
  8121. nom.indexOf('Bidouille')!=-1
  8122. ) ? 'none' : '';
  8123. }
  8124. }
  8125.  
  8126.  
  8127. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  8128.  
  8129. function filtreLieux() {
  8130. // += Handler checkbox trous
  8131. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  8132. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  8133. for(var i=nbLieux ; i>0 ; i--) {
  8134. tr_lieux[i].style.display = (
  8135. strLieu &&
  8136. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  8137. ) || (
  8138. noTrou &&
  8139. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  8140. getLieuDistance(i)>1
  8141. ) ? 'none' : '';
  8142. }
  8143. }
  8144.  
  8145.  
  8146. /*-[functions]-------------------- Diplomatie --------------------------------*/
  8147.  
  8148. function refreshDiplo() {
  8149. MY_setValue(numTroll+'.diplo.off',
  8150. checkBoxDiplo.checked?'true':'false'
  8151. );
  8152. if(isDiploRaw) { computeDiplo(); }
  8153. appliqueDiplo();
  8154. }
  8155.  
  8156. function computeDiplo() {
  8157. // On extrait les données de couleur et on les stocke par id
  8158. // Ordre de préséance :
  8159. // source Guilde < source Perso
  8160. // guilde cible < troll cible
  8161. /* Diplo de Guilde */
  8162. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  8163. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  8164. if(diploGuilde && diploGuilde.isOn=='true') {
  8165. // Guilde perso
  8166. if(diploGuilde.guilde) {
  8167. Diplo.Guilde[diploGuilde.guilde.id] = {
  8168. couleur: diploGuilde.guilde.couleur,
  8169. titre: 'Ma Guilde'
  8170. };
  8171. }
  8172. // Guildes/Trolls A/E
  8173. for(var AE in {Amis:0,Ennemis:0}) {
  8174. for(var i=0 ; i<5 ; i++) {
  8175. if(diploGuilde[AE+i]) {
  8176. for(var type in {Guilde:0,Troll:0}) {
  8177. var liste = diploGuilde[AE+i][type].split(';');
  8178. for(var j=liste.length-2 ; j>=0 ; j--) {
  8179. Diplo[type][liste[j]] = {
  8180. couleur: diploGuilde[AE+i].couleur,
  8181. titre: diploGuilde[AE+i].titre
  8182. };
  8183. }
  8184. }
  8185. }
  8186. }
  8187. }
  8188. }
  8189. /* Diplo Perso */
  8190. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  8191. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  8192. if(diploPerso && diploPerso.isOn=='true') {
  8193. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8194. for(var id in diploPerso[type]) {
  8195. Diplo[type][id] = diploPerso[type][id];
  8196. }
  8197. }
  8198. }
  8199. if(diploPerso.mythiques) {
  8200. Diplo.mythiques = diploPerso.mythiques;
  8201. }
  8202. isDiploRaw = false;
  8203. }
  8204.  
  8205. function appliqueDiplo() {
  8206. var aAppliquer = Diplo;
  8207. if(checkBoxDiplo.checked) {
  8208. // Pour retour à l'affichage basique sur désactivation de la diplo
  8209. aAppliquer = {
  8210. Guilde: {},
  8211. Troll: {},
  8212. Monstre: {}
  8213. };
  8214. }
  8215. /* On applique "aAppliquer" */
  8216. // Diplo Trõlls
  8217. for(var i=nbTrolls ; i>0 ; i--) {
  8218. var idG = getTrollGuildeID(i);
  8219. var idT = getTrollID(i);
  8220. var tr = tr_trolls[i];
  8221. if(aAppliquer.Troll[idT]) {
  8222. tr.className = '';
  8223. var descr = aAppliquer.Troll[idT].titre;
  8224. if(descr) {
  8225. getTrollNomNode(i).title = descr
  8226. }
  8227. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  8228. } else if(aAppliquer.Guilde[idG]) {
  8229. tr.className = '';
  8230. var descr = aAppliquer.Guilde[idG].titre;
  8231. if(descr) {
  8232. getTrollNomNode(i).title = descr
  8233. }
  8234. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  8235. } else {
  8236. tr.className = 'mh_tdpage';
  8237. getTrollNomNode(i).title = '';
  8238. }
  8239. }
  8240. // Diplo Monstres
  8241. for(var i=nbMonstres ; i>0 ; i--) {
  8242. var id = getMonstreID(i);
  8243. var nom = getMonstreNom(i).toLowerCase();
  8244. if(aAppliquer.Monstre[id]) {
  8245. tr_monstres[i].className = '';
  8246. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  8247. tr_monstres[i].diploActive = 'oui';
  8248. var descr = aAppliquer.Monstre[id].titre;
  8249. if(descr) {
  8250. getMonstreNomNode(i).title = descr;
  8251. }
  8252. } else if(aAppliquer.mythiques &&
  8253. (nom.indexOf('liche')==0 ||
  8254. nom.indexOf('hydre')==0 ||
  8255. nom.indexOf('balrog')==0 ||
  8256. nom.indexOf('beholder')==0)) {
  8257. tr_monstres[i].className = '';
  8258. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  8259. tr_monstres[i].diploActive = 'oui';
  8260. getMonstreNomNode(i).title = 'Monstre Mythique';
  8261. } else {
  8262. tr_monstres[i].className = 'mh_tdpage';
  8263. tr_monstres[i].diploActive = '';
  8264. }
  8265. }
  8266. }
  8267.  
  8268.  
  8269. /*-[functions]---------------- Actions à distance ----------------------------*/
  8270.  
  8271. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  8272. var monN = parseInt(getPosition()[2]);
  8273. for(var type in keltypes) {
  8274. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  8275. for(var i=this['nb'+type] ; i>0 ; i--) {
  8276. var tr = this['tr_'+type.toLowerCase()][i];
  8277. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  8278. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  8279. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  8280. var sonN = getXxxPosition(type, i)[2];
  8281. var d = getXxxDistance(type, i);
  8282. if(sonN==monN && d>=dmin && d<=dmax) {
  8283. var iconeAction = document.evaluate(
  8284. "./descendant::img[@alt='"+alt+"']",
  8285. tr, null, 9, null
  8286. ).singleNodeValue;
  8287. if(iconeAction) {
  8288. if(iconeAction.title) {
  8289. iconeAction.title += "\n"+message;
  8290. } else {
  8291. iconeAction.title = message;
  8292. }
  8293. iconeAction.src = urlIcon;
  8294. } else {
  8295. var tdAction = tr.getElementsByTagName('td')[1];
  8296. var icon = document.createElement('img');
  8297. icon.src = urlIcon;
  8298. icon.height = 20;
  8299. icon.alt = alt;
  8300. icon.title = message;
  8301. tdAction.appendChild(icon);
  8302. }
  8303. }
  8304. }
  8305. }
  8306. }
  8307.  
  8308. function computeCharge() {
  8309. computeActionDistante(1,
  8310. getPortee__Vue(
  8311. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  8312. MY_getValue(numTroll+".caracs.regeneration")
  8313. ),
  8314. {'Monstres':1, 'Trolls':1},
  8315. 'Attaquer',
  8316. MHicons+'E_Metal09.png',
  8317. 'Cible à portée de Charge'
  8318. );
  8319. }
  8320.  
  8321. function computeProjo() {
  8322. computeActionDistante(0,
  8323. getPortee__Vue(
  8324. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8325. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8326. ),
  8327. {'Monstres':1, 'Trolls':1},
  8328. 'Attaquer',
  8329. MHicons+'S_Fire05.png',
  8330. 'Cible à portée de Projo'
  8331. );
  8332. }
  8333.  
  8334. function computeTelek() {
  8335. computeActionDistante(0,
  8336. Math.floor((
  8337. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8338. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8339. )/2),
  8340. {'Tresors':1},
  8341. 'Telek',
  8342. MHicons+'S_Magic04.png',
  8343. 'Trésor à portée de Télékinésie'
  8344. );
  8345. }
  8346.  
  8347. function computeLdP() {
  8348. computeActionDistante(0,
  8349. 2+Math.floor((
  8350. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8351. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8352. )/5),
  8353. {'Monstres':1, 'Trolls':1},
  8354. 'self',
  8355. MHicons+'P_Red01.png',
  8356. 'Cible à portée de Lancer de Potions'
  8357. );
  8358. }
  8359.  
  8360.  
  8361. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  8362.  
  8363. function putScriptExterne() {
  8364. var infoit = MY_getValue(numTroll+'.INFOSIT');
  8365. if(!infoit || infoit=='') return;
  8366. var nomit = infoit.slice(0,infoit.indexOf('$'));
  8367. if(nomit=='bricol') {
  8368. var data = infoit.split('$');
  8369. try {
  8370. appendNewScript(URL_ratibus_lien+data[1]
  8371. +'/mz.php?login='+data[2]
  8372. +'&password='+data[3]
  8373. );
  8374. }
  8375. catch(e) { window.alert(erreurIT(e,it)); }
  8376. }
  8377. }
  8378.  
  8379. function erreurIT( chaine , it ) {
  8380. if(it=='bricol')
  8381. window.alert(
  8382. "Erreur lors de la connection avec l'interface des Bricol'Trolls :\n"
  8383. +chaine
  8384. );
  8385. MY_removeValue(numTroll+'.INFOSIT');
  8386. }
  8387.  
  8388. /* Le script de Ratibus renvoie :
  8389. + infosTrolls = new Array();
  8390. + infosTrolls[numdutroll] =
  8391. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  8392. + etc ...
  8393. + putInfosTrolls();
  8394. *
  8395. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  8396. */
  8397.  
  8398. function corrigeBricolTrolls() {
  8399. for(var i in infosTrolls) {
  8400. var pv = infosTrolls[i][0];
  8401. var pvmax = infosTrolls[i][1];
  8402. var pvmem = MY_getValue(i+'.caracs.pv.max');
  8403. if(pvmem && pvmem>pvmax) {
  8404. infosTrolls[i][1] = pvmem;
  8405. pvmax = pvmem;
  8406. }
  8407. if(pv>pvmax) {
  8408. var newpvmax = 5*Math.ceil(pv/5);
  8409. MY_setValue(i+'.caracs.pv.max',newpvmax);
  8410. infosTrolls[i][1] = newpvmax;
  8411. }
  8412. }
  8413. }
  8414.  
  8415. function putInfosTrolls() {
  8416. // teste la présence de trõlls de l'IT
  8417. var i=nbTrolls;
  8418. while( i>0 && !infosTrolls[getTrollID(i)] ) i--;
  8419. if(i==0) return;
  8420. try
  8421. {
  8422. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  8423. td.width = 40;
  8424. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  8425. td.width = 105;
  8426. corrigeBricolTrolls();
  8427. for(i=nbTrolls ; i>0 ; i--) {
  8428. var infos = infosTrolls[getTrollID(i)];
  8429. if(infos) {
  8430. /* PAs dispos */
  8431. var span = document.createElement('span');
  8432. span.title = infos[3];
  8433. appendText(span, infos[4]+' PA' );
  8434. insertTdElement(tr_trolls[i].childNodes[6], span);
  8435. /* cadre barre PV */
  8436. var tab = document.createElement('div');
  8437. tab.width = 100;
  8438. tab.style.background = '#FFFFFF';
  8439. tab.style.width = 100;
  8440. tab.style.border = 1;
  8441. tab.height = 10;
  8442. tab.title = infos[0]+'/'+infos[1]+' '+ infos[2];
  8443. /* barre PV */
  8444. var img = document.createElement('img');
  8445. img.src = '../Images/Interface/milieu.gif';
  8446. img.height = 10;
  8447. img.width = Math.floor( (100*infos[0])/infos[1] );
  8448. tab.appendChild(img);
  8449. /* lien vers l'IT */
  8450. var lien = document.createElement('a');
  8451. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  8452. lien.href = URL_ratibus_lien+nomit+'/index.php';
  8453. lien.target = '_blank';
  8454. lien.appendChild(tab);
  8455. insertTdElement(tr_trolls[i].childNodes[6],lien);
  8456. }
  8457. else {
  8458. insertTd(tr_trolls[i].childNodes[6]);
  8459. insertTd(tr_trolls[i].childNodes[6]);
  8460. }
  8461. }
  8462. }
  8463. catch(e) {
  8464. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  8465. }
  8466. }
  8467.  
  8468.  
  8469. /* Mode Tétalanvert! ---------------------------------------------------------*/
  8470.  
  8471. function calculeDistance(maPos,posArr) {
  8472. return Math.max(
  8473. Math.abs(maPos[0]-posArr[0]),
  8474. Math.abs(maPos[1]-posArr[1]),
  8475. Math.abs(maPos[2]-posArr[2])
  8476. );
  8477. }
  8478.  
  8479. function inversionCoord() {
  8480. var maPos = getPosition();
  8481. var listeOffsets = {
  8482. 'monstres':checkBoxLevels.checked?4:3,
  8483. 'trolls':6,
  8484. };
  8485. for(var type in listeOffsets) {
  8486. var trList = this['tr_'+type];
  8487. var offset = listeOffsets[type];
  8488. for(var i=trList.length-1 ; i>0 ; i--) {
  8489. var oldX = parseInt(trList[i].cells[offset].textContent);
  8490. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  8491. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  8492. trList[i].cells[offset].innerHTML = oldY;
  8493. trList[i].cells[offset+1].innerHTML = oldX;
  8494. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  8495. }
  8496. }
  8497. }
  8498.  
  8499.  
  8500. /* Partie principale */
  8501. function do_vue() {
  8502. for(var type in typesAFetcher) {
  8503. fetchData(type);
  8504. }
  8505.  
  8506. // roule' 11/03/2016
  8507. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  8508. // je fais une recopie :(
  8509. tr_monstres = this['tr_monstres'];
  8510. tr_trolls = this['tr_trolls'];
  8511. tr_tresors = this['tr_tresors'];
  8512. tr_champignons = this['tr_champignons'];
  8513. tr_lieux = this['tr_lieux'];
  8514.  
  8515. nbMonstres = this['nbMonstres'];
  8516. nbTrolls = this['nbTrolls'];
  8517. nbTresors = this['nbTresors'];
  8518. nbChampignons = this['nbChampignons'];
  8519. nbLieux = this['nbLieux'];
  8520.  
  8521. try {
  8522. start_script(31);
  8523. initialiseInfos();
  8524. savePosition();
  8525.  
  8526. // Fonctionnalité "Têtalenvert" cachée, en test :
  8527. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  8528. inversionCoord();
  8529. }
  8530. ajoutDesFiltres();
  8531. set2DViewSystem();
  8532. //putBoutonTroogle();
  8533. putBoutonPXMP();
  8534. synchroniseFiltres();
  8535. toggleLevelColumn();
  8536.  
  8537. refreshDiplo();
  8538. //400 ms
  8539. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  8540. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  8541. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  8542. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  8543. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  8544. var noTresorsEngages =
  8545. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  8546. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  8547. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  8548. filtreMonstres();
  8549. if(noIntangibles) {
  8550. filtreTrolls();
  8551. }
  8552. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  8553. filtreTresors();
  8554. }
  8555. if(noTrou) {
  8556. filtreLieux();
  8557. }
  8558.  
  8559. initPopupVue();
  8560. initPXTroll();
  8561.  
  8562. if(getTalent("Projectile Magique")!=0) {
  8563. computeProjo();
  8564. }
  8565. if(getTalent("Charger")!=0) {
  8566. computeCharge();
  8567. }
  8568. if(getTalent("Télékinésie")!=0) {
  8569. computeTelek();
  8570. }
  8571. if(getTalent("Lancer de Potions")!=0) {
  8572. computeLdP();
  8573. }
  8574. putScriptExterne();
  8575. displayScriptTime();
  8576. } catch(e) {
  8577. avertissement("[MZ] Une erreur s'est produite.");
  8578. window.console.error("[MZ] Erreur générale Vue",e);
  8579. }
  8580. }
  8581.  
  8582.  
  8583.  
  8584. /*******************************************************************************
  8585. * This file is part of Mountyzilla. *
  8586. * *
  8587. * Mountyzilla is free software; you can redistribute it and/or modify *
  8588. * it under the terms of the GNU General Public License as published by *
  8589. * the Free Software Foundation; either version 2 of the License, or *
  8590. * (at your option) any later version. *
  8591. * *
  8592. * Mountyzilla is distributed in the hope that it will be useful, *
  8593. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8594. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8595. * GNU General Public License for more details. *
  8596. * *
  8597. * You should have received a copy of the GNU General Public License *
  8598. * along with Mountyzilla; if not, write to the Free Software *
  8599. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8600. *******************************************************************************/
  8601.  
  8602. // x~x profil2
  8603.  
  8604. /*---------------------------- Variables globales ----------------------------*/
  8605.  
  8606. var
  8607. // Anatrolliseur
  8608. urlAnatrolliseur,
  8609. // Infobulles talents
  8610. hauteur = 50, bulleStyle = null,
  8611. // Caracteristiques
  8612. // Infos troll
  8613. race, niv, idtroll, datecrea,
  8614. // Etats du troll
  8615. fatigue, bmfatigue,
  8616.  
  8617. // Experience, Pi, ...
  8618. pxdistribuables, pxperso,
  8619. piutilisable, pitotal,
  8620. nbmeurtres, nbmorts,
  8621. // utilisee pour les moyennes MM/jour, kill/jour, etc
  8622. NBjours,
  8623. // calcul des DLA suivantes
  8624. DLA, DLAsuiv, HeureServeur,
  8625. // details duree du tour (calcul pvdispo) :
  8626. dtb, pdm, bmt, adb, dpt,
  8627. //posale
  8628. posX, posY, posN,
  8629. // caracs physiques
  8630. vue, vuebp, vuebm, vuetotale,
  8631. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  8632. reg, regbp, regbm, regmoy,
  8633. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  8634. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  8635. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  8636. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  8637. rm, rmbp, rmbm, rmtotale,
  8638. mm, mmbp, mmbm, mmtotale,
  8639.  
  8640. // Variables speciales Kastars
  8641. pvActuelKastar, minParPV, overDLA,
  8642. // id pour edition manuelle de lastDLA :
  8643. inJour, inMois, inAn, inHr, inMin, inSec,
  8644. // id pour auto-refresh lastDLA :
  8645. lastDLAZone, maxAMZone, cumulZone,
  8646. lastDLA, DLAaccel;
  8647.  
  8648.  
  8649. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  8650.  
  8651. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  8652. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  8653. function getUniqueValueBySelector(selector, defaultValue){
  8654. var valNode = document.querySelector(selector);
  8655. if(valNode!=null){
  8656. if(valNode.hasChildNodes()) {
  8657. return valNode.childNodes[0].nodeValue;
  8658. }else{
  8659. return defaultValue;
  8660. }
  8661. } else{
  8662. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  8663. return defaultValue;
  8664. }
  8665. }
  8666. function getUniqueStringValueBySelector(selector){
  8667. return getUniqueValueBySelector(selector,"");
  8668. }
  8669. function getUniqueIntValueBySelector(selector){
  8670. var ret = getUniqueValueBySelector(selector,0);
  8671. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  8672. ret = 0;
  8673. }
  8674. return parseInt(ret);
  8675. }
  8676. function getUniqueFloatValueBySelector(selector){
  8677. var ret = getUniqueValueBySelector(selector,0.0);
  8678. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  8679. ret = 0.0;
  8680. }
  8681. return parseFloat(ret);
  8682. }
  8683.  
  8684.  
  8685. function resiste(Ddeg,bm) {
  8686. // version naive mais compréhensible ^^
  8687. // DEBUG: à revoir
  8688. if(!bm) {
  8689. return 2*Math.floor(Ddeg/2);
  8690. }
  8691. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  8692. }
  8693.  
  8694. function retourAZero(fatig) {
  8695. var fat = fatig, raz = 0;
  8696. while(fat>0) {
  8697. raz++;
  8698. fat = Math.floor(fat/1.25);
  8699. }
  8700. return raz;
  8701. }
  8702.  
  8703. function decumulPumPrem(bonus) {
  8704. switch(bonus) {
  8705. case 20: return 33;
  8706. case 33: return 41;
  8707. case 41: return 46;
  8708. case 46: return 49;
  8709. case 49: return 51;
  8710. default: return 20;
  8711. }
  8712. }
  8713.  
  8714. function coefDecumul(i) {
  8715. switch(i) {
  8716. case 2: return 0.67;
  8717. case 3: return 0.4;
  8718. case 4: return 0.25;
  8719. case 5: return 0.15;
  8720. default: return 0.1;
  8721. }
  8722. }
  8723.  
  8724. function dureeHM(dmin) {
  8725. var ret = "";
  8726. dmin = Math.floor(dmin);
  8727. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  8728. var mins = dmin%60;
  8729. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  8730. return (ret) ? ret : "-";
  8731. }
  8732.  
  8733.  
  8734. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  8735.  
  8736. function extractionDonnees() {
  8737. // Variables temporaires
  8738. var Nbrs = {};
  8739.  
  8740. // *********************
  8741. // Cadre "Description"
  8742. // *********************
  8743. race = getUniqueStringValueBySelector('#descr #race');
  8744. debugMZ("Race : " + race);
  8745. idtroll = getUniqueStringValueBySelector('#descr #id');
  8746. debugMZ("Id troll : " + idtroll);
  8747. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  8748. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  8749. datecrea = new Date(StringToDate(strDateCrea));
  8750. debugMZ("Date creation : " + datecrea);
  8751.  
  8752. // *******************
  8753. // Cadre "Experience"
  8754. // *******************
  8755. // Niveau de troll
  8756. niv = getUniqueIntValueBySelector('#exp #niv');
  8757. nivTroll = niv;
  8758. debugMZ("Niveau : " + niv);
  8759. // PX
  8760. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  8761. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  8762. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  8763. // PI
  8764. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  8765. pitotal = parseInt(document.querySelector('#exp #pi').parentElement.nextElementSibling.childNodes[2].textContent);
  8766. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  8767. // Meutres/Morts
  8768. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  8769. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  8770. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  8771.  
  8772. // *********************
  8773. // Cadre "Tour de Jeu"
  8774. // *********************
  8775. // DLA
  8776. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  8777. DLA = new Date(StringToDate(Nbrs["dla"]));
  8778. debugMZ("DLA: " + DLA);
  8779. // DLA suivante
  8780. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  8781. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  8782. debugMZ("DLAsuiv: " + DLAsuiv);
  8783. // Duree normale de mon Tour
  8784. Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  8785. dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  8786. debugMZ("Duree normale de mon Tour : " + dtb);
  8787. // Bonus/Malus sur la duree
  8788. Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  8789. bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  8790. debugMZ("Bonus/Malus sur la duree : " + bmt);
  8791. // Augmentation due aux blessures
  8792. Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  8793. adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  8794. debugMZ("Augmentation due aux blessures : " + adb);
  8795. // Poids de l'equipement
  8796. Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  8797. pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  8798. debugMZ("Poids de l'equipement : " + pdm);
  8799. // Duree de mon prochain Tour
  8800. Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  8801. dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  8802. debugMZ('Duree de mon prochain Tour : ' + dpt);
  8803.  
  8804. // ****************
  8805. // Cadre "Etats"
  8806. // ****************
  8807. // Position du troll :
  8808. posX = getUniqueIntValueBySelector('#pos #x');
  8809. posY = getUniqueIntValueBySelector('#pos #y');
  8810. posN = getUniqueIntValueBySelector('#pos #n');
  8811. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  8812. // PV actuel
  8813. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  8814. pvActuelKastar = pvcourant;
  8815. debugMZ("PV actuel : " + pvcourant)
  8816. // Fatigue
  8817. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  8818. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  8819. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  8820.  
  8821. // **************************
  8822. // Cadre "Caracteristiques"
  8823. // **************************
  8824. // Attaque
  8825. att = getUniqueIntValueBySelector('#carac #att');
  8826. attbp = getUniqueIntValueBySelector('#carac #att_p');
  8827. attbm = getUniqueIntValueBySelector('#carac #att_m');
  8828. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  8829. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  8830. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  8831. attmoy = 3.5*att + attbp + attbm;
  8832. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  8833. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  8834. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  8835. // Esquive
  8836. esq = getUniqueIntValueBySelector('#carac #esq');
  8837. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  8838. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  8839. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  8840. esqmoy = 3.5*esq + esqbp+esqbm;
  8841. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  8842. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  8843. // Degat
  8844. deg = getUniqueIntValueBySelector('#carac #deg');
  8845. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  8846. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  8847. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  8848. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  8849. degmoy = 2*deg + degbp+degbm;
  8850. degmoycrit = 3*deg + degbp+degbm;
  8851. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  8852. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  8853. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  8854. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  8855. // PV
  8856. pvbase = getUniqueIntValueBySelector('#carac #pv');
  8857. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  8858. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  8859. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  8860. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  8861. // Regeneration
  8862. reg = getUniqueIntValueBySelector('#carac #reg');
  8863. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  8864. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  8865. regmoy = 2 * reg + regbp + regbm; // D3
  8866. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  8867. // Armure
  8868. arm = getUniqueIntValueBySelector('#carac #arm');
  8869. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  8870. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  8871. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  8872. armmoy = 2*arm + armbp+armbm;
  8873. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  8874. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  8875. // TODO : D d'armure non active
  8876. // Vue
  8877. vue = getUniqueIntValueBySelector('#carac #vue');
  8878. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  8879. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  8880. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  8881. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  8882. // RM
  8883. rm = getUniqueIntValueBySelector('#carac #rm');
  8884. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  8885. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  8886. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  8887. rmTroll = rmtotale;
  8888. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  8889. // MM
  8890. mm = getUniqueIntValueBySelector('#carac #mm');
  8891. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  8892. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  8893. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  8894. mmTroll = mmtotale;
  8895. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  8896.  
  8897. // Heure Serveur
  8898. try {
  8899. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  8900. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  8901. HeureServeur = new Date(StringToDate(heureServeurSTR));
  8902. } catch (e) {
  8903. window.console.warn(
  8904. "[MZ] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  8905. );
  8906. HeureServeur = new Date();
  8907. }
  8908. debugMZ("HeureServeur: " + HeureServeur);
  8909.  
  8910. // ***INIT GLOBALE*** NBjours
  8911. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  8912.  
  8913. // Calcul debut lien anatroliseur avec les caracteristiques connues
  8914. var amelio_dtb = function(dtb) {
  8915. if(dtb>555) {
  8916. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  8917. }
  8918. return 10+Math.ceil((555-dtb)/2.5);
  8919. },
  8920. amelio_pv = Math.floor(pvbase/10)-3,
  8921. amelio_vue = vue-3,
  8922. amelio_att = att-3,
  8923. amelio_esq = esq-3,
  8924. amelio_deg = deg-3,
  8925. amelio_reg = reg-1,
  8926. amelio_arm = arm-1;
  8927. if(race==="Darkling"){amelio_reg--; }
  8928. if(race==="Durakuir"){amelio_pv-- ; }
  8929. if(race==="Kastar") {amelio_deg--; }
  8930. if(race==="Skrim") {amelio_att--; }
  8931. if(race==="Tomawak") {amelio_vue--; }
  8932.  
  8933. urlAnatrolliseur = URL_AnatrolDispas
  8934. +"outils_anatrolliseur.php?anatrolliseur=v8"
  8935. +"|r="+race.toLowerCase()
  8936. +"|dla="+amelio_dtb(dtb)
  8937. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  8938. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  8939. +"|att="+amelio_att+","+attbp+","+attbm
  8940. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  8941. +"|deg="+amelio_deg+","+degbp+","+degbm
  8942. +"|reg="+amelio_reg+","+regbp+","+regbm
  8943. +"|arm="+amelio_arm+","+armbp+","+armbm
  8944. +"|mm="+mmtotale
  8945. +"|rm="+rmtotale+"|";
  8946. }
  8947.  
  8948. function saveProfil() {
  8949. MY_setValue(idtroll+'.caracs.attaque',att);
  8950. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  8951. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  8952. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  8953. if(atttourD||atttourP||atttourM) {
  8954. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  8955. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  8956. }
  8957. MY_setValue(idtroll+'.caracs.esquive',esq);
  8958. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  8959. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  8960. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  8961. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  8962. MY_setValue(idtroll+'.caracs.degats',deg);
  8963. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  8964. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  8965. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  8966. if(degtourP||degtourM){
  8967. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  8968. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  8969. }
  8970. MY_setValue(idtroll+'.caracs.regeneration',reg);
  8971. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  8972. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  8973. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  8974. MY_setValue(idtroll+'.caracs.vue',vue);
  8975. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  8976. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  8977. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  8978. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  8979. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  8980. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  8981. MY_setValue(idtroll+'.caracs.rm',rm);
  8982. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  8983. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  8984. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  8985. MY_setValue(idtroll+'.caracs.mm',mm);
  8986. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  8987. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  8988. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  8989. MY_setValue(idtroll+'.caracs.armure',arm);
  8990. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  8991. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  8992. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  8993. MY_setValue(idtroll+'.position.X',posX);
  8994. MY_setValue(idtroll+'.position.Y',posY);
  8995. MY_setValue(idtroll+'.position.N',posN);
  8996. MY_setValue(idtroll+'.race',race);
  8997. MY_setValue(idtroll+'.niveau',niv);
  8998. }
  8999.  
  9000.  
  9001. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  9002.  
  9003. function setInfosCaracteristiques() {
  9004. // Modification de l'entete
  9005. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  9006. thTotal.innerHTML+='|<i>Moyenne</i>';
  9007. thTotal.title="Moyenne (Moyenne ce tour)";
  9008.  
  9009. // Ajout des informations calculees
  9010. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  9011. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  9012. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  9013.  
  9014. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  9015. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  9016. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  9017.  
  9018. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  9019. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  9020. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  9021.  
  9022. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  9023. var tdRegTotal = trRegeneration.children[5];
  9024. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  9025. // Temps recupere par reg (propale R')
  9026. var regmoyTemp = Math.max(0, regmoy);
  9027. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  9028. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  9029. if (sec != 0) {
  9030. regTitle += " " + sec + " sec";
  9031. }
  9032. trRegeneration.title = regTitle;
  9033.  
  9034. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  9035. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  9036. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  9037.  
  9038. var trRM=document.querySelector("table#caracs #rm").parentElement;
  9039. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  9040. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  9041.  
  9042.  
  9043. var trMM=document.querySelector("table#caracs #mm").parentElement;
  9044. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  9045. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  9046.  
  9047. var tdRefl=document.querySelector("#refl");
  9048. // TODO : prendre en compte bonus/malus D esq du tour ?
  9049. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  9050. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  9051. }
  9052.  
  9053. function setLienAnatrolliseur(){
  9054. var pTableAmelio = document.querySelector("#carac>div>p");
  9055. pTableAmelio.innerHTML+=" - ";
  9056. var aElt = document.createElement("a");
  9057. aElt.setAttribute("href",urlAnatrolliseur);
  9058. aElt.setAttribute("target","_blank");
  9059. aElt.className="AllLinks";
  9060. aElt.innerHTML="Anatrolliser";
  9061. pTableAmelio.appendChild(aElt);
  9062. }
  9063. function setInfoDescription() {
  9064. var txtDateCrea = (NBjours!=1) ?
  9065. " ("+NBjours+" jours dans le hall)" :
  9066. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  9067. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  9068. }
  9069.  
  9070. function setInfosEtatLieux() {
  9071. var urlBricol = URL_MZmountyhall + 'lieux.php'+
  9072. '?search=position&orderBy=distance&posx='+
  9073. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  9074. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  9075. appendBr(tdPosition);
  9076. var aElt = document.createElement("a");
  9077. aElt.setAttribute("href",urlBricol);
  9078. aElt.setAttribute("target","_blank");
  9079. aElt.className="AllLinks";
  9080. aElt.innerHTML="Lieux à proximité";
  9081. tdPosition.appendChild(aElt);
  9082. }
  9083.  
  9084. function setInfosEtatPV() { // pour AM et Sacro
  9085. var
  9086. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  9087. sec = Math.floor(15000/pvtotal)%60,
  9088. lifebar = document.querySelector("#pos .barre-vie");
  9089. if(sec!=0) { txt += " "+sec+" sec"; }
  9090. if(lifebar) { lifebar.title = txt; }
  9091. if(pvcourant<=0) { return; }
  9092. // Difference PV p/r a equilibre de temps (propale R')
  9093. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  9094. // ***INIT GLOBALE*** pvdispo
  9095. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  9096. var span = document.createElement("span");
  9097. span.title = txt;
  9098. span.style.fontStyle = "italic";
  9099. if(bmt+pdm>=0) {
  9100. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  9101. } else if(pvdispo>0) {
  9102. txt = "Vous pouvez encore perdre "+
  9103. Math.min(pvdispo,pvcourant)+
  9104. " PV sans malus de temps.";
  9105. } else if(pvdispo<0) {
  9106. txt = "Il vous manque "
  9107. +(-pvdispo)
  9108. +" PV pour ne plus avoir de malus de temps.";
  9109. } else {
  9110. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  9111. }
  9112. appendText(span,txt);
  9113. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  9114. }
  9115.  
  9116. // Complete le cadre "Experience"
  9117. function setInfosExp() {
  9118. var tdNiv = document.querySelector("#exp #niv");
  9119.  
  9120. // Calcul niveau monstre/troll min pour gain PX
  9121. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  9122. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  9123.  
  9124. // Calcul PX restant
  9125. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  9126. if (pxRestant >= 0) {
  9127. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  9128. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  9129. }
  9130.  
  9131. // Calul pi/jour
  9132. var
  9133. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  9134. tdPi = document.querySelector("#exp #pi").parentElement;
  9135. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  9136. tdPi.title = tdPiTotal.title;
  9137.  
  9138. // Rapports meurtres,morts
  9139. var tdKill = document.querySelector("#exp #kill");
  9140. tdKill.setAttribute("colspan", 1);
  9141. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  9142.  
  9143. var tdMort = document.querySelector("#exp #mort");
  9144. tdMort.setAttribute("colspan", 1);
  9145. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  9146.  
  9147. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  9148. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  9149. }
  9150.  
  9151.  
  9152. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  9153.  
  9154. function minParPVsac(fat,bm) {
  9155. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  9156. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  9157. var out = [];
  9158. out[0] = (fat>4) ?
  9159. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  9160. 30;
  9161. if(bm && bm>0) {
  9162. var totalfat=fat+bm;
  9163. out[1] = (totalfat>4) ?
  9164. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  9165. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  9166. }
  9167. return out;
  9168. }
  9169.  
  9170. function toInt(str) {
  9171. str = parseInt(str);
  9172. return (str) ? str : 0;
  9173. }
  9174.  
  9175. function saveLastDLA() {
  9176. // pour les calculs d'AM max
  9177. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  9178. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  9179. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  9180. lastDLA = new Date( StringToDate(str) );
  9181. MY_setValue(numTroll+'.DLA.ancienne',str);
  9182. lastDLAZone.innerHTML = '';
  9183. var b = document.createElement('b');
  9184. b.addEventListener('click',inputMode,false);
  9185. appendText(b,str);
  9186. lastDLAZone.appendChild(b);
  9187. refreshAccel();
  9188. }
  9189.  
  9190. function inputMode() {
  9191. // Edition manuelle lastDLA
  9192. var date;
  9193. if(lastDLA)
  9194. date = new Date( lastDLA );
  9195. else
  9196. date = new Date( DLAaccel );
  9197. lastDLAZone.innerHTML = '';
  9198. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  9199. appendText(lastDLAZone,'/');
  9200. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  9201. appendText(lastDLAZone,'/');
  9202. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  9203. appendText(lastDLAZone,' - ');
  9204. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  9205. appendText(lastDLAZone,':');
  9206. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  9207. appendText(lastDLAZone,':');
  9208. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  9209. appendText(lastDLAZone,' - ');
  9210. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  9211. }
  9212.  
  9213. function setAccel() {
  9214. var
  9215. BMfrais=false,
  9216. fat=fatigue, listeBmFat=[],
  9217. tr, th, insertPt;
  9218.  
  9219. // Creation ligne speciale pour AM dans le cadre "Etat"
  9220. tr = document.createElement('tr');
  9221. th = document.createElement('th');
  9222. appendText(th,'Fatigue et AM',true);
  9223. tr.appendChild(th);
  9224. insertPt = document.createElement('td');
  9225. tr.appendChild(insertPt);
  9226. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  9227.  
  9228. // Est-on en over-DLA ?
  9229. // ***INIT GLOBALE*** overDLA
  9230. overDLA = (HeureServeur>DLA.getTime()+3e5);
  9231. if(overDLA) {
  9232. fat=Math.floor(fatigue/1.25);
  9233. }
  9234.  
  9235. // Gestion des BM de fatigue
  9236. if(bmfatigue>0) {
  9237. // On tente de recuperer les BM de fatigue de la page des BM
  9238. if(MY_getValue(numTroll+'.bm.fatigue')) {
  9239. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  9240. BMmemoire.pop();
  9241. var tour = 0;
  9242. for(var i=0 ; i<BMmemoire.length ; i++) {
  9243. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  9244. while(tour<=parseInt(nbrs[0])) {
  9245. listeBmFat[tour]=parseInt(nbrs[1]);
  9246. tour++;
  9247. }
  9248. }
  9249. }
  9250. if(listeBmFat[0]==bmfatigue) {
  9251. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  9252. BMfrais = true;
  9253. MY_removeValue(numTroll+".bm.fatigue");
  9254. }
  9255. } else {
  9256. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  9257. BMfrais = true;
  9258. }
  9259. if(!BMfrais && bmfatigue>0) {
  9260. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  9261. if(bmfatigue==15) {
  9262. listeBmFat = [15,15,15];
  9263. } else {
  9264. listeBmFat = [30,30,15];
  9265. }
  9266. }
  9267. if(overDLA) {
  9268. // Si on est en over-DLA, on decale les bm d'un tour
  9269. listeBmFat.shift();
  9270. }
  9271. // Tableau des fatigues et accel futures
  9272. var
  9273. minppv = minParPVsac(fat,listeBmFat[0]),
  9274. table, tbody,
  9275. ligneTour, ligneFat, ligneMin,
  9276. col;
  9277. // ***INIT GLOBALE*** minParPV
  9278. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  9279. if(fat>0 || listeBmFat[0]>0) {
  9280. table = document.createElement('table');
  9281. table.className = 'mh_tdborder';
  9282. table.border = 0;
  9283. table.cellSpacing = 1;
  9284. table.cellPadding = 1;
  9285. table.style.textAlign = "center";
  9286. tbody = document.createElement('tbody');
  9287. table.appendChild(tbody);
  9288. insertPt.appendChild(table);
  9289. ligneTour = appendTr(tbody,'mh_tdtitre');
  9290. ligneTour.style.fontWeight = "bold";
  9291. var td = appendTdText(ligneTour,'Tour :',true);
  9292. td.align = 'left';
  9293. ligneFat = appendTr(tbody,'mh_tdpage');
  9294. td = appendTdText(ligneFat,'Fatigue :',true);
  9295. td.className = 'mh_tdtitre';
  9296. td.align = 'left';
  9297. ligneMin = appendTr(tbody,'mh_tdpage');
  9298. td = appendTdText(ligneMin,'1 PV =',true);
  9299. td.className = 'mh_tdtitre';
  9300. td.align = 'left';
  9301. col=0;
  9302. while(col<9 && (fat>0 || listeBmFat[col])) {
  9303. if(col==0) {
  9304. if(overDLA) {
  9305. var i = document.createElement('i');
  9306. appendText(i,'A activer');
  9307. ligneTour.appendChild(i);
  9308. } else {
  9309. appendTdText(ligneTour,'En cours');
  9310. }
  9311. } else {
  9312. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9313. }
  9314. if(listeBmFat[col]) {
  9315. if(BMfrais || (!overDLA && col==0)) {
  9316. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  9317. appendTdText(ligneMin,minppv[1]+'\'');
  9318. } else {
  9319. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  9320. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  9321. }
  9322. } else {
  9323. appendTdText(ligneFat,fat);
  9324. appendTdText(ligneMin,minppv[0]+'\'');
  9325. }
  9326. col++;
  9327. fat = Math.floor(fat / 1.25);
  9328. minppv = minParPVsac(fat,listeBmFat[col]);
  9329. }
  9330. if(fat>1 || (fat==1 && !overDLA)) {
  9331. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  9332. appendTdText(ligneFat,'-');
  9333. appendTdText(ligneMin,'-');
  9334. }
  9335. col = (overDLA) ?
  9336. Math.max(retourAZero(fatigue)-1,col) :
  9337. Math.max(retourAZero(fatigue),col);
  9338. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9339. appendTdText(ligneFat,'0');
  9340. appendTdText(ligneMin,'30\'');
  9341. if(!BMfrais && bmfatigue) {
  9342. // si les BM n'ont pas ete rafraichis, on signale:
  9343. appendText(
  9344. insertPt,
  9345. '/!\\ Visitez la page des Bonus/Malus '+
  9346. 'pour mettre à jour votre fatigue. /!\\',
  9347. true
  9348. );
  9349. appendBr(insertPt);
  9350. }
  9351. appendBr(insertPt);
  9352. }
  9353. if(pvcourant<=0) {
  9354. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  9355. return;
  9356. }
  9357. if(fatigue>30) {
  9358. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  9359. return;
  9360. }
  9361. // Setup lastDLAZone
  9362. if(overDLA) {
  9363. // bypass des infos de "menu_FF.js" en cas d'overDLA
  9364. DLAaccel = new Date( DLAsuiv );
  9365. lastDLA = new Date( DLA );
  9366. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  9367. // ***INIT GLOBALE*** pvActuelKastar
  9368. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  9369. appendText(
  9370. insertPt,
  9371. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  9372. true
  9373. );
  9374. appendBr(insertPt);
  9375. } else {
  9376. DLAaccel = new Date( DLA );
  9377. pvActuelKastar = pvcourant;
  9378. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  9379. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  9380. } else {
  9381. lastDLA = false;
  9382. }
  9383. }
  9384. appendText(insertPt,'Dernière DLA enregistrée : ');
  9385. lastDLAZone = document.createElement('span');
  9386. lastDLAZone.style.cursor = 'pointer';
  9387. var b = document.createElement('b');
  9388. b.onclick = inputMode;
  9389. lastDLAZone.appendChild(b);
  9390. insertPt.appendChild(lastDLAZone);
  9391. if(lastDLA) {
  9392. appendText(b,DateToString(lastDLA));
  9393. } else {
  9394. appendText(b,'aucune');
  9395. }
  9396. appendBr(insertPt);
  9397. // Setup maxAMZone et cumulZone
  9398. appendText(insertPt,'Accélération maximale possible : ');
  9399. maxAMZone = document.createElement('b');
  9400. insertPt.appendChild(maxAMZone);
  9401. appendBr(insertPt);
  9402. cumulZone = document.createElement('span');
  9403. insertPt.appendChild(cumulZone);
  9404. refreshAccel();
  9405. }
  9406.  
  9407. function refreshAccel() {
  9408. var pvs, pvsmax;
  9409. // Acceleration pour cumul instantane
  9410. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  9411. if(lastDLA) {
  9412. pvsmax = Math.min(
  9413. pvActuelKastar-1,
  9414. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  9415. );
  9416. maxAMZone.innerHTML = pvsmax+" PV";
  9417. } else {
  9418. pvsmax = pvActuelKastar-1;
  9419. maxAMZone.innerHTML = "inconnue";
  9420. }
  9421. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  9422. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  9423. cumulZone.innerHTML = '';
  9424. if(pvs<=pvsmax) {
  9425. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  9426. appendText(cumulZone,pvs+' PV', true);
  9427. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  9428. if(pvs!=1) {
  9429. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  9430. -(pvs-1)*60*minParPV;
  9431. appendText(
  9432. cumulZone,
  9433. ' ('+(pvs-1)+' PV dans '+
  9434. Math.floor(gainSec/60)+'min'+
  9435. addZero(gainSec%60)+'s)'
  9436. );
  9437. }
  9438. } else {
  9439. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  9440. appendText(
  9441. cumulZone,
  9442. 'Après votre accélération maximale, il vous faudra encore attendre '+
  9443. dureeHM(avantDLA/6e4)+
  9444. ' avant de réactiver.'
  9445. );
  9446. }
  9447. }
  9448.  
  9449.  
  9450. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  9451.  
  9452. function traitementTalents() {
  9453. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  9454. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  9455. removeAllTalents();
  9456. var totalComp = injecteInfosBulles(trCompetence,'competences');
  9457. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  9458. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  9459. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  9460. }
  9461.  
  9462. function injecteInfosBulles(liste,fonction) {
  9463. var totalpc = 0;
  9464. // on parse la liste des talents du type 'fonction'
  9465. for(var i=0 ; i<liste.length ; i++) {
  9466. var
  9467. trTalent=liste[i],
  9468. node=trTalent.cells[1].querySelector('a'),
  9469. nomTalent=epure(trim(node.textContent)),
  9470. indiceTDniveaux=7,
  9471. indiceTDSousCompetence=2,
  9472. sousCompetences=undefined;
  9473. if(fonction=="competences"){
  9474. // un TD en plus pour des information complementaire liees a la comp
  9475. indiceTDniveaux++;
  9476. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  9477. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  9478. for (var j=0; j < sousCompetences.length; j++) {
  9479. sousCompetences[j] = sousCompetences[j].epure().trim();
  9480. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  9481. }
  9482. }
  9483. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  9484. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  9485. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  9486. totalpc += niveauxMaitrisesTalentArray[1];
  9487.  
  9488. // stockage des niveaux inferieurs du talent si presents
  9489. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  9490. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  9491. totalpc+=niveauxMaitrisesTalentArray[j+1];
  9492. }
  9493. }
  9494. return totalpc;
  9495. }
  9496.  
  9497. function setInfos(node,nom,fonction,niveau) {
  9498. node.nom = nom;
  9499. node.fonction = fonction;
  9500. node.niveau = niveau;
  9501. node.onmouseover = setBulle;
  9502. node.onmouseout = cacherBulle;
  9503. }
  9504.  
  9505. var arrayModifAnatroll = {
  9506. 'Glue':'Glu',
  9507. 'PuM':'PuiM',
  9508. 'HE':'Hurlement',
  9509. //'Insultes':'Insu',
  9510. 'Pistage':'Pist',
  9511. 'PuC':'Planter'
  9512. }
  9513.  
  9514. function setTalent(nom,pc,niveau,sousCompetences) {
  9515. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  9516. // (et pas les % dont osf) ne serait pas plus rentable
  9517. var nomEnBase = arrayTalents[epure(nom)];
  9518. if(!nomEnBase) { return; }
  9519. if(!niveau) { niveau = 1; }
  9520. switch(nomEnBase) {
  9521. case 'Insultes':
  9522. urlAnatrolliseur += 'Insu'+niveau+'|';
  9523. case 'IdT':
  9524. nomEnBase += niveau;
  9525. break;
  9526. case 'Golemo':
  9527. case 'Piege':
  9528. for (var i=0 ; i < sousCompetences.length ; i++) {
  9529. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  9530. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  9531. }
  9532. break;
  9533. case 'AP':
  9534. case 'Baroufle':
  9535. case 'CdB':
  9536. case 'CdM':
  9537. case 'Parer':
  9538. case 'Retraite':
  9539. case 'RB':
  9540. case 'SInterposer':
  9541. nomEnBase += niveau;
  9542. default:
  9543. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  9544. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  9545. }
  9546. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  9547. }
  9548.  
  9549. function creerBulleVide() {
  9550. var table = document.createElement('table');
  9551. table.id = 'bulle';
  9552. table.className = 'mh_tdborder';
  9553. table.width = 300;
  9554. table.border = 0;
  9555. table.cellPadding = 5;
  9556. table.cellSpacing = 1;
  9557. table.style =
  9558. 'position:absolute;'
  9559. +'visibility:hidden;'
  9560. +'z-index:800;'
  9561. +'height:auto;';
  9562. var tr = appendTr(table,'mh_tdtitre');
  9563. appendTdText(tr,'Titre');
  9564. tr = appendTr(table,'mh_tdpage');
  9565. appendTdText(tr,'Contenu');
  9566. var aList = document.getElementsByTagName('a');
  9567. aList[aList.length-1].parentNode.appendChild(table);
  9568. }
  9569.  
  9570. function cacherBulle() {
  9571. if(bulleStyle)
  9572. bulleStyle.visibility = 'hidden';
  9573. }
  9574.  
  9575. function setBulle(evt) {
  9576. var nom = this.nom;
  9577. var fonction = this.fonction;
  9578. var niveau = parseInt(this.niveau);
  9579. var str='';
  9580. if(fonction=='competences'){
  9581. str=competences(nom,niveau);
  9582. } else if(fonction=='sortileges') {
  9583. str=sortileges(nom,true);
  9584. }
  9585. if(str=='') return;
  9586. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  9587. var xfenetre, yfenetre, xpage, ypage, element = null;
  9588. var offset = 15;
  9589. var bulleWidth = 300;
  9590. if(!hauteur) hauteur = 50;
  9591. element = document.getElementById('bulle');
  9592. xfenetre = evt.clientX;
  9593. yfenetre = evt.clientY;
  9594. xpage = xfenetre;
  9595. ypage = yfenetre;
  9596. if(evt.pageX) xpage = evt.pageX;
  9597. if(evt.pageY) ypage = evt.pageY;
  9598. if(element) {
  9599. bulleStyle = element.style;
  9600. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  9601. element.childNodes[1].firstChild.innerHTML = str;
  9602. }
  9603. if(bulleStyle) {
  9604. if(xfenetre>bulleWidth+offset)
  9605. xpage -= bulleWidth+offset;
  9606. else
  9607. xpage += offset;
  9608. if(yfenetre>hauteur+offset)
  9609. ypage -= hauteur + offset;
  9610. bulleStyle.width = bulleWidth;
  9611. bulleStyle.left = xpage + 'px';
  9612. bulleStyle.top = ypage + 'px';
  9613. bulleStyle.visibility = 'visible';
  9614. }
  9615. }
  9616.  
  9617.  
  9618. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  9619.  
  9620. function competences(comp,niveau) {
  9621. var texte = '';
  9622. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  9623. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  9624. if(minParPV>1) texte += 's';
  9625. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  9626. }
  9627. else if(comp.indexOf('Attaque Precise')!=-1) {
  9628. var pc, lastmax=0, espatt=0;
  9629. var notMaxedOut = false;
  9630. for(var i=niveau ; i>0 ; i--) {
  9631. pc = getTalent(comp,i);
  9632. if(lastmax!=0 && pc<=lastmax) continue;
  9633. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  9634. attbp+attbm;
  9635. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  9636. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  9637. ' => <b>'+jetatt+'</b><br/>';
  9638. espatt += (pc-lastmax)*jetatt;
  9639. lastmax = pc;
  9640. if(i<niveau) notMaxedOut = true;
  9641. }
  9642. if(notMaxedOut) {
  9643. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  9644. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  9645. }
  9646. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  9647. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  9648. }
  9649. else if(comp.indexOf('Balayage')!=-1)
  9650. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  9651. +' => <b>'+attmoy+'</b><br/>'
  9652. +'Effet : <b>Met à terre l\'adversaire</b>';
  9653. else if(comp.indexOf('Bidouille')!=-1)
  9654. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  9655. +'de votre inventaire avec le texte de votre choix.';
  9656. else if(comp.indexOf('Baroufle')!=-1){
  9657. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  9658. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  9659. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  9660. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  9661. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  9662. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  9663. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  9664. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  9665. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  9666. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  9667. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  9668. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  9669. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  9670. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  9671. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  9672. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  9673. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  9674. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  9675. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  9676. '</tbody></table>';
  9677. }
  9678. else if(comp.indexOf('Botte Secrete')!=-1){
  9679. texte = 'Attaque : <b>'
  9680. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  9681. +' => <b>'
  9682. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  9683. +'</b><br/>Dégâts : <b>'
  9684. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  9685. +' => <b>'
  9686. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  9687. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  9688. +'</b>';
  9689. }
  9690. else if(comp.indexOf('Camouflage')!=-1) {
  9691. var camou = getTalent('Camouflage');
  9692. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  9693. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  9694. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  9695. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  9696. }
  9697. else if(comp.indexOf('Charger')!=-1) {
  9698. if(pvcourant<=0)
  9699. return '<i>On ne peut charger personne quand on est mort !</i>';
  9700. var portee = Math.min(
  9701. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  9702. vuetotale);
  9703. if(portee<1)
  9704. return '<b>Impossible de charger</b>';
  9705. else {
  9706. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  9707. +' => <b>'+attmoy+'</b><br/>'
  9708. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  9709. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  9710. +'<br/>Portée : <b>'+portee+'</b> case';
  9711. if(portee>1) texte += 's';
  9712. }
  9713. }
  9714. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  9715. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  9716. if(vuetotale>1) texte += 's';
  9717. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  9718. if(vuetotale>2) texte += 's';
  9719. }
  9720. else if(comp.indexOf('Piege')!=-1) {
  9721. if(comp.indexOf('Glue')!=-1)
  9722. texte = 'Et si vous colliez vos adversaires au sol ?';
  9723. if(comp.indexOf('Feu')!=-1) {
  9724. if(texte){
  9725. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  9726. }
  9727. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  9728. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  9729. }
  9730. }
  9731. else if(comp.indexOf('Contre-Attaquer')!=-1){
  9732. texte = 'Attaque : <b>'
  9733. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  9734. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  9735. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  9736. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  9737. }
  9738. else if(comp.indexOf('Coup de Butoir')!=-1) {
  9739. var pc, lastmax=0, espdeg=0;
  9740. var notMaxedOut = false;
  9741. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  9742. +' => <b>'+attmoy+'</b>';
  9743. for(var i=niveau ; i>0 ; i--) {
  9744. pc = getTalent(comp,i);
  9745. if(lastmax!=0 && pc<=lastmax) continue;
  9746. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  9747. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  9748. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  9749. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  9750. espdeg += (pc-lastmax)*jetdeg;
  9751. lastmax = pc;
  9752. if(i<niveau) notMaxedOut = true;
  9753. }
  9754. if(notMaxedOut) {
  9755. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  9756. Math.floor(10*espdeg/lastmax)/10+'/'+
  9757. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  9758. }
  9759. }
  9760. else if(comp.indexOf('Course')!=-1)
  9761. texte = 'Déplacement gratuit : <b>'
  9762. +Math.floor(getTalent('Course')/2)
  9763. +' %</b> de chance';
  9764. else if(comp.indexOf('Deplacement Eclair')!=-1)
  9765. texte = 'Permet d\'économiser <b>1</b> PA '
  9766. +'par rapport au déplacement classique';
  9767. else if(comp.indexOf('Dressage')!=-1)
  9768. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  9769. +'ou un gnu sauvage.';
  9770. else if(comp.indexOf('Ecriture Magique')!=-1)
  9771. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  9772. +'la formule nécessite de réunir les composants de cette formule, '
  9773. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  9774. +'un champignon adéquat pour confectionner l\'encre.';
  9775. else if(comp.indexOf('Frenesie')!=-1) {
  9776. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  9777. +' => <b>'+attmoy+'</b><br/>'
  9778. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  9779. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  9780. }
  9781. else if(comp.indexOf('Golem')!=-1)
  9782. texte = 'Animez votre golem en assemblant divers matériaux '
  9783. +'autour d\'un cerveau minéral.'
  9784. else if(comp.indexOf('Grattage')!=-1) {
  9785. texte = 'Permet de confectionner un Parchemin Vierge '
  9786. +'à partir de composants et de Gigots de Gob\'.';
  9787. }
  9788. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  9789. texte = 'Fait fuir un monstre si tout se passe bien.'
  9790. +'<br/>Lui donne de gros bonus sinon...';
  9791. else if(comp.indexOf('Identification des Champignons')!=-1) {
  9792. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  9793. if(vuetotale>2) texte += 's';
  9794. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  9795. if(vuetotale>4) texte += 's';
  9796. }
  9797. else if(comp.indexOf('Insultes')!=-1)
  9798. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  9799. else if(comp.indexOf('interposer')!=-1)
  9800. texte = 'Jet de réflexe : <b>'
  9801. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  9802. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  9803. else if(comp.indexOf('Lancer de Potions') != -1)
  9804. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  9805. else if(comp.indexOf('Marquage')!=-1)
  9806. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  9807. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  9808. +'se trouver dans la même caverne que le monstre pour le marquer.';
  9809. else if(comp.indexOf('Melange Magique')!=-1)
  9810. texte = 'Cette Compétence permet de combiner deux Potions pour '
  9811. +'en réaliser une nouvelle dont l\'effet est la somme '
  9812. +'des effets des potions initiales.';
  9813. else if(comp.indexOf('Miner')!=-1)
  9814. texte = 'Portée horizontale (officieuse) : <b>'
  9815. +2*vuetotale+'</b> cases<br/>'
  9816. +'Portée verticale (officieuse) : <b>'
  9817. +2*Math.ceil(vuetotale/2)+'</b> cases';
  9818. else if(comp.indexOf('Necromancie')!=-1)
  9819. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  9820. +'de faire "revivre" ce monstre.';
  9821. else if(comp.indexOf('Painthure de Guerre')!=-1)
  9822. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  9823. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  9824. +'pour s\'inspirer, et laissez parler votre créativité.'
  9825. else if(comp.indexOf('Parer')!=-1)
  9826. texte = 'Jet de parade : <b>'
  9827. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  9828. +' => <b>'
  9829. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  9830. +'</b><hr><i>Equivalent esquive : <b>'
  9831. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  9832. +' => <b>'
  9833. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  9834. +'</b></i>';
  9835. else if(comp.indexOf('Pistage')!=-1)
  9836. texte = 'Portée horizontale : <b>'
  9837. +2*vuetotale+'</b> cases<br/>'
  9838. +'Portée verticale : <b>'
  9839. +2*Math.ceil(vuetotale/2)+'</b> cases';
  9840. else if(comp.indexOf('Planter un Champignon')!=-1)
  9841. texte = 'Planter un Champignon est une compétence qui vous permet de '
  9842. +'créer des colonies d\'une variété donnée de champignon à partir de '
  9843. +'quelques exemplaires préalablement enterrés.';
  9844. else if(comp.indexOf('Regeneration Accrue')!=-1)
  9845. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  9846. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  9847. else if(comp.indexOf('Reparation')!=-1)
  9848. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  9849. +'et réparez vous-même votre matériel !';
  9850. else if(comp.indexOf('Retraite')!=-1)
  9851. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  9852. +'préférable de préparer un repli stratégique pour déconcerter '
  9853. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  9854. +'Quelle intelligence démoniaque.';
  9855. else if(comp.indexOf('Rotobaffe')!=-1) {
  9856. var Datt = att, vattbm = attbp+attbm;
  9857. var Ddeg = deg, vdegbm = degbp+degbm;
  9858. for(var i=1 ; i<niveau+2 ; i++) {
  9859. texte += '<b>Attaque n°'+i+' :</b><br/>'
  9860. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  9861. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  9862. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  9863. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  9864. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  9865. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  9866. if(i<niveau+1) texte += '<hr>';
  9867. }
  9868. }
  9869. else if(comp.indexOf('Shamaner')!=-1)
  9870. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  9871. +'des monstres en utilisant des champignons (de 1 à 3).';
  9872. else if(comp.indexOf('Tailler')!=-1){
  9873. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  9874. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  9875. }
  9876. return texte;
  9877. }
  9878.  
  9879. function decumul_buff(nom,str,buff) {
  9880. // Decumul des sorts de buff
  9881. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  9882. var dec = buff, total = buff, i=1;
  9883. while(i<6) {
  9884. i++;
  9885. dec = Math.floor(coefDecumul(i)*buff);
  9886. if(dec<=1 || i==6) break;
  9887. total += dec;
  9888. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  9889. +str+' +'+dec+' (+'+total+')</i>';
  9890. }
  9891. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  9892. return ret;
  9893. }
  9894.  
  9895.  
  9896. function sortileges(sort,mainCall,pcA,pcD) {
  9897. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  9898. var texte = '';
  9899. if (mainCall) {
  9900. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  9901. pcA = (atttourP+atttourM);
  9902. pcD = (degtourP+degtourM);
  9903. }
  9904. if (sort.indexOf('Analyse Anatomique') != -1) {
  9905. texte = 'Portée horizontale : <b>'
  9906. + Math.floor(vuetotale / 2) + '</b> case';
  9907. if (vuetotale > 3){ texte += 's'; }
  9908. texte += '<br/>Portée verticale : <b>'
  9909. + Math.floor((vuetotale+1)/4)+'</b> case';
  9910. if (vuetotale > 7){ texte += 's'; }
  9911. }
  9912. else if (sort.indexOf('Armure Etheree') != -1){
  9913. texte = decumul_buff('AE', 'Armure magique', reg);
  9914. }
  9915. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  9916. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  9917. }
  9918. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  9919. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  9920. }
  9921. else if (sort.indexOf('Augmentation des Degats') != -1){
  9922. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  9923. }
  9924. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  9925. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  9926. }
  9927. else if(sort.indexOf('Bulle Magique')!=-1){
  9928. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  9929. }
  9930. else if(sort.indexOf('Explosion')!=-1){
  9931. texte = 'Dégâts : <b>'
  9932. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  9933. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  9934. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  9935. }
  9936. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  9937. if(pvcourant<=0)
  9938. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  9939. texte = 'Portée horizontale : <b>'
  9940. +Math.min(1,vuetotale)+'</b> case<br/>'
  9941. +'Dégâts physiques : <b>-'
  9942. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  9943. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  9944. +'Dégâts magiques : <b>-'
  9945. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  9946. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  9947. }
  9948. else if(sort.indexOf('Flash Aveuglant')!=-1){
  9949. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  9950. }
  9951. else if(sort.indexOf('Glue')!=-1) {
  9952. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  9953. if(vuetotale>2) texte += 's';
  9954. }
  9955. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  9956. /* Frappe */
  9957. var modD = 0;
  9958. texte = 'Attaque : <b>'+att+'</b> D6 ';
  9959. if(pcA!=0){
  9960. modD = parseInt(att*pcA/100);
  9961. texte += '<i>'+aff(modD)+'D6</i> ';
  9962. }
  9963. texte += aff(attbm)
  9964. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  9965. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  9966. if(pcD!=0) {
  9967. modD = parseInt(Math.floor(deg/2)*pcD/100);
  9968. texte += '<i>'+aff(modD)+'D3</i> ';
  9969. }else
  9970. modD = 0;
  9971. texte += aff(degbm)+' => <b>'
  9972. +(2*(Math.floor(deg/2)+modD)+degbm)
  9973. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  9974. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  9975. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  9976. +')</b>';
  9977. if(!mainCall) return texte;
  9978. /* Venins */
  9979. function addVenin(type,effet,duree) {
  9980. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  9981. +' pendant <b>'+duree+'</b> tour';
  9982. if(duree>1) ret += 's';
  9983. var dred = Math.max(Math.floor(duree/2),1);
  9984. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  9985. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  9986. }
  9987. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  9988. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  9989. effet = Math.floor(1.5*effet);
  9990. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  9991. }
  9992. else if(sort.indexOf('Hypnotisme')!=-1)
  9993. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  9994. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  9995. else if(sort.indexOf('Identification des tresors')!=-1)
  9996. texte = 'Permet de connaitre les caractéristiques et effets précis '
  9997. +'d\'un trésor.';
  9998. else if(sort.indexOf('Invisibilite')!=-1)
  9999. texte = 'Un troll invisible est indétectable même quand on se trouve '
  10000. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  10001. +'fait disparaître l\'invisibilité.';
  10002. else if(sort.indexOf('Levitation')!=-1)
  10003. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  10004. +'Comme les pièges ou les trous par exemple...';
  10005. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  10006. var eps = 1,
  10007. pc = 20;
  10008. var str = 'PréM';
  10009. var newSort;
  10010. var sortAtt = [
  10011. 'Projectile Magique',
  10012. 'Rafale Psychique',
  10013. 'Siphon des Ames',
  10014. 'Vampirisme',
  10015. 'Griffe du Sorcier'
  10016. ];
  10017. if(sort.indexOf('Puissance')!=-1) {
  10018. eps = -1; str='PuM';
  10019. }
  10020. for(var i=1 ; i<4 ; i++) {
  10021. if(texte) { texte += '<hr>'; }
  10022. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  10023. newSort = false;
  10024. for(var j=0 ; j<sortAtt.length ; j++) {
  10025. if(getTalent(sortAtt[j])) {
  10026. if(newSort) { texte += '<br/><br/>'; }
  10027. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  10028. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  10029. newSort = true;
  10030. }
  10031. }
  10032. pc = decumulPumPrem(pc);
  10033. }
  10034. }
  10035. else if(sort.indexOf('Projectile Magique')!=-1) {
  10036. var modD = 0;
  10037. var portee = getPortee__Profil(vuetotale);
  10038. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  10039. if(pcA!=0) {
  10040. modD = parseInt(vue*pcA/100);
  10041. texte += '<i>'+aff(modD)+'D6</i> ';
  10042. }
  10043. texte += aff(attbm)
  10044. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  10045. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  10046. if(pcD!=0) {
  10047. modD = parseInt(Math.floor(vue/2)+pcD);
  10048. texte += '<i>'+aff(modD)+'D3</i> ';
  10049. }else
  10050. modD = 0;
  10051. texte += aff(degbm)
  10052. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  10053. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  10054. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  10055. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  10056. if(!mainCall) return texte;
  10057. texte += '<br/>Portée : <b>'+portee+'</b> case';
  10058. if(portee>1) texte += 's';
  10059. }
  10060. else if(sort.indexOf('Projection')!=-1) {
  10061. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  10062. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  10063. +'Si le jet de résistance de la victime est réussi:<br/>'
  10064. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  10065. }
  10066. else if(sort.indexOf('Rafale Psychique')!=-1) {
  10067. var modD = 0;
  10068. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  10069. if(pcD!=0) {
  10070. modD = parseInt(deg*pcD/100);
  10071. texte += '<i>'+aff(modD)+'D3</i> ';
  10072. }
  10073. texte += aff(degbm)
  10074. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  10075. if(!mainCall) return texte;
  10076. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  10077. }
  10078. else if(sort.indexOf('Sacrifice')!=-1) {
  10079. if(pvcourant<=0)
  10080. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  10081.  
  10082. function perteSacro(sac) {
  10083. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  10084. }
  10085.  
  10086. var sac = Math.floor((pvcourant-1)/2);
  10087. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10088. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  10089. /* Sacros max et optimal sans malus (propale R') */
  10090. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10091. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  10092. if(sac>0)
  10093. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  10094. else
  10095. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  10096. /*if(sac>3) {
  10097. sac = 5*Math.floor((sac+1)/5)-1;
  10098. texte += '<br/>Soin optimal sans malus de temps : <b>'
  10099. +sac+'</b> PV'+perteSacro(sac);
  10100. }*/
  10101. }
  10102. else if(sort.indexOf('Siphon')!=-1) {
  10103. var modD = 0;
  10104. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10105. if(pcA!=0) {
  10106. modD = parseInt(att*pcA/100);
  10107. texte += '<i>'+aff(modD)+'D6</i> ';
  10108. }
  10109. texte += aff(attbm)
  10110. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  10111. +'Dégâts : <b>'+reg+'</b> D3 ';
  10112. if(pcD!=0) {
  10113. modD = parseInt(reg*pcD/100);
  10114. texte += '<i>'+aff(modD)+'D3</i> ';
  10115. }else
  10116. modD = 0;
  10117. texte += aff(degbm)
  10118. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  10119. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  10120. if(!mainCall) return texte;
  10121. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  10122. }
  10123. else if(sort.indexOf('Telekinesie')!=-1) {
  10124. texte = 'Portée horizontale :';
  10125. var vt = Math.floor(vuetotale/2)+2;
  10126. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  10127. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  10128. for(var i=0 ; i<5 ; i++) {
  10129. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  10130. if(vt>1) texte += 's';
  10131. vt=Math.max(0,vt-1);
  10132. }
  10133. }
  10134. else if(sort.indexOf('Teleportation')!=-1) {
  10135. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  10136. var pmh = (20+vue+portee);
  10137. var pmv = 3+Math.floor(portee/3);
  10138. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  10139. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  10140. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  10141. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  10142. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  10143. }
  10144. else if(sort.indexOf('Vampirisme')!=-1) {
  10145. var modD = 0;
  10146. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  10147. if(pcA!=0) {
  10148. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  10149. texte += '<i>'+aff(modD)+'D6</i> ';
  10150. }
  10151. texte += aff(attbm)
  10152. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  10153. +'Dégâts : <b>'+deg+'</b> D3 ';
  10154. if(pcD!=0) {
  10155. modD = parseInt(deg*pcD/100);
  10156. texte += '<i>'+aff(modD)+'D3</i> ';
  10157. }else
  10158. modD = 0;
  10159. texte += aff(degbm)
  10160. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  10161. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  10162. }
  10163. else if(sort.indexOf('Vision Accrue')!=-1)
  10164. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  10165. else if(sort.indexOf('Vision lointaine')!=-1)
  10166. texte = 'En ciblant une zone située n\'importe où dans le '
  10167. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  10168. else if(sort.indexOf('Voir le Cache')!=-1)
  10169. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  10170. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  10171. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  10172. +getPortee__Profil(vuetotale)+'</b> cases';
  10173. else if(sort.indexOf('Vue Troublee')!=-1)
  10174. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10175. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  10176. return texte;
  10177. }
  10178.  
  10179.  
  10180. /*---------------------------------- Main ------------------------------------*/
  10181.  
  10182. function do_profil2()
  10183. {
  10184. try {
  10185. start_script(31);
  10186.  
  10187. extractionDonnees();
  10188. setInfosCaracteristiques();
  10189. setInfoDescription();
  10190. setInfosEtatLieux();
  10191. setInfosEtatPV();
  10192. setInfosExp();
  10193.  
  10194. creerBulleVide();
  10195. traitementTalents();
  10196. setLienAnatrolliseur();
  10197.  
  10198. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  10199. if(race=='Kastar'){ setAccel(); }
  10200. saveProfil();
  10201. displayScriptTime();
  10202. } catch(e) {
  10203. avertissement("[MZ] Une erreur s'est produite.");
  10204. window.console.error("[MZ] Erreur générale Profil",e);
  10205. }
  10206. }
  10207.  
  10208. /*********************************************************************************
  10209. * This file is part of Mountyzilla. *
  10210. * *
  10211. * Mountyzilla is free software; you can redistribute it and/or modify *
  10212. * it under the terms of the GNU General Public License as published by *
  10213. * the Free Software Foundation; either version 2 of the License, or *
  10214. * (at your option) any later version. *
  10215. * *
  10216. * Mountyzilla is distributed in the hope that it will be useful, *
  10217. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10218. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10219. * GNU General Public License for more details. *
  10220. * *
  10221. * You should have received a copy of the GNU General Public License *
  10222. * along with Mountyzilla; if not, write to the Free Software *
  10223. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10224. *********************************************************************************/
  10225.  
  10226. // x~x tancompo
  10227.  
  10228. var popup;
  10229.  
  10230. function initPopupTancompo() {
  10231. popup = document.createElement('div');
  10232. popup.setAttribute('id', 'popup');
  10233. popup.setAttribute('class', 'mh_textbox');
  10234. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  10235. + 'display: inline; z-index: 3; max-width: 400px;');
  10236. document.body.appendChild(popup);
  10237. }
  10238.  
  10239. // roule 16/03/2016, existe déjà ailleurs
  10240. // function showPopup(evt) {
  10241. // var texte = this.getAttribute("texteinfo");
  10242. // popup.innerHTML = texte;
  10243. // popup.style.left = evt.pageX + 15 + 'px';
  10244. // popup.style.top = evt.pageY + 'px';
  10245. // popup.style.visibility = "visible";
  10246. // }
  10247.  
  10248. // roule 16/03/2016, existe déjà ailleurs
  10249. // function hidePopup() {
  10250. // popup.style.visibility = 'hidden';
  10251. // }
  10252.  
  10253. function createPopupImage(url, text)
  10254. {
  10255. var img = document.createElement('img');
  10256. img.setAttribute('src',url);
  10257. img.setAttribute('align','ABSMIDDLE');
  10258. img.setAttribute("texteinfo",text);
  10259. img.addEventListener("mouseover", showPopup,true);
  10260. img.addEventListener("mouseout", hidePopup,true);
  10261. return img;
  10262. }
  10263.  
  10264. function formateTexte(texte)
  10265. {
  10266. texte = texte.replace(/\n/g,"<br/>");
  10267. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  10268. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  10269. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  10270. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  10271. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  10272. return texte;
  10273. }
  10274.  
  10275. function arrondi(x) {
  10276. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  10277. }
  10278.  
  10279. function traiteMinerai() {
  10280. if (currentURL.indexOf("as_type=Divers")==-1) return;
  10281. try {
  10282. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  10283. +" and contains(./tr/th/text(),'Minerai')]",
  10284. document, null, 9, null).singleNodeValue;
  10285. node = node.nextSibling.nextSibling;
  10286. }
  10287. catch(e) {return;}
  10288. var trlist = document.evaluate('./tr', node, null, 7, null);
  10289. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  10290. var node = trlist.snapshotItem(i);
  10291. var nature = node.childNodes[5].textContent;
  10292. var caracs = node.childNodes[7].textContent;
  10293. var taille = caracs.match(/\d+/)[0];
  10294. var coef = 1;
  10295. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  10296. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  10297. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  10298. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  10299. if (nature.indexOf('Mithril')!=-1) {
  10300. coef = 0.2*coef;
  10301. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  10302. }
  10303. else {
  10304. coef = 0.75*coef+1.25;
  10305. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  10306. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  10307. }
  10308. }
  10309. }
  10310.  
  10311. function treateComposants() {
  10312. if (currentURL.indexOf("as_type=Compo")==-1) return;
  10313. //On récupère les composants
  10314. var nodes = document.evaluate(
  10315. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  10316. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  10317. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  10318. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10319. if (nodes.snapshotLength == 0) {
  10320. // window.alert('treateComposants DOWN');
  10321. return;
  10322. }
  10323. window.alert(nodes.snapshotLength);
  10324.  
  10325. var texte = "";
  10326. for (var i = 0; i < nodes.snapshotLength; i++) {
  10327. var n1 = nodes.snapshotItem(i).childNodes[1];
  10328. var n3 = nodes.snapshotItem(i).childNodes[3];
  10329. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  10330. var prix = n3.childNodes[0].nodeValue;
  10331. if (!prix)
  10332. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  10333. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10334. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10335. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  10336. + prix.replace(/\n/g, '') + "\n";
  10337. }
  10338.  
  10339. var c = document.evaluate("//div[@class = 'titre2']/text()",
  10340. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10341. var id_taniere = c.snapshotItem(0).nodeValue;
  10342. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  10343.  
  10344. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  10345. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  10346. if (form)
  10347. {
  10348. if(document.getElementsByTagName('form').length>0)
  10349. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  10350. else
  10351. {
  10352. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  10353. insertBefore(thisP, form);
  10354. }
  10355. }
  10356. }
  10357.  
  10358. function treateAllComposants() {
  10359. if(currentURL.indexOf("as_type=Compo")==-1) return;
  10360. //On récupère les composants
  10361. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  10362. document, null, 0, null ).numberValue;
  10363. var c = (categ == 0 ? 3 : 4);
  10364. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  10365. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  10366. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  10367. + "td["+c+"]/text()[1] = '\240-\240' "
  10368. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  10369. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  10370. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  10371. + "and td[1]/img/@alt = 'Identifié']",
  10372. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10373. if (nodes.snapshotLength == 0) {
  10374. // window.alert('treateAllComposants DOWN');
  10375. return;
  10376. }
  10377.  
  10378. var texte = "";
  10379. for (var i = 0; i < nodes.snapshotLength; i++) {
  10380. var n1 = nodes.snapshotItem(i).childNodes[1];
  10381. var n3 = nodes.snapshotItem(i).childNodes[3];
  10382. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  10383. var prix = n3.childNodes[0].nodeValue;
  10384. if (!prix)
  10385. {
  10386. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  10387. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  10388. }
  10389. else
  10390. {
  10391. prix= prix.replace(/[\240 ]/g, "");
  10392. if(prix=="-")
  10393. prix=null;
  10394. }
  10395. if(prix)
  10396. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10397. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10398. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  10399. + prix.replace(/\n/g, '') + "\n";
  10400. else
  10401. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10402. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10403. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  10404. }
  10405.  
  10406. var c = document.evaluate("//div[@class = 'titre2']/text()",
  10407. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10408. var id_taniere = c.snapshotItem(0).nodeValue;
  10409. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  10410.  
  10411. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  10412. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  10413. if (form)
  10414. {
  10415. if(document.getElementsByTagName('form').length>0)
  10416. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  10417. else
  10418. {
  10419. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  10420. insertBefore(thisP, form);
  10421. }
  10422. }
  10423. }
  10424.  
  10425. function treateEM()
  10426. {
  10427. if(currentURL.indexOf("as_type=Compo")==-1)
  10428. return false;
  10429. var urlImg = URL_MZimg09 + 'Competences/ecritureMagique.png';
  10430. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  10431. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10432. if (nodes.snapshotLength == 0)
  10433. return false;
  10434. for (var i = 0; i < nodes.snapshotLength; i++) {
  10435. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  10436. var link = desc[2].firstChild ;
  10437. var nomCompoTotal = desc[2].textContent ;
  10438. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  10439. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  10440. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  10441. var locqual = desc[3].textContent ;
  10442. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  10443. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  10444. if(isEM(nomMonstre).length>0)
  10445. {
  10446. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  10447. if(infos.length>0)
  10448. {
  10449. var shortDescr = "Variable";
  10450. var bold = 0;
  10451. if(infos != "Composant variable")
  10452. {
  10453. shortDescr = infos.substring(0,infos.indexOf(" "));
  10454. if(parseInt(shortDescr)>=0)
  10455. bold=1;
  10456. }
  10457. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  10458. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  10459. }
  10460. }
  10461. }
  10462. }
  10463.  
  10464. function treateChampi() {
  10465. if (currentURL.indexOf('as_type=Champi')==-1)
  10466. return false;
  10467. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  10468. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10469. if (nodes.snapshotLength == 0)
  10470. return false;
  10471.  
  10472. for (var i = 0; i < nodes.snapshotLength; i++) {
  10473. var node = nodes.snapshotItem(i);
  10474. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  10475. if (moisChampi[nomChampi])
  10476. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  10477. }
  10478. }
  10479.  
  10480. function treateEnchant()
  10481. {
  10482. if(currentURL.indexOf("as_type=Compo")==-1)
  10483. return false;
  10484. try
  10485. {
  10486. if(!listeMonstreEnchantement)
  10487. computeCompoEnchantement();
  10488. var nodes = document.evaluate(
  10489. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  10490. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  10491. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10492. if (nodes.snapshotLength == 0)
  10493. return false;
  10494. var urlImg = URL_MZimg09 + "enchant.png";
  10495. for (var i = 0; i < nodes.snapshotLength; i++) {
  10496. var link = nodes.snapshotItem(i);
  10497. var nomCompoTotal = link.firstChild.nodeValue;
  10498. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  10499. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  10500. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  10501. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  10502. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  10503. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  10504. if(isEnchant(nomMonstre).length>0)
  10505. {
  10506. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  10507. if(infos.length>0)
  10508. {
  10509. link.parentNode.appendChild(createImage(urlImg,infos));
  10510. }
  10511. }
  10512. }
  10513. }
  10514. catch(e)
  10515. {
  10516. window.alert(e);
  10517. }
  10518. }
  10519.  
  10520. function treateEquipEnchant()
  10521. {
  10522. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  10523. return false;
  10524. initPopupTancompo();
  10525. computeEnchantementEquipement(createPopupImage,formateTexte);
  10526. }
  10527.  
  10528. function do_tancompo()
  10529. {
  10530. start_script();
  10531.  
  10532. treateAllComposants();
  10533. treateComposants();
  10534. traiteMinerai();
  10535. if (MY_getValue('NOINFOEM')!='true') {
  10536. treateChampi();
  10537. treateEM();
  10538. }
  10539. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  10540. treateEnchant();
  10541. treateEquipEnchant();
  10542. }
  10543.  
  10544. displayScriptTime();
  10545. }
  10546.  
  10547.  
  10548.  
  10549.  
  10550.  
  10551. /*******************************************************************************
  10552. * This file is part of Mountyzilla. *
  10553. * *
  10554. * Mountyzilla is free software; you can redistribute it and/or modify *
  10555. * it under the terms of the GNU General Public License as published by *
  10556. * the Free Software Foundation; either version 2 of the License, or *
  10557. * (at your option) any later version. *
  10558. * *
  10559. * Mountyzilla is distributed in the hope that it will be useful, *
  10560. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10561. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10562. * GNU General Public License for more details. *
  10563. * *
  10564. * You should have received a copy of the GNU General Public License *
  10565. * along with Mountyzilla; if not, write to the Free Software *
  10566. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10567. *******************************************************************************/
  10568.  
  10569. // x~x script_principal
  10570.  
  10571. function isPage(url) {
  10572. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  10573. }
  10574.  
  10575. /*--------------------------------- Dispatch ---------------------------------*/
  10576.  
  10577. //chargerScriptDev("libs");
  10578. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  10579.  
  10580. // Détection de la page à traiter
  10581. if(isPage("Messagerie/ViewMessageBot")) {
  10582. do_cdmbot();
  10583. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  10584. do_cdmcomp();
  10585. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  10586. do_diplo();
  10587. } else if(isPage("MH_Play/Play_equipement")) {
  10588. do_equip();
  10589. } else if(isPage("MH_Play/Play_menu")) {
  10590. do_menu();
  10591. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  10592. do_option();
  10593. } else if(isPage("View/PJView")) {
  10594. do_pjview();
  10595. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  10596. do_profil();
  10597. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  10598. do_tancompo();
  10599. } else if(isPage("MH_Play/Play_vue")) {
  10600. do_vue();
  10601. } else if(isPage("MH_Play/Play_news")) {
  10602. do_news();
  10603. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  10604. do_move();
  10605. } else if(isPage("MH_Missions/Mission_Etape")) {
  10606. do_mission();
  10607. } else if(isPage("View/MonsterView")) {
  10608. do_infomonstre();
  10609. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  10610. do_attaque();
  10611. } else if(isPage("MH_Follower/FO_Ordres")) {
  10612. do_ordresgowap();
  10613. } else if(isPage("MH_Follower/FO_Equipement")) {
  10614. do_equipgowap();
  10615. } else if(isPage("MH_Play/Play_mouche")) {
  10616. do_mouches();
  10617. } else if(isPage("MH_Play/Play_BM")) {
  10618. do_malus();
  10619. } else if(isPage("MH_Play/Play_evenement")) {
  10620. do_myevent();
  10621. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  10622. do_enchant();
  10623. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  10624. do_pre_enchant();
  10625. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  10626. do_actions();
  10627. } else if(isPage('MH_Missions/Mission_Liste.php')) { // Roule 28/03/2016 je n'ai pas vu l'utilité et ça bloque... && MY_getValue(numTroll+'.MISSIONS')) {
  10628. do_mission_liste();
  10629. } else if(isPage('MH_Play/Play_action')) {
  10630. do_actions();
  10631. } else if(isPage('MH_Play/Play_profil2')) {
  10632. do_profil2();
  10633. }