Tout_MZ

Client MountyZilla

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

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @version 1.2.10.2
  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. // V1.2.4 14/10/2016
  43. // utilisation du relai raistlin pour l'envoi des CdM
  44. // V1.2.5 17/10/2016
  45. // correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence
  46. // remise en route de la gestion des options avec intégration md5 dans ce script
  47. // V1.2.6 19/10/2016
  48. // affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https
  49. // stockage idguilde et nomguilde
  50. // V1.2.7 07/11/2016
  51. // remise en route de l'interface avec l'IT bricol'Troll
  52. // V1.2.8 10/11/2016
  53. // gestion des messages d'erreur de l'interface avec l'IT bricol'Troll
  54. // déplacement des images sur l'infra raistlin + meilleure gestion HTTPS
  55. // V1.2.9 16/11/2016
  56. // adaptation Firefox 50 (comportement différent sur échec Ajax https)
  57. // V1.2.10 07/12/2016
  58. // correction décumul des bonus/malus
  59. // affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll
  60. // V1.2.10.1 08/12/2016
  61. // option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage
  62. // V1.2.10.2 09/12/2016
  63. // positionnement des Trõlls camou/invi à la bonne position par rapport à la distance
  64.  
  65. /**********************************************************
  66. **** Début de zone à déplacer dans une bibli commune ******
  67. **********************************************************/
  68.  
  69. // URLs externes images (déplacées sur infra raistlin 09/11/2016, pas besoin deCORS, HTTPS OK)
  70. //const URL_MZimg09 = 'http://mountyzilla.tilk.info/scripts_0.9/images/'; // en cours de migration vers infra raistlin
  71. //const URL_MZimg11 = 'http://mountyzilla.tilk.info/scripts_1.1/images/'
  72. const URL_MZimg = 'http://mz.mh.raistlin.fr/mz/img/';
  73. var URL_MZimg09 = URL_MZimg; // à fusioner
  74. var URL_MZimg11 = URL_MZimg;
  75. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  76. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  77.  
  78. // URLs externes redirection (pas de souci CORS)
  79. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  80. const URL_MZmountyhall = 'http://trolls.ratibus.net/mountyhall/';
  81. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  82. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  83. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  84. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  85. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  86. //const URL_tilk_js = 'http://mountyzilla.tilk.info/scripts/'; // un de moins \o/ source intégré dans tout_MZ
  87. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  88. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  89.  
  90. // URLs de test HTTPS
  91. const URL_CertifRaistlin1 = 'https://mz.mh.raistlin.fr/mz/img/1.gif';
  92. const URL_CertifRaistlin2 = 'https://cdm.mh.raistlin.fr/mz/niveau_monstre_combat.php';
  93.  
  94. // URLs externes ajax (nécessite l'entête CORS, solution actuelle : passage en proxy chez raistlin)
  95. // var URL_MZinfoMonstre = 'http://mz.mh.raistlin.fr/mz/monstres_0.9_FF.php'; // infra sur serveur raistlin en préparation
  96. // var URL_MZinfoMonstrePost = 'http://mz.mh.raistlin.fr/mz/monstres_0.9_post_FF.php';
  97. // var URL_pageDispatcher = "http://mz.mh.raistlin.fr/mz/cdmdispatcher.php";
  98. var URL_MZinfoMonstre = 'http://cdm.mh.raistlin.fr/mz/monstres_0.9_FF.php'; // redirigé vers http://mountypedia.free.fr/mz/monstres_0.9_FF.php
  99. var URL_MZinfoMonstrePost = 'http://cdm.mh.raistlin.fr/mz/monstres_0.9_post_FF.php'; // redirigé vers mountypedia.free.fr
  100. var URL_pageDispatcher = "http://cdm.mh.raistlin.fr/mz/cdmdispatcher.php"; // envoi des CdM, redirigé vers mountypedia.free.fr
  101. // pour passer en mode IP, commenter les 3 lignes précédentes et décommenter les 3 suivantes
  102. //var URL_MZinfoMonstre = 'http://192.99.225.92/mz/monstres_0.9_FF.php';
  103. //var URL_MZinfoMonstrePost = 'http://192.99.225.92/mz/monstres_0.9_post_FF.php';
  104. //var URL_pageDispatcher = 'http://192.99.225.92/mz/cdmdispatcher.php';
  105.  
  106. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  107. const URL_ratibus_lien = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  108. const URL_anniv = 'http://mountyzilla.tilk.info/scripts/anniv.php'; // Url de récup des jubilaires:
  109. const URL_rss = 'http://mountyzilla.tilk.info/news/rss.php'; // Flux RSS des news MZ
  110. const URL_trooglebeta = 'http://troogle-beta.aacg.be/view_submission';
  111.  
  112. // x~x Libs
  113.  
  114. /* TODO
  115. * - revoir la gestion des CdM --> nott armure magique
  116. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  117. * - vérfier la gestion des enchants
  118. */
  119.  
  120. // Roule 04/09/2016 switch extern URLs to https if available
  121. var isHTTPS = false;
  122. if ( window.location.protocol.indexOf('https') === 0) {
  123. URL_MZinfoMonstre = URL_MZinfoMonstre.replace(/http:\/\//, 'https://');
  124. URL_MZinfoMonstrePost = URL_MZinfoMonstrePost.replace(/http:\/\//, 'https://');
  125. URL_pageDispatcher = URL_pageDispatcher.replace(/http:\/\//, 'https://');
  126. // Roule 09/11/2016 images OK en https sur infra Raistlin
  127. URL_MZimg09 = URL_MZimg09.replace(/http:\/\//, 'https://');
  128. URL_MZimg11 = URL_MZimg11.replace(/http:\/\//, 'https://');
  129. isHTTPS = true;
  130. }
  131. var MHicons = '/mountyhall/Images/Icones/';
  132. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  133. var MY_DEBUG = false;
  134.  
  135. /* remplacement fonction MZ */
  136. function MY_getValue(key) {
  137. return window.localStorage[key];
  138. }
  139.  
  140. function MY_removeValue(key) {
  141. window.localStorage.removeItem(key);
  142. }
  143.  
  144. function MY_setValue(key, val) {
  145. window.localStorage[key] = val;
  146. }
  147.  
  148. /*---------------- mise à jour de variables globales utiles ------------------*/
  149. // utilisé pour accès bdd (un peu partout) :
  150. var numTroll = MY_getValue('NUM_TROLL');
  151. // utilisé dans vue pour PX :
  152. var nivTroll = MY_getValue('NIV_TROLL');
  153. // utilisés dans actions et vue (calculs SR) :
  154. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  155. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  156.  
  157. /*-[functions]------------ Fonctions durée de script -------------------------*/
  158. var date_debut = null;
  159.  
  160. function start_script(nbJours_exp) {
  161. if(date_debut) return;
  162. date_debut = new Date();
  163. // Créé la variable expdate si demandé
  164. if(nbJours_exp) {
  165. expdate = new Date();
  166. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  167. }
  168. }
  169.  
  170. function displayScriptTime() {
  171. var footerNode = document.getElementById('footer2');
  172. if(!footerNode) return;
  173. try{
  174. var node = document.evaluate(
  175. ".//text()[contains(.,'Page générée en')]/../br",
  176. footerNode,null,9,null).singleNodeValue;
  177. }
  178. catch(e){return;}
  179. insertText(node,
  180. ' - [Script exécuté en '
  181. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  182. }
  183.  
  184. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  185.  
  186. function debugMZ(str){
  187. if(MY_DEBUG){
  188. window.console.debug('[MY_DEBUG] '+str);
  189. if(typeof str === "object"){
  190. window.console.debug(str);
  191. }
  192. }
  193. }
  194.  
  195. function FF_XMLHttpRequest(MY_XHR_Ob) {
  196. var request = new XMLHttpRequest();
  197. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  198. for(var head in MY_XHR_Ob.headers) {
  199. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  200. }
  201. request.onreadystatechange = function() {
  202. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  203. if(request.readyState!=4) { return; }
  204. if(request.error) {
  205. if(MY_XHR_Ob.onerror) {
  206. MY_XHR_Ob.onerror(request);
  207. }
  208. }
  209. else if(MY_XHR_Ob.onload) {
  210. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  211. MY_XHR_Ob.onload(request);
  212. }
  213. };
  214. request.send(MY_XHR_Ob.data);
  215. }
  216.  
  217.  
  218. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  219.  
  220. function avertissement(txt,duree) {
  221. if(!duree) duree = 15000;
  222. var div = document.createElement('div');
  223. // On numérote les avertissements pour destruction sélective
  224. var num = document.getElementsByName('avertissement').length;
  225. div.num = num;
  226. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  227. div.setAttribute('name','avertissement');
  228. div.className = 'mh_textbox';
  229. div.style.position = 'fixed';
  230. div.style.top = (10+15*num)+'px';
  231. div.style.left = (10+5*num)+'px';
  232. div.style.border = '5px solid red';
  233. div.style.zIndex = 2+num;
  234. div.style.cursor = 'pointer';
  235. div.style.fontSize = 'large';
  236. div.innerHTML = txt;
  237. div.onclick=function(){ tueAvertissement(this.num) };
  238.  
  239. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  240. var divcroix = document.createElement('div');
  241. divcroix.style.position = 'absolute';
  242. divcroix.style.top = 0;
  243. divcroix.style.right = 0;
  244. divcroix.style.color = 'black';
  245. divcroix.style.fontSize = 'inherit';
  246. divcroix.style.cursor = 'pointer'
  247. divcroix.style.zIndex = 2+num;
  248. divcroix.innerHTML = "X";
  249. div.appendChild(divcroix);
  250.  
  251. document.body.appendChild(div);
  252. // Destruction automatique de l'avertissement après "un certain temps"
  253. window.setTimeout(function(){ tueAvertissement(num) },duree);
  254. }
  255.  
  256. function tueAvertissement(num) {
  257. var divs = document.getElementsByName('avertissement');
  258. if(divs.length==0) { return; }
  259. for(var i=0 ; i<divs.length ; i++) {
  260. if(divs[i].num==num) {
  261. divs[i].parentNode.removeChild(divs[i]);
  262. return;
  263. }
  264. }
  265. }
  266.  
  267.  
  268. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  269.  
  270. function insertBefore(next,el) {
  271. next.parentNode.insertBefore(el,next);
  272. }
  273.  
  274. function appendTr(tbody,clas) {
  275. var tr = document.createElement('tr');
  276. if(clas) tr.className = clas;
  277. tbody.appendChild(tr);
  278. return tr;
  279. }
  280.  
  281. function insertTr(next,clas) {
  282. var tr = document.createElement('tr');
  283. if(clas) tr.className = clas;
  284. insertBefore(next,tr);
  285. return tr;
  286. }
  287.  
  288. function appendTd(tr) {
  289. var td = document.createElement('td');
  290. if(tr) tr.appendChild(td);
  291. return td;
  292. }
  293.  
  294. function insertTd(next) {
  295. var td = document.createElement('td');
  296. insertBefore(next,td);
  297. return td;
  298. }
  299.  
  300. function appendTdCenter(tr,colspan) {
  301. var td = appendTd(tr);
  302. td.align = 'center'; // WARNING - Obsolete
  303. if(colspan) td.colSpan = colspan;
  304. return td;
  305. }
  306.  
  307. function insertTdElement(next,el) {
  308. var td = insertTd(next);
  309. if(el) td.appendChild(el);
  310. return td;
  311. }
  312.  
  313. function appendA(paren,href,cssClass,text) {
  314. var a = document.createElement('a');
  315. if (href) a.href = href;
  316. if (cssClass) a.className = cssClass;
  317. if (text) a.appendChild(document.createTextNode(text));
  318. paren.appendChild(a);
  319. }
  320.  
  321. function appendText(paren,text,bold) {
  322. if(bold) {
  323. var b = document.createElement('b');
  324. b.appendChild(document.createTextNode(text));
  325. paren.appendChild(b);
  326. }
  327. else
  328. paren.appendChild(document.createTextNode(text));
  329. }
  330.  
  331. function insertText(next,text,bold) {
  332. if(bold) {
  333. var b = document.createElement('b');
  334. appendText(b,text);
  335. insertBefore(next,b);
  336. }
  337. else
  338. insertBefore(next,document.createTextNode(text));
  339. }
  340.  
  341. function appendTdText(tr,text,bold) {
  342. var td = appendTd(tr);
  343. appendText(td,text,bold);
  344. return td;
  345. }
  346.  
  347. function insertTdText(next,text,bold) {
  348. var td = insertTd(next);
  349. appendText(td,text,bold);
  350. return td;
  351. }
  352.  
  353. function appendBr(paren) {
  354. paren.appendChild(document.createElement('br'));
  355. }
  356.  
  357. function insertBr(next) {
  358. insertBefore(next,document.createElement('br'));
  359. }
  360.  
  361. function appendLI(ul,text) {
  362. // uniquement utilisé dans les options (crédits)
  363. var li = document.createElement('li');
  364. appendText(li,text);
  365. ul.appendChild(li);
  366. return li;
  367. }
  368.  
  369. function appendTextbox(paren,type,nam,size,maxlength,value) {
  370. var input = document.createElement('input');
  371. input.className = 'TextboxV2';
  372. input.type = type;
  373. input.name = nam;
  374. input.id = nam;
  375. input.size = size;
  376. input.maxLength = maxlength;
  377. if(value) input.value = value;
  378. paren.appendChild(input);
  379. return input;
  380. }
  381.  
  382. function appendCheckBox(paren,nam,checked,onClick) {
  383. var input = document.createElement('input');
  384. input.type = 'checkbox';
  385. input.name = nam;
  386. input.id = nam;
  387. if(checked) input.checked = true;
  388. if(onClick) input.onclick = onClick;
  389. paren.appendChild(input);
  390. return input;
  391. }
  392.  
  393. function appendNobr(paren,id,delgg,text) {
  394. var nobr = document.createElement('nobr');
  395. appendCheckBox(nobr,id,null,delgg);
  396. appendText(nobr,text);
  397. paren.appendChild(nobr);
  398. appendText(paren,' ');
  399. return nobr;
  400. }
  401.  
  402. function appendCheckBoxSpan(paren,id,onClick,text) {
  403. var span = document.createElement('span');
  404. span.style.whiteSpace = 'nowrap';
  405. appendCheckBox(span,id,false,onClick);
  406. appendText(span,text);
  407. paren.appendChild(span);
  408. appendText(paren,' ');
  409. return span;
  410. }
  411.  
  412. function appendOption(select,value,text) {
  413. var option = document.createElement('option');
  414. option.value = value;
  415. appendText(option,text);
  416. select.appendChild(option);
  417. return option;
  418. }
  419.  
  420. function appendHidden(form,nam,value) {
  421. var input = document.createElement('input');
  422. input.type = 'hidden';
  423. input.name = nam;
  424. input.id = nam;
  425. input.value = value;
  426. form.appendChild(input);
  427. }
  428.  
  429. function appendButton(paren,value,onClick) {
  430. var input = document.createElement('input');
  431. input.type = 'button';
  432. input.className = 'mh_form_submit';
  433. input.value = value;
  434. input.onmouseover = function(){this.style.cursor='pointer';};
  435. if(onClick) input.onclick = onClick;
  436. paren.appendChild(input);
  437. return input;
  438. }
  439.  
  440. function insertButton(next,value,onClick) {
  441. var input = document.createElement('input');
  442. input.type = 'button';
  443. input.className = 'mh_form_submit';
  444. input.value = value;
  445. input.onmouseover = function(){this.style.cursor='pointer';};
  446. input.onclick = onClick;
  447. insertBefore(next,input);
  448. return input;
  449. }
  450.  
  451. function appendSubmit(paren,value,onClick) {
  452. var input = document.createElement('input');
  453. input.type = 'submit';
  454. input.className = 'mh_form_submit';
  455. input.value = value;
  456. input.onmouseover = function(){this.style.cursor='pointer';};
  457. if(onClick) input.onclick = onClick;
  458. paren.appendChild(input);
  459. return input;
  460. }
  461.  
  462. function createImage(url,title) {
  463. var img = document.createElement('img');
  464. img.src = url;
  465. img.title = title;
  466. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  467. return img;
  468. }
  469.  
  470. function createAltImage(url,alt,title) {
  471. var img = document.createElement('img');
  472. img.src = url;
  473. img.alt = alt;
  474. img.title = title;
  475. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  476. return img;
  477. }
  478.  
  479. function createImageSpan(url,alt,title,text,bold) {
  480. var span = document.createElement('span');
  481. span.title = title;
  482. var img = document.createElement('img');
  483. img.src = url;
  484. img.alt = alt;
  485. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  486. span.appendChild(img);
  487. appendText(span,text,bold);
  488. return span;
  489. }
  490.  
  491. function createCase(titre,table,width) {
  492. if(!width) width=120;
  493. var tr = appendTr(table,'mh_tdpage');
  494. var td = appendTdText(tr,titre,true);
  495. td.className = 'mh_tdtitre';
  496. td.width = width;
  497. td = appendTdText(tr,'');
  498. td.className = 'mh_tdpage';
  499. return td;
  500. }
  501.  
  502. function getMyID(e) {
  503. var parent = e.parentNode;
  504. for(var i=0 ; i<parent.childNodes.length ; i++) {
  505. if(e==parent.childNodes[i])
  506. return i;
  507. }
  508. return -1;
  509. }
  510.  
  511. function insertAfter(elt,newElt) {
  512. var id = getMyID(elt);
  513. if(id==-1) return;
  514. if(id<elt.parentNode.childNodes.length-1)
  515. insertBefore(elt.nextSibling,newElt);
  516. else
  517. elt.parentNode.appendChild(newElt);
  518. }
  519.  
  520.  
  521. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  522.  
  523. function aff(nb) {
  524. return (nb>=0) ? '+'+nb : nb;
  525. }
  526.  
  527. function getNumber(str) {
  528. var nbr = str.match(/\d+/);
  529. return nbr ? Number(nbr[0]) : Number.NaN;
  530. }
  531.  
  532. function getNumbers(str) {
  533. var nbrs = str.match(/-?\d+/g);
  534. for(var i=0 ; i<nbrs.length ; i++)
  535. nbrs[i] = Number(nbrs[i]);
  536. return nbrs;
  537. }
  538.  
  539. function trim(str) {
  540. return str.replace(/(^\s*)|(\s*$)/g,'');
  541. }
  542.  
  543. String.prototype.trim = function() {
  544. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  545. }
  546.  
  547. function epure(texte) {
  548. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  549. .replace(/[ç]/g,'c')
  550. .replace(/[éêèë]/g,'e')
  551. .replace(/[ïî]/g,'i')
  552. .replace(/[ôöõ]/g,'o')
  553. .replace(/[ùûü]/g,'u');
  554. }
  555.  
  556. String.prototype.epure = function () {
  557. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  558. .replace(/[ç]/g,'c')
  559. .replace(/[éêèë]/g,'e')
  560. .replace(/[ïî]/g,'i')
  561. .replace(/[ôöõ]/g,'o')
  562. .replace(/[ùûü]/g,'u');
  563. }
  564.  
  565. function bbcode(texte) {
  566. return texte.replace(/&/g,'&amp;')
  567. .replace(/"/g,'&quot;')
  568. .replace(/</g,'&lt;')
  569. .replace(/>/g,'&gt;')
  570. .replace(/'/g,'&#146;')
  571. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  572. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  573. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  574. }
  575.  
  576.  
  577. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  578.  
  579. function addZero(i) {
  580. return (i<10) ? '0'+i : i;
  581. }
  582.  
  583. function DateToString(date) {
  584. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  585. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  586. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  587. }
  588.  
  589. function StringToDate(str) {
  590. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  591. }
  592.  
  593. /**********************************************************
  594. **** Fin de zone à déplacer dans une bibli commune ********
  595. **********************************************************/
  596.  
  597. /* DEBUG: NETTOYAGE TAGS */
  598. if(MY_getValue(numTroll+'.TAGSURL')) {
  599. MY_removeValue(numTroll+'.TAGSURL');
  600. }
  601.  
  602. /*---------- regroupement des getPortee() ------------------------------------*/
  603. // issu des script profil et profil2
  604. function getPortee__Profil(param) {
  605. param = Math.max(0,Number(param));
  606. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  607. // ça devrait être floor, +10.25, -2.5
  608. }
  609.  
  610. // issu du script vue
  611. function getPortee__Vue(param) {
  612. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  613. }
  614.  
  615.  
  616. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  617.  
  618. function getPXKill(niv) {
  619. return Math.max(0,10+3*niv-2*nivTroll);
  620. }
  621.  
  622. function getPXDeath(niv) {
  623. return Math.max(0,10+3*nivTroll-2*niv);
  624. }
  625.  
  626. function analysePX(niv) {
  627. niv = niv+'';
  628. var i = niv.indexOf('+');
  629. if(i!=-1) // si niv = 'XX+' ??
  630. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  631. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  632. if(i!=-1) {
  633. var max = getPXKill(niv.slice(i+2));
  634. if(max==0)
  635. return ' --> <b>0</b> PX';
  636. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  637. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  638. }
  639. i = niv.indexOf('='); // ???
  640. if(i!=-1) {
  641. var max = getPXKill(niv.slice(i+1));
  642. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  643. }
  644. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  645. }
  646.  
  647. function analysePXTroll(niv) {
  648. var str = analysePX(niv);
  649. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  650. return str;
  651. }
  652.  
  653.  
  654. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  655. // Refonte totale du code de Zorya
  656.  
  657. // Elements à implémenter en dur dans MZ2.0
  658. var numQualite = {
  659. 'Très Mauvaise':1,
  660. 'Mauvaise':2,
  661. 'Moyenne':3,
  662. 'Bonne':4,
  663. 'Très Bonne':5
  664. };
  665.  
  666. var qualiteNum = [
  667. '_dummy_',
  668. 'Très Mauvaise',
  669. 'Mauvaise',
  670. 'Moyenne',
  671. 'Bonne',
  672. 'Très Bonne'
  673. ];
  674.  
  675. var nival = {
  676. 'Abishaii Bleu':19,
  677. 'Abishaii Noir':10,
  678. 'Abishaii Rouge':23,
  679. 'Abishaii Vert':15,
  680. 'Ame-en-peine':8,
  681. 'Amibe Geante':9,
  682. 'Anaconda des Catacombes':8,
  683. 'Ankheg':10,
  684. 'Anoploure Purpurin':36,
  685. 'Araignee Geante':2,
  686. 'Ashashin':35,
  687. 'Balrog':50,
  688. 'Banshee':16,
  689. 'Barghest':36,
  690. 'Basilisk':11,
  691. 'Behemoth':34,
  692. 'Behir':14,
  693. 'Beholder':50,
  694. 'Boggart':3,
  695. 'Bondin':9,
  696. "Bouj'Dla Placide":37,
  697. "Bouj'Dla":19,
  698. 'Bulette':19,
  699. 'Caillouteux':1,
  700. 'Capitan':35,
  701. 'Carnosaure':25,
  702. 'Champi-Glouton':3,
  703. 'Chauve-Souris Geante':4,
  704. 'Cheval a Dents de Sabre':23,
  705. 'Chevalier du Chaos':20,
  706. 'Chimere':13,
  707. 'Chonchon':24,
  708. 'Coccicruelle':22,
  709. 'Cockatrice':5,
  710. 'Crasc Medius':17,
  711. 'Crasc Maexus':25,
  712. 'Crasc':10,
  713. 'Croquemitaine':6,
  714. 'Cube Gelatineux':32,
  715. 'Daemonite':27,
  716. 'Diablotin':5,
  717. 'Dindon du Chaos':1,
  718. 'Djinn':29,
  719. 'Ectoplasme':18,
  720. 'Effrit':27,
  721. "Elementaire d'Air":23,
  722. "Elementaire d'Eau":17,
  723. 'Elementaire de Feu':21,
  724. 'Elementaire de Terre':21,
  725. 'Elementaire du Chaos':26,
  726. 'Erinyes':7,
  727. 'Esprit-Follet':16,
  728. 'Essaim Craterien':30,
  729. 'Essaim Sanguinaire':25,
  730. 'Ettin':8,
  731. 'Familier':1,
  732. 'Fantome':24,
  733. 'Feu Follet':20,
  734. 'Flagelleur Mental':33,
  735. 'Foudroyeur':38,
  736. 'Fumeux':22,
  737. 'Fungus Geant':9,
  738. 'Fungus Violet':4,
  739. 'Furgolin':10,
  740. 'Gargouille':3,
  741. 'Geant de Pierre':13,
  742. 'Geant des Gouffres':22,
  743. "Geck'oo Majestueux":40,
  744. "Geck'oo":15,
  745. 'Glouton':20,
  746. 'Gnoll':5,
  747. 'Gnu Domestique':1,
  748. 'Gnu Sauvage':1,
  749. 'Goblin':4,
  750. 'Goblours':4,
  751. "Golem d'Argile":15,
  752. 'Golem de cuir':1,
  753. 'Golem de Chair':8,
  754. 'Golem de Fer':31,
  755. 'Golem de mithril':1,
  756. 'Golem de metal':1,
  757. 'Golem de papier':1,
  758. 'Golem de Pierre':23,
  759. 'Gorgone':11,
  760. 'Goule':4,
  761. 'Gowap Apprivoise':1,
  762. 'Gowap Sauvage':1,
  763. 'Gremlins':3,
  764. 'Gritche':39,
  765. 'Grouilleux':4,
  766. 'Grylle':31,
  767. 'Harpie':4,
  768. 'Hellrot':18,
  769. 'Homme-Lezard':4,
  770. 'Hurleur':8,
  771. 'Hydre':50,
  772. 'Incube':13,
  773. 'Kobold':2,
  774. 'Labeilleux':26,
  775. 'Lezard Geant':5,
  776. 'Liche':50,
  777. 'Limace Geante':10,
  778. 'Loup-Garou':8,
  779. 'Lutin':4,
  780. 'Mante Fulcreuse':30,
  781. 'Manticore':9,
  782. 'Marilith':33,
  783. 'Meduse':6,
  784. 'Megacephale':38,
  785. 'Mille-Pattes Geant':14,
  786. 'Mimique':6,
  787. 'Minotaure':7,
  788. 'Molosse Satanique':8,
  789. 'Momie':4,
  790. 'Monstre Rouilleur':3,
  791. "Mouch'oo Domestique":14,
  792. "Mouch'oo Majestueux Sauvage":33,
  793. "Mouch'oo Sauvage":14,
  794. 'Na-Haniym-Heee':0,
  795. 'Necrochore':37,
  796. 'Necromant':39,
  797. 'Necrophage':8,
  798. 'Naga':10,
  799. 'Nuee de Vermine':13,
  800. "Nuage d'Insectes":7,
  801. 'Ogre':7,
  802. 'Ombre de Roches':13,
  803. 'Ombre':2,
  804. 'Orque':3,
  805. 'Ours-Garou':18,
  806. 'Palefroi Infernal':29,
  807. 'Phoenix':32,
  808. 'Pititabeille':0,
  809. 'Plante Carnivore':4,
  810. 'Pseudo-Dragon':5,
  811. 'Rat Geant':2,
  812. 'Rat-Garou':3,
  813. 'Rocketeux':5,
  814. 'Sagouin':3,
  815. 'Scarabee Geant':4,
  816. 'Scorpion Geant':10,
  817. 'Shai':28,
  818. 'Sirene':8,
  819. 'Slaad':5,
  820. 'Sorciere':17,
  821. 'Spectre':14,
  822. 'Sphinx':30,
  823. 'Squelette':1,
  824. 'Strige':2,
  825. 'Succube':13,
  826. 'Tertre Errant':20,
  827. 'Thri-kreen':10,
  828. 'Tigre-Garou':12,
  829. 'Titan':26,
  830. 'Trancheur':35,
  831. 'Tubercule Tueur':14,
  832. 'Tutoki':4,
  833. 'Vampire':29,
  834. 'Ver Carnivore Geant':12,
  835. 'Ver Carnivore':11,
  836. 'Veskan Du Chaos':14,
  837. 'Vouivre':33,
  838. 'Worg':5,
  839. 'Xorn':14,
  840. 'Yeti':8,
  841. 'Yuan-ti':15,
  842. 'Zombie':2
  843. }
  844.  
  845. var tabEM = {
  846. //Monstre: [Compo exact, Sort, Position, Localisation]
  847. // AA
  848. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  849. // AE
  850. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  851. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  852. // AdA
  853. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  854. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  855. // AdE
  856. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  857. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  858. // AdD
  859. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  860. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  861. // BAM
  862. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  863. // BuM
  864. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  865. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  866. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  867. // Explo
  868. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  869. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  870. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  871. // FP
  872. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  873. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  874. // FA
  875. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  876. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  877. // Glue
  878. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  879. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  880. // GdS
  881. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  882. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  883. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  884. // Invi
  885. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  886. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  887. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  888. // Lévitation
  889. // ???
  890. // PréM :
  891. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  892. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  893. // Proj
  894. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  895. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  896. // PuM :
  897. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  898. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  899. // Sacro
  900. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  901. // Télék
  902. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  903. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  904. // TP
  905. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  906. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  907. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  908. // VA
  909. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  910. // VL
  911. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  912. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  913. // VlC
  914. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  915. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  916. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  917. // VT
  918. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  919. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  920. // Variables
  921. 'Rat':["d'un"],
  922. 'Rat Géant':["d'un"],
  923. 'Dindon':["d'un"],
  924. 'Goblin':["d'un"],
  925. 'Limace':["d'une"],
  926. 'Limace Géante':["d'une"],
  927. 'Ver':["d'un"],
  928. 'Ver Carnivore':["d'un"],
  929. 'Ver Carnivore Géant':["d'un"],
  930. 'Fungus':["d'un"],
  931. 'Vouivre':["d'une"],
  932. 'Gnu':["d'un"],
  933. 'Scarabée':["d'un"]
  934. };
  935.  
  936. var mundiChampi = {
  937. 'Préscientus Reguis':'du Phoenix',
  938. 'Amanite Trolloïde':'de la Mouche',
  939. 'Girolle Sanglante':'du Dindon',
  940. 'Horreur Des Prés':'du Gobelin',
  941. 'Bolet Péteur':'du Démon',
  942. 'Pied Jaune':'de la Limace',
  943. 'Agaric Sous-Terrain':'du Rat',
  944. 'Suinte Cadavre':"de l'Hydre",
  945. 'Cèpe Lumineux':'du Ver',
  946. 'Fungus Rampant':'du Fungus',
  947. 'Nez Noir':'de la Vouivre',
  948. 'Pleurote Pleureuse':'du Gnu',
  949. 'Phytomassus Xilénique':'du Scarabée'
  950. };
  951.  
  952. function addInfoMM(node,mob,niv,qualite,effetQ) {
  953. appendText(node,' ');
  954. var urlImg = URL_MZimg11
  955. +'Competences/melangeMagique.png';
  956. var text = ' [-'+(niv+effetQ)+' %]';
  957. var str = '';
  958. switch(mob[0]) {
  959. case 'A':
  960. case 'E':
  961. case 'I':
  962. case 'O':
  963. case 'U':
  964. str = "Compo d'";
  965. break;
  966. default:
  967. str = 'Compo de ';
  968. }
  969. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  970. var span = createImageSpan(urlImg,'MM:',title,text);
  971. node.appendChild(span);
  972. }
  973. function addInfoEM(node,mob,compo,qualite,localisation) {
  974. if(!tabEM[mob]) return;
  975. var title = 'Composant variable', texte = 'Variable';
  976. var bold = false;
  977. if(tabEM[mob].length>1) {
  978. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  979. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  980. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  981. if(pc<-20) return;
  982. if(pc>=0) bold = true;
  983. texte = aff(pc)+'%';
  984. title = texte+" pour l'écriture de "+tabEM[mob][1];
  985. }
  986. var urlImg = URL_MZimg09
  987. +'Competences/ecritureMagique.png';
  988. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  989. node.appendChild(span);
  990. }
  991.  
  992. function insererInfosEM(tbody) {
  993. // lancé par equip, equipgowap
  994. var trCompos = document.evaluate(
  995. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  996. tbody,null,7,null);
  997. var strCompos = '';
  998. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  999. var node = trCompos.snapshotItem(i).childNodes[7];
  1000. var str = node.firstChild.textContent;
  1001. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1002. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1003. // Si non-EM on stoppe le traitement
  1004. if(!tabEM[mob]) continue;
  1005. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1006. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1007. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1008. addInfoEM(node,mob,compo,qualite,localisation);
  1009. }
  1010. }
  1011.  
  1012. function getQualite(qualite) {
  1013. var nb = numQualite[qualite];
  1014. return nb ? nb-1 : -1;
  1015. }
  1016.  
  1017. function getEM(nom) {
  1018. if(nom.indexOf('[')!=-1)
  1019. nom = trim(nom.substring(0,nom.indexOf('[')));
  1020. if(tabEM[nom]) return nom;
  1021. return '';
  1022. }
  1023.  
  1024. // DEBUG ex-fonction composantEM
  1025. function compoMobEM(mob) {
  1026. if(!tabEM[mob]) return '';
  1027. if(tabEM[mob].length==1)
  1028. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1029. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1030. +") pour l'écriture de "+tabEM[mob][1];
  1031. }
  1032.  
  1033. // DEBUG ex-fonction compoEM
  1034. function titreCompoEM(mob,compo,localisation,qualite) {
  1035. if(!tabEM[mob]) return '';
  1036. if(tabEM[mob].length==1) return 'Composant variable';
  1037. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1038. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1039. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1040. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1041. return '';
  1042. }
  1043.  
  1044. // DEBUG - rétrocompatibilité
  1045. function compoEM(mob) {
  1046. // appelé dans libs, vue
  1047. return compoMobEM(mob);
  1048. }
  1049. function composantEM(mob,compo,localisation,qualite) {
  1050. // appelé dans libs, tancompo
  1051. return titreCompoEM(mob,compo,localisation,qualite);
  1052. }
  1053. //
  1054.  
  1055.  
  1056. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1057.  
  1058. arrayTalents = {
  1059. /* Compétences */
  1060. 'Acceleration du Metabolisme':'AM',
  1061. 'Attaque Precise':'AP',
  1062. 'Balayage':'Balayage',
  1063. //'Balluchonnage':'Ballu',
  1064. 'Baroufle':'Baroufle',
  1065. 'Bidouille':'Bidouille',
  1066. 'Botte Secrete':'BS',
  1067. 'Camouflage':'Camou',
  1068. 'Charger':'Charger',
  1069. 'Connaissance des Monstres':'CdM',
  1070. 'Construire un Piege':'Piege',
  1071. 'Piege a Feu':'PiegeFeu',
  1072. 'Piege a Glue':'PiegeGlue',
  1073. 'Contre-Attaquer':'CA',
  1074. 'Coup de Butoir':'CdB',
  1075. 'Course':'Course',
  1076. 'Deplacement Eclair':'DE',
  1077. 'Dressage':'Dressage',
  1078. 'Ecriture Magique':'EM',
  1079. 'Frenesie':'Frenesie',
  1080. 'Golemologie':'Golemo',
  1081. 'Golem de cuir':'GolemCuir',
  1082. 'Golem de metal':'GolemMetal',
  1083. 'Golem de mithril':'GolemMithril',
  1084. 'Golem de papier':'GolemPapier',
  1085. 'Grattage':'Grattage',
  1086. 'Hurlement Effrayant':'HE',
  1087. 'Identification des Champignons':'IdC',
  1088. 'Insultes':'Insultes',
  1089. 'Lancer de Potions':'LdP',
  1090. 'Marquage':'Marquage',
  1091. 'Melange Magique':'Melange',
  1092. 'Miner':'Miner',
  1093. 'Necromancie':'Necro',
  1094. 'Painthure de Guerre':'PG',
  1095. 'Parer':'Parer',
  1096. 'Pistage':'Pistage',
  1097. 'Planter un Champignon':'PuC',
  1098. 'Regeneration Accrue':'RA',
  1099. 'Reparation':'Reparation',
  1100. 'Retraite':'Retraite',
  1101. 'Rotobaffe':'RB',
  1102. 'Shamaner':'Shamaner',
  1103. "S'interposer":'SInterposer',
  1104. 'Tailler':'Tailler',
  1105. //'Vol':'Vol',
  1106. /* Sortilèges */
  1107. 'Analyse Anatomique':'AA',
  1108. 'Armure Etheree':'AE',
  1109. 'Augmentation de l´Attaque':'AdA',
  1110. 'Augmentation de l´Esquive':'AdE',
  1111. 'Augmentation des Degats':'AdD',
  1112. 'Bulle Anti-Magie':'BAM',
  1113. 'Bulle Magique':'BuM',
  1114. 'Explosion':'Explo',
  1115. 'Faiblesse Passagere':'FP',
  1116. 'Flash Aveuglant':'FA',
  1117. 'Glue':'Glue',
  1118. 'Griffe du Sorcier':'GdS',
  1119. 'Hypnotisme':'Hypno',
  1120. 'Identification des tresors':'IdT',
  1121. 'Invisibilite':'Invi',
  1122. 'Levitation':'Levitation',
  1123. 'Precision Magique':'PreM',
  1124. 'Projectile Magique':'Projo',
  1125. 'Projection':'Proj',
  1126. 'Puissance Magique':'PuM',
  1127. 'Rafale Psychique':'Rafale',
  1128. 'Sacrifice':'Sacro',
  1129. 'Siphon des Ames':'Siphon',
  1130. 'Telekinesie':'Telek',
  1131. 'Teleportation':'TP',
  1132. 'Vampirisme':'Vampi',
  1133. 'Vision Accrue':'VA',
  1134. 'Vision lointaine':'VL',
  1135. 'Voir le Cache':'VlC',
  1136. 'Vue Troublee':'VT'
  1137. //'':''
  1138. }
  1139.  
  1140. // DEBUG - Pour rétrocompatibilité
  1141. function getSortComp(nom,niveau) {
  1142. return getTalent(nom,niveau);
  1143. }
  1144. //
  1145.  
  1146. function getTalent(nom,niveau) {
  1147. var nomEnBase = arrayTalents[epure(nom)];
  1148. if(!nomEnBase) return 0;
  1149. if(!niveau) var niveau = '';
  1150. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1151. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1152. return 0;
  1153. }
  1154.  
  1155. function removeAllTalents() {
  1156. for(var talent in arrayTalents) {
  1157. var nomEnBase = arrayTalents[talent];
  1158. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1159. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1160. continue;
  1161. }
  1162. var niveau = 1;
  1163. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1164. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1165. niveau++;
  1166. }
  1167. }
  1168. }
  1169.  
  1170. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1171. var att = MY_getValue(numTroll+'.caracs.attaque');
  1172. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1173. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1174. var mm = MY_getValue(numTroll+'.caracs.mm');
  1175. var deg = MY_getValue(numTroll+'.caracs.degats');
  1176. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1177. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1178. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1179. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1180. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1181. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1182. return false;
  1183. return true;
  1184. }
  1185.  
  1186.  
  1187. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1188.  
  1189. function getPVsRestants(pv,bless,vue) {
  1190. bless = Number(bless.match(/\d+/)[0]);
  1191. if(bless==0) return null;
  1192. var pvminmax = pv.match(/\d+/g);
  1193. if(bless==95) {
  1194. var pvb = 1;
  1195. var pvh = Math.floor( pvminmax[1]/20 );
  1196. }
  1197. else if(bless==5) {
  1198. var pvb = Math.floor( pvminmax[0]*19/20 );
  1199. var pvh = pvminmax[1];
  1200. }
  1201. else {
  1202. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1203. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1204. }
  1205. return vue ? ' ('+pvb+'-'+pvh+')' :
  1206. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1207. }
  1208.  
  1209. function insertButtonCdm(nextName,onClick,texte) {
  1210. if(texte==null) texte = 'Participer au bestiaire';
  1211. var nextNode = document.getElementsByName(nextName)[0];
  1212.  
  1213. var espace = document.createTextNode('\t');
  1214. insertBefore(nextNode,espace);
  1215.  
  1216. var button = document.createElement('input');
  1217. button.type = 'button';
  1218. button.className = 'mh_form_submit';
  1219. button.value = texte;
  1220. button.onmouseover = function(){this.style.cursor='pointer';};
  1221. if(onClick) button.onclick = onClick;
  1222. insertBefore(espace,button);
  1223. return button;
  1224. }
  1225.  
  1226. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1227. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1228. 'Capacité spéciale','Résistance Magique','Autres'];
  1229.  
  1230. function createImageTactique(url,id,nom) {
  1231. var img = document.createElement('img');
  1232. img.src = url;
  1233. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1234. img.id = id;
  1235. img.nom = nom;
  1236. img.onmouseover = showPopupTactique;
  1237. img.onmouseout = hidePopup;
  1238. return img;
  1239. }
  1240.  
  1241. function createCDMTable(id,nom,donneesMonstre) {
  1242. try {
  1243. var urlImg = URL_MZimg09;
  1244. var table = document.createElement('table');
  1245. var profilActif = isProfilActif();
  1246. table.className = 'mh_tdborder';
  1247. table.border = 0;
  1248. table.cellSpacing = 1;
  1249. table.cellPadding = 4;
  1250. var thead = document.createElement('thead');
  1251. var tr = appendTr(thead,'mh_tdtitre');
  1252. var td = appendTdText(tr,
  1253. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1254. true
  1255. );
  1256. td.colSpan = 2;
  1257. table.appendChild(thead);
  1258. var tbody = document.createElement('tbody');
  1259. table.appendChild(tbody);
  1260. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1261. createCase(listeTitres[i],tbody,80);
  1262. }
  1263. var TypeMonstre = getEM(nom);
  1264. var infosCompo='';
  1265. if(TypeMonstre!='') {
  1266. infosCompo = compoEM(TypeMonstre);
  1267. }
  1268. var nodes = tbody.childNodes;
  1269. nodes[0].childNodes[1].innerHTML =
  1270. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1271. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1272. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1273. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1274. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1275. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1276. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1277. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1278. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1279. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1280. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1281. td = createCase(listeTitres[10],tbody);
  1282. td.innerHTML = bbcode(donneesMonstre[10]);
  1283. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1284. td.appendChild(document.createTextNode(" "));
  1285. if(donneesMonstre[16] == "De zone")
  1286. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1287. else if(donneesMonstre[16] == "Automatique")
  1288. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1289. else if(donneesMonstre[16] == "Au toucher")
  1290. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1291. }
  1292. }
  1293. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1294. {
  1295. td = createCase(listeTitres[11],tbody);
  1296. td.innerHTML = bbcode(donneesMonstre[9]);
  1297. // seuil de résistance du monstre
  1298. var lb = td.getElementsByTagName('b');
  1299. if(lb.length == 1) {
  1300. var mrm = lb[0].firstChild.nodeValue * 1;
  1301. var v = (mrm / mmTroll);
  1302. lb[0].firstChild.nodeValue += " ("
  1303. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1304. }
  1305. }
  1306. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1307. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1308. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1309. {
  1310. td = createCase(listeTitres[12],tbody);
  1311. if(donneesMonstre[12]==1)
  1312. {
  1313. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1314. }
  1315. if(donneesMonstre[13]==1)
  1316. {
  1317. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1318. }
  1319. else if(donneesMonstre[13]==0)
  1320. {
  1321. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1322. }
  1323. if(donneesMonstre[14]==1)
  1324. {
  1325. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1326. }
  1327. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1328. {
  1329. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1330. }
  1331. else if(donneesMonstre[14]>6)
  1332. {
  1333. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1334. }
  1335. if(donneesMonstre[15]=="Lente")
  1336. {
  1337. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1338. }
  1339. else if(donneesMonstre[15]=="Normale")
  1340. {
  1341. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1342. }
  1343. else if(donneesMonstre[15]=="Rapide")
  1344. {
  1345. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1346. }
  1347. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1348. {
  1349. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1350. }
  1351. if(infosCompo.length>0)
  1352. {
  1353. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1354. }
  1355. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1356. {
  1357. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1358. }
  1359. }
  1360. // pourcentage de blessure
  1361. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1362. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1363. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1364. if(pvs)
  1365. lb[0].firstChild.nodeValue += pvs;
  1366. }
  1367. return table;
  1368. }
  1369. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  1370. }
  1371.  
  1372.  
  1373. /*-[functions]------------ Gestion des enchantements -------------------------*/
  1374.  
  1375. var listeMonstreEnchantement = null,
  1376. listeEquipementEnchantement = null,
  1377. listeInfoEnchantement = null;
  1378.  
  1379. function computeCompoEnchantement()
  1380. {
  1381. listeMonstreEnchantement = new Array();
  1382. listeInfoEnchantement = new Array();
  1383. listeEquipementEnchantement = new Array();
  1384. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  1385. for(var i=0;i<liste.length;i++)
  1386. {
  1387. var idEquipement = liste[i]*1;
  1388. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  1389. continue;
  1390. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  1391. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  1392. var texteGlobal='';
  1393. for(var j=0;j<3;j++)
  1394. {
  1395. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  1396. listeMonstreEnchantement[infoComposant[2]] = 1;
  1397. var array = new Array();
  1398. array[0]=infoComposant[0].replace("Ril","Œil");
  1399. array[1]=infoComposant[1];
  1400. array[2]=infoComposant[2];
  1401. array[3]=getQualite(infoComposant[3]);
  1402. var texte = infoComposant[4].replace("Ril","Œil");
  1403. for(var k=5;k<infoComposant.length;k++)
  1404. {
  1405. texte += ";"+infoComposant[k].replace("Ril","Œil");
  1406. }
  1407. texteGlobal+=texte+'\n';
  1408. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1409. array[4]=texte;
  1410. listeInfoEnchantement.push(array);
  1411. }
  1412. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1413. listeEquipementEnchantement[idEquipement] = texteGlobal;
  1414. }
  1415. }
  1416.  
  1417. function isEnchant(nom) {
  1418. var monstreEnchant = '';
  1419. for(j in listeInfoEnchantement) {
  1420. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1421. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1422. monstreEnchant=monstre;
  1423. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  1424. }
  1425. }
  1426. return trim(monstreEnchant);
  1427. }
  1428.  
  1429. function getInfoEnchantementFromMonstre(nom)
  1430. {
  1431. try
  1432. {
  1433. if(!listeMonstreEnchantement)
  1434. {
  1435. computeCompoEnchantement();
  1436. }
  1437. var infosEnchant = '';
  1438. for(j in listeInfoEnchantement) {
  1439. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1440. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1441. if(infosEnchant=='')
  1442. infosEnchant=listeInfoEnchantement[j][4];
  1443. else
  1444. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  1445. }
  1446. }
  1447. return trim(infosEnchant);
  1448. }
  1449. catch(e)
  1450. {
  1451. window.alert(e);
  1452. }
  1453. }
  1454.  
  1455. function composantEnchant(Monstre,composant,localisation,qualite) {
  1456. var compo='';
  1457. for(var i=0; i<listeInfoEnchantement.length; i++) {
  1458. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  1459. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  1460. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  1461. listeInfoEnchantement[i][3]<=qualite
  1462. ) {
  1463. return listeInfoEnchantement[i][4];
  1464. }
  1465. }
  1466. return compo;
  1467. }
  1468.  
  1469. function insertEnchantInfos(tbody) {
  1470. try
  1471. {
  1472. if(!listeMonstreEnchantement)
  1473. computeCompoEnchantement();
  1474. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  1475. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1476. if(nodes.snapshotLength == 0)
  1477. return false;
  1478. var urlImg = URL_MZimg09 + 'enchant.png';
  1479. for(var i = 0; i < nodes.snapshotLength; i++) {
  1480. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  1481. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  1482. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  1483. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  1484. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  1485. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  1486. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  1487. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  1488. if(isEnchant(nomMonstre).length>0)
  1489. {
  1490. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  1491. if(infos.length>0)
  1492. {
  1493. if(link.parentNode == link.nextSibling.parentNode)
  1494. {
  1495. var tmp = link.nextSibling;
  1496. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  1497. }
  1498. else
  1499. {
  1500. link.parentNode.appendChild(createImage(urlImg,infos));
  1501. }
  1502. }
  1503. }
  1504. }
  1505. }
  1506. catch(e)
  1507. {
  1508. window.alert(e);
  1509. }
  1510. }
  1511.  
  1512. function computeEnchantementEquipement(fontionTexte,formateTexte)
  1513. {
  1514. try
  1515. {
  1516. if(!listeMonstreEnchantement)
  1517. computeCompoEnchantement();
  1518. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  1519. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1520. if(nodes.snapshotLength == 0)
  1521. return false;
  1522. var urlImg = URL_MZimg09 + 'enchant.png';
  1523. for(var i = 0; i < nodes.snapshotLength; i++)
  1524. {
  1525. var link = nodes.snapshotItem(i);
  1526. var idEquipement = link.getAttribute('href');
  1527. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  1528. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  1529. var nomEquipement = trim(link.firstChild.nodeValue);
  1530. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  1531. if(!enchanteur || enchanteur == '')
  1532. continue;
  1533. var infos = listeEquipementEnchantement[idEquipement];
  1534. infos=formateTexte(infos);
  1535. if(infos.length>0)
  1536. {
  1537. if(link.parentNode == link.nextSibling.parentNode)
  1538. {
  1539. var tmp = link.nextSibling;
  1540. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  1541. }
  1542. else
  1543. {
  1544. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  1545. }
  1546. }
  1547. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  1548. }
  1549. }
  1550. catch(e)
  1551. {
  1552. window.alert(e);
  1553. }
  1554. }
  1555.  
  1556. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  1557.  
  1558.  
  1559. // Les % de toucher
  1560. var c = new Array();
  1561.  
  1562. // coefficients binomiaux
  1563. function cnp(n,k)
  1564. {
  1565. if(c[n] != null && c[n][k] != null)
  1566. return c[n][k];
  1567. if(c[n] == null)
  1568. c[n] = new Array();
  1569. if(k==0)
  1570. {
  1571. c[n][k] = 1;
  1572. return 1;
  1573. }
  1574. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  1575. c[n][k] = result;
  1576. // Roule debug
  1577. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  1578. return result;
  1579. }
  1580.  
  1581. // by Dab, à comparer
  1582. function binom(n,p) {
  1583. if(p<0 || p>n) return 0;
  1584. if(c[n])
  1585. if(c[n][p]) return c[n][p];
  1586. else {
  1587. c[n]=[1];
  1588. c[n][n]=1;
  1589. if(p==0 || p==n) return 1;
  1590. }
  1591. if(2*p>n)
  1592. c[n][p]=binom(n,n-p);
  1593. else
  1594. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  1595. return c[n][p];
  1596. }
  1597.  
  1598. var coeff = new Array();
  1599.  
  1600. function coef(n,p)
  1601. {
  1602. if(n==0 && p==0)
  1603. return 1;
  1604. if(p>n*3.5)
  1605. p = 7*n-p
  1606. // roule désactive cache
  1607. if(coeff[n] != null && coeff[n][p] !=null)
  1608. return coeff[n][p];
  1609. if(coeff[n] == null)
  1610. coeff[n] = new Array();
  1611. var kmax = Math.floor((p-n)/6);
  1612. var x=0;
  1613. for(var k=0;k<=kmax;k++)
  1614. {
  1615. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  1616. }
  1617. coeff[n][p] = x;
  1618. // Roule debug
  1619. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  1620. return x;
  1621. }
  1622.  
  1623. function chanceEsquiveParfaite(a,d,ba,bd)
  1624. {
  1625. var win = 0;
  1626. var los = 0;
  1627. if(ba==null)
  1628. ba=0;
  1629. if(bd==null)
  1630. bd=0;
  1631. /* if(6*a+ba<2*(d+bd))
  1632. return 100;
  1633. if(a+ba>2*(6*d+bd))
  1634. return 0;*/
  1635. for(var ds=d;ds<=6*d;ds++)
  1636. {
  1637. var cd = coef(d,ds);
  1638. for(var as=a;as<=6*a;as++)
  1639. {
  1640. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  1641. win += cd * coef(a,as);
  1642. else
  1643. los += cd * coef(a,as);
  1644. }
  1645. }
  1646. // roule debug
  1647. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  1648. return Math.round(100*win/(win+los));
  1649. }
  1650.  
  1651. function chanceTouche(a,d,ba,bd)
  1652. {
  1653. var win = 0;
  1654. var los = 0;
  1655. if(ba==null)
  1656. ba=0;
  1657. if(bd==null)
  1658. bd=0;
  1659. if(a+ba>6*d+bd)
  1660. return 100;
  1661. if(6*a+ba<d+bd)
  1662. return 0;
  1663. for(var ds=d;ds<=6*d;ds++)
  1664. {
  1665. var cd = coef(d,ds);
  1666. for(var as=a;as<=6*a;as++)
  1667. {
  1668. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  1669. win += cd * coef(a,as);
  1670. else
  1671. los += cd * coef(a,as);
  1672. }
  1673. }
  1674. return Math.round(100*win/(win+los));
  1675. }
  1676.  
  1677. function chanceCritique(a,d,ba,bd)
  1678. {
  1679. var win = 0;
  1680. var los = 0;
  1681. if(ba==null)
  1682. ba=0;
  1683. if(bd==null)
  1684. bd=0;
  1685. if(a+ba>2*(6*d+bd))
  1686. return 100;
  1687. if(6*a+ba<2*(d+bd))
  1688. return 0;
  1689. for(var ds=d;ds<=6*d;ds++)
  1690. {
  1691. var cd = coef(d,ds);
  1692. for(var as=a;as<=6*a;as++)
  1693. {
  1694. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  1695. win += cd * coef(a,as);
  1696. else
  1697. los += cd * coef(a,as);
  1698. }
  1699. }
  1700. return Math.round(100*win/(win+los));
  1701. }
  1702.  
  1703. /***********************************************
  1704. Analyse tactique
  1705. ***********************************************/
  1706.  
  1707. function getTexteAnalyse(modificateur,chiffre)
  1708. {
  1709. if(chiffre==0)
  1710. return chiffre;
  1711. return modificateur+chiffre;
  1712. }
  1713.  
  1714. function getAnalyseTactique(id,nom)
  1715. {
  1716. var donneesMonstre = listeCDM[id];
  1717. var needAutres=false;
  1718. var i;
  1719. if(donneesMonstre == null)
  1720. return;
  1721. var array = analyseTactique(donneesMonstre,nom);
  1722. if(array==null)
  1723. return "";
  1724. 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>";
  1725. for(i=0;i<array.length;i++)
  1726. {
  1727. if(array[i][1]==100 && i>0)
  1728. {
  1729. needAutres=true;
  1730. break;
  1731. }
  1732. if(i==1 && array[i][4]>0)
  1733. 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>";
  1734. else if(i==0)
  1735. 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>";
  1736. else
  1737. 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>";
  1738. }
  1739. if(needAutres)
  1740. {
  1741. if(i==array.length-1)
  1742. 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>";
  1743. else if(i==1)
  1744. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  1745. else
  1746. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  1747. }
  1748. return str+"</table>";
  1749. }
  1750.  
  1751. function analyseTactique(donneesMonstre,nom) {
  1752. try
  1753. {
  1754. var listeAttaques = [];
  1755. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  1756. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  1757. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  1758. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  1759. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  1760. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  1761. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  1762. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  1763. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  1764. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  1765. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  1766. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  1767. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  1768. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  1769. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  1770. var modificateurEsquive = '';
  1771. var modificateurArmure = '';
  1772. var modificateurMagie = '';
  1773. var modificateurEsquiveM = '';
  1774. var modificateurArmureM = '';
  1775. var pasDeSR=false;
  1776. var esqM,attM,armM,degM;
  1777. 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)
  1778. return null;
  1779. var td = document.createElement('td')
  1780. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  1781. var esqM = 0;
  1782. try
  1783. {
  1784. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1785. }
  1786. catch(e)
  1787. {
  1788. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1789. modificateurEsquive = '<';
  1790. modificateurArmure = '<';
  1791. modificateurMagie = '<';
  1792. }
  1793. td.innerHTML = bbcode(donneesMonstre[3]);
  1794. var attM = 0;
  1795. try
  1796. {
  1797. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1798. }
  1799. catch(e)
  1800. {
  1801. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1802. modificateurEsquiveM = '>';
  1803. modificateurArmureM = '>';
  1804. }
  1805. td.innerHTML = bbcode(donneesMonstre[5]);
  1806. var degM = 0;
  1807. try
  1808. {
  1809. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1810. }
  1811. catch(e)
  1812. {
  1813. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1814. modificateurArmureM = '>';
  1815. }
  1816. td.innerHTML = bbcode(donneesMonstre[7]);
  1817. var armM = 0;
  1818. try
  1819. {
  1820. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1821. }
  1822. catch(e)
  1823. {
  1824. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1825. modificateurArmure = '<';
  1826. }
  1827. var coeffSeuil = 0.95;
  1828. try
  1829. {
  1830. td.innerHTML = bbcode(donneesMonstre[9]);
  1831. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1832. var v = (rm / mm);
  1833. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  1834. coeffSeuil = (200-seuil)/200;
  1835. }
  1836. catch(e)
  1837. {
  1838. modificateurMagie = '<';
  1839. pasDeSR = true;
  1840. }
  1841. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  1842. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  1843. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  1844. // roule debug
  1845. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  1846. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  1847. 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);
  1848. //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);
  1849. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1850. if(getSortComp("Vampirisme")>0)
  1851. {
  1852. var pour = getSortComp("Vampirisme");
  1853. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  1854. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  1855. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  1856. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  1857. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1858. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  1859. }
  1860. if(getSortComp("Botte Secrète")>0)
  1861. {
  1862. var pour = getSortComp("Botte Secrète");
  1863. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  1864. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  1865. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  1866. 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;
  1867. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1868. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1869. }
  1870. if(getSortComp("Rafale Psychique")>0)
  1871. {
  1872. var pour = getSortComp("Rafale Psychique");
  1873. chanceDEsquiveParfaite = 0;
  1874. chanceDeTouche = Math.round(100*pour/100);
  1875. chanceDeCritique = Math.round(0*pour/100);
  1876. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  1877. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1878. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  1879. }
  1880. if(getSortComp("Explosion")>0)
  1881. {
  1882. var pour = getSortComp("Explosion");
  1883. chanceDEsquiveParfaite = 0;
  1884. chanceDeTouche = Math.round(100*pour/100);
  1885. chanceDeCritique = Math.round(0*pour/100);
  1886. 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;
  1887. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1888. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  1889. }
  1890. if(getSortComp("Projectile Magique")>0)
  1891. {
  1892. var pour = getSortComp("Projectile Magique");
  1893. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  1894. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  1895. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  1896. 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;
  1897. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1898. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  1899. }
  1900. if(getSortComp("Frénésie")>0)
  1901. {
  1902. var pour = getSortComp("Frénésie");
  1903. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  1904. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  1905. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  1906. 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;
  1907. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1908. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1909. }
  1910. if(getSortComp("Charger")>0)
  1911. {
  1912. var pour = getSortComp("Charger");
  1913. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  1914. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  1915. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  1916. 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;
  1917. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1918. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  1919. }
  1920. if(getSortComp("Griffe du Sorcier")>0)
  1921. {
  1922. var pour = getSortComp("Griffe du Sorcier");
  1923. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  1924. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  1925. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  1926. 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;
  1927. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  1928. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  1929. }
  1930. if(getSortComp("Attaque Précise",1)>0)
  1931. {
  1932. var niveau = 5;
  1933. var oldPour = 0;
  1934. var chanceDEsquiveParfaite = 0;
  1935. var chanceDeTouche = 0;
  1936. var chanceDeCritique = 0;
  1937. degats = 0;
  1938. while(niveau>0)
  1939. {
  1940. var pour = getSortComp("Attaque Précise",niveau);
  1941. if(pour>oldPour)
  1942. {
  1943. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1944. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1945. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1946. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  1947. chanceDeTouche += chanceDeToucheNiveau;
  1948. chanceDeCritique += chanceDeCritiqueNiveau;
  1949. 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);
  1950. oldPour = pour;
  1951. }
  1952. niveau--;
  1953. }
  1954. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  1955. 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));
  1956. }
  1957. if(getSortComp("Coup de Butoir",1)>0)
  1958. {
  1959. var niveau = 5;
  1960. var oldPour =0;
  1961. var chanceDEsquiveParfaite = 0;
  1962. var chanceDeTouche=0;
  1963. var chanceDeCritique=0;
  1964. degats=0;
  1965. while(niveau>0)
  1966. {
  1967. var pour = getSortComp("Coup de Butoir",niveau);
  1968. if(pour>oldPour)
  1969. {
  1970. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1971. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1972. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  1973. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  1974. chanceDeTouche += chanceDeToucheNiveau;
  1975. chanceDeCritique += chanceDeCritiqueNiveau;
  1976. 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);
  1977. oldPour = pour;
  1978. }
  1979. niveau--;
  1980. }
  1981. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  1982. 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));
  1983. }
  1984. 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;});
  1985. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  1986. {
  1987. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  1988. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  1989. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  1990. }
  1991. else
  1992. {
  1993. chanceDEsquiveParfaite = 0;
  1994. chanceDeTouche = 100;
  1995. chanceDeCritique = 0;
  1996. }
  1997. 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;
  1998.  
  1999. 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));
  2000. return listeAttaques;
  2001. }
  2002. catch(e) { window.alert(e);}
  2003. }
  2004.  
  2005. // x~~x marque pour s'y retrouver sous l'éditeur
  2006.  
  2007. /*
  2008. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2009. * published under GNU License v2.
  2010. *
  2011. * Patch :
  2012. * gestion des missions terminées
  2013. */
  2014. // x~x mission_liste
  2015.  
  2016. function checkLesMimis() {
  2017. try {
  2018. var titresMimis = document.evaluate(
  2019. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2020. document, null, 7, null
  2021. );
  2022. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2023. } catch(e) {
  2024. window.console.error('[MZ mission_liste] Erreur initialisation:\n'+e);
  2025. return;
  2026. }
  2027. var enCours = {};
  2028. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2029. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2030. enCours[num] = true;
  2031. }
  2032. for(var numMimi in obMissions) {
  2033. if(!enCours[numMimi]) {
  2034. delete obMissions[numMimi];
  2035. }
  2036. }
  2037. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2038. }
  2039.  
  2040. function do_mission_liste() {
  2041. checkLesMimis();
  2042. }
  2043.  
  2044. /*******************************************************************************
  2045. * This file is part of Mountyzilla. *
  2046. * *
  2047. * Mountyzilla is free software; you can redistribute it and/or modify *
  2048. * it under the terms of the GNU General Public License as published by *
  2049. * the Free Software Foundation; either version 2 of the License, or *
  2050. * (at your option) any later version. *
  2051. * *
  2052. * Mountyzilla is distributed in the hope that it will be useful, *
  2053. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2054. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2055. * GNU General Public License for more details. *
  2056. * *
  2057. * You should have received a copy of the GNU General Public License *
  2058. * along with Mountyzilla; if not, write to the Free Software *
  2059. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2060. *******************************************************************************/
  2061.  
  2062. // x~x actions
  2063.  
  2064. /* TODO
  2065. * getLvl pour Explo, Rotobaffe et cie
  2066. */
  2067.  
  2068.  
  2069.  
  2070. /* Page de combat */
  2071.  
  2072. function getLevel() {
  2073. var divList = document.getElementsByTagName('div');
  2074. if(divList.length <= 2)
  2075. return;
  2076. // On essaie de voir si cette action était une attaque
  2077. var pList = document.getElementsByTagName('p');
  2078. var nomM = '';
  2079. // Modification pour Frénésie by TetDure
  2080. var numAtt = 0;
  2081. for (var i = 0; i < pList.length; i++) {
  2082. if(pList[i].firstChild) {
  2083. nomM = pList[i].firstChild.nodeValue;
  2084. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2085. numAtt++;
  2086. }
  2087. }
  2088. if(nomM == '')
  2089. return;
  2090. // Si c'est une attaque normale, un seul PX
  2091. var comPX = 1;
  2092. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2093. comPX++;
  2094.  
  2095. // Extraction des infos du monstre attaqué
  2096. var idM;
  2097. var male;
  2098. if(nomM.slice(20, 21) == 'e') {
  2099. male = false;
  2100. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2101. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2102. }
  2103. else {
  2104. male = true;
  2105. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2106. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2107. }
  2108. if(idM == '')
  2109. return;
  2110. var bList = document.getElementsByTagName('b');
  2111. var niveau = '';
  2112. for (var i = 0; i < bList.length; i++) {
  2113. var b = bList[i];
  2114. if(b.childNodes[0].nodeValue != "TUÉ")
  2115. continue;
  2116. var nbPX = "";
  2117. for (i++; i < bList.length; i++) {
  2118. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2119. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2120. return;
  2121. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2122. nbPX = bList[i].childNodes[0].nodeValue;
  2123. break;
  2124. }
  2125. }
  2126. if(nbPX == '')
  2127. return;
  2128. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2129. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2130. if(!nbPX)
  2131. nbPX = 0;
  2132. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2133. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2134. if(comPX > nbPX) {
  2135. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2136. niveau = "";
  2137. } else if(Math.floor(niveau) == niveau) {
  2138. chaine += niveau + ".";
  2139. } else {
  2140. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2141. niveau = "";
  2142. }
  2143. insertBr(b.nextSibling.nextSibling.nextSibling);
  2144. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2145. }
  2146.  
  2147. if(niveau != '') {
  2148. var button = insertButtonCdm('as_Action');
  2149. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2150. + escape(nomM) + "&niveau=" + escape(niveau)
  2151. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2152. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2153. }
  2154. }
  2155.  
  2156.  
  2157. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2158.  
  2159. function insertInfoMagie(node, intitule, magie) {
  2160. if(node.nextSibling) {
  2161. node = node.nextSibling;
  2162. insertBr(node);
  2163. insertText(node, intitule);
  2164. insertText(node, magie, true);
  2165. } else {
  2166. node = node.parentNode;
  2167. appendBr(node);
  2168. appendText(node, intitule);
  2169. appendText(node, magie, true);
  2170. }
  2171. }
  2172.  
  2173. function getMM(sr) {
  2174. if(rmTroll<=0) {
  2175. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2176. }
  2177. sr = Number(sr.match(/\d+/)[0]);
  2178. if(sr==10) {
  2179. return '\u2265 '+5*rmTroll;
  2180. }
  2181. if(sr<=50) {
  2182. return Math.round(50*rmTroll/sr);
  2183. }
  2184. if(sr<90) {
  2185. return Math.round((100-sr)*rmTroll/50);
  2186. }
  2187. return '\u2264 '+Math.round(rmTroll/5);
  2188. }
  2189.  
  2190. function traiteMM() {
  2191. var node = document.evaluate(
  2192. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2193. document, null, 9, null).singleNodeValue;
  2194. if(node) {
  2195. var mm = getMM(node.nodeValue);
  2196. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2197. } else {
  2198. var node = document.evaluate(
  2199. "//p/text()[contains(., 'Seuil de Résistance')]",
  2200. document, null, 9, null).singleNodeValue;
  2201. if(!node) {
  2202. return;
  2203. }
  2204. var mm = getMM(node.nodeValue);
  2205. node = node.nextSibling.nextSibling;
  2206. }
  2207. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2208. }
  2209.  
  2210. function getRM(sr) {
  2211. if(mmTroll<=0) {
  2212. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2213. }
  2214. sr = Number(sr.match(/\d+/)[0]);
  2215. if(sr==10) {
  2216. return '\u2264 '+Math.round(mmTroll/5);
  2217. }
  2218. if(sr<=50) {
  2219. return Math.round(sr*mmTroll/50);
  2220. }
  2221. if(sr<90) {
  2222. return Math.round(50*mmTroll/(100-sr));
  2223. }
  2224. return '\u2265 '+5*mmTroll;
  2225. }
  2226.  
  2227. function traiteRM() {
  2228. var nodes = document.evaluate(
  2229. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2230. document, null, 7, null);
  2231. if(nodes.snapshotLength==0) {
  2232. return;
  2233. }
  2234. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2235. var node = nodes.snapshotItem(i);
  2236. var rm = getRM(node.nodeValue);
  2237. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2238. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2239. }
  2240. }
  2241.  
  2242.  
  2243. /* Fonction stats IdT par Raistlin */
  2244. /*function getIdt() {
  2245. if(MY_getValue("SEND_IDT") == "non")
  2246. return false;
  2247. var regExpBeginning = /^\s+/;
  2248. var regExpEnd = /\s+$/;
  2249.  
  2250. var nomIdt = document.evaluate(
  2251. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2252. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2253. if(!nomIdt)
  2254. return false;
  2255.  
  2256. var caracIdt;
  2257. if(nomIdt.indexOf("Malédiction !") != -1) {
  2258. caracIdt = "";
  2259. nomIdt = "Mission maudite";
  2260. } else {
  2261. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2262. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2263. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2264. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2265. }
  2266. FF_XMLHttpRequest({
  2267. method: 'GET',
  2268. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2269. headers : {
  2270. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2271. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2272. }
  2273. });
  2274. return true;
  2275. }*/
  2276.  
  2277.  
  2278. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2279.  
  2280. function confirmeDecalage() {
  2281. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2282. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2283. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2284. var newDLA = new Date( oldDLA );
  2285. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2286. return window.confirm(
  2287. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2288. +'\nConfirmez-vous ce décalage ?'
  2289. );
  2290. }
  2291.  
  2292. function newsubmitDLA(evt) {
  2293. evt.stopPropagation();
  2294. evt.preventDefault();
  2295. if(confirmeDecalage()) {
  2296. this.submit();
  2297. }
  2298. }
  2299.  
  2300. function changeActionDecalage() {
  2301. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2302. return;
  2303. }
  2304. try {
  2305. // On récupère le contenu du script JS MH de calcul du décalage
  2306. var scriptTxt = document.evaluate(
  2307. ".//script[ not(@src) ]",
  2308. document, null, 9, null
  2309. ).singleNodeValue.textContent;
  2310. // On en extrait la DLA courante
  2311. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2312. scriptTxt = scriptTxt.split('\n')[0];
  2313. var nbs = scriptTxt.match(/\d+/g);
  2314. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2315. } catch(e) {
  2316. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2317. window.console.error('[changeActionDecalage] DLA non trouvée',e);
  2318. return;
  2319. }
  2320. var form = document.getElementsByName('ActionForm')[0];
  2321. if(form) {
  2322. form.addEventListener('submit', newsubmitDLA, true);
  2323. } else {
  2324. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2325. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2326. }
  2327. }
  2328.  
  2329. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2330.  
  2331. function prochainMundi() {
  2332. try {
  2333. var node = document.evaluate(
  2334. "//div[@class='dateAction']/b",
  2335. document, null, 9, null
  2336. ).singleNodeValue;
  2337. } catch(e) {
  2338. window.console.error('[prochainMundi] Date introuvable',e);
  2339. return;
  2340. }
  2341. if(!node) { return; }
  2342.  
  2343. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2344. var jour = longueurMois+1-getNumber(node.textContent);
  2345. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2346. var txt = '[Prochain Mundidey ';
  2347. if(jour>1) {
  2348. txt += 'dans '+jour+' jours]';
  2349. } else {
  2350. txt += 'demain]';
  2351. }
  2352. insertText(node.parentNode.nextSibling,txt,true);
  2353. }
  2354.  
  2355.  
  2356. /* Fonction principale */
  2357.  
  2358. function dispatch() {
  2359. if(isPage('MH_Play/Play_action')) {
  2360. prochainMundi();
  2361. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2362. var oldDLA;
  2363. changeActionDecalage();
  2364. } else if(isPage('MH_Play/Actions')) {
  2365. if(document.evaluate(
  2366. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  2367. document, null, 2, null
  2368. ).stringValue) {
  2369. traiteMM();
  2370. } else if(document.evaluate(
  2371. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  2372. document, null, 2, null
  2373. ).stringValue) {
  2374. //getIdt();
  2375. traiteRM();
  2376. } /*else {
  2377. // Est censé se lancer sur quoi *précisément* ?
  2378. traiteRM();
  2379. getLevel();
  2380. }*/
  2381. } else {
  2382. /* Traitement des messages du bot */
  2383. var messageTitle = document.evaluate(
  2384. "//form/table/tbody/tr[1]/td[1]/"
  2385. +"descendant::text()[contains(.,'[MountyHall]')]",
  2386. document, null, 2, null
  2387. ).stringValue;
  2388. if(messageTitle.indexOf('Attaquant') != -1 &&
  2389. messageTitle.indexOf('sur') != -1) {
  2390. getLevel();
  2391. traiteRM();
  2392. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  2393. messageTitle.indexOf('Défenseur') != -1) {
  2394. traiteMM();
  2395. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  2396. // à replacer avec Attaque après révision getLvl :
  2397. messageTitle.indexOf('Explosion') != -1 ||
  2398. messageTitle.indexOf('Insulte') != -1) {
  2399. traiteRM();
  2400. }
  2401. }
  2402. }
  2403.  
  2404. function do_actions() {
  2405. start_script(31);
  2406. dispatch();
  2407. displayScriptTime();
  2408. }
  2409.  
  2410. /*********************************************************************************
  2411. * This file is part of Mountyzilla. *
  2412. * *
  2413. * Mountyzilla is free software; you can redistribute it and/or modify *
  2414. * it under the terms of the GNU General Public License as published by *
  2415. * the Free Software Foundation; either version 2 of the License, or *
  2416. * (at your option) any later version. *
  2417. * *
  2418. * Mountyzilla is distributed in the hope that it will be useful, *
  2419. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2420. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2421. * GNU General Public License for more details. *
  2422. * *
  2423. * You should have received a copy of the GNU General Public License *
  2424. * along with Mountyzilla; if not, write to the Free Software *
  2425. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2426. *********************************************************************************/
  2427.  
  2428. // x~x pre-enchant
  2429.  
  2430. /* 2013-08-19 : correction auto syntaxe alert */
  2431.  
  2432. var combobox=null;
  2433.  
  2434. function changeObject()
  2435. {
  2436. if(!combobox)
  2437. return ;
  2438. var id = combobox.options[combobox.selectedIndex].value;
  2439. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  2440. if(!id || id=="")
  2441. {
  2442. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2443. return;
  2444. }
  2445. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  2446. }
  2447.  
  2448. function treatePreEnchantement() {
  2449. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2450. if(!input || input.getAttribute("type")=="hidden")
  2451. {
  2452. return false;
  2453. }
  2454. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  2455. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2456. if(!combobox)
  2457. {
  2458. return true;
  2459. }
  2460. combobox.addEventListener('change', changeObject, true);
  2461. return true;
  2462. }
  2463.  
  2464. function treateEnchantement() {
  2465. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2466. if(!input || input.getAttribute("type")!="hidden")
  2467. {
  2468. return false;
  2469. }
  2470. var idEquipement = input.getAttribute("value");
  2471. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  2472. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  2473. if(enchanteur && enchanteur != null)
  2474. return true;
  2475. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2476. if(!input || input.getAttribute("type")!="hidden")
  2477. {
  2478. return false;
  2479. }
  2480. var idEnchanteur = input.getAttribute("value");
  2481. var nodes = document.evaluate(
  2482. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2483. if (nodes.snapshotLength != 3)
  2484. return;
  2485. for(var i=0;i<3;i++)
  2486. {
  2487. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2488. texte = texte.replace(" d'une "," d'un ");
  2489. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2490. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2491. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2492. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2493. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2494. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2495. }
  2496. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2497. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2498. var liste = MY_getValue(numTroll+".enchantement.liste");
  2499. if(!liste || liste=="")
  2500. {
  2501. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2502. }
  2503. else
  2504. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2505. }
  2506.  
  2507. function do_pre_enchant() {
  2508. start_script(60);
  2509. if(!treatePreEnchantement())
  2510. treateEnchantement();
  2511. displayScriptTime();
  2512. }
  2513.  
  2514. /*********************************************************************************
  2515. * This file is part of Mountyzilla. *
  2516. * *
  2517. * Mountyzilla is free software; you can redistribute it and/or modify *
  2518. * it under the terms of the GNU General Public License as published by *
  2519. * the Free Software Foundation; either version 2 of the License, or *
  2520. * (at your option) any later version. *
  2521. * *
  2522. * Mountyzilla is distributed in the hope that it will be useful, *
  2523. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2524. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2525. * GNU General Public License for more details. *
  2526. * *
  2527. * You should have received a copy of the GNU General Public License *
  2528. * along with Mountyzilla; if not, write to the Free Software *
  2529. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2530. *********************************************************************************/
  2531.  
  2532. // x~x enchant
  2533.  
  2534. /* 2013-08-19 : correction auto syntaxe alert */
  2535.  
  2536. function treateEnchantement() {
  2537. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  2538. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  2539. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  2540. return;
  2541. var tab = infoEquipement.split(";");
  2542. if(tab.length<2)
  2543. return;
  2544. var idEquipement = tab[0];
  2545. var nomEquipement = tab[1];
  2546. for(var i=2;i<tab.length;i++)
  2547. nomEquipement += ";"+tab[i];
  2548. var nodes = document.evaluate(
  2549. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2550. if (nodes.snapshotLength != 3)
  2551. return;
  2552. for(var i=0;i<3;i++)
  2553. {
  2554. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2555. texte = texte.replace(" d'une "," d'un ");
  2556. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2557. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2558. monstre = monstre.replace(/ Géante?/,"");
  2559. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2560. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2561. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2562. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2563. }
  2564. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2565. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2566. var liste = MY_getValue(numTroll+".enchantement.liste");
  2567. if(!liste || liste=="")
  2568. {
  2569. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2570. }
  2571. else
  2572. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2573. }
  2574.  
  2575. function do_enchant() {
  2576. start_script(60);
  2577.  
  2578. treateEnchantement();
  2579. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2580. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  2581. displayScriptTime();
  2582. }
  2583.  
  2584. /*********************************************************************************
  2585. * This file is part of Mountyzilla. *
  2586. * *
  2587. * Mountyzilla is free software; you can redistribute it and/or modify *
  2588. * it under the terms of the GNU General Public License as published by *
  2589. * the Free Software Foundation; either version 2 of the License, or *
  2590. * (at your option) any later version. *
  2591. * *
  2592. * Mountyzilla is distributed in the hope that it will be useful, *
  2593. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2594. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2595. * GNU General Public License for more details. *
  2596. * *
  2597. * You should have received a copy of the GNU General Public License *
  2598. * along with Mountyzilla; if not, write to the Free Software *
  2599. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2600. *********************************************************************************/
  2601.  
  2602. // x~x myevent
  2603.  
  2604. // Script désactivé en attendant la màj vers le nouveau système de missions.
  2605. function do_myevent() {
  2606. }
  2607.  
  2608. /*********************************************************************************
  2609. * This file is part of Mountyzilla. *
  2610. * *
  2611. * Mountyzilla is free software; you can redistribute it and/or modify *
  2612. * it under the terms of the GNU General Public License as published by *
  2613. * the Free Software Foundation; either version 2 of the License, or *
  2614. * (at your option) any later version. *
  2615. * *
  2616. * Mountyzilla is distributed in the hope that it will be useful, *
  2617. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2618. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2619. * GNU General Public License for more details. *
  2620. * *
  2621. * You should have received a copy of the GNU General Public License *
  2622. * along with Mountyzilla; if not, write to the Free Software *
  2623. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2624. *********************************************************************************/
  2625.  
  2626. // x~x malus
  2627.  
  2628. /* v1.4 - 2014-01-06
  2629. * - Gestion des sorts double composante
  2630. * v1.4.1 - 2014-01-22
  2631. * - Correction décumul
  2632. * TODO
  2633. * - Identifier la position de "PV" dans l'ordre MH
  2634. */
  2635.  
  2636. var listeBM;
  2637.  
  2638.  
  2639. /* [functions] Utilitaires */
  2640.  
  2641. function decumul(bmt,nbr) {
  2642. var bmr;
  2643. if(!nbr || nbr<2) bmr = bmt;
  2644. else if(nbr==2) bmr = parseInt(0.67*bmt);
  2645. else if(nbr==3) bmr = parseInt(0.40*bmt);
  2646. else if(nbr==4) bmr = parseInt(0.25*bmt);
  2647. else if(nbr==5) bmr = parseInt(0.15*bmt);
  2648. else bmr = parseInt(0.1*bmt);
  2649. if(bmt<0) return Math.min(-1,bmr);
  2650. return Math.max(1,bmr);
  2651. }
  2652.  
  2653. function triecaracs(a,b) { // version Yoyor, mod by Dab
  2654. // Roule 23/11/2016 ajout PV
  2655. switch( a ) {
  2656. case 'ATT':
  2657. return -1;
  2658. case 'ESQ':
  2659. if(b=='ATT') return 1;
  2660. return -1;
  2661. case 'DEG':
  2662. switch( b ) {
  2663. case 'ATT':
  2664. case 'ESQ':
  2665. return 1;
  2666. default:
  2667. return -1;
  2668. }
  2669. case 'REG':
  2670. switch( b ) {
  2671. case 'ATT':
  2672. case 'ESQ':
  2673. case 'DEG':
  2674. return 1;
  2675. default:
  2676. return -1;
  2677. }
  2678. case 'Vue':
  2679. switch( b ) {
  2680. case 'ATT':
  2681. case 'ESQ':
  2682. case 'DEG':
  2683. case 'REG':
  2684. return 1;
  2685. default:
  2686. return -1;
  2687. }
  2688. case 'TOUR':
  2689. switch( b ) {
  2690. case 'ATT':
  2691. case 'ESQ':
  2692. case 'DEG':
  2693. case 'REG':
  2694. case 'Vue':
  2695. return 1;
  2696. default:
  2697. return -1;
  2698. }
  2699. case 'PV':
  2700. switch( b ) {
  2701. case 'ATT':
  2702. case 'ESQ':
  2703. case 'DEG':
  2704. case 'REG':
  2705. case 'Vue':
  2706. case 'TOUR':
  2707. return 1;
  2708. default:
  2709. return -1;
  2710. }
  2711. case 'Armure':
  2712. switch( b ) {
  2713. case 'ATT':
  2714. case 'ESQ':
  2715. case 'DEG':
  2716. case 'REG':
  2717. case 'Vue':
  2718. case 'TOUR':
  2719. case 'PV':
  2720. return 1;
  2721. default:
  2722. return -1;
  2723. }
  2724. case 'RM':
  2725. switch( b ) {
  2726. case 'ATT':
  2727. case 'ESQ':
  2728. case 'DEG':
  2729. case 'REG':
  2730. case 'Vue':
  2731. case 'TOUR':
  2732. case 'PV':
  2733. case 'Armure':
  2734. return 1;
  2735. default:
  2736. return -1;
  2737. }
  2738. case 'MM':
  2739. switch( b ) {
  2740. case 'ATT':
  2741. case 'ESQ':
  2742. case 'DEG':
  2743. case 'REG':
  2744. case 'Vue':
  2745. case 'TOUR':
  2746. case 'PV':
  2747. case 'Armure':
  2748. case 'RM':
  2749. return 1;
  2750. default:
  2751. return -1;
  2752. }
  2753. case 'Concentration':
  2754. switch( b ) {
  2755. case 'ATT':
  2756. case 'ESQ':
  2757. case 'DEG':
  2758. case 'REG':
  2759. case 'Vue':
  2760. case 'TOUR':
  2761. case 'PV':
  2762. case 'Armure':
  2763. case 'RM':
  2764. case 'MM':
  2765. return 1;
  2766. default:
  2767. return -1;
  2768. }
  2769. case 'Fatigue':
  2770. switch( b ) {
  2771. case 'ATT':
  2772. case 'ESQ':
  2773. case 'DEG':
  2774. case 'REG':
  2775. case 'Vue':
  2776. case 'TOUR':
  2777. case 'PV':
  2778. case 'Armure':
  2779. case 'RM':
  2780. case 'MM':
  2781. case 'Concentration':
  2782. return 1;
  2783. default:
  2784. return -1;
  2785. }
  2786. case "Dés d'attaque":
  2787. switch( b ) {
  2788. case 'ATT':
  2789. case 'ESQ':
  2790. case 'DEG':
  2791. case 'REG':
  2792. case 'Vue':
  2793. case 'TOUR':
  2794. case 'PV':
  2795. case 'Armure':
  2796. case 'RM':
  2797. case 'MM':
  2798. case 'Concentration':
  2799. case 'Fatigue':
  2800. return 1;
  2801. default:
  2802. return -1;
  2803. }
  2804. case 'Dés de dégâts':
  2805. switch( b ) {
  2806. case 'ATT':
  2807. case 'ESQ':
  2808. case 'DEG':
  2809. case 'REG':
  2810. case 'Vue':
  2811. case 'TOUR':
  2812. case 'PV':
  2813. case 'Armure':
  2814. case 'RM':
  2815. case 'MM':
  2816. case 'Concentration':
  2817. case 'Fatigue':
  2818. case "Dés d'attaque":
  2819. return 1;
  2820. default:
  2821. return -1;
  2822. }
  2823. default :
  2824. switch( b ) {
  2825. case 'ATT':
  2826. case 'ESQ':
  2827. case 'DEG':
  2828. case 'REG':
  2829. case 'Vue':
  2830. case 'TOUR':
  2831. case 'PV':
  2832. case 'Armure':
  2833. case 'RM':
  2834. case 'MM':
  2835. case 'Concentration':
  2836. case 'Fatigue':
  2837. case "Dés d'attaque":
  2838. case 'Dés de dégâts':
  2839. return 1;
  2840. default:
  2841. return -1;
  2842. }
  2843. }
  2844. }
  2845.  
  2846.  
  2847. /* [functions] Fonctions hide / display */
  2848.  
  2849. function toggleDetailsBM() {
  2850. if(MY_getValue('BMDETAIL')!='false') {
  2851. MY_setValue('BMDETAIL','false');
  2852. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  2853. for(var i=0 ; i<trlist.length ; i++)
  2854. trlist[i].style.display = 'none';
  2855. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  2856. for(var i=0 ; i<trlist.length ; i++)
  2857. trlist[i].style = '';
  2858. }
  2859. else {
  2860. MY_setValue('BMDETAIL','true');
  2861. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  2862. for(var i=0 ; i<trlist.length ; i++)
  2863. trlist[i].style.display = 'none';
  2864. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  2865. for(var i=0 ; i<trlist.length ; i++)
  2866. trlist[i].style = '';
  2867. }
  2868. }
  2869.  
  2870. function toggleBMList() {
  2871. if(MY_getValue('BMHIDELIST')=='true') {
  2872. MY_setValue('BMHIDELIST','false');
  2873. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  2874. listeBM.snapshotItem(i).style = '';
  2875. document.getElementsByTagName('thead')[0].style = '';
  2876. document.getElementById('trhelp').style = '';
  2877. }
  2878. else {
  2879. MY_setValue('BMHIDELIST','true');
  2880. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  2881. listeBM.snapshotItem(i).style.display = 'none';
  2882. document.getElementsByTagName('thead')[0].style.display = 'none';
  2883. document.getElementById('trhelp').style.display = 'none';
  2884. }
  2885. }
  2886.  
  2887. function setDisplayBM() {
  2888. if(!listeBM) return;
  2889. var titre = document.getElementById('titre2');
  2890. if(titre) {
  2891. titre.style.cursor = 'pointer';
  2892. titre.onclick = toggleBMList;
  2893. }
  2894. var tfoot = document.getElementsByTagName('tfoot')[0];
  2895. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  2896. tfoot, null, 9, null).singleNodeValue;
  2897. tr.id = 'trhelp';
  2898. if(MY_getValue('BMHIDELIST')=='true') {
  2899. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  2900. listeBM.snapshotItem(i).style.display = 'none';
  2901. document.getElementsByTagName('thead')[0].style.display = 'none';
  2902. tr.style.display = 'none';
  2903. }
  2904. }
  2905.  
  2906.  
  2907. /* [functions] Fonction principale */
  2908.  
  2909. function traiteMalus() {
  2910. var mainTab = document.getElementsByTagName('table')[0];
  2911. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  2912. if(listeBM.snapshotLength==0) return;
  2913. /* Suppression des BM de fatigue stockés */
  2914. if(MY_getValue(numTroll+'.bm.fatigue'))
  2915. MY_removeValue(numTroll+'.bm.fatigue');
  2916. /* Extraction des données */
  2917. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  2918. var nb = 0;
  2919. while(nb<listeBM.snapshotLength) {
  2920. tr = listeBM.snapshotItem(nb); nb++;
  2921. var effetsT = tr.childNodes[5].textContent.split(' | ');
  2922. var phymag = tr.childNodes[9].textContent;
  2923. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  2924. var type = tr.childNodes[3].textContent, nom;
  2925. // si c'est un type à décumul
  2926. /*
  2927. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  2928. switch(type) {
  2929. case 'Potion':
  2930. case 'Parchemin':
  2931. case 'Sortilège':
  2932. case 'Capacité Spéciale':
  2933. nom = tr.childNodes[1].textContent+phymag;
  2934. break;
  2935. default:
  2936. nom = 'pasdedecumul';
  2937. }
  2938. */
  2939. nom = tr.childNodes[1].textContent+phymag;
  2940. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  2941. nom = 'pasdedecumul';
  2942. uniListe[nb] = {
  2943. 'duree':duree,
  2944. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  2945. 'caracs':{}
  2946. }
  2947. for(var i=0 ; i<effetsT.length ; i++) {
  2948. if(effetsT[i].indexOf(':')==-1) continue;
  2949. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  2950. // nom = 'pasdedecumul' si pas de décumul
  2951. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  2952. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  2953. uniListe[nb]['type'] = phymag;
  2954. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  2955. uniListe[nb]['caracs'][carac] = bm;
  2956. listeDurees[duree] = true;
  2957. }
  2958. } // fin boucle sur les lignes de bonus/malus
  2959. /* Gestion des décumuls et cumuls des durées */
  2960. var toursGeres = [];
  2961. for(var d in listeDurees) toursGeres.push(d);
  2962. toursGeres.sort( function (a,b){return b-a;} );
  2963. // pour sauvegarder les bm de fatigue
  2964. var strfat = '';
  2965. // Pour affichage & adpatation à footable.js (statique)
  2966. var thead = document.getElementsByTagName('thead')[0];
  2967. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  2968. thead, null, 7, null).snapshotLength;
  2969. var tfoot = document.getElementsByTagName('tfoot')[0];
  2970. for(var i=0 ; i<toursGeres.length ; i++) {
  2971. var tour = toursGeres[i];
  2972. var effetsCeTour = {}; decumulsCeTour = {};
  2973. for(var nb=1 ; nb<uniListe.length ; nb++) {
  2974. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  2975. continue;
  2976. var nom = uniListe[nb]['nom'];
  2977. if(nom!='pasdedecumul') {
  2978. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  2979. decumulsCeTour[nom]++;
  2980. }
  2981. for(var carac in uniListe[nb]['caracs']) {
  2982. var bm = uniListe[nb]['caracs'][carac];
  2983. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  2984. var type = uniListe[nb]['type'];
  2985. if(!effetsCeTour[carac])
  2986. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  2987. if(nom=='pasdedecumul')
  2988. effetsCeTour[carac][type] += bm;
  2989. else
  2990. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  2991. } else {
  2992. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  2993. var thisBm;
  2994. if(nom=='pasdedecumul' || carac=='Fatigue')
  2995. thisBm = bm;
  2996. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  2997. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  2998. else
  2999. thisBm = decumul(bm,decumulsCeTour[nom]);
  3000. effetsCeTour[carac] += thisBm;
  3001. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3002. }
  3003. } // fin boucle sur les caractéristiques
  3004. } // fin boucle sur les bonus/malus
  3005. /* Création du bilan du tour */
  3006. var texteD = '', texteS = '';
  3007. var caracGerees = [];
  3008. for(var k in effetsCeTour) caracGerees.push(k);
  3009. caracGerees.sort( triecaracs );
  3010. for(var j=0 ; j<caracGerees.length ; j++) {
  3011. var carac = caracGerees[j], str = '';
  3012. switch( carac ) {
  3013. case 'ATT':
  3014. case 'DEG':
  3015. case 'Armure':
  3016. var phy = effetsCeTour[carac]['Physique'];
  3017. var mag = effetsCeTour[carac]['Magie'];
  3018. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3019. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3020. break;
  3021. case 'TOUR':
  3022. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3023. break;
  3024. case 'Fatigue':
  3025. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3026. case 'PV':
  3027. case 'ESQ':
  3028. case 'REG':
  3029. case 'Vue':
  3030. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3031. break;
  3032. default:
  3033. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3034. }
  3035. if(str) {
  3036. texteD += str;
  3037. texteS += str;
  3038. }
  3039. } // fin boucle sur les caractéristiques
  3040. /* Affichage */
  3041. // Si rien à afficher on passe
  3042. if(!texteD) continue;
  3043. // Si BMM+BMP=0
  3044. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3045. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3046. if(MY_getValue('BMDETAIL')=='false')
  3047. tr.style.display = 'none';
  3048. var td = appendTdText(tr,texteD.substring(3));
  3049. td.colSpan = 5-nbHidden;
  3050. var txttour = toursGeres[i]+' Tour';
  3051. if(toursGeres[i]>1) txttour += 's';
  3052. appendTdText(tr,txttour);
  3053. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3054. if(MY_getValue('BMDETAIL')!='false')
  3055. tr.style.display = 'none';
  3056. td = appendTdText(tr,texteS);
  3057. td.colSpan = 5-nbHidden;
  3058. appendTdText(tr,txttour);
  3059. } // fin boucle sur les tours générés
  3060. /* mise en place toggleDetails */
  3061. tfoot.style.cursor = 'pointer';
  3062. tfoot.onclick = toggleDetailsBM;
  3063. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3064. if(strfat)
  3065. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3066. }
  3067.  
  3068. function do_malus() {
  3069. try {
  3070. start_script();
  3071. traiteMalus();
  3072. setDisplayBM();
  3073. displayScriptTime();
  3074. }
  3075. catch(e) {window.alert(e)};
  3076. }
  3077.  
  3078. /*******************************************************************************
  3079. * This file is part of Mountyzilla. *
  3080. * *
  3081. * Mountyzilla is free software; you can redistribute it and/or modify *
  3082. * it under the terms of the GNU General Public License as published by *
  3083. * the Free Software Foundation; either version 2 of the License, or *
  3084. * (at your option) any later version. *
  3085. * *
  3086. * Mountyzilla is distributed in the hope that it will be useful, *
  3087. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3088. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3089. * GNU General Public License for more details. *
  3090. * *
  3091. * You should have received a copy of the GNU General Public License *
  3092. * along with Mountyzilla; if not, write to the Free Software *
  3093. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3094. *******************************************************************************/
  3095.  
  3096. // x~x mouches
  3097.  
  3098. var mainTab, tr_mouches;
  3099.  
  3100. function initialiseMouches() {
  3101. // Lanceur global
  3102. try {
  3103. mainTab = document.getElementById('mouches');
  3104. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3105. } catch(e) {
  3106. avertissement('Erreur MZ:<br />Consulter la console.');
  3107. window.console.error('Erreur MZ mouches:\n'+e);
  3108. return;
  3109. }
  3110. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3111. setDisplayMouches();
  3112. traiteMouches();
  3113. }
  3114.  
  3115. function setDisplayMouches() {
  3116. // Initialise l'affichage / l'effacement du détail des mouches
  3117. var titre = document.getElementById('titre2');
  3118. if(titre) {
  3119. titre.style.cursor = 'pointer';
  3120. titre.onclick = toggleMouches;
  3121. }
  3122. var tfoot = document.getElementsByTagName('tfoot')[0];
  3123. if(tfoot) {
  3124. tfoot.style.cursor = 'pointer';
  3125. tfoot.onclick = toggleMouches;
  3126. }
  3127. if(MY_getValue('HIDEMOUCHES')=='true') {
  3128. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3129. tr_mouches.snapshotItem(i).style.display = 'none';
  3130. }
  3131. document.getElementsByTagName('thead')[0].style.display = 'none';
  3132. }
  3133. }
  3134.  
  3135. function toggleMouches() {
  3136. // Handler pour afficher / masquer les détasil
  3137. if(MY_getValue('HIDEMOUCHES')=='true') {
  3138. MY_setValue('HIDEMOUCHES','false');
  3139. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3140. tr_mouches.snapshotItem(i).style.display = '';
  3141. }
  3142. document.getElementsByTagName('thead')[0].style.display = '';
  3143. } else {
  3144. MY_setValue('HIDEMOUCHES','true');
  3145. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3146. tr_mouches.snapshotItem(i).style.display = 'none';
  3147. }
  3148. document.getElementsByTagName('thead')[0].style.display = 'none';
  3149. }
  3150. }
  3151.  
  3152. function traiteMouches() {
  3153. // Traitement complet: présence et effets des mouches
  3154. var listeTypes = {}, effetsActifs = {};
  3155. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3156. var tr = tr_mouches.snapshotItem(i);
  3157. // La mouche est-elle présente?
  3158. var etat = document.evaluate(
  3159. './img',
  3160. tr.cells[6], null, 9, null
  3161. ).singleNodeValue.alt;
  3162. if(etat!='La Mouche est là') { continue; }
  3163. // Extraction du type de mouche
  3164. var type = trim(tr.cells[3].textContent);
  3165. if(!listeTypes[type]) {
  3166. listeTypes[type] = 1;
  3167. } else {
  3168. listeTypes[type]++;
  3169. }
  3170. // La mouche a-t-elle un effet?
  3171. var effet = trim(tr.cells[2].textContent);
  3172. if(etat!='La Mouche est là' || !effet) { continue; }
  3173. // Si oui, extraction des effets (multiples pour pogées)
  3174. var caracs = effet.split(' | ');
  3175. for(var j=0 ; j<caracs.length ; j++) {
  3176. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3177. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3178. if(effetsActifs[carac]===void(0)) {
  3179. effetsActifs[carac] = valeur;
  3180. } else {
  3181. effetsActifs[carac] += valeur;
  3182. }
  3183. }
  3184. }
  3185. // Extraction Effet total et affichage des différences à la normale
  3186. var tfoot = document.getElementsByTagName('tfoot')[0];
  3187. if(!tfoot) { return; }
  3188. var nodeTotal = document.evaluate(
  3189. ".//b[contains(./text(),'Effet total')]",
  3190. tfoot, null, 9, null
  3191. ).singleNodeValue.nextSibling;
  3192. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3193. var texte = ' ';
  3194. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3195. if(texte.length>1) { texte += ' | '; }
  3196. var carac = trim(
  3197. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3198. );
  3199. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3200. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3201. texte += effetsTheoriques[i];
  3202. } else {
  3203. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3204. if(carac=='TOUR') { texte += ' min'; }
  3205. texte += '</b>';
  3206. }
  3207. }
  3208. var span = document.createElement('span');
  3209. span.innerHTML = texte;
  3210. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3211. // Affichage des différences du nombre de mouches de chaque type
  3212. var mouchesParType = document.evaluate(
  3213. "./tr/td/ul/li/text()",
  3214. tfoot, null, 7, null
  3215. );
  3216. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3217. var node = mouchesParType.snapshotItem(i);
  3218. var mots = node.nodeValue.split(' ');
  3219. var type = mots.pop();
  3220. if(!listeTypes[type]) {
  3221. node.nodeValue += ' (0 présente)';
  3222. } else if(mots[0]!=listeTypes[type]) {
  3223. if(listeTypes[type]==1) {
  3224. node.nodeValue += ' (1 présente)';
  3225. } else {
  3226. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3227. }
  3228. }
  3229. }
  3230. }
  3231.  
  3232. function do_mouches() {
  3233. start_script();
  3234. initialiseMouches();
  3235. displayScriptTime();
  3236. }
  3237.  
  3238. /*********************************************************************************
  3239. * This file is part of Mountyzilla. *
  3240. * *
  3241. * Mountyzilla is free software; you can redistribute it and/or modify *
  3242. * it under the terms of the GNU General Public License as published by *
  3243. * the Free Software Foundation; either version 2 of the License, or *
  3244. * (at your option) any later version. *
  3245. * *
  3246. * Mountyzilla is distributed in the hope that it will be useful, *
  3247. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3248. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3249. * GNU General Public License for more details. *
  3250. * *
  3251. * You should have received a copy of the GNU General Public License *
  3252. * along with Mountyzilla; if not, write to the Free Software *
  3253. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3254. *********************************************************************************/
  3255.  
  3256. // x~x equipgowap
  3257.  
  3258. var popup;
  3259.  
  3260. function initPopupEquipgowap() {
  3261. popup = document.createElement('div');
  3262. popup.setAttribute('id', 'popup');
  3263. popup.setAttribute('class', 'mh_textbox');
  3264. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3265. 'display: inline; z-index: 3; max-width: 400px;');
  3266. document.body.appendChild(popup);
  3267. }
  3268.  
  3269. function showPopupEquipgowap(evt) {
  3270. var texte = this.getAttribute("texteinfo");
  3271. popup.innerHTML = texte;
  3272. popup.style.left = evt.pageX + 15 + 'px';
  3273. popup.style.top = evt.pageY + 'px';
  3274. popup.style.visibility = "visible";
  3275. }
  3276.  
  3277. function hidePopup() {
  3278. popup.style.visibility = "hidden";
  3279. }
  3280.  
  3281. function createPopupImage(url, text)
  3282. {
  3283. var img = document.createElement('img');
  3284. img.setAttribute('src',url);
  3285. img.setAttribute('align','ABSMIDDLE');
  3286. img.setAttribute("texteinfo",text);
  3287. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3288. img.addEventListener("mouseout", hidePopup,true);
  3289. return img;
  3290. }
  3291.  
  3292. function formateTexte(texte)
  3293. {
  3294. texte = texte.replace(/\n/g,"<br/>");
  3295. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3296. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3297. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3298. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3299. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3300. return texte;
  3301. }
  3302.  
  3303.  
  3304. function treateGowaps() {
  3305. //On récupère les gowaps possédants des composants
  3306. var tbodys = document.evaluate(
  3307. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3308. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3309. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3310. var tbody = tbodys.snapshotItem(j);
  3311. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3312. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3313. if(MY_getValue("NOINFOEM") != "true")
  3314. insertEMInfos(tbody);
  3315. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3316. insertEnchantInfos(tbody);
  3317. }
  3318. }
  3319.  
  3320. function treateChampi() {
  3321. if(MY_getValue("NOINFOEM") == "true")
  3322. return false;
  3323. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3324. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3325. if (nodes.snapshotLength == 0)
  3326. return false;
  3327.  
  3328. for (var i = 0; i < nodes.snapshotLength; i++) {
  3329. var node = nodes.snapshotItem(i);
  3330. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3331. if(texte.indexOf("*")!=-1)
  3332. texte = texte.substring(0,texte.lastIndexOf(" "));
  3333. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3334. if(moisChampi[nomChampi])
  3335. {
  3336. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3337. }
  3338. }
  3339. }
  3340.  
  3341. function do_equipgowap() {
  3342. start_script();
  3343.  
  3344. treateGowaps();
  3345. treateChampi();
  3346. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3347. {
  3348. initPopupEquipgowap();
  3349. computeEnchantementEquipement(createPopupImage,formateTexte);
  3350. }
  3351.  
  3352. displayScriptTime();
  3353. }
  3354.  
  3355. /*********************************************************************************
  3356. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3357. *********************************************************************************/
  3358.  
  3359. // x~x ordresgowap
  3360.  
  3361. /* v0.2 by Dab - 2013-08-31
  3362. * - correction acquisition posale initiale
  3363. * - correction tare et affichage mire
  3364. */
  3365.  
  3366. function setCarteGogo() {
  3367. try {
  3368. var pars = document.getElementsByTagName('p');
  3369. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]",
  3370. pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3371. }
  3372. catch(e) {return;}
  3373. var serv_img_trou = URL_MZimg09 + "carte_trou.png";
  3374. var serv_img_cible = URL_MZimg09 + "rep.png";
  3375.  
  3376. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  3377. var lignes = pars[0].getElementsByTagName('tr');
  3378. var nbpt = 0;
  3379. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  3380. for(var i=0 ; i<lignes.length ; i++) {
  3381. if(lignes[i].className == 'mh_tdpage_fo') {
  3382. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  3383. if(point) {
  3384. nbpt++;
  3385. trajet += point[1]+','+point[2]+','+point[3]+',';
  3386. }
  3387. }
  3388. }
  3389. 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'/>";
  3390. var base = [-229,-5];
  3391. if (nbpt>0) {
  3392. base = [-684,-5];
  3393. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  3394. }
  3395. 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;'/>";
  3396.  
  3397. 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>';
  3398.  
  3399. var nvspan = document.createElement('div');
  3400. nvspan.align = 'center';
  3401. nvspan.valign = 'top';
  3402. nvspan.innerHTML += nvdiv;
  3403. pars[1].insertBefore(nvspan,pars[1].firstChild);
  3404. }
  3405.  
  3406. function do_ordresgowap() {
  3407. setCarteGogo(); // Via script des trouillots
  3408. }
  3409.  
  3410. /*********************************************************************************
  3411. * This file is part of Mountyzilla. *
  3412. * *
  3413. * Mountyzilla is free software; you can redistribute it and/or modify *
  3414. * it under the terms of the GNU General Public License as published by *
  3415. * the Free Software Foundation; either version 2 of the License, or *
  3416. * (at your option) any later version. *
  3417. * *
  3418. * Mountyzilla is distributed in the hope that it will be useful, *
  3419. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3420. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3421. * GNU General Public License for more details. *
  3422. * *
  3423. * You should have received a copy of the GNU General Public License *
  3424. * along with Mountyzilla; if not, write to the Free Software *
  3425. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3426. *********************************************************************************/
  3427.  
  3428. // x~x attaque
  3429.  
  3430. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3431.  
  3432. function do_attaque() {
  3433. }
  3434.  
  3435. /*******************************************************************************
  3436. * This file is part of Mountyzilla. *
  3437. * *
  3438. * Mountyzilla is free software; you can redistribute it and/or modify *
  3439. * it under the terms of the GNU General Public License as published by *
  3440. * the Free Software Foundation; either version 2 of the License, or *
  3441. * (at your option) any later version. *
  3442. * *
  3443. * Mountyzilla is distributed in the hope that it will be useful, *
  3444. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3445. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3446. * GNU General Public License for more details. *
  3447. * *
  3448. * You should have received a copy of the GNU General Public License *
  3449. * along with Mountyzilla; if not, write to the Free Software *
  3450. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3451. *******************************************************************************/
  3452.  
  3453. // x~x infomonstre
  3454.  
  3455. // DEBUG
  3456. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  3457. // À corriger, évidemment.
  3458. var listeCDM = {};
  3459. var nomMonstre='';
  3460. var idMonstre=-1;
  3461. var tbody;
  3462. var popup;
  3463.  
  3464. function traiteMonstre() {
  3465. try {
  3466. var nodeTitre = document.evaluate(
  3467. "//div[@class='titre2' and contains(text(),'(')]",
  3468. document, null, 9, null
  3469. ).singleNodeValue;
  3470. var texte = nodeTitre.firstChild.nodeValue;
  3471. } catch(e) {
  3472. window.console.log(e);
  3473. return;
  3474. }
  3475. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  3476. if(nomMonstre.indexOf(']')!=-1) {
  3477. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  3478. }
  3479. idMonstre = texte.match(/\d+/)[0];
  3480. FF_XMLHttpRequest({
  3481. method: 'GET',
  3482. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  3483. +MY_getValue('CDMID')
  3484. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  3485. headers : {
  3486. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3487. 'Accept': 'application/atom+xml,application/xml,text/xml'
  3488. },
  3489. onload: function(responseDetails) {
  3490. try {
  3491. var texte = responseDetails.responseText;
  3492. var lines = texte.split("\n");
  3493. if(lines.length>=1) {
  3494. var infos = lines[0].split(";");
  3495. if(infos.length<4) { return; }
  3496. var idMonstre = infos[0];
  3497. infos=infos.slice(3);
  3498. listeCDM[idMonstre]=infos;
  3499. computeMissionInfomonstre();
  3500. }
  3501. } catch(e) {
  3502. window.alert(e);
  3503. }
  3504. }
  3505. });
  3506. }
  3507.  
  3508. function initPopupInfomonstre() {
  3509. // Initialise le popup tactique (calculs att/deg)
  3510. popup = document.createElement('div');
  3511. popup.id = 'popup';
  3512. popup.className = 'mh_textbox';
  3513. popup.style =
  3514. 'position: absolute;'+
  3515. 'border: 1px solid #000000;'+
  3516. 'visibility: hidden;'+
  3517. 'display: inline;'+
  3518. 'z-index: 3;'+
  3519. 'max-width: 400px;';
  3520. document.body.appendChild(popup);
  3521. }
  3522.  
  3523. function showPopupTactique(evt) {
  3524. try {
  3525. var id = this.id;
  3526. var nom = this.nom;
  3527. var texte = getAnalyseTactique(id,nom);
  3528. if(texte=='') { return; }
  3529. popup.innerHTML = texte;
  3530. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  3531. if(isPage("View/MonsterView")) {
  3532. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  3533. } else {
  3534. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  3535. }
  3536. popup.style.top = evt.pageY+15+'px';
  3537. popup.style.visibility = 'visible';
  3538. } catch(e) {
  3539. window.alert(e);
  3540. }
  3541. }
  3542.  
  3543. // roule 16/03/2016, existe déjà ailleurs
  3544. // function hidePopup() {
  3545. // popup.style.visibility = 'hidden';
  3546. // }
  3547.  
  3548. function toggleTableau() {
  3549. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  3550. }
  3551.  
  3552. function computeMissionInfomonstre() {
  3553. // C'est quoi ce titre de fonction ? (O_o)
  3554. try {
  3555. var nodeInsert = document.evaluate(
  3556. "//div[@class = 'titre3']",
  3557. document, null, 9, null
  3558. ).singleNodeValue;
  3559. } catch(e) {
  3560. window.console.log(e);
  3561. return;
  3562. }
  3563. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  3564. table.align = 'center';
  3565. tbody = table.childNodes[1];
  3566. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  3567. table.firstChild.firstChild.onmouseover = function() {
  3568. this.style.cursor = 'pointer';
  3569. this.className = 'mh_tdpage';
  3570. };
  3571. table.firstChild.firstChild.onmouseout = function() {
  3572. this.className = 'mh_tdtitre';
  3573. };
  3574. tbody.style.display = 'none';
  3575. table.style.width = '350px';
  3576. insertBefore(nodeInsert,table);
  3577. }
  3578.  
  3579. function do_infomonstre() {
  3580. start_script();
  3581. try {
  3582. initPopupInfomonstre();
  3583. traiteMonstre();
  3584. } catch(e) {
  3585. window.alert('Erreur infoMonstre:\n'+e);
  3586. }
  3587. displayScriptTime();
  3588. }
  3589.  
  3590. /*******************************************************************************
  3591. * This file is part of Mountyzilla. *
  3592. * *
  3593. * Mountyzilla is free software; you can redistribute it and/or modify *
  3594. * it under the terms of the GNU General Public License as published by *
  3595. * the Free Software Foundation; either version 2 of the License, or *
  3596. * (at your option) any later version. *
  3597. * *
  3598. * Mountyzilla is distributed in the hope that it will be useful, *
  3599. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3600. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3601. * GNU General Public License for more details. *
  3602. * *
  3603. * You should have received a copy of the GNU General Public License *
  3604. * along with Mountyzilla; if not, write to the Free Software *
  3605. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3606. *******************************************************************************/
  3607.  
  3608. // x~x mission
  3609.  
  3610. /* TODO
  3611. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  3612. *
  3613. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  3614. */
  3615.  
  3616. function saveMission(num,obEtape) {
  3617. var obMissions = {};
  3618. if(MY_getValue(numTroll+'.MISSIONS')) {
  3619. try {
  3620. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3621. } catch(e) {
  3622. window.console.error('[MZ Mission] Erreur parsage:\n'+e);
  3623. return;
  3624. }
  3625. }
  3626. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  3627. if(obEtape) {
  3628. obMissions[num] = obEtape;
  3629. } else if(obMissions[num]) {
  3630. delete obMissions[num];
  3631. }
  3632. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3633. }
  3634.  
  3635. function traiteMission() {
  3636. try {
  3637. var titreMission = document.getElementsByClassName('titre2')[0];
  3638. var numMission = titreMission.textContent.match(/\d+/)[0];
  3639. var missionForm = document.getElementsByName('ActionForm')[0];
  3640. var tdLibelle = document.evaluate(
  3641. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  3642. missionForm, null, 9, null).singleNodeValue;
  3643. } catch(e) {
  3644. window.console.error('[MZ Mission] Erreur récupération mission:\n'+e);
  3645. return;
  3646. }
  3647. if(!numMission) { return; }
  3648. try {
  3649. if(!tdLibelle) {
  3650. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  3651. saveMission(numMission,false);
  3652. return;
  3653. }
  3654.  
  3655. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  3656. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  3657. // debug Roule'
  3658. //for (var i =0; i < tdLibelle.childNodes.length; i++) window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  3659. if(libelle.indexOf('niveau égal à')!=-1) {
  3660. var nbKills = 1, niveau, mod;
  3661. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  3662. // Étape de kill multiple de niveau donné
  3663. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3664. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  3665. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3666. niveau = Number(mod[0]);
  3667. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3668. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  3669. } else {
  3670. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  3671. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3672. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  3673. mod = mod ? Number(mod[0]) : 'plus';
  3674. }
  3675. } else {
  3676. // Étape de kill unique de niveau donné
  3677. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  3678. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3679. mod = mod ? Number(mod[0]) : 'plus';
  3680. }
  3681. // debug Roule'
  3682. //window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + ', libelle=' + libelle);
  3683. saveMission(numMission,{
  3684. type: 'Niveau',
  3685. niveau: niveau,
  3686. mod: mod,
  3687. mundidey: siMundidey,
  3688. libelle: libelle
  3689. });
  3690. } else if(libelle.indexOf('de la race')!=-1) {
  3691. var nbKills = 1, race;
  3692. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  3693. // Étape de kill multiple de race donnée
  3694. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3695. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  3696. } else {
  3697. // Étape de kill unique de race donnée
  3698. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3699. }
  3700. saveMission(numMission,{
  3701. type: 'Race',
  3702. race: race.replace(/\"/g,''),
  3703. mundidey: siMundidey,
  3704. libelle: libelle
  3705. });
  3706. } else if(libelle.indexOf('de la famille')!=-1) {
  3707. var nbKills = 1, famille;
  3708. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  3709. // Étape de kill multiple de famille donnée
  3710. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3711. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  3712. } else {
  3713. // Étape de kill unique de famille donnée
  3714. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3715. }
  3716. saveMission(numMission,{
  3717. type: 'Famille',
  3718. famille: famille,
  3719. mundidey: siMundidey,
  3720. libelle: libelle
  3721. });
  3722. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  3723. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  3724. saveMission(numMission,{
  3725. type: 'Pouvoir',
  3726. pouvoir: pouvoir,
  3727. libelle: libelle
  3728. });
  3729. } else {
  3730. saveMission(numMission,false);
  3731. }
  3732. } catch(e) {
  3733. window.console.error('[MZ Mission] Erreur récupération étape mission:\n'+e);
  3734. return;
  3735. }
  3736. }
  3737.  
  3738. function do_mission() {
  3739. start_script(60);
  3740.  
  3741. traiteMission();
  3742.  
  3743. displayScriptTime();
  3744. }
  3745.  
  3746. /*******************************************************************************
  3747. * This file is part of Mountyzilla. *
  3748. * *
  3749. * Mountyzilla is free software; you can redistribute it and/or modify *
  3750. * it under the terms of the GNU General Public License as published by *
  3751. * the Free Software Foundation; either version 2 of the License, or *
  3752. * (at your option) any later version. *
  3753. * *
  3754. * Mountyzilla is distributed in the hope that it will be useful, *
  3755. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3756. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3757. * GNU General Public License for more details. *
  3758. * *
  3759. * You should have received a copy of the GNU General Public License *
  3760. * along with Mountyzilla; if not, write to the Free Software *
  3761. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3762. *******************************************************************************/
  3763.  
  3764. // x~x move
  3765.  
  3766. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  3767.  
  3768. var petitsTrous = {
  3769. '-52;57': true,
  3770. '55;70': true,
  3771. '64;70': true,
  3772. '12;-15': true,
  3773. '30;-52': true,
  3774. '48;-39': true
  3775. };
  3776.  
  3777. var grosTrous = {
  3778. '-35;65': true,
  3779. '-13;73': true,
  3780. '-64;9': true,
  3781. '-35;15': true,
  3782. '5;32': true,
  3783. '10;64': true,
  3784. '21;36': true,
  3785. '46;52': true,
  3786. '74;32': true,
  3787. '-71;-7': true,
  3788. '-67;-37': true,
  3789. '-60;-32': true,
  3790. '-51;-22': true,
  3791. '-36;-51': true,
  3792. '5;-49': true
  3793. };
  3794.  
  3795. var centreCarmine_X = 56.5;
  3796. var centreCarmine_Y = 23.5;
  3797. var rayonCarmine = 8.7;
  3798.  
  3799. function isTrou(x,y,n) {
  3800. if(petitsTrous[x+';'+y]) {
  3801. return n<0 && n>-60;
  3802. }
  3803. if(grosTrous[x+';'+y]
  3804. || grosTrous[x-1+';'+y]
  3805. || grosTrous[x+';'+y+1]
  3806. || grosTrous[x-1+';'+y+1]) {
  3807. return n<0 && n>-70;
  3808. }
  3809. if(Math.sqrt(
  3810. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  3811. )<=rayonCarmine) {
  3812. return n<0 && n>-100;
  3813. }
  3814. return false;
  3815. }
  3816.  
  3817. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  3818.  
  3819. function validateDestination() {
  3820. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  3821. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  3822. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  3823. var form = document.getElementsByName('ActionForm')[0];
  3824. if(form) {
  3825. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  3826. if(document.getElementsByName('ai_DeplX')[i].checked) {
  3827. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  3828. }
  3829. }
  3830. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  3831. if(document.getElementsByName('ai_DeplY')[i].checked) {
  3832. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  3833. }
  3834. }
  3835. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  3836. if(document.getElementsByName('ai_DeplN')[i].checked) {
  3837. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  3838. }
  3839. }
  3840. if(isTrou(x,y,n)) {
  3841. return window.confirm(
  3842. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  3843. +'Vous allez tomber dans un trou de météorite.\n'
  3844. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  3845. );
  3846. }
  3847. }
  3848. return true;
  3849. }
  3850.  
  3851. function newsubmitDE(event) {
  3852. event.stopPropagation();
  3853. event.preventDefault();
  3854. if(validateDestination()) {
  3855. this.submit();
  3856. }
  3857. }
  3858.  
  3859. function changeValidation() {
  3860. var form = document.getElementsByName('ActionForm')[0];
  3861. if(form) {
  3862. form.addEventListener('submit', newsubmitDE, true);
  3863. }
  3864. }
  3865.  
  3866.  
  3867. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  3868.  
  3869. function validateTPDestination() {
  3870. try {
  3871. var text = document.getElementsByTagName('B')[0];
  3872. var a = text.firstChild.nodeValue.split('|');
  3873. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  3874. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  3875. var pos_n = a[2].substring(5, a[2].length) * 1;
  3876.  
  3877. var nbtrous = 0;
  3878. for(var signX=-1 ; signX<=1 ; signX+=2) {
  3879. for(var x=0 ; x<=2 ; x++) {
  3880. for(var signY=-1 ; signY<=1 ; signY+=2) {
  3881. for(var y=0 ; y<=2 ; y++) {
  3882. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  3883. for(var n = 0 ; n <= 1 ; n++) {
  3884. if(isTrou(
  3885. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  3886. )) {
  3887. nbtrous++;
  3888. }
  3889. }
  3890. }
  3891. }
  3892. }
  3893. }
  3894. }
  3895. if(nbtrous>0 && nbtrous<72) {
  3896. return window.confirm(
  3897. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  3898. +'Vous avez '+Math.floor((100*nbtrous)/144)
  3899. +'% de risque de tomber dans un trou de météorite.\n'
  3900. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  3901. );
  3902. }
  3903. else if(nbtrous>=72) {
  3904. return window.confirm(
  3905. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  3906. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  3907. +'% de risque de tomber dans un trou de météorite !\n'
  3908. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  3909. );
  3910. }
  3911. return true;
  3912. }
  3913. catch(e) {
  3914. window.alert(e)
  3915. }
  3916. }
  3917.  
  3918. function newsubmitTP(event) {
  3919. event.stopPropagation();
  3920. event.preventDefault();
  3921. if(validateTPDestination()) {
  3922. this.submit();
  3923. }
  3924. }
  3925.  
  3926. function changeButtonValidate() {
  3927. var form = document.getElementsByName('Formulaire')[0];
  3928. if(form) {
  3929. if(!form.getAttribute('onsubmit')) {
  3930. form.setAttribute('onsubmit','return true;');
  3931. }
  3932. form.addEventListener('submit', newsubmitTP, true);
  3933. }
  3934. }
  3935.  
  3936.  
  3937. /*-[functions]---------------- Partie Principale -----------------------------*/
  3938.  
  3939. function do_move() {
  3940. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  3941. changeValidation();
  3942. }
  3943. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  3944. changeButtonValidate();
  3945. }
  3946. }
  3947.  
  3948. /*******************************************************************************
  3949. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  3950. * Mountyzilla is free software; provided under the GNU General Public License *
  3951. *******************************************************************************/
  3952.  
  3953. // x~x news
  3954.  
  3955. // Nombre de news à afficher & nb max de caractères par news:
  3956. const nbItems = 5;
  3957. const maxCarDescription = 300;
  3958.  
  3959. /*-[functions]------------------- Utilitaires --------------------------------*/
  3960.  
  3961. // Ne semble avoir strictement aucun effet:
  3962. String.prototype.epureDescription = function() {
  3963. return this.replace(/\\(.)/g,"$1");
  3964. }
  3965.  
  3966. function appendTitledTable(node,titre,description) {
  3967. // Crée les tables contenant les infos (avec titre)
  3968. var table = document.createElement('table');
  3969. table.border = 0;
  3970. table.className = 'mh_tdborder';
  3971. table.cellSpacing = 1;
  3972. table.cellPadding = 1;
  3973. table.style.maxWidth = '98%';
  3974. table.style.marginLeft = 'auto';
  3975. table.style.marginRight = 'auto';
  3976. var tbody = document.createElement('tbody');
  3977. table.appendChild(tbody);
  3978. var tr = appendTr(tbody,'mh_tdtitre');
  3979. var td = appendTdCenter(tr,2);
  3980. var span = document.createElement('span');
  3981. appendText(span,titre,true);
  3982. if(description) {
  3983. span.title = description;
  3984. }
  3985. td.appendChild(span);
  3986. node.appendChild(table);
  3987. return tbody;
  3988. }
  3989.  
  3990. function testCertif(paramURL, callbackOnError) {
  3991. try {
  3992. FF_XMLHttpRequest({
  3993. method: 'GET',
  3994. url: paramURL,
  3995. onload: function(responseDetails) {
  3996. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  3997. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  3998. }
  3999. });
  4000. } catch(e) {
  4001. window.console.log('testCertif(' + paramURL + '), exception=' + e);
  4002. callbackOnError();
  4003. }
  4004. }
  4005.  
  4006. function createOrGetGrandCadre() {
  4007. var grandCadre = document.getElementById('grandCadre');
  4008. if (grandCadre) return grandCadre;
  4009. try {
  4010. var rappels = document.evaluate(
  4011. "//p[contains(a/text(),'messagerie')]",
  4012. document, null, 9, null).singleNodeValue;
  4013. }
  4014. catch(e) {
  4015. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4016. grandCadre = document.createElement('div');
  4017. return grandCadre;
  4018. }
  4019. grandCadre = document.createElement('div');
  4020. grandCadre.id = 'grandCadre';
  4021. var sousCadre = document.createElement('div');
  4022. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4023. sousCadre.style.textAlign = 'center';
  4024. sousCadre.style.fontSize = 'xx-large';
  4025. grandCadre.appendChild(sousCadre);
  4026.  
  4027. grandCadre.style.border = 'solid 5px red';
  4028. grandCadre.style.width = 'auto';
  4029. insertBefore(rappels,grandCadre);
  4030. return grandCadre;
  4031. }
  4032.  
  4033. function showHttpsErrorCadre1() {
  4034. var grandCadre = createOrGetGrandCadre();
  4035. var sousCadre = document.createElement('div');
  4036. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlain.</b>'
  4037. + '<br />Cela empêchera de voir les belles petites icônes un peu partout'
  4038. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4039. + URL_CertifRaistlin1
  4040. + '" target="raistlin">clique ici</a>'
  4041. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4042. + ' « Confirmer l\'exception de sécurité »'
  4043. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4044. sousCadre.style.width = 'auto';
  4045. sousCadre.style.fontSize = 'large';
  4046. sousCadre.style.border = 'solid 1px black';
  4047. sousCadre.style.backgroundColor = 'red';
  4048. grandCadre.appendChild(sousCadre);
  4049. }
  4050.  
  4051. function showHttpsErrorCadre2() {
  4052. var grandCadre = createOrGetGrandCadre();
  4053. var sousCadre = document.createElement('div');
  4054. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlain.</b>'
  4055. + '<br />Cela empêchera le fonctionnement de Mountyzilla<br />'
  4056. + '<a style="color:blue;font-size: inherits;" href="'
  4057. + URL_CertifRaistlin2
  4058. + '" target="raistlin">clique ici</a>'
  4059. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4060. + ' « Confirmer l\'exception de sécurité »'
  4061. + '<br />(<i>Ignore ensuite le message au sujet du firewall</i>)'
  4062. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4063. sousCadre.style.width = 'auto';
  4064. sousCadre.style.fontSize = 'large';
  4065. sousCadre.style.border = 'solid 1px black';
  4066. sousCadre.style.backgroundColor = 'red';
  4067. grandCadre.appendChild(sousCadre);
  4068. }
  4069.  
  4070. function showHttpsErrorContenuMixte() {
  4071. var grandCadre = createOrGetGrandCadre();
  4072. var sousCadre = document.createElement('div');
  4073. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  4074. + 'Cela interdit le fonctionnement des <b>services suivants</b> de Mountyzilla (le reste, dont l\'enrichissement de la vue, fonctionne à condition d\'accepter les certificats)'
  4075. + '<ul>'
  4076. + '<li>Interface Bricol\'Troll</li>'
  4077. + '<li>Jubilaire</li>'
  4078. + '<li>Nouveautés de Mountyzilla</li>'
  4079. + '</ul>'
  4080. + 'Pour autoriser le contenu mixte, regarde <a href="https://support.mozilla.org/fr/kb/blocage-du-contenu-mixte-avec-firefox#w_daebloquer-le-contenu-mixte" target="_blank">cette page</a><br />'
  4081. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  4082. sousCadre.style.width = 'auto';
  4083. sousCadre.style.fontSize = 'large';
  4084. sousCadre.style.border = 'solid 1px black';
  4085. grandCadre.appendChild(sousCadre);
  4086. }
  4087.  
  4088. /*-[functions]------------------- Jubilaires ---------------------------------*/
  4089.  
  4090. function traiterJubilaires() {
  4091. try {
  4092. FF_XMLHttpRequest({
  4093. method: 'GET',
  4094. url: URL_anniv,
  4095. headers: {
  4096. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4097. 'Accept': 'application/xml,text/xml',
  4098. },
  4099. onload: function(responseDetails) {
  4100. if ((responseDetails.status == 0) && isHTTPS) {
  4101. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  4102. showHttpsErrorContenuMixte();
  4103. return;
  4104. }
  4105. var listeTrolls = responseDetails.responseText.split('\n');
  4106. if(!listeTrolls || listeTrolls.length==0) {
  4107. return;
  4108. }
  4109. afficherJubilaires(listeTrolls);
  4110. },
  4111. });
  4112. }
  4113. catch(e) {
  4114. if (isHTTPS) {
  4115. window.console.log('exception à l\'appel jubilaires ' + e);
  4116. showHttpsErrorContenuMixte();
  4117. } else {
  4118. window.alert('Erreur Jubilaires:\n'+e);
  4119. }
  4120. }
  4121. if (isHTTPS) {
  4122. // test si les certificats raistlin ont été acceptés
  4123. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  4124. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers l'infra chez FREE (provisoire)
  4125. }
  4126. }
  4127.  
  4128. function afficherJubilaires(listeTrolls) {
  4129. try {
  4130. var rappels = document.evaluate(
  4131. "//p[contains(a/text(),'messagerie')]",
  4132. document, null, 9, null).singleNodeValue;
  4133. }
  4134. catch(e) {
  4135. return;
  4136. }
  4137. var p = document.createElement('p');
  4138. var tbody = appendTitledTable(p,
  4139. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  4140. 'Envoyez leur un message ou un cadeau !'
  4141. );
  4142. tr = appendTr(tbody,'mh_tdpage');
  4143. td = appendTdCenter(tr);
  4144. var small = document.createElement('small');
  4145. td.appendChild(small);
  4146. var first = true;
  4147. for(var i=0 ; i<listeTrolls.length ; i++) {
  4148. var infos = listeTrolls[i].split(';');
  4149. if(infos.length!=3 || infos[2]==='0') {
  4150. continue;
  4151. }
  4152. if(first) {
  4153. first = false;
  4154. }
  4155. else {
  4156. appendText(small,', ');
  4157. }
  4158. var a = document.createElement('a');
  4159. a.href = 'javascript:EPV('+infos[0]+')';
  4160. appendText(a,infos[1]);
  4161. small.appendChild(a);
  4162. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  4163. }
  4164. insertBefore(rappels,p);
  4165. }
  4166.  
  4167.  
  4168. /*-[functions]--------------------- News MZ ----------------------------------*/
  4169.  
  4170. function traiterNouvelles() {
  4171. try {
  4172. FF_XMLHttpRequest({
  4173. method: 'GET',
  4174. url: URL_rss,
  4175. headers: {
  4176. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4177. 'Accept': 'application/xml,text/xml',
  4178. },
  4179. onload: function(responseDetails) {
  4180. responseDetails.responseXML = new DOMParser().parseFromString(
  4181. responseDetails.responseText,
  4182. 'text/xml');
  4183. afficherNouvelles(responseDetails.responseXML);
  4184. }
  4185. });
  4186. }
  4187. catch(e) {
  4188. if (isHTTPS) {
  4189. // ignore
  4190. } else {
  4191. window.alert('Erreur News:\n'+e)
  4192. }
  4193. }
  4194. }
  4195.  
  4196. function afficherNouvelles(xml_data) {
  4197. var footer = document.getElementById('footer1');
  4198. if(!footer) {
  4199. return;
  4200. }
  4201. try {
  4202. var titre = xml_data.evaluate('//channel/title/text()',
  4203. xml_data, null, 9, null).singleNodeValue.nodeValue;
  4204. var description = xml_data.evaluate('//channel/description/text()',
  4205. xml_data, null, 9, null).singleNodeValue.nodeValue;
  4206. var items = xml_data.evaluate('//channel/item',
  4207. xml_data, null, 7, null);
  4208. }
  4209. catch(e) {
  4210. return;
  4211. }
  4212. if(!titre || !description || items.snapshotLength==0) {
  4213. return;
  4214. }
  4215. var p = document.createElement('p');
  4216. var tbody = appendTitledTable(p,titre,description);
  4217. for(var i=0 ; i<Math.min(items.snapshotLength,nbItems) ; i++) {
  4218. var item = items.snapshotItem(i);
  4219. var sousTitre = xml_data.evaluate('title/text()',
  4220. item, null, 9, null).singleNodeValue.nodeValue;
  4221. var details = xml_data.evaluate('description/text()',
  4222. item, null, 9, null).singleNodeValue.nodeValue;
  4223. if(sousTitre && details) {
  4224. var tr = appendTr(tbody,'mh_tdpage');
  4225. var td = appendTdCenter(tr);
  4226. td.style.verticalAlign = 'middle'; // semble sans effet
  4227. appendText(td,sousTitre,true);
  4228. td = appendTd(tr);
  4229. td.innerHTML = details.epureDescription().slice(0,maxCarDescription);
  4230. // DEBUG
  4231. // pourquoi il ajoute une ligne vide sous les listes ??
  4232. // même avec trim(), il vire le textNode mais pas l'espace !
  4233. }
  4234. }
  4235. insertBefore(footer,p);
  4236. }
  4237.  
  4238.  
  4239. /*---------------------------------- Main ------------------------------------*/
  4240.  
  4241. function do_news() {
  4242. start_script();
  4243.  
  4244. traiterJubilaires();
  4245. traiterNouvelles();
  4246.  
  4247. displayScriptTime();
  4248. }
  4249.  
  4250. /*********************************************************************************
  4251. * This file is part of Mountyzilla. *
  4252. * *
  4253. * Mountyzilla is free software; you can redistribute it and/or modify *
  4254. * it under the terms of the GNU General Public License as published by *
  4255. * the Free Software Foundation; either version 2 of the License, or *
  4256. * (at your option) any later version. *
  4257. * *
  4258. * Mountyzilla is distributed in the hope that it will be useful, *
  4259. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4260. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4261. * GNU General Public License for more details. *
  4262. * *
  4263. * You should have received a copy of the GNU General Public License *
  4264. * along with Mountyzilla; if not, write to the Free Software *
  4265. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4266. *********************************************************************************/
  4267.  
  4268. // x~x tabcompo
  4269.  
  4270. var popup;
  4271.  
  4272. function initPopupTabcompo() {
  4273. popup = document.createElement('div');
  4274. popup.setAttribute('id', 'popup');
  4275. popup.setAttribute('class', 'mh_textbox');
  4276. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  4277. + 'display: inline; z-index: 3; max-width: 400px;');
  4278. document.body.appendChild(popup);
  4279. }
  4280.  
  4281. function showPopup(evt) {
  4282. var texte = this.getAttribute("texteinfo");
  4283. popup.innerHTML = texte;
  4284. popup.style.left = evt.pageX + 15 + 'px';
  4285. popup.style.top = evt.pageY + 'px';
  4286. popup.style.visibility = "visible";
  4287. }
  4288.  
  4289. // roule 16/03/2016, existe déjà ailleurs
  4290. // function hidePopup() {
  4291. // popup.style.visibility = 'hidden';
  4292. // }
  4293.  
  4294. function createPopupImage(url, text)
  4295. {
  4296. var img = document.createElement('img');
  4297. img.setAttribute('src',url);
  4298. img.setAttribute('align','ABSMIDDLE');
  4299. img.setAttribute("texteinfo",text);
  4300. img.addEventListener("mouseover", showPopup,true);
  4301. img.addEventListener("mouseout", hidePopup,true);
  4302. return img;
  4303. }
  4304.  
  4305. function formateTexte(texte)
  4306. {
  4307. texte = texte.replace(/\n/g,"<br/>");
  4308. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4309. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4310. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4311. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4312. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4313. return texte;
  4314. }
  4315.  
  4316. function arrondi(x) {
  4317. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  4318. }
  4319.  
  4320. function traiteMinerai() {
  4321. if (currentURL.indexOf("as_type=Divers")==-1) return;
  4322. try {
  4323. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  4324. +" and contains(./tr/th/text(),'Minerai')]",
  4325. document, null, 9, null).singleNodeValue;
  4326. node = node.nextSibling.nextSibling;
  4327. }
  4328. catch(e) {return;}
  4329. var trlist = document.evaluate('./tr', node, null, 7, null);
  4330. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  4331. var node = trlist.snapshotItem(i);
  4332. var nature = node.childNodes[5].textContent;
  4333. var caracs = node.childNodes[7].textContent;
  4334. var taille = caracs.match(/\d+/)[0];
  4335. var coef = 1;
  4336. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  4337. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  4338. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  4339. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  4340. if (nature.indexOf('Mithril')!=-1) {
  4341. coef = 0.2*coef;
  4342. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  4343. }
  4344. else {
  4345. coef = 0.75*coef+1.25;
  4346. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  4347. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  4348. }
  4349. }
  4350. }
  4351.  
  4352. function treateComposants() {
  4353. if (currentURL.indexOf("as_type=Compo")==-1) return;
  4354. //On récupère les composants
  4355. var nodes = document.evaluate(
  4356. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4357. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4358. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  4359. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4360. if (nodes.snapshotLength == 0) {
  4361. // window.alert('treateComposants DOWN');
  4362. return;
  4363. }
  4364. window.alert(nodes.snapshotLength);
  4365.  
  4366. var texte = "";
  4367. for (var i = 0; i < nodes.snapshotLength; i++) {
  4368. var n1 = nodes.snapshotItem(i).childNodes[1];
  4369. var n3 = nodes.snapshotItem(i).childNodes[3];
  4370. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4371. var prix = n3.childNodes[0].nodeValue;
  4372. if (!prix)
  4373. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4374. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4375. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4376. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4377. + prix.replace(/\n/g, '') + "\n";
  4378. }
  4379.  
  4380. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4381. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4382. var id_taniere = c.snapshotItem(0).nodeValue;
  4383. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  4384.  
  4385. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4386. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  4387. if (form)
  4388. {
  4389. if(document.getElementsByTagName('form').length>0)
  4390. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4391. else
  4392. {
  4393. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4394. insertBefore(thisP, form);
  4395. }
  4396. }
  4397. }
  4398.  
  4399. function treateAllComposants() {
  4400. if(currentURL.indexOf("as_type=Compo")==-1) return;
  4401. //On récupère les composants
  4402. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  4403. document, null, 0, null ).numberValue;
  4404. var c = (categ == 0 ? 3 : 4);
  4405. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  4406. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  4407. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  4408. + "td["+c+"]/text()[1] = '\240-\240' "
  4409. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  4410. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  4411. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  4412. + "and td[1]/img/@alt = 'Identifié']",
  4413. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4414. if (nodes.snapshotLength == 0) {
  4415. // window.alert('treateAllComposants DOWN');
  4416. return;
  4417. }
  4418.  
  4419. var texte = "";
  4420. for (var i = 0; i < nodes.snapshotLength; i++) {
  4421. var n1 = nodes.snapshotItem(i).childNodes[1];
  4422. var n3 = nodes.snapshotItem(i).childNodes[3];
  4423. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4424. var prix = n3.childNodes[0].nodeValue;
  4425. if (!prix)
  4426. {
  4427. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  4428. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4429. }
  4430. else
  4431. {
  4432. prix= prix.replace(/[\240 ]/g, "");
  4433. if(prix=="-")
  4434. prix=null;
  4435. }
  4436. if(prix)
  4437. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4438. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4439. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4440. + prix.replace(/\n/g, '') + "\n";
  4441. else
  4442. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4443. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4444. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  4445. }
  4446.  
  4447. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4448. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4449. var id_taniere = c.snapshotItem(0).nodeValue;
  4450. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  4451.  
  4452. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4453. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  4454. if (form)
  4455. {
  4456. if(document.getElementsByTagName('form').length>0)
  4457. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4458. else
  4459. {
  4460. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4461. insertBefore(thisP, form);
  4462. }
  4463. }
  4464. }
  4465.  
  4466. function treateEM()
  4467. {
  4468. if(currentURL.indexOf("as_type=Compo")==-1)
  4469. return false;
  4470. var urlImg = URL_MZimg09 + "Competences/ecritureMagique.png";
  4471. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  4472. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4473. if (nodes.snapshotLength == 0)
  4474. return false;
  4475. for (var i = 0; i < nodes.snapshotLength; i++) {
  4476. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  4477. var link = desc[2].firstChild ;
  4478. var nomCompoTotal = desc[2].textContent ;
  4479. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4480. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4481. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  4482. var locqual = desc[3].textContent ;
  4483. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  4484. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  4485. if(isEM(nomMonstre).length>0)
  4486. {
  4487. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  4488. if(infos.length>0)
  4489. {
  4490. var shortDescr = "Variable";
  4491. var bold = 0;
  4492. if(infos != "Composant variable")
  4493. {
  4494. shortDescr = infos.substring(0,infos.indexOf(" "));
  4495. if(parseInt(shortDescr)>=0)
  4496. bold=1;
  4497. }
  4498. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  4499. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  4500. }
  4501. }
  4502. }
  4503. }
  4504.  
  4505. function treateChampi() {
  4506. if (currentURL.indexOf('as_type=Champi')==-1)
  4507. return false;
  4508. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  4509. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4510. if (nodes.snapshotLength == 0)
  4511. return false;
  4512.  
  4513. for (var i = 0; i < nodes.snapshotLength; i++) {
  4514. var node = nodes.snapshotItem(i);
  4515. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  4516. if (moisChampi[nomChampi])
  4517. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  4518. }
  4519. }
  4520.  
  4521. function treateEnchant()
  4522. {
  4523. if(currentURL.indexOf("as_type=Compo")==-1)
  4524. return false;
  4525. try
  4526. {
  4527. if(!listeMonstreEnchantement)
  4528. computeCompoEnchantement();
  4529. var nodes = document.evaluate(
  4530. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4531. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4532. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4533. if (nodes.snapshotLength == 0)
  4534. return false;
  4535. var urlImg = URL_MZimg09 + "enchant.png";
  4536. for (var i = 0; i < nodes.snapshotLength; i++) {
  4537. var link = nodes.snapshotItem(i);
  4538. var nomCompoTotal = link.firstChild.nodeValue;
  4539. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4540. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4541. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  4542. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  4543. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  4544. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  4545. if(isEnchant(nomMonstre).length>0)
  4546. {
  4547. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  4548. if(infos.length>0)
  4549. {
  4550. link.parentNode.appendChild(createImage(urlImg,infos));
  4551. }
  4552. }
  4553. }
  4554. }
  4555. catch(e)
  4556. {
  4557. window.alert(e);
  4558. }
  4559. }
  4560.  
  4561. function treateEquipEnchant()
  4562. {
  4563. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  4564. return false;
  4565. initPopupTabcompo();
  4566. computeEnchantementEquipement(createPopupImage,formateTexte);
  4567. }
  4568.  
  4569. function do_tancompo() {
  4570. start_script();
  4571.  
  4572. treateAllComposants();
  4573. treateComposants();
  4574. traiteMinerai();
  4575. if (MY_getValue('NOINFOEM')!='true') {
  4576. treateChampi();
  4577. treateEM();
  4578. }
  4579. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  4580. treateEnchant();
  4581. treateEquipEnchant();
  4582. }
  4583.  
  4584. displayScriptTime();
  4585. }
  4586.  
  4587. /*******************************************************************************
  4588. * This file is part of Mountyzilla. *
  4589. * *
  4590. * Mountyzilla is free software; you can redistribute it and/or modify *
  4591. * it under the terms of the GNU General Public License as published by *
  4592. * the Free Software Foundation; either version 2 of the License, or *
  4593. * (at your option) any later version. *
  4594. * *
  4595. * Mountyzilla is distributed in the hope that it will be useful, *
  4596. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4597. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4598. * GNU General Public License for more details. *
  4599. * *
  4600. * You should have received a copy of the GNU General Public License *
  4601. * along with Mountyzilla; if not, write to the Free Software *
  4602. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4603. *******************************************************************************/
  4604.  
  4605. // x~x pjview
  4606.  
  4607. /* TODO
  4608. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  4609. */
  4610.  
  4611. // Bulle d'infos
  4612. var DivInfo;
  4613. // Booléen stockant l'état de freezing de la bulle
  4614. var freezed = false;
  4615.  
  4616. // liste du matos
  4617. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  4618. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4619. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  4620. var mh_caracs = {
  4621. 'anneau de protection':
  4622. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  4623. "armure d'anneaux":
  4624. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  4625. 'armure de bois':
  4626. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  4627. 'armure de cuir':
  4628. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  4629. 'armure de peaux':
  4630. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  4631. 'armure de pierre':
  4632. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  4633. 'armure de plates':
  4634. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  4635. 'baton lesté':
  4636. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4637. 'bâtons de parade':
  4638. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4639. 'bottes':
  4640. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4641. 'bouclier à pointes':
  4642. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4643. 'boulet et chaîne':
  4644. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4645. 'cagoule':
  4646. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  4647. 'casque à cornes':
  4648. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4649. 'casque à pointes':
  4650. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  4651. 'casque en cuir':
  4652. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  4653. 'casque en métal':
  4654. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4655. 'chaîne cloutée':
  4656. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4657. 'chapeau pointu':
  4658. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  4659. 'collier de dents':
  4660. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  4661. 'collier de pierre':
  4662. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4663. 'collier à pointes':
  4664. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4665. 'cotte de mailles':
  4666. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  4667. 'couronne de cristal':
  4668. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  4669. "couronne d'obsidienne":
  4670. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  4671. "coutelas d'obsidienne":
  4672. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  4673. 'coutelas en os':
  4674. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  4675. 'crochet':
  4676. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4677. 'cuir bouilli':
  4678. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  4679. "cuirasse d'ossements":
  4680. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  4681. "cuirasse d'écailles":
  4682. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  4683. 'culotte en cuir':
  4684. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4685. 'dague':
  4686. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4687. 'epée courte':
  4688. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4689. 'epée longue':
  4690. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4691. 'espadon':
  4692. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4693. 'fouet':
  4694. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4695. 'fourrures':
  4696. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  4697. 'gantelet':
  4698. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4699. 'gorgeron en cuir':
  4700. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4701. 'gorgeron en métal':
  4702. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  4703. 'gourdin':
  4704. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4705. 'gourdin clouté':
  4706. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4707. 'grimoire':
  4708. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  4709. "gros'porte":
  4710. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  4711. 'grosse racine':
  4712. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  4713. 'grosse stalagmite':
  4714. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  4715. 'hache de bataille':
  4716. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4717. 'hache de guerre en os':
  4718. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  4719. 'hache de guerre en pierre':
  4720. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  4721. "hache à deux mains d'obsidienne":
  4722. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  4723. 'hallebarde':
  4724. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  4725. "haubert d'écailles":
  4726. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  4727. 'haubert de mailles':
  4728. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  4729. 'heaume':
  4730. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  4731. 'jambières en cuir':
  4732. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  4733. 'jambières en fourrure':
  4734. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  4735. 'jambières en maille':
  4736. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  4737. 'jambières en métal':
  4738. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  4739. 'jambières en os':
  4740. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  4741. "lame d'obsidienne":
  4742. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  4743. 'lame en os':
  4744. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4745. 'lame en pierre':
  4746. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4747. 'lorgnons':
  4748. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  4749. 'machette':
  4750. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4751. "masse d'arme":
  4752. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4753. 'pagne de mailles':
  4754. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4755. 'pagne en cuir':
  4756. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4757. 'robe de mage':
  4758. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  4759. 'rondache en bois':
  4760. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4761. 'rondache en métal':
  4762. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  4763. 'sandales':
  4764. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4765. 'souliers dorés':
  4766. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4767. "talisman d'obsidienne":
  4768. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  4769. 'talisman de pierre':
  4770. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  4771. 'targe':
  4772. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4773. 'torche':
  4774. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  4775. 'torque de pierre':
  4776. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  4777. 'tunique':
  4778. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4779. "tunique d'écailles":
  4780. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  4781. 'turban':
  4782. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  4783. }
  4784.  
  4785. // liste des templates
  4786. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  4787. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4788. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  4789. var mh_templates = {
  4790. 'de Feu':
  4791. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4792. 'de Résistance':
  4793. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  4794. "de l'Aigle":
  4795. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  4796. 'de la Salamandre':
  4797. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  4798. 'des Cyclopes':
  4799. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  4800. 'des Enragés':
  4801. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  4802. 'des Tortues':
  4803. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  4804. 'des Vampires':
  4805. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  4806. 'du Glacier':
  4807. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  4808. 'du Rat':
  4809. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  4810. 'du Roc':
  4811. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  4812. 'du Temps':
  4813. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  4814. 'du Vent':
  4815. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  4816. 'en Mithril':
  4817. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4818. 'des Anciens':
  4819. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4820. 'des Champions':
  4821. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4822. 'des Duellistes':
  4823. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4824. 'de la Terre':
  4825. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  4826. "de l'Orage":
  4827. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  4828. "de l'Ours":
  4829. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  4830. 'des Béhémoths':
  4831. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  4832. 'des Mages':
  4833. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  4834. 'du Pic':
  4835. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  4836. 'du Sable':
  4837. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  4838. 'acéré':
  4839. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4840. 'acérée':
  4841. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4842. 'équilibré':
  4843. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4844. 'équilibrée':
  4845. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4846. 'léger':
  4847. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  4848. 'légère':
  4849. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  4850. 'renforcé':
  4851. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  4852. 'renforcée':
  4853. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  4854. 'robuste':
  4855. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  4856. }
  4857.  
  4858. function clone(arr) {
  4859. // Clonage rapide
  4860. return arr.slice(0);
  4861. }
  4862.  
  4863. function addArray(arr1,arr2) {
  4864. // Somme matricielle
  4865. var res = clone(arr1);
  4866. for(i=res.length-1 ; i>=0 ; i--) {
  4867. res[i] += arr2[i];
  4868. }
  4869. return res;
  4870. }
  4871.  
  4872. function getTemplates(nomItem) {
  4873. // Déstructure le nom de l'item en array [nom, template1, ...]
  4874. var tempFound = true;
  4875. var str = nomItem.trim();
  4876. var arr = [];
  4877. while(tempFound) {
  4878. tempFound = false;
  4879. for(var temp in mh_templates) {
  4880. // on teste la fin du nom contre chaque template
  4881. if(str.slice(-temp.length)!=temp) { continue; }
  4882. tempFound = true;
  4883. str = str.slice(0,-temp.length-1);
  4884. arr.unshift(temp);
  4885. if(str.slice(-3)==' et') {
  4886. str = str.slice(0,-3);
  4887. }
  4888. }
  4889. }
  4890. arr.unshift(str);
  4891. return arr;
  4892. }
  4893.  
  4894. function addMithril(arrayCaracs,typeItem) {
  4895. // Ajoute l'effet du Mithril sur les caracs
  4896. if(typeItem=='arme') {
  4897. if(arrayCaracs[0]<0) {
  4898. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  4899. }
  4900. }
  4901. else {
  4902. if(arrayCaracs[4]<0) {
  4903. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  4904. }
  4905. }
  4906. arrayCaracs[15] /= 2;
  4907. arrayCaracs[16] /= 2;
  4908. return arrayCaracs;
  4909. }
  4910.  
  4911. function addRenfort(arrayCaracs,template) {
  4912. // Ajoute l'effet des pseudo-templates sur les caracs
  4913. // S'applique APRÈS le mithril
  4914. // WARNING - Cette formule n'a rien d'officiel, gare !
  4915. var coef = 0;
  4916. if(/^lég[e,è]re?$/.test(template)) {
  4917. coef = -1;
  4918. }
  4919. else if(/^renforcée?$/.test(template)
  4920. || template==='robuste') {
  4921. coef = 1;
  4922. }
  4923. if(coef) {
  4924. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  4925. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  4926. }
  4927. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  4928. return arrayCaracs;
  4929. }
  4930.  
  4931. function getCaracs(item) {
  4932. // Calcule les caractéristiques de l'item
  4933. var templates = getTemplates(item);
  4934. if(!mh_caracs[templates[0]]) {
  4935. // Si l'item est inconnu
  4936. return [];
  4937. }
  4938. var caracs = clone(mh_caracs[templates[0]]);
  4939. var typeItem = caracs[0];
  4940. caracs.shift();
  4941. templates.shift();
  4942. if(templates[templates.length-1]=='en Mithril') {
  4943. caracs = addMithril(caracs,typeItem);
  4944. templates.pop();
  4945. }
  4946. if(/^acérée?$/.test(templates[0])
  4947. || /^équilibrée?$/.test(templates[0])
  4948. || /^lég[e,è]re?$/.test(templates[0])
  4949. || /^renforcée?$/.test(templates[0])
  4950. || templates[0]=='robuste') {
  4951. caracs = addRenfort(caracs,templates[0]);
  4952. templates.shift();
  4953. }
  4954. for(var i=templates.length-1 ; i>=0 ; i--) {
  4955. caracs = addArray(caracs,mh_templates[templates[i]]);
  4956. }
  4957. return caracs;
  4958. }
  4959.  
  4960. function getLine(tab) {
  4961. // Préparation de la ligne à afficher lors d'un mouseover
  4962. var str = '';
  4963. if(tab[0]!=0 || tab[1]!=0) {
  4964. str += '<b>Att : </b>'+aff(tab[0]);
  4965. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  4966. str += ' | ';
  4967. }
  4968. if(tab[4]!=0) {
  4969. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  4970. }
  4971. if(tab[2]!=0 || tab[3]!=0) {
  4972. str += '<b>Deg : </b>'+aff(tab[2]);
  4973. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  4974. str += ' | ';
  4975. }
  4976. if(tab[8]!=0) {
  4977. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  4978. }
  4979. if(tab[7]!=0) {
  4980. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  4981. }
  4982. if(tab[5]!=0 || tab[6]!=0) {
  4983. str += '<b>Arm : </b>'+aff(tab[5]);
  4984. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  4985. str += ' | ';
  4986. }
  4987. if(tab[9]!=0 || tab[10]!=0) {
  4988. str += '<b>RM : </b>'+aff(tab[9])+'%';
  4989. if(tab[9]!=tab[10]) {
  4990. str += '/'+aff(tab[10])+'%';
  4991. }
  4992. str += ' | ';
  4993. }
  4994. if(tab[11]!=0 || tab[12]!=0) {
  4995. str += '<b>MM : </b>'+aff(tab[11])+'%';
  4996. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  4997. str += ' | ';
  4998. }
  4999. if(tab[13]!=0) {
  5000. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5001. }
  5002. if(tab[14]!=0) {
  5003. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5004. }
  5005. str += '<b>Poids : </b>'+tab[15]+' min';
  5006. if(tab[15]!=tab[16]) {
  5007. str += ' / '+tab[16]+' min';
  5008. }
  5009. return str;
  5010. }
  5011.  
  5012. function toolTipInit() {
  5013. DivInfo = document.createElement('div');
  5014. DivInfo.id = 'infosVue';
  5015. DivInfo.className = 'mh_textbox';
  5016. DivInfo.style =
  5017. 'position: absolute;'
  5018. +'border: 1px solid #000000;'
  5019. +'visibility:hidden;'
  5020. +'display:inline;'
  5021. +'z-index:99;';
  5022. document.body.appendChild(DivInfo);
  5023. document.onmousemove = getXY;
  5024. document.onclick = changeFreezeStatus;
  5025. }
  5026.  
  5027. function getXY(evt) {
  5028. if(!freezed && DivInfo.style.visibility=='visible') {
  5029. DivInfo.style.left = evt.pageX+'px';
  5030. DivInfo.style.top = evt.pageY+10+'px';
  5031. }
  5032. }
  5033.  
  5034. function changeFreezeStatus() {
  5035. if(DivInfo.style.visibility=='visible') {
  5036. freezed = !freezed;
  5037. if(!freezed) { hideInfos(); }
  5038. }
  5039. }
  5040.  
  5041. function showInfos() {
  5042. if(freezed) { return; }
  5043. var currentInfos = this.infos;
  5044. DivInfo.innerHTML = currentInfos;
  5045. DivInfo.style.visibility = 'visible';
  5046. }
  5047.  
  5048. function hideInfos() {
  5049. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  5050. }
  5051.  
  5052. function treateEquipement() {
  5053. // Extrait les données du matos et réinjecte les infos déduites
  5054. if(MY_getValue('INFOCARAC')=='false') { return; }
  5055. var faireLigne = false;
  5056. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  5057. var nodes = document.evaluate(
  5058. "//td/b[text()='Equipement Utilisé']/../../"
  5059. +"td[2]/img[contains(@src,bullet)]",
  5060. document, null, 7, null);
  5061. if(nodes.snapshotLength>0) {
  5062. // Si CSS de base
  5063. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5064. var node = nodes.snapshotItem(i);
  5065. var next = node.nextSibling;
  5066. var nnext = next.nextSibling;
  5067. var nom = next.nodeValue.toLowerCase();
  5068. if(nnext.childNodes.length==1) {
  5069. nom += nnext.firstChild.nodeValue;
  5070. }
  5071. nom = nom.trim();
  5072. // gestion winpostrophe
  5073. var c = String.fromCharCode(180);
  5074. while(nom.indexOf(c)!=-1) {
  5075. nom = nom.replace(c,"'");
  5076. }
  5077. var arr = getCaracs(nom);
  5078. if(arr.length>0) {
  5079. faireLigne = true;
  5080. caracs = addArray(caracs,arr);
  5081. var span = document.createElement('span');
  5082. span.appendChild(next);
  5083. span.appendChild(nnext);
  5084. span.infos = getLine(arr);
  5085. span.onmouseover = showInfos;
  5086. span.onmouseout = hideInfos;
  5087. insertBefore(node.nextSibling,span);
  5088. }
  5089. }
  5090. if(faireLigne) {
  5091. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  5092. document, null, 9, null).singleNodeValue;
  5093. node.infos = getLine(caracs);
  5094. node.onmouseover = showInfos;
  5095. node.onmouseout = hideInfos;
  5096. }
  5097. }
  5098. else {
  5099. // Si CSS avancée
  5100. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  5101. document, null, 7, null);
  5102. if(nodes.snapshotLength>0) {
  5103. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5104. var node = nodes.snapshotItem(i);
  5105. var nom = node.firstChild.nodeValue.toLowerCase();
  5106. if(node.childNodes.length>1) {
  5107. nom += node.childNodes[1].firstChild.nodeValue;
  5108. }
  5109. nom = nom.trim();
  5110. // gestion winpostrophe
  5111. var c = String.fromCharCode(180);
  5112. while(nom.indexOf(c)!=-1) {
  5113. nom = nom.replace(c,"'");
  5114. }
  5115. var arr = getCaracs(nom);
  5116. if(arr.length!=0) {
  5117. caracs = addArray(caracs,arr);
  5118. node.infos = getLine(arr);
  5119. node.onmouseover = showInfos;
  5120. node.onmouseout = hideInfos;
  5121. }
  5122. }
  5123. var nodes = document.evaluate("//dt[@class='equipement']",
  5124. document, null, 7, null);
  5125. var node = nodes.snapshotItem(0);
  5126. node.infos = getLine(caracs);
  5127. node.onmouseover = showInfos;
  5128. node.onmouseout = hideInfos;
  5129. }
  5130. }
  5131. }
  5132.  
  5133. function do_pjview() {
  5134. treateEquipement();
  5135. toolTipInit();
  5136. }
  5137.  
  5138. /*******************************************************************************
  5139. * This file is part of Mountyzilla. *
  5140. * *
  5141. * Mountyzilla is free software; you can redistribute it and/or modify *
  5142. * it under the terms of the GNU General Public License as published by *
  5143. * the Free Software Foundation; either version 2 of the License, or *
  5144. * (at your option) any later version. *
  5145. * *
  5146. * Mountyzilla is distributed in the hope that it will be useful, *
  5147. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5148. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5149. * GNU General Public License for more details. *
  5150. * *
  5151. * You should have received a copy of the GNU General Public License *
  5152. * along with Mountyzilla; if not, write to the Free Software *
  5153. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5154. *******************************************************************************/
  5155.  
  5156. // x~x option
  5157.  
  5158. /* TODO
  5159. * Passer le HTML injecté aux conventions HTML5
  5160. */
  5161.  
  5162.  
  5163. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  5164.  
  5165. function saveITData() {
  5166. var IT = document.getElementById('itSelect').value;
  5167. if(IT=='bricol') {
  5168. var system = document.getElementById('urlbricol').value;
  5169. var login = document.getElementById('loginbricol').value;
  5170. var pass = document.getElementById('passbricol').value;
  5171. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  5172. if(system && login) {
  5173. if (pass) {
  5174. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  5175. MY_setValue(numTroll+'.INFOSIT', v);
  5176. //window.console.log('v=' + v);
  5177. } else {
  5178. // vérif que rien n'a changé
  5179. var str = MY_getValue(numTroll+'.INFOSIT');
  5180. if(str) {
  5181. var arr = str.split('$');
  5182. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  5183. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  5184. }
  5185. }
  5186. }
  5187. }
  5188. }
  5189. else {
  5190. MY_removeValue(numTroll+'.INFOSIT');
  5191. }
  5192. }
  5193.  
  5194. function saveLinks() {
  5195. var numLinks = document.getElementById('linksBody').childNodes.length;
  5196. var data=[ [] ];
  5197. /* Récupération et tri des liens */
  5198. for(var i=1 ; i<=numLinks ; i++) {
  5199. MY_removeValue('URL'+i);
  5200. MY_removeValue('URL'+i+'.nom');
  5201. MY_removeValue('URL'+i+'.ico');
  5202. var url = document.getElementById('url'+i).value;
  5203. var nom = document.getElementById('nom'+i).value;
  5204. var ico = document.getElementById('ico'+i).value;
  5205. if(url && (nom || ico) ) {
  5206. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5207. }
  5208. }
  5209. /* Sauvegarde */
  5210. for(var i=1 ; i<data.length ; i++) {
  5211. MY_setValue('URL'+i,data[i][0]);
  5212. MY_setValue('URL'+i+'.nom',data[i][1]);
  5213. MY_setValue('URL'+i+'.ico',data[i][2]);
  5214. }
  5215. }
  5216.  
  5217. function saveAll() {
  5218. var urlIco = document.getElementById('icoMenuIco').value;
  5219. if(urlIco) {
  5220. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5221. }
  5222. else {
  5223. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5224. document.getElementById('icoMenuIco').value = '';
  5225. }
  5226. saveLinks();
  5227. refreshLinks();
  5228. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5229. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5230. if(maxcdm) {
  5231. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5232. }
  5233. else {
  5234. MY_removeValue(numTroll+'.MAXCDM');
  5235. document.getElementById('maxcdm').value = '';
  5236. }
  5237.  
  5238. MY_setValue('NOINFOEM',
  5239. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5240. // Pourquoi Tilk stockait-il tout en str ?
  5241. // -> parce que les booléens c'est foireux (vérifié)
  5242. MY_setValue(numTroll+'.USECSS',
  5243. document.getElementById('usecss').checked ? 'true':'false');
  5244. MY_setValue('INFOCARAC',
  5245. document.getElementById('infocarac').checked ? 'true' : 'false');
  5246. //MY_setValue(numTroll+'.SEND_IDT',
  5247. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  5248. // Fonctionnalité désactivée
  5249.  
  5250. MY_setValue(numTroll+'.AUTOCDM',
  5251. document.getElementById('autoCdM').checked ? 'true' : 'false');
  5252. MY_setValue('VUECARAC',
  5253. document.getElementById('vueCarac').checked ? 'true' : 'false');
  5254. MY_setValue('CONFIRMEDECALAGE',
  5255. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  5256. MY_setValue(numTroll+".OLDSCHOOL",
  5257. document.getElementById("oldShoolStyle").checked ? "true" : "false");
  5258.  
  5259. saveITData();
  5260. var bouton = document.getElementById('saveAll');
  5261. bouton.value = (bouton.value=='Sauvegardé !') ?
  5262. 'Re-sauvegardé !' : 'Sauvegardé !';
  5263. }
  5264.  
  5265.  
  5266. /*-[functions]----------------- EventListeners -------------------------------*/
  5267.  
  5268. function onChangeIT() {
  5269. var IT = document.getElementById('itSelect').value;
  5270. var itBody = document.getElementById('itBody');
  5271. itBody.innerHTML = '';
  5272. if(IT=='bricol') {
  5273. var tr = appendTr(itBody,'mh_tdpage')
  5274. var td = appendTd(tr);
  5275. var str = MY_getValue(numTroll+'.INFOSIT');
  5276. //window.console.log('onChangeIT str=' + str);
  5277. if(str) {
  5278. var arr = str.split('$');
  5279. var system = arr[1];
  5280. var login = arr[2];
  5281. var affhv = arr[4];
  5282. }
  5283. appendText(td,'Nom du système : ');
  5284. appendTextbox(td,'text','urlbricol',20,50,system);
  5285. td = appendTd(tr);
  5286. appendText(td,'Login du compte : ');
  5287. appendTextbox(td,'text','loginbricol',20,50,login);
  5288. td = appendTd(tr);
  5289. appendText(td,'Mot de passe du compte : ');
  5290. appendTextbox(td,'password','passbricol',20,50);
  5291. td = appendTd(tr);
  5292. appendText(td,'Affichage des Trõlls hors vue : ');
  5293. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  5294. appendCheckBox(td,'affhvbricol', (affhv>0));
  5295. }
  5296. }
  5297.  
  5298. function refreshLinks() {
  5299. document.getElementById('linksBody').innerHTML = '';
  5300. var anotherURL = MY_getValue('URL1');
  5301. if(!anotherURL) { addLinkField(); }
  5302. var i=1;
  5303. while(anotherURL && i<99) {
  5304. addLinkField(i,anotherURL,
  5305. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  5306. i++;
  5307. anotherURL = MY_getValue('URL'+i);
  5308. }
  5309. }
  5310.  
  5311. function addLinkField(i,url,nom,ico) {
  5312. var linksBody = document.getElementById('linksBody');
  5313. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  5314. var tr = appendTr(linksBody);
  5315. var td = appendTdCenter(tr);
  5316. appendText(td,'Lien '+i+' : ');
  5317. appendTextbox(td,'text','url'+i,40,150,url);
  5318. td = appendTdCenter(tr);
  5319. appendText(td,'Nom : ');
  5320. appendTextbox(td,'text','nom'+i,20,150,nom);
  5321. td = appendTdCenter(tr);
  5322. appendText(td,'Icône : ');
  5323. appendTextbox(td,'text','ico'+i,40,150,ico);
  5324. }
  5325.  
  5326. function removeLinkField() {
  5327. var linksBody = document.getElementById('linksBody');
  5328. var i = linksBody.childNodes.length;
  5329. MY_removeValue('URL'+i);
  5330. MY_removeValue('URL'+i+'.nom');
  5331. MY_removeValue('URL'+i+'.ico');
  5332. linksBody.removeChild(linksBody.lastChild);
  5333. if(linksBody.childNodes.length==0) { addLinkField(); }
  5334. }
  5335.  
  5336. function resetMainIco() {
  5337. document.getElementById('icoMenuIco').value=
  5338. URL_MZimg09 + 'mz_logo_small.png';
  5339. }
  5340.  
  5341.  
  5342. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  5343.  
  5344. function insertTitle(next,txt) {
  5345. var div = document.createElement('div');
  5346. div.className = 'titre2';
  5347. appendText(div,txt);
  5348. insertBefore(next,div);
  5349. }
  5350.  
  5351. function insertMainTable(next) {
  5352. var table = document.createElement('table');
  5353. table.width = '98%';
  5354. table.border = 0;
  5355. table.align = 'center';
  5356. table.cellPadding = 2;
  5357. table.cellSpacing = 1;
  5358. table.className = 'mh_tdborder';
  5359. var tbody = document.createElement('tbody');
  5360. table.appendChild(tbody);
  5361. insertBefore(next,table);
  5362. return tbody;
  5363. }
  5364.  
  5365. function appendSubTable(node) {
  5366. var table = document.createElement('table');
  5367. table.width = '100%';
  5368. var tbody = document.createElement('tbody');
  5369. table.appendChild(tbody);
  5370. node.appendChild(table);
  5371. return tbody;
  5372. }
  5373.  
  5374. function insertOptionTable(insertPt) {
  5375. var mainBody = insertMainTable(insertPt);
  5376. /* Liens dans le Menu */
  5377. var tr = appendTr(mainBody,'mh_tdtitre');
  5378. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  5379. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5380. appendText(td,'Icône du Menu: ');
  5381. var url = MY_getValue(numTroll+'.ICOMENU');
  5382. if(!url) {
  5383. url = URL_MZimg09 + 'mz_logo_small.png';
  5384. }
  5385. appendTextbox(td,'text','icoMenuIco',50,200,url);
  5386. appendButton(td,'Réinitialiser',resetMainIco);
  5387. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5388. var tbody = appendSubTable(td);
  5389. tbody.id = 'linksBody';
  5390. refreshLinks();
  5391. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  5392. appendButton(td,'Ajouter',addLinkField);
  5393. appendButton(td,'Supprimer',removeLinkField);
  5394. /* Options de la Vue : vue externe, nb de CdM, etc */
  5395. tr = appendTr(mainBody,'mh_tdtitre');
  5396. appendTdText(tr,'Options de la Vue :',true);
  5397. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5398. tbody = appendSubTable(td);
  5399. tr = appendTr(tbody);
  5400. td = appendTdText(tr,'Vue externe : ');
  5401. var select = document.createElement('select');
  5402. select.id = 'vueext';
  5403. td.appendChild(select);
  5404. var listeVues2D = [
  5405. 'Bricol\' Vue',
  5406. 'Vue du CCM',
  5407. 'Vue Gloumfs 2D',
  5408. 'Vue Gloumfs 3D',
  5409. 'Grouky Vue!'
  5410. ];
  5411. for(var i=0 ; i<listeVues2D.length ; i++) {
  5412. appendOption(select,listeVues2D[i],listeVues2D[i]);
  5413. }
  5414. if(MY_getValue('VUEEXT')) {
  5415. select.value = MY_getValue('VUEEXT');
  5416. }
  5417. td = appendTd(tr);
  5418. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  5419. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  5420. tr = appendTr(tbody);
  5421. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  5422. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  5423. td = appendTd(tr);
  5424. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  5425. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  5426. /* Interface Tactique */
  5427. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5428. appendText(td,'Interface Tactique : ',true);
  5429. select = document.createElement('select');
  5430. select.id = 'itSelect';
  5431. appendOption(select,'none','Aucune');
  5432. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  5433. // seule interface supportée !
  5434. td.appendChild(select);
  5435. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5436. tbody = appendSubTable(td);
  5437. tbody.id = 'itBody';
  5438. select.onchange = onChangeIT;
  5439. var str = MY_getValue(numTroll+'.INFOSIT');
  5440. if(str) {
  5441. select.value = str.slice(0,str.indexOf('$'));
  5442. onChangeIT();
  5443. }
  5444. /* Options diverses */
  5445. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5446. appendText(td,'Options diverses :',true);
  5447. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5448. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  5449. appendText(td,
  5450. ' Afficher les caractéristiques des équipements des autres Trõlls');
  5451. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5452. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  5453. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  5454. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5455. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  5456. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  5457. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5458. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  5459. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  5460. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5461. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  5462. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  5463. td = appendTd(appendTr(mainBody,"mh_tdpage"));
  5464. appendCheckBox(td,"oldShoolStyle",MY_getValue(numTroll+".OLDSCHOOL")=="true");
  5465. appendText(td," Ouvrir l'ancien profil par défaut");
  5466. /* Bouton SaveAll */
  5467. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  5468. input = appendButton(td,'Sauvegarder',saveAll);
  5469. input.id = 'saveAll';
  5470. }
  5471.  
  5472. function insertCreditsTable(insertPt) {
  5473. var tbody = insertMainTable(insertPt);
  5474. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  5475. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  5476. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  5477.  
  5478. var ul = document.createElement('ul');
  5479. td.appendChild(ul);
  5480. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  5481. appendLI(ul,'Reivax (4234) pour les infos bulles');
  5482. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  5483. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  5484. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  5485. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  5486. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  5487. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer '
  5488. +'à Mountyzilla');
  5489. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites '
  5490. +'du raisonnable avec sa vue de barbare');
  5491. appendLI(ul,'TuttiRikikiMaoussKosTroll (61214) pour le script '
  5492. +'sur les caracs de l\'équipement');
  5493. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, '
  5494. +'des scripts, et beaucoup de choses à venir');
  5495. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  5496. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233)... '
  5497. +'et tous les participants au projet ZoryaZilla');
  5498. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  5499. appendLI(ul,'Rokü Menton-brûlant (108387) pour m\'avoir incité à passer '
  5500. +'sur GitHub');
  5501. appendLI(ul,'Rouletabille (91305) & Marmotte (93138) pour leur support '
  5502. +'technique récurrent');
  5503. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  5504. appendLI(ul,'Tous les testeurs de la nouvelle génération '
  5505. +'oubliés par Dabihul');
  5506. }
  5507.  
  5508.  
  5509. /* [functions] Obsolètes */
  5510. function deleteEnchantement()
  5511. {
  5512. try
  5513. {
  5514. var idEquipement = this.getAttribute('name');
  5515. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  5516. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  5517. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  5518. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  5519. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  5520. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5521. var string = "";
  5522. for(var i=0;i<listeEquipement.length;i++)
  5523. {
  5524. if(listeEquipement[i]!=idEquipement)
  5525. if(string=="")
  5526. string = listeEquipement[i];
  5527. else
  5528. string += ";"+listeEquipement[i];
  5529. }
  5530. if(string=="")
  5531. {
  5532. MY_removeValue(numTroll+".enchantement.liste");
  5533. var table = this.parentNode.parentNode.parentNode.parentNode;
  5534. var parent = table.parentNode;
  5535. for(var i=0;i<parent.childNodes.length;i++)
  5536. {
  5537. if(parent.childNodes[i]==table)
  5538. {
  5539. parent.removeChild(parent.childNodes[i-1]);
  5540. parent.removeChild(parent.childNodes[i-1]);
  5541. parent.removeChild(parent.childNodes[i-1]);
  5542. break;
  5543. }
  5544. }
  5545. }
  5546. else
  5547. {
  5548. MY_getValue(numTroll+".enchantement.liste",string);
  5549. this.parentNode.parentNode.parentNode
  5550. .removeChild(this.parentNode.parentNode);
  5551. }
  5552. }
  5553. catch(e)
  5554. {
  5555. window.alert(e);
  5556. }
  5557. }
  5558. /* [functions] fin Obsolètes */
  5559.  
  5560. /*-[functions]---------------- Partie principale -----------------------------*/
  5561.  
  5562. function do_option() {
  5563. start_script(712);
  5564.  
  5565. // Pour cryptage des mdp IT
  5566. //appendNewScript(URL_tilk_js + 'md5.js'); // source intégré dans tout_MZ
  5567.  
  5568. var insertPoint = document.getElementById('footer1');
  5569. insertBefore(insertPoint,document.createElement('p'));
  5570. insertTitle(insertPoint,'Mountyzilla : Options');
  5571. insertOptionTable(insertPoint);
  5572. /* insertion enchantements ici
  5573. if(...)
  5574. insertEnchantementTable();
  5575. */
  5576. insertBefore(insertPoint,document.createElement('p'));
  5577. insertTitle(insertPoint,'Mountyzilla : Crédits');
  5578. insertCreditsTable(insertPoint);
  5579. insertBefore(insertPoint,document.createElement('p'));
  5580.  
  5581. /* [zone] Obsolète ?? */
  5582. if(MY_getValue(numTroll+".enchantement.liste")
  5583. && MY_getValue(numTroll+".enchantement.liste")!="" )
  5584. {
  5585. insertTitle(insertPoint, 'Les Enchantements en cours');
  5586. table = document.createElement('table');
  5587. table.setAttribute('width', '98%');
  5588. table.setAttribute('border', '0');
  5589. table.setAttribute('align', 'center');
  5590. table.setAttribute('cellpadding', '2');
  5591. table.setAttribute('cellspacing', '1');
  5592. table.setAttribute('class', 'mh_tdborder');
  5593.  
  5594. tbody = document.createElement('tbody');
  5595. table.appendChild(tbody);
  5596. tr = appendTr(tbody, 'mh_tdtitre');
  5597. appendTdText(tr, 'Equipement',1);
  5598. appendTdText(tr, 'Composants',1);
  5599. appendTdText(tr, 'Enchanteur',1);
  5600. appendTdText(tr, 'Action',1);
  5601. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5602. for(var i=0;i<listeEquipement.length;i++)
  5603. {
  5604. try
  5605. {
  5606. var idEquipement = listeEquipement[i];
  5607. var nomEquipement = MY_getValue(numTroll+".enchantement."
  5608. +idEquipement+".objet");
  5609. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  5610. +idEquipement+".enchanteur").split(";");
  5611. var ul = document.createElement('UL');
  5612. for(var j=0;j<3;j++)
  5613. {
  5614. var infoComposant = MY_getValue(numTroll+".enchantement."
  5615. +idEquipement+".composant."+j).split(";");
  5616. var texte = infoComposant[4].replace("Ril ","Œil ");
  5617. for(var k=5;k<infoComposant.length;k++)
  5618. {
  5619. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  5620. }
  5621. li = appendLI(ul,texte);
  5622. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  5623. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  5624. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  5625. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  5626. string+= '<input type="hidden" name="q" value="min" />';
  5627. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  5628. 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>';
  5629.  
  5630. string+= '</form>';
  5631. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  5632. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  5633. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  5634. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  5635. li.innerHTML += string;
  5636. }
  5637. tr = appendTr(tbody, 'mh_tdpage');
  5638. td = appendTdText(tr, nomEquipement);
  5639. td.setAttribute('valign', 'center');
  5640. td = document.createElement('td');
  5641. td.appendChild(ul);
  5642. tr.appendChild(td);
  5643. td.setAttribute('valign', 'center');
  5644. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  5645. td.setAttribute('valign', 'center');
  5646. td = document.createElement('td');
  5647. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  5648. input.setAttribute('name', idEquipement);
  5649. tr.appendChild(td);
  5650. td.setAttribute('valign', 'center');
  5651. }
  5652. catch(e)
  5653. {
  5654. }
  5655. }
  5656. insertBefore(insertPoint, table);
  5657. insertBefore(insertPoint, document.createElement('p'));
  5658. }
  5659. /* [zone] fin Obsolète ?? */
  5660.  
  5661.  
  5662. displayScriptTime();
  5663. }
  5664.  
  5665. /*******************************************************************************
  5666. * This file is part of Mountyzilla. *
  5667. * *
  5668. * Mountyzilla is free software; you can redistribute it and/or modify *
  5669. * it under the terms of the GNU General Public License as published by *
  5670. * the Free Software Foundation; either version 2 of the License, or *
  5671. * (at your option) any later version. *
  5672. * *
  5673. * Mountyzilla is distributed in the hope that it will be useful, *
  5674. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5675. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5676. * GNU General Public License for more details. *
  5677. * *
  5678. * You should have received a copy of the GNU General Public License *
  5679. * along with Mountyzilla; if not, write to the Free Software *
  5680. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5681. *******************************************************************************/
  5682.  
  5683. // x~x equip
  5684.  
  5685. /**
  5686. * 2014-02-08 - v2.0a (from scratch)
  5687. * 2014-02-18 - v2.0a0
  5688. * - ajout calcul Carats / UM des minerais + totaux
  5689. * 2014-03-06 - v2.0a1
  5690. * - retour Infos EM des Champis
  5691. * TODO
  5692. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  5693. */
  5694.  
  5695. function traiteChampis() {
  5696. try{
  5697. var tr = document.getElementById('mh_objet_hidden_Champignon');
  5698. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  5699. }
  5700. catch(e){return;}
  5701. if(trlist.length<=0) return;
  5702. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  5703. var node = trlist.snapshotItem(i).childNodes[7];
  5704. var str = node.textContent.trim();
  5705. var type = str.slice(0,str.lastIndexOf(' '));
  5706. var mundi = mundiChampi[type];
  5707. if(!mundi) continue;
  5708. var urlImg = URL_MZimg09
  5709. +'Competences/ecritureMagique.png';
  5710. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  5711. appendText(node,' ');
  5712. node.appendChild(img);
  5713. }
  5714. }
  5715.  
  5716. function traiteCompos() {
  5717. try {
  5718. var tr = document.getElementById('mh_objet_hidden_Composant');
  5719. var tbody = document.evaluate("./td/table/tbody",
  5720. tr, null, 9, null).singleNodeValue;
  5721. }
  5722. catch(e) {return;}
  5723. insererInfosEM(tbody);
  5724. }
  5725.  
  5726. function traiteMinerai() {
  5727. try{
  5728. var tr = document.getElementById('mh_objet_hidden_Minerai');
  5729. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  5730. }
  5731. catch(e){return;}
  5732. if(trlist.length<=0) return;
  5733. var totaux = {};
  5734. var str;
  5735. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  5736. var node = trlist.snapshotItem(i);
  5737. var nature = node.childNodes[7].textContent,
  5738. caracs = node.childNodes[9].textContent;
  5739. var taille = Number(caracs.match(/\d+/)[0]);
  5740. var coef = 1;
  5741. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  5742. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  5743. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  5744. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5745. if(nature.indexOf('Mithril')!=-1) {
  5746. coef = 0.2*coef;
  5747. str = ' | UM: ';
  5748. }
  5749. else {
  5750. coef = 0.75*coef+1.25;
  5751. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5752. str = ' | Carats: ';
  5753. }
  5754. var carats = Math.round(taille*coef)
  5755. appendText(node.childNodes[9], str+carats );
  5756. if(!totaux[nature]) {
  5757. totaux[nature] = [taille,carats];
  5758. }
  5759. else {
  5760. totaux[nature][0] += taille;
  5761. totaux[nature][1] += carats;
  5762. }
  5763. }
  5764. str = 'Total : ';
  5765. for(var nature in totaux) {
  5766. if(str.length>8) str += ', ';
  5767. if(nature.indexOf('Mithril')!=-1) {
  5768. str += nature+totaux[nature][1]+' UM';
  5769. }
  5770. else {
  5771. str += nature+totaux[nature][0]+'U/'
  5772. +totaux[nature][1]+'c';
  5773. }
  5774. }
  5775. /*var node = document.getElementById('mh_plus_Minerai');
  5776. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  5777. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  5778. if(!titre) return;*/
  5779. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  5780. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  5781. td.colSpan = 7;
  5782. }
  5783.  
  5784. function do_equip() {
  5785. start_script();
  5786.  
  5787. traiteChampis();
  5788. traiteCompos();
  5789. traiteMinerai();
  5790.  
  5791. displayScriptTime();
  5792. }
  5793.  
  5794. /*******************************************************************************
  5795. * This file is part of Mountyzilla. *
  5796. * *
  5797. * Mountyzilla is free software; you can redistribute it and/or modify *
  5798. * it under the terms of the GNU General Public License as published by *
  5799. * the Free Software Foundation; either version 2 of the License, or *
  5800. * (at your option) any later version. *
  5801. * *
  5802. * Mountyzilla is distributed in the hope that it will be useful, *
  5803. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5804. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5805. * GNU General Public License for more details. *
  5806. * *
  5807. * You should have received a copy of the GNU General Public License *
  5808. * along with Mountyzilla; if not, write to the Free Software *
  5809. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5810. *******************************************************************************/
  5811.  
  5812. // x~x diplo
  5813.  
  5814. /*
  5815. TODO:
  5816. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  5817. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  5818. V Étape 3: Ajout de la diplo perso
  5819. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  5820. V Étape 5: Ajout des fioritures (preview de la couleur...)
  5821. Options Globales:
  5822. Actuelles:
  5823. numTroll.USECSS,
  5824. numTroll.NODIPLO
  5825. NOMYTH
  5826. Nouvelles:
  5827. TODO numTroll.USECSS
  5828. numTroll.diplo.off (remplace NODIPLO)
  5829. numTroll.diplo.guilde
  5830. numTroll.diplo.perso
  5831. Structure de diplo.guilde:
  5832. isOn: 'true' ou 'false'
  5833. isDetailOn: 'true' ou 'false'
  5834. guilde
  5835. > id
  5836. > couleur
  5837. AllAmis,AllEnnemis: couleur
  5838. Amis0,...,Ennemis5
  5839. > Troll: idTroll1;...;
  5840. > Guilde: idGuilde1;...;
  5841. > titre
  5842. > couleur
  5843. Structure de diplo.perso:
  5844. isOn: 'true' ou 'false'
  5845. mythiques: couleur
  5846. Troll,Guilde,Monstre:
  5847. > id
  5848. > couleur
  5849. > description
  5850. */
  5851.  
  5852. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  5853.  
  5854. function couleurAleatoire() {
  5855. var alph = '0123456789ABCDEF'.split('');
  5856. var clr = '#';
  5857. for (var i=0; i<6; i++) {
  5858. clr+=alph[ Math.floor(16*Math.random()) ];
  5859. }
  5860. return clr;
  5861. }
  5862.  
  5863. function isCouleur(str) {
  5864. return /^#[0-9A-F]{6}$/i.test(str);
  5865. }
  5866.  
  5867. /*-[functions]---------------- Analyse de la page ----------------------------*/
  5868.  
  5869. function appendChoixCouleur(node,id) {
  5870. var span = document.createElement('span');
  5871. span.id = 'span'+id;
  5872. if(isDetailOn) {
  5873. span.style.display = 'none';
  5874. }
  5875. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  5876. if(diploGuilde[id]) {
  5877. couleur = diploGuilde[id];
  5878. }
  5879. appendText(span,' - Couleur HTML: ');
  5880. var input = appendTextbox(span,'text',id,7,7,couleur);
  5881. input.onkeyup = previewCouleur;
  5882. input.onchange = previewCouleur;
  5883. input.onkeyup();
  5884. node.appendChild(span);
  5885. }
  5886.  
  5887. function insertChoixCouleur(node,id) {
  5888. var span = document.createElement('span');
  5889. span.id = 'span'+id;
  5890. // La couleur détaillée passera à une valeur aléatoire
  5891. // si toggle vers isDetailOn
  5892. var couleur = couleurAleatoire();
  5893. if(!isDetailOn) {
  5894. span.style.display = 'none';
  5895. } else if(diploGuilde[id]) {
  5896. couleur = diploGuilde[id].couleur;
  5897. }
  5898. appendText(span,' - Couleur HTML: ');
  5899. var input = appendTextbox(span,'text',id,7,7,couleur);
  5900. input.onkeyup = previewCouleur;
  5901. input.onchange = previewCouleur;
  5902. input.onkeyup();
  5903. insertBefore(node,span);
  5904. }
  5905.  
  5906. function setChoixCouleurs() {
  5907. try {
  5908. var form = document.getElementsByName('ActionForm')[0];
  5909. var nodesAE = document.evaluate(
  5910. "./table/tbody/tr/td[@class='mh_tdtitre']",
  5911. form, null, 7, null
  5912. );
  5913. var nodes = document.evaluate(
  5914. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  5915. form, null, 7, null
  5916. );
  5917. } catch(e) {
  5918. window.console.error('[Diplomatie] Structure de la page non reconnue');
  5919. return false;
  5920. };
  5921. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  5922. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  5923. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  5924. for(var i=0 ; i<5 ; i++) {
  5925. nodes.snapshotItem(i).id = 'tdAmis'+i;
  5926. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  5927. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  5928. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  5929. }
  5930. return true;
  5931. }
  5932.  
  5933. function fetchDiploGuilde() {
  5934. try {
  5935. for(var AE in {Amis:0,Ennemis:0}) {
  5936. for(var i=0 ; i<5 ; i++) {
  5937. /* Récup des A/E de rang i */
  5938. var td = document.getElementById('td'+AE+i);
  5939. var ligne = td.getElementsByTagName('table')[0].rows;
  5940. var titre = trim(td.firstChild.textContent);
  5941. // On laisse la gestion des couleurs à setChoixCouleurs:
  5942. var couleur = document.getElementById(AE+i).value;
  5943. diploGuilde[AE+i] = {
  5944. Troll:'',
  5945. Guilde:'',
  5946. titre: titre,
  5947. couleur: couleur
  5948. };
  5949. for(var j=1 ; j<ligne.length ; j++) {
  5950. var str = trim(ligne[j].cells[0].textContent);
  5951. var idx = str.lastIndexOf('(');
  5952. var num = str.slice(idx+1,-1);
  5953. var type = trim(ligne[j].cells[1].textContent);
  5954. diploGuilde[AE+i][type] += num+';';
  5955. }
  5956. }
  5957. }
  5958. } catch(e) {
  5959. window.console.error('[Diplomatie] Échec de récupération de la diplo\n'+e);
  5960. return false;
  5961. }
  5962. return true;
  5963. }
  5964.  
  5965.  
  5966. /*-[functions]--------------------- Handlers ---------------------------------*/
  5967.  
  5968. function toggleDetails() {
  5969. isDetailOn = !isDetailOn;
  5970. for(var AE in {Amis:0,Ennemis:0}) {
  5971. document.getElementById('spanAll'+AE).style.display =
  5972. (isDetailOn?'none':'');
  5973. for(var i=0 ; i<5 ; i++) {
  5974. document.getElementById('span'+AE+i).style.display =
  5975. (isDetailOn?'':'none');
  5976. }
  5977. }
  5978. }
  5979.  
  5980. function toggleMythiques() {
  5981. isMythiquesOn = !isMythiquesOn;
  5982. document.getElementById('spanMythiques').style.display =
  5983. (isMythiquesOn?'':'none');
  5984. }
  5985.  
  5986. function previewCouleur() {
  5987. var value = this.value;
  5988. if(isCouleur(value)) {
  5989. this.style.backgroundColor = value;
  5990. this.title = '';
  5991. } else {
  5992. this.style.backgroundColor = '';
  5993. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  5994. }
  5995. }
  5996.  
  5997. function appendMenuType(node,duType) {
  5998. var select = document.createElement('select');
  5999. select.className = 'SelectboxV2';
  6000. var type = ['Guilde','Troll','Monstre'];
  6001. for(var i=0 ; i<3 ; i++) {
  6002. appendOption(select,type[i],type[i]);
  6003. if(type[i]==duType) { select.selectedIndex=i; }
  6004. }
  6005. node.appendChild(select);
  6006. }
  6007.  
  6008. function ajouteChamp(type,num,couleur,descr) {
  6009. var champs = document.getElementById('diploPerso');
  6010. var nb = champs.rows.length;
  6011. var tr = champs.insertRow(-1);
  6012. var td = appendTd(tr);
  6013. appendMenuType(td,type);
  6014. td = appendTd(tr);
  6015. appendText(td,' n°');
  6016. appendTextbox(td,'text','num'+nb,6,15,num);
  6017. td = appendTd(tr);
  6018. appendText(td,' couleur HTML:');
  6019. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  6020. input.onkeyup = previewCouleur;
  6021. input.onchange = previewCouleur;
  6022. input.onkeyup();
  6023. td = appendTd(tr);
  6024. appendText(td,' Description:');
  6025. appendTextbox(td,'text','descr'+nb,30,150,descr);
  6026. td = appendTd(tr);
  6027. var span = document.createElement('span');
  6028. appendText(span,'[ok!]',true);
  6029. span.style.visibility = 'hidden';
  6030. td.appendChild(span);
  6031. td = appendTd(tr);
  6032. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  6033. }
  6034.  
  6035. function retireCeChamp() {
  6036. var thisTr = this.parentNode.parentNode;
  6037. thisTr.parentNode.removeChild(thisTr);
  6038. var champs = document.getElementById('diploPerso');
  6039. if(champs.rows.length==0) { ajouteChamp(); }
  6040. }
  6041.  
  6042. function valideChamp(champ) {
  6043. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  6044. isCouleur(champ.cells[2].childNodes[1].value);
  6045. if(isValide) {
  6046. champ.cells[4].firstChild.style.visibility = 'visible';
  6047. } else {
  6048. champ.cells[4].firstChild.style.visibility = 'hidden';
  6049. }
  6050. return isValide;
  6051. }
  6052.  
  6053. function sauvegarderTout() {
  6054. /* Diplo de guilde */
  6055. diploGuilde.isOn =
  6056. document.getElementById('isGuildeOn').checked?'true':'false';
  6057. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  6058. var numGuilde = Number(document.getElementById('numGuilde').value);
  6059. var couleur = document.getElementById('couleurGuilde').value;
  6060. if(numGuilde) {
  6061. diploGuilde.guilde = {
  6062. id: numGuilde,
  6063. couleur: couleur
  6064. };
  6065. } else {
  6066. delete diploGuilde.guilde;
  6067. }
  6068. for(var AE in {Amis:0,Ennemis:0}) {
  6069. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  6070. for(var i=0 ; i<5 ; i++) {
  6071. if(isDetailOn) {
  6072. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  6073. } else {
  6074. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  6075. }
  6076. }
  6077. }
  6078. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  6079. /* Diplo personnelle (ex-fonction saveChamps) */
  6080. var champs = document.getElementById('diploPerso');
  6081. diploPerso = {
  6082. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  6083. Guilde: {},
  6084. Troll: {},
  6085. Monstre: {}
  6086. };
  6087. if(isMythiquesOn &&
  6088. isCouleur(document.getElementById('couleurMythiques').value)) {
  6089. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  6090. }
  6091. for(var i=0 ; i<champs.rows.length ; i++) {
  6092. if(valideChamp(champs.rows[i])) {
  6093. var type = champs.rows[i].cells[0].firstChild.value;
  6094. var num = champs.rows[i].cells[1].childNodes[1].value;
  6095. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  6096. var descr = champs.rows[i].cells[3].childNodes[1].value;
  6097. diploPerso[type][num] = {
  6098. couleur: couleur
  6099. };
  6100. if(descr) {
  6101. diploPerso[type][num].titre = descr;
  6102. }
  6103. }
  6104. }
  6105. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  6106.  
  6107. avertissement('Données sauvegardées');
  6108. }
  6109.  
  6110.  
  6111. /*-[functions]------------- Modifications de la page -------------------------*/
  6112.  
  6113. function creeTablePrincipale() {
  6114. var insertPt = document.getElementById('insertPt');
  6115. /* Titre + bouton de Sauvegarde */
  6116. var tr = insertTr(insertPt,'mh_tdtitre');
  6117. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  6118. appendButton(td,'Sauvegarder',sauvegarderTout);
  6119. /* Options fixes */
  6120. tr = insertTr(insertPt,'mh_tdpage');
  6121. td = appendTdText(tr,'Diplomatie de guilde:',true);
  6122. appendBr(td);
  6123. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  6124. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  6125. appendBr(td);
  6126. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  6127. appendText(td,'Utiliser des couleurs détaillées (10)');
  6128. /* Diplo personnelle */
  6129. tr = insertTr(insertPt,'mh_tdpage');
  6130. td = appendTdText(tr,'Diplomatie personnelle:',true);
  6131. appendBr(td);
  6132. // Diplo Mythiques
  6133. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  6134. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  6135. var span = document.createElement('span');
  6136. span.id = 'spanMythiques';
  6137. if(!isMythiquesOn) {
  6138. span.style.display = 'none';
  6139. }
  6140. var couleur = '#FFAAAA';
  6141. if(diploPerso.mythiques) {
  6142. couleur = diploPerso.mythiques;
  6143. }
  6144. appendText(span,' - couleur HTML:');
  6145. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  6146. input.onkeyup = previewCouleur;
  6147. input.onchange = previewCouleur;
  6148. input.onkeyup();
  6149. td.appendChild(span);
  6150. appendBr(td);
  6151. // Diplo éditable
  6152. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  6153. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  6154. appendBr(td);
  6155. var table = document.createElement('table');
  6156. table.id = 'diploPerso'
  6157. td.appendChild(table);
  6158. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  6159. for(var num in diploPerso[type]) {
  6160. ajouteChamp(
  6161. type,
  6162. num,
  6163. diploPerso[type][num].couleur,
  6164. diploPerso[type][num].titre
  6165. );
  6166. }
  6167. }
  6168. if(table.rows.length==0) {
  6169. ajouteChamp();
  6170. }
  6171. appendButton(td,'Ajouter',ajouteChamp)
  6172. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  6173. appendText(td,' ');
  6174. appendButton(td,
  6175. 'Exemples de couleur',
  6176. function() {
  6177. var fenetre = window.open(
  6178. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  6179. 'Divers',
  6180. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  6181. 'status=0,menubar=0,resizable=1,scrollbars=1'
  6182. );
  6183. fenetre.focus();
  6184. }
  6185. );
  6186. /* Couleur de Guilde */
  6187. tr = insertTr(insertPt,'mh_tdtitre');
  6188. td = appendTdText(tr,'GUILDE',true);
  6189. appendText(td,' - n°');
  6190. appendTextbox(td,'text','numGuilde',5,10,
  6191. diploGuilde.guilde && diploGuilde.guilde.id ?
  6192. diploGuilde.guilde.id : ''
  6193. );
  6194. appendText(td,' - Couleur HTML: ');
  6195. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  6196. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  6197. diploGuilde.guilde.couleur : '#BBBBFF'
  6198. );
  6199. input.onkeyup = previewCouleur;
  6200. input.onchange = previewCouleur;
  6201. input.onkeyup();
  6202. }
  6203.  
  6204.  
  6205. /*-[functions]----------------------- Main -----------------------------------*/
  6206.  
  6207. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6208. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6209. var isDetailOn = diploGuilde.isDetailOn=='true';
  6210. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6211. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6212. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6213.  
  6214. function do_diplo() {
  6215. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6216. creeTablePrincipale();
  6217. }
  6218. }
  6219.  
  6220. /*******************************************************************************
  6221. * This file is part of Mountyzilla. *
  6222. * *
  6223. * Mountyzilla is free software; you can redistribute it and/or modify *
  6224. * it under the terms of the GNU General Public License as published by *
  6225. * the Free Software Foundation; either version 2 of the License, or *
  6226. * (at your option) any later version. *
  6227. * *
  6228. * Mountyzilla is distributed in the hope that it will be useful, *
  6229. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6230. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6231. * GNU General Public License for more details. *
  6232. * *
  6233. * You should have received a copy of the GNU General Public License *
  6234. * along with Mountyzilla; if not, write to the Free Software *
  6235. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6236. *******************************************************************************/
  6237.  
  6238. // x~x cdmcomp
  6239.  
  6240. var cdm = '';
  6241.  
  6242. function getNonNegInts(str) {
  6243. var nbrs = str.match(/\d+/g);
  6244. for(var i=0 ; i<nbrs.length ; i++) {
  6245. nbrs[i] = Number(nbrs[i]);
  6246. }
  6247. return nbrs;
  6248. }
  6249.  
  6250. function traiteCdMcomp() {
  6251. try {
  6252. var msgEffet = document.getElementById('msgEffet');
  6253. } catch(e) {
  6254. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  6255. return;
  6256. }
  6257.  
  6258. // Teste si ce message du bot est un message de CdM
  6259. if(!document.evaluate(
  6260. "./p/b/text()[contains(.,'fait partie')]",
  6261. msgEffet, null, 9, null
  6262. ).singleNodeValue) {
  6263. return;
  6264. }
  6265. // Début de récupération de la CdM
  6266. cdm = document.evaluate(
  6267. "./p/b/text()[contains(.,'fait partie')]",
  6268. msgEffet, null, 9, null
  6269. ).singleNodeValue.nodeValue+'\n';
  6270. var tbody = document.evaluate(
  6271. "descendant::table/tbody",
  6272. msgEffet, null, 9, null
  6273. ).singleNodeValue;
  6274. var nomStat = document.evaluate(
  6275. "./tr/td[1]/b/text()",
  6276. tbody, null, 7, null
  6277. );
  6278. var valStat = document.evaluate(
  6279. "./tr/td[2]/descendant::text()",
  6280. tbody, null, 7, null
  6281. );
  6282. var i=0;
  6283. while(i<nomStat.snapshotLength) {
  6284. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  6285. cdm += 'Armure : ';
  6286. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  6287. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  6288. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  6289. armp = [0,armp[0]];
  6290. }
  6291. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  6292. armm = [0,armm[0]];
  6293. }
  6294. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  6295. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  6296. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  6297. } else {
  6298. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6299. }
  6300. cdm += ')\n';
  6301. i++;
  6302. } else {
  6303. cdm += nomStat.snapshotItem(i).nodeValue+
  6304. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  6305. }
  6306. i++;
  6307. }
  6308. // Envoi auto ou insertion bouton envoi (suivant option)
  6309. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  6310. sendInfoCDM();
  6311. var p = document.createElement('p');
  6312. p.style.color = 'green';
  6313. appendText(p,'CdM envoyée vers la base MountyZilla !');
  6314. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  6315. } else {
  6316. insertButtonCdm('as_Action', sendInfoCDM);
  6317. }
  6318.  
  6319. // Insertion de l'estimation des PV restants
  6320. var pv = valStat.snapshotItem(1).nodeValue;
  6321. if(pv.indexOf("entre")==-1) {
  6322. return;
  6323. }
  6324. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  6325. if(pv) {
  6326. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  6327. appendTdText(tr, pv[0], true);
  6328. appendTdText(tr, pv[1], true);
  6329. }
  6330. }
  6331.  
  6332. function sendInfoCDM() {
  6333. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  6334. var buttonCDM = this;
  6335. var texte = '';
  6336. FF_XMLHttpRequest({
  6337. method: 'GET',
  6338. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6339. headers : {
  6340. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6341. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6342. },
  6343. onload: function(responseDetails) {
  6344. texte = responseDetails.responseText;
  6345. buttonCDM.value = texte;
  6346. buttonCDM.disabled = true;
  6347. }
  6348. });
  6349. }
  6350.  
  6351. function do_cdmcomp() {
  6352. start_script(31);
  6353. traiteCdMcomp();
  6354. displayScriptTime();
  6355. }
  6356.  
  6357. /*********************************************************************************
  6358. * This file is part of Mountyzilla. *
  6359. * *
  6360. * Mountyzilla is free software; you can redistribute it and/or modify *
  6361. * it under the terms of the GNU General Public License as published by *
  6362. * the Free Software Foundation; either version 2 of the License, or *
  6363. * (at your option) any later version. *
  6364. * *
  6365. * Mountyzilla is distributed in the hope that it will be useful, *
  6366. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6367. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6368. * GNU General Public License for more details. *
  6369. * *
  6370. * You should have received a copy of the GNU General Public License *
  6371. * along with Mountyzilla; if not, write to the Free Software *
  6372. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6373. *********************************************************************************/
  6374.  
  6375. // x~x cmdbot
  6376.  
  6377. /* v0.2 by Dab - 2013-08-20
  6378. * - patch dégueu pour gérer la décomposition P/M de l'armure
  6379. */
  6380.  
  6381. var buttonCDM;
  6382.  
  6383. /*******************************************************************************************
  6384. CDM :
  6385. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  6386.  
  6387. Il ne vous est pas possible d'améliorer cette compétence.
  6388.  
  6389. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  6390. Niveau : Inimaginable (entre 49 et 51)
  6391. Points de Vie : Surtrollesque (entre 450 et 470)
  6392. Blessure (Approximatif) : 0 %
  6393. Dés d'Attaque : Impressionnant (entre 30 et 32)
  6394. Dés d'Esquive : Impressionnant (entre 28 et 30)
  6395. Dés de Dégat : Très Fort (entre 18 et 20)
  6396. Dés de Régénération : Excellent (égal à 13)
  6397. Armure Physique : Moyen (entre 10 et 12)
  6398. Armure Magique : Faible (inférieur à 6)
  6399. Vue : Moyen (entre 9 et 11)
  6400. Maitrise Magique : Inimaginable (supérieur à 6000)
  6401. Résistance Magique : Inimaginable (supérieur à 6000)
  6402. Nombre d'attaques : 1
  6403. Vitesse de Déplacement : Normale
  6404. Voir le Caché : Oui
  6405. Attaque à distance : Non
  6406. Attaque magique : Oui
  6407. Vole : Non
  6408. Sang froid : Inexistant
  6409. DLA : Milieu
  6410. Durée Tour : Remarquable (entre 9 et 11)
  6411. Chargement : Vide
  6412. Bonus Malus : Aucun
  6413.  
  6414. Vous avez également gagné 1 PX pour la réussite.
  6415. *******************************************************************************************
  6416. BOT :
  6417. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  6418.  
  6419. Le Monstre ciblé fait partie des : Mort-Vivant
  6420.  
  6421. Niveau : Incroyable (entre 36 et 38)
  6422. *******************************************************************************************/
  6423.  
  6424. function getNNInt(str) {
  6425. var nbrs = str.match(/\d+/g);
  6426. for (var i=0 ; i<nbrs.length ; i++)
  6427. nbrs[i] = parseInt(nbrs[i]);
  6428. return nbrs;
  6429. }
  6430.  
  6431. function sendCDM() {
  6432. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6433. document, null, 9, null).singleNodeValue;
  6434. cdm = td.innerHTML;
  6435. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  6436. "$3$4 ($1 - N°$2)<br>");
  6437. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  6438. 'Blessure : XX % (approximativement)');
  6439. // Supprime la décomposition P/M de l'Armure
  6440. var bgn = cdm.indexOf('Armure Physique');
  6441. if (bgn!=-1) {
  6442. var end = cdm.indexOf('Vue')-2;
  6443. var lines = cdm.substring(bgn,end).split('<br>');
  6444. var armp = getNNInt(lines[0]);
  6445. var armm = getNNInt(lines[1]);
  6446. if (lines[0].indexOf('(inf')!=-1)
  6447. armp = [0,armp[0]];
  6448. if (lines[1].indexOf('(inf')!=-1)
  6449. armm = [0,armm[0]];
  6450. var insrt = 'Armure : ';
  6451. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  6452. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  6453. else
  6454. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6455. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  6456. }
  6457. cdm = cdm.replace(/<br>/g,'\n');
  6458. FF_XMLHttpRequest({
  6459. method: 'GET',
  6460. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6461. headers : {
  6462. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6463. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6464. },
  6465. onload: function(responseDetails) {
  6466. buttonCDM.value=responseDetails.responseText;
  6467. buttonCDM.disabled = true;
  6468. }
  6469. });
  6470. }
  6471.  
  6472. function traiteCdMmsg() {
  6473. // Teste si ce message du bot est un message de CdM
  6474. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6475. document, null, 9, null).singleNodeValue;
  6476. if (!td) return false;
  6477. cdm = td.innerHTML;
  6478. // Insertion de l'estimation des PV restants
  6479. var des = cdm.indexOf('Dés');
  6480. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  6481. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  6482. if(pv)
  6483. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  6484.  
  6485. // Insertion bouton envoi + espace
  6486. buttonCDM = insertButtonCdm('bClose',sendCDM);
  6487. }
  6488.  
  6489. /*function traitePouvoir() {
  6490. // Teste si ce message du bot est un message de CdM
  6491. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  6492. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  6493. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6494. if (!td)
  6495. return false;
  6496. var infos = td.innerHTML;
  6497. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  6498. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  6499. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  6500. var date = /alors : ([^<]+)\./.exec(infos)[1];
  6501. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  6502. var effetPouvoir="";
  6503. var full=false;
  6504. if(infos.indexOf("REDUIT")!=-1) {
  6505. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  6506. }
  6507. else {
  6508. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  6509. full=true;
  6510. }
  6511. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  6512. // On insère le bouton et un espace
  6513. //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));
  6514. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  6515. if(!MY_getValue('AUTOSENDPOUV'))
  6516. {
  6517. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  6518. button.setAttribute("onClick", "window.open('" + url
  6519. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  6520. + "this.value='Merci de votre participation'; this.disabled = true;");
  6521. }
  6522. else
  6523. {
  6524. FF_XMLHttpRequest({
  6525. method: 'GET',
  6526. url: url,
  6527. headers : {
  6528. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6529. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6530. }});
  6531. }
  6532. }*/
  6533.  
  6534. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  6535. traiteCdMmsg();
  6536. }
  6537. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  6538.  
  6539. /*******************************************************************************
  6540. * This file is part of Mountyzilla. *
  6541. * *
  6542. * Mountyzilla is free software; you can redistribute it and/or modify *
  6543. * it under the terms of the GNU General Public License as published by *
  6544. * the Free Software Foundation; either version 2 of the License, or *
  6545. * (at your option) any later version. *
  6546. * *
  6547. * Mountyzilla is distributed in the hope that it will be useful, *
  6548. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6549. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6550. * GNU General Public License for more details. *
  6551. * *
  6552. * You should have received a copy of the GNU General Public License *
  6553. * along with Mountyzilla; if not, write to the Free Software *
  6554. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6555. *******************************************************************************/
  6556.  
  6557. // x~x menu
  6558. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  6559.  
  6560. var menuRac, mainIco;
  6561.  
  6562. function updateData() {
  6563. var inputs = document.getElementsByTagName('input');
  6564. var divs = document.getElementsByTagName('div');
  6565. numTroll = inputs[0].value;
  6566. MY_setValue('NUM_TROLL', numTroll);
  6567. MY_setValue('NIV_TROLL',inputs[1].value);
  6568. if(!MY_getValue(numTroll+'.caracs.rm')) {
  6569. MY_setValue(numTroll+'.caracs.rm',0);
  6570. // assure l'init des 4 var de libs
  6571. }
  6572. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  6573. var DLA = new Date(
  6574. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  6575. );
  6576. if(MY_getValue(numTroll+'.DLA.encours')) {
  6577. var DLAstockee = new Date(
  6578. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  6579. );
  6580. if(DLA>DLAstockee) {
  6581. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  6582. // Pose un pb en cas de décalage de DLA
  6583. }
  6584. }
  6585. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  6586. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  6587. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  6588. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  6589. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  6590. }
  6591.  
  6592. function initRaccourcis() {
  6593. var anotherURL = MY_getValue('URL1');
  6594. if(!anotherURL) { return; }
  6595. /* Création de l'icône faisant apparaître le menu */
  6596. mainIco = document.createElement('img');
  6597. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  6598. if(!urlIco) {
  6599. urlIco =
  6600. URL_MZimg09 + 'mz_logo_small.png';
  6601. }
  6602. mainIco.src = urlIco;
  6603. mainIco.alt = 'MZ';
  6604. mainIco.style = 'position:fixed; top:0px; left:0px';
  6605. mainIco.onmouseover = afficheMenu;
  6606. document.body.appendChild(mainIco);
  6607. /* Création du menu des Raccourcis */
  6608. menuRac = document.createElement('div');
  6609. menuRac.className = 'mh_textbox';
  6610. menuRac.style =
  6611. 'position:fixed; top:10px; left:10px;'+
  6612. 'max-width:190px;'+
  6613. 'border-radius: 4px; padding: 4px;'+
  6614. 'z-index: 500;'+
  6615. 'visibility: hidden;';
  6616. document.body.appendChild(menuRac);
  6617. document.addEventListener('mousemove',cacheMenu,false);
  6618. var i=1;
  6619. while(anotherURL) {
  6620. var a = document.createElement('a');
  6621. var url = MY_getValue('URL'+i);
  6622. var nom = MY_getValue('URL'+i+'.nom');
  6623. var ico = MY_getValue('URL'+i+'.ico');
  6624. a.href = url;
  6625. a.target = '_blank';
  6626. if(ico) {
  6627. var txt = nom ? nom : '';
  6628. var img = createImage(ico,txt);
  6629. a.appendChild(img);
  6630. }
  6631. else {
  6632. appendText(a,'['+nom+']');
  6633. }
  6634. menuRac.appendChild(a);
  6635. appendBr(menuRac);
  6636. i++;
  6637. anotherURL = MY_getValue('URL'+i);
  6638. }
  6639. }
  6640.  
  6641. function afficheMenu() {
  6642. menuRac.style.visibility = 'visible';
  6643. }
  6644.  
  6645. function cacheMenu(e) {
  6646. if(menuRac.style.visibility=='hidden') { return; }
  6647. // Position souris
  6648. var ptX = e.clientX;
  6649. var ptY = e.clientY;
  6650. // On recalcule en live les BoundingBox pour mainIco et menuRac
  6651. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  6652. var menuRect = menuRac.getBoundingClientRect();
  6653. var icoRect = mainIco.getBoundingClientRect();
  6654. if((ptX>icoRect.width || ptY>icoRect.height) &&
  6655. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  6656. menuRac.style.visibility = 'hidden';
  6657. }
  6658. }
  6659.  
  6660. function oldSchoolProfile() {
  6661. try {
  6662. var lienProfil = document.getElementById("Image1").parentNode;
  6663. lienProfil.href = "Play_profil.php";
  6664. } catch(e) {
  6665. avertissement();
  6666. window.console.log("[MZ menu] Lien vers le profil non trouvé",e);
  6667. }
  6668. }
  6669.  
  6670. function do_menu() {
  6671. updateData();
  6672. initRaccourcis();
  6673. if(MY_getValue(numTroll+".OLDSCHOOL")=="true") {
  6674. oldSchoolProfile();
  6675. }
  6676. }
  6677.  
  6678. /*******************************************************************************
  6679. * This file is part of Mountyzilla. *
  6680. * *
  6681. * Mountyzilla is free software; you can redistribute it and/or modify *
  6682. * it under the terms of the GNU General Public License as published by *
  6683. * the Free Software Foundation; either version 2 of the License, or *
  6684. * (at your option) any later version. *
  6685. * *
  6686. * Mountyzilla is distributed in the hope that it will be useful, *
  6687. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6688. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6689. * GNU General Public License for more details. *
  6690. * *
  6691. * You should have received a copy of the GNU General Public License *
  6692. * along with Mountyzilla; if not, write to the Free Software *
  6693. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6694. *******************************************************************************/
  6695.  
  6696. // x~x vue
  6697.  
  6698. /* TODO
  6699. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  6700. * prévoir fix ("delete infos")
  6701. */
  6702.  
  6703. /*--------------------------- Variables Globales -----------------------------*/
  6704.  
  6705. // Infos remplies par des scripts extérieurs
  6706. var listeCDM = [], listeLevels = [];
  6707.  
  6708. // Position actuelle
  6709. var currentPosition=[0,0,0];
  6710.  
  6711. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  6712. var porteeVue=[0,0,0,0];
  6713.  
  6714. // Fenêtres déplaçables
  6715. var winCurr = null;
  6716. var offsetX, offsetY;
  6717. document.onmousemove = drag;
  6718.  
  6719. // Diplomatie
  6720. var Diplo = {
  6721. Guilde: {},
  6722. Troll: {},
  6723. Monstre: {}
  6724. // .mythiques: uniquement si option activée
  6725. };
  6726. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  6727.  
  6728. // Infos tactiques
  6729. var popup;
  6730.  
  6731. // Gère l'affichage en cascade des popups de CdM
  6732. var nbCDM = 0;
  6733.  
  6734. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  6735.  
  6736. // Utilisé pour supprimer les monstres "engagés"
  6737. var listeEngages = {};
  6738. var isEngagesComputed = false;
  6739. var cursorOnLink = false; // DEBUG: wtf ?
  6740.  
  6741. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  6742. && MY_getValue(numTroll+'.enchantement.liste')!='';
  6743.  
  6744. // Checkboxes de filtrage
  6745. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  6746. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  6747. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  6748. comboBoxNiveauMin, comboBoxNiveauMax;
  6749.  
  6750. /* Acquisition & Stockage des données de DB */
  6751. const typesAFetcher = {
  6752. 'monstres':1,
  6753. 'trolls':1,
  6754. 'tresors':1,
  6755. 'champignons':1,
  6756. 'lieux':1
  6757. }
  6758. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  6759. tr_champignons = {}, tr_lieux = {};
  6760. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  6761. nbChampignons = 0, nbLieux = 0;
  6762.  
  6763. function fetchData(type) {
  6764. try {
  6765. var node = document.getElementById('mh_vue_hidden_'+type);
  6766. // this = MZ.global = sandBox de travail de MZ
  6767. // On définit donc des variables MZ-globales
  6768. this['tr_'+type] = node.getElementsByTagName('tr');
  6769. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  6770. } catch(e) {
  6771. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  6772. }
  6773. }
  6774.  
  6775.  
  6776. /*---------------------------------- DEBUG -----------------------------------*/
  6777. var mainTabs = document.getElementsByClassName('mh_tdborder');
  6778. var x_monstres = tr_monstres;
  6779. var x_trolls = tr_trolls;
  6780. var x_tresors = tr_tresors;
  6781. var x_champis = tr_champignons;
  6782. var x_lieux = tr_lieux;
  6783. /*-------------------------------- FIN DEBUG ---------------------------------*/
  6784.  
  6785.  
  6786. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6787.  
  6788. function positionToString(arr) {
  6789. return arr.join(';');
  6790. }
  6791.  
  6792. function savePosition() {
  6793. // Stocke la position (à jour) de la vue pour les autres scripts
  6794. // DEBUG: Lesquels et pourquoi?
  6795. var pos = getPosition();
  6796. MY_setValue(numTroll+'.position.X',pos[0]);
  6797. MY_setValue(numTroll+'.position.Y',pos[1]);
  6798. MY_setValue(numTroll+'.position.N',pos[2]);
  6799. }
  6800.  
  6801.  
  6802. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  6803. /* INFOS :
  6804. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  6805. * sont identifiables via leur Name
  6806. * les tables-listings sont identifiables via l'ID du tr conteneur
  6807. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  6808. */
  6809.  
  6810. /* [functions] Récup données Utilisateur */
  6811. function getPosition() {
  6812. // Pour rétrocompatibilité
  6813. return currentPosition;
  6814. }
  6815.  
  6816. function getPorteVue() {
  6817. // Pour rétrocompatibilité
  6818. return porteeVue;
  6819. }
  6820.  
  6821. function getVue() {
  6822. // Retourne [vueHpure, vueVpure]
  6823. var vues = getPorteVue();
  6824. return [ vues[0], vues[1] ];
  6825. }
  6826.  
  6827. // Roule 11/03/2016
  6828. /* [functions] Récup données monstres, trolls, etc. */
  6829. function getXxxDistance(xxx, i) {
  6830. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  6831. }
  6832. function getXxxPosition(xxx, i) {
  6833. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  6834. var l = tds.length;
  6835. return [
  6836. parseInt(tds[l-3].textContent),
  6837. parseInt(tds[l-2].textContent),
  6838. parseInt(tds[l-1].textContent)
  6839. ];
  6840. }
  6841.  
  6842.  
  6843. /* [functions] Récup données monstres */
  6844. function getMonstreDistance(i) {
  6845. return parseInt(tr_monstres[i].cells[0].textContent);
  6846. }
  6847.  
  6848. function getMonstreID(i) {
  6849. return tr_monstres[i].cells[2].firstChild.nodeValue;
  6850. }
  6851.  
  6852. function getMonstreIDByTR(tr) {
  6853. return tr.cells[2].firstChild.nodeValue;
  6854. }
  6855.  
  6856. function getMonstreLevelNode(i) {
  6857. return tr_monstres[i].cells[3];
  6858. }
  6859.  
  6860. function getMonstreLevel(i) {
  6861. if(!isCDMsRetrieved) return -1;
  6862. var donneesMonstre = listeCDM[getMonstreID(i)];
  6863. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  6864. }
  6865.  
  6866. function getMonstreNomNode(i) {
  6867. try {
  6868. var td = document.evaluate(
  6869. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  6870. tr_monstres[i], null, 9, null
  6871. ).singleNodeValue;
  6872. return td;
  6873. } catch(e) {
  6874. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  6875. window.console.error(e);
  6876. }
  6877. }
  6878.  
  6879. function getMonstreNom(i) {
  6880. return getMonstreNomByTR(tr_monstres[i]);
  6881. }
  6882.  
  6883. function getMonstreNomByTR(tr) {
  6884. try {
  6885. var nom = document.evaluate(
  6886. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  6887. tr, null, 2, null
  6888. ).stringValue;
  6889. return nom;
  6890. } catch(e) {
  6891. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  6892. window.console.error(e);
  6893. }
  6894. }
  6895.  
  6896. function getMonstrePosition(i) {
  6897. var tds = tr_monstres[i].childNodes;
  6898. var l = tds.length;
  6899. return [
  6900. parseInt(tds[l-3].textContent),
  6901. parseInt(tds[l-2].textContent),
  6902. parseInt(tds[l-1].textContent)
  6903. ];
  6904. }
  6905.  
  6906. function appendMonstres(txt) {
  6907. for(var i=1; i<=nbMonstres ; i++)
  6908. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  6909. return txt;
  6910. }
  6911.  
  6912. function getMonstres() {
  6913. var vue = getVue();
  6914. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  6915. }
  6916.  
  6917. function bddMonstres(start,stop) {
  6918. if(!start) { var start = 1; }
  6919. if(!stop) { var stop = nbMonstres; }
  6920. stop = Math.min(nbMonstres,stop);
  6921. var txt='';
  6922. for(var i=start ; i<=stop ; i++) {
  6923. txt += getMonstreID(i)+';'+
  6924. getMonstreNom(i)+';'+
  6925. positionToString(getMonstrePosition(i))+'\n';
  6926. }
  6927. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  6928. }
  6929.  
  6930. /* [functions] Récup données Trolls */
  6931. function getTrollDistance(i) {
  6932. return parseInt(tr_trolls[i].cells[0].textContent);
  6933. }
  6934.  
  6935. function getTrollID(i) {
  6936. return parseInt(tr_trolls[i].cells[2].textContent);
  6937. }
  6938.  
  6939. function getTrollNomNode(i) {
  6940. var isEnvoiOn =
  6941. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  6942. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  6943. }
  6944.  
  6945. function getTrollNivNode(i) {
  6946. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  6947. return tr_trolls[i].cells[4];
  6948. }
  6949.  
  6950. function getTrollGuilde(i) {
  6951. return trim(tr_trolls[i].cells[6].textContent);
  6952. }
  6953.  
  6954. function getTrollGuildeID(i) {
  6955. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  6956. var href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  6957. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  6958. }
  6959. return -1;
  6960. }
  6961.  
  6962. function getTrollPosition(i) {
  6963. var tds = tr_trolls[i].childNodes;
  6964. var l = tds.length;
  6965. return [
  6966. parseInt(tds[l-3].textContent),
  6967. parseInt(tds[l-2].textContent),
  6968. parseInt(tds[l-1].textContent)
  6969. ];
  6970. }
  6971.  
  6972. function bddTrolls() {
  6973. var txt='#DEBUT TROLLS\n'+
  6974. numTroll+';'+positionToString(getPosition())+'\n';
  6975. for(var i=1 ; i<=nbTrolls ; i++) {
  6976. txt += getTrollID(i)+';'+
  6977. positionToString(getTrollPosition(i))+'\n';
  6978. }
  6979. return txt+'#FIN TROLLS';
  6980. }
  6981.  
  6982. /* [functions] Récup données Trésors */
  6983. function getTresorDistance(i) {
  6984. return tr_tresors[i].cells[0].firstChild.nodeValue;
  6985. }
  6986.  
  6987. function getTresorID(i) {
  6988. return trim(tr_tresors[i].cells[2].textContent);
  6989. }
  6990.  
  6991. function getTresorNom(i) {
  6992. // Utilisation de textContent pour régler le "bug de Pollux"
  6993. return trim(tr_tresors[i].cells[3].textContent);
  6994. }
  6995.  
  6996. function getTresorPosition(i) {
  6997. var tds = tr_tresors[i].childNodes;
  6998. var l = tds.length;
  6999. return [
  7000. parseInt(tds[l-3].textContent),
  7001. parseInt(tds[l-2].textContent),
  7002. parseInt(tds[l-1].textContent),
  7003. ];
  7004. }
  7005.  
  7006. function bddTresors(dmin,start,stop) {
  7007. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  7008. if(!dmin) { var dmin = 0; }
  7009. if(!start) { var start = 1; }
  7010. if(!stop) { var stop = nbTresors; }
  7011. stop = Math.min(nbTresors,stop);
  7012. var txt='';
  7013. for(var i=start ; i<=stop ; i++) {
  7014. if(getTresorDistance(i)>=dmin) {
  7015. txt += getTresorID(i)+';'+
  7016. getTresorNom(i)+';'+
  7017. positionToString(getTresorPosition(i))+'\n';
  7018. }
  7019. }
  7020. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  7021. }
  7022.  
  7023. /* [functions] Récup données Champignons */
  7024. // DEBUG: Pas de colonne "Référence" sur serveur de test
  7025. function getChampignonNom(i) {
  7026. return trim(tr_champignons[i].cells[2].textContent);
  7027. }
  7028.  
  7029. function getChampignonPosition(i) {
  7030. var tds = tr_champignons[i].childNodes;
  7031. var l = tds.length;
  7032. return [
  7033. parseInt(tds[l-3].textContent),
  7034. parseInt(tds[l-2].textContent),
  7035. parseInt(tds[l-1].textContent)
  7036. ];
  7037. }
  7038.  
  7039. function bddChampignons() {
  7040. var txt='';
  7041. for(var i=1 ; i<=nbChampignons ; i++) {
  7042. txt += ';'+ // Les champis n'ont pas de Référence
  7043. getChampignonNom(i)+';'+
  7044. positionToString(getChampignonPosition(i))+'\n';
  7045. }
  7046. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  7047. }
  7048.  
  7049. /* [functions] Récup données Lieux */
  7050. function getLieuDistance(i) {
  7051. return parseInt(tr_lieux[i].cells[0].textContent);
  7052. }
  7053.  
  7054. function getLieuID(i) {
  7055. return parseInt(tr_lieux[i].cells[2].textContent);
  7056. }
  7057.  
  7058. function getLieuNom(i) {
  7059. // Conversion ASCII pour éviter les bugs des Vues externes
  7060. return trim(tr_lieux[i].cells[3].textContent);
  7061. }
  7062.  
  7063. function getLieuPosition(i) {
  7064. var tds = tr_lieux[i].childNodes;
  7065. var l = tds.length;
  7066. return [
  7067. parseInt(tds[l-3].textContent),
  7068. parseInt(tds[l-2].textContent),
  7069. parseInt(tds[l-1].textContent)
  7070. ];
  7071. }
  7072.  
  7073. function appendLieux(txt) {
  7074. for(var i = 1; i < nbLieux+1; i++) {
  7075. var tds = x_lieux[i].childNodes;
  7076. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  7077. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  7078. }
  7079. return txt;
  7080. }
  7081.  
  7082. function getLieux() {
  7083. var vue = getVue();
  7084. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7085. }
  7086.  
  7087. function bddLieux(start,stop) {
  7088. if(!start) { var start = 1; }
  7089. if(!stop) { var stop = nbLieux; }
  7090. stop = Math.min(nbLieux,stop);
  7091. var txt='';
  7092. for(var i=start ; i<=stop ; i++) {
  7093. txt += getLieuID(i)+';'+
  7094. epure(getLieuNom(i))+';'+
  7095. positionToString(getLieuPosition(i))+'\n';
  7096. }
  7097. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  7098. }
  7099.  
  7100.  
  7101. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  7102.  
  7103. function saveCheckBox(chkbo, pref) {
  7104. // Enregistre et retourne l'état d'une CheckBox
  7105. var etat = chkbo.checked;
  7106. MY_setValue(pref, etat ? 'true' : 'false' );
  7107. return etat;
  7108. }
  7109.  
  7110. function recallCheckBox(chkbox, pref) {
  7111. // Restitue l'état d'une CheckBox
  7112. chkbox.checked = (MY_getValue(pref)=='true');
  7113. }
  7114.  
  7115. function saveComboBox(cbb, pref) {
  7116. // Enregistre et retourne l'état d'une ComboBox
  7117. var etat = cbb.selectedIndex;
  7118. MY_setValue(pref, etat);
  7119. return etat;
  7120. }
  7121.  
  7122. function recallComboBox(cbb, pref) {
  7123. // Restitue l'état d'une ComboBox
  7124. var nb = MY_getValue(pref);
  7125. if(nb) cbb.value = nb;
  7126. return nb;
  7127. }
  7128.  
  7129. function synchroniseFiltres() {
  7130. // Récupération de toutes les options de la vue
  7131. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  7132. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  7133. if(numBool) {
  7134. debutFiltrage('Monstres');
  7135. }
  7136. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  7137. recallCheckBox(checkBoxMythiques,'NOMYTH');
  7138. recallCheckBox(checkBoxEngages,'NOENGAGE');
  7139. recallCheckBox(checkBoxLevels,'NOLEVEL');
  7140. recallCheckBox(checkBoxIntangibles,'NOINT');
  7141. recallCheckBox(checkBoxGG,'NOGG');
  7142. recallCheckBox(checkBoxCompos,'NOCOMP');
  7143. recallCheckBox(checkBoxBidouilles,'NOBID');
  7144. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  7145. recallCheckBox(checkBoxTrou,'NOTROU');
  7146. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  7147. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  7148. if(MY_getValue('NOINFOEM')!='true')
  7149. recallCheckBox(checkBoxEM,'NOEM');
  7150. }
  7151.  
  7152.  
  7153. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  7154.  
  7155. /* [functions] Menu Vue 2D */
  7156. var vue2Ddata = {
  7157. 'Bricol\' Vue': {
  7158. url: URL_MZmountyhall + 'vue_form.php',
  7159. paramid: 'vue',
  7160. func: getVueScript,
  7161. extra_params: {
  7162. 'mode': 'vue_SP_Vue2',
  7163. 'screen_width': window.screen.width
  7164. }
  7165. },
  7166. 'Vue du CCM': {
  7167. url: URL_vue_CCM,
  7168. paramid: 'vue',
  7169. func: getVueScript,
  7170. extra_params: {
  7171. 'id': numTroll+';'+positionToString(getPosition())
  7172. }
  7173. },
  7174. 'Vue Gloumfs 2D': {
  7175. url: URL_vue_Gloumfs2D,
  7176. paramid: 'vue_mountyzilla',
  7177. func: getVueScript,
  7178. extra_params: {}
  7179. },
  7180. 'Vue Gloumfs 3D': {
  7181. url: URL_vue_Gloumfs3D,
  7182. paramid: 'vue_mountyzilla',
  7183. func: getVueScript,
  7184. extra_params: {}
  7185. },
  7186. 'Grouky Vue!': {
  7187. url: URL_vue_Grouky,
  7188. paramid: 'vue',
  7189. func: getVueScript,
  7190. extra_params: {
  7191. 'type_vue': 'V5b1'
  7192. }
  7193. },
  7194. /*'DEBUG': {
  7195. url: 'http://weblocal/testeur.php',
  7196. paramid: 'vue',
  7197. func: getVueScript,
  7198. extra_params: {}
  7199. }*/
  7200. };
  7201.  
  7202. function getVueScript() {
  7203. try {
  7204. var txt = bddTrolls()+
  7205. bddMonstres()+
  7206. bddChampignons()+
  7207. bddTresors()+
  7208. bddLieux()+
  7209. '#DEBUT ORIGINE\n'+
  7210. getPorteVue()[2]+';'+positionToString(getPosition())+
  7211. '\n#FIN ORIGINE\n';
  7212. return txt;
  7213. } catch(e) {
  7214. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7215. window.console.error('[MZ getVueScript]\n',e)
  7216. }
  7217. }
  7218.  
  7219. function refresh2DViewButton() {
  7220. // = EventListener menu+bouton vue 2D
  7221. var vueext = document.getElementById('selectVue2D').value;
  7222. MY_setValue('VUEEXT',vueext);
  7223. var form = document.getElementById('viewForm');
  7224. form.innerHTML = '';
  7225. form.method = 'post';
  7226. form.action = vue2Ddata[vueext].url;
  7227. form.target = '_blank';
  7228. appendHidden(form, vue2Ddata[vueext].paramid, '');
  7229. for(var key in vue2Ddata[vueext].extra_params) {
  7230. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  7231. }
  7232. appendSubmit(form, 'Voir',
  7233. function() {
  7234. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  7235. vue2Ddata[vueext].func();
  7236. }
  7237. );
  7238. }
  7239.  
  7240. function set2DViewSystem() {
  7241. // Initialise le système de vue 2D
  7242. // Recherche du point d'insertion
  7243. try {
  7244. var center = document.evaluate(
  7245. "//h2[@id='titre2']/following-sibling::center",
  7246. document, null, 9, null
  7247. ).singleNodeValue;
  7248. } catch(e) {
  7249. avertissement("Erreur d'initialisation du système de vue 2D");
  7250. window.console.error("[MZ] set2DViewSystem",e);
  7251. return;
  7252. }
  7253. // Récupération de la dernière vue utilisée
  7254. var vueext = MY_getValue('VUEEXT');
  7255. if(!vueext || !vue2Ddata[vueext]) {
  7256. // sinon, la vue Bricol'Trolls est employée par défaut
  7257. vueext = 'Bricol\' Vue';
  7258. }
  7259. // Création du sélecteur de vue externe
  7260. selectVue2D = document.createElement('select');
  7261. selectVue2D.id = 'selectVue2D';
  7262. selectVue2D.className = 'SelectboxV2';
  7263. for(var view in vue2Ddata) {
  7264. appendOption(selectVue2D, view, view);
  7265. }
  7266. selectVue2D.value = vueext;
  7267. selectVue2D.onchange = refresh2DViewButton;
  7268. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  7269. var form = document.createElement('form');
  7270. form.id = 'viewForm';
  7271. // Insertion du système de vue
  7272. var table = document.createElement('table');
  7273. var tr = appendTr(table);
  7274. var td = appendTd(tr);
  7275. td.appendChild(selectVue2D);
  7276. td = appendTd(tr);
  7277. td.style.fontSize = '0px'; // gère le bug de l'extra character
  7278. td.appendChild(form);
  7279. center.insertBefore(table,center.firstChild);
  7280. insertBr(center.childNodes[1]);
  7281. // Appelle le handler pour initialiser le bouton de submit
  7282. refresh2DViewButton();
  7283. }
  7284.  
  7285. /* [functions] Tableau d'Infos */
  7286. function initialiseInfos() {
  7287. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  7288. var
  7289. infoTab = document.getElementsByName('LimitViewForm')[0].
  7290. getElementsByTagName('table')[0],
  7291. tbody = infoTab.tBodies[0],
  7292. thead = infoTab.createTHead(),
  7293. tr = appendTr(thead,'mh_tdtitre'),
  7294. td = appendTdText(tr,'INFORMATIONS',true),
  7295. span = document.createElement('span');
  7296. // Récupération de la position du joueur
  7297. try {
  7298. var strPos = document.evaluate(
  7299. ".//li/b/text()[contains(.,'X = ')]",
  7300. infoTab, null, 9, null
  7301. ).singleNodeValue.nodeValue;
  7302. // ***INIT GLOBALE*** currentPosition
  7303. currentPosition = getNumbers(strPos);
  7304. debugMZ("retrievePosition(): "+currentPosition);
  7305. } catch(e) {
  7306. // Si on ne trouve pas le "X ="
  7307. window.console.error("[MZ Vue] Position joueur non trouvée",e);
  7308. }
  7309. // Récupération des portées (max et limitée) de la vue
  7310. try {
  7311. var
  7312. nodes = document.evaluate(
  7313. ".//li/b/text()[contains(.,'horizontalement') "+
  7314. "or contains(.,'verticalement')]",
  7315. infoTab, null, 7, null
  7316. ),
  7317. array = [];
  7318. for(var i=0 ; i<4 ; i++) {
  7319. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  7320. }
  7321. // ***INIT GLOBALE*** porteeVue
  7322. porteeVue = array;
  7323. } catch(e) {
  7324. window.console.error("[MZ Vue] Portées Vue non trouvées",e);
  7325. }
  7326.  
  7327. infoTab.id = 'infoTab'; // Pour scripts externes
  7328. tbody.id = 'corpsInfoTab';
  7329. tbody.rows[0].cells[0].colSpan = 2;
  7330. td.colSpan = 3;
  7331. td.onmouseover = function() {
  7332. this.style.cursor = 'pointer';
  7333. this.className = 'mh_tdpage';
  7334. };
  7335. td.onmouseout = function() {
  7336. this.className = 'mh_tdtitre';
  7337. };
  7338. td.onclick = function() {
  7339. toggleTableauInfos(false);
  7340. };
  7341. span.id = 'msgInfoTab';
  7342. span.style.display = 'none';
  7343. appendText(
  7344. span,
  7345. ' => Position : X = '+currentPosition[0]+
  7346. ', Y = '+currentPosition[1]+
  7347. ', N = '+currentPosition[2]+
  7348. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  7349. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  7350. true
  7351. );
  7352. td.appendChild(span);
  7353. tr = appendTr(tbody,'mh_tdpage');
  7354. td = appendTdText(tr,'EFFACER : ',true);
  7355. td.align = 'center';
  7356. td.className = 'mh_tdtitre';
  7357. td.width = 100;
  7358. td = appendTdCenter(tr,2);
  7359. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  7360. checkBoxGG = appendCheckBoxSpan(
  7361. td,'delgg',filtreTresors," Les GG'"
  7362. ).firstChild;
  7363. checkBoxCompos = appendCheckBoxSpan(
  7364. td,'delcomp',filtreTresors,' Les Compos'
  7365. ).firstChild;
  7366. checkBoxBidouilles = appendCheckBoxSpan(
  7367. td,'delbid',filtreTresors,' Les Bidouilles'
  7368. ).firstChild;
  7369. checkBoxIntangibles = appendCheckBoxSpan(
  7370. td,'delint',filtreTrolls,' Les Intangibles'
  7371. ).firstChild;
  7372. checkBoxGowaps = appendCheckBoxSpan(
  7373. td,'delgowap',filtreMonstres,' Les Gowaps'
  7374. ).firstChild;
  7375. checkBoxEngages = appendCheckBoxSpan(
  7376. td,'delengage',filtreMonstres,' Les Engagés'
  7377. ).firstChild;
  7378. checkBoxLevels = appendCheckBoxSpan(
  7379. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  7380. ).firstChild;
  7381. checkBoxDiplo = appendCheckBoxSpan(
  7382. td,'delDiplo',refreshDiplo,' La Diplomatie'
  7383. ).firstChild;
  7384. checkBoxTrou = appendCheckBoxSpan(
  7385. td,'deltrou',filtreLieux,' Les Trous'
  7386. ).firstChild;
  7387. checkBoxMythiques = appendCheckBoxSpan(
  7388. td,'delmyth',filtreMonstres,' Les Mythiques'
  7389. ).firstChild;
  7390. if(MY_getValue('NOINFOEM')!='true') {
  7391. checkBoxEM = appendCheckBoxSpan(
  7392. td,'delem',filtreMonstres,' Les Composants EM'
  7393. ).firstChild;
  7394. }
  7395. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  7396. td,'deltres',filtreTresors,' Les Trésors non libres'
  7397. ).firstChild;
  7398. checkBoxTactique = appendCheckBoxSpan(
  7399. td,'deltactique',updateTactique,' Les Infos tactiques'
  7400. ).firstChild;
  7401. if(MY_getValue('INFOPLIE')) {
  7402. toggleTableauInfos(true);
  7403. }
  7404. }
  7405.  
  7406. function toggleTableauInfos(firstRun) {
  7407. var
  7408. msg = document.getElementById('msgInfoTab'),
  7409. corps = document.getElementById('corpsInfoTab'),
  7410. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7411. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  7412. if(!firstRun) {
  7413. infoplie = !infoplie;
  7414. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7415. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  7416. }
  7417. if(infoplie) {
  7418. msg.style.display = '';
  7419. corps.style.display = 'none';
  7420. } else {
  7421. msg.style.display = 'none';
  7422. corps.style.display = '';
  7423. }
  7424. }
  7425.  
  7426. /* [functions] Filtres */
  7427. function prepareFiltrage(ref,width) {
  7428. // = Initialise le filtre 'ref'
  7429. try {
  7430. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  7431. } catch(e) {
  7432. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  7433. return false;
  7434. }
  7435. if(width) { tdTitre.width = width; }
  7436. // Ajout du tr de Filtrage (masqué)
  7437. var tbody = tdTitre.parentNode.parentNode;
  7438. var tr = appendTr(tbody,'mh_tdpage');
  7439. tr.style.display = 'none';
  7440. tr.id = 'trFiltre'+ref;
  7441. var td = appendTd(tr);
  7442. td.colSpan = 5;
  7443. // Ajout du bouton de gestion de Filtrage
  7444. var tdBtn = insertTd(tdTitre.nextSibling);
  7445. tdBtn.id = 'tdInsert'+ref;
  7446. var btn = appendButton(tdBtn,'Filtrer');
  7447. btn.id = 'btnFiltre'+ref;
  7448. btn.onclick = function() {
  7449. debutFiltrage(ref)
  7450. };
  7451. return td;
  7452. }
  7453.  
  7454. function debutFiltrage(ref) {
  7455. // = Handler de début de filtrage (filtre 'ref')
  7456. document.getElementById('trFiltre'+ref).style.display = '';
  7457. var btn = document.getElementById('btnFiltre'+ref);
  7458. btn.value = 'Annuler Filtre';
  7459. btn.onclick = function() {
  7460. finFiltrage(ref);
  7461. };
  7462. }
  7463.  
  7464. function finFiltrage(ref) {
  7465. // = Handler de fin de filtrage (filtre 'ref')
  7466. /* On réassigne le bouton 'Filtrer' */
  7467. document.getElementById('trFiltre'+ref).style.display = 'none';
  7468. var btn = document.getElementById('btnFiltre'+ref);
  7469. btn.value = 'Filtrer';
  7470. btn.onclick = function() {
  7471. debutFiltrage(ref);
  7472. };
  7473. /* Réinitialisation filtres */
  7474. document.getElementById('str'+ref).value = '';
  7475. switch(ref) {
  7476. case 'Monstres':
  7477. document.getElementById('nivMinMonstres').value = 0;
  7478. document.getElementById('nivMaxMonstres').value = 0;
  7479. break;
  7480. case 'Trolls':
  7481. document.getElementById('strGuildes').value = '';
  7482. }
  7483. /* Nettoyage (=lance le filtre) */
  7484. // Ici this = MZ.global = sandBox de travail de MZ
  7485. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  7486. //this['filtre'+ref]();
  7487. switch (ref) {
  7488. case 'Monstres':
  7489. filtreMonstres();
  7490. break;
  7491. case 'Trolls':
  7492. filtreTrolls();
  7493. break;
  7494. case 'Tresors':
  7495. filtreTresors();
  7496. break;
  7497. case 'Lieux':
  7498. filtreLieux();
  7499. break;
  7500. default:
  7501. window.console.log('cas incongru dans finFiltrage : ' + ref);
  7502. break;
  7503. }
  7504. }
  7505.  
  7506. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  7507. var bouton = appendButton(td,nomBouton,onClick);
  7508. appendText(td,'\u00a0');
  7509. var textbox = appendTextbox(td,'text',id,15,30);
  7510. textbox.onkeypress = function(event) {
  7511. try {
  7512. if(event.keyCode==13) {
  7513. event.preventDefault();
  7514. bouton.click();
  7515. }
  7516. }
  7517. catch(e){
  7518. window.alert(e)
  7519. }
  7520. };
  7521. }
  7522.  
  7523. function ajoutFiltreMenu(tr,id,onChange) {
  7524. var select = document.createElement('select');
  7525. select.id = id;
  7526. select.onchange = onChange;
  7527. appendOption(select,0,'Aucun');
  7528. for(var i=1 ; i<=60 ; i++) {
  7529. appendOption(select,i,i);
  7530. }
  7531. tr.appendChild(select);
  7532. return select;
  7533. }
  7534.  
  7535. function ajoutDesFiltres() {
  7536. /* Monstres */
  7537. var td = prepareFiltrage('Monstres',120);
  7538. if(td) {
  7539. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  7540. appendText(td,'\u00a0\u00a0\u00a0');
  7541. appendText(td,'Niveau Min: ');
  7542. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  7543. appendText(td,'\u00a0');
  7544. appendText(td,'Niveau Max: ');
  7545. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  7546. }
  7547. /* Trõlls */
  7548. td = prepareFiltrage('Trolls',50);
  7549. if(td) {
  7550. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  7551. appendText(td,'\u00a0\u00a0\u00a0');
  7552. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  7553. }
  7554. /* Trésors */
  7555. td = prepareFiltrage('Tresors',55);
  7556. if(td) {
  7557. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  7558. }
  7559. /* Lieux */
  7560. td = prepareFiltrage('Lieux',40);
  7561. if(td) {
  7562. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  7563. }
  7564. }
  7565.  
  7566. /* [functions] Bouton d'envoi vers Troogle */
  7567. // WARNING - Nécessite que le Filtre Monstres ait été mis en place
  7568. function envoiVersTroogle() {
  7569. // = 1er Handler bouton Troogle
  7570. try {
  7571. var bouton = document.getElementById('bouton_Troogle');
  7572. } catch(e) {
  7573. window.console.log('Bouton d\'envoi non trouvé.');
  7574. return;
  7575. }
  7576. bouton.onclick = lireInfosTroogle;
  7577. bouton.value = 'Envoi en cours';
  7578. var responses = {}, erreur = false;
  7579. var maxDonnees = Math.max(
  7580. nbMonstres,
  7581. nbTresors,
  7582. nbLieux
  7583. );
  7584. var parLot = 100;
  7585. var lotStop = Math.ceil(maxDonnees/parLot);
  7586. for(var i=0 ; i<lotStop ; i++) {
  7587. var debutLot = parLot*i+1;
  7588. var finLot = parLot*(i+1);
  7589. var data = //'#'+numTroll+
  7590. bddMonstres(debutLot,finLot)+'\n'+
  7591. bddTresors(1,debutLot,finLot)+'\n'+
  7592. bddLieux(debutLot,finLot);
  7593. FF_XMLHttpRequest({
  7594. method: 'POST',
  7595. url: URL_trooglebeta,
  7596. //url: 'http://weblocal/POST_RESULT/index.php',
  7597. headers : {
  7598. 'Content-type': 'application/x-www-form-urlencoded'
  7599. },
  7600. data: 'view='+encodeURIComponent(data), //+'&from='+debutLot,
  7601. lot: i,
  7602. debutLot: debutLot,
  7603. finLot: finLot,
  7604. onload: function(responseDetails) {
  7605. try {
  7606. var resp = responseDetails.responseText;
  7607. responses[this.lot] = 'Envoi des éléments '+this.debutLot+
  7608. ' à '+Math.min(maxDonnees,this.finLot)+' :\n'+resp;
  7609. if(resp.indexOf('succès')==-1) {
  7610. erreur = true;
  7611. }
  7612. } catch(e) {
  7613. console.error(e);
  7614. return;
  7615. }
  7616. var txt = '';
  7617. var fini = true;
  7618. for(var j=0 ; j<lotStop ; j++) {
  7619. if(responses[j]) {
  7620. txt += txt ? '\n'+responses[j] : responses[j];
  7621. } else {
  7622. fini = false;
  7623. }
  7624. }
  7625. bouton.info = txt;
  7626. if(fini) {
  7627. bouton.value = erreur ? 'Erreur' : 'Envoi réussi';
  7628. }
  7629. }
  7630. });
  7631. }
  7632. }
  7633.  
  7634. function lireInfosTroogle() {
  7635. // = 2e Handler bouton Troogle
  7636. try {
  7637. var infos = document.getElementById('bouton_Troogle').info;
  7638. } catch(e) {
  7639. avertissement('[lireInfosTroogle] Bouton Troogle non trouvé');
  7640. window.console.error('[lireInfosTroogle]\n'+e);
  7641. return;
  7642. }
  7643. window.alert(infos);
  7644. }
  7645.  
  7646. function putBoutonTroogle() {
  7647. var td = document.getElementById('tdInsertMonstres');
  7648. td = insertTd(td.nextSibling);
  7649. td.style.fontSize = '0px';
  7650. var bouton = document.createElement('input');
  7651. bouton.type = 'button';
  7652. bouton.id = 'bouton_Troogle';
  7653. bouton.className = 'mh_form_submit';
  7654. bouton.value = 'Envoyer les données vers Troogle';
  7655. bouton.onmouseover = function(){
  7656. this.style.cursor='pointer';
  7657. };
  7658. bouton.onclick = envoiVersTroogle;
  7659. td.appendChild(bouton);
  7660. }
  7661.  
  7662.  
  7663. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  7664.  
  7665. /* [functions] Affichage de la colonne des niveaux */
  7666. function insertLevelColumn() {
  7667. // Déclenché si bascule vers affichage des niveaux des mobs
  7668. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7669. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  7670. td.width = 25;
  7671. for(var i=1 ; i<=nbMonstres ; i++) {
  7672. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7673. td = insertTdText(getMonstreLevelNode(i), '-');
  7674. td.onclick = function() {
  7675. basculeCDM(
  7676. getMonstreNomByTR(this.parentNode),
  7677. getMonstreIDByTR(this.parentNode)
  7678. );
  7679. };
  7680. td.onmouseover = function() {
  7681. this.style.cursor = 'pointer';
  7682. this.className = 'mh_tdtitre';
  7683. };
  7684. td.onmouseout = function() {
  7685. if(this.parentNode.diploActive=='oui') {
  7686. this.className = '';
  7687. } else {
  7688. this.className = 'mh_tdpage';
  7689. }
  7690. };
  7691. td.style = 'font-weight:bold;text-align:center;';
  7692. if(isCDMsRetrieved) {
  7693. // Rappel des niveaux si mémorisés
  7694. td.innerHTML = listeLevels[i];
  7695. }
  7696. }
  7697. }
  7698.  
  7699. function toggleLevelColumn() {
  7700. // = Handler checkBox noLevel
  7701. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  7702. insertLevelColumn();
  7703. if(!isCDMsRetrieved) { retrieveCDMs(); }
  7704. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  7705. for(var i=0 ; i<=nbMonstres ; i++) {
  7706. if(isCDMsRetrieved) {
  7707. // Mémorisation des niveaux pour rappel éventuel
  7708. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  7709. }
  7710. // Suppression du td Niveau
  7711. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  7712. }
  7713. }
  7714. }
  7715.  
  7716. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  7717. function basculeCDM(nom,id) {
  7718. // = Bascule l'affichage des popups CdM
  7719. if(listeCDM[id]) {
  7720. if(!document.getElementById('popupCDM'+id)) {
  7721. afficherCDM(nom, id);
  7722. } else {
  7723. cacherPopupCDM('popupCDM'+id);
  7724. }
  7725. }
  7726. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  7727. }
  7728.  
  7729. function cacherPopupCDM(titre) {
  7730. var popup = document.getElementById(titre);
  7731. popup.parentNode.removeChild(popup);
  7732. }
  7733.  
  7734. /* DEBUG: Section à mettre à jour */
  7735. var selectionFunction;
  7736.  
  7737. function startDrag(evt) {
  7738. winCurr = this.parentNode;
  7739. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  7740. offsetX = evt.pageX - parseInt( winCurr.style.left );
  7741. offsetY = evt.pageY - parseInt( winCurr.style.top );
  7742. selectionFunction = document.body.style.MozUserSelect;
  7743. document.body.style.MozUserSelect = 'none';
  7744. winCurr.style.MozUserSelect = 'none';
  7745. return false;
  7746. }
  7747.  
  7748. function stopDrag(evt) {
  7749. winCurr.style.MozUserSelect = selectionFunction;
  7750. document.body.style.MozUserSelect = selectionFunction;
  7751. winCurr = null;
  7752. }
  7753.  
  7754. function drag(evt) {
  7755. if(winCurr==null) { return; }
  7756. evt = evt || window.event;
  7757. winCurr.style.left = (evt.pageX - offsetX)+'px';
  7758. winCurr.style.top = (evt.pageY - offsetY)+'px';
  7759. return false;
  7760. }
  7761. /* FIN DEBUG */
  7762.  
  7763. function afficherCDM(nom,id) {
  7764. // Crée la table de CdM du mob n° id
  7765. var donneesMonstre = listeCDM[id];
  7766. /* Début création table */
  7767. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  7768. table.id = 'popupCDM'+id;
  7769. table.style =
  7770. 'position:fixed;'+
  7771. 'z-index:1;'+
  7772. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  7773. 'left:'+(window.innerWidth-365)+'px;'+
  7774. 'width:300px;'+
  7775. 'height:200px;';
  7776. /* Ajout du titre avec gestion Drag & Drop */
  7777. var tr = table.firstChild;
  7778. tr.style.cursor = 'move';
  7779. tr.onmousedown = startDrag;
  7780. tr.onmouseup = stopDrag;
  7781. /* Ajout du bouton "Fermer" */
  7782. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  7783. tr.onmouseover = function() {
  7784. this.style.cursor = 'pointer';
  7785. this.className = 'mh_tdpage';
  7786. };
  7787. tr.onmouseout = function() {
  7788. this.className = 'mh_tdtitre';
  7789. };
  7790. tr.idcdm = id;
  7791. tr.onclick = function() {
  7792. cacherPopupCDM('popupCDM'+this.idcdm);
  7793. this.className = 'mh_tdtitre';
  7794. };
  7795. td = appendTdText(tr,'Fermer',true);
  7796. td.colSpan = 2;
  7797. td.style = 'text-align:center;';
  7798. nbCDM++;
  7799. /* Fin création table & Affichage */
  7800. document.body.appendChild(table);
  7801. }
  7802.  
  7803. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  7804. function initPopupVue() {
  7805. popup = document.createElement('div');
  7806. popup.id = 'popup';
  7807. popup.className = 'mh_textbox';
  7808. popup.style =
  7809. 'position: absolute;'+
  7810. 'border: 1px solid #000000;'+
  7811. 'visibility: hidden;'+
  7812. 'display: inline;'+
  7813. 'z-index: 3;'+
  7814. 'max-width: 400px;';
  7815. document.body.appendChild(popup);
  7816. }
  7817.  
  7818. // roule 16/03/2016 supprimé, existe déjà dans vue
  7819. // function showPopupTactique(evt) {
  7820. // var id = this.id;
  7821. // var nom = this.nom;
  7822. // var texte = getAnalyseTactique(id,nom);
  7823. // if(texte=='') { return; }
  7824. // popup.innerHTML = texte;
  7825. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  7826. // popup.style.top = (evt.pageY+15)+'px';
  7827. // popup.style.visibility = 'visible';
  7828. // }
  7829.  
  7830. // roule 16/03/2016, existe déjà ailleurs
  7831. // function hidePopup() {
  7832. // popup.style.visibility = 'hidden';
  7833. // }
  7834.  
  7835. /* [functions] Récupération / Computation des Infos Tactiques */
  7836. // TODO à revoir
  7837. function retireMarquage(nom) {
  7838. var i = nom.indexOf(']');
  7839. switch(i) {
  7840. case -1:
  7841. case nom.length-1:
  7842. return nom;
  7843. default:
  7844. return nom.slice(0,i+1);
  7845. }
  7846. }
  7847.  
  7848. function showPopupError(sHTML) {
  7849. var divpopup = document.createElement('div');
  7850. divpopup.id = 'divpopup';
  7851. divpopup.style =
  7852. 'position: fixed;'+
  7853. 'border: 3px solid #000000;'+
  7854. 'top: 300px;left: 10px;'+
  7855. 'background-color: red;'+
  7856. 'color: white;'+
  7857. 'font-size: xx-large;'+
  7858. 'z-index: 200;';
  7859. divpopup.innerHTML = sHTML;
  7860. var divcroix = document.createElement('div');
  7861. divcroix.style =
  7862. 'position: absolute;'+
  7863. 'top: 0;right: 0;'+
  7864. 'color: inherit;'+
  7865. 'font-size: inherit;'+
  7866. 'cursor: pointer;'+
  7867. 'z-index: 201;';
  7868. divcroix.innerHTML = "X";
  7869. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  7870. document.body.appendChild(divpopup);
  7871. divpopup.appendChild(divcroix);
  7872. }
  7873.  
  7874. function retrieveCDMs() {
  7875. // Récupère les CdM disponibles dans la BDD
  7876. // Lancé uniquement sur toggleLevelColumn
  7877. if(checkBoxLevels.checked) { return; }
  7878. var str = '';
  7879. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  7880. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  7881. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  7882. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  7883. for(var i=1 ; i<=cdmMax ; i++) {
  7884. var nomMonstre = retireMarquage(getMonstreNom(i));
  7885. if(nomMonstre.indexOf(']') != -1) {
  7886. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  7887. }
  7888. // *** WARNING : PROXY RATIBUS ***
  7889. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  7890. str += 'nom[]='+escape(nomMonstre)+'$'+(
  7891. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  7892. )+'&';
  7893. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  7894. FF_XMLHttpRequest({
  7895. method: 'POST',
  7896. url: URL_MZinfoMonstrePost,
  7897. headers : {
  7898. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7899. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7900. 'Content-type':'application/x-www-form-urlencoded'
  7901. },
  7902. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  7903. onload: function(responseDetails) {
  7904. try {
  7905. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  7906. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  7907. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin2 +
  7908. '" target="raistlin">Mountyzilla - https<br />'+
  7909. 'Tu dois accepter le certificat de Raistlin<br />'+
  7910. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  7911. ' « Confirmer l\'exception de sécurité »<br />'+
  7912. '(<i>Ignore ensuite le message au sujet du firewall</i>)');
  7913. return;
  7914. }
  7915. var texte = responseDetails.responseText;
  7916. var lines = texte.split('\n');
  7917. if(lines.length==0) { return; }
  7918. var begin2, end2, index;
  7919. for(var j=0 ; j<lines.length ; j++) {
  7920. var infos = lines[j].split(';');
  7921. if(infos.length<4) { continue; }
  7922. var idMonstre=infos[0];
  7923. var isCDM = infos[1];
  7924. index = parseInt(infos[2]);
  7925. var level = infos[3];
  7926. infos = infos.slice(3);
  7927. if(begin2==null) { begin2 = index; }
  7928. end2 = index;
  7929. listeCDM[idMonstre] = infos;
  7930. if(isCDM==1) {
  7931. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  7932. } else {
  7933. getMonstreLevelNode(index).innerHTML = level;
  7934. }
  7935. }
  7936. computeMission(begin2,end2);
  7937. } catch(e) {
  7938. window.console.error(
  7939. '[retrieveCDMs]\n'+e+'\n'+URL_MZinfoMonstrePost+'\n'+texte
  7940. );
  7941. }
  7942. }
  7943. });
  7944. str = '';
  7945. begin = i+1;
  7946. }
  7947. }
  7948. isCDMsRetrieved=true;
  7949. }
  7950.  
  7951. function computeMission(begin,end) {
  7952. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  7953. computeVLC(begin,end);
  7954. if(!begin) begin=1;
  7955. if(!end) end=nbMonstres;
  7956. var str = MY_getValue(numTroll+'.MISSIONS');
  7957. if(!str) { return; }
  7958. var urlImg = URL_MZimg09+'mission.png';
  7959. var obMissions = JSON.parse(str);
  7960. for(var i=end ; i>=begin ; i--) {
  7961. var mess = '';
  7962. for(var num in obMissions) {
  7963. var mobMission = false;
  7964. switch(obMissions[num].type) {
  7965. case 'Race':
  7966. var race = epure(obMissions[num].race.toLowerCase());
  7967. var nom = epure(getMonstreNom(i).toLowerCase());
  7968. if(nom.indexOf(race)!=-1) {
  7969. mobMission = true;
  7970. }
  7971. break;
  7972. case 'Niveau':
  7973. var donneesMonstre = listeCDM[getMonstreID(i)];
  7974. if(donneesMonstre) {
  7975. var nivMob = Number(donneesMonstre[0]);
  7976. var nivMimi = Number(obMissions[num].niveau),
  7977. mod = obMissions[num].mod;
  7978. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  7979. || (isNaN(mod) && nivMob>=nivMimi)) {
  7980. mobMission = true;
  7981. }
  7982. }
  7983. break;
  7984. case 'Famille':
  7985. var donneesMonstre = listeCDM[getMonstreID(i)];
  7986. if(donneesMonstre) {
  7987. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  7988. var familleMob = epure(donneesMonstre[1].toLowerCase());
  7989. if(familleMob.indexOf(familleMimi)!=-1) {
  7990. mobMission = true;
  7991. }
  7992. }
  7993. break;
  7994. case 'Pouvoir':
  7995. var donneesMonstre = listeCDM[getMonstreID(i)];
  7996. if(donneesMonstre) {
  7997. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  7998. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  7999. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8000. mobMission = true;
  8001. }
  8002. }
  8003. }
  8004. if(mobMission) {
  8005. mess += mess ? '\n\n' : '';
  8006. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8007. }
  8008. }
  8009. if(mess) {
  8010. var td = getMonstreNomNode(i);
  8011. appendText(td,' ');
  8012. td.appendChild(createImage(urlImg,mess));
  8013. }
  8014. }
  8015. }
  8016.  
  8017. function computeVLC(begin,end) {
  8018. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8019. computeTactique(begin,end);
  8020. if(!begin) begin=1;
  8021. if(!end) end=nbMonstres;
  8022. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8023. if(!cache)
  8024. return false;
  8025. var urlImg = URL_MZimg09 + "oeil.png";
  8026. for(var i = end; i >= begin;i--)
  8027. {
  8028. var id = getMonstreID(i);
  8029. var donneesMonstre = listeCDM[id];
  8030. if(donneesMonstre && donneesMonstre.length>12)
  8031. {
  8032. if(donneesMonstre[12]==1)
  8033. {
  8034. var td = getMonstreNomNode(i);
  8035. td.appendChild(document.createTextNode(" "));
  8036. td.appendChild(createImage(urlImg, "Voit le caché"));
  8037. }
  8038. }
  8039. }
  8040. }
  8041.  
  8042. function computeTactique(begin, end) {
  8043. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8044. try {
  8045. if(!begin) begin = 1;
  8046. if(!end) end = nbMonstres;
  8047. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8048. if(noTactique || !isProfilActif()) return;
  8049. for(var j=end ; j>=begin ; j--) {
  8050. var id = getMonstreID(j);
  8051. var nom = getMonstreNom(j);
  8052. var donneesMonstre = listeCDM[id];
  8053. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8054. var td = getMonstreNomNode(j);
  8055. appendText(td,' ');
  8056. td.appendChild(
  8057. createImageTactique(URL_MZimg09+'calc2.png', id, nom)
  8058. );
  8059. }
  8060. }
  8061. }
  8062. catch(e) {
  8063. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8064. }
  8065. filtreMonstres();
  8066. }
  8067.  
  8068. function updateTactique() {
  8069. // = Handler checkBox noTactique
  8070. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8071. if(!isCDMsRetrieved) return;
  8072. if(noTactique) {
  8073. for(var i=nbMonstres ; i>0 ; i--) {
  8074. var tr = getMonstreNomNode(i);
  8075. var img = document.evaluate("img[@src='"+URL_MZimg09+"calc2.png']",
  8076. tr, null, 9, null).singleNodeValue;
  8077. if(img) {
  8078. img.parentNode.removeChild(img.previousSibling);
  8079. img.parentNode.removeChild(img);
  8080. }
  8081. }
  8082. }
  8083. else
  8084. computeTactique();
  8085. }
  8086.  
  8087. function filtreMonstres() {
  8088. // = Handler universel pour les fonctions liées aux monstres
  8089. var urlImg = URL_MZimg09+'Competences/ecritureMagique.png',
  8090. urlEnchantImg = URL_MZimg09+'images/enchant.png';
  8091. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  8092. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  8093. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  8094. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  8095. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  8096. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  8097. // old/new : détermine s'il faut ou non nettoyer les tr
  8098. var oldNOEM = true, noEM = true;
  8099. if(MY_getValue('NOINFOEM')!='true') {
  8100. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  8101. }
  8102. // Filtrage par nom
  8103. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  8104. // Génère la liste des mobs engagés (si filtrés)
  8105. if(noEngages && !isEngagesComputed) {
  8106. for(var i=nbTrolls ; i>0 ; i--) {
  8107. var pos = getTrollPosition(i);
  8108. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  8109. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  8110. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  8111. }
  8112. isEngagesComputed = true;
  8113. }
  8114. /*** FILTRAGE ***/
  8115. /* À computer :
  8116. * - EM (nom suffit)
  8117. * - Enchant (nom suffit)
  8118. * - Mission (nécessite CdM)
  8119. * - mob VlC (nécessite CdM)
  8120. * Sans computation :
  8121. * - Gowap ? engagé ?
  8122. */
  8123. for(var i=nbMonstres ; i>0 ; i--) {
  8124. var pos = getMonstrePosition(i);
  8125. var nom = getMonstreNom(i).toLowerCase();
  8126. if(noEM!=oldNOEM) {
  8127. if(noEM) {
  8128. // Si noEM passe de false à true, on nettoie les td "Nom"
  8129. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  8130. var tr = getMonstreNomNode(i);
  8131. while(tr.childNodes.length>1) {
  8132. tr.removeChild(tr.childNodes[1]);
  8133. }
  8134. } else {
  8135. var tr = getMonstreNomNode(i);
  8136. var TypeMonstre=getEM(nom);
  8137. if(TypeMonstre!='') {
  8138. var infosCompo=compoMobEM(TypeMonstre);
  8139. if(infosCompo.length>0) {
  8140. tr.appendChild(document.createTextNode(' '));
  8141. tr.appendChild(createImage(urlImg, infosCompo));
  8142. }
  8143. }
  8144. }
  8145. }
  8146. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  8147. var texte = getInfoEnchantementFromMonstre(nom);
  8148. if(texte!='') {
  8149. var td = getMonstreNomNode(i);
  8150. td.appendChild(document.createTextNode(' '));
  8151. td.appendChild(createImage(urlEnchantImg, texte));
  8152. }
  8153. }
  8154. tr_monstres[i].style.display = (
  8155. noGowaps &&
  8156. nom.indexOf('gowap apprivoisé')!=-1 &&
  8157. getMonstreDistance(i)>1
  8158. ) || (
  8159. noEngages &&
  8160. getMonstreDistance(i)!=0 &&
  8161. listeEngages[pos[0]] &&
  8162. listeEngages[pos[0]][pos[1]] &&
  8163. listeEngages[pos[0]][pos[1]][pos[2]]
  8164. ) || (
  8165. strMonstre!='' &&
  8166. nom.indexOf(strMonstre)==-1
  8167. ) || (
  8168. nivMin>0 &&
  8169. getMonstreLevel(i)!=-1 &&
  8170. getMonstreLevel(i)<nivMin &&
  8171. getMonstreDistance(i)>1 &&
  8172. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  8173. ) || (
  8174. nivMax>0 &&
  8175. getMonstreLevel(i)>nivMax &&
  8176. getMonstreDistance(i)>1 &&
  8177. nom.toLowerCase().indexOf("kilamo")==-1
  8178. ) ? 'none' : '';
  8179. }
  8180. if(MY_getValue('NOINFOEM')!='true') {
  8181. if(noEM != oldNOEM) {
  8182. if(noEM && isCDMsRetrieved) computeMission();
  8183. }
  8184. oldNOEM = noEM;
  8185. }
  8186. needComputeEnchantement = false;
  8187. }
  8188.  
  8189.  
  8190. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  8191.  
  8192. function filtreTrolls() {
  8193. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  8194. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  8195. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  8196. for(var i=1 ; i<=nbTrolls ; i++) {
  8197. tr_trolls[i].style.display = (
  8198. noIntangibles &&
  8199. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  8200. ) || (
  8201. strTroll!='' &&
  8202. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  8203. ) || (
  8204. strGuilde!='' &&
  8205. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  8206. ) ? 'none' : '';
  8207. }
  8208. }
  8209.  
  8210. /* [functions] Bulle PX Trolls */
  8211. var bulle;
  8212.  
  8213. function initPXTroll() {
  8214. bulle = document.createElement('div');
  8215. bulle.id = 'bulle';
  8216. bulle.className = 'mh_textbox';
  8217. bulle.style =
  8218. 'position: absolute;'+
  8219. 'border: 1px solid #000000;'+
  8220. 'visibility: hidden;'+
  8221. 'display: inline;'+
  8222. 'z-index: 2;';
  8223. document.body.appendChild(bulle);
  8224.  
  8225. for(var i=nbTrolls ; i>0 ; i--) {
  8226. var td_niv = getTrollNivNode(i);
  8227. td_niv.onmouseover = showPXTroll;
  8228. td_niv.onmouseout = hidePXTroll;
  8229. }
  8230. }
  8231.  
  8232. function showPXTroll(evt) {
  8233. var lvl = this.firstChild.nodeValue;
  8234. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  8235. bulle.style.left = evt.pageX+15+'px';
  8236. bulle.style.top = evt.pageY+'px';
  8237. bulle.style.visibility = 'visible';
  8238. }
  8239.  
  8240. function hidePXTroll() {
  8241. bulle.style.visibility = 'hidden';
  8242. }
  8243.  
  8244. /* [functions] Envoi PX / MP */
  8245. function putBoutonPXMP() {
  8246. // Bouton d'initialisation du mode Envoi
  8247. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8248. var td = document.getElementById('tdInsertTrolls');
  8249. if(!td) { return; }
  8250. td.width = 100;
  8251. td = insertTd(td.nextSibling);
  8252. td.style.verticalAlign = 'top';
  8253. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8254. bouton.id = 'btnEnvoi';
  8255. }
  8256.  
  8257. function prepareEnvoi() {
  8258. // = 1er Handler du bouton d'envoi
  8259. /* Ajout de la colonne des CheckBoxes */
  8260. var td = insertTdText(getTrollNomNode(0),'');
  8261. td.width = 5;
  8262. for(var i=nbTrolls ; i>0 ; i--) {
  8263. td = insertTd(getTrollNomNode(i));
  8264. appendCheckBox(td,'envoi'+i);
  8265. }
  8266. /* Ajout du radio de choix PX ou MP */
  8267. var btnEnvoi = document.getElementById('btnEnvoi');
  8268. if(!btnEnvoi) { return; }
  8269. var tdEnvoi = btnEnvoi.parentNode;
  8270. appendText(tdEnvoi,' ');
  8271. var span = document.createElement('span');
  8272. span.style.whiteSpace = 'nowrap';
  8273. var radioElt = document.createElement('input');
  8274. radioElt.type = 'radio';
  8275. radioElt.name = 'envoiPXMP';
  8276. radioElt.id = 'radioPX';
  8277. span.appendChild(radioElt);
  8278. appendText(span,' des PX ');
  8279. radioElt = document.createElement('input');
  8280. radioElt.type = 'radio';
  8281. radioElt.name = 'envoiPXMP';
  8282. radioElt.checked = true;
  8283. span.appendChild(radioElt);
  8284. appendText(span,' un MP');
  8285. tdEnvoi.appendChild(span);
  8286. /* Insertion du bouton Annuler */
  8287. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8288. /* Modification de l'effet du bouton Envoi */
  8289. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8290. }
  8291.  
  8292. function annuleEnvoi() {
  8293. // = Handler bouton Annuler
  8294. /* Nettoyage du td du bouton Envoi */
  8295. var btnEnvoi = document.getElementById('btnEnvoi');
  8296. var tdEnvoi = btnEnvoi.parentNode;
  8297. while(tdEnvoi.firstChild) {
  8298. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8299. }
  8300. /* Retour à l'effet de base du bouton Envoi */
  8301. btnEnvoi.onclick = prepareEnvoi;
  8302. tdEnvoi.appendChild(btnEnvoi);
  8303. /* Suppression CheckBoxes */
  8304. for(var i=nbTrolls ; i>=0 ; i--) {
  8305. var td = getTrollNomNode(i);
  8306. td.parentNode.removeChild(td);
  8307. }
  8308. }
  8309.  
  8310. function effectueEnvoi() {
  8311. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  8312. var str='';
  8313. for(var i=nbTrolls ; i>0 ; i--) {
  8314. var chb = document.getElementById('envoi'+i);
  8315. if(chb.checked) {
  8316. str += (str?',':'')+getTrollID(i);
  8317. }
  8318. }
  8319. var PXchecked = document.getElementById('radioPX').checked;
  8320. if(PXchecked) {
  8321. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  8322. } else {
  8323. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  8324. }
  8325. }
  8326.  
  8327. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  8328.  
  8329. function filtreTresors() {
  8330. // += Handler checkboxes : gg, compos, bidouilles, non libres
  8331. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  8332. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  8333. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  8334. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8335. if(noEngages && !isEngagesComputed) {
  8336. for(var i=nbTrolls ; i>0 ; i--) {
  8337. var pos = getTrollPosition(i);
  8338. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  8339. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  8340. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  8341. }
  8342. isEngagesComputed = true;
  8343. }
  8344. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  8345. for(var i=nbTresors ; i>0 ; i--) {
  8346. var nom = getTresorNom(i);
  8347. var pos = getTresorPosition(i);
  8348. tr_tresors[i].style.display = (
  8349. noGG &&
  8350. nom.indexOf('Gigots de Gob')!=-1
  8351. ) || (
  8352. noCompos &&
  8353. nom.indexOf('Composant')!=-1
  8354. ) || (
  8355. noEngages &&
  8356. listeEngages[pos[2]] &&
  8357. listeEngages[pos[2]][pos[1]] &&
  8358. listeEngages[pos[2]][pos[1]][pos[0]] &&
  8359. getTresorDistance(i)>0
  8360. ) || (
  8361. strTresor!='' &&
  8362. nom.toLowerCase().indexOf(strTresor)==-1
  8363. ) || (
  8364. noBidouilles &&
  8365. nom.indexOf('Bidouille')!=-1
  8366. ) ? 'none' : '';
  8367. }
  8368. }
  8369.  
  8370.  
  8371. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  8372.  
  8373. function filtreLieux() {
  8374. // += Handler checkbox trous
  8375. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  8376. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  8377. for(var i=nbLieux ; i>0 ; i--) {
  8378. tr_lieux[i].style.display = (
  8379. strLieu &&
  8380. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  8381. ) || (
  8382. noTrou &&
  8383. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  8384. getLieuDistance(i)>1
  8385. ) ? 'none' : '';
  8386. }
  8387. }
  8388.  
  8389.  
  8390. /*-[functions]-------------------- Diplomatie --------------------------------*/
  8391.  
  8392. function refreshDiplo() {
  8393. MY_setValue(numTroll+'.diplo.off',
  8394. checkBoxDiplo.checked?'true':'false'
  8395. );
  8396. if(isDiploRaw) { computeDiplo(); }
  8397. appliqueDiplo();
  8398. }
  8399.  
  8400. function computeDiplo() {
  8401. // On extrait les données de couleur et on les stocke par id
  8402. // Ordre de préséance :
  8403. // source Guilde < source Perso
  8404. // guilde cible < troll cible
  8405. /* Diplo de Guilde */
  8406. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  8407. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  8408. if(diploGuilde && diploGuilde.isOn=='true') {
  8409. // Guilde perso
  8410. if(diploGuilde.guilde) {
  8411. Diplo.Guilde[diploGuilde.guilde.id] = {
  8412. couleur: diploGuilde.guilde.couleur,
  8413. titre: 'Ma Guilde'
  8414. };
  8415. }
  8416. // Guildes/Trolls A/E
  8417. for(var AE in {Amis:0,Ennemis:0}) {
  8418. for(var i=0 ; i<5 ; i++) {
  8419. if(diploGuilde[AE+i]) {
  8420. for(var type in {Guilde:0,Troll:0}) {
  8421. var liste = diploGuilde[AE+i][type].split(';');
  8422. for(var j=liste.length-2 ; j>=0 ; j--) {
  8423. Diplo[type][liste[j]] = {
  8424. couleur: diploGuilde[AE+i].couleur,
  8425. titre: diploGuilde[AE+i].titre
  8426. };
  8427. }
  8428. }
  8429. }
  8430. }
  8431. }
  8432. }
  8433. /* Diplo Perso */
  8434. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  8435. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  8436. if(diploPerso && diploPerso.isOn=='true') {
  8437. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8438. for(var id in diploPerso[type]) {
  8439. Diplo[type][id] = diploPerso[type][id];
  8440. }
  8441. }
  8442. }
  8443. if(diploPerso.mythiques) {
  8444. Diplo.mythiques = diploPerso.mythiques;
  8445. }
  8446. isDiploRaw = false;
  8447. }
  8448.  
  8449. function appliqueDiplo() {
  8450. var aAppliquer = Diplo;
  8451. if(checkBoxDiplo.checked) {
  8452. // Pour retour à l'affichage basique sur désactivation de la diplo
  8453. aAppliquer = {
  8454. Guilde: {},
  8455. Troll: {},
  8456. Monstre: {}
  8457. };
  8458. }
  8459. /* On applique "aAppliquer" */
  8460. // Diplo Trõlls
  8461. for(var i=nbTrolls ; i>0 ; i--) {
  8462. var idG = getTrollGuildeID(i);
  8463. var idT = getTrollID(i);
  8464. var tr = tr_trolls[i];
  8465. if(aAppliquer.Troll[idT]) {
  8466. tr.className = '';
  8467. var descr = aAppliquer.Troll[idT].titre;
  8468. if(descr) {
  8469. getTrollNomNode(i).title = descr
  8470. }
  8471. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  8472. } else if(aAppliquer.Guilde[idG]) {
  8473. tr.className = '';
  8474. var descr = aAppliquer.Guilde[idG].titre;
  8475. if(descr) {
  8476. getTrollNomNode(i).title = descr
  8477. }
  8478. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  8479. } else {
  8480. tr.className = 'mh_tdpage';
  8481. getTrollNomNode(i).title = '';
  8482. }
  8483. }
  8484. // Diplo Monstres
  8485. for(var i=nbMonstres ; i>0 ; i--) {
  8486. var id = getMonstreID(i);
  8487. var nom = getMonstreNom(i).toLowerCase();
  8488. if(aAppliquer.Monstre[id]) {
  8489. tr_monstres[i].className = '';
  8490. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  8491. tr_monstres[i].diploActive = 'oui';
  8492. var descr = aAppliquer.Monstre[id].titre;
  8493. if(descr) {
  8494. getMonstreNomNode(i).title = descr;
  8495. }
  8496. } else if(aAppliquer.mythiques &&
  8497. (nom.indexOf('liche')==0 ||
  8498. nom.indexOf('hydre')==0 ||
  8499. nom.indexOf('balrog')==0 ||
  8500. nom.indexOf('beholder')==0)) {
  8501. tr_monstres[i].className = '';
  8502. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  8503. tr_monstres[i].diploActive = 'oui';
  8504. getMonstreNomNode(i).title = 'Monstre Mythique';
  8505. } else {
  8506. tr_monstres[i].className = 'mh_tdpage';
  8507. tr_monstres[i].diploActive = '';
  8508. }
  8509. }
  8510. }
  8511.  
  8512.  
  8513. /*-[functions]---------------- Actions à distance ----------------------------*/
  8514.  
  8515. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  8516. var monN = parseInt(getPosition()[2]);
  8517. for(var type in keltypes) {
  8518. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  8519. for(var i=this['nb'+type] ; i>0 ; i--) {
  8520. var tr = this['tr_'+type.toLowerCase()][i];
  8521. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  8522. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  8523. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  8524. var sonN = getXxxPosition(type, i)[2];
  8525. var d = getXxxDistance(type, i);
  8526. if(sonN==monN && d>=dmin && d<=dmax) {
  8527. var iconeAction = document.evaluate(
  8528. "./descendant::img[@alt='"+alt+"']",
  8529. tr, null, 9, null
  8530. ).singleNodeValue;
  8531. if(iconeAction) {
  8532. if(iconeAction.title) {
  8533. iconeAction.title += "\n"+message;
  8534. } else {
  8535. iconeAction.title = message;
  8536. }
  8537. iconeAction.src = urlIcon;
  8538. } else {
  8539. var tdAction = tr.getElementsByTagName('td')[1];
  8540. var icon = document.createElement('img');
  8541. icon.src = urlIcon;
  8542. icon.height = 20;
  8543. icon.alt = alt;
  8544. icon.title = message;
  8545. tdAction.appendChild(icon);
  8546. }
  8547. }
  8548. }
  8549. }
  8550. }
  8551.  
  8552. function computeCharge() {
  8553. computeActionDistante(1,
  8554. getPortee__Vue(
  8555. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  8556. MY_getValue(numTroll+".caracs.regeneration")
  8557. ),
  8558. {'Monstres':1, 'Trolls':1},
  8559. 'Attaquer',
  8560. MHicons+'E_Metal09.png',
  8561. 'Cible à portée de Charge'
  8562. );
  8563. }
  8564.  
  8565. function computeProjo() {
  8566. computeActionDistante(0,
  8567. getPortee__Vue(
  8568. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8569. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8570. ),
  8571. {'Monstres':1, 'Trolls':1},
  8572. 'Attaquer',
  8573. MHicons+'S_Fire05.png',
  8574. 'Cible à portée de Projo'
  8575. );
  8576. }
  8577.  
  8578. function computeTelek() {
  8579. computeActionDistante(0,
  8580. Math.floor((
  8581. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8582. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8583. )/2),
  8584. {'Tresors':1},
  8585. 'Telek',
  8586. MHicons+'S_Magic04.png',
  8587. 'Trésor à portée de Télékinésie'
  8588. );
  8589. }
  8590.  
  8591. function computeLdP() {
  8592. computeActionDistante(0,
  8593. 2+Math.floor((
  8594. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8595. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8596. )/5),
  8597. {'Monstres':1, 'Trolls':1},
  8598. 'self',
  8599. MHicons+'P_Red01.png',
  8600. 'Cible à portée de Lancer de Potions'
  8601. );
  8602. }
  8603.  
  8604.  
  8605. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  8606.  
  8607. function putScriptExterne() {
  8608. var infoit = MY_getValue(numTroll+'.INFOSIT');
  8609. if(!infoit || infoit=='') return;
  8610.  
  8611. var nomit = infoit.slice(0,infoit.indexOf('$'));
  8612. if(nomit=='bricol') {
  8613. var data = infoit.split('$');
  8614. try {
  8615. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  8616. // appendNewScript(URL_ratibus_lien+data[1]
  8617. // +'/mz.php?login='+data[2]
  8618. // +'&password='+data[3]
  8619. // );
  8620. FF_XMLHttpRequest({
  8621. method: 'GET',
  8622. url: URL_ratibus_lien+data[1]
  8623. +'/mz_json.php?login='+data[2]
  8624. +'&password='+data[3],
  8625. onload: function(responseDetails) {
  8626. try {
  8627. if (responseDetails.status == 0) {
  8628. if (isHTTPS) {
  8629. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  8630. } else {
  8631. window.console.log('status=0 à l\'appel bricol\'troll ' + e);
  8632. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  8633. }
  8634. return;
  8635. }
  8636. var ratibusData;
  8637. try {
  8638. ratibusData = JSON.parse(responseDetails.responseText);
  8639. } catch(e) {}
  8640. if (ratibusData === undefined) {
  8641. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  8642. return;
  8643. }
  8644. if (ratibusData.error) {
  8645. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  8646. } else {
  8647. putInfosTrolls(ratibusData.data.trolls);
  8648. }
  8649. } catch(e) {
  8650. window.console.log('exception retour bricol\'troll ' + e);
  8651. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  8652. }
  8653. }
  8654. });
  8655. } catch(e) {
  8656. if (isHTTPS) {
  8657. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  8658. } else {
  8659. window.console.log('exception appel bricol\'troll ' + e);
  8660. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  8661. }
  8662. }
  8663. }
  8664. }
  8665.  
  8666. /* Le script mz.php de Ratibus renvoie :
  8667. + infosTrolls = new Array();
  8668. + infosTrolls[numdutroll] =
  8669. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  8670. + etc ...
  8671. + putInfosTrolls();
  8672. *
  8673. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  8674. * Roule 07/11/2016, on utilise mz_json qui envoie
  8675. {
  8676. "data": {
  8677. "trolls": {
  8678. "59424": {
  8679. "id": 59424,
  8680. "pv": xx,
  8681. "pv_max": xx,
  8682. "updated_at": "2016-10-31 07:28:40",
  8683. "dla": "2016-10-05 07:28:04",
  8684. "pa": 0
  8685. },
  8686. }
  8687. }
  8688. }
  8689. */
  8690.  
  8691. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  8692. function corrigeBricolTrolls(infosTrolls) {
  8693. for(var i in infosTrolls) {
  8694. var pv = infosTrolls[i][0];
  8695. var pvmax = infosTrolls[i][1];
  8696. var pvmem = MY_getValue(i+'.caracs.pv.max');
  8697. if(pvmem && pvmem>pvmax) {
  8698. infosTrolls[i][1] = pvmem;
  8699. pvmax = pvmem;
  8700. }
  8701. if(pv>pvmax) {
  8702. var newpvmax = 5*Math.ceil(pv/5);
  8703. MY_setValue(i+'.caracs.pv.max',newpvmax);
  8704. infosTrolls[i][1] = newpvmax;
  8705. }
  8706. }
  8707. }
  8708.  
  8709. // insère 2 TD avant nextTD avec les infos venant de l'IT
  8710. function addTdInfosTroll(infos, nextTD) {
  8711. /* cadre barre PV */
  8712. var tab = document.createElement('div');
  8713. tab.width = 100;
  8714. tab.style.background = '#FFFFFF';
  8715. tab.style.width = 100;
  8716. tab.style.border = 1;
  8717. tab.height = 10;
  8718. tab.title = infos.pv+'/'+infos.pv_max+' le '+ infos.updated_at.replace(' ', ' à '); //infos[0]+'/'+infos[1]+' '+ infos[2];
  8719. /* barre PV */
  8720. var img = document.createElement('img');
  8721. img.src = '../Images/Interface/milieu.gif';
  8722. img.height = 10;
  8723. img.width = Math.floor( (100*infos.pv)/infos.pv_max ); //infos[0])/infos[1] );
  8724. tab.appendChild(img);
  8725. /* lien vers l'IT */
  8726. var lien = document.createElement('a');
  8727. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  8728. lien.href = URL_ratibus_lien+nomit+'/index.php';
  8729. lien.target = '_blank';
  8730. lien.appendChild(tab);
  8731. insertTdElement(nextTD,lien);
  8732. /* PAs dispos */
  8733. var span = document.createElement('span');
  8734. span.title = 'DLA : ' + infos.dla; //infos[3];
  8735. appendText(span, infos.pa +' PA' ); //infos[4]+' PA' );
  8736. insertTdElement(nextTD, span);
  8737. }
  8738.  
  8739. function putInfosTrolls(infosTrolls) {
  8740. // teste la présence de trõlls de l'IT
  8741. var i=nbTrolls;
  8742. while( i>0 && !infosTrolls[getTrollID(i)] ) i--;
  8743. if(i==0) return;
  8744. try {
  8745. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  8746. td.width = 40;
  8747. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  8748. td.width = 105;
  8749.  
  8750. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  8751. //corrigeBricolTrolls(infosTrolls);
  8752. for(i=nbTrolls ; i>0 ; i--) {
  8753. var infos = infosTrolls[getTrollID(i)];
  8754. if(infos) {
  8755. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  8756. infos.done = true;
  8757. } else {
  8758. insertTd(tr_trolls[i].childNodes[6]);
  8759. insertTd(tr_trolls[i].childNodes[6]);
  8760. }
  8761. }
  8762. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  8763. var str = MY_getValue(numTroll+'.INFOSIT');
  8764. if(!str) return;
  8765. var arr = str.split('$');
  8766. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  8767.  
  8768. var IDs = Object.keys(infosTrolls);
  8769. //window.console.log('nb Troll IT : ' + IDs.length);
  8770. var tBody = tr_trolls[1].parentNode;
  8771. var pos = getPosition();
  8772. for (i = 0; i < IDs.length; i++) {
  8773. var idTroll = IDs[i];
  8774. infos = infosTrolls[idTroll];
  8775. if (infos.done) continue; // déjà vu
  8776. if (idTroll == numTroll) continue; // pas nous-même
  8777. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  8778. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  8779. // trouver où insérer ce Troll
  8780. var next = undefined;
  8781. for(var j=0 ; j<tr_trolls.length ; j++) {
  8782. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  8783. if (thisDist > distance) {
  8784. next = tr_trolls[j]
  8785. break;
  8786. }
  8787. }
  8788. var tr;
  8789. if (next === undefined) {
  8790. tr = appendTr(tBody,'mh_tdpage');
  8791. } else {
  8792. tr = insertTr(next,'mh_tdpage')
  8793. }
  8794. var td = appendTd(tr); // distance
  8795. appendText(td, distance);
  8796. td = appendTd(tr); // actions
  8797. td = appendTd(tr); // ID
  8798. appendText(td, idTroll);
  8799. td = appendTd(tr); // Nom
  8800. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  8801. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  8802. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  8803. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  8804. td = appendTd(tr); // Niveau
  8805. if (infos.niveau) appendText(td, infos.niveau);
  8806. td.align = 'center';
  8807. td = appendTd(tr); // Race
  8808. if (infos.race) appendText(td, infos.race);
  8809. // PV et PA ajoutés par addTdInfosTroll
  8810. td = appendTd(tr); // Guilde
  8811. if (infos.guilde) appendText(td, infos.guilde);
  8812. td = appendTd(tr); // X
  8813. td.align = 'center';
  8814. if (infos.x) appendText(td, infos.x);
  8815. td = appendTd(tr); // Y
  8816. td.align = 'center';
  8817. if (infos.y) appendText(td, infos.y);
  8818. td = appendTd(tr); // N
  8819. td.align = 'center';
  8820. if (infos.n) appendText(td, infos.n);
  8821. addTdInfosTroll(infos, tr.childNodes[6]);
  8822. }
  8823. } catch(e) {
  8824. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  8825. }
  8826. }
  8827.  
  8828.  
  8829. /* Mode Tétalanvert! ---------------------------------------------------------*/
  8830.  
  8831. function calculeDistance(maPos,posArr) {
  8832. return Math.max(
  8833. Math.abs(maPos[0]-posArr[0]),
  8834. Math.abs(maPos[1]-posArr[1]),
  8835. Math.abs(maPos[2]-posArr[2])
  8836. );
  8837. }
  8838.  
  8839. function inversionCoord() {
  8840. var maPos = getPosition();
  8841. var listeOffsets = {
  8842. 'monstres':checkBoxLevels.checked?4:3,
  8843. 'trolls':6,
  8844. };
  8845. for(var type in listeOffsets) {
  8846. var trList = this['tr_'+type];
  8847. var offset = listeOffsets[type];
  8848. for(var i=trList.length-1 ; i>0 ; i--) {
  8849. var oldX = parseInt(trList[i].cells[offset].textContent);
  8850. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  8851. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  8852. trList[i].cells[offset].innerHTML = oldY;
  8853. trList[i].cells[offset+1].innerHTML = oldX;
  8854. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  8855. }
  8856. }
  8857. }
  8858.  
  8859.  
  8860. /* Partie principale */
  8861. function do_vue() {
  8862. for(var type in typesAFetcher) {
  8863. fetchData(type);
  8864. }
  8865.  
  8866. // roule' 11/03/2016
  8867. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  8868. // je fais une recopie :(
  8869. tr_monstres = this['tr_monstres'];
  8870. tr_trolls = this['tr_trolls'];
  8871. tr_tresors = this['tr_tresors'];
  8872. tr_champignons = this['tr_champignons'];
  8873. tr_lieux = this['tr_lieux'];
  8874.  
  8875. nbMonstres = this['nbMonstres'];
  8876. nbTrolls = this['nbTrolls'];
  8877. nbTresors = this['nbTresors'];
  8878. nbChampignons = this['nbChampignons'];
  8879. nbLieux = this['nbLieux'];
  8880.  
  8881. try {
  8882. start_script(31);
  8883. initialiseInfos();
  8884. savePosition();
  8885.  
  8886. // Fonctionnalité "Têtalenvert" cachée, en test :
  8887. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  8888. inversionCoord();
  8889. }
  8890. ajoutDesFiltres();
  8891. set2DViewSystem();
  8892. //putBoutonTroogle();
  8893. putBoutonPXMP();
  8894. synchroniseFiltres();
  8895. toggleLevelColumn();
  8896.  
  8897. refreshDiplo();
  8898. //400 ms
  8899. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  8900. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  8901. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  8902. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  8903. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  8904. var noTresorsEngages =
  8905. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  8906. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  8907. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  8908. filtreMonstres();
  8909. if(noIntangibles) {
  8910. filtreTrolls();
  8911. }
  8912. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  8913. filtreTresors();
  8914. }
  8915. if(noTrou) {
  8916. filtreLieux();
  8917. }
  8918.  
  8919. initPopupVue();
  8920. initPXTroll();
  8921.  
  8922. if(getTalent("Projectile Magique")!=0) {
  8923. computeProjo();
  8924. }
  8925. if(getTalent("Charger")!=0) {
  8926. computeCharge();
  8927. }
  8928. if(getTalent("Télékinésie")!=0) {
  8929. computeTelek();
  8930. }
  8931. if(getTalent("Lancer de Potions")!=0) {
  8932. computeLdP();
  8933. }
  8934. putScriptExterne();
  8935. displayScriptTime();
  8936. } catch(e) {
  8937. avertissement("[MZ] Une erreur s'est produite.");
  8938. window.console.error("[MZ] Erreur générale Vue",e);
  8939. }
  8940. }
  8941.  
  8942.  
  8943.  
  8944. /*******************************************************************************
  8945. * This file is part of Mountyzilla. *
  8946. * *
  8947. * Mountyzilla is free software; you can redistribute it and/or modify *
  8948. * it under the terms of the GNU General Public License as published by *
  8949. * the Free Software Foundation; either version 2 of the License, or *
  8950. * (at your option) any later version. *
  8951. * *
  8952. * Mountyzilla is distributed in the hope that it will be useful, *
  8953. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  8954. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  8955. * GNU General Public License for more details. *
  8956. * *
  8957. * You should have received a copy of the GNU General Public License *
  8958. * along with Mountyzilla; if not, write to the Free Software *
  8959. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  8960. *******************************************************************************/
  8961.  
  8962. // x~x profil2
  8963.  
  8964. /*---------------------------- Variables globales ----------------------------*/
  8965.  
  8966. var
  8967. // Anatrolliseur
  8968. urlAnatrolliseur,
  8969. // Infobulles talents
  8970. hauteur = 50, bulleStyle = null,
  8971. // Caracteristiques
  8972. // Infos troll
  8973. race, niv, idtroll, datecrea,
  8974. idguilde, nomguilde,
  8975. // Etats du troll
  8976. fatigue, bmfatigue,
  8977.  
  8978. // Experience, Pi, ...
  8979. pxdistribuables, pxperso,
  8980. piutilisable, pitotal,
  8981. nbmeurtres, nbmorts,
  8982. // utilisee pour les moyennes MM/jour, kill/jour, etc
  8983. NBjours,
  8984. // calcul des DLA suivantes
  8985. DLA, DLAsuiv, HeureServeur,
  8986. // details duree du tour (calcul pvdispo) :
  8987. dtb, pdm, bmt, adb, dpt,
  8988. //posale
  8989. posX, posY, posN,
  8990. // caracs physiques
  8991. vue, vuebp, vuebm, vuetotale,
  8992. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  8993. reg, regbp, regbm, regmoy,
  8994. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  8995. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  8996. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  8997. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  8998. rm, rmbp, rmbm, rmtotale,
  8999. mm, mmbp, mmbm, mmtotale,
  9000.  
  9001. // Variables speciales Kastars
  9002. pvActuelKastar, minParPV, overDLA,
  9003. // id pour edition manuelle de lastDLA :
  9004. inJour, inMois, inAn, inHr, inMin, inSec,
  9005. // id pour auto-refresh lastDLA :
  9006. lastDLAZone, maxAMZone, cumulZone,
  9007. lastDLA, DLAaccel;
  9008.  
  9009.  
  9010. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9011.  
  9012. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  9013. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  9014. function getUniqueValueBySelector(selector, defaultValue){
  9015. var valNode = document.querySelector(selector);
  9016. if(valNode!=null){
  9017. if(valNode.hasChildNodes()) {
  9018. return valNode.childNodes[0].nodeValue;
  9019. }else{
  9020. return defaultValue;
  9021. }
  9022. } else{
  9023. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  9024. return defaultValue;
  9025. }
  9026. }
  9027. function getUniqueStringValueBySelector(selector){
  9028. return getUniqueValueBySelector(selector,"");
  9029. }
  9030. function getUniqueIntValueBySelector(selector){
  9031. var ret = getUniqueValueBySelector(selector,0);
  9032. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9033. ret = 0;
  9034. }
  9035. return parseInt(ret);
  9036. }
  9037. function getUniqueFloatValueBySelector(selector){
  9038. var ret = getUniqueValueBySelector(selector,0.0);
  9039. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9040. ret = 0.0;
  9041. }
  9042. return parseFloat(ret);
  9043. }
  9044.  
  9045.  
  9046. function resiste(Ddeg,bm) {
  9047. // version naive mais compréhensible ^^
  9048. // DEBUG: à revoir
  9049. if(!bm) {
  9050. return 2*Math.floor(Ddeg/2);
  9051. }
  9052. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  9053. }
  9054.  
  9055. function retourAZero(fatig) {
  9056. var fat = fatig, raz = 0;
  9057. while(fat>0) {
  9058. raz++;
  9059. fat = Math.floor(fat/1.25);
  9060. }
  9061. return raz;
  9062. }
  9063.  
  9064. function decumulPumPrem(bonus) {
  9065. switch(bonus) {
  9066. case 20: return 33;
  9067. case 33: return 41;
  9068. case 41: return 46;
  9069. case 46: return 49;
  9070. case 49: return 51;
  9071. default: return 20;
  9072. }
  9073. }
  9074.  
  9075. function coefDecumul(i) {
  9076. switch(i) {
  9077. case 2: return 0.67;
  9078. case 3: return 0.4;
  9079. case 4: return 0.25;
  9080. case 5: return 0.15;
  9081. default: return 0.1;
  9082. }
  9083. }
  9084.  
  9085. function dureeHM(dmin) {
  9086. var ret = "";
  9087. dmin = Math.floor(dmin);
  9088. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  9089. var mins = dmin%60;
  9090. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  9091. return (ret) ? ret : "-";
  9092. }
  9093.  
  9094.  
  9095. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  9096.  
  9097. function extractionDonnees() {
  9098. // Variables temporaires
  9099. var Nbrs = {};
  9100.  
  9101. // *********************
  9102. // Cadre "Description"
  9103. // *********************
  9104. race = getUniqueStringValueBySelector('#descr #race');
  9105. debugMZ("Race : " + race);
  9106. idtroll = getUniqueStringValueBySelector('#descr #id');
  9107. debugMZ("Id troll : " + idtroll);
  9108. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  9109. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  9110. datecrea = new Date(StringToDate(strDateCrea));
  9111. debugMZ("Date creation : " + datecrea);
  9112. // Guilde
  9113. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  9114. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  9115. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  9116.  
  9117. // *******************
  9118. // Cadre "Experience"
  9119. // *******************
  9120. // Niveau de troll
  9121. niv = getUniqueIntValueBySelector('#exp #niv');
  9122. nivTroll = niv;
  9123. debugMZ("Niveau : " + niv);
  9124. // PX
  9125. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  9126. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  9127. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  9128. // PI
  9129. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  9130. pitotal = parseInt(document.querySelector('#exp #pi').parentElement.nextElementSibling.childNodes[2].textContent);
  9131. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  9132. // Meutres/Morts
  9133. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  9134. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  9135. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  9136.  
  9137. // *********************
  9138. // Cadre "Tour de Jeu"
  9139. // *********************
  9140. // DLA
  9141. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  9142. DLA = new Date(StringToDate(Nbrs["dla"]));
  9143. debugMZ("DLA: " + DLA);
  9144. // DLA suivante
  9145. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  9146. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  9147. debugMZ("DLAsuiv: " + DLAsuiv);
  9148. // Duree normale de mon Tour
  9149. Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  9150. dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  9151. debugMZ("Duree normale de mon Tour : " + dtb);
  9152. // Bonus/Malus sur la duree
  9153. Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  9154. bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  9155. debugMZ("Bonus/Malus sur la duree : " + bmt);
  9156. // Augmentation due aux blessures
  9157. Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  9158. adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  9159. debugMZ("Augmentation due aux blessures : " + adb);
  9160. // Poids de l'equipement
  9161. Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  9162. pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  9163. debugMZ("Poids de l'equipement : " + pdm);
  9164. // Duree de mon prochain Tour
  9165. Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  9166. dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  9167. debugMZ('Duree de mon prochain Tour : ' + dpt);
  9168.  
  9169. // ****************
  9170. // Cadre "Etats"
  9171. // ****************
  9172. // Position du troll :
  9173. posX = getUniqueIntValueBySelector('#pos #x');
  9174. posY = getUniqueIntValueBySelector('#pos #y');
  9175. posN = getUniqueIntValueBySelector('#pos #n');
  9176. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  9177. // PV actuel
  9178. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  9179. pvActuelKastar = pvcourant;
  9180. debugMZ("PV actuel : " + pvcourant)
  9181. // Fatigue
  9182. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  9183. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  9184. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  9185.  
  9186. // **************************
  9187. // Cadre "Caracteristiques"
  9188. // **************************
  9189. // Attaque
  9190. att = getUniqueIntValueBySelector('#carac #att');
  9191. attbp = getUniqueIntValueBySelector('#carac #att_p');
  9192. attbm = getUniqueIntValueBySelector('#carac #att_m');
  9193. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  9194. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  9195. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  9196. attmoy = 3.5*att + attbp + attbm;
  9197. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9198. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  9199. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  9200. // Esquive
  9201. esq = getUniqueIntValueBySelector('#carac #esq');
  9202. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  9203. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  9204. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  9205. esqmoy = 3.5*esq + esqbp+esqbm;
  9206. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  9207. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  9208. // Degat
  9209. deg = getUniqueIntValueBySelector('#carac #deg');
  9210. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  9211. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  9212. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  9213. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  9214. degmoy = 2*deg + degbp+degbm;
  9215. degmoycrit = 3*deg + degbp+degbm;
  9216. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9217. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  9218. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  9219. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  9220. // PV
  9221. pvbase = getUniqueIntValueBySelector('#carac #pv');
  9222. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  9223. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  9224. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  9225. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  9226. // Regeneration
  9227. reg = getUniqueIntValueBySelector('#carac #reg');
  9228. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  9229. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  9230. regmoy = 2 * reg + regbp + regbm; // D3
  9231. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  9232. // Armure
  9233. arm = getUniqueIntValueBySelector('#carac #arm');
  9234. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  9235. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  9236. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  9237. armmoy = 2*arm + armbp+armbm;
  9238. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  9239. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  9240. // TODO : D d'armure non active
  9241. // Vue
  9242. vue = getUniqueIntValueBySelector('#carac #vue');
  9243. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  9244. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  9245. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  9246. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  9247. // RM
  9248. rm = getUniqueIntValueBySelector('#carac #rm');
  9249. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  9250. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  9251. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  9252. rmTroll = rmtotale;
  9253. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  9254. // MM
  9255. mm = getUniqueIntValueBySelector('#carac #mm');
  9256. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  9257. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  9258. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  9259. mmTroll = mmtotale;
  9260. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  9261.  
  9262. // Heure Serveur
  9263. try {
  9264. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  9265. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  9266. HeureServeur = new Date(StringToDate(heureServeurSTR));
  9267. } catch (e) {
  9268. window.console.warn(
  9269. "[MZ] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  9270. );
  9271. HeureServeur = new Date();
  9272. }
  9273. debugMZ("HeureServeur: " + HeureServeur);
  9274.  
  9275. // ***INIT GLOBALE*** NBjours
  9276. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  9277.  
  9278. // Calcul debut lien anatroliseur avec les caracteristiques connues
  9279. var amelio_dtb = function(dtb) {
  9280. if(dtb>555) {
  9281. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  9282. }
  9283. return 10+Math.ceil((555-dtb)/2.5);
  9284. },
  9285. amelio_pv = Math.floor(pvbase/10)-3,
  9286. amelio_vue = vue-3,
  9287. amelio_att = att-3,
  9288. amelio_esq = esq-3,
  9289. amelio_deg = deg-3,
  9290. amelio_reg = reg-1,
  9291. amelio_arm = arm-1;
  9292. if(race==="Darkling"){amelio_reg--; }
  9293. if(race==="Durakuir"){amelio_pv-- ; }
  9294. if(race==="Kastar") {amelio_deg--; }
  9295. if(race==="Skrim") {amelio_att--; }
  9296. if(race==="Tomawak") {amelio_vue--; }
  9297.  
  9298. urlAnatrolliseur = URL_AnatrolDispas
  9299. +"outils_anatrolliseur.php?anatrolliseur=v8"
  9300. +"|r="+race.toLowerCase()
  9301. +"|dla="+amelio_dtb(dtb)
  9302. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  9303. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  9304. +"|att="+amelio_att+","+attbp+","+attbm
  9305. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  9306. +"|deg="+amelio_deg+","+degbp+","+degbm
  9307. +"|reg="+amelio_reg+","+regbp+","+regbm
  9308. +"|arm="+amelio_arm+","+armbp+","+armbm
  9309. +"|mm="+mmtotale
  9310. +"|rm="+rmtotale+"|";
  9311. }
  9312.  
  9313. function saveProfil() {
  9314. MY_setValue(idtroll+'.caracs.attaque',att);
  9315. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  9316. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  9317. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  9318. if(atttourD||atttourP||atttourM) {
  9319. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9320. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  9321. }
  9322. MY_setValue(idtroll+'.caracs.esquive',esq);
  9323. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  9324. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  9325. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  9326. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  9327. MY_setValue(idtroll+'.caracs.degats',deg);
  9328. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  9329. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  9330. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  9331. if(degtourP||degtourM){
  9332. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9333. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  9334. }
  9335. MY_setValue(idtroll+'.caracs.regeneration',reg);
  9336. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  9337. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  9338. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  9339. MY_setValue(idtroll+'.caracs.vue',vue);
  9340. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  9341. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  9342. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  9343. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  9344. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  9345. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  9346. MY_setValue(idtroll+'.caracs.rm',rm);
  9347. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  9348. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  9349. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  9350. MY_setValue(idtroll+'.caracs.mm',mm);
  9351. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  9352. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  9353. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  9354. MY_setValue(idtroll+'.caracs.armure',arm);
  9355. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  9356. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  9357. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  9358. MY_setValue(idtroll+'.position.X',posX);
  9359. MY_setValue(idtroll+'.position.Y',posY);
  9360. MY_setValue(idtroll+'.position.N',posN);
  9361. MY_setValue(idtroll+'.race',race);
  9362. MY_setValue(idtroll+'.niveau',niv);
  9363. MY_setValue(idtroll+'.idguilde',idguilde);
  9364. MY_setValue(idtroll+'.nomguilde',nomguilde);
  9365. }
  9366.  
  9367.  
  9368. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  9369.  
  9370. function setInfosCaracteristiques() {
  9371. // Modification de l'entete
  9372. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  9373. thTotal.innerHTML+='|<i>Moyenne</i>';
  9374. thTotal.title="Moyenne (Moyenne ce tour)";
  9375.  
  9376. // Ajout des informations calculees
  9377. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  9378. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  9379. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  9380.  
  9381. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  9382. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  9383. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  9384.  
  9385. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  9386. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  9387. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  9388.  
  9389. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  9390. var tdRegTotal = trRegeneration.children[5];
  9391. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  9392. // Temps recupere par reg (propale R')
  9393. var regmoyTemp = Math.max(0, regmoy);
  9394. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  9395. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  9396. if (sec != 0) {
  9397. regTitle += " " + sec + " sec";
  9398. }
  9399. trRegeneration.title = regTitle;
  9400.  
  9401. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  9402. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  9403. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  9404.  
  9405. var trRM=document.querySelector("table#caracs #rm").parentElement;
  9406. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  9407. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  9408.  
  9409.  
  9410. var trMM=document.querySelector("table#caracs #mm").parentElement;
  9411. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  9412. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  9413.  
  9414. var tdRefl=document.querySelector("#refl");
  9415. // TODO : prendre en compte bonus/malus D esq du tour ?
  9416. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  9417. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  9418. }
  9419.  
  9420. function setLienAnatrolliseur(){
  9421. var pTableAmelio = document.querySelector("#carac>div>p");
  9422. pTableAmelio.innerHTML+=" - ";
  9423. var aElt = document.createElement("a");
  9424. aElt.setAttribute("href",urlAnatrolliseur);
  9425. aElt.setAttribute("target","_blank");
  9426. aElt.className="AllLinks";
  9427. aElt.innerHTML="Anatrolliser";
  9428. pTableAmelio.appendChild(aElt);
  9429. }
  9430. function setInfoDescription() {
  9431. var txtDateCrea = (NBjours!=1) ?
  9432. " ("+NBjours+" jours dans le hall)" :
  9433. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  9434. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  9435. }
  9436.  
  9437. function setInfosEtatLieux() {
  9438. var urlBricol = URL_MZmountyhall + 'lieux.php'+
  9439. '?search=position&orderBy=distance&posx='+
  9440. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  9441. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  9442. appendBr(tdPosition);
  9443. var aElt = document.createElement("a");
  9444. aElt.setAttribute("href",urlBricol);
  9445. aElt.setAttribute("target","_blank");
  9446. aElt.className="AllLinks";
  9447. aElt.innerHTML="Lieux à proximité";
  9448. tdPosition.appendChild(aElt);
  9449. }
  9450.  
  9451. function setInfosEtatPV() { // pour AM et Sacro
  9452. var
  9453. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  9454. sec = Math.floor(15000/pvtotal)%60,
  9455. lifebar = document.querySelector("#pos .barre-vie");
  9456. if(sec!=0) { txt += " "+sec+" sec"; }
  9457. if(lifebar) { lifebar.title = txt; }
  9458. if(pvcourant<=0) { return; }
  9459. // Difference PV p/r a equilibre de temps (propale R')
  9460. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  9461. // ***INIT GLOBALE*** pvdispo
  9462. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  9463. var span = document.createElement("span");
  9464. span.title = txt;
  9465. span.style.fontStyle = "italic";
  9466. if(bmt+pdm>=0) {
  9467. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  9468. } else if(pvdispo>0) {
  9469. txt = "Vous pouvez encore perdre "+
  9470. Math.min(pvdispo,pvcourant)+
  9471. " PV sans malus de temps.";
  9472. } else if(pvdispo<0) {
  9473. txt = "Il vous manque "
  9474. +(-pvdispo)
  9475. +" PV pour ne plus avoir de malus de temps.";
  9476. } else {
  9477. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  9478. }
  9479. appendText(span,txt);
  9480. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  9481. }
  9482.  
  9483. // Complete le cadre "Experience"
  9484. function setInfosExp() {
  9485. var tdNiv = document.querySelector("#exp #niv");
  9486.  
  9487. // Calcul niveau monstre/troll min pour gain PX
  9488. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  9489. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  9490.  
  9491. // Calcul PX restant
  9492. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  9493. if (pxRestant >= 0) {
  9494. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  9495. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  9496. }
  9497.  
  9498. // Calul pi/jour
  9499. var
  9500. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  9501. tdPi = document.querySelector("#exp #pi").parentElement;
  9502. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  9503. tdPi.title = tdPiTotal.title;
  9504.  
  9505. // Rapports meurtres,morts
  9506. var tdKill = document.querySelector("#exp #kill");
  9507. tdKill.setAttribute("colspan", 1);
  9508. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  9509.  
  9510. var tdMort = document.querySelector("#exp #mort");
  9511. tdMort.setAttribute("colspan", 1);
  9512. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  9513.  
  9514. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  9515. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  9516. }
  9517.  
  9518.  
  9519. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  9520.  
  9521. function minParPVsac(fat,bm) {
  9522. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  9523. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  9524. var out = [];
  9525. out[0] = (fat>4) ?
  9526. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  9527. 30;
  9528. if(bm && bm>0) {
  9529. var totalfat=fat+bm;
  9530. out[1] = (totalfat>4) ?
  9531. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  9532. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  9533. }
  9534. return out;
  9535. }
  9536.  
  9537. function toInt(str) {
  9538. str = parseInt(str);
  9539. return (str) ? str : 0;
  9540. }
  9541.  
  9542. function saveLastDLA() {
  9543. // pour les calculs d'AM max
  9544. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  9545. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  9546. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  9547. lastDLA = new Date( StringToDate(str) );
  9548. MY_setValue(numTroll+'.DLA.ancienne',str);
  9549. lastDLAZone.innerHTML = '';
  9550. var b = document.createElement('b');
  9551. b.addEventListener('click',inputMode,false);
  9552. appendText(b,str);
  9553. lastDLAZone.appendChild(b);
  9554. refreshAccel();
  9555. }
  9556.  
  9557. function inputMode() {
  9558. // Edition manuelle lastDLA
  9559. var date;
  9560. if(lastDLA)
  9561. date = new Date( lastDLA );
  9562. else
  9563. date = new Date( DLAaccel );
  9564. lastDLAZone.innerHTML = '';
  9565. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  9566. appendText(lastDLAZone,'/');
  9567. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  9568. appendText(lastDLAZone,'/');
  9569. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  9570. appendText(lastDLAZone,' - ');
  9571. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  9572. appendText(lastDLAZone,':');
  9573. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  9574. appendText(lastDLAZone,':');
  9575. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  9576. appendText(lastDLAZone,' - ');
  9577. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  9578. }
  9579.  
  9580. function setAccel() {
  9581. var
  9582. BMfrais=false,
  9583. fat=fatigue, listeBmFat=[],
  9584. tr, th, insertPt;
  9585.  
  9586. // Creation ligne speciale pour AM dans le cadre "Etat"
  9587. tr = document.createElement('tr');
  9588. th = document.createElement('th');
  9589. appendText(th,'Fatigue et AM',true);
  9590. tr.appendChild(th);
  9591. insertPt = document.createElement('td');
  9592. tr.appendChild(insertPt);
  9593. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  9594.  
  9595. // Est-on en over-DLA ?
  9596. // ***INIT GLOBALE*** overDLA
  9597. overDLA = (HeureServeur>DLA.getTime()+3e5);
  9598. if(overDLA) {
  9599. fat=Math.floor(fatigue/1.25);
  9600. }
  9601.  
  9602. // Gestion des BM de fatigue
  9603. if(bmfatigue>0) {
  9604. // On tente de recuperer les BM de fatigue de la page des BM
  9605. if(MY_getValue(numTroll+'.bm.fatigue')) {
  9606. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  9607. BMmemoire.pop();
  9608. var tour = 0;
  9609. for(var i=0 ; i<BMmemoire.length ; i++) {
  9610. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  9611. while(tour<=parseInt(nbrs[0])) {
  9612. listeBmFat[tour]=parseInt(nbrs[1]);
  9613. tour++;
  9614. }
  9615. }
  9616. }
  9617. if(listeBmFat[0]==bmfatigue) {
  9618. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  9619. BMfrais = true;
  9620. MY_removeValue(numTroll+".bm.fatigue");
  9621. }
  9622. } else {
  9623. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  9624. BMfrais = true;
  9625. }
  9626. if(!BMfrais && bmfatigue>0) {
  9627. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  9628. if(bmfatigue==15) {
  9629. listeBmFat = [15,15,15];
  9630. } else {
  9631. listeBmFat = [30,30,15];
  9632. }
  9633. }
  9634. if(overDLA) {
  9635. // Si on est en over-DLA, on decale les bm d'un tour
  9636. listeBmFat.shift();
  9637. }
  9638. // Tableau des fatigues et accel futures
  9639. var
  9640. minppv = minParPVsac(fat,listeBmFat[0]),
  9641. table, tbody,
  9642. ligneTour, ligneFat, ligneMin,
  9643. col;
  9644. // ***INIT GLOBALE*** minParPV
  9645. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  9646. if(fat>0 || listeBmFat[0]>0) {
  9647. table = document.createElement('table');
  9648. table.className = 'mh_tdborder';
  9649. table.border = 0;
  9650. table.cellSpacing = 1;
  9651. table.cellPadding = 1;
  9652. table.style.textAlign = "center";
  9653. tbody = document.createElement('tbody');
  9654. table.appendChild(tbody);
  9655. insertPt.appendChild(table);
  9656. ligneTour = appendTr(tbody,'mh_tdtitre');
  9657. ligneTour.style.fontWeight = "bold";
  9658. var td = appendTdText(ligneTour,'Tour :',true);
  9659. td.align = 'left';
  9660. ligneFat = appendTr(tbody,'mh_tdpage');
  9661. td = appendTdText(ligneFat,'Fatigue :',true);
  9662. td.className = 'mh_tdtitre';
  9663. td.align = 'left';
  9664. ligneMin = appendTr(tbody,'mh_tdpage');
  9665. td = appendTdText(ligneMin,'1 PV =',true);
  9666. td.className = 'mh_tdtitre';
  9667. td.align = 'left';
  9668. col=0;
  9669. while(col<9 && (fat>0 || listeBmFat[col])) {
  9670. if(col==0) {
  9671. if(overDLA) {
  9672. var i = document.createElement('i');
  9673. appendText(i,'A activer');
  9674. ligneTour.appendChild(i);
  9675. } else {
  9676. appendTdText(ligneTour,'En cours');
  9677. }
  9678. } else {
  9679. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9680. }
  9681. if(listeBmFat[col]) {
  9682. if(BMfrais || (!overDLA && col==0)) {
  9683. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  9684. appendTdText(ligneMin,minppv[1]+'\'');
  9685. } else {
  9686. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  9687. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  9688. }
  9689. } else {
  9690. appendTdText(ligneFat,fat);
  9691. appendTdText(ligneMin,minppv[0]+'\'');
  9692. }
  9693. col++;
  9694. fat = Math.floor(fat / 1.25);
  9695. minppv = minParPVsac(fat,listeBmFat[col]);
  9696. }
  9697. if(fat>1 || (fat==1 && !overDLA)) {
  9698. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  9699. appendTdText(ligneFat,'-');
  9700. appendTdText(ligneMin,'-');
  9701. }
  9702. col = (overDLA) ?
  9703. Math.max(retourAZero(fatigue)-1,col) :
  9704. Math.max(retourAZero(fatigue),col);
  9705. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9706. appendTdText(ligneFat,'0');
  9707. appendTdText(ligneMin,'30\'');
  9708. if(!BMfrais && bmfatigue) {
  9709. // si les BM n'ont pas ete rafraichis, on signale:
  9710. appendText(
  9711. insertPt,
  9712. '/!\\ Visitez la page des Bonus/Malus '+
  9713. 'pour mettre à jour votre fatigue. /!\\',
  9714. true
  9715. );
  9716. appendBr(insertPt);
  9717. }
  9718. appendBr(insertPt);
  9719. }
  9720. if(pvcourant<=0) {
  9721. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  9722. return;
  9723. }
  9724. if(fatigue>30) {
  9725. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  9726. return;
  9727. }
  9728. // Setup lastDLAZone
  9729. if(overDLA) {
  9730. // bypass des infos de "menu_FF.js" en cas d'overDLA
  9731. DLAaccel = new Date( DLAsuiv );
  9732. lastDLA = new Date( DLA );
  9733. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  9734. // ***INIT GLOBALE*** pvActuelKastar
  9735. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  9736. appendText(
  9737. insertPt,
  9738. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  9739. true
  9740. );
  9741. appendBr(insertPt);
  9742. } else {
  9743. DLAaccel = new Date( DLA );
  9744. pvActuelKastar = pvcourant;
  9745. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  9746. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  9747. } else {
  9748. lastDLA = false;
  9749. }
  9750. }
  9751. appendText(insertPt,'Dernière DLA enregistrée : ');
  9752. lastDLAZone = document.createElement('span');
  9753. lastDLAZone.style.cursor = 'pointer';
  9754. var b = document.createElement('b');
  9755. b.onclick = inputMode;
  9756. lastDLAZone.appendChild(b);
  9757. insertPt.appendChild(lastDLAZone);
  9758. if(lastDLA) {
  9759. appendText(b,DateToString(lastDLA));
  9760. } else {
  9761. appendText(b,'aucune');
  9762. }
  9763. appendBr(insertPt);
  9764. // Setup maxAMZone et cumulZone
  9765. appendText(insertPt,'Accélération maximale possible : ');
  9766. maxAMZone = document.createElement('b');
  9767. insertPt.appendChild(maxAMZone);
  9768. appendBr(insertPt);
  9769. cumulZone = document.createElement('span');
  9770. insertPt.appendChild(cumulZone);
  9771. refreshAccel();
  9772. }
  9773.  
  9774. function refreshAccel() {
  9775. var pvs, pvsmax;
  9776. // Acceleration pour cumul instantane
  9777. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  9778. if(lastDLA) {
  9779. pvsmax = Math.min(
  9780. pvActuelKastar-1,
  9781. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  9782. );
  9783. maxAMZone.innerHTML = pvsmax+" PV";
  9784. } else {
  9785. pvsmax = pvActuelKastar-1;
  9786. maxAMZone.innerHTML = "inconnue";
  9787. }
  9788. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  9789. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  9790. cumulZone.innerHTML = '';
  9791. if(pvs<=pvsmax) {
  9792. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  9793. appendText(cumulZone,pvs+' PV', true);
  9794. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  9795. if(pvs!=1) {
  9796. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  9797. -(pvs-1)*60*minParPV;
  9798. appendText(
  9799. cumulZone,
  9800. ' ('+(pvs-1)+' PV dans '+
  9801. Math.floor(gainSec/60)+'min'+
  9802. addZero(gainSec%60)+'s)'
  9803. );
  9804. }
  9805. } else {
  9806. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  9807. appendText(
  9808. cumulZone,
  9809. 'Après votre accélération maximale, il vous faudra encore attendre '+
  9810. dureeHM(avantDLA/6e4)+
  9811. ' avant de réactiver.'
  9812. );
  9813. }
  9814. }
  9815.  
  9816.  
  9817. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  9818.  
  9819. function traitementTalents() {
  9820. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  9821. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  9822. removeAllTalents();
  9823. var totalComp = injecteInfosBulles(trCompetence,'competences');
  9824. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  9825. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  9826. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  9827. }
  9828.  
  9829. function injecteInfosBulles(liste,fonction) {
  9830. var totalpc = 0;
  9831. // on parse la liste des talents du type 'fonction'
  9832. for(var i=0 ; i<liste.length ; i++) {
  9833. var
  9834. trTalent=liste[i],
  9835. node=trTalent.cells[1].querySelector('a'),
  9836. nomTalent=epure(trim(node.textContent)),
  9837. indiceTDniveaux=7,
  9838. indiceTDSousCompetence=2,
  9839. sousCompetences=undefined;
  9840. if(fonction=="competences"){
  9841. // un TD en plus pour des information complementaire liees a la comp
  9842. indiceTDniveaux++;
  9843. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  9844. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  9845. for (var j=0; j < sousCompetences.length; j++) {
  9846. sousCompetences[j] = sousCompetences[j].epure().trim();
  9847. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  9848. }
  9849. }
  9850. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  9851. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  9852. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  9853. totalpc += niveauxMaitrisesTalentArray[1];
  9854.  
  9855. // stockage des niveaux inferieurs du talent si presents
  9856. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  9857. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  9858. totalpc+=niveauxMaitrisesTalentArray[j+1];
  9859. }
  9860. }
  9861. return totalpc;
  9862. }
  9863.  
  9864. function setInfos(node,nom,fonction,niveau) {
  9865. node.nom = nom;
  9866. node.fonction = fonction;
  9867. node.niveau = niveau;
  9868. node.onmouseover = setBulle;
  9869. node.onmouseout = cacherBulle;
  9870. }
  9871.  
  9872. var arrayModifAnatroll = {
  9873. 'Glue':'Glu',
  9874. 'PuM':'PuiM',
  9875. 'HE':'Hurlement',
  9876. //'Insultes':'Insu',
  9877. 'Pistage':'Pist',
  9878. 'PuC':'Planter'
  9879. }
  9880.  
  9881. function setTalent(nom,pc,niveau,sousCompetences) {
  9882. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  9883. // (et pas les % dont osf) ne serait pas plus rentable
  9884. var nomEnBase = arrayTalents[epure(nom)];
  9885. if(!nomEnBase) { return; }
  9886. if(!niveau) { niveau = 1; }
  9887. switch(nomEnBase) {
  9888. case 'Insultes':
  9889. urlAnatrolliseur += 'Insu'+niveau+'|';
  9890. case 'IdT':
  9891. nomEnBase += niveau;
  9892. break;
  9893. case 'Golemo':
  9894. case 'Piege':
  9895. for (var i=0 ; i < sousCompetences.length ; i++) {
  9896. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  9897. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  9898. }
  9899. break;
  9900. case 'AP':
  9901. case 'Baroufle':
  9902. case 'CdB':
  9903. case 'CdM':
  9904. case 'Parer':
  9905. case 'Retraite':
  9906. case 'RB':
  9907. case 'SInterposer':
  9908. nomEnBase += niveau;
  9909. default:
  9910. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  9911. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  9912. }
  9913. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  9914. }
  9915.  
  9916. function creerBulleVide() {
  9917. var table = document.createElement('table');
  9918. table.id = 'bulle';
  9919. table.className = 'mh_tdborder';
  9920. table.width = 300;
  9921. table.border = 0;
  9922. table.cellPadding = 5;
  9923. table.cellSpacing = 1;
  9924. table.style =
  9925. 'position:absolute;'
  9926. +'visibility:hidden;'
  9927. +'z-index:800;'
  9928. +'height:auto;';
  9929. var tr = appendTr(table,'mh_tdtitre');
  9930. appendTdText(tr,'Titre');
  9931. tr = appendTr(table,'mh_tdpage');
  9932. appendTdText(tr,'Contenu');
  9933. var aList = document.getElementsByTagName('a');
  9934. aList[aList.length-1].parentNode.appendChild(table);
  9935. }
  9936.  
  9937. function cacherBulle() {
  9938. if(bulleStyle)
  9939. bulleStyle.visibility = 'hidden';
  9940. }
  9941.  
  9942. function setBulle(evt) {
  9943. var nom = this.nom;
  9944. var fonction = this.fonction;
  9945. var niveau = parseInt(this.niveau);
  9946. var str='';
  9947. if(fonction=='competences'){
  9948. str=competences(nom,niveau);
  9949. } else if(fonction=='sortileges') {
  9950. str=sortileges(nom,true);
  9951. }
  9952. if(str=='') return;
  9953. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  9954. var xfenetre, yfenetre, xpage, ypage, element = null;
  9955. var offset = 15;
  9956. var bulleWidth = 300;
  9957. if(!hauteur) hauteur = 50;
  9958. element = document.getElementById('bulle');
  9959. xfenetre = evt.clientX;
  9960. yfenetre = evt.clientY;
  9961. xpage = xfenetre;
  9962. ypage = yfenetre;
  9963. if(evt.pageX) xpage = evt.pageX;
  9964. if(evt.pageY) ypage = evt.pageY;
  9965. if(element) {
  9966. bulleStyle = element.style;
  9967. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  9968. element.childNodes[1].firstChild.innerHTML = str;
  9969. }
  9970. if(bulleStyle) {
  9971. if(xfenetre>bulleWidth+offset)
  9972. xpage -= bulleWidth+offset;
  9973. else
  9974. xpage += offset;
  9975. if(yfenetre>hauteur+offset)
  9976. ypage -= hauteur + offset;
  9977. bulleStyle.width = bulleWidth;
  9978. bulleStyle.left = xpage + 'px';
  9979. bulleStyle.top = ypage + 'px';
  9980. bulleStyle.visibility = 'visible';
  9981. }
  9982. }
  9983.  
  9984.  
  9985. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  9986.  
  9987. function competences(comp,niveau) {
  9988. var texte = '';
  9989. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  9990. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  9991. if(minParPV>1) texte += 's';
  9992. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  9993. }
  9994. else if(comp.indexOf('Attaque Precise')!=-1) {
  9995. var pc, lastmax=0, espatt=0;
  9996. var notMaxedOut = false;
  9997. for(var i=niveau ; i>0 ; i--) {
  9998. pc = getTalent(comp,i);
  9999. if(lastmax!=0 && pc<=lastmax) continue;
  10000. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  10001. attbp+attbm;
  10002. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10003. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  10004. ' => <b>'+jetatt+'</b><br/>';
  10005. espatt += (pc-lastmax)*jetatt;
  10006. lastmax = pc;
  10007. if(i<niveau) notMaxedOut = true;
  10008. }
  10009. if(notMaxedOut) {
  10010. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  10011. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  10012. }
  10013. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  10014. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10015. }
  10016. else if(comp.indexOf('Balayage')!=-1)
  10017. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  10018. +' => <b>'+attmoy+'</b><br/>'
  10019. +'Effet : <b>Met à terre l\'adversaire</b>';
  10020. else if(comp.indexOf('Bidouille')!=-1)
  10021. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  10022. +'de votre inventaire avec le texte de votre choix.';
  10023. else if(comp.indexOf('Baroufle')!=-1){
  10024. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  10025. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  10026. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  10027. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  10028. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  10029. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  10030. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  10031. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  10032. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  10033. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  10034. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  10035. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  10036. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  10037. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  10038. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  10039. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  10040. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  10041. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  10042. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  10043. '</tbody></table>';
  10044. }
  10045. else if(comp.indexOf('Botte Secrete')!=-1){
  10046. texte = 'Attaque : <b>'
  10047. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10048. +' => <b>'
  10049. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  10050. +'</b><br/>Dégâts : <b>'
  10051. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  10052. +' => <b>'
  10053. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  10054. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  10055. +'</b>';
  10056. }
  10057. else if(comp.indexOf('Camouflage')!=-1) {
  10058. var camou = getTalent('Camouflage');
  10059. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  10060. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  10061. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  10062. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  10063. }
  10064. else if(comp.indexOf('Charger')!=-1) {
  10065. if(pvcourant<=0)
  10066. return '<i>On ne peut charger personne quand on est mort !</i>';
  10067. var portee = Math.min(
  10068. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  10069. vuetotale);
  10070. if(portee<1)
  10071. return '<b>Impossible de charger</b>';
  10072. else {
  10073. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10074. +' => <b>'+attmoy+'</b><br/>'
  10075. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10076. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  10077. +'<br/>Portée : <b>'+portee+'</b> case';
  10078. if(portee>1) texte += 's';
  10079. }
  10080. }
  10081. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  10082. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  10083. if(vuetotale>1) texte += 's';
  10084. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10085. if(vuetotale>2) texte += 's';
  10086. }
  10087. else if(comp.indexOf('Piege')!=-1) {
  10088. if(comp.indexOf('Glue')!=-1)
  10089. texte = 'Et si vous colliez vos adversaires au sol ?';
  10090. if(comp.indexOf('Feu')!=-1) {
  10091. if(texte){
  10092. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  10093. }
  10094. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  10095. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  10096. }
  10097. }
  10098. else if(comp.indexOf('Contre-Attaquer')!=-1){
  10099. texte = 'Attaque : <b>'
  10100. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10101. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10102. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10103. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10104. }
  10105. else if(comp.indexOf('Coup de Butoir')!=-1) {
  10106. var pc, lastmax=0, espdeg=0;
  10107. var notMaxedOut = false;
  10108. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10109. +' => <b>'+attmoy+'</b>';
  10110. for(var i=niveau ; i>0 ; i--) {
  10111. pc = getTalent(comp,i);
  10112. if(lastmax!=0 && pc<=lastmax) continue;
  10113. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  10114. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10115. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  10116. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  10117. espdeg += (pc-lastmax)*jetdeg;
  10118. lastmax = pc;
  10119. if(i<niveau) notMaxedOut = true;
  10120. }
  10121. if(notMaxedOut) {
  10122. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  10123. Math.floor(10*espdeg/lastmax)/10+'/'+
  10124. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  10125. }
  10126. }
  10127. else if(comp.indexOf('Course')!=-1)
  10128. texte = 'Déplacement gratuit : <b>'
  10129. +Math.floor(getTalent('Course')/2)
  10130. +' %</b> de chance';
  10131. else if(comp.indexOf('Deplacement Eclair')!=-1)
  10132. texte = 'Permet d\'économiser <b>1</b> PA '
  10133. +'par rapport au déplacement classique';
  10134. else if(comp.indexOf('Dressage')!=-1)
  10135. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  10136. +'ou un gnu sauvage.';
  10137. else if(comp.indexOf('Ecriture Magique')!=-1)
  10138. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  10139. +'la formule nécessite de réunir les composants de cette formule, '
  10140. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  10141. +'un champignon adéquat pour confectionner l\'encre.';
  10142. else if(comp.indexOf('Frenesie')!=-1) {
  10143. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10144. +' => <b>'+attmoy+'</b><br/>'
  10145. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10146. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10147. }
  10148. else if(comp.indexOf('Golem')!=-1)
  10149. texte = 'Animez votre golem en assemblant divers matériaux '
  10150. +'autour d\'un cerveau minéral.'
  10151. else if(comp.indexOf('Grattage')!=-1) {
  10152. texte = 'Permet de confectionner un Parchemin Vierge '
  10153. +'à partir de composants et de Gigots de Gob\'.';
  10154. }
  10155. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  10156. texte = 'Fait fuir un monstre si tout se passe bien.'
  10157. +'<br/>Lui donne de gros bonus sinon...';
  10158. else if(comp.indexOf('Identification des Champignons')!=-1) {
  10159. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10160. if(vuetotale>2) texte += 's';
  10161. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  10162. if(vuetotale>4) texte += 's';
  10163. }
  10164. else if(comp.indexOf('Insultes')!=-1)
  10165. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  10166. else if(comp.indexOf('interposer')!=-1)
  10167. texte = 'Jet de réflexe : <b>'
  10168. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  10169. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  10170. else if(comp.indexOf('Lancer de Potions') != -1)
  10171. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  10172. else if(comp.indexOf('Marquage')!=-1)
  10173. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  10174. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  10175. +'se trouver dans la même caverne que le monstre pour le marquer.';
  10176. else if(comp.indexOf('Melange Magique')!=-1)
  10177. texte = 'Cette Compétence permet de combiner deux Potions pour '
  10178. +'en réaliser une nouvelle dont l\'effet est la somme '
  10179. +'des effets des potions initiales.';
  10180. else if(comp.indexOf('Miner')!=-1)
  10181. texte = 'Portée horizontale (officieuse) : <b>'
  10182. +2*vuetotale+'</b> cases<br/>'
  10183. +'Portée verticale (officieuse) : <b>'
  10184. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10185. else if(comp.indexOf('Necromancie')!=-1)
  10186. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  10187. +'de faire "revivre" ce monstre.';
  10188. else if(comp.indexOf('Painthure de Guerre')!=-1)
  10189. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  10190. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  10191. +'pour s\'inspirer, et laissez parler votre créativité.'
  10192. else if(comp.indexOf('Parer')!=-1)
  10193. texte = 'Jet de parade : <b>'
  10194. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  10195. +' => <b>'
  10196. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10197. +'</b><hr><i>Equivalent esquive : <b>'
  10198. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  10199. +' => <b>'
  10200. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  10201. +'</b></i>';
  10202. else if(comp.indexOf('Pistage')!=-1)
  10203. texte = 'Portée horizontale : <b>'
  10204. +2*vuetotale+'</b> cases<br/>'
  10205. +'Portée verticale : <b>'
  10206. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10207. else if(comp.indexOf('Planter un Champignon')!=-1)
  10208. texte = 'Planter un Champignon est une compétence qui vous permet de '
  10209. +'créer des colonies d\'une variété donnée de champignon à partir de '
  10210. +'quelques exemplaires préalablement enterrés.';
  10211. else if(comp.indexOf('Regeneration Accrue')!=-1)
  10212. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  10213. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  10214. else if(comp.indexOf('Reparation')!=-1)
  10215. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  10216. +'et réparez vous-même votre matériel !';
  10217. else if(comp.indexOf('Retraite')!=-1)
  10218. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  10219. +'préférable de préparer un repli stratégique pour déconcerter '
  10220. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  10221. +'Quelle intelligence démoniaque.';
  10222. else if(comp.indexOf('Rotobaffe')!=-1) {
  10223. var Datt = att, vattbm = attbp+attbm;
  10224. var Ddeg = deg, vdegbm = degbp+degbm;
  10225. for(var i=1 ; i<niveau+2 ; i++) {
  10226. texte += '<b>Attaque n°'+i+' :</b><br/>'
  10227. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  10228. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  10229. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  10230. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  10231. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  10232. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  10233. if(i<niveau+1) texte += '<hr>';
  10234. }
  10235. }
  10236. else if(comp.indexOf('Shamaner')!=-1)
  10237. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  10238. +'des monstres en utilisant des champignons (de 1 à 3).';
  10239. else if(comp.indexOf('Tailler')!=-1){
  10240. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  10241. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  10242. }
  10243. return texte;
  10244. }
  10245.  
  10246. function decumul_buff(nom,str,buff) {
  10247. // Decumul des sorts de buff
  10248. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  10249. var dec = buff, total = buff, i=1;
  10250. while(i<6) {
  10251. i++;
  10252. dec = Math.floor(coefDecumul(i)*buff);
  10253. if(dec<=1 || i==6) break;
  10254. total += dec;
  10255. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  10256. +str+' +'+dec+' (+'+total+')</i>';
  10257. }
  10258. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  10259. return ret;
  10260. }
  10261.  
  10262.  
  10263. function sortileges(sort,mainCall,pcA,pcD) {
  10264. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  10265. var texte = '';
  10266. if (mainCall) {
  10267. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  10268. pcA = (atttourP+atttourM);
  10269. pcD = (degtourP+degtourM);
  10270. }
  10271. if (sort.indexOf('Analyse Anatomique') != -1) {
  10272. texte = 'Portée horizontale : <b>'
  10273. + Math.floor(vuetotale / 2) + '</b> case';
  10274. if (vuetotale > 3){ texte += 's'; }
  10275. texte += '<br/>Portée verticale : <b>'
  10276. + Math.floor((vuetotale+1)/4)+'</b> case';
  10277. if (vuetotale > 7){ texte += 's'; }
  10278. }
  10279. else if (sort.indexOf('Armure Etheree') != -1){
  10280. texte = decumul_buff('AE', 'Armure magique', reg);
  10281. }
  10282. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  10283. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  10284. }
  10285. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  10286. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  10287. }
  10288. else if (sort.indexOf('Augmentation des Degats') != -1){
  10289. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  10290. }
  10291. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  10292. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  10293. }
  10294. else if(sort.indexOf('Bulle Magique')!=-1){
  10295. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  10296. }
  10297. else if(sort.indexOf('Explosion')!=-1){
  10298. texte = 'Dégâts : <b>'
  10299. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  10300. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  10301. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  10302. }
  10303. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  10304. if(pvcourant<=0)
  10305. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  10306. texte = 'Portée horizontale : <b>'
  10307. +Math.min(1,vuetotale)+'</b> case<br/>'
  10308. +'Dégâts physiques : <b>-'
  10309. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  10310. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  10311. +'Dégâts magiques : <b>-'
  10312. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  10313. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  10314. }
  10315. else if(sort.indexOf('Flash Aveuglant')!=-1){
  10316. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  10317. }
  10318. else if(sort.indexOf('Glue')!=-1) {
  10319. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  10320. if(vuetotale>2) texte += 's';
  10321. }
  10322. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  10323. /* Frappe */
  10324. var modD = 0;
  10325. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10326. if(pcA!=0){
  10327. modD = parseInt(att*pcA/100);
  10328. texte += '<i>'+aff(modD)+'D6</i> ';
  10329. }
  10330. texte += aff(attbm)
  10331. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  10332. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  10333. if(pcD!=0) {
  10334. modD = parseInt(Math.floor(deg/2)*pcD/100);
  10335. texte += '<i>'+aff(modD)+'D3</i> ';
  10336. }else
  10337. modD = 0;
  10338. texte += aff(degbm)+' => <b>'
  10339. +(2*(Math.floor(deg/2)+modD)+degbm)
  10340. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  10341. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  10342. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  10343. +')</b>';
  10344. if(!mainCall) return texte;
  10345. /* Venins */
  10346. function addVenin(type,effet,duree) {
  10347. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  10348. +' pendant <b>'+duree+'</b> tour';
  10349. if(duree>1) ret += 's';
  10350. var dred = Math.max(Math.floor(duree/2),1);
  10351. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  10352. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  10353. }
  10354. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  10355. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  10356. effet = Math.floor(1.5*effet);
  10357. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  10358. }
  10359. else if(sort.indexOf('Hypnotisme')!=-1)
  10360. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  10361. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  10362. else if(sort.indexOf('Identification des tresors')!=-1)
  10363. texte = 'Permet de connaitre les caractéristiques et effets précis '
  10364. +'d\'un trésor.';
  10365. else if(sort.indexOf('Invisibilite')!=-1)
  10366. texte = 'Un troll invisible est indétectable même quand on se trouve '
  10367. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  10368. +'fait disparaître l\'invisibilité.';
  10369. else if(sort.indexOf('Levitation')!=-1)
  10370. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  10371. +'Comme les pièges ou les trous par exemple...';
  10372. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  10373. var eps = 1,
  10374. pc = 20;
  10375. var str = 'PréM';
  10376. var newSort;
  10377. var sortAtt = [
  10378. 'Projectile Magique',
  10379. 'Rafale Psychique',
  10380. 'Siphon des Ames',
  10381. 'Vampirisme',
  10382. 'Griffe du Sorcier'
  10383. ];
  10384. if(sort.indexOf('Puissance')!=-1) {
  10385. eps = -1; str='PuM';
  10386. }
  10387. for(var i=1 ; i<4 ; i++) {
  10388. if(texte) { texte += '<hr>'; }
  10389. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  10390. newSort = false;
  10391. for(var j=0 ; j<sortAtt.length ; j++) {
  10392. if(getTalent(sortAtt[j])) {
  10393. if(newSort) { texte += '<br/><br/>'; }
  10394. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  10395. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  10396. newSort = true;
  10397. }
  10398. }
  10399. pc = decumulPumPrem(pc);
  10400. }
  10401. }
  10402. else if(sort.indexOf('Projectile Magique')!=-1) {
  10403. var modD = 0;
  10404. var portee = getPortee__Profil(vuetotale);
  10405. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  10406. if(pcA!=0) {
  10407. modD = parseInt(vue*pcA/100);
  10408. texte += '<i>'+aff(modD)+'D6</i> ';
  10409. }
  10410. texte += aff(attbm)
  10411. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  10412. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  10413. if(pcD!=0) {
  10414. modD = parseInt(Math.floor(vue/2)+pcD);
  10415. texte += '<i>'+aff(modD)+'D3</i> ';
  10416. }else
  10417. modD = 0;
  10418. texte += aff(degbm)
  10419. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  10420. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  10421. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  10422. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  10423. if(!mainCall) return texte;
  10424. texte += '<br/>Portée : <b>'+portee+'</b> case';
  10425. if(portee>1) texte += 's';
  10426. }
  10427. else if(sort.indexOf('Projection')!=-1) {
  10428. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  10429. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  10430. +'Si le jet de résistance de la victime est réussi:<br/>'
  10431. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  10432. }
  10433. else if(sort.indexOf('Rafale Psychique')!=-1) {
  10434. var modD = 0;
  10435. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  10436. if(pcD!=0) {
  10437. modD = parseInt(deg*pcD/100);
  10438. texte += '<i>'+aff(modD)+'D3</i> ';
  10439. }
  10440. texte += aff(degbm)
  10441. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  10442. if(!mainCall) return texte;
  10443. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  10444. }
  10445. else if(sort.indexOf('Sacrifice')!=-1) {
  10446. if(pvcourant<=0)
  10447. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  10448.  
  10449. function perteSacro(sac) {
  10450. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  10451. }
  10452.  
  10453. var sac = Math.floor((pvcourant-1)/2);
  10454. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10455. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  10456. /* Sacros max et optimal sans malus (propale R') */
  10457. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10458. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  10459. if(sac>0)
  10460. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  10461. else
  10462. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  10463. /*if(sac>3) {
  10464. sac = 5*Math.floor((sac+1)/5)-1;
  10465. texte += '<br/>Soin optimal sans malus de temps : <b>'
  10466. +sac+'</b> PV'+perteSacro(sac);
  10467. }*/
  10468. }
  10469. else if(sort.indexOf('Siphon')!=-1) {
  10470. var modD = 0;
  10471. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10472. if(pcA!=0) {
  10473. modD = parseInt(att*pcA/100);
  10474. texte += '<i>'+aff(modD)+'D6</i> ';
  10475. }
  10476. texte += aff(attbm)
  10477. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  10478. +'Dégâts : <b>'+reg+'</b> D3 ';
  10479. if(pcD!=0) {
  10480. modD = parseInt(reg*pcD/100);
  10481. texte += '<i>'+aff(modD)+'D3</i> ';
  10482. }else
  10483. modD = 0;
  10484. texte += aff(degbm)
  10485. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  10486. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  10487. if(!mainCall) return texte;
  10488. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  10489. }
  10490. else if(sort.indexOf('Telekinesie')!=-1) {
  10491. texte = 'Portée horizontale :';
  10492. var vt = Math.floor(vuetotale/2)+2;
  10493. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  10494. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  10495. for(var i=0 ; i<5 ; i++) {
  10496. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  10497. if(vt>1) texte += 's';
  10498. vt=Math.max(0,vt-1);
  10499. }
  10500. }
  10501. else if(sort.indexOf('Teleportation')!=-1) {
  10502. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  10503. var pmh = (20+vue+portee);
  10504. var pmv = 3+Math.floor(portee/3);
  10505. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  10506. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  10507. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  10508. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  10509. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  10510. }
  10511. else if(sort.indexOf('Vampirisme')!=-1) {
  10512. var modD = 0;
  10513. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  10514. if(pcA!=0) {
  10515. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  10516. texte += '<i>'+aff(modD)+'D6</i> ';
  10517. }
  10518. texte += aff(attbm)
  10519. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  10520. +'Dégâts : <b>'+deg+'</b> D3 ';
  10521. if(pcD!=0) {
  10522. modD = parseInt(deg*pcD/100);
  10523. texte += '<i>'+aff(modD)+'D3</i> ';
  10524. }else
  10525. modD = 0;
  10526. texte += aff(degbm)
  10527. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  10528. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  10529. }
  10530. else if(sort.indexOf('Vision Accrue')!=-1)
  10531. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  10532. else if(sort.indexOf('Vision lointaine')!=-1)
  10533. texte = 'En ciblant une zone située n\'importe où dans le '
  10534. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  10535. else if(sort.indexOf('Voir le Cache')!=-1)
  10536. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  10537. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  10538. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  10539. +getPortee__Profil(vuetotale)+'</b> cases';
  10540. else if(sort.indexOf('Vue Troublee')!=-1)
  10541. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10542. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  10543. return texte;
  10544. }
  10545.  
  10546.  
  10547. /*---------------------------------- Main ------------------------------------*/
  10548.  
  10549. function do_profil2()
  10550. {
  10551. try {
  10552. start_script(31);
  10553.  
  10554. extractionDonnees();
  10555. setInfosCaracteristiques();
  10556. setInfoDescription();
  10557. setInfosEtatLieux();
  10558. setInfosEtatPV();
  10559. setInfosExp();
  10560.  
  10561. creerBulleVide();
  10562. traitementTalents();
  10563. setLienAnatrolliseur();
  10564.  
  10565. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  10566. if(race=='Kastar'){ setAccel(); }
  10567. saveProfil();
  10568. displayScriptTime();
  10569. } catch(e) {
  10570. avertissement("[MZ] Une erreur s'est produite.");
  10571. window.console.error("[MZ] Erreur générale Profil",e);
  10572. }
  10573. }
  10574.  
  10575. /*********************************************************************************
  10576. * This file is part of Mountyzilla. *
  10577. * *
  10578. * Mountyzilla is free software; you can redistribute it and/or modify *
  10579. * it under the terms of the GNU General Public License as published by *
  10580. * the Free Software Foundation; either version 2 of the License, or *
  10581. * (at your option) any later version. *
  10582. * *
  10583. * Mountyzilla is distributed in the hope that it will be useful, *
  10584. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10585. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10586. * GNU General Public License for more details. *
  10587. * *
  10588. * You should have received a copy of the GNU General Public License *
  10589. * along with Mountyzilla; if not, write to the Free Software *
  10590. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10591. *********************************************************************************/
  10592.  
  10593. // x~x tancompo
  10594.  
  10595. var popup;
  10596.  
  10597. function initPopupTancompo() {
  10598. popup = document.createElement('div');
  10599. popup.setAttribute('id', 'popup');
  10600. popup.setAttribute('class', 'mh_textbox');
  10601. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  10602. + 'display: inline; z-index: 3; max-width: 400px;');
  10603. document.body.appendChild(popup);
  10604. }
  10605.  
  10606. // roule 16/03/2016, existe déjà ailleurs
  10607. // function showPopup(evt) {
  10608. // var texte = this.getAttribute("texteinfo");
  10609. // popup.innerHTML = texte;
  10610. // popup.style.left = evt.pageX + 15 + 'px';
  10611. // popup.style.top = evt.pageY + 'px';
  10612. // popup.style.visibility = "visible";
  10613. // }
  10614.  
  10615. // roule 16/03/2016, existe déjà ailleurs
  10616. // function hidePopup() {
  10617. // popup.style.visibility = 'hidden';
  10618. // }
  10619.  
  10620. function createPopupImage(url, text)
  10621. {
  10622. var img = document.createElement('img');
  10623. img.setAttribute('src',url);
  10624. img.setAttribute('align','ABSMIDDLE');
  10625. img.setAttribute("texteinfo",text);
  10626. img.addEventListener("mouseover", showPopup,true);
  10627. img.addEventListener("mouseout", hidePopup,true);
  10628. return img;
  10629. }
  10630.  
  10631. function formateTexte(texte)
  10632. {
  10633. texte = texte.replace(/\n/g,"<br/>");
  10634. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  10635. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  10636. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  10637. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  10638. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  10639. return texte;
  10640. }
  10641.  
  10642. function arrondi(x) {
  10643. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  10644. }
  10645.  
  10646. function traiteMinerai() {
  10647. if (currentURL.indexOf("as_type=Divers")==-1) return;
  10648. try {
  10649. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  10650. +" and contains(./tr/th/text(),'Minerai')]",
  10651. document, null, 9, null).singleNodeValue;
  10652. node = node.nextSibling.nextSibling;
  10653. }
  10654. catch(e) {return;}
  10655. var trlist = document.evaluate('./tr', node, null, 7, null);
  10656. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  10657. var node = trlist.snapshotItem(i);
  10658. var nature = node.childNodes[5].textContent;
  10659. var caracs = node.childNodes[7].textContent;
  10660. var taille = caracs.match(/\d+/)[0];
  10661. var coef = 1;
  10662. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  10663. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  10664. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  10665. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  10666. if (nature.indexOf('Mithril')!=-1) {
  10667. coef = 0.2*coef;
  10668. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  10669. }
  10670. else {
  10671. coef = 0.75*coef+1.25;
  10672. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  10673. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  10674. }
  10675. }
  10676. }
  10677.  
  10678. function treateComposants() {
  10679. if (currentURL.indexOf("as_type=Compo")==-1) return;
  10680. //On récupère les composants
  10681. var nodes = document.evaluate(
  10682. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  10683. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  10684. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  10685. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10686. if (nodes.snapshotLength == 0) {
  10687. // window.alert('treateComposants DOWN');
  10688. return;
  10689. }
  10690. window.alert(nodes.snapshotLength);
  10691.  
  10692. var texte = "";
  10693. for (var i = 0; i < nodes.snapshotLength; i++) {
  10694. var n1 = nodes.snapshotItem(i).childNodes[1];
  10695. var n3 = nodes.snapshotItem(i).childNodes[3];
  10696. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  10697. var prix = n3.childNodes[0].nodeValue;
  10698. if (!prix)
  10699. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  10700. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10701. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10702. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  10703. + prix.replace(/\n/g, '') + "\n";
  10704. }
  10705.  
  10706. var c = document.evaluate("//div[@class = 'titre2']/text()",
  10707. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10708. var id_taniere = c.snapshotItem(0).nodeValue;
  10709. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  10710.  
  10711. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  10712. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  10713. if (form)
  10714. {
  10715. if(document.getElementsByTagName('form').length>0)
  10716. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  10717. else
  10718. {
  10719. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  10720. insertBefore(thisP, form);
  10721. }
  10722. }
  10723. }
  10724.  
  10725. function treateAllComposants() {
  10726. if(currentURL.indexOf("as_type=Compo")==-1) return;
  10727. //On récupère les composants
  10728. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  10729. document, null, 0, null ).numberValue;
  10730. var c = (categ == 0 ? 3 : 4);
  10731. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  10732. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  10733. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  10734. + "td["+c+"]/text()[1] = '\240-\240' "
  10735. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  10736. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  10737. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  10738. + "and td[1]/img/@alt = 'Identifié']",
  10739. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10740. if (nodes.snapshotLength == 0) {
  10741. // window.alert('treateAllComposants DOWN');
  10742. return;
  10743. }
  10744.  
  10745. var texte = "";
  10746. for (var i = 0; i < nodes.snapshotLength; i++) {
  10747. var n1 = nodes.snapshotItem(i).childNodes[1];
  10748. var n3 = nodes.snapshotItem(i).childNodes[3];
  10749. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  10750. var prix = n3.childNodes[0].nodeValue;
  10751. if (!prix)
  10752. {
  10753. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  10754. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  10755. }
  10756. else
  10757. {
  10758. prix= prix.replace(/[\240 ]/g, "");
  10759. if(prix=="-")
  10760. prix=null;
  10761. }
  10762. if(prix)
  10763. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10764. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10765. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  10766. + prix.replace(/\n/g, '') + "\n";
  10767. else
  10768. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10769. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10770. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  10771. }
  10772.  
  10773. var c = document.evaluate("//div[@class = 'titre2']/text()",
  10774. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10775. var id_taniere = c.snapshotItem(0).nodeValue;
  10776. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  10777.  
  10778. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  10779. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  10780. if (form)
  10781. {
  10782. if(document.getElementsByTagName('form').length>0)
  10783. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  10784. else
  10785. {
  10786. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  10787. insertBefore(thisP, form);
  10788. }
  10789. }
  10790. }
  10791.  
  10792. function treateEM()
  10793. {
  10794. if(currentURL.indexOf("as_type=Compo")==-1)
  10795. return false;
  10796. var urlImg = URL_MZimg09 + 'Competences/ecritureMagique.png';
  10797. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  10798. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10799. if (nodes.snapshotLength == 0)
  10800. return false;
  10801. for (var i = 0; i < nodes.snapshotLength; i++) {
  10802. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  10803. var link = desc[2].firstChild ;
  10804. var nomCompoTotal = desc[2].textContent ;
  10805. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  10806. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  10807. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  10808. var locqual = desc[3].textContent ;
  10809. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  10810. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  10811. if(isEM(nomMonstre).length>0)
  10812. {
  10813. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  10814. if(infos.length>0)
  10815. {
  10816. var shortDescr = "Variable";
  10817. var bold = 0;
  10818. if(infos != "Composant variable")
  10819. {
  10820. shortDescr = infos.substring(0,infos.indexOf(" "));
  10821. if(parseInt(shortDescr)>=0)
  10822. bold=1;
  10823. }
  10824. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  10825. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  10826. }
  10827. }
  10828. }
  10829. }
  10830.  
  10831. function treateChampi() {
  10832. if (currentURL.indexOf('as_type=Champi')==-1)
  10833. return false;
  10834. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  10835. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10836. if (nodes.snapshotLength == 0)
  10837. return false;
  10838.  
  10839. for (var i = 0; i < nodes.snapshotLength; i++) {
  10840. var node = nodes.snapshotItem(i);
  10841. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  10842. if (moisChampi[nomChampi])
  10843. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  10844. }
  10845. }
  10846.  
  10847. function treateEnchant()
  10848. {
  10849. if(currentURL.indexOf("as_type=Compo")==-1)
  10850. return false;
  10851. try
  10852. {
  10853. if(!listeMonstreEnchantement)
  10854. computeCompoEnchantement();
  10855. var nodes = document.evaluate(
  10856. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  10857. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  10858. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10859. if (nodes.snapshotLength == 0)
  10860. return false;
  10861. var urlImg = URL_MZimg09 + "enchant.png";
  10862. for (var i = 0; i < nodes.snapshotLength; i++) {
  10863. var link = nodes.snapshotItem(i);
  10864. var nomCompoTotal = link.firstChild.nodeValue;
  10865. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  10866. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  10867. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  10868. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  10869. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  10870. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  10871. if(isEnchant(nomMonstre).length>0)
  10872. {
  10873. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  10874. if(infos.length>0)
  10875. {
  10876. link.parentNode.appendChild(createImage(urlImg,infos));
  10877. }
  10878. }
  10879. }
  10880. }
  10881. catch(e)
  10882. {
  10883. window.alert(e);
  10884. }
  10885. }
  10886.  
  10887. function treateEquipEnchant()
  10888. {
  10889. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  10890. return false;
  10891. initPopupTancompo();
  10892. computeEnchantementEquipement(createPopupImage,formateTexte);
  10893. }
  10894.  
  10895. function do_tancompo()
  10896. {
  10897. start_script();
  10898.  
  10899. treateAllComposants();
  10900. treateComposants();
  10901. traiteMinerai();
  10902. if (MY_getValue('NOINFOEM')!='true') {
  10903. treateChampi();
  10904. treateEM();
  10905. }
  10906. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  10907. treateEnchant();
  10908. treateEquipEnchant();
  10909. }
  10910.  
  10911. displayScriptTime();
  10912. }
  10913.  
  10914.  
  10915.  
  10916.  
  10917.  
  10918. /*******************************************************************************
  10919. * This file is part of Mountyzilla. *
  10920. * *
  10921. * Mountyzilla is free software; you can redistribute it and/or modify *
  10922. * it under the terms of the GNU General Public License as published by *
  10923. * the Free Software Foundation; either version 2 of the License, or *
  10924. * (at your option) any later version. *
  10925. * *
  10926. * Mountyzilla is distributed in the hope that it will be useful, *
  10927. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10928. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10929. * GNU General Public License for more details. *
  10930. * *
  10931. * You should have received a copy of the GNU General Public License *
  10932. * along with Mountyzilla; if not, write to the Free Software *
  10933. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10934. *******************************************************************************/
  10935.  
  10936. // x~x script_principal
  10937.  
  10938. function isPage(url) {
  10939. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  10940. }
  10941.  
  10942. // x~x md5.js
  10943. /*
  10944. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  10945. * Digest Algorithm, as defined in RFC 1321.
  10946. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  10947. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  10948. * Distributed under the BSD License
  10949. * See http://pajhome.org.uk/crypt/md5 for more info.
  10950. */
  10951.  
  10952. /*
  10953. * Configurable variables. You may need to tweak these to be compatible with
  10954. * the server-side, but the defaults work in most cases.
  10955. */
  10956. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  10957. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  10958. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  10959.  
  10960. /*
  10961. * These are the functions you'll usually want to call
  10962. * They take string arguments and return either hex or base-64 encoded strings
  10963. */
  10964. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  10965. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  10966. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  10967. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  10968. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  10969. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  10970.  
  10971. /*
  10972. * Perform a simple self-test to see if the VM is working
  10973. */
  10974. function md5_vm_test()
  10975. {
  10976. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  10977. }
  10978.  
  10979. /*
  10980. * Calculate the MD5 of an array of little-endian words, and a bit length
  10981. */
  10982. function core_md5(x, len)
  10983. {
  10984. /* append padding */
  10985. x[len >> 5] |= 0x80 << ((len) % 32);
  10986. x[(((len + 64) >>> 9) << 4) + 14] = len;
  10987.  
  10988. var a = 1732584193;
  10989. var b = -271733879;
  10990. var c = -1732584194;
  10991. var d = 271733878;
  10992.  
  10993. for(var i = 0; i < x.length; i += 16)
  10994. {
  10995. var olda = a;
  10996. var oldb = b;
  10997. var oldc = c;
  10998. var oldd = d;
  10999.  
  11000. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11001. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11002. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11003. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11004. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11005. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11006. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11007. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11008. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11009. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11010. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11011. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11012. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11013. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11014. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11015. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11016.  
  11017. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11018. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11019. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11020. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11021. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11022. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11023. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11024. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11025. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11026. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11027. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11028. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11029. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11030. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11031. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11032. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11033.  
  11034. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11035. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11036. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11037. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11038. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11039. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11040. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11041. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11042. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11043. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11044. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11045. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11046. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11047. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11048. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11049. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11050.  
  11051. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11052. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11053. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11054. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11055. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11056. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11057. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11058. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11059. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11060. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11061. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11062. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11063. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11064. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11065. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11066. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11067.  
  11068. a = safe_add(a, olda);
  11069. b = safe_add(b, oldb);
  11070. c = safe_add(c, oldc);
  11071. d = safe_add(d, oldd);
  11072. }
  11073. return Array(a, b, c, d);
  11074.  
  11075. }
  11076.  
  11077. /*
  11078. * These functions implement the four basic operations the algorithm uses.
  11079. */
  11080. function md5_cmn(q, a, b, x, s, t)
  11081. {
  11082. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11083. }
  11084. function md5_ff(a, b, c, d, x, s, t)
  11085. {
  11086. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11087. }
  11088. function md5_gg(a, b, c, d, x, s, t)
  11089. {
  11090. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11091. }
  11092. function md5_hh(a, b, c, d, x, s, t)
  11093. {
  11094. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11095. }
  11096. function md5_ii(a, b, c, d, x, s, t)
  11097. {
  11098. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11099. }
  11100.  
  11101. /*
  11102. * Calculate the HMAC-MD5, of a key and some data
  11103. */
  11104. function core_hmac_md5(key, data)
  11105. {
  11106. var bkey = str2binl(key);
  11107. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11108.  
  11109. var ipad = Array(16), opad = Array(16);
  11110. for(var i = 0; i < 16; i++)
  11111. {
  11112. ipad[i] = bkey[i] ^ 0x36363636;
  11113. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11114. }
  11115.  
  11116. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11117. return core_md5(opad.concat(hash), 512 + 128);
  11118. }
  11119.  
  11120. /*
  11121. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11122. * to work around bugs in some JS interpreters.
  11123. */
  11124. function safe_add(x, y)
  11125. {
  11126. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11127. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11128. return (msw << 16) | (lsw & 0xFFFF);
  11129. }
  11130.  
  11131. /*
  11132. * Bitwise rotate a 32-bit number to the left.
  11133. */
  11134. function bit_rol(num, cnt)
  11135. {
  11136. return (num << cnt) | (num >>> (32 - cnt));
  11137. }
  11138.  
  11139. /*
  11140. * Convert a string to an array of little-endian words
  11141. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11142. */
  11143. function str2binl(str)
  11144. {
  11145. var bin = Array();
  11146. var mask = (1 << chrsz) - 1;
  11147. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11148. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11149. return bin;
  11150. }
  11151.  
  11152. /*
  11153. * Convert an array of little-endian words to a string
  11154. */
  11155. function binl2str(bin)
  11156. {
  11157. var str = "";
  11158. var mask = (1 << chrsz) - 1;
  11159. for(var i = 0; i < bin.length * 32; i += chrsz)
  11160. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11161. return str;
  11162. }
  11163.  
  11164. /*
  11165. * Convert an array of little-endian words to a hex string.
  11166. */
  11167. function binl2hex(binarray)
  11168. {
  11169. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11170. var str = "";
  11171. for(var i = 0; i < binarray.length * 4; i++)
  11172. {
  11173. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11174. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11175. }
  11176. return str;
  11177. }
  11178.  
  11179. /*
  11180. * Convert an array of little-endian words to a base-64 string
  11181. */
  11182. function binl2b64(binarray)
  11183. {
  11184. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11185. var str = "";
  11186. for(var i = 0; i < binarray.length * 4; i += 3)
  11187. {
  11188. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11189. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11190. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11191. for(var j = 0; j < 4; j++)
  11192. {
  11193. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11194. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11195. }
  11196. }
  11197. return str;
  11198. }
  11199.  
  11200. ///////////////////////////////////////////
  11201. // debug cartes capitan Roule 07/12/2016
  11202. ///////////////////////////////////
  11203. // essais : objet
  11204. // .mode : description
  11205. // .essais : tableau d'objets essai
  11206. // .mode : description
  11207. // .essais : tableau de cartes
  11208. // .noCarte : id de la carte
  11209. // .essais : tableau d'essais, [x, y, n, nb]
  11210. function AfficheEssais(essais, sMode) {
  11211. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11212. if (!eBigDiv) {
  11213. var insertPoint = document.getElementById('footer1');
  11214. eBigDiv = document.createElement('table');
  11215. eBigDiv.id = 'ListeEssaiCapitan';
  11216. insertBefore(insertPoint, document.createElement('p'));
  11217. insertTitle(insertPoint,'Capitan : Liste des essais');
  11218. insertBefore(insertPoint, eBigDiv);
  11219. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11220. }
  11221. if (!essais) {
  11222. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11223. return;
  11224. }
  11225. var carte;
  11226. for (carte in essais) {
  11227. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11228. }
  11229. if (carte === undefined) {
  11230. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11231. }
  11232. }
  11233.  
  11234. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11235. var tr = appendTr(eTable);
  11236. var td = appendTd(tr);
  11237. appendText(td, sMode, bBold);
  11238. td = appendTd(tr);
  11239. appendText(td, sCarte, bBold);
  11240. td = appendTd(tr);
  11241. appendText(td, sText, bBold);
  11242. }
  11243.  
  11244. function getEssaiV1_0() {
  11245. try {
  11246. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11247. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11248. var tabK, nK;
  11249. prefs.getChildList('', nK, tabK);
  11250. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11251. //window.console.log('getEssaiV1_0, ' + nK);
  11252. return;
  11253. return r;
  11254. } catch (e) {
  11255. window.console.log('Erreur getEssaiV1_0() :\n'+e);
  11256. }
  11257. }
  11258.  
  11259. function getEssaiV1_1() {
  11260. var locSto = window.localStorage;
  11261. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11262. var r = [];
  11263. for (var i = 0; i < locSto.length; i++) {
  11264. var k = locSto.key(i);
  11265. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11266. var t = k.split(/\./);
  11267. if (t[0] !== 'capitan') continue;
  11268. if (t[2] !== 'essai') continue;
  11269. var carte = 'carte n°' + t[1];
  11270. if (r[carte]) r[carte]++;
  11271. else r[carte] = 1;
  11272. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11273. }
  11274. return r;
  11275. }
  11276.  
  11277. function showEssaiCartes() {
  11278. window.console.log('début showEssai Tout_MZ');
  11279. var essais = getEssaiV1_0();
  11280. AfficheEssais(essais, 'V1.0');
  11281. essais = getEssaiV1_1();
  11282. AfficheEssais(essais, 'V1.1');
  11283. window.console.log('fin showEssai Tout_MZ');
  11284. }
  11285.  
  11286. /*--------------------------------- Dispatch ---------------------------------*/
  11287.  
  11288. //chargerScriptDev("libs");
  11289. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  11290.  
  11291. // Détection de la page à traiter
  11292. if(isPage("Messagerie/ViewMessageBot")) {
  11293. do_cdmbot();
  11294. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  11295. do_cdmcomp();
  11296. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  11297. do_diplo();
  11298. } else if(isPage("MH_Play/Play_equipement")) {
  11299. do_equip();
  11300. } else if(isPage("MH_Play/Play_menu")) {
  11301. do_menu();
  11302. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  11303. do_option();
  11304. //showEssaiCartes();
  11305. } else if(isPage("View/PJView")) {
  11306. do_pjview();
  11307. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  11308. do_profil();
  11309. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  11310. do_tancompo();
  11311. } else if(isPage("MH_Play/Play_vue")) {
  11312. do_vue();
  11313. } else if(isPage("MH_Play/Play_news")) {
  11314. do_news();
  11315. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  11316. do_move();
  11317. } else if(isPage("MH_Missions/Mission_Etape")) {
  11318. do_mission();
  11319. } else if(isPage("View/MonsterView")) {
  11320. do_infomonstre();
  11321. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  11322. do_attaque();
  11323. } else if(isPage("MH_Follower/FO_Ordres")) {
  11324. do_ordresgowap();
  11325. } else if(isPage("MH_Follower/FO_Equipement")) {
  11326. do_equipgowap();
  11327. } else if(isPage("MH_Play/Play_mouche")) {
  11328. do_mouches();
  11329. } else if(isPage("MH_Play/Play_BM")) {
  11330. do_malus();
  11331. } else if(isPage("MH_Play/Play_evenement")) {
  11332. do_myevent();
  11333. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  11334. do_enchant();
  11335. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  11336. do_pre_enchant();
  11337. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  11338. do_actions();
  11339. } 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')) {
  11340. do_mission_liste();
  11341. } else if(isPage('MH_Play/Play_action')) {
  11342. do_actions();
  11343. } else if(isPage('MH_Play/Play_profil2')) {
  11344. do_profil2();
  11345. }