Tout_MZ

Client MountyZilla

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

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @version 1.2.12
  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. // V1.2.10.3 09/12/2016
  65. // Adaptation à une modification du HTML MH (voir set2DViewSystem)
  66. // V1.2.10.4 12/12/2016
  67. // Correction bug à la récupération d'une erreur interface Bricoll'Troll
  68. // V1.2.11 13/12/2016
  69. // Passage sur BdD Raistlin \o/
  70. // V1.2.11.1 17/12/2016
  71. // Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un
  72. // V1.2.11.2 18/12/2016
  73. // Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil
  74. // V1.2.11.3 19/12/2016
  75. // Correction de la récupération des PI totaux (du coup la portée de TP était NaN)
  76. // Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours
  77. // V1.2.11.4 19/12/2016
  78. // Changement des couleurs de la barre de vie Interface Bricol'Troll
  79. // V1.2.11.5 à 7 20 & 21/12/2016
  80. // Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)
  81. // V1.2.12 24/12/2016
  82. // Nettoyage des URL
  83. // Mode dev (Shift+Click sur le mot "Crédits" dans Options/Pack Graphique) qui se branche sur le site de dev
  84. // Interface bricoll'Troll en https
  85. // Remise en marche des cartes des trajets des gowaps
  86. // V1.2.12.1 25/12/2016
  87. // Correction mode IP
  88. // Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)
  89.  
  90. /**********************************************************
  91. À faire / propositions d'évolutions
  92.  
  93. breizhou13 20/12/2016
  94. envoyer les données à l'IT (Bricol'Trolls) aussi
  95. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  96. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  97. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  98. Roule'
  99. Réactiver les jubilaires
  100. [Prioritaire] trajets Gowaps sans avoir besoin de URL_MZscriptCarte (voir comment c'est fait dans Trajet_des_gowap_MkII.user.js)
  101. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  102. **********************************************************/
  103.  
  104. /**********************************************************
  105. **** Début de zone à déplacer dans une bibli commune ******
  106. **********************************************************/
  107.  
  108. // URL de base serveur MZ
  109. var URL_MZ = 'https://mz.mh.raistlin.fr/mz';
  110. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  111. //var URL_MZ = 'http://192.99.225.92/mz';
  112.  
  113. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  114. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  115.  
  116. // URLs externes redirection (pas de souci CORS)
  117. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  118. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  119. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  120. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  121. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  122. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  123. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  124. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  125.  
  126. // URLs de test HTTPS
  127. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  128. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  129.  
  130. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  131. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  132. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  133. //const URL_trooglebeta = 'http://troogle-beta.aacg.be/view_submission'; // obsolette et pas utilisé
  134.  
  135. // x~x Libs
  136.  
  137. /* ancien TODO
  138. * - revoir la gestion des CdM --> nott armure magique
  139. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  140. * - vérfier la gestion des enchants
  141. */
  142.  
  143. // Roule 04/09/2016 switch extern URLs to https if available
  144. var isHTTPS = false;
  145. if (window.location.protocol.indexOf('https') === 0) {
  146. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  147. URL_bricol = URL_bricol_https;
  148. isHTTPS = true;
  149. }
  150.  
  151. // Roule 23/12/2016 mode dev
  152. var isDEV = false;
  153. if (MY_getValue('MZ_dev')) {
  154. URL_MZ = URL_MZ.replace(/$/, 'dev');
  155. isDEV = true;
  156. }
  157.  
  158. // Images (pas de souci CORS)
  159. var URL_MZimg = URL_MZ + '/img/';
  160. // URLs externes ajax (CORS OK)
  161. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  162. var URL_pageDispatcher = URL_MZ + '/cdmdispatcher.php';
  163.  
  164. // liens externes détuits
  165. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  166. var MHicons = '/mountyhall/Images/Icones/';
  167. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  168. var MY_DEBUG = false;
  169.  
  170. /* remplacement fonction MZ */
  171. function MY_getValue(key) {
  172. return window.localStorage[key];
  173. }
  174.  
  175. function MY_removeValue(key) {
  176. window.localStorage.removeItem(key);
  177. }
  178.  
  179. function MY_setValue(key, val) {
  180. window.localStorage[key] = val;
  181. }
  182.  
  183. /*---------------- mise à jour de variables globales utiles ------------------*/
  184. // utilisé pour accès bdd (un peu partout) :
  185. var numTroll = MY_getValue('NUM_TROLL');
  186. // utilisé dans vue pour PX :
  187. var nivTroll = MY_getValue('NIV_TROLL');
  188. // utilisés dans actions et vue (calculs SR) :
  189. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  190. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  191.  
  192. /*-[functions]------------ Fonctions durée de script -------------------------*/
  193. var date_debut = null;
  194.  
  195. function start_script(nbJours_exp) {
  196. if(MY_DEBUG) window.console.log('[MZ] début sur ' + window.location.pathname);
  197. if(date_debut) return;
  198. date_debut = new Date();
  199. // Créé la variable expdate si demandé
  200. if(nbJours_exp) {
  201. expdate = new Date();
  202. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  203. }
  204. }
  205.  
  206. function displayScriptTime() {
  207. var footerNode = document.getElementById('footer2');
  208. if(!footerNode) return;
  209. try{
  210. var node = document.evaluate(
  211. ".//text()[contains(.,'Page générée en')]/../br",
  212. footerNode,null,9,null).singleNodeValue;
  213. }
  214. catch(e){return;}
  215. insertText(node,
  216. ' - [Script exécuté en '
  217. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  218. if(MY_DEBUG) window.console.log('[MZ] fin sur ' + window.location.pathname);
  219. }
  220.  
  221. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  222.  
  223. function debugMZ(str){
  224. if(MY_DEBUG){
  225. window.console.debug('[MY_DEBUG] '+str);
  226. if(typeof str === "object"){
  227. window.console.debug(str);
  228. }
  229. }
  230. }
  231.  
  232. function FF_XMLHttpRequest(MY_XHR_Ob) {
  233. var request = new XMLHttpRequest();
  234. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  235. for(var head in MY_XHR_Ob.headers) {
  236. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  237. }
  238. request.onreadystatechange = function() {
  239. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  240. if(request.readyState!=4) { return; }
  241. if(request.error) {
  242. if(MY_XHR_Ob.onerror) {
  243. MY_XHR_Ob.onerror(request);
  244. }
  245. }
  246. else if(MY_XHR_Ob.onload) {
  247. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  248. MY_XHR_Ob.onload(request);
  249. }
  250. };
  251. request.send(MY_XHR_Ob.data);
  252. }
  253.  
  254.  
  255. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  256.  
  257. function avertissement(txt,duree) {
  258. if(!duree) duree = 15000;
  259. var div = document.createElement('div');
  260. // On numérote les avertissements pour destruction sélective
  261. var num = document.getElementsByName('avertissement').length;
  262. div.num = num;
  263. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  264. div.setAttribute('name','avertissement');
  265. div.className = 'mh_textbox';
  266. div.style.position = 'fixed';
  267. div.style.top = (10+15*num)+'px';
  268. div.style.left = (10+5*num)+'px';
  269. div.style.border = '5px solid red';
  270. div.style.zIndex = 2+num;
  271. div.style.cursor = 'pointer';
  272. div.style.fontSize = 'large';
  273. div.innerHTML = txt;
  274. div.onclick=function(){ tueAvertissement(this.num) };
  275.  
  276. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  277. var divcroix = document.createElement('div');
  278. divcroix.style.position = 'absolute';
  279. divcroix.style.top = 0;
  280. divcroix.style.right = 0;
  281. divcroix.style.color = 'black';
  282. divcroix.style.fontSize = 'inherit';
  283. divcroix.style.cursor = 'pointer'
  284. divcroix.style.zIndex = 2+num;
  285. divcroix.innerHTML = "X";
  286. div.appendChild(divcroix);
  287.  
  288. document.body.appendChild(div);
  289. // Destruction automatique de l'avertissement après "un certain temps"
  290. window.setTimeout(function(){ tueAvertissement(num) },duree);
  291. }
  292.  
  293. function tueAvertissement(num) {
  294. var divs = document.getElementsByName('avertissement');
  295. if(divs.length==0) { return; }
  296. for(var i=0 ; i<divs.length ; i++) {
  297. if(divs[i].num==num) {
  298. divs[i].parentNode.removeChild(divs[i]);
  299. return;
  300. }
  301. }
  302. }
  303.  
  304.  
  305. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  306.  
  307. function insertBefore(next,el) {
  308. next.parentNode.insertBefore(el,next);
  309. }
  310.  
  311. function appendTr(tbody,clas) {
  312. var tr = document.createElement('tr');
  313. if(clas) tr.className = clas;
  314. tbody.appendChild(tr);
  315. return tr;
  316. }
  317.  
  318. function insertTr(next,clas) {
  319. var tr = document.createElement('tr');
  320. if(clas) tr.className = clas;
  321. insertBefore(next,tr);
  322. return tr;
  323. }
  324.  
  325. function appendTd(tr) {
  326. var td = document.createElement('td');
  327. if(tr) tr.appendChild(td);
  328. return td;
  329. }
  330.  
  331. function insertTd(next) {
  332. var td = document.createElement('td');
  333. insertBefore(next,td);
  334. return td;
  335. }
  336.  
  337. function appendTdCenter(tr,colspan) {
  338. var td = appendTd(tr);
  339. td.align = 'center'; // WARNING - Obsolete
  340. if(colspan) td.colSpan = colspan;
  341. return td;
  342. }
  343.  
  344. function insertTdElement(next,el) {
  345. var td = insertTd(next);
  346. if(el) td.appendChild(el);
  347. return td;
  348. }
  349.  
  350. function appendA(paren,href,cssClass,text) {
  351. var a = document.createElement('a');
  352. if (href) a.href = href;
  353. if (cssClass) a.className = cssClass;
  354. if (text) a.appendChild(document.createTextNode(text));
  355. paren.appendChild(a);
  356. }
  357.  
  358. function appendText(paren,text,bold) {
  359. if(bold) {
  360. var b = document.createElement('b');
  361. b.appendChild(document.createTextNode(text));
  362. paren.appendChild(b);
  363. }
  364. else
  365. paren.appendChild(document.createTextNode(text));
  366. }
  367.  
  368. function insertText(next,text,bold) {
  369. if(bold) {
  370. var b = document.createElement('b');
  371. appendText(b,text);
  372. insertBefore(next,b);
  373. }
  374. else
  375. insertBefore(next,document.createTextNode(text));
  376. }
  377.  
  378. function appendTdText(tr,text,bold) {
  379. var td = appendTd(tr);
  380. appendText(td,text,bold);
  381. return td;
  382. }
  383.  
  384. function insertTdText(next,text,bold) {
  385. var td = insertTd(next);
  386. appendText(td,text,bold);
  387. return td;
  388. }
  389.  
  390. function appendBr(paren) {
  391. paren.appendChild(document.createElement('br'));
  392. }
  393.  
  394. function insertBr(next) {
  395. insertBefore(next,document.createElement('br'));
  396. }
  397.  
  398. function appendLI(ul,text) {
  399. // uniquement utilisé dans les options (crédits)
  400. var li = document.createElement('li');
  401. appendText(li,text);
  402. ul.appendChild(li);
  403. return li;
  404. }
  405.  
  406. function appendTextbox(paren,type,nam,size,maxlength,value) {
  407. var input = document.createElement('input');
  408. input.className = 'TextboxV2';
  409. input.type = type;
  410. input.name = nam;
  411. input.id = nam;
  412. input.size = size;
  413. input.maxLength = maxlength;
  414. if(value) input.value = value;
  415. paren.appendChild(input);
  416. return input;
  417. }
  418.  
  419. function appendCheckBox(paren,nam,checked,onClick) {
  420. var input = document.createElement('input');
  421. input.type = 'checkbox';
  422. input.name = nam;
  423. input.id = nam;
  424. if(checked) input.checked = true;
  425. if(onClick) input.onclick = onClick;
  426. paren.appendChild(input);
  427. return input;
  428. }
  429.  
  430. function appendNobr(paren,id,delgg,text) {
  431. var nobr = document.createElement('nobr');
  432. appendCheckBox(nobr,id,null,delgg);
  433. appendText(nobr,text);
  434. paren.appendChild(nobr);
  435. appendText(paren,' ');
  436. return nobr;
  437. }
  438.  
  439. function appendCheckBoxSpan(paren,id,onClick,text) {
  440. var span = document.createElement('span');
  441. span.style.whiteSpace = 'nowrap';
  442. appendCheckBox(span,id,false,onClick);
  443. appendText(span,text);
  444. paren.appendChild(span);
  445. appendText(paren,' ');
  446. return span;
  447. }
  448.  
  449. function appendOption(select,value,text) {
  450. var option = document.createElement('option');
  451. option.value = value;
  452. appendText(option,text);
  453. select.appendChild(option);
  454. return option;
  455. }
  456.  
  457. function appendHidden(form,nam,value) {
  458. var input = document.createElement('input');
  459. input.type = 'hidden';
  460. input.name = nam;
  461. input.id = nam;
  462. input.value = value;
  463. form.appendChild(input);
  464. }
  465.  
  466. function appendButton(paren,value,onClick) {
  467. var input = document.createElement('input');
  468. input.type = 'button';
  469. input.className = 'mh_form_submit';
  470. input.value = value;
  471. input.onmouseover = function(){this.style.cursor='pointer';};
  472. if(onClick) input.onclick = onClick;
  473. paren.appendChild(input);
  474. return input;
  475. }
  476.  
  477. function insertButton(next,value,onClick) {
  478. var input = document.createElement('input');
  479. input.type = 'button';
  480. input.className = 'mh_form_submit';
  481. input.value = value;
  482. input.onmouseover = function(){this.style.cursor='pointer';};
  483. input.onclick = onClick;
  484. insertBefore(next,input);
  485. return input;
  486. }
  487.  
  488. function appendSubmit(paren,value,onClick) {
  489. var input = document.createElement('input');
  490. input.type = 'submit';
  491. input.className = 'mh_form_submit';
  492. input.value = value;
  493. input.onmouseover = function(){this.style.cursor='pointer';};
  494. if(onClick) input.onclick = onClick;
  495. paren.appendChild(input);
  496. return input;
  497. }
  498.  
  499. function createImage(url,title) {
  500. var img = document.createElement('img');
  501. img.src = url;
  502. img.title = title;
  503. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  504. return img;
  505. }
  506.  
  507. function createAltImage(url,alt,title) {
  508. var img = document.createElement('img');
  509. img.src = url;
  510. img.alt = alt;
  511. img.title = title;
  512. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  513. return img;
  514. }
  515.  
  516. function createImageSpan(url,alt,title,text,bold) {
  517. var span = document.createElement('span');
  518. span.title = title;
  519. var img = document.createElement('img');
  520. img.src = url;
  521. img.alt = alt;
  522. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  523. span.appendChild(img);
  524. appendText(span,text,bold);
  525. return span;
  526. }
  527.  
  528. function createCase(titre,table,width) {
  529. if(!width) width=120;
  530. var tr = appendTr(table,'mh_tdpage');
  531. var td = appendTdText(tr,titre,true);
  532. td.className = 'mh_tdtitre';
  533. td.width = width;
  534. td = appendTdText(tr,'');
  535. td.className = 'mh_tdpage';
  536. return td;
  537. }
  538.  
  539. function getMyID(e) {
  540. var parent = e.parentNode;
  541. for(var i=0 ; i<parent.childNodes.length ; i++) {
  542. if(e==parent.childNodes[i])
  543. return i;
  544. }
  545. return -1;
  546. }
  547.  
  548. function insertAfter(elt,newElt) {
  549. var id = getMyID(elt);
  550. if(id==-1) return;
  551. if(id<elt.parentNode.childNodes.length-1)
  552. insertBefore(elt.nextSibling,newElt);
  553. else
  554. elt.parentNode.appendChild(newElt);
  555. }
  556.  
  557.  
  558. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  559.  
  560. function aff(nb) {
  561. return (nb>=0) ? '+'+nb : nb;
  562. }
  563.  
  564. function getNumber(str) {
  565. var nbr = str.match(/\d+/);
  566. return nbr ? Number(nbr[0]) : Number.NaN;
  567. }
  568.  
  569. function getNumbers(str) {
  570. var nbrs = str.match(/-?\d+/g);
  571. if (!nbrs) return [];
  572. for(var i=0 ; i<nbrs.length ; i++)
  573. nbrs[i] = Number(nbrs[i]);
  574. return nbrs;
  575. }
  576.  
  577. function trim(str) {
  578. return str.replace(/(^\s*)|(\s*$)/g,'');
  579. }
  580.  
  581. String.prototype.trim = function() {
  582. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  583. }
  584.  
  585. function epure(texte) {
  586. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  587. .replace(/[ç]/g,'c')
  588. .replace(/[éêèë]/g,'e')
  589. .replace(/[ïî]/g,'i')
  590. .replace(/[ôöõ]/g,'o')
  591. .replace(/[ùûü]/g,'u');
  592. }
  593.  
  594. String.prototype.epure = function () {
  595. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  596. .replace(/[ç]/g,'c')
  597. .replace(/[éêèë]/g,'e')
  598. .replace(/[ïî]/g,'i')
  599. .replace(/[ôöõ]/g,'o')
  600. .replace(/[ùûü]/g,'u');
  601. }
  602.  
  603. function bbcode(texte) {
  604. return texte.replace(/&/g,'&amp;')
  605. .replace(/"/g,'&quot;')
  606. .replace(/</g,'&lt;')
  607. .replace(/>/g,'&gt;')
  608. .replace(/'/g,'&#146;')
  609. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  610. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  611. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  612. }
  613.  
  614.  
  615. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  616.  
  617. function addZero(i) {
  618. return (i<10) ? '0'+i : i;
  619. }
  620.  
  621. function DateToString(date) {
  622. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  623. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  624. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  625. }
  626.  
  627. function StringToDate(str) {
  628. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  629. }
  630.  
  631. // fonctionne aussi avec datetime
  632. function SQLDateToFrench(str) {
  633. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  634. }
  635.  
  636. // ... et ajoute un "à" du plus bel effet
  637. function SQLDateToFrenchTime(str) {
  638. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  639. }
  640.  
  641. // SQLDate vers objet date Javascript
  642. function SQLDateToObject(str) {
  643. var t = str.split(/[- :]/);
  644. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  645. }
  646.  
  647. // mise en commun du dessin des cartes (récupéré de Trajet_des_gowaps de feldspath et Vapulabehemot)
  648. function declare_css_carte_hall() {
  649. if(haut.getElementById("css_gow")) return;
  650. css = "#carte_trajet { position: relative; text-align: left; }\ndiv#carte_gowap, div.mh_tdpage { display: none; }\ndiv.mh_tdpage#cadre_liste, div.mh_tdpage#bulle_desc_gow { display: block !important; }\n#trou, #trajet, #surligne, #danger, #cadre_liste {\n position: absolute;\n top: 0px;\n left: 0px;\n}\n#cadre_liste {\n padding: 10px 20px 5px 10px;\n}\n.etape {\n width: 100%;\n border: 1px solid #000;\n padding: 1px 5px 1px 5px;\n margin: -1px 0px 0px 0px;\n}\nlabel {\n cursor: pointer;\n}\n.etape_surlignee {\n width: 100%;\n border : 2px solid #ff2222;\n padding: 1px 5px 0px 5px;\n margin: -2px -1px -1px -1px;\n}\n.etape canvas, .etape_surlignee canvas {\n position: relative; float: right;\n margin-left:10px; margin-right: -3px; margin-top : 2px;\n}\n.a_cliquer {\n cursor: pointer;\n}\n#aj_noeud { cursor : pointer; }\n#trou_fav, #trace_fav { position: absolute; top: 20px; left: 0px; }\n.choix_zoom { position: relative; margin-left:30px; margin-top:3px; }\n#glissiere_gow, #glissiere_fav { position: relative; }\n\n#bulle_trajet { \n visibility:hidden;\n position:absolute; z-index:3100;\n width:400px;\n border-width:1px; border-style:solid; border-color:#a1927f;\n}\n#mobile_bulleVue { cursor:move; }\n.bulle_haut { font-weight:bold; text-align:left; padding:2px; }\n#bulle_desc_gow { font-size:11px; padding:2px; }\n\n#gestion_fav_gow { position:absolute; padding: 1px; border-with:1px; border-style:solid; min-width:300px; z-index:3000; }\n#titre_gow, .fav, .fav_dessus { min-height:15px; }\n.fav { margin:0; margin:0 0 -1px 0; padding: 1px 1px 1px 1px; border : 1px solid #a1927f; }\n.fav_dessus { margin:-1px; margin:-1px -1px -2px -1px; padding: 0px 1px 0px 1px; border : 2px solid #a1927f; }\n#gestion_fav_gow .a_cliquer { position: relative; float: right; margin-left: 2px; }\n#gestion_fav_gow { display: block !important; }\n#cadre_fav { position: relative; }\n#bulle_zoom { display:block !important; visibility: hidden; position: absolute; z-index: 3500; border : 1px solid #a1927f; }";
  651.  
  652. var node = document.createElement("style");
  653. node.type = "text/css";
  654. node.id = "css_gow";
  655. node.appendChild(document.createTextNode(css));
  656. document.getElementsByTagName("head")[0].appendChild(node);
  657. }
  658.  
  659. function ini_canvas_carte_hall() {
  660. var trajet = document.createElement("div");
  661. trajet.id = "carte_trajet";
  662.  
  663. var dessin = creer_canvas("trou");
  664. dessin.className = "mh_tdpage";
  665. trajet.appendChild(dessin);
  666. trajet.appendChild(creer_canvas("trajet"));
  667. trajet.appendChild(creer_canvas("danger"));
  668.  
  669. var dessin = creer_canvas("surligne");
  670. addEvent(dessin, "click", action_trajet, true);
  671. addEvent(dessin, "mousedown", start_v, true);
  672. addEvent(dessin, "mousemove", afficher_position, true);
  673. addEvent(dessin, "mouseout", function() { cacher_bulle(true) }, true);
  674. addEvent(dessin, "mouseover", function() { cacher_bulle(false) }, true);
  675. trajet.appendChild(dessin);
  676.  
  677. trajet.appendChild(creer_glissiere("gow", zoom));
  678.  
  679. var parp = document.getElementsByTagName('p');
  680. parp[parp.length-1].insertBefore(trajet,parp[parp.length-1].firstChild);
  681. }
  682.  
  683. /**********************
  684. * glissière en mode objet
  685. * Une glissière est un curseur permettant, par exemple de changer le zoome des cartes
  686. * L'objet lui-même est assigné à la propriété "obj" de la div de la glissière
  687. *
  688. * Usage:
  689. * gliss = new glissiere_MZ(ref, labelHTML, target);
  690. * le premier parametre est utilisé pour diversifier les IDs HTML
  691. * le deuxième paramètre est le label qui apparaît davant la glissière (peut contenir des balises HTML)
  692. * le proisième paramètre peut être de 3 types
  693. * - élément HTML : l'élément HTML à zoomer
  694. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  695. * - function : callback quand le curseur bouge
  696. * autres méthodes
  697. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  698. * gliss.setDynamic(true); // par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  699. * // dans le mode dynamique, la callback est appelée sur mouseMove
  700. **********************/
  701.  
  702. function glissiere_MZ(ref, labelHTML, paramTarget) {
  703. var div_gliss = document.createElement("div");
  704. div_gliss.id = "glissiere_MZ_"+ref;
  705. var div_label = document.createElement("div");
  706. div_label.innerHTML = labelHTML;
  707. div_gliss.appendChild(div_label);
  708. div_gliss.className = "choix_zoom";
  709. var dessin = creer_canvas("glissiere_"+ref);
  710. dessin.width = 104;
  711. dessin.height = 12;
  712. addEvent(dessin
  713. , "mousedown"
  714. , function (evt) {
  715. var xpage = (evt.offsetX)? evt.offsetX:evt.layerX;
  716. var zoom = Math.min(250,Math.max(50,(xpage+23.0)*2.0));
  717. MY_setValue("zoom_" + ref, zoom)
  718. trace_glissiere(ref);
  719. if (curs_dynamique) {
  720. document.getElementById("val_zoom_gow").innerHTML = zoom+"%";
  721. coeff = zoom/50.0;
  722. if(page == "trajet") {
  723. echelle_trajet();
  724. trace_trajet_prev();
  725. sauve_trajet();
  726. }
  727. else if(page == "suivants") {
  728. echelle_position();
  729. sauve_opt_position();
  730. }
  731. else {
  732. echelle_teleport();
  733. }
  734. glissable = true;
  735. this.style.cursor = "e-resize";
  736. } else {
  737. trace_glissiere_fav();
  738. haut.getElementById("val_zoom_fav").innerHTML = zoom_fav+"%";
  739. echelle_fav();
  740. }
  741. }
  742. , true);
  743. addEvent(dessin, "mousemove", sur_curseur, true);
  744. if (curs_dynamique) { // ajout par Vapulabehemot (82169) le 10/07/2015
  745. addEvent(dessin, "mouseup", drop, true); // ajout par Vapulabehemot (82169) le 10/07/2015
  746. addEvent(dessin, "mousemove", glisse, true); // ajout par Vapulabehemot (82169) le 10/07/2015
  747. } // ajout par Vapulabehemot (82169) le 10/07/2015
  748. addEvent(dessin, "mouseout", function() { haut.getElementById("bulle_zoom").style.visibility="hidden" }, true);
  749. addEvent(dessin, "mouseover", function() { haut.getElementById("bulle_zoom").style.visibility="visible" }, true);
  750. div_gliss.appendChild(dessin);
  751. div_gliss.appendChild(enligne("val_zoom_"+ref));
  752. div_gliss.lastChild.innerHTML = val+"%";
  753.  
  754. creer_bulle_zoom();
  755. }
  756.  
  757. function trace_glissiere_carte_hall() {
  758. dessine_glissiere("gow", Math.min(99,Math.max(0,Math.round(zoom/2.0)-25)));
  759. if ( page == 'trajet' || page == 'lieu_tp' ) { // ajout par Vapulabehemot (82169) le 10/07/2015
  760. document.getElementById('choix_zoom_gow').style.top = '4px'; // ajout par Vapulabehemot (82169) le 10/07/2015
  761. } // ajout par Vapulabehemot (82169) le 10/07/2015
  762. }
  763.  
  764. function dessine_glissiere(ref, val) {
  765. var dessin = haut.getElementById("glissiere_"+ref);
  766. if (!dessin.getContext) return;
  767. var ctx = dessin.getContext('2d');
  768. ctx.clearRect(0, 0,104, 12);
  769. ctx.fillStyle = "rgb(0,0,0)";
  770. ctx.fillRect(0,0,2,12);
  771. ctx.fillRect(102,0,2,12);
  772. ctx.fillRect(0,5,104,2);
  773.  
  774. ctx.fillStyle = "rgb(80,80,80)";
  775. ctx.fillRect(val,0,5,12);
  776. ctx.fillStyle = "rgb(200,200,200)";
  777. ctx.fillRect(val+1,1,3,10);
  778. }
  779.  
  780.  
  781. /**********************************************************
  782. **** Fin de zone à déplacer dans une bibli commune ********
  783. **********************************************************/
  784.  
  785. /* DEBUG: NETTOYAGE TAGS */
  786. if(MY_getValue(numTroll+'.TAGSURL')) {
  787. MY_removeValue(numTroll+'.TAGSURL');
  788. }
  789.  
  790. // Alerte si mode dev
  791. if (isDEV) {
  792. var divpopup = document.createElement('div');
  793. divpopup.id = 'divDEV';
  794. divpopup.style =
  795. 'position: fixed;'+
  796. 'border: 15px solid red;'+
  797. 'top: 10px;right: 10px;'+
  798. 'background-color: white;'+
  799. 'color: black;'+
  800. 'font-size: large;'+
  801. 'padding: 5px'+
  802. 'z-index: 200;';
  803. appendText(divpopup, 'Mode DEV');
  804. document.body.appendChild(divpopup);
  805. }
  806.  
  807. /*---------- regroupement des getPortee() ------------------------------------*/
  808. // issu des script profil et profil2
  809. function getPortee__Profil(param) {
  810. param = Math.max(0,Number(param));
  811. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  812. // ça devrait être floor, +10.25, -2.5
  813. }
  814.  
  815. // issu du script vue
  816. function getPortee__Vue(param) {
  817. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  818. }
  819.  
  820.  
  821. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  822.  
  823. function getPXKill(niv) {
  824. return Math.max(0,10+3*niv-2*nivTroll);
  825. }
  826.  
  827. function getPXDeath(niv) {
  828. return Math.max(0,10+3*nivTroll-2*niv);
  829. }
  830.  
  831. function analysePX(niv) {
  832. niv = niv+'';
  833. var i = niv.indexOf('+');
  834. if(i!=-1) // si niv = 'XX+' ??
  835. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  836. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  837. if(i!=-1) {
  838. var max = getPXKill(niv.slice(i+2));
  839. if(max==0)
  840. return ' --> <b>0</b> PX';
  841. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  842. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  843. }
  844. i = niv.indexOf('='); // ???
  845. if(i!=-1) {
  846. var max = getPXKill(niv.slice(i+1));
  847. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  848. }
  849. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  850. }
  851.  
  852. function analysePXTroll(niv) {
  853. var str = analysePX(niv);
  854. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  855. return str;
  856. }
  857.  
  858.  
  859. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  860. // Refonte totale du code de Zorya
  861.  
  862. // Elements à implémenter en dur dans MZ2.0
  863. var numQualite = {
  864. 'Très Mauvaise':1,
  865. 'Mauvaise':2,
  866. 'Moyenne':3,
  867. 'Bonne':4,
  868. 'Très Bonne':5
  869. };
  870.  
  871. var qualiteNum = [
  872. '_dummy_',
  873. 'Très Mauvaise',
  874. 'Mauvaise',
  875. 'Moyenne',
  876. 'Bonne',
  877. 'Très Bonne'
  878. ];
  879.  
  880. var nival = {
  881. 'Abishaii Bleu':19,
  882. 'Abishaii Noir':10,
  883. 'Abishaii Rouge':23,
  884. 'Abishaii Vert':15,
  885. 'Ame-en-peine':8,
  886. 'Amibe Geante':9,
  887. 'Anaconda des Catacombes':8,
  888. 'Ankheg':10,
  889. 'Anoploure Purpurin':36,
  890. 'Araignee Geante':2,
  891. 'Ashashin':35,
  892. 'Balrog':50,
  893. 'Banshee':16,
  894. 'Barghest':36,
  895. 'Basilisk':11,
  896. 'Behemoth':34,
  897. 'Behir':14,
  898. 'Beholder':50,
  899. 'Boggart':3,
  900. 'Bondin':9,
  901. "Bouj'Dla Placide":37,
  902. "Bouj'Dla":19,
  903. 'Bulette':19,
  904. 'Caillouteux':1,
  905. 'Capitan':35,
  906. 'Carnosaure':25,
  907. 'Champi-Glouton':3,
  908. 'Chauve-Souris Geante':4,
  909. 'Cheval a Dents de Sabre':23,
  910. 'Chevalier du Chaos':20,
  911. 'Chimere':13,
  912. 'Chonchon':24,
  913. 'Coccicruelle':22,
  914. 'Cockatrice':5,
  915. 'Crasc Medius':17,
  916. 'Crasc Maexus':25,
  917. 'Crasc':10,
  918. 'Croquemitaine':6,
  919. 'Cube Gelatineux':32,
  920. 'Daemonite':27,
  921. 'Diablotin':5,
  922. 'Dindon du Chaos':1,
  923. 'Djinn':29,
  924. 'Ectoplasme':18,
  925. 'Effrit':27,
  926. "Elementaire d'Air":23,
  927. "Elementaire d'Eau":17,
  928. 'Elementaire de Feu':21,
  929. 'Elementaire de Terre':21,
  930. 'Elementaire du Chaos':26,
  931. 'Erinyes':7,
  932. 'Esprit-Follet':16,
  933. 'Essaim Craterien':30,
  934. 'Essaim Sanguinaire':25,
  935. 'Ettin':8,
  936. 'Familier':1,
  937. 'Fantome':24,
  938. 'Feu Follet':20,
  939. 'Flagelleur Mental':33,
  940. 'Foudroyeur':38,
  941. 'Fumeux':22,
  942. 'Fungus Geant':9,
  943. 'Fungus Violet':4,
  944. 'Furgolin':10,
  945. 'Gargouille':3,
  946. 'Geant de Pierre':13,
  947. 'Geant des Gouffres':22,
  948. "Geck'oo Majestueux":40,
  949. "Geck'oo":15,
  950. 'Glouton':20,
  951. 'Gnoll':5,
  952. 'Gnu Domestique':1,
  953. 'Gnu Sauvage':1,
  954. 'Goblin':4,
  955. 'Goblours':4,
  956. "Golem d'Argile":15,
  957. 'Golem de cuir':1,
  958. 'Golem de Chair':8,
  959. 'Golem de Fer':31,
  960. 'Golem de mithril':1,
  961. 'Golem de metal':1,
  962. 'Golem de papier':1,
  963. 'Golem de Pierre':23,
  964. 'Gorgone':11,
  965. 'Goule':4,
  966. 'Gowap Apprivoise':1,
  967. 'Gowap Sauvage':1,
  968. 'Gremlins':3,
  969. 'Gritche':39,
  970. 'Grouilleux':4,
  971. 'Grylle':31,
  972. 'Harpie':4,
  973. 'Hellrot':18,
  974. 'Homme-Lezard':4,
  975. 'Hurleur':8,
  976. 'Hydre':50,
  977. 'Incube':13,
  978. 'Kobold':2,
  979. 'Labeilleux':26,
  980. 'Lezard Geant':5,
  981. 'Liche':50,
  982. 'Limace Geante':10,
  983. 'Loup-Garou':8,
  984. 'Lutin':4,
  985. 'Mante Fulcreuse':30,
  986. 'Manticore':9,
  987. 'Marilith':33,
  988. 'Meduse':6,
  989. 'Megacephale':38,
  990. 'Mille-Pattes Geant':14,
  991. 'Mimique':6,
  992. 'Minotaure':7,
  993. 'Molosse Satanique':8,
  994. 'Momie':4,
  995. 'Monstre Rouilleur':3,
  996. "Mouch'oo Domestique":14,
  997. "Mouch'oo Majestueux Sauvage":33,
  998. "Mouch'oo Sauvage":14,
  999. 'Na-Haniym-Heee':0,
  1000. 'Necrochore':37,
  1001. 'Necromant':39,
  1002. 'Necrophage':8,
  1003. 'Naga':10,
  1004. 'Nuee de Vermine':13,
  1005. "Nuage d'Insectes":7,
  1006. 'Ogre':7,
  1007. 'Ombre de Roches':13,
  1008. 'Ombre':2,
  1009. 'Orque':3,
  1010. 'Ours-Garou':18,
  1011. 'Palefroi Infernal':29,
  1012. 'Phoenix':32,
  1013. 'Pititabeille':0,
  1014. 'Plante Carnivore':4,
  1015. 'Pseudo-Dragon':5,
  1016. 'Rat Geant':2,
  1017. 'Rat-Garou':3,
  1018. 'Rocketeux':5,
  1019. 'Sagouin':3,
  1020. 'Scarabee Geant':4,
  1021. 'Scorpion Geant':10,
  1022. 'Shai':28,
  1023. 'Sirene':8,
  1024. 'Slaad':5,
  1025. 'Sorciere':17,
  1026. 'Spectre':14,
  1027. 'Sphinx':30,
  1028. 'Squelette':1,
  1029. 'Strige':2,
  1030. 'Succube':13,
  1031. 'Tertre Errant':20,
  1032. 'Thri-kreen':10,
  1033. 'Tigre-Garou':12,
  1034. 'Titan':26,
  1035. 'Trancheur':35,
  1036. 'Tubercule Tueur':14,
  1037. 'Tutoki':4,
  1038. 'Vampire':29,
  1039. 'Ver Carnivore Geant':12,
  1040. 'Ver Carnivore':11,
  1041. 'Veskan Du Chaos':14,
  1042. 'Vouivre':33,
  1043. 'Worg':5,
  1044. 'Xorn':14,
  1045. 'Yeti':8,
  1046. 'Yuan-ti':15,
  1047. 'Zombie':2
  1048. }
  1049.  
  1050. var tabEM = {
  1051. //Monstre: [Compo exact, Sort, Position, Localisation]
  1052. // AA
  1053. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1054. // AE
  1055. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1056. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1057. // AdA
  1058. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1059. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1060. // AdE
  1061. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1062. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1063. // AdD
  1064. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1065. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1066. // BAM
  1067. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1068. // BuM
  1069. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1070. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1071. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1072. // Explo
  1073. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1074. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1075. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1076. // FP
  1077. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1078. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1079. // FA
  1080. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1081. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1082. // Glue
  1083. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1084. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1085. // GdS
  1086. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1087. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1088. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1089. // Invi
  1090. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1091. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1092. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1093. // Lévitation
  1094. // ???
  1095. // PréM :
  1096. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1097. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1098. // Proj
  1099. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1100. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1101. // PuM :
  1102. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1103. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1104. // Sacro
  1105. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1106. // Télék
  1107. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1108. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1109. // TP
  1110. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1111. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1112. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1113. // VA
  1114. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1115. // VL
  1116. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1117. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1118. // VlC
  1119. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1120. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1121. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1122. // VT
  1123. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1124. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1125. // Variables
  1126. 'Rat':["d'un"],
  1127. 'Rat Géant':["d'un"],
  1128. 'Dindon':["d'un"],
  1129. 'Goblin':["d'un"],
  1130. 'Limace':["d'une"],
  1131. 'Limace Géante':["d'une"],
  1132. 'Ver':["d'un"],
  1133. 'Ver Carnivore':["d'un"],
  1134. 'Ver Carnivore Géant':["d'un"],
  1135. 'Fungus':["d'un"],
  1136. 'Vouivre':["d'une"],
  1137. 'Gnu':["d'un"],
  1138. 'Scarabée':["d'un"]
  1139. };
  1140.  
  1141. var mundiChampi = {
  1142. 'Préscientus Reguis':'du Phoenix',
  1143. 'Amanite Trolloïde':'de la Mouche',
  1144. 'Girolle Sanglante':'du Dindon',
  1145. 'Horreur Des Prés':'du Gobelin',
  1146. 'Bolet Péteur':'du Démon',
  1147. 'Pied Jaune':'de la Limace',
  1148. 'Agaric Sous-Terrain':'du Rat',
  1149. 'Suinte Cadavre':"de l'Hydre",
  1150. 'Cèpe Lumineux':'du Ver',
  1151. 'Fungus Rampant':'du Fungus',
  1152. 'Nez Noir':'de la Vouivre',
  1153. 'Pleurote Pleureuse':'du Gnu',
  1154. 'Phytomassus Xilénique':'du Scarabée'
  1155. };
  1156.  
  1157. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1158. appendText(node,' ');
  1159. var urlImg = URL_MZimg
  1160. +'Competences/melangeMagique.png';
  1161. var text = ' [-'+(niv+effetQ)+' %]';
  1162. var str = '';
  1163. switch(mob[0]) {
  1164. case 'A':
  1165. case 'E':
  1166. case 'I':
  1167. case 'O':
  1168. case 'U':
  1169. str = "Compo d'";
  1170. break;
  1171. default:
  1172. str = 'Compo de ';
  1173. }
  1174. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1175. var span = createImageSpan(urlImg,'MM:',title,text);
  1176. node.appendChild(span);
  1177. }
  1178. function addInfoEM(node,mob,compo,qualite,localisation) {
  1179. if(!tabEM[mob]) return;
  1180. var title = 'Composant variable', texte = 'Variable';
  1181. var bold = false;
  1182. if(tabEM[mob].length>1) {
  1183. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1184. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1185. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1186. if(pc<-20) return;
  1187. if(pc>=0) bold = true;
  1188. texte = aff(pc)+'%';
  1189. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1190. }
  1191. var urlImg = URL_MZimg
  1192. +'Competences/ecritureMagique.png';
  1193. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1194. node.appendChild(span);
  1195. }
  1196.  
  1197. function insererInfosEM(tbody) {
  1198. // lancé par equip, equipgowap
  1199. var trCompos = document.evaluate(
  1200. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1201. tbody,null,7,null);
  1202. var strCompos = '';
  1203. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1204. var node = trCompos.snapshotItem(i).childNodes[7];
  1205. var str = node.firstChild.textContent;
  1206. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1207. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1208. // Si non-EM on stoppe le traitement
  1209. if(!tabEM[mob]) continue;
  1210. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1211. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1212. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1213. addInfoEM(node,mob,compo,qualite,localisation);
  1214. }
  1215. }
  1216.  
  1217. function getQualite(qualite) {
  1218. var nb = numQualite[qualite];
  1219. return nb ? nb-1 : -1;
  1220. }
  1221.  
  1222. function getEM(nom) {
  1223. if(nom.indexOf('[')!=-1)
  1224. nom = trim(nom.substring(0,nom.indexOf('[')));
  1225. if(tabEM[nom]) return nom;
  1226. return '';
  1227. }
  1228.  
  1229. // DEBUG ex-fonction composantEM
  1230. function compoMobEM(mob) {
  1231. if(!tabEM[mob]) return '';
  1232. if(tabEM[mob].length==1)
  1233. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1234. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1235. +") pour l'écriture de "+tabEM[mob][1];
  1236. }
  1237.  
  1238. // DEBUG ex-fonction compoEM
  1239. function titreCompoEM(mob,compo,localisation,qualite) {
  1240. if(!tabEM[mob]) return '';
  1241. if(tabEM[mob].length==1) return 'Composant variable';
  1242. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1243. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1244. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1245. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1246. return '';
  1247. }
  1248.  
  1249. // DEBUG - rétrocompatibilité
  1250. function compoEM(mob) {
  1251. // appelé dans libs, vue
  1252. return compoMobEM(mob);
  1253. }
  1254. function composantEM(mob,compo,localisation,qualite) {
  1255. // appelé dans libs, tancompo
  1256. return titreCompoEM(mob,compo,localisation,qualite);
  1257. }
  1258. //
  1259.  
  1260.  
  1261. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1262.  
  1263. arrayTalents = {
  1264. /* Compétences */
  1265. 'Acceleration du Metabolisme':'AM',
  1266. 'Attaque Precise':'AP',
  1267. 'Balayage':'Balayage',
  1268. //'Balluchonnage':'Ballu',
  1269. 'Baroufle':'Baroufle',
  1270. 'Bidouille':'Bidouille',
  1271. 'Botte Secrete':'BS',
  1272. 'Camouflage':'Camou',
  1273. 'Charger':'Charger',
  1274. 'Connaissance des Monstres':'CdM',
  1275. 'Construire un Piege':'Piege',
  1276. 'Piege a Feu':'PiegeFeu',
  1277. 'Piege a Glue':'PiegeGlue',
  1278. 'Contre-Attaquer':'CA',
  1279. 'Coup de Butoir':'CdB',
  1280. 'Course':'Course',
  1281. 'Deplacement Eclair':'DE',
  1282. 'Dressage':'Dressage',
  1283. 'Ecriture Magique':'EM',
  1284. 'Frenesie':'Frenesie',
  1285. 'Golemologie':'Golemo',
  1286. 'Golem de cuir':'GolemCuir',
  1287. 'Golem de metal':'GolemMetal',
  1288. 'Golem de mithril':'GolemMithril',
  1289. 'Golem de papier':'GolemPapier',
  1290. 'Grattage':'Grattage',
  1291. 'Hurlement Effrayant':'HE',
  1292. 'Identification des Champignons':'IdC',
  1293. 'Insultes':'Insultes',
  1294. 'Lancer de Potions':'LdP',
  1295. 'Marquage':'Marquage',
  1296. 'Melange Magique':'Melange',
  1297. 'Miner':'Miner',
  1298. 'Necromancie':'Necro',
  1299. 'Painthure de Guerre':'PG',
  1300. 'Parer':'Parer',
  1301. 'Pistage':'Pistage',
  1302. 'Planter un Champignon':'PuC',
  1303. 'Regeneration Accrue':'RA',
  1304. 'Reparation':'Reparation',
  1305. 'Retraite':'Retraite',
  1306. 'Rotobaffe':'RB',
  1307. 'Shamaner':'Shamaner',
  1308. "S'interposer":'SInterposer',
  1309. 'Tailler':'Tailler',
  1310. //'Vol':'Vol',
  1311. /* Sortilèges */
  1312. 'Analyse Anatomique':'AA',
  1313. 'Armure Etheree':'AE',
  1314. 'Augmentation de l´Attaque':'AdA',
  1315. 'Augmentation de l´Esquive':'AdE',
  1316. 'Augmentation des Degats':'AdD',
  1317. 'Bulle Anti-Magie':'BAM',
  1318. 'Bulle Magique':'BuM',
  1319. 'Explosion':'Explo',
  1320. 'Faiblesse Passagere':'FP',
  1321. 'Flash Aveuglant':'FA',
  1322. 'Glue':'Glue',
  1323. 'Griffe du Sorcier':'GdS',
  1324. 'Hypnotisme':'Hypno',
  1325. 'Identification des tresors':'IdT',
  1326. 'Invisibilite':'Invi',
  1327. 'Levitation':'Levitation',
  1328. 'Precision Magique':'PreM',
  1329. 'Projectile Magique':'Projo',
  1330. 'Projection':'Proj',
  1331. 'Puissance Magique':'PuM',
  1332. 'Rafale Psychique':'Rafale',
  1333. 'Sacrifice':'Sacro',
  1334. 'Siphon des Ames':'Siphon',
  1335. 'Telekinesie':'Telek',
  1336. 'Teleportation':'TP',
  1337. 'Vampirisme':'Vampi',
  1338. 'Vision Accrue':'VA',
  1339. 'Vision lointaine':'VL',
  1340. 'Voir le Cache':'VlC',
  1341. 'Vue Troublee':'VT'
  1342. //'':''
  1343. }
  1344.  
  1345. // DEBUG - Pour rétrocompatibilité
  1346. function getSortComp(nom,niveau) {
  1347. return getTalent(nom,niveau);
  1348. }
  1349. //
  1350.  
  1351. function getTalent(nom,niveau) {
  1352. var nomEnBase = arrayTalents[epure(nom)];
  1353. if(!nomEnBase) return 0;
  1354. if(!niveau) var niveau = '';
  1355. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1356. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1357. return 0;
  1358. }
  1359.  
  1360. function removeAllTalents() {
  1361. for(var talent in arrayTalents) {
  1362. var nomEnBase = arrayTalents[talent];
  1363. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1364. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1365. continue;
  1366. }
  1367. var niveau = 1;
  1368. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1369. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1370. niveau++;
  1371. }
  1372. }
  1373. }
  1374.  
  1375. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1376. var att = MY_getValue(numTroll+'.caracs.attaque');
  1377. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1378. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1379. var mm = MY_getValue(numTroll+'.caracs.mm');
  1380. var deg = MY_getValue(numTroll+'.caracs.degats');
  1381. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1382. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1383. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1384. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1385. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1386. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1387. return false;
  1388. return true;
  1389. }
  1390.  
  1391.  
  1392. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1393.  
  1394. function getPVsRestants(pv,bless,vue) {
  1395. bless = Number(bless.match(/\d+/)[0]);
  1396. if(bless==0) return null;
  1397. var pvminmax = pv.match(/\d+/g);
  1398. if(bless==95) {
  1399. var pvb = 1;
  1400. var pvh = Math.floor( pvminmax[1]/20 );
  1401. }
  1402. else if(bless==5) {
  1403. var pvb = Math.floor( pvminmax[0]*19/20 );
  1404. var pvh = pvminmax[1];
  1405. }
  1406. else {
  1407. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1408. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1409. }
  1410. return vue ? ' ('+pvb+'-'+pvh+')' :
  1411. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1412. }
  1413.  
  1414. function insertButtonCdm(nextName,onClick,texte) {
  1415. if(texte==null) texte = 'Participer au bestiaire';
  1416. var nextNode = document.getElementsByName(nextName)[0];
  1417.  
  1418. var espace = document.createTextNode('\t');
  1419. insertBefore(nextNode,espace);
  1420.  
  1421. var button = document.createElement('input');
  1422. button.type = 'button';
  1423. button.className = 'mh_form_submit';
  1424. button.value = texte;
  1425. button.onmouseover = function(){this.style.cursor='pointer';};
  1426. if(onClick) button.onclick = onClick;
  1427. insertBefore(espace,button);
  1428. return button;
  1429. }
  1430.  
  1431. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1432. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1433. 'Capacité spéciale','Résistance Magique','Autres'];
  1434.  
  1435. function createImageTactique(url,id,nom) {
  1436. var img = document.createElement('img');
  1437. img.src = url;
  1438. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1439. img.id = id;
  1440. img.nom = nom;
  1441. img.onmouseover = showPopupTactique;
  1442. img.onmouseout = hidePopup;
  1443. return img;
  1444. }
  1445.  
  1446. function createCDMTable(id,nom,donneesMonstre) {
  1447. try {
  1448. var urlImg = URL_MZimg;
  1449. var table = document.createElement('table');
  1450. var profilActif = isProfilActif();
  1451. table.className = 'mh_tdborder';
  1452. table.border = 0;
  1453. table.cellSpacing = 1;
  1454. table.cellPadding = 4;
  1455. var thead = document.createElement('thead');
  1456. var tr = appendTr(thead,'mh_tdtitre');
  1457. var td = appendTdText(tr,
  1458. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1459. true
  1460. );
  1461. td.colSpan = 2;
  1462. table.appendChild(thead);
  1463. var tbody = document.createElement('tbody');
  1464. table.appendChild(tbody);
  1465. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1466. createCase(listeTitres[i],tbody,80);
  1467. }
  1468. var TypeMonstre = getEM(nom);
  1469. var infosCompo='';
  1470. if(TypeMonstre!='') {
  1471. infosCompo = compoEM(TypeMonstre);
  1472. }
  1473. var nodes = tbody.childNodes;
  1474. nodes[0].childNodes[1].innerHTML =
  1475. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1476. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1477. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1478. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1479. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1480. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1481. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1482. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1483. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1484. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1485. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1486. td = createCase(listeTitres[10],tbody);
  1487. td.innerHTML = bbcode(donneesMonstre[10]);
  1488. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1489. td.appendChild(document.createTextNode(" "));
  1490. if(donneesMonstre[16] == "De zone")
  1491. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1492. else if(donneesMonstre[16] == "Automatique")
  1493. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1494. else if(donneesMonstre[16] == "Au toucher")
  1495. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1496. }
  1497. }
  1498. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1499. {
  1500. td = createCase(listeTitres[11],tbody);
  1501. td.innerHTML = bbcode(donneesMonstre[9]);
  1502. // seuil de résistance du monstre
  1503. var lb = td.getElementsByTagName('b');
  1504. if(lb.length == 1) {
  1505. var mrm = lb[0].firstChild.nodeValue * 1;
  1506. var v = (mrm / mmTroll);
  1507. lb[0].firstChild.nodeValue += " ("
  1508. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1509. }
  1510. }
  1511. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1512. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1513. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1514. {
  1515. td = createCase(listeTitres[12],tbody);
  1516. if(donneesMonstre[12]==1)
  1517. {
  1518. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1519. }
  1520. if(donneesMonstre[13]==1)
  1521. {
  1522. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1523. }
  1524. else if(donneesMonstre[13]==0)
  1525. {
  1526. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1527. }
  1528. if(donneesMonstre[14]==1)
  1529. {
  1530. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1531. }
  1532. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1533. {
  1534. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1535. }
  1536. else if(donneesMonstre[14]>6)
  1537. {
  1538. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1539. }
  1540. if(donneesMonstre[15]=="Lente")
  1541. {
  1542. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1543. }
  1544. else if(donneesMonstre[15]=="Normale")
  1545. {
  1546. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1547. }
  1548. else if(donneesMonstre[15]=="Rapide")
  1549. {
  1550. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1551. }
  1552. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1553. {
  1554. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1555. }
  1556. if(infosCompo.length>0)
  1557. {
  1558. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1559. }
  1560. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1561. {
  1562. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1563. }
  1564. }
  1565. // pourcentage de blessure
  1566. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1567. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1568. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1569. if(pvs)
  1570. lb[0].firstChild.nodeValue += pvs;
  1571. }
  1572. return table;
  1573. }
  1574. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  1575. }
  1576.  
  1577.  
  1578. /*-[functions]------------ Gestion des enchantements -------------------------*/
  1579.  
  1580. var listeMonstreEnchantement = null,
  1581. listeEquipementEnchantement = null,
  1582. listeInfoEnchantement = null;
  1583.  
  1584. function computeCompoEnchantement()
  1585. {
  1586. listeMonstreEnchantement = new Array();
  1587. listeInfoEnchantement = new Array();
  1588. listeEquipementEnchantement = new Array();
  1589. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  1590. for(var i=0;i<liste.length;i++)
  1591. {
  1592. var idEquipement = liste[i]*1;
  1593. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  1594. continue;
  1595. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  1596. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  1597. var texteGlobal='';
  1598. for(var j=0;j<3;j++)
  1599. {
  1600. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  1601. listeMonstreEnchantement[infoComposant[2]] = 1;
  1602. var array = new Array();
  1603. array[0]=infoComposant[0].replace("Ril","Œil");
  1604. array[1]=infoComposant[1];
  1605. array[2]=infoComposant[2];
  1606. array[3]=getQualite(infoComposant[3]);
  1607. var texte = infoComposant[4].replace("Ril","Œil");
  1608. for(var k=5;k<infoComposant.length;k++)
  1609. {
  1610. texte += ";"+infoComposant[k].replace("Ril","Œil");
  1611. }
  1612. texteGlobal+=texte+'\n';
  1613. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1614. array[4]=texte;
  1615. listeInfoEnchantement.push(array);
  1616. }
  1617. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1618. listeEquipementEnchantement[idEquipement] = texteGlobal;
  1619. }
  1620. }
  1621.  
  1622. function isEnchant(nom) {
  1623. var monstreEnchant = '';
  1624. for(j in listeInfoEnchantement) {
  1625. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1626. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1627. monstreEnchant=monstre;
  1628. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  1629. }
  1630. }
  1631. return trim(monstreEnchant);
  1632. }
  1633.  
  1634. function getInfoEnchantementFromMonstre(nom)
  1635. {
  1636. try
  1637. {
  1638. if(!listeMonstreEnchantement)
  1639. {
  1640. computeCompoEnchantement();
  1641. }
  1642. var infosEnchant = '';
  1643. for(j in listeInfoEnchantement) {
  1644. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1645. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1646. if(infosEnchant=='')
  1647. infosEnchant=listeInfoEnchantement[j][4];
  1648. else
  1649. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  1650. }
  1651. }
  1652. return trim(infosEnchant);
  1653. }
  1654. catch(e)
  1655. {
  1656. window.alert(e);
  1657. }
  1658. }
  1659.  
  1660. function composantEnchant(Monstre,composant,localisation,qualite) {
  1661. var compo='';
  1662. for(var i=0; i<listeInfoEnchantement.length; i++) {
  1663. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  1664. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  1665. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  1666. listeInfoEnchantement[i][3]<=qualite
  1667. ) {
  1668. return listeInfoEnchantement[i][4];
  1669. }
  1670. }
  1671. return compo;
  1672. }
  1673.  
  1674. function insertEnchantInfos(tbody) {
  1675. try
  1676. {
  1677. if(!listeMonstreEnchantement)
  1678. computeCompoEnchantement();
  1679. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  1680. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1681. if(nodes.snapshotLength == 0)
  1682. return false;
  1683. var urlImg = URL_MZimg + 'enchant.png';
  1684. for(var i = 0; i < nodes.snapshotLength; i++) {
  1685. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  1686. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  1687. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  1688. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  1689. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  1690. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  1691. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  1692. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  1693. if(isEnchant(nomMonstre).length>0)
  1694. {
  1695. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  1696. if(infos.length>0)
  1697. {
  1698. if(link.parentNode == link.nextSibling.parentNode)
  1699. {
  1700. var tmp = link.nextSibling;
  1701. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  1702. }
  1703. else
  1704. {
  1705. link.parentNode.appendChild(createImage(urlImg,infos));
  1706. }
  1707. }
  1708. }
  1709. }
  1710. }
  1711. catch(e)
  1712. {
  1713. window.alert(e);
  1714. }
  1715. }
  1716.  
  1717. function computeEnchantementEquipement(fontionTexte,formateTexte)
  1718. {
  1719. try
  1720. {
  1721. if(!listeMonstreEnchantement)
  1722. computeCompoEnchantement();
  1723. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  1724. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1725. if(nodes.snapshotLength == 0)
  1726. return false;
  1727. var urlImg = URL_MZimg + 'enchant.png';
  1728. for(var i = 0; i < nodes.snapshotLength; i++)
  1729. {
  1730. var link = nodes.snapshotItem(i);
  1731. var idEquipement = link.getAttribute('href');
  1732. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  1733. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  1734. var nomEquipement = trim(link.firstChild.nodeValue);
  1735. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  1736. if(!enchanteur || enchanteur == '')
  1737. continue;
  1738. var infos = listeEquipementEnchantement[idEquipement];
  1739. infos=formateTexte(infos);
  1740. if(infos.length>0)
  1741. {
  1742. if(link.parentNode == link.nextSibling.parentNode)
  1743. {
  1744. var tmp = link.nextSibling;
  1745. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  1746. }
  1747. else
  1748. {
  1749. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  1750. }
  1751. }
  1752. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  1753. }
  1754. }
  1755. catch(e)
  1756. {
  1757. window.alert(e);
  1758. }
  1759. }
  1760.  
  1761. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  1762.  
  1763.  
  1764. // Les % de toucher
  1765. var c = new Array();
  1766.  
  1767. // coefficients binomiaux
  1768. function cnp(n,k)
  1769. {
  1770. if(c[n] != null && c[n][k] != null)
  1771. return c[n][k];
  1772. if(c[n] == null)
  1773. c[n] = new Array();
  1774. if(k==0)
  1775. {
  1776. c[n][k] = 1;
  1777. return 1;
  1778. }
  1779. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  1780. c[n][k] = result;
  1781. // Roule debug
  1782. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  1783. return result;
  1784. }
  1785.  
  1786. // by Dab, à comparer
  1787. function binom(n,p) {
  1788. if(p<0 || p>n) return 0;
  1789. if(c[n])
  1790. if(c[n][p]) return c[n][p];
  1791. else {
  1792. c[n]=[1];
  1793. c[n][n]=1;
  1794. if(p==0 || p==n) return 1;
  1795. }
  1796. if(2*p>n)
  1797. c[n][p]=binom(n,n-p);
  1798. else
  1799. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  1800. return c[n][p];
  1801. }
  1802.  
  1803. var coeff = new Array();
  1804.  
  1805. function coef(n,p)
  1806. {
  1807. if(n==0 && p==0)
  1808. return 1;
  1809. if(p>n*3.5)
  1810. p = 7*n-p
  1811. // roule désactive cache
  1812. if(coeff[n] != null && coeff[n][p] !=null)
  1813. return coeff[n][p];
  1814. if(coeff[n] == null)
  1815. coeff[n] = new Array();
  1816. var kmax = Math.floor((p-n)/6);
  1817. var x=0;
  1818. for(var k=0;k<=kmax;k++)
  1819. {
  1820. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  1821. }
  1822. coeff[n][p] = x;
  1823. // Roule debug
  1824. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  1825. return x;
  1826. }
  1827.  
  1828. function chanceEsquiveParfaite(a,d,ba,bd)
  1829. {
  1830. var win = 0;
  1831. var los = 0;
  1832. if(ba==null)
  1833. ba=0;
  1834. if(bd==null)
  1835. bd=0;
  1836. /* if(6*a+ba<2*(d+bd))
  1837. return 100;
  1838. if(a+ba>2*(6*d+bd))
  1839. return 0;*/
  1840. for(var ds=d;ds<=6*d;ds++)
  1841. {
  1842. var cd = coef(d,ds);
  1843. for(var as=a;as<=6*a;as++)
  1844. {
  1845. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  1846. win += cd * coef(a,as);
  1847. else
  1848. los += cd * coef(a,as);
  1849. }
  1850. }
  1851. // roule debug
  1852. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  1853. return Math.round(100*win/(win+los));
  1854. }
  1855.  
  1856. function chanceTouche(a,d,ba,bd)
  1857. {
  1858. var win = 0;
  1859. var los = 0;
  1860. if(ba==null)
  1861. ba=0;
  1862. if(bd==null)
  1863. bd=0;
  1864. if(a+ba>6*d+bd)
  1865. return 100;
  1866. if(6*a+ba<d+bd)
  1867. return 0;
  1868. for(var ds=d;ds<=6*d;ds++)
  1869. {
  1870. var cd = coef(d,ds);
  1871. for(var as=a;as<=6*a;as++)
  1872. {
  1873. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  1874. win += cd * coef(a,as);
  1875. else
  1876. los += cd * coef(a,as);
  1877. }
  1878. }
  1879. return Math.round(100*win/(win+los));
  1880. }
  1881.  
  1882. function chanceCritique(a,d,ba,bd)
  1883. {
  1884. var win = 0;
  1885. var los = 0;
  1886. if(ba==null)
  1887. ba=0;
  1888. if(bd==null)
  1889. bd=0;
  1890. if(a+ba>2*(6*d+bd))
  1891. return 100;
  1892. if(6*a+ba<2*(d+bd))
  1893. return 0;
  1894. for(var ds=d;ds<=6*d;ds++)
  1895. {
  1896. var cd = coef(d,ds);
  1897. for(var as=a;as<=6*a;as++)
  1898. {
  1899. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  1900. win += cd * coef(a,as);
  1901. else
  1902. los += cd * coef(a,as);
  1903. }
  1904. }
  1905. return Math.round(100*win/(win+los));
  1906. }
  1907.  
  1908. /***********************************************
  1909. Analyse tactique
  1910. ***********************************************/
  1911.  
  1912. function getTexteAnalyse(modificateur,chiffre)
  1913. {
  1914. if(chiffre==0)
  1915. return chiffre;
  1916. return modificateur+chiffre;
  1917. }
  1918.  
  1919. function getAnalyseTactique(id,nom)
  1920. {
  1921. var donneesMonstre = listeCDM[id];
  1922. var needAutres=false;
  1923. var i;
  1924. if(donneesMonstre == null)
  1925. return;
  1926. var array = analyseTactique(donneesMonstre,nom);
  1927. if(array==null)
  1928. return "";
  1929. 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>";
  1930. for(i=0;i<array.length;i++)
  1931. {
  1932. if(array[i][1]==100 && i>0)
  1933. {
  1934. needAutres=true;
  1935. break;
  1936. }
  1937. if(i==1 && array[i][4]>0)
  1938. 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>";
  1939. else if(i==0)
  1940. 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>";
  1941. else
  1942. 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>";
  1943. }
  1944. if(needAutres)
  1945. {
  1946. if(i==array.length-1)
  1947. 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>";
  1948. else if(i==1)
  1949. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  1950. else
  1951. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  1952. }
  1953. return str+"</table>";
  1954. }
  1955.  
  1956. function analyseTactique(donneesMonstre,nom) {
  1957. try
  1958. {
  1959. var listeAttaques = [];
  1960. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  1961. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  1962. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  1963. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  1964. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  1965. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  1966. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  1967. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  1968. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  1969. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  1970. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  1971. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  1972. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  1973. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  1974. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  1975. var modificateurEsquive = '';
  1976. var modificateurArmure = '';
  1977. var modificateurMagie = '';
  1978. var modificateurEsquiveM = '';
  1979. var modificateurArmureM = '';
  1980. var pasDeSR=false;
  1981. var esqM,attM,armM,degM;
  1982. 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)
  1983. return null;
  1984. var td = document.createElement('td')
  1985. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  1986. var esqM = 0;
  1987. try
  1988. {
  1989. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  1990. }
  1991. catch(e)
  1992. {
  1993. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  1994. modificateurEsquive = '<';
  1995. modificateurArmure = '<';
  1996. modificateurMagie = '<';
  1997. }
  1998. td.innerHTML = bbcode(donneesMonstre[3]);
  1999. var attM = 0;
  2000. try
  2001. {
  2002. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2003. }
  2004. catch(e)
  2005. {
  2006. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2007. modificateurEsquiveM = '>';
  2008. modificateurArmureM = '>';
  2009. }
  2010. td.innerHTML = bbcode(donneesMonstre[5]);
  2011. var degM = 0;
  2012. try
  2013. {
  2014. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2015. }
  2016. catch(e)
  2017. {
  2018. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2019. modificateurArmureM = '>';
  2020. }
  2021. td.innerHTML = bbcode(donneesMonstre[7]);
  2022. var armM = 0;
  2023. try
  2024. {
  2025. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2026. }
  2027. catch(e)
  2028. {
  2029. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2030. modificateurArmure = '<';
  2031. }
  2032. var coeffSeuil = 0.95;
  2033. try
  2034. {
  2035. td.innerHTML = bbcode(donneesMonstre[9]);
  2036. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2037. var v = (rm / mm);
  2038. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2039. coeffSeuil = (200-seuil)/200;
  2040. }
  2041. catch(e)
  2042. {
  2043. modificateurMagie = '<';
  2044. pasDeSR = true;
  2045. }
  2046. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2047. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2048. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2049. // roule debug
  2050. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2051. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2052. 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);
  2053. //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);
  2054. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2055. if(getSortComp("Vampirisme")>0)
  2056. {
  2057. var pour = getSortComp("Vampirisme");
  2058. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2059. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2060. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2061. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2062. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2063. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2064. }
  2065. if(getSortComp("Botte Secrète")>0)
  2066. {
  2067. var pour = getSortComp("Botte Secrète");
  2068. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2069. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2070. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2071. 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;
  2072. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2073. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2074. }
  2075. if(getSortComp("Rafale Psychique")>0)
  2076. {
  2077. var pour = getSortComp("Rafale Psychique");
  2078. chanceDEsquiveParfaite = 0;
  2079. chanceDeTouche = Math.round(100*pour/100);
  2080. chanceDeCritique = Math.round(0*pour/100);
  2081. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2082. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2083. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2084. }
  2085. if(getSortComp("Explosion")>0)
  2086. {
  2087. var pour = getSortComp("Explosion");
  2088. chanceDEsquiveParfaite = 0;
  2089. chanceDeTouche = Math.round(100*pour/100);
  2090. chanceDeCritique = Math.round(0*pour/100);
  2091. 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;
  2092. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2093. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2094. }
  2095. if(getSortComp("Projectile Magique")>0)
  2096. {
  2097. var pour = getSortComp("Projectile Magique");
  2098. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2099. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2100. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2101. 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;
  2102. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2103. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2104. }
  2105. if(getSortComp("Frénésie")>0)
  2106. {
  2107. var pour = getSortComp("Frénésie");
  2108. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2109. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2110. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2111. 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;
  2112. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2113. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2114. }
  2115. if(getSortComp("Charger")>0)
  2116. {
  2117. var pour = getSortComp("Charger");
  2118. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2119. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2120. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2121. 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;
  2122. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2123. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2124. }
  2125. if(getSortComp("Griffe du Sorcier")>0)
  2126. {
  2127. var pour = getSortComp("Griffe du Sorcier");
  2128. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2129. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2130. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2131. 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;
  2132. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2133. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2134. }
  2135. if(getSortComp("Attaque Précise",1)>0)
  2136. {
  2137. var niveau = 5;
  2138. var oldPour = 0;
  2139. var chanceDEsquiveParfaite = 0;
  2140. var chanceDeTouche = 0;
  2141. var chanceDeCritique = 0;
  2142. degats = 0;
  2143. while(niveau>0)
  2144. {
  2145. var pour = getSortComp("Attaque Précise",niveau);
  2146. if(pour>oldPour)
  2147. {
  2148. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2149. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2150. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2151. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2152. chanceDeTouche += chanceDeToucheNiveau;
  2153. chanceDeCritique += chanceDeCritiqueNiveau;
  2154. 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);
  2155. oldPour = pour;
  2156. }
  2157. niveau--;
  2158. }
  2159. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2160. 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));
  2161. }
  2162. if(getSortComp("Coup de Butoir",1)>0)
  2163. {
  2164. var niveau = 5;
  2165. var oldPour =0;
  2166. var chanceDEsquiveParfaite = 0;
  2167. var chanceDeTouche=0;
  2168. var chanceDeCritique=0;
  2169. degats=0;
  2170. while(niveau>0)
  2171. {
  2172. var pour = getSortComp("Coup de Butoir",niveau);
  2173. if(pour>oldPour)
  2174. {
  2175. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2176. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2177. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2178. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2179. chanceDeTouche += chanceDeToucheNiveau;
  2180. chanceDeCritique += chanceDeCritiqueNiveau;
  2181. 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);
  2182. oldPour = pour;
  2183. }
  2184. niveau--;
  2185. }
  2186. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2187. 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));
  2188. }
  2189. 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;});
  2190. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2191. {
  2192. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2193. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2194. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2195. }
  2196. else
  2197. {
  2198. chanceDEsquiveParfaite = 0;
  2199. chanceDeTouche = 100;
  2200. chanceDeCritique = 0;
  2201. }
  2202. 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;
  2203.  
  2204. 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));
  2205. return listeAttaques;
  2206. }
  2207. catch(e) { window.alert(e);}
  2208. }
  2209.  
  2210. // x~~x marque pour s'y retrouver sous l'éditeur
  2211.  
  2212. /*
  2213. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2214. * published under GNU License v2.
  2215. *
  2216. * Patch :
  2217. * gestion des missions terminées
  2218. */
  2219. // x~x mission_liste
  2220.  
  2221. function checkLesMimis() {
  2222. try {
  2223. var titresMimis = document.evaluate(
  2224. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2225. document, null, 7, null
  2226. );
  2227. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2228. } catch(e) {
  2229. window.console.error('[MZ mission_liste] Erreur initialisation:\n'+e);
  2230. return;
  2231. }
  2232. var enCours = {};
  2233. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2234. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2235. enCours[num] = true;
  2236. }
  2237. for(var numMimi in obMissions) {
  2238. if(!enCours[numMimi]) {
  2239. delete obMissions[numMimi];
  2240. }
  2241. }
  2242. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2243. }
  2244.  
  2245. function do_mission_liste() {
  2246. checkLesMimis();
  2247. }
  2248.  
  2249. /*******************************************************************************
  2250. * This file is part of Mountyzilla. *
  2251. * *
  2252. * Mountyzilla is free software; you can redistribute it and/or modify *
  2253. * it under the terms of the GNU General Public License as published by *
  2254. * the Free Software Foundation; either version 2 of the License, or *
  2255. * (at your option) any later version. *
  2256. * *
  2257. * Mountyzilla is distributed in the hope that it will be useful, *
  2258. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2259. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2260. * GNU General Public License for more details. *
  2261. * *
  2262. * You should have received a copy of the GNU General Public License *
  2263. * along with Mountyzilla; if not, write to the Free Software *
  2264. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2265. *******************************************************************************/
  2266.  
  2267. // x~x actions
  2268.  
  2269. /* TODO
  2270. * getLvl pour Explo, Rotobaffe et cie
  2271. */
  2272.  
  2273.  
  2274.  
  2275. /* Page de combat */
  2276.  
  2277. function getLevel() {
  2278. var divList = document.getElementsByTagName('div');
  2279. if(divList.length <= 2)
  2280. return;
  2281. // On essaie de voir si cette action était une attaque
  2282. var pList = document.getElementsByTagName('p');
  2283. var nomM = '';
  2284. // Modification pour Frénésie by TetDure
  2285. var numAtt = 0;
  2286. for (var i = 0; i < pList.length; i++) {
  2287. if(pList[i].firstChild) {
  2288. nomM = pList[i].firstChild.nodeValue;
  2289. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2290. numAtt++;
  2291. }
  2292. }
  2293. if(nomM == '')
  2294. return;
  2295. // Si c'est une attaque normale, un seul PX
  2296. var comPX = 1;
  2297. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2298. comPX++;
  2299.  
  2300. // Extraction des infos du monstre attaqué
  2301. var idM;
  2302. var male;
  2303. if(nomM.slice(20, 21) == 'e') {
  2304. male = false;
  2305. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2306. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2307. }
  2308. else {
  2309. male = true;
  2310. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2311. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2312. }
  2313. if(idM == '')
  2314. return;
  2315. var bList = document.getElementsByTagName('b');
  2316. var niveau = '';
  2317. for (var i = 0; i < bList.length; i++) {
  2318. var b = bList[i];
  2319. if(b.childNodes[0].nodeValue != "TUÉ")
  2320. continue;
  2321. var nbPX = "";
  2322. for (i++; i < bList.length; i++) {
  2323. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2324. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2325. return;
  2326. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2327. nbPX = bList[i].childNodes[0].nodeValue;
  2328. break;
  2329. }
  2330. }
  2331. if(nbPX == '')
  2332. return;
  2333. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2334. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2335. if(!nbPX)
  2336. nbPX = 0;
  2337. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2338. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2339. if(comPX > nbPX) {
  2340. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2341. niveau = "";
  2342. } else if(Math.floor(niveau) == niveau) {
  2343. chaine += niveau + ".";
  2344. } else {
  2345. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2346. niveau = "";
  2347. }
  2348. insertBr(b.nextSibling.nextSibling.nextSibling);
  2349. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2350. }
  2351.  
  2352. if(niveau != '') {
  2353. var button = insertButtonCdm('as_Action');
  2354. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2355. + escape(nomM) + "&niveau=" + escape(niveau)
  2356. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2357. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2358. }
  2359. }
  2360.  
  2361.  
  2362. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2363.  
  2364. function insertInfoMagie(node, intitule, magie) {
  2365. if(node.nextSibling) {
  2366. node = node.nextSibling;
  2367. insertBr(node);
  2368. insertText(node, intitule);
  2369. insertText(node, magie, true);
  2370. } else {
  2371. node = node.parentNode;
  2372. appendBr(node);
  2373. appendText(node, intitule);
  2374. appendText(node, magie, true);
  2375. }
  2376. }
  2377.  
  2378. function getMM(sr) {
  2379. if(rmTroll<=0) {
  2380. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2381. }
  2382. sr = Number(sr.match(/\d+/)[0]);
  2383. if(sr==10) {
  2384. return '\u2265 '+5*rmTroll;
  2385. }
  2386. if(sr<=50) {
  2387. return Math.round(50*rmTroll/sr);
  2388. }
  2389. if(sr<90) {
  2390. return Math.round((100-sr)*rmTroll/50);
  2391. }
  2392. return '\u2264 '+Math.round(rmTroll/5);
  2393. }
  2394.  
  2395. function traiteMM() {
  2396. var node = document.evaluate(
  2397. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2398. document, null, 9, null).singleNodeValue;
  2399. if(node) {
  2400. var mm = getMM(node.nodeValue);
  2401. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2402. } else {
  2403. var node = document.evaluate(
  2404. "//p/text()[contains(., 'Seuil de Résistance')]",
  2405. document, null, 9, null).singleNodeValue;
  2406. if(!node) {
  2407. return;
  2408. }
  2409. var mm = getMM(node.nodeValue);
  2410. node = node.nextSibling.nextSibling;
  2411. }
  2412. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2413. }
  2414.  
  2415. function getRM(sr) {
  2416. if(mmTroll<=0) {
  2417. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2418. }
  2419. sr = Number(sr.match(/\d+/)[0]);
  2420. if(sr==10) {
  2421. return '\u2264 '+Math.round(mmTroll/5);
  2422. }
  2423. if(sr<=50) {
  2424. return Math.round(sr*mmTroll/50);
  2425. }
  2426. if(sr<90) {
  2427. return Math.round(50*mmTroll/(100-sr));
  2428. }
  2429. return '\u2265 '+5*mmTroll;
  2430. }
  2431.  
  2432. function traiteRM() {
  2433. var nodes = document.evaluate(
  2434. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2435. document, null, 7, null);
  2436. if(nodes.snapshotLength==0) {
  2437. return;
  2438. }
  2439. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2440. var node = nodes.snapshotItem(i);
  2441. var rm = getRM(node.nodeValue);
  2442. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2443. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2444. }
  2445. }
  2446.  
  2447.  
  2448. /* Fonction stats IdT par Raistlin */
  2449. /*function getIdt() {
  2450. if(MY_getValue("SEND_IDT") == "non")
  2451. return false;
  2452. var regExpBeginning = /^\s+/;
  2453. var regExpEnd = /\s+$/;
  2454.  
  2455. var nomIdt = document.evaluate(
  2456. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2457. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2458. if(!nomIdt)
  2459. return false;
  2460.  
  2461. var caracIdt;
  2462. if(nomIdt.indexOf("Malédiction !") != -1) {
  2463. caracIdt = "";
  2464. nomIdt = "Mission maudite";
  2465. } else {
  2466. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2467. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2468. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2469. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2470. }
  2471. FF_XMLHttpRequest({
  2472. method: 'GET',
  2473. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2474. headers : {
  2475. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2476. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2477. }
  2478. });
  2479. return true;
  2480. }*/
  2481.  
  2482.  
  2483. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2484.  
  2485. function confirmeDecalage() {
  2486. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2487. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2488. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2489. var newDLA = new Date( oldDLA );
  2490. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2491. return window.confirm(
  2492. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2493. +'\nConfirmez-vous ce décalage ?'
  2494. );
  2495. }
  2496.  
  2497. function newsubmitDLA(evt) {
  2498. evt.stopPropagation();
  2499. evt.preventDefault();
  2500. if(confirmeDecalage()) {
  2501. this.submit();
  2502. }
  2503. }
  2504.  
  2505. function changeActionDecalage() {
  2506. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2507. return;
  2508. }
  2509. try {
  2510. // On récupère le contenu du script JS MH de calcul du décalage
  2511. var scriptTxt = document.evaluate(
  2512. ".//script[ not(@src) ]",
  2513. document, null, 9, null
  2514. ).singleNodeValue.textContent;
  2515. // On en extrait la DLA courante
  2516. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2517. scriptTxt = scriptTxt.split('\n')[0];
  2518. var nbs = scriptTxt.match(/\d+/g);
  2519. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2520. } catch(e) {
  2521. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2522. window.console.error('[changeActionDecalage] DLA non trouvée',e);
  2523. return;
  2524. }
  2525. var form = document.getElementsByName('ActionForm')[0];
  2526. if(form) {
  2527. form.addEventListener('submit', newsubmitDLA, true);
  2528. } else {
  2529. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2530. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2531. }
  2532. }
  2533.  
  2534. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2535.  
  2536. function prochainMundi() {
  2537. try {
  2538. var node = document.evaluate(
  2539. "//div[@class='dateAction']/b",
  2540. document, null, 9, null
  2541. ).singleNodeValue;
  2542. } catch(e) {
  2543. window.console.error('[prochainMundi] Date introuvable',e);
  2544. return;
  2545. }
  2546. if(!node) { return; }
  2547.  
  2548. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2549. var jour = longueurMois+1-getNumber(node.textContent);
  2550. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2551. var txt = '[Prochain Mundidey ';
  2552. if(jour>1) {
  2553. txt += 'dans '+jour+' jours]';
  2554. } else {
  2555. txt += 'demain]';
  2556. }
  2557. insertText(node.parentNode.nextSibling,txt,true);
  2558. }
  2559.  
  2560.  
  2561. /* Fonction principale */
  2562.  
  2563. function dispatch() {
  2564. if(isPage('MH_Play/Play_action')) {
  2565. prochainMundi();
  2566. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2567. var oldDLA;
  2568. changeActionDecalage();
  2569. } else if(isPage('MH_Play/Actions')) {
  2570. if(document.evaluate(
  2571. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  2572. document, null, 2, null
  2573. ).stringValue) {
  2574. traiteMM();
  2575. } else if(document.evaluate(
  2576. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  2577. document, null, 2, null
  2578. ).stringValue) {
  2579. //getIdt();
  2580. traiteRM();
  2581. } /*else {
  2582. // Est censé se lancer sur quoi *précisément* ?
  2583. traiteRM();
  2584. getLevel();
  2585. }*/
  2586. } else {
  2587. /* Traitement des messages du bot */
  2588. var messageTitle = document.evaluate(
  2589. "//form/table/tbody/tr[1]/td[1]/"
  2590. +"descendant::text()[contains(.,'[MountyHall]')]",
  2591. document, null, 2, null
  2592. ).stringValue;
  2593. if(messageTitle.indexOf('Attaquant') != -1 &&
  2594. messageTitle.indexOf('sur') != -1) {
  2595. getLevel();
  2596. traiteRM();
  2597. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  2598. messageTitle.indexOf('Défenseur') != -1) {
  2599. traiteMM();
  2600. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  2601. // à replacer avec Attaque après révision getLvl :
  2602. messageTitle.indexOf('Explosion') != -1 ||
  2603. messageTitle.indexOf('Insulte') != -1) {
  2604. traiteRM();
  2605. }
  2606. }
  2607. }
  2608.  
  2609. function do_actions() {
  2610. start_script(31);
  2611. dispatch();
  2612. displayScriptTime();
  2613. }
  2614.  
  2615. /*********************************************************************************
  2616. * This file is part of Mountyzilla. *
  2617. * *
  2618. * Mountyzilla is free software; you can redistribute it and/or modify *
  2619. * it under the terms of the GNU General Public License as published by *
  2620. * the Free Software Foundation; either version 2 of the License, or *
  2621. * (at your option) any later version. *
  2622. * *
  2623. * Mountyzilla is distributed in the hope that it will be useful, *
  2624. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2625. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2626. * GNU General Public License for more details. *
  2627. * *
  2628. * You should have received a copy of the GNU General Public License *
  2629. * along with Mountyzilla; if not, write to the Free Software *
  2630. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2631. *********************************************************************************/
  2632.  
  2633. // x~x pre-enchant
  2634.  
  2635. /* 2013-08-19 : correction auto syntaxe alert */
  2636.  
  2637. var combobox=null;
  2638.  
  2639. function changeObject()
  2640. {
  2641. if(!combobox)
  2642. return ;
  2643. var id = combobox.options[combobox.selectedIndex].value;
  2644. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  2645. if(!id || id=="")
  2646. {
  2647. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2648. return;
  2649. }
  2650. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  2651. }
  2652.  
  2653. function treatePreEnchantement() {
  2654. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2655. if(!input || input.getAttribute("type")=="hidden")
  2656. {
  2657. return false;
  2658. }
  2659. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  2660. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2661. if(!combobox)
  2662. {
  2663. return true;
  2664. }
  2665. combobox.addEventListener('change', changeObject, true);
  2666. return true;
  2667. }
  2668.  
  2669. function treateEnchantement() {
  2670. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2671. if(!input || input.getAttribute("type")!="hidden")
  2672. {
  2673. return false;
  2674. }
  2675. var idEquipement = input.getAttribute("value");
  2676. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  2677. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  2678. if(enchanteur && enchanteur != null)
  2679. return true;
  2680. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2681. if(!input || input.getAttribute("type")!="hidden")
  2682. {
  2683. return false;
  2684. }
  2685. var idEnchanteur = input.getAttribute("value");
  2686. var nodes = document.evaluate(
  2687. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2688. if (nodes.snapshotLength != 3)
  2689. return;
  2690. for(var i=0;i<3;i++)
  2691. {
  2692. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2693. texte = texte.replace(" d'une "," d'un ");
  2694. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2695. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2696. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2697. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2698. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2699. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2700. }
  2701. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2702. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2703. var liste = MY_getValue(numTroll+".enchantement.liste");
  2704. if(!liste || liste=="")
  2705. {
  2706. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2707. }
  2708. else
  2709. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2710. }
  2711.  
  2712. function do_pre_enchant() {
  2713. start_script(60);
  2714. if(!treatePreEnchantement())
  2715. treateEnchantement();
  2716. displayScriptTime();
  2717. }
  2718.  
  2719. /*********************************************************************************
  2720. * This file is part of Mountyzilla. *
  2721. * *
  2722. * Mountyzilla is free software; you can redistribute it and/or modify *
  2723. * it under the terms of the GNU General Public License as published by *
  2724. * the Free Software Foundation; either version 2 of the License, or *
  2725. * (at your option) any later version. *
  2726. * *
  2727. * Mountyzilla is distributed in the hope that it will be useful, *
  2728. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2729. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2730. * GNU General Public License for more details. *
  2731. * *
  2732. * You should have received a copy of the GNU General Public License *
  2733. * along with Mountyzilla; if not, write to the Free Software *
  2734. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2735. *********************************************************************************/
  2736.  
  2737. // x~x enchant
  2738.  
  2739. /* 2013-08-19 : correction auto syntaxe alert */
  2740.  
  2741. function treateEnchantement() {
  2742. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  2743. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  2744. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  2745. return;
  2746. var tab = infoEquipement.split(";");
  2747. if(tab.length<2)
  2748. return;
  2749. var idEquipement = tab[0];
  2750. var nomEquipement = tab[1];
  2751. for(var i=2;i<tab.length;i++)
  2752. nomEquipement += ";"+tab[i];
  2753. var nodes = document.evaluate(
  2754. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2755. if (nodes.snapshotLength != 3)
  2756. return;
  2757. for(var i=0;i<3;i++)
  2758. {
  2759. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2760. texte = texte.replace(" d'une "," d'un ");
  2761. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2762. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2763. monstre = monstre.replace(/ Géante?/,"");
  2764. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2765. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2766. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2767. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2768. }
  2769. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2770. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2771. var liste = MY_getValue(numTroll+".enchantement.liste");
  2772. if(!liste || liste=="")
  2773. {
  2774. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2775. }
  2776. else
  2777. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2778. }
  2779.  
  2780. function do_enchant() {
  2781. start_script(60);
  2782.  
  2783. treateEnchantement();
  2784. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2785. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  2786. displayScriptTime();
  2787. }
  2788.  
  2789. /*********************************************************************************
  2790. * This file is part of Mountyzilla. *
  2791. * *
  2792. * Mountyzilla is free software; you can redistribute it and/or modify *
  2793. * it under the terms of the GNU General Public License as published by *
  2794. * the Free Software Foundation; either version 2 of the License, or *
  2795. * (at your option) any later version. *
  2796. * *
  2797. * Mountyzilla is distributed in the hope that it will be useful, *
  2798. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2799. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2800. * GNU General Public License for more details. *
  2801. * *
  2802. * You should have received a copy of the GNU General Public License *
  2803. * along with Mountyzilla; if not, write to the Free Software *
  2804. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2805. *********************************************************************************/
  2806.  
  2807. // x~x myevent
  2808.  
  2809. // Script désactivé en attendant la màj vers le nouveau système de missions.
  2810. function do_myevent() {
  2811. }
  2812.  
  2813. /*********************************************************************************
  2814. * This file is part of Mountyzilla. *
  2815. * *
  2816. * Mountyzilla is free software; you can redistribute it and/or modify *
  2817. * it under the terms of the GNU General Public License as published by *
  2818. * the Free Software Foundation; either version 2 of the License, or *
  2819. * (at your option) any later version. *
  2820. * *
  2821. * Mountyzilla is distributed in the hope that it will be useful, *
  2822. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2823. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2824. * GNU General Public License for more details. *
  2825. * *
  2826. * You should have received a copy of the GNU General Public License *
  2827. * along with Mountyzilla; if not, write to the Free Software *
  2828. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2829. *********************************************************************************/
  2830.  
  2831. // x~x malus
  2832.  
  2833. /* v1.4 - 2014-01-06
  2834. * - Gestion des sorts double composante
  2835. * v1.4.1 - 2014-01-22
  2836. * - Correction décumul
  2837. * TODO
  2838. * - Identifier la position de "PV" dans l'ordre MH
  2839. */
  2840.  
  2841. var listeBM;
  2842.  
  2843.  
  2844. /* [functions] Utilitaires */
  2845.  
  2846. function decumul(bmt,nbr) {
  2847. var bmr;
  2848. if(!nbr || nbr<2) bmr = bmt;
  2849. else if(nbr==2) bmr = parseInt(0.67*bmt);
  2850. else if(nbr==3) bmr = parseInt(0.40*bmt);
  2851. else if(nbr==4) bmr = parseInt(0.25*bmt);
  2852. else if(nbr==5) bmr = parseInt(0.15*bmt);
  2853. else bmr = parseInt(0.1*bmt);
  2854. if(bmt<0) return Math.min(-1,bmr);
  2855. return Math.max(1,bmr);
  2856. }
  2857.  
  2858. function triecaracs(a,b) { // version Yoyor, mod by Dab
  2859. // Roule 23/11/2016 ajout PV
  2860. switch( a ) {
  2861. case 'ATT':
  2862. return -1;
  2863. case 'ESQ':
  2864. if(b=='ATT') return 1;
  2865. return -1;
  2866. case 'DEG':
  2867. switch( b ) {
  2868. case 'ATT':
  2869. case 'ESQ':
  2870. return 1;
  2871. default:
  2872. return -1;
  2873. }
  2874. case 'REG':
  2875. switch( b ) {
  2876. case 'ATT':
  2877. case 'ESQ':
  2878. case 'DEG':
  2879. return 1;
  2880. default:
  2881. return -1;
  2882. }
  2883. case 'Vue':
  2884. switch( b ) {
  2885. case 'ATT':
  2886. case 'ESQ':
  2887. case 'DEG':
  2888. case 'REG':
  2889. return 1;
  2890. default:
  2891. return -1;
  2892. }
  2893. case 'TOUR':
  2894. switch( b ) {
  2895. case 'ATT':
  2896. case 'ESQ':
  2897. case 'DEG':
  2898. case 'REG':
  2899. case 'Vue':
  2900. return 1;
  2901. default:
  2902. return -1;
  2903. }
  2904. case 'PV':
  2905. switch( b ) {
  2906. case 'ATT':
  2907. case 'ESQ':
  2908. case 'DEG':
  2909. case 'REG':
  2910. case 'Vue':
  2911. case 'TOUR':
  2912. return 1;
  2913. default:
  2914. return -1;
  2915. }
  2916. case 'Armure':
  2917. switch( b ) {
  2918. case 'ATT':
  2919. case 'ESQ':
  2920. case 'DEG':
  2921. case 'REG':
  2922. case 'Vue':
  2923. case 'TOUR':
  2924. case 'PV':
  2925. return 1;
  2926. default:
  2927. return -1;
  2928. }
  2929. case 'RM':
  2930. switch( b ) {
  2931. case 'ATT':
  2932. case 'ESQ':
  2933. case 'DEG':
  2934. case 'REG':
  2935. case 'Vue':
  2936. case 'TOUR':
  2937. case 'PV':
  2938. case 'Armure':
  2939. return 1;
  2940. default:
  2941. return -1;
  2942. }
  2943. case 'MM':
  2944. switch( b ) {
  2945. case 'ATT':
  2946. case 'ESQ':
  2947. case 'DEG':
  2948. case 'REG':
  2949. case 'Vue':
  2950. case 'TOUR':
  2951. case 'PV':
  2952. case 'Armure':
  2953. case 'RM':
  2954. return 1;
  2955. default:
  2956. return -1;
  2957. }
  2958. case 'Concentration':
  2959. switch( b ) {
  2960. case 'ATT':
  2961. case 'ESQ':
  2962. case 'DEG':
  2963. case 'REG':
  2964. case 'Vue':
  2965. case 'TOUR':
  2966. case 'PV':
  2967. case 'Armure':
  2968. case 'RM':
  2969. case 'MM':
  2970. return 1;
  2971. default:
  2972. return -1;
  2973. }
  2974. case 'Fatigue':
  2975. switch( b ) {
  2976. case 'ATT':
  2977. case 'ESQ':
  2978. case 'DEG':
  2979. case 'REG':
  2980. case 'Vue':
  2981. case 'TOUR':
  2982. case 'PV':
  2983. case 'Armure':
  2984. case 'RM':
  2985. case 'MM':
  2986. case 'Concentration':
  2987. return 1;
  2988. default:
  2989. return -1;
  2990. }
  2991. case "Dés d'attaque":
  2992. switch( b ) {
  2993. case 'ATT':
  2994. case 'ESQ':
  2995. case 'DEG':
  2996. case 'REG':
  2997. case 'Vue':
  2998. case 'TOUR':
  2999. case 'PV':
  3000. case 'Armure':
  3001. case 'RM':
  3002. case 'MM':
  3003. case 'Concentration':
  3004. case 'Fatigue':
  3005. return 1;
  3006. default:
  3007. return -1;
  3008. }
  3009. case 'Dés de dégâts':
  3010. switch( b ) {
  3011. case 'ATT':
  3012. case 'ESQ':
  3013. case 'DEG':
  3014. case 'REG':
  3015. case 'Vue':
  3016. case 'TOUR':
  3017. case 'PV':
  3018. case 'Armure':
  3019. case 'RM':
  3020. case 'MM':
  3021. case 'Concentration':
  3022. case 'Fatigue':
  3023. case "Dés d'attaque":
  3024. return 1;
  3025. default:
  3026. return -1;
  3027. }
  3028. default :
  3029. switch( b ) {
  3030. case 'ATT':
  3031. case 'ESQ':
  3032. case 'DEG':
  3033. case 'REG':
  3034. case 'Vue':
  3035. case 'TOUR':
  3036. case 'PV':
  3037. case 'Armure':
  3038. case 'RM':
  3039. case 'MM':
  3040. case 'Concentration':
  3041. case 'Fatigue':
  3042. case "Dés d'attaque":
  3043. case 'Dés de dégâts':
  3044. return 1;
  3045. default:
  3046. return -1;
  3047. }
  3048. }
  3049. }
  3050.  
  3051.  
  3052. /* [functions] Fonctions hide / display */
  3053.  
  3054. function toggleDetailsBM() {
  3055. if(MY_getValue('BMDETAIL')!='false') {
  3056. MY_setValue('BMDETAIL','false');
  3057. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3058. for(var i=0 ; i<trlist.length ; i++)
  3059. trlist[i].style.display = 'none';
  3060. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3061. for(var i=0 ; i<trlist.length ; i++)
  3062. trlist[i].style = '';
  3063. }
  3064. else {
  3065. MY_setValue('BMDETAIL','true');
  3066. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3067. for(var i=0 ; i<trlist.length ; i++)
  3068. trlist[i].style.display = 'none';
  3069. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3070. for(var i=0 ; i<trlist.length ; i++)
  3071. trlist[i].style = '';
  3072. }
  3073. }
  3074.  
  3075. function toggleBMList() {
  3076. if(MY_getValue('BMHIDELIST')=='true') {
  3077. MY_setValue('BMHIDELIST','false');
  3078. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3079. listeBM.snapshotItem(i).style = '';
  3080. document.getElementsByTagName('thead')[0].style = '';
  3081. document.getElementById('trhelp').style = '';
  3082. }
  3083. else {
  3084. MY_setValue('BMHIDELIST','true');
  3085. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3086. listeBM.snapshotItem(i).style.display = 'none';
  3087. document.getElementsByTagName('thead')[0].style.display = 'none';
  3088. document.getElementById('trhelp').style.display = 'none';
  3089. }
  3090. }
  3091.  
  3092. function setDisplayBM() {
  3093. if(!listeBM) return;
  3094. var titre = document.getElementById('titre2');
  3095. if(titre) {
  3096. titre.style.cursor = 'pointer';
  3097. titre.onclick = toggleBMList;
  3098. }
  3099. var tfoot = document.getElementsByTagName('tfoot')[0];
  3100. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3101. tfoot, null, 9, null).singleNodeValue;
  3102. tr.id = 'trhelp';
  3103. if(MY_getValue('BMHIDELIST')=='true') {
  3104. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3105. listeBM.snapshotItem(i).style.display = 'none';
  3106. document.getElementsByTagName('thead')[0].style.display = 'none';
  3107. tr.style.display = 'none';
  3108. }
  3109. }
  3110.  
  3111.  
  3112. /* [functions] Fonction principale */
  3113.  
  3114. function traiteMalus() {
  3115. var mainTab = document.getElementsByTagName('table')[0];
  3116. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3117. if(listeBM.snapshotLength==0) return;
  3118. /* Suppression des BM de fatigue stockés */
  3119. if(MY_getValue(numTroll+'.bm.fatigue'))
  3120. MY_removeValue(numTroll+'.bm.fatigue');
  3121. /* Extraction des données */
  3122. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3123. var nb = 0;
  3124. while(nb<listeBM.snapshotLength) {
  3125. tr = listeBM.snapshotItem(nb); nb++;
  3126. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3127. var phymag = tr.childNodes[9].textContent;
  3128. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3129. var type = tr.childNodes[3].textContent, nom;
  3130. // si c'est un type à décumul
  3131. /*
  3132. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3133. switch(type) {
  3134. case 'Potion':
  3135. case 'Parchemin':
  3136. case 'Sortilège':
  3137. case 'Capacité Spéciale':
  3138. nom = tr.childNodes[1].textContent+phymag;
  3139. break;
  3140. default:
  3141. nom = 'pasdedecumul';
  3142. }
  3143. */
  3144. nom = tr.childNodes[1].textContent+phymag;
  3145. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3146. nom = 'pasdedecumul';
  3147. uniListe[nb] = {
  3148. 'duree':duree,
  3149. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3150. 'caracs':{}
  3151. }
  3152. for(var i=0 ; i<effetsT.length ; i++) {
  3153. if(effetsT[i].indexOf(':')==-1) continue;
  3154. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3155. // nom = 'pasdedecumul' si pas de décumul
  3156. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3157. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3158. uniListe[nb]['type'] = phymag;
  3159. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3160. uniListe[nb]['caracs'][carac] = bm;
  3161. listeDurees[duree] = true;
  3162. }
  3163. } // fin boucle sur les lignes de bonus/malus
  3164. /* Gestion des décumuls et cumuls des durées */
  3165. var toursGeres = [];
  3166. for(var d in listeDurees) toursGeres.push(d);
  3167. toursGeres.sort( function (a,b){return b-a;} );
  3168. // pour sauvegarder les bm de fatigue
  3169. var strfat = '';
  3170. // Pour affichage & adpatation à footable.js (statique)
  3171. var thead = document.getElementsByTagName('thead')[0];
  3172. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3173. thead, null, 7, null).snapshotLength;
  3174. var tfoot = document.getElementsByTagName('tfoot')[0];
  3175. for(var i=0 ; i<toursGeres.length ; i++) {
  3176. var tour = toursGeres[i];
  3177. var effetsCeTour = {}; decumulsCeTour = {};
  3178. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3179. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3180. continue;
  3181. var nom = uniListe[nb]['nom'];
  3182. if(nom!='pasdedecumul') {
  3183. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3184. decumulsCeTour[nom]++;
  3185. }
  3186. for(var carac in uniListe[nb]['caracs']) {
  3187. var bm = uniListe[nb]['caracs'][carac];
  3188. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3189. var type = uniListe[nb]['type'];
  3190. if(!effetsCeTour[carac])
  3191. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3192. if(nom=='pasdedecumul')
  3193. effetsCeTour[carac][type] += bm;
  3194. else
  3195. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  3196. } else {
  3197. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3198. var thisBm;
  3199. if(nom=='pasdedecumul' || carac=='Fatigue')
  3200. thisBm = bm;
  3201. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3202. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3203. else
  3204. thisBm = decumul(bm,decumulsCeTour[nom]);
  3205. effetsCeTour[carac] += thisBm;
  3206. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3207. }
  3208. } // fin boucle sur les caractéristiques
  3209. } // fin boucle sur les bonus/malus
  3210. /* Création du bilan du tour */
  3211. var texteD = '', texteS = '';
  3212. var caracGerees = [];
  3213. for(var k in effetsCeTour) caracGerees.push(k);
  3214. caracGerees.sort( triecaracs );
  3215. for(var j=0 ; j<caracGerees.length ; j++) {
  3216. var carac = caracGerees[j], str = '';
  3217. switch( carac ) {
  3218. case 'ATT':
  3219. case 'DEG':
  3220. case 'Armure':
  3221. var phy = effetsCeTour[carac]['Physique'];
  3222. var mag = effetsCeTour[carac]['Magie'];
  3223. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3224. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3225. break;
  3226. case 'TOUR':
  3227. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3228. break;
  3229. case 'Fatigue':
  3230. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3231. case 'PV':
  3232. case 'ESQ':
  3233. case 'REG':
  3234. case 'Vue':
  3235. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3236. break;
  3237. default:
  3238. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3239. }
  3240. if(str) {
  3241. texteD += str;
  3242. texteS += str;
  3243. }
  3244. } // fin boucle sur les caractéristiques
  3245. /* Affichage */
  3246. // Si rien à afficher on passe
  3247. if(!texteD) continue;
  3248. // Si BMM+BMP=0
  3249. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3250. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3251. if(MY_getValue('BMDETAIL')=='false')
  3252. tr.style.display = 'none';
  3253. var td = appendTdText(tr,texteD.substring(3));
  3254. td.colSpan = 5-nbHidden;
  3255. var txttour = toursGeres[i]+' Tour';
  3256. if(toursGeres[i]>1) txttour += 's';
  3257. appendTdText(tr,txttour);
  3258. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3259. if(MY_getValue('BMDETAIL')!='false')
  3260. tr.style.display = 'none';
  3261. td = appendTdText(tr,texteS);
  3262. td.colSpan = 5-nbHidden;
  3263. appendTdText(tr,txttour);
  3264. } // fin boucle sur les tours générés
  3265. /* mise en place toggleDetails */
  3266. tfoot.style.cursor = 'pointer';
  3267. tfoot.onclick = toggleDetailsBM;
  3268. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3269. if(strfat)
  3270. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3271. }
  3272.  
  3273. function do_malus() {
  3274. try {
  3275. start_script();
  3276. traiteMalus();
  3277. setDisplayBM();
  3278. displayScriptTime();
  3279. }
  3280. catch(e) {window.alert(e)};
  3281. }
  3282.  
  3283. /*******************************************************************************
  3284. * This file is part of Mountyzilla. *
  3285. * *
  3286. * Mountyzilla is free software; you can redistribute it and/or modify *
  3287. * it under the terms of the GNU General Public License as published by *
  3288. * the Free Software Foundation; either version 2 of the License, or *
  3289. * (at your option) any later version. *
  3290. * *
  3291. * Mountyzilla is distributed in the hope that it will be useful, *
  3292. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3293. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3294. * GNU General Public License for more details. *
  3295. * *
  3296. * You should have received a copy of the GNU General Public License *
  3297. * along with Mountyzilla; if not, write to the Free Software *
  3298. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3299. *******************************************************************************/
  3300.  
  3301. // x~x mouches
  3302.  
  3303. var mainTab, tr_mouches;
  3304.  
  3305. function initialiseMouches() {
  3306. // Lanceur global
  3307. try {
  3308. mainTab = document.getElementById('mouches');
  3309. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3310. } catch(e) {
  3311. avertissement('Erreur MZ:<br />Consulter la console.');
  3312. window.console.error('Erreur MZ mouches:\n'+e);
  3313. return;
  3314. }
  3315. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3316. setDisplayMouches();
  3317. traiteMouches();
  3318. }
  3319.  
  3320. function setDisplayMouches() {
  3321. // Initialise l'affichage / l'effacement du détail des mouches
  3322. var titre = document.getElementById('titre2');
  3323. if(titre) {
  3324. titre.style.cursor = 'pointer';
  3325. titre.onclick = toggleMouches;
  3326. }
  3327. var tfoot = document.getElementsByTagName('tfoot')[0];
  3328. if(tfoot) {
  3329. tfoot.style.cursor = 'pointer';
  3330. tfoot.onclick = toggleMouches;
  3331. }
  3332. if(MY_getValue('HIDEMOUCHES')=='true') {
  3333. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3334. tr_mouches.snapshotItem(i).style.display = 'none';
  3335. }
  3336. document.getElementsByTagName('thead')[0].style.display = 'none';
  3337. }
  3338. }
  3339.  
  3340. function toggleMouches() {
  3341. // Handler pour afficher / masquer les détasil
  3342. if(MY_getValue('HIDEMOUCHES')=='true') {
  3343. MY_setValue('HIDEMOUCHES','false');
  3344. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3345. tr_mouches.snapshotItem(i).style.display = '';
  3346. }
  3347. document.getElementsByTagName('thead')[0].style.display = '';
  3348. } else {
  3349. MY_setValue('HIDEMOUCHES','true');
  3350. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3351. tr_mouches.snapshotItem(i).style.display = 'none';
  3352. }
  3353. document.getElementsByTagName('thead')[0].style.display = 'none';
  3354. }
  3355. }
  3356.  
  3357. function traiteMouches() {
  3358. // Traitement complet: présence et effets des mouches
  3359. var listeTypes = {}, effetsActifs = {};
  3360. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3361. var tr = tr_mouches.snapshotItem(i);
  3362. // La mouche est-elle présente?
  3363. var etat = document.evaluate(
  3364. './img',
  3365. tr.cells[6], null, 9, null
  3366. ).singleNodeValue.alt;
  3367. if(etat!='La Mouche est là') { continue; }
  3368. // Extraction du type de mouche
  3369. var type = trim(tr.cells[3].textContent);
  3370. if(!listeTypes[type]) {
  3371. listeTypes[type] = 1;
  3372. } else {
  3373. listeTypes[type]++;
  3374. }
  3375. // La mouche a-t-elle un effet?
  3376. var effet = trim(tr.cells[2].textContent);
  3377. if(etat!='La Mouche est là' || !effet) { continue; }
  3378. // Si oui, extraction des effets (multiples pour pogées)
  3379. var caracs = effet.split(' | ');
  3380. for(var j=0 ; j<caracs.length ; j++) {
  3381. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3382. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3383. if(effetsActifs[carac]===void(0)) {
  3384. effetsActifs[carac] = valeur;
  3385. } else {
  3386. effetsActifs[carac] += valeur;
  3387. }
  3388. }
  3389. }
  3390. // Extraction Effet total et affichage des différences à la normale
  3391. var tfoot = document.getElementsByTagName('tfoot')[0];
  3392. if(!tfoot) { return; }
  3393. var nodeTotal = document.evaluate(
  3394. ".//b[contains(./text(),'Effet total')]",
  3395. tfoot, null, 9, null
  3396. ).singleNodeValue.nextSibling;
  3397. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3398. var texte = ' ';
  3399. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3400. if(texte.length>1) { texte += ' | '; }
  3401. var carac = trim(
  3402. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3403. );
  3404. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3405. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3406. texte += effetsTheoriques[i];
  3407. } else {
  3408. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3409. if(carac=='TOUR') { texte += ' min'; }
  3410. texte += '</b>';
  3411. }
  3412. }
  3413. var span = document.createElement('span');
  3414. span.innerHTML = texte;
  3415. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3416. // Affichage des différences du nombre de mouches de chaque type
  3417. var mouchesParType = document.evaluate(
  3418. "./tr/td/ul/li/text()",
  3419. tfoot, null, 7, null
  3420. );
  3421. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3422. var node = mouchesParType.snapshotItem(i);
  3423. var mots = node.nodeValue.split(' ');
  3424. var type = mots.pop();
  3425. if(!listeTypes[type]) {
  3426. node.nodeValue += ' (0 présente)';
  3427. } else if(mots[0]!=listeTypes[type]) {
  3428. if(listeTypes[type]==1) {
  3429. node.nodeValue += ' (1 présente)';
  3430. } else {
  3431. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3432. }
  3433. }
  3434. }
  3435. }
  3436.  
  3437. function do_mouches() {
  3438. start_script();
  3439. initialiseMouches();
  3440. displayScriptTime();
  3441. }
  3442.  
  3443. /*********************************************************************************
  3444. * This file is part of Mountyzilla. *
  3445. * *
  3446. * Mountyzilla is free software; you can redistribute it and/or modify *
  3447. * it under the terms of the GNU General Public License as published by *
  3448. * the Free Software Foundation; either version 2 of the License, or *
  3449. * (at your option) any later version. *
  3450. * *
  3451. * Mountyzilla is distributed in the hope that it will be useful, *
  3452. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3453. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3454. * GNU General Public License for more details. *
  3455. * *
  3456. * You should have received a copy of the GNU General Public License *
  3457. * along with Mountyzilla; if not, write to the Free Software *
  3458. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3459. *********************************************************************************/
  3460.  
  3461. // x~x equipgowap
  3462.  
  3463. var popup;
  3464.  
  3465. function initPopupEquipgowap() {
  3466. popup = document.createElement('div');
  3467. popup.setAttribute('id', 'popup');
  3468. popup.setAttribute('class', 'mh_textbox');
  3469. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3470. 'display: inline; z-index: 3; max-width: 400px;');
  3471. document.body.appendChild(popup);
  3472. }
  3473.  
  3474. function showPopupEquipgowap(evt) {
  3475. var texte = this.getAttribute("texteinfo");
  3476. popup.innerHTML = texte;
  3477. popup.style.left = evt.pageX + 15 + 'px';
  3478. popup.style.top = evt.pageY + 'px';
  3479. popup.style.visibility = "visible";
  3480. }
  3481.  
  3482. function hidePopup() {
  3483. popup.style.visibility = "hidden";
  3484. }
  3485.  
  3486. function createPopupImage(url, text)
  3487. {
  3488. var img = document.createElement('img');
  3489. img.setAttribute('src',url);
  3490. img.setAttribute('align','ABSMIDDLE');
  3491. img.setAttribute("texteinfo",text);
  3492. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3493. img.addEventListener("mouseout", hidePopup,true);
  3494. return img;
  3495. }
  3496.  
  3497. function formateTexte(texte)
  3498. {
  3499. texte = texte.replace(/\n/g,"<br/>");
  3500. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3501. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3502. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3503. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3504. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3505. return texte;
  3506. }
  3507.  
  3508.  
  3509. function treateGowaps() {
  3510. //On récupère les gowaps possédants des composants
  3511. var tbodys = document.evaluate(
  3512. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3513. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3514. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3515. var tbody = tbodys.snapshotItem(j);
  3516. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3517. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3518. if(MY_getValue("NOINFOEM") != "true")
  3519. insertEMInfos(tbody);
  3520. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3521. insertEnchantInfos(tbody);
  3522. }
  3523. }
  3524.  
  3525. function treateChampi() {
  3526. if(MY_getValue("NOINFOEM") == "true")
  3527. return false;
  3528. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3529. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3530. if (nodes.snapshotLength == 0)
  3531. return false;
  3532.  
  3533. for (var i = 0; i < nodes.snapshotLength; i++) {
  3534. var node = nodes.snapshotItem(i);
  3535. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3536. if(texte.indexOf("*")!=-1)
  3537. texte = texte.substring(0,texte.lastIndexOf(" "));
  3538. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3539. if(moisChampi[nomChampi])
  3540. {
  3541. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3542. }
  3543. }
  3544. }
  3545.  
  3546. function do_equipgowap() {
  3547. start_script();
  3548.  
  3549. treateGowaps();
  3550. treateChampi();
  3551. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3552. {
  3553. initPopupEquipgowap();
  3554. computeEnchantementEquipement(createPopupImage,formateTexte);
  3555. }
  3556.  
  3557. displayScriptTime();
  3558. }
  3559.  
  3560. /*********************************************************************************
  3561. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3562. *********************************************************************************/
  3563.  
  3564. // x~x ordresgowap
  3565.  
  3566. /* v0.2 by Dab - 2013-08-31
  3567. * - correction acquisition posale initiale
  3568. * - correction tare et affichage mire
  3569. */
  3570.  
  3571. function setCarteGogo() {
  3572. try {
  3573. //var pars = document.getElementsByTagName('p');
  3574. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3575. var eTitle = document.getElementById('titre2');
  3576. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3577. var serv_img_trou = URL_MZimg + "carte_trou.png";
  3578. var serv_img_cible = URL_MZimg + "rep.png";
  3579.  
  3580. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  3581. //var lignes = pars[0].getElementsByTagName('tr');
  3582. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  3583. var nbpt = 0;
  3584. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  3585. for(var i=0 ; i<lignes.length ; i++) {
  3586. if(lignes[i].className == 'mh_tdpage_fo') {
  3587. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  3588. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  3589. if(point) {
  3590. nbpt++;
  3591. trajet += point[1]+','+point[2]+','+point[3]+',';
  3592. }
  3593. }
  3594. }
  3595. }
  3596. catch(e) {window.console.log('[MZ] setCarteGogo() impossible de trouver les ordres,' + e); return;}
  3597. 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'/>";
  3598. var base = [-229,-5];
  3599. if (nbpt>0) {
  3600. base = [-684,-5];
  3601. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  3602. }
  3603. 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;'/>";
  3604.  
  3605. 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>';
  3606.  
  3607. var nvspan = document.createElement('div');
  3608. nvspan.align = 'center';
  3609. nvspan.id = 'mz_mapdiv';
  3610. nvspan.valign = 'top';
  3611. nvspan.innerHTML = nvdiv;
  3612. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  3613. var footer = document.getElementById('footer1');
  3614. footer.parentNode.insertBefore(nvspan,footer);
  3615. }
  3616.  
  3617. function do_ordresgowap() {
  3618. setCarteGogo(); // Via script des trouillots
  3619. }
  3620.  
  3621. /*********************************************************************************
  3622. * This file is part of Mountyzilla. *
  3623. * *
  3624. * Mountyzilla is free software; you can redistribute it and/or modify *
  3625. * it under the terms of the GNU General Public License as published by *
  3626. * the Free Software Foundation; either version 2 of the License, or *
  3627. * (at your option) any later version. *
  3628. * *
  3629. * Mountyzilla is distributed in the hope that it will be useful, *
  3630. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3631. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3632. * GNU General Public License for more details. *
  3633. * *
  3634. * You should have received a copy of the GNU General Public License *
  3635. * along with Mountyzilla; if not, write to the Free Software *
  3636. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3637. *********************************************************************************/
  3638.  
  3639. // x~x attaque
  3640.  
  3641. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3642.  
  3643. function do_attaque() {
  3644. }
  3645.  
  3646. /*******************************************************************************
  3647. * This file is part of Mountyzilla. *
  3648. * *
  3649. * Mountyzilla is free software; you can redistribute it and/or modify *
  3650. * it under the terms of the GNU General Public License as published by *
  3651. * the Free Software Foundation; either version 2 of the License, or *
  3652. * (at your option) any later version. *
  3653. * *
  3654. * Mountyzilla is distributed in the hope that it will be useful, *
  3655. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3656. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3657. * GNU General Public License for more details. *
  3658. * *
  3659. * You should have received a copy of the GNU General Public License *
  3660. * along with Mountyzilla; if not, write to the Free Software *
  3661. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3662. *******************************************************************************/
  3663.  
  3664. // x~x infomonstre
  3665.  
  3666. // DEBUG
  3667. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  3668. // À corriger, évidemment.
  3669. var listeCDM = {};
  3670. var nomMonstre='';
  3671. var idMonstre=-1;
  3672. var tbody;
  3673. var popup;
  3674.  
  3675. function traiteMonstre() {
  3676. try {
  3677. var nodeTitre = document.evaluate(
  3678. "//div[@class='titre2' and contains(text(),'(')]",
  3679. document, null, 9, null
  3680. ).singleNodeValue;
  3681. var texte = nodeTitre.firstChild.nodeValue;
  3682. } catch(e) {
  3683. window.console.log(e);
  3684. return;
  3685. }
  3686. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  3687. if(nomMonstre.indexOf(']')!=-1) {
  3688. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  3689. }
  3690. idMonstre = texte.match(/\d+/)[0];
  3691. FF_XMLHttpRequest({
  3692. method: 'GET',
  3693. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  3694. +MY_getValue('CDMID')
  3695. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  3696. headers : {
  3697. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3698. 'Accept': 'application/atom+xml,application/xml,text/xml'
  3699. },
  3700. onload: function(responseDetails) {
  3701. try {
  3702. var texte = responseDetails.responseText;
  3703. var lines = texte.split("\n");
  3704. if(lines.length>=1) {
  3705. var infos = lines[0].split(";");
  3706. if(infos.length<4) { return; }
  3707. var idMonstre = infos[0];
  3708. infos=infos.slice(3);
  3709. listeCDM[idMonstre]=infos;
  3710. computeMissionInfomonstre();
  3711. }
  3712. } catch(e) {
  3713. window.alert(e);
  3714. }
  3715. }
  3716. });
  3717. }
  3718.  
  3719. function initPopupInfomonstre() {
  3720. // Initialise le popup tactique (calculs att/deg)
  3721. popup = document.createElement('div');
  3722. popup.id = 'popup';
  3723. popup.className = 'mh_textbox';
  3724. popup.style =
  3725. 'position: absolute;'+
  3726. 'border: 1px solid #000000;'+
  3727. 'visibility: hidden;'+
  3728. 'display: inline;'+
  3729. 'z-index: 3;'+
  3730. 'max-width: 400px;';
  3731. document.body.appendChild(popup);
  3732. }
  3733.  
  3734. function showPopupTactique(evt) {
  3735. try {
  3736. var id = this.id;
  3737. var nom = this.nom;
  3738. var texte = getAnalyseTactique(id,nom);
  3739. if(texte=='') { return; }
  3740. popup.innerHTML = texte;
  3741. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  3742. if(isPage("View/MonsterView")) {
  3743. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  3744. } else {
  3745. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  3746. }
  3747. popup.style.top = evt.pageY+15+'px';
  3748. popup.style.visibility = 'visible';
  3749. } catch(e) {
  3750. window.alert(e);
  3751. }
  3752. }
  3753.  
  3754. // roule 16/03/2016, existe déjà ailleurs
  3755. // function hidePopup() {
  3756. // popup.style.visibility = 'hidden';
  3757. // }
  3758.  
  3759. function toggleTableau() {
  3760. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  3761. }
  3762.  
  3763. function computeMissionInfomonstre() {
  3764. // C'est quoi ce titre de fonction ? (O_o)
  3765. try {
  3766. var nodeInsert = document.evaluate(
  3767. "//div[@class = 'titre3']",
  3768. document, null, 9, null
  3769. ).singleNodeValue;
  3770. } catch(e) {
  3771. window.console.log(e);
  3772. return;
  3773. }
  3774. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  3775. table.align = 'center';
  3776. tbody = table.childNodes[1];
  3777. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  3778. table.firstChild.firstChild.onmouseover = function() {
  3779. this.style.cursor = 'pointer';
  3780. this.className = 'mh_tdpage';
  3781. };
  3782. table.firstChild.firstChild.onmouseout = function() {
  3783. this.className = 'mh_tdtitre';
  3784. };
  3785. tbody.style.display = 'none';
  3786. table.style.width = '350px';
  3787. insertBefore(nodeInsert,table);
  3788. }
  3789.  
  3790. function do_infomonstre() {
  3791. start_script();
  3792. try {
  3793. initPopupInfomonstre();
  3794. traiteMonstre();
  3795. } catch(e) {
  3796. window.alert('Erreur infoMonstre:\n'+e);
  3797. }
  3798. displayScriptTime();
  3799. }
  3800.  
  3801. /*******************************************************************************
  3802. * This file is part of Mountyzilla. *
  3803. * *
  3804. * Mountyzilla is free software; you can redistribute it and/or modify *
  3805. * it under the terms of the GNU General Public License as published by *
  3806. * the Free Software Foundation; either version 2 of the License, or *
  3807. * (at your option) any later version. *
  3808. * *
  3809. * Mountyzilla is distributed in the hope that it will be useful, *
  3810. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3811. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3812. * GNU General Public License for more details. *
  3813. * *
  3814. * You should have received a copy of the GNU General Public License *
  3815. * along with Mountyzilla; if not, write to the Free Software *
  3816. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3817. *******************************************************************************/
  3818.  
  3819. // x~x mission
  3820.  
  3821. /* TODO
  3822. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  3823. *
  3824. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  3825. */
  3826.  
  3827. function saveMission(num,obEtape) {
  3828. var obMissions = {};
  3829. if(MY_getValue(numTroll+'.MISSIONS')) {
  3830. try {
  3831. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3832. } catch(e) {
  3833. window.console.error('[MZ Mission] Erreur parsage:\n'+e);
  3834. return;
  3835. }
  3836. }
  3837. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  3838. if(obEtape) {
  3839. obMissions[num] = obEtape;
  3840. } else if(obMissions[num]) {
  3841. delete obMissions[num];
  3842. }
  3843. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3844. }
  3845.  
  3846. function traiteMission() {
  3847. try {
  3848. var titreMission = document.getElementsByClassName('titre2')[0];
  3849. var numMission = titreMission.textContent.match(/\d+/)[0];
  3850. var missionForm = document.getElementsByName('ActionForm')[0];
  3851. var tdLibelle = document.evaluate(
  3852. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  3853. missionForm, null, 9, null).singleNodeValue;
  3854. } catch(e) {
  3855. window.console.error('[MZ Mission] Erreur récupération mission:\n'+e);
  3856. return;
  3857. }
  3858. if(!numMission) { return; }
  3859. try {
  3860. if(!tdLibelle) {
  3861. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  3862. saveMission(numMission,false);
  3863. return;
  3864. }
  3865.  
  3866. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  3867. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  3868. // debug Roule'
  3869. //for (var i =0; i < tdLibelle.childNodes.length; i++) window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  3870. if(libelle.indexOf('niveau égal à')!=-1) {
  3871. var nbKills = 1, niveau, mod;
  3872. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  3873. // Étape de kill multiple de niveau donné
  3874. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3875. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  3876. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3877. niveau = Number(mod[0]);
  3878. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3879. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  3880. } else {
  3881. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  3882. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3883. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  3884. mod = mod ? Number(mod[0]) : 'plus';
  3885. }
  3886. } else {
  3887. // Étape de kill unique de niveau donné
  3888. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  3889. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3890. mod = mod ? Number(mod[0]) : 'plus';
  3891. }
  3892. // debug Roule'
  3893. //window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + ', libelle=' + libelle);
  3894. saveMission(numMission,{
  3895. type: 'Niveau',
  3896. niveau: niveau,
  3897. mod: mod,
  3898. mundidey: siMundidey,
  3899. libelle: libelle
  3900. });
  3901. } else if(libelle.indexOf('de la race')!=-1) {
  3902. var nbKills = 1, race;
  3903. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  3904. // Étape de kill multiple de race donnée
  3905. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3906. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  3907. } else {
  3908. // Étape de kill unique de race donnée
  3909. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3910. }
  3911. saveMission(numMission,{
  3912. type: 'Race',
  3913. race: race.replace(/\"/g,''),
  3914. mundidey: siMundidey,
  3915. libelle: libelle
  3916. });
  3917. } else if(libelle.indexOf('de la famille')!=-1) {
  3918. var nbKills = 1, famille;
  3919. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  3920. // Étape de kill multiple de famille donnée
  3921. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3922. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  3923. } else {
  3924. // Étape de kill unique de famille donnée
  3925. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3926. }
  3927. saveMission(numMission,{
  3928. type: 'Famille',
  3929. famille: famille,
  3930. mundidey: siMundidey,
  3931. libelle: libelle
  3932. });
  3933. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  3934. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  3935. saveMission(numMission,{
  3936. type: 'Pouvoir',
  3937. pouvoir: pouvoir,
  3938. libelle: libelle
  3939. });
  3940. } else {
  3941. saveMission(numMission,false);
  3942. }
  3943. } catch(e) {
  3944. window.console.error('[MZ Mission] Erreur récupération étape mission:\n'+e);
  3945. return;
  3946. }
  3947. }
  3948.  
  3949. function do_mission() {
  3950. start_script(60);
  3951.  
  3952. traiteMission();
  3953.  
  3954. displayScriptTime();
  3955. }
  3956.  
  3957. /*******************************************************************************
  3958. * This file is part of Mountyzilla. *
  3959. * *
  3960. * Mountyzilla is free software; you can redistribute it and/or modify *
  3961. * it under the terms of the GNU General Public License as published by *
  3962. * the Free Software Foundation; either version 2 of the License, or *
  3963. * (at your option) any later version. *
  3964. * *
  3965. * Mountyzilla is distributed in the hope that it will be useful, *
  3966. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3967. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3968. * GNU General Public License for more details. *
  3969. * *
  3970. * You should have received a copy of the GNU General Public License *
  3971. * along with Mountyzilla; if not, write to the Free Software *
  3972. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3973. *******************************************************************************/
  3974.  
  3975. // x~x move
  3976.  
  3977. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  3978.  
  3979. var petitsTrous = {
  3980. '-52;57': true,
  3981. '55;70': true,
  3982. '64;70': true,
  3983. '12;-15': true,
  3984. '30;-52': true,
  3985. '48;-39': true
  3986. };
  3987.  
  3988. var grosTrous = {
  3989. '-35;65': true,
  3990. '-13;73': true,
  3991. '-64;9': true,
  3992. '-35;15': true,
  3993. '5;32': true,
  3994. '10;64': true,
  3995. '21;36': true,
  3996. '46;52': true,
  3997. '74;32': true,
  3998. '-71;-7': true,
  3999. '-67;-37': true,
  4000. '-60;-32': true,
  4001. '-51;-22': true,
  4002. '-36;-51': true,
  4003. '5;-49': true
  4004. };
  4005.  
  4006. var centreCarmine_X = 56.5;
  4007. var centreCarmine_Y = 23.5;
  4008. var rayonCarmine = 8.7;
  4009.  
  4010. function isTrou(x,y,n) {
  4011. if(petitsTrous[x+';'+y]) {
  4012. return n<0 && n>-60;
  4013. }
  4014. if(grosTrous[x+';'+y]
  4015. || grosTrous[x-1+';'+y]
  4016. || grosTrous[x+';'+y+1]
  4017. || grosTrous[x-1+';'+y+1]) {
  4018. return n<0 && n>-70;
  4019. }
  4020. if(Math.sqrt(
  4021. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4022. )<=rayonCarmine) {
  4023. return n<0 && n>-100;
  4024. }
  4025. return false;
  4026. }
  4027.  
  4028. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4029.  
  4030. function validateDestination() {
  4031. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4032. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4033. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4034. var form = document.getElementsByName('ActionForm')[0];
  4035. if(form) {
  4036. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4037. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4038. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4039. }
  4040. }
  4041. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4042. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4043. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4044. }
  4045. }
  4046. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4047. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4048. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4049. }
  4050. }
  4051. if(isTrou(x,y,n)) {
  4052. return window.confirm(
  4053. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4054. +'Vous allez tomber dans un trou de météorite.\n'
  4055. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4056. );
  4057. }
  4058. }
  4059. return true;
  4060. }
  4061.  
  4062. function newsubmitDE(event) {
  4063. event.stopPropagation();
  4064. event.preventDefault();
  4065. if(validateDestination()) {
  4066. this.submit();
  4067. }
  4068. }
  4069.  
  4070. function changeValidation() {
  4071. var form = document.getElementsByName('ActionForm')[0];
  4072. if(form) {
  4073. form.addEventListener('submit', newsubmitDE, true);
  4074. }
  4075. }
  4076.  
  4077.  
  4078. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4079.  
  4080. function validateTPDestination() {
  4081. try {
  4082. var text = document.getElementsByTagName('B')[0];
  4083. var a = text.firstChild.nodeValue.split('|');
  4084. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4085. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4086. var pos_n = a[2].substring(5, a[2].length) * 1;
  4087.  
  4088. var nbtrous = 0;
  4089. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4090. for(var x=0 ; x<=2 ; x++) {
  4091. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4092. for(var y=0 ; y<=2 ; y++) {
  4093. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4094. for(var n = 0 ; n <= 1 ; n++) {
  4095. if(isTrou(
  4096. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4097. )) {
  4098. nbtrous++;
  4099. }
  4100. }
  4101. }
  4102. }
  4103. }
  4104. }
  4105. }
  4106. if(nbtrous>0 && nbtrous<72) {
  4107. return window.confirm(
  4108. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4109. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4110. +'% de risque de tomber dans un trou de météorite.\n'
  4111. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4112. );
  4113. }
  4114. else if(nbtrous>=72) {
  4115. return window.confirm(
  4116. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4117. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4118. +'% de risque de tomber dans un trou de météorite !\n'
  4119. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4120. );
  4121. }
  4122. return true;
  4123. }
  4124. catch(e) {
  4125. window.alert(e)
  4126. }
  4127. }
  4128.  
  4129. function newsubmitTP(event) {
  4130. event.stopPropagation();
  4131. event.preventDefault();
  4132. if(validateTPDestination()) {
  4133. this.submit();
  4134. }
  4135. }
  4136.  
  4137. function changeButtonValidate() {
  4138. var form = document.getElementsByName('Formulaire')[0];
  4139. if(form) {
  4140. if(!form.getAttribute('onsubmit')) {
  4141. form.setAttribute('onsubmit','return true;');
  4142. }
  4143. form.addEventListener('submit', newsubmitTP, true);
  4144. }
  4145. }
  4146.  
  4147.  
  4148. /*-[functions]---------------- Partie Principale -----------------------------*/
  4149.  
  4150. function do_move() {
  4151. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4152. changeValidation();
  4153. }
  4154. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4155. changeButtonValidate();
  4156. }
  4157. }
  4158.  
  4159. /*******************************************************************************
  4160. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4161. * Mountyzilla is free software; provided under the GNU General Public License *
  4162. *******************************************************************************/
  4163.  
  4164. // x~x news
  4165.  
  4166. // Nombre de news à afficher & nb max de caractères par news:
  4167. const nbItems = 5;
  4168. const maxCarDescription = 300;
  4169.  
  4170. /*-[functions]------------------- Utilitaires --------------------------------*/
  4171.  
  4172. // Ne semble avoir strictement aucun effet:
  4173. String.prototype.epureDescription = function() {
  4174. return this.replace(/\\(.)/g,"$1");
  4175. }
  4176.  
  4177. function appendTitledTable(node,titre,description) {
  4178. // Crée les tables contenant les infos (avec titre)
  4179. var table = document.createElement('table');
  4180. table.border = 0;
  4181. table.className = 'mh_tdborder';
  4182. table.cellSpacing = 1;
  4183. table.cellPadding = 1;
  4184. table.style.maxWidth = '98%';
  4185. table.style.marginLeft = 'auto';
  4186. table.style.marginRight = 'auto';
  4187. var tbody = document.createElement('tbody');
  4188. table.appendChild(tbody);
  4189. var tr = appendTr(tbody,'mh_tdtitre');
  4190. var td = appendTdCenter(tr,2);
  4191. var span = document.createElement('span');
  4192. appendText(span,titre,true);
  4193. if(description) {
  4194. span.title = description;
  4195. }
  4196. td.appendChild(span);
  4197. node.appendChild(table);
  4198. return tbody;
  4199. }
  4200.  
  4201. function testCertif(paramURL, callbackOnError) {
  4202. try {
  4203. FF_XMLHttpRequest({
  4204. method: 'GET',
  4205. url: paramURL,
  4206. onload: function(responseDetails) {
  4207. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4208. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4209. }
  4210. });
  4211. } catch(e) {
  4212. window.console.log('testCertif(' + paramURL + '), exception=' + e);
  4213. callbackOnError();
  4214. }
  4215. }
  4216.  
  4217. function createOrGetGrandCadre() {
  4218. var grandCadre = document.getElementById('grandCadre');
  4219. if (grandCadre) return grandCadre;
  4220. try {
  4221. var rappels = document.evaluate(
  4222. "//p[contains(a/text(),'messagerie')]",
  4223. document, null, 9, null).singleNodeValue;
  4224. }
  4225. catch(e) {
  4226. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4227. grandCadre = document.createElement('div');
  4228. return grandCadre;
  4229. }
  4230. grandCadre = document.createElement('div');
  4231. grandCadre.id = 'grandCadre';
  4232. var sousCadre = document.createElement('div');
  4233. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4234. sousCadre.style.textAlign = 'center';
  4235. sousCadre.style.fontSize = 'xx-large';
  4236. grandCadre.appendChild(sousCadre);
  4237.  
  4238. grandCadre.style.border = 'solid 5px red';
  4239. grandCadre.style.width = 'auto';
  4240. insertBefore(rappels,grandCadre);
  4241. return grandCadre;
  4242. }
  4243.  
  4244. function showHttpsErrorCadre1() {
  4245. var grandCadre = createOrGetGrandCadre();
  4246. var sousCadre = document.createElement('div');
  4247. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4248. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4249. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4250. + URL_CertifRaistlin1
  4251. + '" target="raistlin">clique ici</a>'
  4252. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4253. + ' « Confirmer l\'exception de sécurité »'
  4254. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4255. sousCadre.style.width = 'auto';
  4256. sousCadre.style.fontSize = 'large';
  4257. sousCadre.style.border = 'solid 1px black';
  4258. sousCadre.style.backgroundColor = 'red';
  4259. grandCadre.appendChild(sousCadre);
  4260. }
  4261.  
  4262. function showHttpsErrorCadre2() {
  4263. var grandCadre = createOrGetGrandCadre();
  4264. var sousCadre = document.createElement('div');
  4265. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  4266. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  4267. + '<a style="color:blue;font-size: inherits;" href="'
  4268. + URL_CertifRaistlin2
  4269. + '" target="raistlin">clique ici</a>'
  4270. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4271. + ' « Confirmer l\'exception de sécurité »'
  4272. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  4273. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4274. sousCadre.style.width = 'auto';
  4275. sousCadre.style.fontSize = 'large';
  4276. sousCadre.style.border = 'solid 1px black';
  4277. sousCadre.style.backgroundColor = 'red';
  4278. grandCadre.appendChild(sousCadre);
  4279. }
  4280.  
  4281. function showHttpsErrorContenuMixte() {
  4282. var grandCadre = createOrGetGrandCadre();
  4283. var sousCadre = document.createElement('div');
  4284. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  4285. + '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)'
  4286. + '<ul>'
  4287. + '<li>Interface Bricol\'Troll</li>'
  4288. + '<li>Nouveautés de Mountyzilla</li>'
  4289. + '</ul>'
  4290. + '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 />'
  4291. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  4292. sousCadre.style.width = 'auto';
  4293. sousCadre.style.fontSize = 'large';
  4294. sousCadre.style.border = 'solid 1px black';
  4295. grandCadre.appendChild(sousCadre);
  4296. }
  4297.  
  4298. /*-[functions]------------------- Jubilaires ---------------------------------*/
  4299.  
  4300. function traiterJubilaires() {
  4301. // à faire
  4302. }
  4303.  
  4304. function traiterJubilaires_a_supprimer() { // ancienne méthode
  4305. try {
  4306. FF_XMLHttpRequest({
  4307. method: 'GET',
  4308. url: URL_anniv,
  4309. headers: {
  4310. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4311. 'Accept': 'application/xml,text/xml',
  4312. },
  4313. onload: function(responseDetails) {
  4314. if ((responseDetails.status == 0) && isHTTPS) {
  4315. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  4316. showHttpsErrorContenuMixte();
  4317. return;
  4318. }
  4319. var listeTrolls = responseDetails.responseText.split('\n');
  4320. if(!listeTrolls || listeTrolls.length==0) {
  4321. return;
  4322. }
  4323. afficherJubilaires(listeTrolls);
  4324. },
  4325. });
  4326. }
  4327. catch(e) {
  4328. if (isHTTPS) {
  4329. window.console.log('exception à l\'appel jubilaires ' + e);
  4330. showHttpsErrorContenuMixte();
  4331. } else {
  4332. window.alert('Erreur Jubilaires:\n'+e);
  4333. }
  4334. }
  4335. }
  4336.  
  4337. function afficherJubilaires(listeTrolls) {
  4338. try {
  4339. var rappels = document.evaluate(
  4340. "//p[contains(a/text(),'messagerie')]",
  4341. document, null, 9, null).singleNodeValue;
  4342. }
  4343. catch(e) {
  4344. return;
  4345. }
  4346. var p = document.createElement('p');
  4347. var tbody = appendTitledTable(p,
  4348. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  4349. 'Envoyez leur un message ou un cadeau !'
  4350. );
  4351. tr = appendTr(tbody,'mh_tdpage');
  4352. td = appendTdCenter(tr);
  4353. var small = document.createElement('small');
  4354. td.appendChild(small);
  4355. var first = true;
  4356. for(var i=0 ; i<listeTrolls.length ; i++) {
  4357. var infos = listeTrolls[i].split(';');
  4358. if(infos.length!=3 || infos[2]==='0') {
  4359. continue;
  4360. }
  4361. if(first) {
  4362. first = false;
  4363. }
  4364. else {
  4365. appendText(small,', ');
  4366. }
  4367. var a = document.createElement('a');
  4368. a.href = 'javascript:EPV('+infos[0]+')';
  4369. appendText(a,infos[1]);
  4370. small.appendChild(a);
  4371. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  4372. }
  4373. insertBefore(rappels,p);
  4374. }
  4375.  
  4376.  
  4377. /*-[functions]--------------------- News MZ ----------------------------------*/
  4378.  
  4379. function traiterNouvelles() {
  4380. var news = new Array;
  4381. news.push(['24/12/2016', 'Les jubilaires ont disparu de Mountyzilla depuis un moment. Ils reviendront. Patience et espoir sont les maître qualités de l\'utilisateur MZ (et du joueur MH ;).']);
  4382. news.push(['24/12/2016', 'Retour de la carte montrant les déplacements des Gowaps']);
  4383. news.push(['24/12/2016', 'Le lien avec Bricol\'Troll est maintenant disponible en https']);
  4384. afficherNouvelles(news);
  4385. }
  4386.  
  4387. function afficherNouvelles(items) {
  4388. var footer = document.getElementById('footer1');
  4389. if(!footer) {
  4390. window.console.log('[MZ] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  4391. return;
  4392. }
  4393. var p = document.createElement('p');
  4394. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  4395. for(var i=0 ; i<items.length ; i++) {
  4396. var tr = appendTr(tbody,'mh_tdpage');
  4397. var td = appendTdCenter(tr);
  4398. td.style.verticalAlign = 'top'; // semble sans effet
  4399. appendText(td,items[i][0],true);
  4400. td = appendTd(tr);
  4401. td.innerHTML = items[i][1];
  4402. }
  4403. insertBefore(footer,p);
  4404. }
  4405.  
  4406.  
  4407. /*---------------------------------- Main ------------------------------------*/
  4408.  
  4409. function do_news() {
  4410. start_script();
  4411.  
  4412. traiterJubilaires();
  4413. traiterNouvelles();
  4414.  
  4415. if (isHTTPS) {
  4416. // test si les certificats raistlin ont été acceptés
  4417. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  4418. var infoit = MY_getValue(numTroll+'.INFOSIT');
  4419. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  4420. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  4421. }
  4422. }
  4423.  
  4424. displayScriptTime();
  4425. }
  4426.  
  4427. /*********************************************************************************
  4428. * This file is part of Mountyzilla. *
  4429. * *
  4430. * Mountyzilla is free software; you can redistribute it and/or modify *
  4431. * it under the terms of the GNU General Public License as published by *
  4432. * the Free Software Foundation; either version 2 of the License, or *
  4433. * (at your option) any later version. *
  4434. * *
  4435. * Mountyzilla is distributed in the hope that it will be useful, *
  4436. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4437. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4438. * GNU General Public License for more details. *
  4439. * *
  4440. * You should have received a copy of the GNU General Public License *
  4441. * along with Mountyzilla; if not, write to the Free Software *
  4442. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4443. *********************************************************************************/
  4444.  
  4445. // x~x tabcompo
  4446.  
  4447. var popup;
  4448.  
  4449. function initPopupTabcompo() {
  4450. popup = document.createElement('div');
  4451. popup.setAttribute('id', 'popup');
  4452. popup.setAttribute('class', 'mh_textbox');
  4453. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  4454. + 'display: inline; z-index: 3; max-width: 400px;');
  4455. document.body.appendChild(popup);
  4456. }
  4457.  
  4458. function showPopup(evt) {
  4459. var texte = this.getAttribute("texteinfo");
  4460. popup.innerHTML = texte;
  4461. popup.style.left = evt.pageX + 15 + 'px';
  4462. popup.style.top = evt.pageY + 'px';
  4463. popup.style.visibility = "visible";
  4464. }
  4465.  
  4466. // roule 16/03/2016, existe déjà ailleurs
  4467. // function hidePopup() {
  4468. // popup.style.visibility = 'hidden';
  4469. // }
  4470.  
  4471. function createPopupImage(url, text)
  4472. {
  4473. var img = document.createElement('img');
  4474. img.setAttribute('src',url);
  4475. img.setAttribute('align','ABSMIDDLE');
  4476. img.setAttribute("texteinfo",text);
  4477. img.addEventListener("mouseover", showPopup,true);
  4478. img.addEventListener("mouseout", hidePopup,true);
  4479. return img;
  4480. }
  4481.  
  4482. function formateTexte(texte)
  4483. {
  4484. texte = texte.replace(/\n/g,"<br/>");
  4485. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4486. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4487. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4488. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4489. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4490. return texte;
  4491. }
  4492.  
  4493. function arrondi(x) {
  4494. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  4495. }
  4496.  
  4497. function traiteMinerai() {
  4498. if (currentURL.indexOf("as_type=Divers")==-1) return;
  4499. try {
  4500. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  4501. +" and contains(./tr/th/text(),'Minerai')]",
  4502. document, null, 9, null).singleNodeValue;
  4503. node = node.nextSibling.nextSibling;
  4504. }
  4505. catch(e) {return;}
  4506. var trlist = document.evaluate('./tr', node, null, 7, null);
  4507. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  4508. var node = trlist.snapshotItem(i);
  4509. var nature = node.childNodes[5].textContent;
  4510. var caracs = node.childNodes[7].textContent;
  4511. var taille = caracs.match(/\d+/)[0];
  4512. var coef = 1;
  4513. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  4514. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  4515. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  4516. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  4517. if (nature.indexOf('Mithril')!=-1) {
  4518. coef = 0.2*coef;
  4519. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  4520. }
  4521. else {
  4522. coef = 0.75*coef+1.25;
  4523. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  4524. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  4525. }
  4526. }
  4527. }
  4528.  
  4529. function treateComposants() {
  4530. if (currentURL.indexOf("as_type=Compo")==-1) return;
  4531. //On récupère les composants
  4532. var nodes = document.evaluate(
  4533. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4534. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4535. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  4536. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4537. if (nodes.snapshotLength == 0) {
  4538. // window.alert('treateComposants DOWN');
  4539. return;
  4540. }
  4541. window.alert(nodes.snapshotLength);
  4542.  
  4543. var texte = "";
  4544. for (var i = 0; i < nodes.snapshotLength; i++) {
  4545. var n1 = nodes.snapshotItem(i).childNodes[1];
  4546. var n3 = nodes.snapshotItem(i).childNodes[3];
  4547. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4548. var prix = n3.childNodes[0].nodeValue;
  4549. if (!prix)
  4550. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4551. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4552. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4553. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4554. + prix.replace(/\n/g, '') + "\n";
  4555. }
  4556.  
  4557. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4558. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4559. var id_taniere = c.snapshotItem(0).nodeValue;
  4560. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  4561.  
  4562. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4563. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  4564. if (form)
  4565. {
  4566. if(document.getElementsByTagName('form').length>0)
  4567. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4568. else
  4569. {
  4570. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4571. insertBefore(thisP, form);
  4572. }
  4573. }
  4574. }
  4575.  
  4576. function treateAllComposants() {
  4577. if(currentURL.indexOf("as_type=Compo")==-1) return;
  4578. //On récupère les composants
  4579. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  4580. document, null, 0, null ).numberValue;
  4581. var c = (categ == 0 ? 3 : 4);
  4582. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  4583. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  4584. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  4585. + "td["+c+"]/text()[1] = '\240-\240' "
  4586. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  4587. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  4588. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  4589. + "and td[1]/img/@alt = 'Identifié']",
  4590. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4591. if (nodes.snapshotLength == 0) {
  4592. // window.alert('treateAllComposants DOWN');
  4593. return;
  4594. }
  4595.  
  4596. var texte = "";
  4597. for (var i = 0; i < nodes.snapshotLength; i++) {
  4598. var n1 = nodes.snapshotItem(i).childNodes[1];
  4599. var n3 = nodes.snapshotItem(i).childNodes[3];
  4600. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4601. var prix = n3.childNodes[0].nodeValue;
  4602. if (!prix)
  4603. {
  4604. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  4605. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4606. }
  4607. else
  4608. {
  4609. prix= prix.replace(/[\240 ]/g, "");
  4610. if(prix=="-")
  4611. prix=null;
  4612. }
  4613. if(prix)
  4614. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4615. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4616. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4617. + prix.replace(/\n/g, '') + "\n";
  4618. else
  4619. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4620. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4621. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  4622. }
  4623.  
  4624. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4625. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4626. var id_taniere = c.snapshotItem(0).nodeValue;
  4627. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  4628.  
  4629. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4630. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  4631. if (form)
  4632. {
  4633. if(document.getElementsByTagName('form').length>0)
  4634. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4635. else
  4636. {
  4637. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4638. insertBefore(thisP, form);
  4639. }
  4640. }
  4641. }
  4642.  
  4643. function treateEM()
  4644. {
  4645. if(currentURL.indexOf("as_type=Compo")==-1)
  4646. return false;
  4647. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  4648. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  4649. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4650. if (nodes.snapshotLength == 0)
  4651. return false;
  4652. for (var i = 0; i < nodes.snapshotLength; i++) {
  4653. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  4654. var link = desc[2].firstChild ;
  4655. var nomCompoTotal = desc[2].textContent ;
  4656. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4657. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4658. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  4659. var locqual = desc[3].textContent ;
  4660. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  4661. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  4662. if(isEM(nomMonstre).length>0)
  4663. {
  4664. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  4665. if(infos.length>0)
  4666. {
  4667. var shortDescr = "Variable";
  4668. var bold = 0;
  4669. if(infos != "Composant variable")
  4670. {
  4671. shortDescr = infos.substring(0,infos.indexOf(" "));
  4672. if(parseInt(shortDescr)>=0)
  4673. bold=1;
  4674. }
  4675. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  4676. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  4677. }
  4678. }
  4679. }
  4680. }
  4681.  
  4682. function treateChampi() {
  4683. if (currentURL.indexOf('as_type=Champi')==-1)
  4684. return false;
  4685. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  4686. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4687. if (nodes.snapshotLength == 0)
  4688. return false;
  4689.  
  4690. for (var i = 0; i < nodes.snapshotLength; i++) {
  4691. var node = nodes.snapshotItem(i);
  4692. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  4693. if (moisChampi[nomChampi])
  4694. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  4695. }
  4696. }
  4697.  
  4698. function treateEnchant()
  4699. {
  4700. if(currentURL.indexOf("as_type=Compo")==-1)
  4701. return false;
  4702. try
  4703. {
  4704. if(!listeMonstreEnchantement)
  4705. computeCompoEnchantement();
  4706. var nodes = document.evaluate(
  4707. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4708. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4709. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4710. if (nodes.snapshotLength == 0)
  4711. return false;
  4712. var urlImg = URL_MZimg + "enchant.png";
  4713. for (var i = 0; i < nodes.snapshotLength; i++) {
  4714. var link = nodes.snapshotItem(i);
  4715. var nomCompoTotal = link.firstChild.nodeValue;
  4716. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4717. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4718. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  4719. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  4720. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  4721. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  4722. if(isEnchant(nomMonstre).length>0)
  4723. {
  4724. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  4725. if(infos.length>0)
  4726. {
  4727. link.parentNode.appendChild(createImage(urlImg,infos));
  4728. }
  4729. }
  4730. }
  4731. }
  4732. catch(e)
  4733. {
  4734. window.alert(e);
  4735. }
  4736. }
  4737.  
  4738. function treateEquipEnchant()
  4739. {
  4740. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  4741. return false;
  4742. initPopupTabcompo();
  4743. computeEnchantementEquipement(createPopupImage,formateTexte);
  4744. }
  4745.  
  4746. function do_tancompo() {
  4747. start_script();
  4748.  
  4749. treateAllComposants();
  4750. treateComposants();
  4751. traiteMinerai();
  4752. if (MY_getValue('NOINFOEM')!='true') {
  4753. treateChampi();
  4754. treateEM();
  4755. }
  4756. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  4757. treateEnchant();
  4758. treateEquipEnchant();
  4759. }
  4760.  
  4761. displayScriptTime();
  4762. }
  4763.  
  4764. /*******************************************************************************
  4765. * This file is part of Mountyzilla. *
  4766. * *
  4767. * Mountyzilla is free software; you can redistribute it and/or modify *
  4768. * it under the terms of the GNU General Public License as published by *
  4769. * the Free Software Foundation; either version 2 of the License, or *
  4770. * (at your option) any later version. *
  4771. * *
  4772. * Mountyzilla is distributed in the hope that it will be useful, *
  4773. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4774. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4775. * GNU General Public License for more details. *
  4776. * *
  4777. * You should have received a copy of the GNU General Public License *
  4778. * along with Mountyzilla; if not, write to the Free Software *
  4779. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4780. *******************************************************************************/
  4781.  
  4782. // x~x pjview
  4783.  
  4784. /* TODO
  4785. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  4786. */
  4787.  
  4788. // Bulle d'infos
  4789. var DivInfo;
  4790. // Booléen stockant l'état de freezing de la bulle
  4791. var freezed = false;
  4792.  
  4793. // liste du matos
  4794. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  4795. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4796. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  4797. var mh_caracs = {
  4798. 'anneau de protection':
  4799. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  4800. "armure d'anneaux":
  4801. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  4802. 'armure de bois':
  4803. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  4804. 'armure de cuir':
  4805. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  4806. 'armure de peaux':
  4807. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  4808. 'armure de pierre':
  4809. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  4810. 'armure de plates':
  4811. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  4812. 'baton lesté':
  4813. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4814. 'bâtons de parade':
  4815. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4816. 'bottes':
  4817. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4818. 'bouclier à pointes':
  4819. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4820. 'boulet et chaîne':
  4821. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4822. 'cagoule':
  4823. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  4824. 'casque à cornes':
  4825. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4826. 'casque à pointes':
  4827. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  4828. 'casque en cuir':
  4829. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  4830. 'casque en métal':
  4831. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4832. 'chaîne cloutée':
  4833. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4834. 'chapeau pointu':
  4835. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  4836. 'collier de dents':
  4837. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  4838. 'collier de pierre':
  4839. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4840. 'collier à pointes':
  4841. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4842. 'cotte de mailles':
  4843. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  4844. 'couronne de cristal':
  4845. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  4846. "couronne d'obsidienne":
  4847. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  4848. "coutelas d'obsidienne":
  4849. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  4850. 'coutelas en os':
  4851. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  4852. 'crochet':
  4853. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4854. 'cuir bouilli':
  4855. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  4856. "cuirasse d'ossements":
  4857. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  4858. "cuirasse d'écailles":
  4859. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  4860. 'culotte en cuir':
  4861. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4862. 'dague':
  4863. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4864. 'epée courte':
  4865. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4866. 'epée longue':
  4867. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4868. 'espadon':
  4869. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4870. 'fouet':
  4871. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4872. 'fourrures':
  4873. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  4874. 'gantelet':
  4875. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4876. 'gorgeron en cuir':
  4877. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4878. 'gorgeron en métal':
  4879. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  4880. 'gourdin':
  4881. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4882. 'gourdin clouté':
  4883. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4884. 'grimoire':
  4885. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  4886. "gros'porte":
  4887. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  4888. 'grosse racine':
  4889. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  4890. 'grosse stalagmite':
  4891. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  4892. 'hache de bataille':
  4893. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4894. 'hache de guerre en os':
  4895. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  4896. 'hache de guerre en pierre':
  4897. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  4898. "hache à deux mains d'obsidienne":
  4899. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  4900. 'hallebarde':
  4901. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  4902. "haubert d'écailles":
  4903. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  4904. 'haubert de mailles':
  4905. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  4906. 'heaume':
  4907. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  4908. 'jambières en cuir':
  4909. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  4910. 'jambières en fourrure':
  4911. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  4912. 'jambières en maille':
  4913. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  4914. 'jambières en métal':
  4915. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  4916. 'jambières en os':
  4917. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  4918. "lame d'obsidienne":
  4919. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  4920. 'lame en os':
  4921. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4922. 'lame en pierre':
  4923. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4924. 'lorgnons':
  4925. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  4926. 'machette':
  4927. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4928. "masse d'arme":
  4929. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4930. 'pagne de mailles':
  4931. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4932. 'pagne en cuir':
  4933. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4934. 'robe de mage':
  4935. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  4936. 'rondache en bois':
  4937. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4938. 'rondache en métal':
  4939. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  4940. 'sandales':
  4941. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4942. 'souliers dorés':
  4943. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4944. "talisman d'obsidienne":
  4945. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  4946. 'talisman de pierre':
  4947. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  4948. 'targe':
  4949. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4950. 'torche':
  4951. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  4952. 'torque de pierre':
  4953. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  4954. 'tunique':
  4955. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4956. "tunique d'écailles":
  4957. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  4958. 'turban':
  4959. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  4960. }
  4961.  
  4962. // liste des templates
  4963. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  4964. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4965. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  4966. var mh_templates = {
  4967. 'de Feu':
  4968. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4969. 'de Résistance':
  4970. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  4971. "de l'Aigle":
  4972. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  4973. 'de la Salamandre':
  4974. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  4975. 'des Cyclopes':
  4976. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  4977. 'des Enragés':
  4978. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  4979. 'des Tortues':
  4980. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  4981. 'des Vampires':
  4982. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  4983. 'du Glacier':
  4984. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  4985. 'du Rat':
  4986. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  4987. 'du Roc':
  4988. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  4989. 'du Temps':
  4990. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  4991. 'du Vent':
  4992. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  4993. 'en Mithril':
  4994. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4995. 'des Anciens':
  4996. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4997. 'des Champions':
  4998. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  4999. 'des Duellistes':
  5000. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5001. 'de la Terre':
  5002. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5003. "de l'Orage":
  5004. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5005. "de l'Ours":
  5006. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5007. 'des Béhémoths':
  5008. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5009. 'des Mages':
  5010. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5011. 'du Pic':
  5012. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5013. 'du Sable':
  5014. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5015. 'acéré':
  5016. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5017. 'acérée':
  5018. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5019. 'équilibré':
  5020. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5021. 'équilibrée':
  5022. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5023. 'léger':
  5024. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5025. 'légère':
  5026. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5027. 'renforcé':
  5028. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5029. 'renforcée':
  5030. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5031. 'robuste':
  5032. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5033. }
  5034.  
  5035. function clone(arr) {
  5036. // Clonage rapide
  5037. return arr.slice(0);
  5038. }
  5039.  
  5040. function addArray(arr1,arr2) {
  5041. // Somme matricielle
  5042. var res = clone(arr1);
  5043. for(i=res.length-1 ; i>=0 ; i--) {
  5044. res[i] += arr2[i];
  5045. }
  5046. return res;
  5047. }
  5048.  
  5049. function getTemplates(nomItem) {
  5050. // Déstructure le nom de l'item en array [nom, template1, ...]
  5051. var tempFound = true;
  5052. var str = nomItem.trim();
  5053. var arr = [];
  5054. while(tempFound) {
  5055. tempFound = false;
  5056. for(var temp in mh_templates) {
  5057. // on teste la fin du nom contre chaque template
  5058. if(str.slice(-temp.length)!=temp) { continue; }
  5059. tempFound = true;
  5060. str = str.slice(0,-temp.length-1);
  5061. arr.unshift(temp);
  5062. if(str.slice(-3)==' et') {
  5063. str = str.slice(0,-3);
  5064. }
  5065. }
  5066. }
  5067. arr.unshift(str);
  5068. return arr;
  5069. }
  5070.  
  5071. function addMithril(arrayCaracs,typeItem) {
  5072. // Ajoute l'effet du Mithril sur les caracs
  5073. if(typeItem=='arme') {
  5074. if(arrayCaracs[0]<0) {
  5075. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5076. }
  5077. }
  5078. else {
  5079. if(arrayCaracs[4]<0) {
  5080. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5081. }
  5082. }
  5083. arrayCaracs[15] /= 2;
  5084. arrayCaracs[16] /= 2;
  5085. return arrayCaracs;
  5086. }
  5087.  
  5088. function addRenfort(arrayCaracs,template) {
  5089. // Ajoute l'effet des pseudo-templates sur les caracs
  5090. // S'applique APRÈS le mithril
  5091. // WARNING - Cette formule n'a rien d'officiel, gare !
  5092. var coef = 0;
  5093. if(/^lég[e,è]re?$/.test(template)) {
  5094. coef = -1;
  5095. }
  5096. else if(/^renforcée?$/.test(template)
  5097. || template==='robuste') {
  5098. coef = 1;
  5099. }
  5100. if(coef) {
  5101. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5102. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5103. }
  5104. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5105. return arrayCaracs;
  5106. }
  5107.  
  5108. function getCaracs(item) {
  5109. // Calcule les caractéristiques de l'item
  5110. var templates = getTemplates(item);
  5111. if(!mh_caracs[templates[0]]) {
  5112. // Si l'item est inconnu
  5113. return [];
  5114. }
  5115. var caracs = clone(mh_caracs[templates[0]]);
  5116. var typeItem = caracs[0];
  5117. caracs.shift();
  5118. templates.shift();
  5119. if(templates[templates.length-1]=='en Mithril') {
  5120. caracs = addMithril(caracs,typeItem);
  5121. templates.pop();
  5122. }
  5123. if(/^acérée?$/.test(templates[0])
  5124. || /^équilibrée?$/.test(templates[0])
  5125. || /^lég[e,è]re?$/.test(templates[0])
  5126. || /^renforcée?$/.test(templates[0])
  5127. || templates[0]=='robuste') {
  5128. caracs = addRenfort(caracs,templates[0]);
  5129. templates.shift();
  5130. }
  5131. for(var i=templates.length-1 ; i>=0 ; i--) {
  5132. caracs = addArray(caracs,mh_templates[templates[i]]);
  5133. }
  5134. return caracs;
  5135. }
  5136.  
  5137. function getLine(tab) {
  5138. // Préparation de la ligne à afficher lors d'un mouseover
  5139. var str = '';
  5140. if(tab[0]!=0 || tab[1]!=0) {
  5141. str += '<b>Att : </b>'+aff(tab[0]);
  5142. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5143. str += ' | ';
  5144. }
  5145. if(tab[4]!=0) {
  5146. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5147. }
  5148. if(tab[2]!=0 || tab[3]!=0) {
  5149. str += '<b>Deg : </b>'+aff(tab[2]);
  5150. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5151. str += ' | ';
  5152. }
  5153. if(tab[8]!=0) {
  5154. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5155. }
  5156. if(tab[7]!=0) {
  5157. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5158. }
  5159. if(tab[5]!=0 || tab[6]!=0) {
  5160. str += '<b>Arm : </b>'+aff(tab[5]);
  5161. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5162. str += ' | ';
  5163. }
  5164. if(tab[9]!=0 || tab[10]!=0) {
  5165. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5166. if(tab[9]!=tab[10]) {
  5167. str += '/'+aff(tab[10])+'%';
  5168. }
  5169. str += ' | ';
  5170. }
  5171. if(tab[11]!=0 || tab[12]!=0) {
  5172. str += '<b>MM : </b>'+aff(tab[11])+'%';
  5173. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  5174. str += ' | ';
  5175. }
  5176. if(tab[13]!=0) {
  5177. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5178. }
  5179. if(tab[14]!=0) {
  5180. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5181. }
  5182. str += '<b>Poids : </b>'+tab[15]+' min';
  5183. if(tab[15]!=tab[16]) {
  5184. str += ' / '+tab[16]+' min';
  5185. }
  5186. return str;
  5187. }
  5188.  
  5189. function toolTipInit() {
  5190. DivInfo = document.createElement('div');
  5191. DivInfo.id = 'infosVue';
  5192. DivInfo.className = 'mh_textbox';
  5193. DivInfo.style =
  5194. 'position: absolute;'
  5195. +'border: 1px solid #000000;'
  5196. +'visibility:hidden;'
  5197. +'display:inline;'
  5198. +'z-index:99;';
  5199. document.body.appendChild(DivInfo);
  5200. document.onmousemove = getXY;
  5201. document.onclick = changeFreezeStatus;
  5202. }
  5203.  
  5204. function getXY(evt) {
  5205. if(!freezed && DivInfo.style.visibility=='visible') {
  5206. DivInfo.style.left = evt.pageX+'px';
  5207. DivInfo.style.top = evt.pageY+10+'px';
  5208. }
  5209. }
  5210.  
  5211. function changeFreezeStatus() {
  5212. if(DivInfo.style.visibility=='visible') {
  5213. freezed = !freezed;
  5214. if(!freezed) { hideInfos(); }
  5215. }
  5216. }
  5217.  
  5218. function showInfos() {
  5219. if(freezed) { return; }
  5220. var currentInfos = this.infos;
  5221. DivInfo.innerHTML = currentInfos;
  5222. DivInfo.style.visibility = 'visible';
  5223. }
  5224.  
  5225. function hideInfos() {
  5226. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  5227. }
  5228.  
  5229. function treateEquipement() {
  5230. // Extrait les données du matos et réinjecte les infos déduites
  5231. if(MY_getValue('INFOCARAC')=='false') { return; }
  5232. var faireLigne = false;
  5233. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  5234. var nodes = document.evaluate(
  5235. "//td/b[text()='Equipement Utilisé']/../../"
  5236. +"td[2]/img[contains(@src,bullet)]",
  5237. document, null, 7, null);
  5238. if(nodes.snapshotLength>0) {
  5239. // Si CSS de base
  5240. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5241. var node = nodes.snapshotItem(i);
  5242. var next = node.nextSibling;
  5243. var nnext = next.nextSibling;
  5244. var nom = next.nodeValue.toLowerCase();
  5245. if(nnext.childNodes.length==1) {
  5246. nom += nnext.firstChild.nodeValue;
  5247. }
  5248. nom = nom.trim();
  5249. // gestion winpostrophe
  5250. var c = String.fromCharCode(180);
  5251. while(nom.indexOf(c)!=-1) {
  5252. nom = nom.replace(c,"'");
  5253. }
  5254. var arr = getCaracs(nom);
  5255. if(arr.length>0) {
  5256. faireLigne = true;
  5257. caracs = addArray(caracs,arr);
  5258. var span = document.createElement('span');
  5259. span.appendChild(next);
  5260. span.appendChild(nnext);
  5261. span.infos = getLine(arr);
  5262. span.onmouseover = showInfos;
  5263. span.onmouseout = hideInfos;
  5264. insertBefore(node.nextSibling,span);
  5265. }
  5266. }
  5267. if(faireLigne) {
  5268. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  5269. document, null, 9, null).singleNodeValue;
  5270. node.infos = getLine(caracs);
  5271. node.onmouseover = showInfos;
  5272. node.onmouseout = hideInfos;
  5273. }
  5274. }
  5275. else {
  5276. // Si CSS avancée
  5277. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  5278. document, null, 7, null);
  5279. if(nodes.snapshotLength>0) {
  5280. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5281. var node = nodes.snapshotItem(i);
  5282. var nom = node.firstChild.nodeValue.toLowerCase();
  5283. if(node.childNodes.length>1) {
  5284. nom += node.childNodes[1].firstChild.nodeValue;
  5285. }
  5286. nom = nom.trim();
  5287. // gestion winpostrophe
  5288. var c = String.fromCharCode(180);
  5289. while(nom.indexOf(c)!=-1) {
  5290. nom = nom.replace(c,"'");
  5291. }
  5292. var arr = getCaracs(nom);
  5293. if(arr.length!=0) {
  5294. caracs = addArray(caracs,arr);
  5295. node.infos = getLine(arr);
  5296. node.onmouseover = showInfos;
  5297. node.onmouseout = hideInfos;
  5298. }
  5299. }
  5300. var nodes = document.evaluate("//dt[@class='equipement']",
  5301. document, null, 7, null);
  5302. var node = nodes.snapshotItem(0);
  5303. node.infos = getLine(caracs);
  5304. node.onmouseover = showInfos;
  5305. node.onmouseout = hideInfos;
  5306. }
  5307. }
  5308. }
  5309.  
  5310. function do_pjview() {
  5311. treateEquipement();
  5312. toolTipInit();
  5313. }
  5314.  
  5315. /*******************************************************************************
  5316. * This file is part of Mountyzilla. *
  5317. * *
  5318. * Mountyzilla is free software; you can redistribute it and/or modify *
  5319. * it under the terms of the GNU General Public License as published by *
  5320. * the Free Software Foundation; either version 2 of the License, or *
  5321. * (at your option) any later version. *
  5322. * *
  5323. * Mountyzilla is distributed in the hope that it will be useful, *
  5324. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5325. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5326. * GNU General Public License for more details. *
  5327. * *
  5328. * You should have received a copy of the GNU General Public License *
  5329. * along with Mountyzilla; if not, write to the Free Software *
  5330. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5331. *******************************************************************************/
  5332.  
  5333. // x~x option
  5334.  
  5335. /* TODO
  5336. * Passer le HTML injecté aux conventions HTML5
  5337. */
  5338.  
  5339.  
  5340. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  5341.  
  5342. function saveITData() {
  5343. var IT = document.getElementById('itSelect').value;
  5344. if(IT=='bricol') {
  5345. var system = document.getElementById('urlbricol').value;
  5346. var login = document.getElementById('loginbricol').value;
  5347. var pass = document.getElementById('passbricol').value;
  5348. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  5349. if(system && login) {
  5350. if (pass) {
  5351. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  5352. MY_setValue(numTroll+'.INFOSIT', v);
  5353. //window.console.log('v=' + v);
  5354. } else {
  5355. // vérif que rien n'a changé
  5356. var str = MY_getValue(numTroll+'.INFOSIT');
  5357. if(str) {
  5358. var arr = str.split('$');
  5359. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  5360. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  5361. }
  5362. }
  5363. }
  5364. }
  5365. }
  5366. else {
  5367. MY_removeValue(numTroll+'.INFOSIT');
  5368. }
  5369. }
  5370.  
  5371. function saveLinks() {
  5372. var numLinks = document.getElementById('linksBody').childNodes.length;
  5373. var data=[ [] ];
  5374. /* Récupération et tri des liens */
  5375. for(var i=1 ; i<=numLinks ; i++) {
  5376. MY_removeValue('URL'+i);
  5377. MY_removeValue('URL'+i+'.nom');
  5378. MY_removeValue('URL'+i+'.ico');
  5379. var url = document.getElementById('url'+i).value;
  5380. var nom = document.getElementById('nom'+i).value;
  5381. var ico = document.getElementById('ico'+i).value;
  5382. if(url && (nom || ico) ) {
  5383. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5384. }
  5385. }
  5386. /* Sauvegarde */
  5387. for(var i=1 ; i<data.length ; i++) {
  5388. MY_setValue('URL'+i,data[i][0]);
  5389. MY_setValue('URL'+i+'.nom',data[i][1]);
  5390. MY_setValue('URL'+i+'.ico',data[i][2]);
  5391. }
  5392. }
  5393.  
  5394. function saveAll() {
  5395. var urlIco = document.getElementById('icoMenuIco').value;
  5396. if(urlIco) {
  5397. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5398. }
  5399. else {
  5400. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5401. document.getElementById('icoMenuIco').value = '';
  5402. }
  5403. saveLinks();
  5404. refreshLinks();
  5405. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5406. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5407. if(maxcdm) {
  5408. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5409. }
  5410. else {
  5411. MY_removeValue(numTroll+'.MAXCDM');
  5412. document.getElementById('maxcdm').value = '';
  5413. }
  5414.  
  5415. MY_setValue('NOINFOEM',
  5416. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5417. // Pourquoi Tilk stockait-il tout en str ?
  5418. // -> parce que les booléens c'est foireux (vérifié)
  5419. MY_setValue(numTroll+'.USECSS',
  5420. document.getElementById('usecss').checked ? 'true':'false');
  5421. MY_setValue('INFOCARAC',
  5422. document.getElementById('infocarac').checked ? 'true' : 'false');
  5423. //MY_setValue(numTroll+'.SEND_IDT',
  5424. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  5425. // Fonctionnalité désactivée
  5426.  
  5427. MY_setValue(numTroll+'.AUTOCDM',
  5428. document.getElementById('autoCdM').checked ? 'true' : 'false');
  5429. MY_setValue('VUECARAC',
  5430. document.getElementById('vueCarac').checked ? 'true' : 'false');
  5431. MY_setValue('CONFIRMEDECALAGE',
  5432. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  5433. MY_setValue(numTroll+".OLDSCHOOL",
  5434. document.getElementById("oldShoolStyle").checked ? "true" : "false");
  5435.  
  5436. saveITData();
  5437. var bouton = document.getElementById('saveAll');
  5438. bouton.value = (bouton.value=='Sauvegardé !') ?
  5439. 'Re-sauvegardé !' : 'Sauvegardé !';
  5440. }
  5441.  
  5442.  
  5443. /*-[functions]----------------- EventListeners -------------------------------*/
  5444.  
  5445. function onChangeIT() {
  5446. var IT = document.getElementById('itSelect').value;
  5447. var itBody = document.getElementById('itBody');
  5448. itBody.innerHTML = '';
  5449. if(IT=='bricol') {
  5450. var tr = appendTr(itBody,'mh_tdpage')
  5451. var td = appendTd(tr);
  5452. var str = MY_getValue(numTroll+'.INFOSIT');
  5453. //window.console.log('onChangeIT str=' + str);
  5454. if(str) {
  5455. var arr = str.split('$');
  5456. var system = arr[1];
  5457. var login = arr[2];
  5458. var affhv = arr[4];
  5459. }
  5460. appendText(td,'Nom du système : ');
  5461. appendTextbox(td,'text','urlbricol',20,50,system);
  5462. td = appendTd(tr);
  5463. appendText(td,'Login du compte : ');
  5464. appendTextbox(td,'text','loginbricol',20,50,login);
  5465. td = appendTd(tr);
  5466. appendText(td,'Mot de passe du compte : ');
  5467. appendTextbox(td,'password','passbricol',20,50);
  5468. td = appendTd(tr);
  5469. appendText(td,'Affichage des Trõlls hors vue : ');
  5470. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  5471. appendCheckBox(td,'affhvbricol', (affhv>0));
  5472. }
  5473. }
  5474.  
  5475. function refreshLinks() {
  5476. document.getElementById('linksBody').innerHTML = '';
  5477. var anotherURL = MY_getValue('URL1');
  5478. if(!anotherURL) { addLinkField(); }
  5479. var i=1;
  5480. while(anotherURL && i<99) {
  5481. addLinkField(i,anotherURL,
  5482. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  5483. i++;
  5484. anotherURL = MY_getValue('URL'+i);
  5485. }
  5486. }
  5487.  
  5488. function addLinkField(i,url,nom,ico) {
  5489. var linksBody = document.getElementById('linksBody');
  5490. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  5491. var tr = appendTr(linksBody);
  5492. var td = appendTdCenter(tr);
  5493. appendText(td,'Lien '+i+' : ');
  5494. appendTextbox(td,'text','url'+i,40,150,url);
  5495. td = appendTdCenter(tr);
  5496. appendText(td,'Nom : ');
  5497. appendTextbox(td,'text','nom'+i,20,150,nom);
  5498. td = appendTdCenter(tr);
  5499. appendText(td,'Icône : ');
  5500. appendTextbox(td,'text','ico'+i,40,150,ico);
  5501. }
  5502.  
  5503. function removeLinkField() {
  5504. var linksBody = document.getElementById('linksBody');
  5505. var i = linksBody.childNodes.length;
  5506. MY_removeValue('URL'+i);
  5507. MY_removeValue('URL'+i+'.nom');
  5508. MY_removeValue('URL'+i+'.ico');
  5509. linksBody.removeChild(linksBody.lastChild);
  5510. if(linksBody.childNodes.length==0) { addLinkField(); }
  5511. }
  5512.  
  5513. function resetMainIco() {
  5514. document.getElementById('icoMenuIco').value=
  5515. URL_MZimg + 'mz_logo_small.png';
  5516. }
  5517.  
  5518.  
  5519. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  5520.  
  5521. function insertTitle(next,txt) {
  5522. var div = document.createElement('div');
  5523. div.className = 'titre2';
  5524. appendText(div,txt);
  5525. insertBefore(next,div);
  5526. return div;
  5527. }
  5528.  
  5529. function insertMainTable(next) {
  5530. var table = document.createElement('table');
  5531. table.width = '98%';
  5532. table.border = 0;
  5533. table.align = 'center';
  5534. table.cellPadding = 2;
  5535. table.cellSpacing = 1;
  5536. table.className = 'mh_tdborder';
  5537. var tbody = document.createElement('tbody');
  5538. table.appendChild(tbody);
  5539. insertBefore(next,table);
  5540. return tbody;
  5541. }
  5542.  
  5543. function appendSubTable(node) {
  5544. var table = document.createElement('table');
  5545. table.width = '100%';
  5546. var tbody = document.createElement('tbody');
  5547. table.appendChild(tbody);
  5548. node.appendChild(table);
  5549. return tbody;
  5550. }
  5551.  
  5552. function insertOptionTable(insertPt) {
  5553. var mainBody = insertMainTable(insertPt);
  5554. /* Liens dans le Menu */
  5555. var tr = appendTr(mainBody,'mh_tdtitre');
  5556. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  5557. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5558. appendText(td,'Icône du Menu: ');
  5559. var url = MY_getValue(numTroll+'.ICOMENU');
  5560. if(!url) {
  5561. url = URL_MZimg + 'mz_logo_small.png';
  5562. }
  5563. appendTextbox(td,'text','icoMenuIco',50,200,url);
  5564. appendButton(td,'Réinitialiser',resetMainIco);
  5565. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5566. var tbody = appendSubTable(td);
  5567. tbody.id = 'linksBody';
  5568. refreshLinks();
  5569. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  5570. appendButton(td,'Ajouter',addLinkField);
  5571. appendButton(td,'Supprimer',removeLinkField);
  5572. /* Options de la Vue : vue externe, nb de CdM, etc */
  5573. tr = appendTr(mainBody,'mh_tdtitre');
  5574. appendTdText(tr,'Options de la Vue :',true);
  5575. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5576. tbody = appendSubTable(td);
  5577. tr = appendTr(tbody);
  5578. td = appendTdText(tr,'Vue externe : ');
  5579. var select = document.createElement('select');
  5580. select.id = 'vueext';
  5581. td.appendChild(select);
  5582. var listeVues2D = [
  5583. 'Bricol\' Vue',
  5584. 'Vue du CCM',
  5585. 'Vue Gloumfs 2D',
  5586. 'Vue Gloumfs 3D',
  5587. 'Grouky Vue!'
  5588. ];
  5589. for(var i=0 ; i<listeVues2D.length ; i++) {
  5590. appendOption(select,listeVues2D[i],listeVues2D[i]);
  5591. }
  5592. if(MY_getValue('VUEEXT')) {
  5593. select.value = MY_getValue('VUEEXT');
  5594. }
  5595. td = appendTd(tr);
  5596. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  5597. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  5598. tr = appendTr(tbody);
  5599. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  5600. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  5601. td = appendTd(tr);
  5602. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  5603. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  5604. /* Interface Tactique */
  5605. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5606. appendText(td,'Interface Tactique : ',true);
  5607. select = document.createElement('select');
  5608. select.id = 'itSelect';
  5609. appendOption(select,'none','Aucune');
  5610. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  5611. // seule interface supportée !
  5612. td.appendChild(select);
  5613. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5614. tbody = appendSubTable(td);
  5615. tbody.id = 'itBody';
  5616. select.onchange = onChangeIT;
  5617. var str = MY_getValue(numTroll+'.INFOSIT');
  5618. if(str) {
  5619. select.value = str.slice(0,str.indexOf('$'));
  5620. onChangeIT();
  5621. }
  5622. /* Options diverses */
  5623. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5624. appendText(td,'Options diverses :',true);
  5625. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5626. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  5627. appendText(td,
  5628. ' Afficher les caractéristiques des équipements des autres Trõlls');
  5629. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5630. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  5631. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  5632. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5633. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  5634. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  5635. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5636. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  5637. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  5638. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5639. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  5640. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  5641. td = appendTd(appendTr(mainBody,"mh_tdpage"));
  5642. appendCheckBox(td,"oldShoolStyle",MY_getValue(numTroll+".OLDSCHOOL")=="true");
  5643. appendText(td," Ouvrir l'ancien profil par défaut");
  5644. /* Bouton SaveAll */
  5645. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  5646. input = appendButton(td,'Sauvegarder',saveAll);
  5647. input.id = 'saveAll';
  5648. }
  5649.  
  5650. function insertCreditsTable(insertPt) {
  5651. var tbody = insertMainTable(insertPt);
  5652. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  5653. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  5654. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  5655.  
  5656. var ul = document.createElement('ul');
  5657. td.appendChild(ul);
  5658. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  5659. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  5660. appendLI(ul,'Reivax (4234) pour les infos bulles');
  5661. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  5662. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  5663. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  5664. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  5665. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  5666. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  5667. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  5668. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  5669. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  5670. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  5671. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  5672. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  5673. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  5674. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  5675. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  5676. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  5677. }
  5678.  
  5679.  
  5680. /* [functions] Obsolètes */
  5681. function deleteEnchantement()
  5682. {
  5683. try
  5684. {
  5685. var idEquipement = this.getAttribute('name');
  5686. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  5687. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  5688. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  5689. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  5690. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  5691. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5692. var string = "";
  5693. for(var i=0;i<listeEquipement.length;i++)
  5694. {
  5695. if(listeEquipement[i]!=idEquipement)
  5696. if(string=="")
  5697. string = listeEquipement[i];
  5698. else
  5699. string += ";"+listeEquipement[i];
  5700. }
  5701. if(string=="")
  5702. {
  5703. MY_removeValue(numTroll+".enchantement.liste");
  5704. var table = this.parentNode.parentNode.parentNode.parentNode;
  5705. var parent = table.parentNode;
  5706. for(var i=0;i<parent.childNodes.length;i++)
  5707. {
  5708. if(parent.childNodes[i]==table)
  5709. {
  5710. parent.removeChild(parent.childNodes[i-1]);
  5711. parent.removeChild(parent.childNodes[i-1]);
  5712. parent.removeChild(parent.childNodes[i-1]);
  5713. break;
  5714. }
  5715. }
  5716. }
  5717. else
  5718. {
  5719. MY_getValue(numTroll+".enchantement.liste",string);
  5720. this.parentNode.parentNode.parentNode
  5721. .removeChild(this.parentNode.parentNode);
  5722. }
  5723. }
  5724. catch(e)
  5725. {
  5726. window.alert(e);
  5727. }
  5728. }
  5729. /* [functions] fin Obsolètes */
  5730.  
  5731. /*-[functions]---------------- Partie principale -----------------------------*/
  5732.  
  5733. function do_option() {
  5734. start_script(712);
  5735.  
  5736. // Pour cryptage des mdp IT
  5737. //appendNewScript(URL_tilk_js + 'md5.js'); // source intégré dans tout_MZ
  5738.  
  5739. var insertPoint = document.getElementById('footer1');
  5740. insertBefore(insertPoint,document.createElement('p'));
  5741. insertTitle(insertPoint,'Mountyzilla : Options');
  5742. insertOptionTable(insertPoint);
  5743. /* insertion enchantements ici
  5744. if(...)
  5745. insertEnchantementTable();
  5746. */
  5747. insertBefore(insertPoint,document.createElement('p'));
  5748. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  5749. ti.onclick = function (e) {
  5750. var evt = e || window.event;
  5751. if (evt.shiftKey) {
  5752. var oldDev = MY_getValue('MZ_dev');
  5753. if (oldDev) {
  5754. MY_removeValue('MZ_dev');
  5755. } else {
  5756. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  5757. MY_setValue('MZ_dev', 1);
  5758. }
  5759. document.location.href = document.location.href;
  5760. }
  5761. }
  5762. insertCreditsTable(insertPoint);
  5763. insertBefore(insertPoint,document.createElement('p'));
  5764.  
  5765. /* [zone] Obsolète ?? */
  5766. if(MY_getValue(numTroll+".enchantement.liste")
  5767. && MY_getValue(numTroll+".enchantement.liste")!="" )
  5768. {
  5769. insertTitle(insertPoint, 'Les Enchantements en cours');
  5770. table = document.createElement('table');
  5771. table.setAttribute('width', '98%');
  5772. table.setAttribute('border', '0');
  5773. table.setAttribute('align', 'center');
  5774. table.setAttribute('cellpadding', '2');
  5775. table.setAttribute('cellspacing', '1');
  5776. table.setAttribute('class', 'mh_tdborder');
  5777.  
  5778. tbody = document.createElement('tbody');
  5779. table.appendChild(tbody);
  5780. tr = appendTr(tbody, 'mh_tdtitre');
  5781. appendTdText(tr, 'Equipement',1);
  5782. appendTdText(tr, 'Composants',1);
  5783. appendTdText(tr, 'Enchanteur',1);
  5784. appendTdText(tr, 'Action',1);
  5785. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5786. for(var i=0;i<listeEquipement.length;i++)
  5787. {
  5788. try
  5789. {
  5790. var idEquipement = listeEquipement[i];
  5791. var nomEquipement = MY_getValue(numTroll+".enchantement."
  5792. +idEquipement+".objet");
  5793. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  5794. +idEquipement+".enchanteur").split(";");
  5795. var ul = document.createElement('UL');
  5796. for(var j=0;j<3;j++)
  5797. {
  5798. var infoComposant = MY_getValue(numTroll+".enchantement."
  5799. +idEquipement+".composant."+j).split(";");
  5800. var texte = infoComposant[4].replace("Ril ","Œil ");
  5801. for(var k=5;k<infoComposant.length;k++)
  5802. {
  5803. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  5804. }
  5805. li = appendLI(ul,texte);
  5806. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  5807. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  5808. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  5809. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  5810. string+= '<input type="hidden" name="q" value="min" />';
  5811. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  5812. 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>';
  5813.  
  5814. string+= '</form>';
  5815. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  5816. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  5817. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  5818. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  5819. li.innerHTML += string;
  5820. }
  5821. tr = appendTr(tbody, 'mh_tdpage');
  5822. td = appendTdText(tr, nomEquipement);
  5823. td.setAttribute('valign', 'center');
  5824. td = document.createElement('td');
  5825. td.appendChild(ul);
  5826. tr.appendChild(td);
  5827. td.setAttribute('valign', 'center');
  5828. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  5829. td.setAttribute('valign', 'center');
  5830. td = document.createElement('td');
  5831. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  5832. input.setAttribute('name', idEquipement);
  5833. tr.appendChild(td);
  5834. td.setAttribute('valign', 'center');
  5835. }
  5836. catch(e)
  5837. {
  5838. }
  5839. }
  5840. insertBefore(insertPoint, table);
  5841. insertBefore(insertPoint, document.createElement('p'));
  5842. }
  5843. /* [zone] fin Obsolète ?? */
  5844.  
  5845.  
  5846. displayScriptTime();
  5847. }
  5848.  
  5849. /*******************************************************************************
  5850. * This file is part of Mountyzilla. *
  5851. * *
  5852. * Mountyzilla is free software; you can redistribute it and/or modify *
  5853. * it under the terms of the GNU General Public License as published by *
  5854. * the Free Software Foundation; either version 2 of the License, or *
  5855. * (at your option) any later version. *
  5856. * *
  5857. * Mountyzilla is distributed in the hope that it will be useful, *
  5858. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5859. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5860. * GNU General Public License for more details. *
  5861. * *
  5862. * You should have received a copy of the GNU General Public License *
  5863. * along with Mountyzilla; if not, write to the Free Software *
  5864. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5865. *******************************************************************************/
  5866.  
  5867. // x~x equip
  5868.  
  5869. /**
  5870. * 2014-02-08 - v2.0a (from scratch)
  5871. * 2014-02-18 - v2.0a0
  5872. * - ajout calcul Carats / UM des minerais + totaux
  5873. * 2014-03-06 - v2.0a1
  5874. * - retour Infos EM des Champis
  5875. * TODO
  5876. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  5877. */
  5878.  
  5879. function traiteChampis() {
  5880. try{
  5881. var tr = document.getElementById('mh_objet_hidden_Champignon');
  5882. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  5883. }
  5884. catch(e){return;}
  5885. if(trlist.length<=0) return;
  5886. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  5887. var node = trlist.snapshotItem(i).childNodes[7];
  5888. var str = node.textContent.trim();
  5889. var type = str.slice(0,str.lastIndexOf(' '));
  5890. var mundi = mundiChampi[type];
  5891. if(!mundi) continue;
  5892. var urlImg = URL_MZimg
  5893. +'Competences/ecritureMagique.png';
  5894. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  5895. appendText(node,' ');
  5896. node.appendChild(img);
  5897. }
  5898. }
  5899.  
  5900. function traiteCompos() {
  5901. try {
  5902. var tr = document.getElementById('mh_objet_hidden_Composant');
  5903. var tbody = document.evaluate("./td/table/tbody",
  5904. tr, null, 9, null).singleNodeValue;
  5905. }
  5906. catch(e) {return;}
  5907. insererInfosEM(tbody);
  5908. }
  5909.  
  5910. function traiteMinerai() {
  5911. try{
  5912. var tr = document.getElementById('mh_objet_hidden_Minerai');
  5913. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  5914. }
  5915. catch(e){return;}
  5916. if(trlist.length<=0) return;
  5917. var totaux = {};
  5918. var str;
  5919. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  5920. var node = trlist.snapshotItem(i);
  5921. var nature = node.childNodes[7].textContent,
  5922. caracs = node.childNodes[9].textContent;
  5923. var taille = Number(caracs.match(/\d+/)[0]);
  5924. var coef = 1;
  5925. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  5926. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  5927. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  5928. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5929. if(nature.indexOf('Mithril')!=-1) {
  5930. coef = 0.2*coef;
  5931. str = ' | UM: ';
  5932. }
  5933. else {
  5934. coef = 0.75*coef+1.25;
  5935. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5936. str = ' | Carats: ';
  5937. }
  5938. var carats = Math.round(taille*coef)
  5939. appendText(node.childNodes[9], str+carats );
  5940. if(!totaux[nature]) {
  5941. totaux[nature] = [taille,carats];
  5942. }
  5943. else {
  5944. totaux[nature][0] += taille;
  5945. totaux[nature][1] += carats;
  5946. }
  5947. }
  5948. str = 'Total : ';
  5949. for(var nature in totaux) {
  5950. if(str.length>8) str += ', ';
  5951. if(nature.indexOf('Mithril')!=-1) {
  5952. str += nature+totaux[nature][1]+' UM';
  5953. }
  5954. else {
  5955. str += nature+totaux[nature][0]+'U/'
  5956. +totaux[nature][1]+'c';
  5957. }
  5958. }
  5959. /*var node = document.getElementById('mh_plus_Minerai');
  5960. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  5961. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  5962. if(!titre) return;*/
  5963. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  5964. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  5965. td.colSpan = 7;
  5966. }
  5967.  
  5968. function do_equip() {
  5969. start_script();
  5970.  
  5971. traiteChampis();
  5972. traiteCompos();
  5973. traiteMinerai();
  5974.  
  5975. displayScriptTime();
  5976. }
  5977.  
  5978. /*******************************************************************************
  5979. * This file is part of Mountyzilla. *
  5980. * *
  5981. * Mountyzilla is free software; you can redistribute it and/or modify *
  5982. * it under the terms of the GNU General Public License as published by *
  5983. * the Free Software Foundation; either version 2 of the License, or *
  5984. * (at your option) any later version. *
  5985. * *
  5986. * Mountyzilla is distributed in the hope that it will be useful, *
  5987. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5988. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5989. * GNU General Public License for more details. *
  5990. * *
  5991. * You should have received a copy of the GNU General Public License *
  5992. * along with Mountyzilla; if not, write to the Free Software *
  5993. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5994. *******************************************************************************/
  5995.  
  5996. // x~x diplo
  5997.  
  5998. /*
  5999. TODO:
  6000. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6001. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6002. V Étape 3: Ajout de la diplo perso
  6003. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6004. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6005. Options Globales:
  6006. Actuelles:
  6007. numTroll.USECSS,
  6008. numTroll.NODIPLO
  6009. NOMYTH
  6010. Nouvelles:
  6011. TODO numTroll.USECSS
  6012. numTroll.diplo.off (remplace NODIPLO)
  6013. numTroll.diplo.guilde
  6014. numTroll.diplo.perso
  6015. Structure de diplo.guilde:
  6016. isOn: 'true' ou 'false'
  6017. isDetailOn: 'true' ou 'false'
  6018. guilde
  6019. > id
  6020. > couleur
  6021. AllAmis,AllEnnemis: couleur
  6022. Amis0,...,Ennemis5
  6023. > Troll: idTroll1;...;
  6024. > Guilde: idGuilde1;...;
  6025. > titre
  6026. > couleur
  6027. Structure de diplo.perso:
  6028. isOn: 'true' ou 'false'
  6029. mythiques: couleur
  6030. Troll,Guilde,Monstre:
  6031. > id
  6032. > couleur
  6033. > description
  6034. */
  6035.  
  6036. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6037.  
  6038. function couleurAleatoire() {
  6039. var alph = '0123456789ABCDEF'.split('');
  6040. var clr = '#';
  6041. for (var i=0; i<6; i++) {
  6042. clr+=alph[ Math.floor(16*Math.random()) ];
  6043. }
  6044. return clr;
  6045. }
  6046.  
  6047. function isCouleur(str) {
  6048. return /^#[0-9A-F]{6}$/i.test(str);
  6049. }
  6050.  
  6051. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6052.  
  6053. function appendChoixCouleur(node,id) {
  6054. var span = document.createElement('span');
  6055. span.id = 'span'+id;
  6056. if(isDetailOn) {
  6057. span.style.display = 'none';
  6058. }
  6059. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6060. if(diploGuilde[id]) {
  6061. couleur = diploGuilde[id];
  6062. }
  6063. appendText(span,' - Couleur HTML: ');
  6064. var input = appendTextbox(span,'text',id,7,7,couleur);
  6065. input.onkeyup = previewCouleur;
  6066. input.onchange = previewCouleur;
  6067. input.onkeyup();
  6068. node.appendChild(span);
  6069. }
  6070.  
  6071. function insertChoixCouleur(node,id) {
  6072. var span = document.createElement('span');
  6073. span.id = 'span'+id;
  6074. // La couleur détaillée passera à une valeur aléatoire
  6075. // si toggle vers isDetailOn
  6076. var couleur = couleurAleatoire();
  6077. if(!isDetailOn) {
  6078. span.style.display = 'none';
  6079. } else if(diploGuilde[id]) {
  6080. couleur = diploGuilde[id].couleur;
  6081. }
  6082. appendText(span,' - Couleur HTML: ');
  6083. var input = appendTextbox(span,'text',id,7,7,couleur);
  6084. input.onkeyup = previewCouleur;
  6085. input.onchange = previewCouleur;
  6086. input.onkeyup();
  6087. insertBefore(node,span);
  6088. }
  6089.  
  6090. function setChoixCouleurs() {
  6091. try {
  6092. var form = document.getElementsByName('ActionForm')[0];
  6093. var nodesAE = document.evaluate(
  6094. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6095. form, null, 7, null
  6096. );
  6097. var nodes = document.evaluate(
  6098. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6099. form, null, 7, null
  6100. );
  6101. } catch(e) {
  6102. window.console.error('[Diplomatie] Structure de la page non reconnue');
  6103. return false;
  6104. };
  6105. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6106. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6107. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6108. for(var i=0 ; i<5 ; i++) {
  6109. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6110. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6111. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6112. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6113. }
  6114. return true;
  6115. }
  6116.  
  6117. function fetchDiploGuilde() {
  6118. try {
  6119. for(var AE in {Amis:0,Ennemis:0}) {
  6120. for(var i=0 ; i<5 ; i++) {
  6121. /* Récup des A/E de rang i */
  6122. var td = document.getElementById('td'+AE+i);
  6123. var ligne = td.getElementsByTagName('table')[0].rows;
  6124. var titre = trim(td.firstChild.textContent);
  6125. // On laisse la gestion des couleurs à setChoixCouleurs:
  6126. var couleur = document.getElementById(AE+i).value;
  6127. diploGuilde[AE+i] = {
  6128. Troll:'',
  6129. Guilde:'',
  6130. titre: titre,
  6131. couleur: couleur
  6132. };
  6133. for(var j=1 ; j<ligne.length ; j++) {
  6134. var str = trim(ligne[j].cells[0].textContent);
  6135. var idx = str.lastIndexOf('(');
  6136. var num = str.slice(idx+1,-1);
  6137. var type = trim(ligne[j].cells[1].textContent);
  6138. diploGuilde[AE+i][type] += num+';';
  6139. }
  6140. }
  6141. }
  6142. } catch(e) {
  6143. window.console.error('[Diplomatie] Échec de récupération de la diplo\n'+e);
  6144. return false;
  6145. }
  6146. return true;
  6147. }
  6148.  
  6149.  
  6150. /*-[functions]--------------------- Handlers ---------------------------------*/
  6151.  
  6152. function toggleDetails() {
  6153. isDetailOn = !isDetailOn;
  6154. for(var AE in {Amis:0,Ennemis:0}) {
  6155. document.getElementById('spanAll'+AE).style.display =
  6156. (isDetailOn?'none':'');
  6157. for(var i=0 ; i<5 ; i++) {
  6158. document.getElementById('span'+AE+i).style.display =
  6159. (isDetailOn?'':'none');
  6160. }
  6161. }
  6162. }
  6163.  
  6164. function toggleMythiques() {
  6165. isMythiquesOn = !isMythiquesOn;
  6166. document.getElementById('spanMythiques').style.display =
  6167. (isMythiquesOn?'':'none');
  6168. }
  6169.  
  6170. function previewCouleur() {
  6171. var value = this.value;
  6172. if(isCouleur(value)) {
  6173. this.style.backgroundColor = value;
  6174. this.title = '';
  6175. } else {
  6176. this.style.backgroundColor = '';
  6177. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  6178. }
  6179. }
  6180.  
  6181. function appendMenuType(node,duType) {
  6182. var select = document.createElement('select');
  6183. select.className = 'SelectboxV2';
  6184. var type = ['Guilde','Troll','Monstre'];
  6185. for(var i=0 ; i<3 ; i++) {
  6186. appendOption(select,type[i],type[i]);
  6187. if(type[i]==duType) { select.selectedIndex=i; }
  6188. }
  6189. node.appendChild(select);
  6190. }
  6191.  
  6192. function ajouteChamp(type,num,couleur,descr) {
  6193. var champs = document.getElementById('diploPerso');
  6194. var nb = champs.rows.length;
  6195. var tr = champs.insertRow(-1);
  6196. var td = appendTd(tr);
  6197. appendMenuType(td,type);
  6198. td = appendTd(tr);
  6199. appendText(td,' n°');
  6200. appendTextbox(td,'text','num'+nb,6,15,num);
  6201. td = appendTd(tr);
  6202. appendText(td,' couleur HTML:');
  6203. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  6204. input.onkeyup = previewCouleur;
  6205. input.onchange = previewCouleur;
  6206. input.onkeyup();
  6207. td = appendTd(tr);
  6208. appendText(td,' Description:');
  6209. appendTextbox(td,'text','descr'+nb,30,150,descr);
  6210. td = appendTd(tr);
  6211. var span = document.createElement('span');
  6212. appendText(span,'[ok!]',true);
  6213. span.style.visibility = 'hidden';
  6214. td.appendChild(span);
  6215. td = appendTd(tr);
  6216. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  6217. }
  6218.  
  6219. function retireCeChamp() {
  6220. var thisTr = this.parentNode.parentNode;
  6221. thisTr.parentNode.removeChild(thisTr);
  6222. var champs = document.getElementById('diploPerso');
  6223. if(champs.rows.length==0) { ajouteChamp(); }
  6224. }
  6225.  
  6226. function valideChamp(champ) {
  6227. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  6228. isCouleur(champ.cells[2].childNodes[1].value);
  6229. if(isValide) {
  6230. champ.cells[4].firstChild.style.visibility = 'visible';
  6231. } else {
  6232. champ.cells[4].firstChild.style.visibility = 'hidden';
  6233. }
  6234. return isValide;
  6235. }
  6236.  
  6237. function sauvegarderTout() {
  6238. /* Diplo de guilde */
  6239. diploGuilde.isOn =
  6240. document.getElementById('isGuildeOn').checked?'true':'false';
  6241. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  6242. var numGuilde = Number(document.getElementById('numGuilde').value);
  6243. var couleur = document.getElementById('couleurGuilde').value;
  6244. if(numGuilde) {
  6245. diploGuilde.guilde = {
  6246. id: numGuilde,
  6247. couleur: couleur
  6248. };
  6249. } else {
  6250. delete diploGuilde.guilde;
  6251. }
  6252. for(var AE in {Amis:0,Ennemis:0}) {
  6253. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  6254. for(var i=0 ; i<5 ; i++) {
  6255. if(isDetailOn) {
  6256. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  6257. } else {
  6258. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  6259. }
  6260. }
  6261. }
  6262. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  6263. /* Diplo personnelle (ex-fonction saveChamps) */
  6264. var champs = document.getElementById('diploPerso');
  6265. diploPerso = {
  6266. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  6267. Guilde: {},
  6268. Troll: {},
  6269. Monstre: {}
  6270. };
  6271. if(isMythiquesOn &&
  6272. isCouleur(document.getElementById('couleurMythiques').value)) {
  6273. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  6274. }
  6275. for(var i=0 ; i<champs.rows.length ; i++) {
  6276. if(valideChamp(champs.rows[i])) {
  6277. var type = champs.rows[i].cells[0].firstChild.value;
  6278. var num = champs.rows[i].cells[1].childNodes[1].value;
  6279. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  6280. var descr = champs.rows[i].cells[3].childNodes[1].value;
  6281. diploPerso[type][num] = {
  6282. couleur: couleur
  6283. };
  6284. if(descr) {
  6285. diploPerso[type][num].titre = descr;
  6286. }
  6287. }
  6288. }
  6289. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  6290.  
  6291. avertissement('Données sauvegardées');
  6292. }
  6293.  
  6294.  
  6295. /*-[functions]------------- Modifications de la page -------------------------*/
  6296.  
  6297. function creeTablePrincipale() {
  6298. var insertPt = document.getElementById('insertPt');
  6299. /* Titre + bouton de Sauvegarde */
  6300. var tr = insertTr(insertPt,'mh_tdtitre');
  6301. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  6302. appendButton(td,'Sauvegarder',sauvegarderTout);
  6303. /* Options fixes */
  6304. tr = insertTr(insertPt,'mh_tdpage');
  6305. td = appendTdText(tr,'Diplomatie de guilde:',true);
  6306. appendBr(td);
  6307. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  6308. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  6309. appendBr(td);
  6310. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  6311. appendText(td,'Utiliser des couleurs détaillées (10)');
  6312. /* Diplo personnelle */
  6313. tr = insertTr(insertPt,'mh_tdpage');
  6314. td = appendTdText(tr,'Diplomatie personnelle:',true);
  6315. appendBr(td);
  6316. // Diplo Mythiques
  6317. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  6318. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  6319. var span = document.createElement('span');
  6320. span.id = 'spanMythiques';
  6321. if(!isMythiquesOn) {
  6322. span.style.display = 'none';
  6323. }
  6324. var couleur = '#FFAAAA';
  6325. if(diploPerso.mythiques) {
  6326. couleur = diploPerso.mythiques;
  6327. }
  6328. appendText(span,' - couleur HTML:');
  6329. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  6330. input.onkeyup = previewCouleur;
  6331. input.onchange = previewCouleur;
  6332. input.onkeyup();
  6333. td.appendChild(span);
  6334. appendBr(td);
  6335. // Diplo éditable
  6336. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  6337. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  6338. appendBr(td);
  6339. var table = document.createElement('table');
  6340. table.id = 'diploPerso'
  6341. td.appendChild(table);
  6342. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  6343. for(var num in diploPerso[type]) {
  6344. ajouteChamp(
  6345. type,
  6346. num,
  6347. diploPerso[type][num].couleur,
  6348. diploPerso[type][num].titre
  6349. );
  6350. }
  6351. }
  6352. if(table.rows.length==0) {
  6353. ajouteChamp();
  6354. }
  6355. appendButton(td,'Ajouter',ajouteChamp)
  6356. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  6357. appendText(td,' ');
  6358. appendButton(td,
  6359. 'Exemples de couleur',
  6360. function() {
  6361. var fenetre = window.open(
  6362. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  6363. 'Divers',
  6364. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  6365. 'status=0,menubar=0,resizable=1,scrollbars=1'
  6366. );
  6367. fenetre.focus();
  6368. }
  6369. );
  6370. /* Couleur de Guilde */
  6371. tr = insertTr(insertPt,'mh_tdtitre');
  6372. td = appendTdText(tr,'GUILDE',true);
  6373. appendText(td,' - n°');
  6374. appendTextbox(td,'text','numGuilde',5,10,
  6375. diploGuilde.guilde && diploGuilde.guilde.id ?
  6376. diploGuilde.guilde.id : ''
  6377. );
  6378. appendText(td,' - Couleur HTML: ');
  6379. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  6380. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  6381. diploGuilde.guilde.couleur : '#BBBBFF'
  6382. );
  6383. input.onkeyup = previewCouleur;
  6384. input.onchange = previewCouleur;
  6385. input.onkeyup();
  6386. }
  6387.  
  6388.  
  6389. /*-[functions]----------------------- Main -----------------------------------*/
  6390.  
  6391. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6392. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6393. var isDetailOn = diploGuilde.isDetailOn=='true';
  6394. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6395. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6396. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6397.  
  6398. function do_diplo() {
  6399. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6400. creeTablePrincipale();
  6401. }
  6402. }
  6403.  
  6404. /*******************************************************************************
  6405. * This file is part of Mountyzilla. *
  6406. * *
  6407. * Mountyzilla is free software; you can redistribute it and/or modify *
  6408. * it under the terms of the GNU General Public License as published by *
  6409. * the Free Software Foundation; either version 2 of the License, or *
  6410. * (at your option) any later version. *
  6411. * *
  6412. * Mountyzilla is distributed in the hope that it will be useful, *
  6413. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6414. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6415. * GNU General Public License for more details. *
  6416. * *
  6417. * You should have received a copy of the GNU General Public License *
  6418. * along with Mountyzilla; if not, write to the Free Software *
  6419. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6420. *******************************************************************************/
  6421.  
  6422. // x~x cdmcomp
  6423.  
  6424. var cdm = '';
  6425.  
  6426. function getNonNegInts(str) {
  6427. var nbrs = str.match(/\d+/g);
  6428. for(var i=0 ; i<nbrs.length ; i++) {
  6429. nbrs[i] = Number(nbrs[i]);
  6430. }
  6431. return nbrs;
  6432. }
  6433.  
  6434. function traiteCdMcomp() {
  6435. try {
  6436. var msgEffet = document.getElementById('msgEffet');
  6437. } catch(e) {
  6438. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  6439. return;
  6440. }
  6441.  
  6442. // Teste si ce message du bot est un message de CdM
  6443. if(!document.evaluate(
  6444. "./p/b/text()[contains(.,'fait partie')]",
  6445. msgEffet, null, 9, null
  6446. ).singleNodeValue) {
  6447. return;
  6448. }
  6449. // Début de récupération de la CdM
  6450. cdm = document.evaluate(
  6451. "./p/b/text()[contains(.,'fait partie')]",
  6452. msgEffet, null, 9, null
  6453. ).singleNodeValue.nodeValue+'\n';
  6454. var tbody = document.evaluate(
  6455. "descendant::table/tbody",
  6456. msgEffet, null, 9, null
  6457. ).singleNodeValue;
  6458. var nomStat = document.evaluate(
  6459. "./tr/td[1]/b/text()",
  6460. tbody, null, 7, null
  6461. );
  6462. var valStat = document.evaluate(
  6463. "./tr/td[2]/descendant::text()",
  6464. tbody, null, 7, null
  6465. );
  6466. var i=0;
  6467. while(i<nomStat.snapshotLength) {
  6468. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  6469. cdm += 'Armure : ';
  6470. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  6471. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  6472. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  6473. armp = [0,armp[0]];
  6474. }
  6475. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  6476. armm = [0,armm[0]];
  6477. }
  6478. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  6479. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  6480. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  6481. } else {
  6482. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6483. }
  6484. cdm += ')\n';
  6485. i++;
  6486. } else {
  6487. cdm += nomStat.snapshotItem(i).nodeValue+
  6488. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  6489. }
  6490. i++;
  6491. }
  6492. // Envoi auto ou insertion bouton envoi (suivant option)
  6493. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  6494. sendInfoCDM();
  6495. var p = document.createElement('p');
  6496. p.style.color = 'green';
  6497. appendText(p,'CdM envoyée vers la base MountyZilla !');
  6498. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  6499. } else {
  6500. insertButtonCdm('as_Action', sendInfoCDM);
  6501. }
  6502.  
  6503. // Insertion de l'estimation des PV restants
  6504. var pv = valStat.snapshotItem(1).nodeValue;
  6505. if(pv.indexOf("entre")==-1) {
  6506. return;
  6507. }
  6508. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  6509. if(pv) {
  6510. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  6511. appendTdText(tr, pv[0], true);
  6512. appendTdText(tr, pv[1], true);
  6513. }
  6514. }
  6515.  
  6516. function sendInfoCDM() {
  6517. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  6518. var buttonCDM = this;
  6519. var texte = '';
  6520. FF_XMLHttpRequest({
  6521. method: 'GET',
  6522. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6523. headers : {
  6524. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6525. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6526. },
  6527. onload: function(responseDetails) {
  6528. texte = responseDetails.responseText;
  6529. buttonCDM.value = texte;
  6530. buttonCDM.disabled = true;
  6531. }
  6532. });
  6533. }
  6534.  
  6535. function do_cdmcomp() {
  6536. start_script(31);
  6537. traiteCdMcomp();
  6538. displayScriptTime();
  6539. }
  6540.  
  6541. /*********************************************************************************
  6542. * This file is part of Mountyzilla. *
  6543. * *
  6544. * Mountyzilla is free software; you can redistribute it and/or modify *
  6545. * it under the terms of the GNU General Public License as published by *
  6546. * the Free Software Foundation; either version 2 of the License, or *
  6547. * (at your option) any later version. *
  6548. * *
  6549. * Mountyzilla is distributed in the hope that it will be useful, *
  6550. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6551. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6552. * GNU General Public License for more details. *
  6553. * *
  6554. * You should have received a copy of the GNU General Public License *
  6555. * along with Mountyzilla; if not, write to the Free Software *
  6556. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6557. *********************************************************************************/
  6558.  
  6559. // x~x cmdbot
  6560.  
  6561. /* v0.2 by Dab - 2013-08-20
  6562. * - patch dégueu pour gérer la décomposition P/M de l'armure
  6563. */
  6564.  
  6565. var buttonCDM;
  6566.  
  6567. /*******************************************************************************************
  6568. CDM :
  6569. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  6570.  
  6571. Il ne vous est pas possible d'améliorer cette compétence.
  6572.  
  6573. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  6574. Niveau : Inimaginable (entre 49 et 51)
  6575. Points de Vie : Surtrollesque (entre 450 et 470)
  6576. Blessure (Approximatif) : 0 %
  6577. Dés d'Attaque : Impressionnant (entre 30 et 32)
  6578. Dés d'Esquive : Impressionnant (entre 28 et 30)
  6579. Dés de Dégat : Très Fort (entre 18 et 20)
  6580. Dés de Régénération : Excellent (égal à 13)
  6581. Armure Physique : Moyen (entre 10 et 12)
  6582. Armure Magique : Faible (inférieur à 6)
  6583. Vue : Moyen (entre 9 et 11)
  6584. Maitrise Magique : Inimaginable (supérieur à 6000)
  6585. Résistance Magique : Inimaginable (supérieur à 6000)
  6586. Nombre d'attaques : 1
  6587. Vitesse de Déplacement : Normale
  6588. Voir le Caché : Oui
  6589. Attaque à distance : Non
  6590. Attaque magique : Oui
  6591. Vole : Non
  6592. Sang froid : Inexistant
  6593. DLA : Milieu
  6594. Durée Tour : Remarquable (entre 9 et 11)
  6595. Chargement : Vide
  6596. Bonus Malus : Aucun
  6597.  
  6598. Vous avez également gagné 1 PX pour la réussite.
  6599. *******************************************************************************************
  6600. BOT :
  6601. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  6602.  
  6603. Le Monstre ciblé fait partie des : Mort-Vivant
  6604.  
  6605. Niveau : Incroyable (entre 36 et 38)
  6606. *******************************************************************************************/
  6607.  
  6608. function getNNInt(str) {
  6609. var nbrs = str.match(/\d+/g);
  6610. for (var i=0 ; i<nbrs.length ; i++)
  6611. nbrs[i] = parseInt(nbrs[i]);
  6612. return nbrs;
  6613. }
  6614.  
  6615. function sendCDM() {
  6616. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6617. document, null, 9, null).singleNodeValue;
  6618. cdm = td.innerHTML;
  6619. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  6620. "$3$4 ($1 - N°$2)<br>");
  6621. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  6622. 'Blessure : XX % (approximativement)');
  6623. // Supprime la décomposition P/M de l'Armure
  6624. var bgn = cdm.indexOf('Armure Physique');
  6625. if (bgn!=-1) {
  6626. var end = cdm.indexOf('Vue')-2;
  6627. var lines = cdm.substring(bgn,end).split('<br>');
  6628. var armp = getNNInt(lines[0]);
  6629. var armm = getNNInt(lines[1]);
  6630. if (lines[0].indexOf('(inf')!=-1)
  6631. armp = [0,armp[0]];
  6632. if (lines[1].indexOf('(inf')!=-1)
  6633. armm = [0,armm[0]];
  6634. var insrt = 'Armure : ';
  6635. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  6636. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  6637. else
  6638. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6639. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  6640. }
  6641. cdm = cdm.replace(/<br>/g,'\n');
  6642. FF_XMLHttpRequest({
  6643. method: 'GET',
  6644. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6645. headers : {
  6646. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6647. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6648. },
  6649. onload: function(responseDetails) {
  6650. buttonCDM.value=responseDetails.responseText;
  6651. buttonCDM.disabled = true;
  6652. }
  6653. });
  6654. }
  6655.  
  6656. function traiteCdMmsg() {
  6657. // Teste si ce message du bot est un message de CdM
  6658. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6659. document, null, 9, null).singleNodeValue;
  6660. if (!td) return false;
  6661. cdm = td.innerHTML;
  6662. // Insertion de l'estimation des PV restants
  6663. var des = cdm.indexOf('Dés');
  6664. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  6665. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  6666. if(pv)
  6667. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  6668.  
  6669. // Insertion bouton envoi + espace
  6670. buttonCDM = insertButtonCdm('bClose',sendCDM);
  6671. }
  6672.  
  6673. /*function traitePouvoir() {
  6674. // Teste si ce message du bot est un message de CdM
  6675. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  6676. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  6677. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6678. if (!td)
  6679. return false;
  6680. var infos = td.innerHTML;
  6681. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  6682. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  6683. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  6684. var date = /alors : ([^<]+)\./.exec(infos)[1];
  6685. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  6686. var effetPouvoir="";
  6687. var full=false;
  6688. if(infos.indexOf("REDUIT")!=-1) {
  6689. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  6690. }
  6691. else {
  6692. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  6693. full=true;
  6694. }
  6695. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  6696. // On insère le bouton et un espace
  6697. //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));
  6698. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  6699. if(!MY_getValue('AUTOSENDPOUV'))
  6700. {
  6701. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  6702. button.setAttribute("onClick", "window.open('" + url
  6703. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  6704. + "this.value='Merci de votre participation'; this.disabled = true;");
  6705. }
  6706. else
  6707. {
  6708. FF_XMLHttpRequest({
  6709. method: 'GET',
  6710. url: url,
  6711. headers : {
  6712. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6713. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6714. }});
  6715. }
  6716. }*/
  6717.  
  6718. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  6719. traiteCdMmsg();
  6720. }
  6721. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  6722.  
  6723. /*******************************************************************************
  6724. * This file is part of Mountyzilla. *
  6725. * *
  6726. * Mountyzilla is free software; you can redistribute it and/or modify *
  6727. * it under the terms of the GNU General Public License as published by *
  6728. * the Free Software Foundation; either version 2 of the License, or *
  6729. * (at your option) any later version. *
  6730. * *
  6731. * Mountyzilla is distributed in the hope that it will be useful, *
  6732. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6733. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6734. * GNU General Public License for more details. *
  6735. * *
  6736. * You should have received a copy of the GNU General Public License *
  6737. * along with Mountyzilla; if not, write to the Free Software *
  6738. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6739. *******************************************************************************/
  6740.  
  6741. // x~x menu
  6742. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  6743.  
  6744. var menuRac, mainIco;
  6745.  
  6746. function updateData() {
  6747. var inputs = document.getElementsByTagName('input');
  6748. var divs = document.getElementsByTagName('div');
  6749. numTroll = inputs[0].value;
  6750. MY_setValue('NUM_TROLL', numTroll);
  6751. MY_setValue('NIV_TROLL',inputs[1].value);
  6752. if(!MY_getValue(numTroll+'.caracs.rm')) {
  6753. MY_setValue(numTroll+'.caracs.rm',0);
  6754. // assure l'init des 4 var de libs
  6755. }
  6756. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  6757. var DLA = new Date(
  6758. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  6759. );
  6760. if(MY_getValue(numTroll+'.DLA.encours')) {
  6761. var DLAstockee = new Date(
  6762. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  6763. );
  6764. if(DLA>DLAstockee) {
  6765. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  6766. // Pose un pb en cas de décalage de DLA
  6767. }
  6768. }
  6769. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  6770. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  6771. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  6772. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  6773. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  6774. }
  6775.  
  6776. function initRaccourcis() {
  6777. var anotherURL = MY_getValue('URL1');
  6778. if(!anotherURL) { return; }
  6779. /* Création de l'icône faisant apparaître le menu */
  6780. mainIco = document.createElement('img');
  6781. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  6782. if(!urlIco) {
  6783. urlIco =
  6784. URL_MZimg + 'mz_logo_small.png';
  6785. }
  6786. mainIco.src = urlIco;
  6787. mainIco.alt = 'MZ';
  6788. mainIco.style = 'position:fixed; top:0px; left:0px';
  6789. mainIco.onmouseover = afficheMenu;
  6790. document.body.appendChild(mainIco);
  6791. /* Création du menu des Raccourcis */
  6792. menuRac = document.createElement('div');
  6793. menuRac.className = 'mh_textbox';
  6794. menuRac.style =
  6795. 'position:fixed; top:10px; left:10px;'+
  6796. 'max-width:190px;'+
  6797. 'border-radius: 4px; padding: 4px;'+
  6798. 'z-index: 500;'+
  6799. 'visibility: hidden;';
  6800. document.body.appendChild(menuRac);
  6801. document.addEventListener('mousemove',cacheMenu,false);
  6802. var i=1;
  6803. while(anotherURL) {
  6804. var a = document.createElement('a');
  6805. var url = MY_getValue('URL'+i);
  6806. var nom = MY_getValue('URL'+i+'.nom');
  6807. var ico = MY_getValue('URL'+i+'.ico');
  6808. a.href = url;
  6809. a.target = '_blank';
  6810. if(ico) {
  6811. var txt = nom ? nom : '';
  6812. var img = createImage(ico,txt);
  6813. a.appendChild(img);
  6814. }
  6815. else {
  6816. appendText(a,'['+nom+']');
  6817. }
  6818. menuRac.appendChild(a);
  6819. appendBr(menuRac);
  6820. i++;
  6821. anotherURL = MY_getValue('URL'+i);
  6822. }
  6823. }
  6824.  
  6825. function afficheMenu() {
  6826. menuRac.style.visibility = 'visible';
  6827. }
  6828.  
  6829. function cacheMenu(e) {
  6830. if(menuRac.style.visibility=='hidden') { return; }
  6831. // Position souris
  6832. var ptX = e.clientX;
  6833. var ptY = e.clientY;
  6834. // On recalcule en live les BoundingBox pour mainIco et menuRac
  6835. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  6836. var menuRect = menuRac.getBoundingClientRect();
  6837. var icoRect = mainIco.getBoundingClientRect();
  6838. if((ptX>icoRect.width || ptY>icoRect.height) &&
  6839. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  6840. menuRac.style.visibility = 'hidden';
  6841. }
  6842. }
  6843.  
  6844. function oldSchoolProfile() {
  6845. try {
  6846. var lienProfil = document.getElementById("Image1").parentNode;
  6847. lienProfil.href = "Play_profil.php";
  6848. } catch(e) {
  6849. avertissement();
  6850. window.console.log("[MZ menu] Lien vers le profil non trouvé",e);
  6851. }
  6852. }
  6853.  
  6854. function do_menu() {
  6855. updateData();
  6856. initRaccourcis();
  6857. if(MY_getValue(numTroll+".OLDSCHOOL")=="true") {
  6858. oldSchoolProfile();
  6859. }
  6860. }
  6861.  
  6862. /*******************************************************************************
  6863. * This file is part of Mountyzilla. *
  6864. * *
  6865. * Mountyzilla is free software; you can redistribute it and/or modify *
  6866. * it under the terms of the GNU General Public License as published by *
  6867. * the Free Software Foundation; either version 2 of the License, or *
  6868. * (at your option) any later version. *
  6869. * *
  6870. * Mountyzilla is distributed in the hope that it will be useful, *
  6871. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6872. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6873. * GNU General Public License for more details. *
  6874. * *
  6875. * You should have received a copy of the GNU General Public License *
  6876. * along with Mountyzilla; if not, write to the Free Software *
  6877. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6878. *******************************************************************************/
  6879.  
  6880. // x~x vue
  6881.  
  6882. /* TODO
  6883. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  6884. * prévoir fix ("delete infos")
  6885. */
  6886.  
  6887. /*--------------------------- Variables Globales -----------------------------*/
  6888.  
  6889. // Infos remplies par des scripts extérieurs
  6890. var listeCDM = [], listeLevels = [];
  6891.  
  6892. // Position actuelle
  6893. var currentPosition=[0,0,0];
  6894.  
  6895. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  6896. var porteeVue=[0,0,0,0];
  6897.  
  6898. // Fenêtres déplaçables
  6899. var winCurr = null;
  6900. var offsetX, offsetY;
  6901. document.onmousemove = drag;
  6902.  
  6903. // Diplomatie
  6904. var Diplo = {
  6905. Guilde: {},
  6906. Troll: {},
  6907. Monstre: {}
  6908. // .mythiques: uniquement si option activée
  6909. };
  6910. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  6911.  
  6912. // Infos tactiques
  6913. var popup;
  6914.  
  6915. // Gère l'affichage en cascade des popups de CdM
  6916. var nbCDM = 0;
  6917.  
  6918. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  6919.  
  6920. // Utilisé pour supprimer les monstres "engagés"
  6921. var listeEngages = {};
  6922. var isEngagesComputed = false;
  6923. var cursorOnLink = false; // DEBUG: wtf ?
  6924.  
  6925. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  6926. && MY_getValue(numTroll+'.enchantement.liste')!='';
  6927.  
  6928. // Checkboxes de filtrage
  6929. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  6930. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  6931. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  6932. comboBoxNiveauMin, comboBoxNiveauMax;
  6933.  
  6934. /* Acquisition & Stockage des données de DB */
  6935. const typesAFetcher = {
  6936. 'monstres':1,
  6937. 'trolls':1,
  6938. 'tresors':1,
  6939. 'champignons':1,
  6940. 'lieux':1
  6941. }
  6942. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  6943. tr_champignons = {}, tr_lieux = {};
  6944. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  6945. nbChampignons = 0, nbLieux = 0;
  6946.  
  6947. function fetchData(type) {
  6948. try {
  6949. var node = document.getElementById('mh_vue_hidden_'+type);
  6950. // this = MZ.global = sandBox de travail de MZ
  6951. // On définit donc des variables MZ-globales
  6952. this['tr_'+type] = node.getElementsByTagName('tr');
  6953. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  6954. } catch(e) {
  6955. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  6956. }
  6957. }
  6958.  
  6959.  
  6960. /*---------------------------------- DEBUG -----------------------------------*/
  6961. var mainTabs = document.getElementsByClassName('mh_tdborder');
  6962. var x_monstres = tr_monstres;
  6963. var x_trolls = tr_trolls;
  6964. var x_tresors = tr_tresors;
  6965. var x_champis = tr_champignons;
  6966. var x_lieux = tr_lieux;
  6967. /*-------------------------------- FIN DEBUG ---------------------------------*/
  6968.  
  6969.  
  6970. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6971.  
  6972. function positionToString(arr) {
  6973. return arr.join(';');
  6974. }
  6975.  
  6976. function savePosition() {
  6977. // Stocke la position (à jour) de la vue pour les autres scripts
  6978. // DEBUG: Lesquels et pourquoi?
  6979. var pos = getPosition();
  6980. MY_setValue(numTroll+'.position.X',pos[0]);
  6981. MY_setValue(numTroll+'.position.Y',pos[1]);
  6982. MY_setValue(numTroll+'.position.N',pos[2]);
  6983. }
  6984.  
  6985.  
  6986. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  6987. /* INFOS :
  6988. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  6989. * sont identifiables via leur Name
  6990. * les tables-listings sont identifiables via l'ID du tr conteneur
  6991. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  6992. */
  6993.  
  6994. /* [functions] Récup données Utilisateur */
  6995. function getPosition() {
  6996. // Pour rétrocompatibilité
  6997. return currentPosition;
  6998. }
  6999.  
  7000. function getPorteVue() {
  7001. // Pour rétrocompatibilité
  7002. return porteeVue;
  7003. }
  7004.  
  7005. function getVue() {
  7006. // Retourne [vueHpure, vueVpure]
  7007. var vues = getPorteVue();
  7008. return [ vues[0], vues[1] ];
  7009. }
  7010.  
  7011. // Roule 11/03/2016
  7012. /* [functions] Récup données monstres, trolls, etc. */
  7013. function getXxxDistance(xxx, i) {
  7014. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7015. }
  7016. function getXxxPosition(xxx, i) {
  7017. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7018. var l = tds.length;
  7019. return [
  7020. parseInt(tds[l-3].textContent),
  7021. parseInt(tds[l-2].textContent),
  7022. parseInt(tds[l-1].textContent)
  7023. ];
  7024. }
  7025.  
  7026.  
  7027. /* [functions] Récup données monstres */
  7028. function getMonstreDistance(i) {
  7029. return parseInt(tr_monstres[i].cells[0].textContent);
  7030. }
  7031.  
  7032. function getMonstreID(i) {
  7033. return tr_monstres[i].cells[2].firstChild.nodeValue;
  7034. }
  7035.  
  7036. function getMonstreIDByTR(tr) {
  7037. return tr.cells[2].firstChild.nodeValue;
  7038. }
  7039.  
  7040. function getMonstreLevelNode(i) {
  7041. return tr_monstres[i].cells[3];
  7042. }
  7043.  
  7044. function getMonstreLevel(i) {
  7045. if(!isCDMsRetrieved) return -1;
  7046. var donneesMonstre = listeCDM[getMonstreID(i)];
  7047. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  7048. }
  7049.  
  7050. function getMonstreNomNode(i) {
  7051. try {
  7052. var td = document.evaluate(
  7053. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  7054. tr_monstres[i], null, 9, null
  7055. ).singleNodeValue;
  7056. return td;
  7057. } catch(e) {
  7058. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  7059. window.console.error(e);
  7060. }
  7061. }
  7062.  
  7063. function getMonstreNom(i) {
  7064. return getMonstreNomByTR(tr_monstres[i]);
  7065. }
  7066.  
  7067. function getMonstreNomByTR(tr) {
  7068. try {
  7069. var nom = document.evaluate(
  7070. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  7071. tr, null, 2, null
  7072. ).stringValue;
  7073. return nom;
  7074. } catch(e) {
  7075. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  7076. window.console.error(e);
  7077. }
  7078. }
  7079.  
  7080. function getMonstrePosition(i) {
  7081. var tds = tr_monstres[i].childNodes;
  7082. var l = tds.length;
  7083. return [
  7084. parseInt(tds[l-3].textContent),
  7085. parseInt(tds[l-2].textContent),
  7086. parseInt(tds[l-1].textContent)
  7087. ];
  7088. }
  7089.  
  7090. function appendMonstres(txt) {
  7091. for(var i=1; i<=nbMonstres ; i++)
  7092. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  7093. return txt;
  7094. }
  7095.  
  7096. function getMonstres() {
  7097. var vue = getVue();
  7098. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7099. }
  7100.  
  7101. function bddMonstres(start,stop) {
  7102. if(!start) { var start = 1; }
  7103. if(!stop) { var stop = nbMonstres; }
  7104. stop = Math.min(nbMonstres,stop);
  7105. var txt='';
  7106. for(var i=start ; i<=stop ; i++) {
  7107. txt += getMonstreID(i)+';'+
  7108. getMonstreNom(i)+';'+
  7109. positionToString(getMonstrePosition(i))+'\n';
  7110. }
  7111. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  7112. }
  7113.  
  7114. /* [functions] Récup données Trolls */
  7115. function getTrollDistance(i) {
  7116. return parseInt(tr_trolls[i].cells[0].textContent);
  7117. }
  7118.  
  7119. function getTrollID(i) {
  7120. return parseInt(tr_trolls[i].cells[2].textContent);
  7121. }
  7122.  
  7123. function getTrollNomNode(i) {
  7124. var isEnvoiOn =
  7125. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  7126. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  7127. }
  7128.  
  7129. function getTrollNivNode(i) {
  7130. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  7131. return tr_trolls[i].cells[4];
  7132. }
  7133.  
  7134. function getTrollGuilde(i) {
  7135. return trim(tr_trolls[i].cells[6].textContent);
  7136. }
  7137.  
  7138. function getTrollGuildeID(i) {
  7139. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  7140. var href;
  7141. try {
  7142. if ((!tr_trolls[i].childNodes[6].firstChild) || (!tr_trolls[i].childNodes[6].firstChild.getAttribute)) return -1; // Roule 21/12/2016 protection conte le "bug Marsak"
  7143. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  7144. } catch(e) { // debug pb remonté par Marsak
  7145. window.console.error('[MZ getTrollGuildeID]\n'
  7146. ,e
  7147. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  7148. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  7149. return -1;
  7150. }
  7151. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  7152. }
  7153. return -1;
  7154. }
  7155.  
  7156. function getTrollPosition(i) {
  7157. var tds = tr_trolls[i].childNodes;
  7158. var l = tds.length;
  7159. return [
  7160. parseInt(tds[l-3].textContent),
  7161. parseInt(tds[l-2].textContent),
  7162. parseInt(tds[l-1].textContent)
  7163. ];
  7164. }
  7165.  
  7166. function bddTrolls() {
  7167. var txt='#DEBUT TROLLS\n'+
  7168. numTroll+';'+positionToString(getPosition())+'\n';
  7169. for(var i=1 ; i<=nbTrolls ; i++) {
  7170. txt += getTrollID(i)+';'+
  7171. positionToString(getTrollPosition(i))+'\n';
  7172. }
  7173. return txt+'#FIN TROLLS';
  7174. }
  7175.  
  7176. /* [functions] Récup données Trésors */
  7177. function getTresorDistance(i) {
  7178. return tr_tresors[i].cells[0].firstChild.nodeValue;
  7179. }
  7180.  
  7181. function getTresorID(i) {
  7182. return trim(tr_tresors[i].cells[2].textContent);
  7183. }
  7184.  
  7185. function getTresorNom(i) {
  7186. // Utilisation de textContent pour régler le "bug de Pollux"
  7187. return trim(tr_tresors[i].cells[3].textContent);
  7188. }
  7189.  
  7190. function getTresorPosition(i) {
  7191. var tds = tr_tresors[i].childNodes;
  7192. var l = tds.length;
  7193. return [
  7194. parseInt(tds[l-3].textContent),
  7195. parseInt(tds[l-2].textContent),
  7196. parseInt(tds[l-1].textContent),
  7197. ];
  7198. }
  7199.  
  7200. function bddTresors(dmin,start,stop) {
  7201. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  7202. if(!dmin) { var dmin = 0; }
  7203. if(!start) { var start = 1; }
  7204. if(!stop) { var stop = nbTresors; }
  7205. stop = Math.min(nbTresors,stop);
  7206. var txt='';
  7207. for(var i=start ; i<=stop ; i++) {
  7208. if(getTresorDistance(i)>=dmin) {
  7209. txt += getTresorID(i)+';'+
  7210. getTresorNom(i)+';'+
  7211. positionToString(getTresorPosition(i))+'\n';
  7212. }
  7213. }
  7214. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  7215. }
  7216.  
  7217. /* [functions] Récup données Champignons */
  7218. // DEBUG: Pas de colonne "Référence" sur serveur de test
  7219. function getChampignonNom(i) {
  7220. return trim(tr_champignons[i].cells[2].textContent);
  7221. }
  7222.  
  7223. function getChampignonPosition(i) {
  7224. var tds = tr_champignons[i].childNodes;
  7225. var l = tds.length;
  7226. return [
  7227. parseInt(tds[l-3].textContent),
  7228. parseInt(tds[l-2].textContent),
  7229. parseInt(tds[l-1].textContent)
  7230. ];
  7231. }
  7232.  
  7233. function bddChampignons() {
  7234. var txt='';
  7235. for(var i=1 ; i<=nbChampignons ; i++) {
  7236. txt += ';'+ // Les champis n'ont pas de Référence
  7237. getChampignonNom(i)+';'+
  7238. positionToString(getChampignonPosition(i))+'\n';
  7239. }
  7240. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  7241. }
  7242.  
  7243. /* [functions] Récup données Lieux */
  7244. function getLieuDistance(i) {
  7245. return parseInt(tr_lieux[i].cells[0].textContent);
  7246. }
  7247.  
  7248. function getLieuID(i) {
  7249. return parseInt(tr_lieux[i].cells[2].textContent);
  7250. }
  7251.  
  7252. function getLieuNom(i) {
  7253. // Conversion ASCII pour éviter les bugs des Vues externes
  7254. return trim(tr_lieux[i].cells[3].textContent);
  7255. }
  7256.  
  7257. function getLieuPosition(i) {
  7258. var tds = tr_lieux[i].childNodes;
  7259. var l = tds.length;
  7260. return [
  7261. parseInt(tds[l-3].textContent),
  7262. parseInt(tds[l-2].textContent),
  7263. parseInt(tds[l-1].textContent)
  7264. ];
  7265. }
  7266.  
  7267. function appendLieux(txt) {
  7268. for(var i = 1; i < nbLieux+1; i++) {
  7269. var tds = x_lieux[i].childNodes;
  7270. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  7271. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  7272. }
  7273. return txt;
  7274. }
  7275.  
  7276. function getLieux() {
  7277. var vue = getVue();
  7278. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7279. }
  7280.  
  7281. function bddLieux(start,stop) {
  7282. if(!start) { var start = 1; }
  7283. if(!stop) { var stop = nbLieux; }
  7284. stop = Math.min(nbLieux,stop);
  7285. var txt='';
  7286. for(var i=start ; i<=stop ; i++) {
  7287. txt += getLieuID(i)+';'+
  7288. epure(getLieuNom(i))+';'+
  7289. positionToString(getLieuPosition(i))+'\n';
  7290. }
  7291. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  7292. }
  7293.  
  7294.  
  7295. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  7296.  
  7297. function saveCheckBox(chkbo, pref) {
  7298. // Enregistre et retourne l'état d'une CheckBox
  7299. var etat = chkbo.checked;
  7300. MY_setValue(pref, etat ? 'true' : 'false' );
  7301. return etat;
  7302. }
  7303.  
  7304. function recallCheckBox(chkbox, pref) {
  7305. // Restitue l'état d'une CheckBox
  7306. chkbox.checked = (MY_getValue(pref)=='true');
  7307. }
  7308.  
  7309. function saveComboBox(cbb, pref) {
  7310. // Enregistre et retourne l'état d'une ComboBox
  7311. var etat = cbb.selectedIndex;
  7312. MY_setValue(pref, etat);
  7313. return etat;
  7314. }
  7315.  
  7316. function recallComboBox(cbb, pref) {
  7317. // Restitue l'état d'une ComboBox
  7318. var nb = MY_getValue(pref);
  7319. if(nb) cbb.value = nb;
  7320. return nb;
  7321. }
  7322.  
  7323. function synchroniseFiltres() {
  7324. // Récupération de toutes les options de la vue
  7325. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  7326. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  7327. if(numBool) {
  7328. debutFiltrage('Monstres');
  7329. }
  7330. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  7331. recallCheckBox(checkBoxMythiques,'NOMYTH');
  7332. recallCheckBox(checkBoxEngages,'NOENGAGE');
  7333. recallCheckBox(checkBoxLevels,'NOLEVEL');
  7334. recallCheckBox(checkBoxIntangibles,'NOINT');
  7335. recallCheckBox(checkBoxGG,'NOGG');
  7336. recallCheckBox(checkBoxCompos,'NOCOMP');
  7337. recallCheckBox(checkBoxBidouilles,'NOBID');
  7338. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  7339. recallCheckBox(checkBoxTrou,'NOTROU');
  7340. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  7341. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  7342. if(MY_getValue('NOINFOEM')!='true')
  7343. recallCheckBox(checkBoxEM,'NOEM');
  7344. }
  7345.  
  7346.  
  7347. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  7348.  
  7349. /* [functions] Menu Vue 2D */
  7350. var vue2Ddata = {
  7351. 'Bricol\' Vue': {
  7352. url: URL_bricol_mountyhall + 'vue_form.php',
  7353. paramid: 'vue',
  7354. func: getVueScript,
  7355. extra_params: {
  7356. 'mode': 'vue_SP_Vue2',
  7357. 'screen_width': window.screen.width
  7358. }
  7359. },
  7360. 'Vue du CCM': {
  7361. url: URL_vue_CCM,
  7362. paramid: 'vue',
  7363. func: getVueScript,
  7364. extra_params: {
  7365. 'id': numTroll+';'+positionToString(getPosition())
  7366. }
  7367. },
  7368. 'Vue Gloumfs 2D': {
  7369. url: URL_vue_Gloumfs2D,
  7370. paramid: 'vue_mountyzilla',
  7371. func: getVueScript,
  7372. extra_params: {}
  7373. },
  7374. 'Vue Gloumfs 3D': {
  7375. url: URL_vue_Gloumfs3D,
  7376. paramid: 'vue_mountyzilla',
  7377. func: getVueScript,
  7378. extra_params: {}
  7379. },
  7380. 'Grouky Vue!': {
  7381. url: URL_vue_Grouky,
  7382. paramid: 'vue',
  7383. func: getVueScript,
  7384. extra_params: {
  7385. 'type_vue': 'V5b1'
  7386. }
  7387. },
  7388. /*'DEBUG': {
  7389. url: 'http://weblocal/testeur.php',
  7390. paramid: 'vue',
  7391. func: getVueScript,
  7392. extra_params: {}
  7393. }*/
  7394. };
  7395.  
  7396. function getVueScript() {
  7397. try {
  7398. var txt = bddTrolls()+
  7399. bddMonstres()+
  7400. bddChampignons()+
  7401. bddTresors()+
  7402. bddLieux()+
  7403. '#DEBUT ORIGINE\n'+
  7404. getPorteVue()[2]+';'+positionToString(getPosition())+
  7405. '\n#FIN ORIGINE\n';
  7406. window.console.log('[MZd] fin getVueScript');
  7407. return txt;
  7408. } catch(e) {
  7409. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7410. window.console.error('[MZ getVueScript]\n',e)
  7411. }
  7412. }
  7413.  
  7414. function refresh2DViewButton() {
  7415. // = EventListener menu+bouton vue 2D
  7416. var vueext = document.getElementById('selectVue2D').value;
  7417. MY_setValue('VUEEXT',vueext);
  7418. var form = document.getElementById('viewForm');
  7419. form.innerHTML = '';
  7420. form.method = 'post';
  7421. form.action = vue2Ddata[vueext].url;
  7422. form.target = '_blank';
  7423. appendHidden(form, vue2Ddata[vueext].paramid, '');
  7424. for(var key in vue2Ddata[vueext].extra_params) {
  7425. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  7426. }
  7427. appendSubmit(form, 'Voir',
  7428. function() {
  7429. window.console.log('[MZd] click voir vue externe');
  7430. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  7431. vue2Ddata[vueext].func();
  7432. }
  7433. );
  7434. }
  7435.  
  7436. function set2DViewSystem() {
  7437. // Initialise le système de vue 2D
  7438. // Recherche du point d'insertion
  7439. try {
  7440. var center = document.evaluate(
  7441. "//h2[@id='titre2']/following-sibling::center",
  7442. document, null, 9, null
  7443. ).singleNodeValue;
  7444. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  7445. if (!center) center = document.evaluate(
  7446. "//h2[@id='titre2']/following-sibling::div",
  7447. document, null, 9, null
  7448. ).singleNodeValue;
  7449. } catch(e) {
  7450. avertissement("Erreur d'initialisation du système de vue 2D");
  7451. window.console.error("[MZ] set2DViewSystem",e);
  7452. return;
  7453. }
  7454. // Récupération de la dernière vue utilisée
  7455. var vueext = MY_getValue('VUEEXT');
  7456. if(!vueext || !vue2Ddata[vueext]) {
  7457. // sinon, la vue Bricol'Trolls est employée par défaut
  7458. vueext = 'Bricol\' Vue';
  7459. }
  7460. try {
  7461. // Création du sélecteur de vue externe
  7462. selectVue2D = document.createElement('select');
  7463. selectVue2D.id = 'selectVue2D';
  7464. selectVue2D.className = 'SelectboxV2';
  7465. window.console.log('[MZd] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  7466. for(var view in vue2Ddata) {
  7467. appendOption(selectVue2D, view, view);
  7468. }
  7469. selectVue2D.value = vueext;
  7470. selectVue2D.onchange = refresh2DViewButton;
  7471. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  7472. var form = document.createElement('form');
  7473. form.id = 'viewForm';
  7474. // Insertion du système de vue
  7475. var table = document.createElement('table');
  7476. var tr = appendTr(table);
  7477. var td = appendTd(tr);
  7478. td.appendChild(selectVue2D);
  7479. td = appendTd(tr);
  7480. td.style.fontSize = '0px'; // gère le bug de l'extra character
  7481. td.appendChild(form);
  7482. center.insertBefore(table,center.firstChild);
  7483. insertBr(center.childNodes[1]);
  7484. // Appelle le handler pour initialiser le bouton de submit
  7485. refresh2DViewButton();
  7486. window.console.log('[MZd] fin prépartation des vues externes');
  7487. } catch(e) {
  7488. avertissement("Erreur de traitement du système de vue 2D");
  7489. window.console.error("[MZ] set2DViewSystem",e);
  7490. }
  7491. }
  7492.  
  7493. /* [functions] Tableau d'Infos */
  7494. function initialiseInfos() {
  7495. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  7496. var
  7497. infoTab = document.getElementsByName('LimitViewForm')[0].
  7498. getElementsByTagName('table')[0],
  7499. tbody = infoTab.tBodies[0],
  7500. thead = infoTab.createTHead(),
  7501. tr = appendTr(thead,'mh_tdtitre'),
  7502. td = appendTdText(tr,'INFORMATIONS',true),
  7503. span = document.createElement('span');
  7504. // Récupération de la position du joueur
  7505. try {
  7506. var strPos = document.evaluate(
  7507. ".//li/b/text()[contains(.,'X = ')]",
  7508. infoTab, null, 9, null
  7509. ).singleNodeValue.nodeValue;
  7510. // ***INIT GLOBALE*** currentPosition
  7511. currentPosition = getNumbers(strPos);
  7512. debugMZ("retrievePosition(): "+currentPosition);
  7513. } catch(e) {
  7514. // Si on ne trouve pas le "X ="
  7515. window.console.error("[MZ Vue] Position joueur non trouvée",e);
  7516. }
  7517. // Récupération des portées (max et limitée) de la vue
  7518. try {
  7519. var
  7520. nodes = document.evaluate(
  7521. ".//li/b/text()[contains(.,'horizontalement') "+
  7522. "or contains(.,'verticalement')]",
  7523. infoTab, null, 7, null
  7524. ),
  7525. array = [];
  7526. for(var i=0 ; i<4 ; i++) {
  7527. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  7528. }
  7529. // ***INIT GLOBALE*** porteeVue
  7530. porteeVue = array;
  7531. } catch(e) {
  7532. window.console.error("[MZ Vue] Portées Vue non trouvées",e);
  7533. }
  7534.  
  7535. infoTab.id = 'infoTab'; // Pour scripts externes
  7536. tbody.id = 'corpsInfoTab';
  7537. tbody.rows[0].cells[0].colSpan = 2;
  7538. td.colSpan = 3;
  7539. td.onmouseover = function() {
  7540. this.style.cursor = 'pointer';
  7541. this.className = 'mh_tdpage';
  7542. };
  7543. td.onmouseout = function() {
  7544. this.className = 'mh_tdtitre';
  7545. };
  7546. td.onclick = function() {
  7547. toggleTableauInfos(false);
  7548. };
  7549. span.id = 'msgInfoTab';
  7550. span.style.display = 'none';
  7551. appendText(
  7552. span,
  7553. ' => Position : X = '+currentPosition[0]+
  7554. ', Y = '+currentPosition[1]+
  7555. ', N = '+currentPosition[2]+
  7556. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  7557. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  7558. true
  7559. );
  7560. td.appendChild(span);
  7561. tr = appendTr(tbody,'mh_tdpage');
  7562. td = appendTdText(tr,'EFFACER : ',true);
  7563. td.align = 'center';
  7564. td.className = 'mh_tdtitre';
  7565. td.width = 100;
  7566. td = appendTdCenter(tr,2);
  7567. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  7568. checkBoxGG = appendCheckBoxSpan(
  7569. td,'delgg',filtreTresors," Les GG'"
  7570. ).firstChild;
  7571. checkBoxCompos = appendCheckBoxSpan(
  7572. td,'delcomp',filtreTresors,' Les Compos'
  7573. ).firstChild;
  7574. checkBoxBidouilles = appendCheckBoxSpan(
  7575. td,'delbid',filtreTresors,' Les Bidouilles'
  7576. ).firstChild;
  7577. checkBoxIntangibles = appendCheckBoxSpan(
  7578. td,'delint',filtreTrolls,' Les Intangibles'
  7579. ).firstChild;
  7580. checkBoxGowaps = appendCheckBoxSpan(
  7581. td,'delgowap',filtreMonstres,' Les Gowaps'
  7582. ).firstChild;
  7583. checkBoxEngages = appendCheckBoxSpan(
  7584. td,'delengage',filtreMonstres,' Les Engagés'
  7585. ).firstChild;
  7586. checkBoxLevels = appendCheckBoxSpan(
  7587. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  7588. ).firstChild;
  7589. checkBoxDiplo = appendCheckBoxSpan(
  7590. td,'delDiplo',refreshDiplo,' La Diplomatie'
  7591. ).firstChild;
  7592. checkBoxTrou = appendCheckBoxSpan(
  7593. td,'deltrou',filtreLieux,' Les Trous'
  7594. ).firstChild;
  7595. checkBoxMythiques = appendCheckBoxSpan(
  7596. td,'delmyth',filtreMonstres,' Les Mythiques'
  7597. ).firstChild;
  7598. if(MY_getValue('NOINFOEM')!='true') {
  7599. checkBoxEM = appendCheckBoxSpan(
  7600. td,'delem',filtreMonstres,' Les Composants EM'
  7601. ).firstChild;
  7602. }
  7603. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  7604. td,'deltres',filtreTresors,' Les Trésors non libres'
  7605. ).firstChild;
  7606. checkBoxTactique = appendCheckBoxSpan(
  7607. td,'deltactique',updateTactique,' Les Infos tactiques'
  7608. ).firstChild;
  7609. if(MY_getValue('INFOPLIE')) {
  7610. toggleTableauInfos(true);
  7611. }
  7612. }
  7613.  
  7614. function toggleTableauInfos(firstRun) {
  7615. var
  7616. msg = document.getElementById('msgInfoTab'),
  7617. corps = document.getElementById('corpsInfoTab'),
  7618. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7619. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  7620. if(!firstRun) {
  7621. infoplie = !infoplie;
  7622. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7623. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  7624. }
  7625. if(infoplie) {
  7626. msg.style.display = '';
  7627. corps.style.display = 'none';
  7628. } else {
  7629. msg.style.display = 'none';
  7630. corps.style.display = '';
  7631. }
  7632. }
  7633.  
  7634. /* [functions] Filtres */
  7635. function prepareFiltrage(ref,width) {
  7636. // = Initialise le filtre 'ref'
  7637. try {
  7638. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  7639. } catch(e) {
  7640. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  7641. return false;
  7642. }
  7643. if(width) { tdTitre.width = width; }
  7644. // Ajout du tr de Filtrage (masqué)
  7645. var tbody = tdTitre.parentNode.parentNode;
  7646. var tr = appendTr(tbody,'mh_tdpage');
  7647. tr.style.display = 'none';
  7648. tr.id = 'trFiltre'+ref;
  7649. var td = appendTd(tr);
  7650. td.colSpan = 5;
  7651. // Ajout du bouton de gestion de Filtrage
  7652. var tdBtn = insertTd(tdTitre.nextSibling);
  7653. tdBtn.id = 'tdInsert'+ref;
  7654. var btn = appendButton(tdBtn,'Filtrer');
  7655. btn.id = 'btnFiltre'+ref;
  7656. btn.onclick = function() {
  7657. debutFiltrage(ref)
  7658. };
  7659. return td;
  7660. }
  7661.  
  7662. function debutFiltrage(ref) {
  7663. // = Handler de début de filtrage (filtre 'ref')
  7664. document.getElementById('trFiltre'+ref).style.display = '';
  7665. var btn = document.getElementById('btnFiltre'+ref);
  7666. btn.value = 'Annuler Filtre';
  7667. btn.onclick = function() {
  7668. finFiltrage(ref);
  7669. };
  7670. }
  7671.  
  7672. function finFiltrage(ref) {
  7673. // = Handler de fin de filtrage (filtre 'ref')
  7674. /* On réassigne le bouton 'Filtrer' */
  7675. document.getElementById('trFiltre'+ref).style.display = 'none';
  7676. var btn = document.getElementById('btnFiltre'+ref);
  7677. btn.value = 'Filtrer';
  7678. btn.onclick = function() {
  7679. debutFiltrage(ref);
  7680. };
  7681. /* Réinitialisation filtres */
  7682. document.getElementById('str'+ref).value = '';
  7683. switch(ref) {
  7684. case 'Monstres':
  7685. document.getElementById('nivMinMonstres').value = 0;
  7686. document.getElementById('nivMaxMonstres').value = 0;
  7687. break;
  7688. case 'Trolls':
  7689. document.getElementById('strGuildes').value = '';
  7690. }
  7691. /* Nettoyage (=lance le filtre) */
  7692. // Ici this = MZ.global = sandBox de travail de MZ
  7693. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  7694. //this['filtre'+ref]();
  7695. switch (ref) {
  7696. case 'Monstres':
  7697. filtreMonstres();
  7698. break;
  7699. case 'Trolls':
  7700. filtreTrolls();
  7701. break;
  7702. case 'Tresors':
  7703. filtreTresors();
  7704. break;
  7705. case 'Lieux':
  7706. filtreLieux();
  7707. break;
  7708. default:
  7709. window.console.log('cas incongru dans finFiltrage : ' + ref);
  7710. break;
  7711. }
  7712. }
  7713.  
  7714. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  7715. var bouton = appendButton(td,nomBouton,onClick);
  7716. appendText(td,'\u00a0');
  7717. var textbox = appendTextbox(td,'text',id,15,30);
  7718. textbox.onkeypress = function(event) {
  7719. try {
  7720. if(event.keyCode==13) {
  7721. event.preventDefault();
  7722. bouton.click();
  7723. }
  7724. }
  7725. catch(e){
  7726. window.alert(e)
  7727. }
  7728. };
  7729. }
  7730.  
  7731. function ajoutFiltreMenu(tr,id,onChange) {
  7732. var select = document.createElement('select');
  7733. select.id = id;
  7734. select.onchange = onChange;
  7735. appendOption(select,0,'Aucun');
  7736. for(var i=1 ; i<=60 ; i++) {
  7737. appendOption(select,i,i);
  7738. }
  7739. tr.appendChild(select);
  7740. return select;
  7741. }
  7742.  
  7743. function ajoutDesFiltres() {
  7744. /* Monstres */
  7745. var td = prepareFiltrage('Monstres',120);
  7746. if(td) {
  7747. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  7748. appendText(td,'\u00a0\u00a0\u00a0');
  7749. appendText(td,'Niveau Min: ');
  7750. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  7751. appendText(td,'\u00a0');
  7752. appendText(td,'Niveau Max: ');
  7753. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  7754. }
  7755. /* Trõlls */
  7756. td = prepareFiltrage('Trolls',50);
  7757. if(td) {
  7758. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  7759. appendText(td,'\u00a0\u00a0\u00a0');
  7760. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  7761. }
  7762. /* Trésors */
  7763. td = prepareFiltrage('Tresors',55);
  7764. if(td) {
  7765. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  7766. }
  7767. /* Lieux */
  7768. td = prepareFiltrage('Lieux',40);
  7769. if(td) {
  7770. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  7771. }
  7772. }
  7773.  
  7774. /* [functions] Bouton d'envoi vers Troogle */
  7775. // WARNING - Nécessite que le Filtre Monstres ait été mis en place
  7776. function envoiVersTroogle() {
  7777. // = 1er Handler bouton Troogle
  7778. try {
  7779. var bouton = document.getElementById('bouton_Troogle');
  7780. } catch(e) {
  7781. window.console.log('Bouton d\'envoi non trouvé.');
  7782. return;
  7783. }
  7784. bouton.onclick = lireInfosTroogle;
  7785. bouton.value = 'Envoi en cours';
  7786. var responses = {}, erreur = false;
  7787. var maxDonnees = Math.max(
  7788. nbMonstres,
  7789. nbTresors,
  7790. nbLieux
  7791. );
  7792. var parLot = 100;
  7793. var lotStop = Math.ceil(maxDonnees/parLot);
  7794. for(var i=0 ; i<lotStop ; i++) {
  7795. var debutLot = parLot*i+1;
  7796. var finLot = parLot*(i+1);
  7797. var data = //'#'+numTroll+
  7798. bddMonstres(debutLot,finLot)+'\n'+
  7799. bddTresors(1,debutLot,finLot)+'\n'+
  7800. bddLieux(debutLot,finLot);
  7801. FF_XMLHttpRequest({
  7802. method: 'POST',
  7803. url: URL_trooglebeta,
  7804. //url: 'http://weblocal/POST_RESULT/index.php',
  7805. headers : {
  7806. 'Content-type': 'application/x-www-form-urlencoded'
  7807. },
  7808. data: 'view='+encodeURIComponent(data), //+'&from='+debutLot,
  7809. lot: i,
  7810. debutLot: debutLot,
  7811. finLot: finLot,
  7812. onload: function(responseDetails) {
  7813. try {
  7814. var resp = responseDetails.responseText;
  7815. responses[this.lot] = 'Envoi des éléments '+this.debutLot+
  7816. ' à '+Math.min(maxDonnees,this.finLot)+' :\n'+resp;
  7817. if(resp.indexOf('succès')==-1) {
  7818. erreur = true;
  7819. }
  7820. } catch(e) {
  7821. console.error(e);
  7822. return;
  7823. }
  7824. var txt = '';
  7825. var fini = true;
  7826. for(var j=0 ; j<lotStop ; j++) {
  7827. if(responses[j]) {
  7828. txt += txt ? '\n'+responses[j] : responses[j];
  7829. } else {
  7830. fini = false;
  7831. }
  7832. }
  7833. bouton.info = txt;
  7834. if(fini) {
  7835. bouton.value = erreur ? 'Erreur' : 'Envoi réussi';
  7836. }
  7837. }
  7838. });
  7839. }
  7840. }
  7841.  
  7842. function lireInfosTroogle() {
  7843. // = 2e Handler bouton Troogle
  7844. try {
  7845. var infos = document.getElementById('bouton_Troogle').info;
  7846. } catch(e) {
  7847. avertissement('[lireInfosTroogle] Bouton Troogle non trouvé');
  7848. window.console.error('[lireInfosTroogle]\n'+e);
  7849. return;
  7850. }
  7851. window.alert(infos);
  7852. }
  7853.  
  7854. function putBoutonTroogle() {
  7855. var td = document.getElementById('tdInsertMonstres');
  7856. td = insertTd(td.nextSibling);
  7857. td.style.fontSize = '0px';
  7858. var bouton = document.createElement('input');
  7859. bouton.type = 'button';
  7860. bouton.id = 'bouton_Troogle';
  7861. bouton.className = 'mh_form_submit';
  7862. bouton.value = 'Envoyer les données vers Troogle';
  7863. bouton.onmouseover = function(){
  7864. this.style.cursor='pointer';
  7865. };
  7866. bouton.onclick = envoiVersTroogle;
  7867. td.appendChild(bouton);
  7868. }
  7869.  
  7870.  
  7871. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  7872.  
  7873. /* [functions] Affichage de la colonne des niveaux */
  7874. function insertLevelColumn() {
  7875. // Déclenché si bascule vers affichage des niveaux des mobs
  7876. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7877. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  7878. td.width = 25;
  7879. for(var i=1 ; i<=nbMonstres ; i++) {
  7880. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7881. td = insertTdText(getMonstreLevelNode(i), '-');
  7882. td.onclick = function() {
  7883. basculeCDM(
  7884. getMonstreNomByTR(this.parentNode),
  7885. getMonstreIDByTR(this.parentNode)
  7886. );
  7887. };
  7888. td.onmouseover = function() {
  7889. this.style.cursor = 'pointer';
  7890. this.className = 'mh_tdtitre';
  7891. };
  7892. td.onmouseout = function() {
  7893. if(this.parentNode.diploActive=='oui') {
  7894. this.className = '';
  7895. } else {
  7896. this.className = 'mh_tdpage';
  7897. }
  7898. };
  7899. td.style = 'font-weight:bold;text-align:center;';
  7900. if(isCDMsRetrieved) {
  7901. // Rappel des niveaux si mémorisés
  7902. td.innerHTML = listeLevels[i];
  7903. }
  7904. }
  7905. }
  7906.  
  7907. function toggleLevelColumn() {
  7908. // = Handler checkBox noLevel
  7909. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  7910. insertLevelColumn();
  7911. if(!isCDMsRetrieved) { retrieveCDMs(); }
  7912. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  7913. for(var i=0 ; i<=nbMonstres ; i++) {
  7914. if(isCDMsRetrieved) {
  7915. // Mémorisation des niveaux pour rappel éventuel
  7916. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  7917. }
  7918. // Suppression du td Niveau
  7919. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  7920. }
  7921. }
  7922. }
  7923.  
  7924. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  7925. function basculeCDM(nom,id) {
  7926. // = Bascule l'affichage des popups CdM
  7927. if(listeCDM[id]) {
  7928. if(!document.getElementById('popupCDM'+id)) {
  7929. afficherCDM(nom, id);
  7930. } else {
  7931. cacherPopupCDM('popupCDM'+id);
  7932. }
  7933. }
  7934. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  7935. }
  7936.  
  7937. function cacherPopupCDM(titre) {
  7938. var popup = document.getElementById(titre);
  7939. popup.parentNode.removeChild(popup);
  7940. }
  7941.  
  7942. /* DEBUG: Section à mettre à jour */
  7943. var selectionFunction;
  7944.  
  7945. function startDrag(evt) {
  7946. winCurr = this.parentNode;
  7947. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  7948. offsetX = evt.pageX - parseInt( winCurr.style.left );
  7949. offsetY = evt.pageY - parseInt( winCurr.style.top );
  7950. selectionFunction = document.body.style.MozUserSelect;
  7951. document.body.style.MozUserSelect = 'none';
  7952. winCurr.style.MozUserSelect = 'none';
  7953. return false;
  7954. }
  7955.  
  7956. function stopDrag(evt) {
  7957. winCurr.style.MozUserSelect = selectionFunction;
  7958. document.body.style.MozUserSelect = selectionFunction;
  7959. winCurr = null;
  7960. }
  7961.  
  7962. function drag(evt) {
  7963. if(winCurr==null) { return; }
  7964. evt = evt || window.event;
  7965. winCurr.style.left = (evt.pageX - offsetX)+'px';
  7966. winCurr.style.top = (evt.pageY - offsetY)+'px';
  7967. return false;
  7968. }
  7969. /* FIN DEBUG */
  7970.  
  7971. function afficherCDM(nom,id) {
  7972. // Crée la table de CdM du mob n° id
  7973. var donneesMonstre = listeCDM[id];
  7974. /* Début création table */
  7975. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  7976. table.id = 'popupCDM'+id;
  7977. table.style =
  7978. 'position:fixed;'+
  7979. 'z-index:1;'+
  7980. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  7981. 'left:'+(window.innerWidth-365)+'px;'+
  7982. 'width:300px;'+
  7983. 'height:200px;';
  7984. /* Ajout du titre avec gestion Drag & Drop */
  7985. var tr = table.firstChild;
  7986. tr.style.cursor = 'move';
  7987. tr.onmousedown = startDrag;
  7988. tr.onmouseup = stopDrag;
  7989. /* Ajout du bouton "Fermer" */
  7990. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  7991. tr.onmouseover = function() {
  7992. this.style.cursor = 'pointer';
  7993. this.className = 'mh_tdpage';
  7994. };
  7995. tr.onmouseout = function() {
  7996. this.className = 'mh_tdtitre';
  7997. };
  7998. tr.idcdm = id;
  7999. tr.onclick = function() {
  8000. cacherPopupCDM('popupCDM'+this.idcdm);
  8001. this.className = 'mh_tdtitre';
  8002. };
  8003. td = appendTdText(tr,'Fermer',true);
  8004. td.colSpan = 2;
  8005. td.style = 'text-align:center;';
  8006. nbCDM++;
  8007. /* Fin création table & Affichage */
  8008. document.body.appendChild(table);
  8009. }
  8010.  
  8011. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8012. function initPopupVue() {
  8013. popup = document.createElement('div');
  8014. popup.id = 'popup';
  8015. popup.className = 'mh_textbox';
  8016. popup.style =
  8017. 'position: absolute;'+
  8018. 'border: 1px solid #000000;'+
  8019. 'visibility: hidden;'+
  8020. 'display: inline;'+
  8021. 'z-index: 3;'+
  8022. 'max-width: 400px;';
  8023. document.body.appendChild(popup);
  8024. }
  8025.  
  8026. // roule 16/03/2016 supprimé, existe déjà dans vue
  8027. // function showPopupTactique(evt) {
  8028. // var id = this.id;
  8029. // var nom = this.nom;
  8030. // var texte = getAnalyseTactique(id,nom);
  8031. // if(texte=='') { return; }
  8032. // popup.innerHTML = texte;
  8033. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  8034. // popup.style.top = (evt.pageY+15)+'px';
  8035. // popup.style.visibility = 'visible';
  8036. // }
  8037.  
  8038. // roule 16/03/2016, existe déjà ailleurs
  8039. // function hidePopup() {
  8040. // popup.style.visibility = 'hidden';
  8041. // }
  8042.  
  8043. /* [functions] Récupération / Computation des Infos Tactiques */
  8044. // TODO à revoir
  8045. function retireMarquage(nom) {
  8046. var i = nom.indexOf(']');
  8047. switch(i) {
  8048. case -1:
  8049. case nom.length-1:
  8050. return nom;
  8051. default:
  8052. return nom.slice(0,i+1);
  8053. }
  8054. }
  8055.  
  8056. function showPopupError(sHTML) {
  8057. var divpopup = document.createElement('div');
  8058. divpopup.id = 'divpopup';
  8059. divpopup.style =
  8060. 'position: fixed;'+
  8061. 'border: 3px solid #000000;'+
  8062. 'top: 300px;left: 10px;'+
  8063. 'background-color: red;'+
  8064. 'color: white;'+
  8065. 'font-size: xx-large;'+
  8066. 'z-index: 200;';
  8067. divpopup.innerHTML = sHTML;
  8068. var divcroix = document.createElement('div');
  8069. divcroix.style =
  8070. 'position: absolute;'+
  8071. 'top: 0;right: 0;'+
  8072. 'color: inherit;'+
  8073. 'font-size: inherit;'+
  8074. 'cursor: pointer;'+
  8075. 'z-index: 201;';
  8076. divcroix.innerHTML = "X";
  8077. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8078. document.body.appendChild(divpopup);
  8079. divpopup.appendChild(divcroix);
  8080. }
  8081.  
  8082. function retrieveCDMs() {
  8083. // Récupère les CdM disponibles dans la BDD
  8084. // Lancé uniquement sur toggleLevelColumn
  8085. if(checkBoxLevels.checked) { return; }
  8086. var str = '';
  8087. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8088. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8089. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8090. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  8091. for(var i=1 ; i<=cdmMax ; i++) {
  8092. var nomMonstre = retireMarquage(getMonstreNom(i));
  8093. if(nomMonstre.indexOf(']') != -1) {
  8094. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  8095. }
  8096. // *** WARNING : PROXY RATIBUS ***
  8097. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  8098. str += 'nom[]='+escape(nomMonstre)+'$'+(
  8099. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  8100. )+'&';
  8101. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  8102. FF_XMLHttpRequest({
  8103. method: 'POST',
  8104. url: URL_MZinfoMonstre,
  8105. headers : {
  8106. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8107. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8108. 'Content-type':'application/x-www-form-urlencoded'
  8109. },
  8110. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  8111. onload: function(responseDetails) {
  8112. try {
  8113. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  8114. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  8115. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  8116. '" target="raistlin">Mountyzilla - https<br />'+
  8117. 'Tu dois accepter le certificat de Raistlin<br />'+
  8118. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  8119. ' « Confirmer l\'exception de sécurité »</a>');
  8120. return;
  8121. }
  8122. var texte = responseDetails.responseText;
  8123. var lines = texte.split('\n');
  8124. if(lines.length==0) { return; }
  8125. var begin2, end2, index;
  8126. for(var j=0 ; j<lines.length ; j++) {
  8127. var infos = lines[j].split(';');
  8128. if(infos.length<4) { continue; }
  8129. var idMonstre=infos[0];
  8130. var isCDM = infos[1];
  8131. index = parseInt(infos[2]);
  8132. var level = infos[3];
  8133. infos = infos.slice(3);
  8134. if(begin2==null) { begin2 = index; }
  8135. end2 = index;
  8136. listeCDM[idMonstre] = infos;
  8137. if(isCDM==1) {
  8138. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  8139. } else {
  8140. getMonstreLevelNode(index).innerHTML = level;
  8141. }
  8142. }
  8143. computeMission(begin2,end2);
  8144. } catch(e) {
  8145. window.console.error(
  8146. '[retrieveCDMs]\n'+e+'\n'+URL_MZinfoMonstre+'\n'+texte
  8147. );
  8148. }
  8149. }
  8150. });
  8151. str = '';
  8152. begin = i+1;
  8153. }
  8154. }
  8155. isCDMsRetrieved=true;
  8156. }
  8157.  
  8158. function computeMission(begin,end) {
  8159. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  8160. computeVLC(begin,end);
  8161. if(!begin) begin=1;
  8162. if(!end) end=nbMonstres;
  8163. var str = MY_getValue(numTroll+'.MISSIONS');
  8164. if(!str) { return; }
  8165. var urlImg = URL_MZimg+'mission.png';
  8166. var obMissions = JSON.parse(str);
  8167. for(var i=end ; i>=begin ; i--) {
  8168. var mess = '';
  8169. for(var num in obMissions) {
  8170. var mobMission = false;
  8171. switch(obMissions[num].type) {
  8172. case 'Race':
  8173. var race = epure(obMissions[num].race.toLowerCase());
  8174. var nom = epure(getMonstreNom(i).toLowerCase());
  8175. if(nom.indexOf(race)!=-1) {
  8176. mobMission = true;
  8177. }
  8178. break;
  8179. case 'Niveau':
  8180. var donneesMonstre = listeCDM[getMonstreID(i)];
  8181. if(donneesMonstre) {
  8182. var nivMob = Number(donneesMonstre[0]);
  8183. var nivMimi = Number(obMissions[num].niveau),
  8184. mod = obMissions[num].mod;
  8185. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  8186. || (isNaN(mod) && nivMob>=nivMimi)) {
  8187. mobMission = true;
  8188. }
  8189. }
  8190. break;
  8191. case 'Famille':
  8192. var donneesMonstre = listeCDM[getMonstreID(i)];
  8193. if(donneesMonstre) {
  8194. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  8195. var familleMob = epure(donneesMonstre[1].toLowerCase());
  8196. if(familleMob.indexOf(familleMimi)!=-1) {
  8197. mobMission = true;
  8198. }
  8199. }
  8200. break;
  8201. case 'Pouvoir':
  8202. var donneesMonstre = listeCDM[getMonstreID(i)];
  8203. if(donneesMonstre) {
  8204. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  8205. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  8206. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8207. mobMission = true;
  8208. }
  8209. }
  8210. }
  8211. if(mobMission) {
  8212. mess += mess ? '\n\n' : '';
  8213. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8214. }
  8215. }
  8216. if(mess) {
  8217. var td = getMonstreNomNode(i);
  8218. appendText(td,' ');
  8219. td.appendChild(createImage(urlImg,mess));
  8220. }
  8221. }
  8222. }
  8223.  
  8224. function computeVLC(begin,end) {
  8225. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8226. computeTactique(begin,end);
  8227. if(!begin) begin=1;
  8228. if(!end) end=nbMonstres;
  8229. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8230. if(!cache)
  8231. return false;
  8232. var urlImg = URL_MZimg + "oeil.png";
  8233. for(var i = end; i >= begin;i--)
  8234. {
  8235. var id = getMonstreID(i);
  8236. var donneesMonstre = listeCDM[id];
  8237. if(donneesMonstre && donneesMonstre.length>12)
  8238. {
  8239. if(donneesMonstre[12]==1)
  8240. {
  8241. var td = getMonstreNomNode(i);
  8242. td.appendChild(document.createTextNode(" "));
  8243. td.appendChild(createImage(urlImg, "Voit le caché"));
  8244. }
  8245. }
  8246. }
  8247. }
  8248.  
  8249. function computeTactique(begin, end) {
  8250. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8251. try {
  8252. if(!begin) begin = 1;
  8253. if(!end) end = nbMonstres;
  8254. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8255. if(noTactique || !isProfilActif()) return;
  8256. for(var j=end ; j>=begin ; j--) {
  8257. var id = getMonstreID(j);
  8258. var nom = getMonstreNom(j);
  8259. var donneesMonstre = listeCDM[id];
  8260. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8261. var td = getMonstreNomNode(j);
  8262. appendText(td,' ');
  8263. td.appendChild(
  8264. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  8265. );
  8266. }
  8267. }
  8268. }
  8269. catch(e) {
  8270. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8271. }
  8272. filtreMonstres();
  8273. }
  8274.  
  8275. function updateTactique() {
  8276. // = Handler checkBox noTactique
  8277. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8278. if(!isCDMsRetrieved) return;
  8279. if(noTactique) {
  8280. for(var i=nbMonstres ; i>0 ; i--) {
  8281. var tr = getMonstreNomNode(i);
  8282. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  8283. tr, null, 9, null).singleNodeValue;
  8284. if(img) {
  8285. img.parentNode.removeChild(img.previousSibling);
  8286. img.parentNode.removeChild(img);
  8287. }
  8288. }
  8289. }
  8290. else
  8291. computeTactique();
  8292. }
  8293.  
  8294. function filtreMonstres() {
  8295. // = Handler universel pour les fonctions liées aux monstres
  8296. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  8297. urlEnchantImg = URL_MZimg+'images/enchant.png';
  8298. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  8299. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  8300. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  8301. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  8302. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  8303. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  8304. // old/new : détermine s'il faut ou non nettoyer les tr
  8305. var oldNOEM = true, noEM = true;
  8306. if(MY_getValue('NOINFOEM')!='true') {
  8307. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  8308. }
  8309. // Filtrage par nom
  8310. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  8311. // Génère la liste des mobs engagés (si filtrés)
  8312. if(noEngages && !isEngagesComputed) {
  8313. for(var i=nbTrolls ; i>0 ; i--) {
  8314. var pos = getTrollPosition(i);
  8315. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  8316. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  8317. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  8318. }
  8319. isEngagesComputed = true;
  8320. }
  8321. /*** FILTRAGE ***/
  8322. /* À computer :
  8323. * - EM (nom suffit)
  8324. * - Enchant (nom suffit)
  8325. * - Mission (nécessite CdM)
  8326. * - mob VlC (nécessite CdM)
  8327. * Sans computation :
  8328. * - Gowap ? engagé ?
  8329. */
  8330. for(var i=nbMonstres ; i>0 ; i--) {
  8331. var pos = getMonstrePosition(i);
  8332. var nom = getMonstreNom(i).toLowerCase();
  8333. if(noEM!=oldNOEM) {
  8334. if(noEM) {
  8335. // Si noEM passe de false à true, on nettoie les td "Nom"
  8336. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  8337. var tr = getMonstreNomNode(i);
  8338. while(tr.childNodes.length>1) {
  8339. tr.removeChild(tr.childNodes[1]);
  8340. }
  8341. } else {
  8342. var tr = getMonstreNomNode(i);
  8343. var TypeMonstre=getEM(nom);
  8344. if(TypeMonstre!='') {
  8345. var infosCompo=compoMobEM(TypeMonstre);
  8346. if(infosCompo.length>0) {
  8347. tr.appendChild(document.createTextNode(' '));
  8348. tr.appendChild(createImage(urlImg, infosCompo));
  8349. }
  8350. }
  8351. }
  8352. }
  8353. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  8354. var texte = getInfoEnchantementFromMonstre(nom);
  8355. if(texte!='') {
  8356. var td = getMonstreNomNode(i);
  8357. td.appendChild(document.createTextNode(' '));
  8358. td.appendChild(createImage(urlEnchantImg, texte));
  8359. }
  8360. }
  8361. tr_monstres[i].style.display = (
  8362. noGowaps &&
  8363. nom.indexOf('gowap apprivoisé')!=-1 &&
  8364. getMonstreDistance(i)>1
  8365. ) || (
  8366. noEngages &&
  8367. getMonstreDistance(i)!=0 &&
  8368. listeEngages[pos[0]] &&
  8369. listeEngages[pos[0]][pos[1]] &&
  8370. listeEngages[pos[0]][pos[1]][pos[2]]
  8371. ) || (
  8372. strMonstre!='' &&
  8373. nom.indexOf(strMonstre)==-1
  8374. ) || (
  8375. nivMin>0 &&
  8376. getMonstreLevel(i)!=-1 &&
  8377. getMonstreLevel(i)<nivMin &&
  8378. getMonstreDistance(i)>1 &&
  8379. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  8380. ) || (
  8381. nivMax>0 &&
  8382. getMonstreLevel(i)>nivMax &&
  8383. getMonstreDistance(i)>1 &&
  8384. nom.toLowerCase().indexOf("kilamo")==-1
  8385. ) ? 'none' : '';
  8386. }
  8387. if(MY_getValue('NOINFOEM')!='true') {
  8388. if(noEM != oldNOEM) {
  8389. if(noEM && isCDMsRetrieved) computeMission();
  8390. }
  8391. oldNOEM = noEM;
  8392. }
  8393. needComputeEnchantement = false;
  8394. }
  8395.  
  8396.  
  8397. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  8398.  
  8399. function filtreTrolls() {
  8400. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  8401. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  8402. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  8403. for(var i=1 ; i<=nbTrolls ; i++) {
  8404. tr_trolls[i].style.display = (
  8405. noIntangibles &&
  8406. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  8407. ) || (
  8408. strTroll!='' &&
  8409. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  8410. ) || (
  8411. strGuilde!='' &&
  8412. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  8413. ) ? 'none' : '';
  8414. }
  8415. }
  8416.  
  8417. /* [functions] Bulle PX Trolls */
  8418. var bulle;
  8419.  
  8420. function initPXTroll() {
  8421. bulle = document.createElement('div');
  8422. bulle.id = 'bulle';
  8423. bulle.className = 'mh_textbox';
  8424. bulle.style =
  8425. 'position: absolute;'+
  8426. 'border: 1px solid #000000;'+
  8427. 'visibility: hidden;'+
  8428. 'display: inline;'+
  8429. 'z-index: 2;';
  8430. document.body.appendChild(bulle);
  8431.  
  8432. for(var i=nbTrolls ; i>0 ; i--) {
  8433. var td_niv = getTrollNivNode(i);
  8434. td_niv.onmouseover = showPXTroll;
  8435. td_niv.onmouseout = hidePXTroll;
  8436. }
  8437. }
  8438.  
  8439. function showPXTroll(evt) {
  8440. var lvl = this.firstChild.nodeValue;
  8441. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  8442. bulle.style.left = evt.pageX+15+'px';
  8443. bulle.style.top = evt.pageY+'px';
  8444. bulle.style.visibility = 'visible';
  8445. }
  8446.  
  8447. function hidePXTroll() {
  8448. bulle.style.visibility = 'hidden';
  8449. }
  8450.  
  8451. /* [functions] Envoi PX / MP */
  8452. function putBoutonPXMP() {
  8453. // Bouton d'initialisation du mode Envoi
  8454. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8455. var td = document.getElementById('tdInsertTrolls');
  8456. if(!td) { return; }
  8457. td.width = 100;
  8458. td = insertTd(td.nextSibling);
  8459. td.style.verticalAlign = 'top';
  8460. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8461. bouton.id = 'btnEnvoi';
  8462. }
  8463.  
  8464. function prepareEnvoi() {
  8465. // = 1er Handler du bouton d'envoi
  8466. /* Ajout de la colonne des CheckBoxes */
  8467. var td = insertTdText(getTrollNomNode(0),'');
  8468. td.width = 5;
  8469. for(var i=nbTrolls ; i>0 ; i--) {
  8470. td = insertTd(getTrollNomNode(i));
  8471. appendCheckBox(td,'envoi'+i);
  8472. }
  8473. /* Ajout du radio de choix PX ou MP */
  8474. var btnEnvoi = document.getElementById('btnEnvoi');
  8475. if(!btnEnvoi) { return; }
  8476. var tdEnvoi = btnEnvoi.parentNode;
  8477. appendText(tdEnvoi,' ');
  8478. var span = document.createElement('span');
  8479. span.style.whiteSpace = 'nowrap';
  8480. var radioElt = document.createElement('input');
  8481. radioElt.type = 'radio';
  8482. radioElt.name = 'envoiPXMP';
  8483. radioElt.id = 'radioPX';
  8484. span.appendChild(radioElt);
  8485. appendText(span,' des PX ');
  8486. radioElt = document.createElement('input');
  8487. radioElt.type = 'radio';
  8488. radioElt.name = 'envoiPXMP';
  8489. radioElt.checked = true;
  8490. span.appendChild(radioElt);
  8491. appendText(span,' un MP');
  8492. tdEnvoi.appendChild(span);
  8493. /* Insertion du bouton Annuler */
  8494. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8495. /* Modification de l'effet du bouton Envoi */
  8496. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8497. }
  8498.  
  8499. function annuleEnvoi() {
  8500. // = Handler bouton Annuler
  8501. /* Nettoyage du td du bouton Envoi */
  8502. var btnEnvoi = document.getElementById('btnEnvoi');
  8503. var tdEnvoi = btnEnvoi.parentNode;
  8504. while(tdEnvoi.firstChild) {
  8505. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8506. }
  8507. /* Retour à l'effet de base du bouton Envoi */
  8508. btnEnvoi.onclick = prepareEnvoi;
  8509. tdEnvoi.appendChild(btnEnvoi);
  8510. /* Suppression CheckBoxes */
  8511. for(var i=nbTrolls ; i>=0 ; i--) {
  8512. var td = getTrollNomNode(i);
  8513. td.parentNode.removeChild(td);
  8514. }
  8515. }
  8516.  
  8517. function effectueEnvoi() {
  8518. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  8519. var str='';
  8520. for(var i=nbTrolls ; i>0 ; i--) {
  8521. var chb = document.getElementById('envoi'+i);
  8522. if(chb.checked) {
  8523. str += (str?',':'')+getTrollID(i);
  8524. }
  8525. }
  8526. var PXchecked = document.getElementById('radioPX').checked;
  8527. if(PXchecked) {
  8528. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  8529. } else {
  8530. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  8531. }
  8532. }
  8533.  
  8534. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  8535.  
  8536. function filtreTresors() {
  8537. // += Handler checkboxes : gg, compos, bidouilles, non libres
  8538. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  8539. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  8540. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  8541. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8542. if(noEngages && !isEngagesComputed) {
  8543. for(var i=nbTrolls ; i>0 ; i--) {
  8544. var pos = getTrollPosition(i);
  8545. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  8546. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  8547. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  8548. }
  8549. isEngagesComputed = true;
  8550. }
  8551. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  8552. for(var i=nbTresors ; i>0 ; i--) {
  8553. var nom = getTresorNom(i);
  8554. var pos = getTresorPosition(i);
  8555. tr_tresors[i].style.display = (
  8556. noGG &&
  8557. nom.indexOf('Gigots de Gob')!=-1
  8558. ) || (
  8559. noCompos &&
  8560. nom.indexOf('Composant')!=-1
  8561. ) || (
  8562. noEngages &&
  8563. listeEngages[pos[2]] &&
  8564. listeEngages[pos[2]][pos[1]] &&
  8565. listeEngages[pos[2]][pos[1]][pos[0]] &&
  8566. getTresorDistance(i)>0
  8567. ) || (
  8568. strTresor!='' &&
  8569. nom.toLowerCase().indexOf(strTresor)==-1
  8570. ) || (
  8571. noBidouilles &&
  8572. nom.indexOf('Bidouille')!=-1
  8573. ) ? 'none' : '';
  8574. }
  8575. }
  8576.  
  8577.  
  8578. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  8579.  
  8580. function filtreLieux() {
  8581. // += Handler checkbox trous
  8582. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  8583. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  8584. for(var i=nbLieux ; i>0 ; i--) {
  8585. tr_lieux[i].style.display = (
  8586. strLieu &&
  8587. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  8588. ) || (
  8589. noTrou &&
  8590. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  8591. getLieuDistance(i)>1
  8592. ) ? 'none' : '';
  8593. }
  8594. }
  8595.  
  8596.  
  8597. /*-[functions]-------------------- Diplomatie --------------------------------*/
  8598.  
  8599. function refreshDiplo() {
  8600. MY_setValue(numTroll+'.diplo.off',
  8601. checkBoxDiplo.checked?'true':'false'
  8602. );
  8603. if(isDiploRaw) { computeDiplo(); }
  8604. appliqueDiplo();
  8605. }
  8606.  
  8607. function computeDiplo() {
  8608. // On extrait les données de couleur et on les stocke par id
  8609. // Ordre de préséance :
  8610. // source Guilde < source Perso
  8611. // guilde cible < troll cible
  8612. /* Diplo de Guilde */
  8613. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  8614. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  8615. if(diploGuilde && diploGuilde.isOn=='true') {
  8616. // Guilde perso
  8617. if(diploGuilde.guilde) {
  8618. Diplo.Guilde[diploGuilde.guilde.id] = {
  8619. couleur: diploGuilde.guilde.couleur,
  8620. titre: 'Ma Guilde'
  8621. };
  8622. }
  8623. // Guildes/Trolls A/E
  8624. for(var AE in {Amis:0,Ennemis:0}) {
  8625. for(var i=0 ; i<5 ; i++) {
  8626. if(diploGuilde[AE+i]) {
  8627. for(var type in {Guilde:0,Troll:0}) {
  8628. var liste = diploGuilde[AE+i][type].split(';');
  8629. for(var j=liste.length-2 ; j>=0 ; j--) {
  8630. Diplo[type][liste[j]] = {
  8631. couleur: diploGuilde[AE+i].couleur,
  8632. titre: diploGuilde[AE+i].titre
  8633. };
  8634. }
  8635. }
  8636. }
  8637. }
  8638. }
  8639. }
  8640. /* Diplo Perso */
  8641. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  8642. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  8643. if(diploPerso && diploPerso.isOn=='true') {
  8644. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8645. for(var id in diploPerso[type]) {
  8646. Diplo[type][id] = diploPerso[type][id];
  8647. }
  8648. }
  8649. }
  8650. if(diploPerso.mythiques) {
  8651. Diplo.mythiques = diploPerso.mythiques;
  8652. }
  8653. isDiploRaw = false;
  8654. }
  8655.  
  8656. function appliqueDiplo() {
  8657. var aAppliquer = Diplo;
  8658. if(checkBoxDiplo.checked) {
  8659. // Pour retour à l'affichage basique sur désactivation de la diplo
  8660. aAppliquer = {
  8661. Guilde: {},
  8662. Troll: {},
  8663. Monstre: {}
  8664. };
  8665. }
  8666. /* On applique "aAppliquer" */
  8667. // Diplo Trõlls
  8668. for(var i=nbTrolls ; i>0 ; i--) {
  8669. var idG = getTrollGuildeID(i);
  8670. var idT = getTrollID(i);
  8671. var tr = tr_trolls[i];
  8672. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  8673. if(aAppliquer.Troll[idT]) {
  8674. tr.className = '';
  8675. var descr = aAppliquer.Troll[idT].titre;
  8676. if(descr) {
  8677. getTrollNomNode(i).title = descr
  8678. }
  8679. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  8680. } else if(aAppliquer.Guilde[idG]) {
  8681. tr.className = '';
  8682. var descr = aAppliquer.Guilde[idG].titre;
  8683. if(descr) {
  8684. getTrollNomNode(i).title = descr
  8685. }
  8686. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  8687. } else {
  8688. tr.className = 'mh_tdpage';
  8689. getTrollNomNode(i).title = '';
  8690. }
  8691. }
  8692. // Diplo Monstres
  8693. for(var i=nbMonstres ; i>0 ; i--) {
  8694. var id = getMonstreID(i);
  8695. var nom = getMonstreNom(i).toLowerCase();
  8696. if(aAppliquer.Monstre[id]) {
  8697. tr_monstres[i].className = '';
  8698. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  8699. tr_monstres[i].diploActive = 'oui';
  8700. var descr = aAppliquer.Monstre[id].titre;
  8701. if(descr) {
  8702. getMonstreNomNode(i).title = descr;
  8703. }
  8704. } else if(aAppliquer.mythiques &&
  8705. (nom.indexOf('liche')==0 ||
  8706. nom.indexOf('hydre')==0 ||
  8707. nom.indexOf('balrog')==0 ||
  8708. nom.indexOf('beholder')==0)) {
  8709. tr_monstres[i].className = '';
  8710. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  8711. tr_monstres[i].diploActive = 'oui';
  8712. getMonstreNomNode(i).title = 'Monstre Mythique';
  8713. } else {
  8714. tr_monstres[i].className = 'mh_tdpage';
  8715. tr_monstres[i].diploActive = '';
  8716. }
  8717. }
  8718. }
  8719.  
  8720.  
  8721. /*-[functions]---------------- Actions à distance ----------------------------*/
  8722.  
  8723. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  8724. var monN = parseInt(getPosition()[2]);
  8725. for(var type in keltypes) {
  8726. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  8727. for(var i=this['nb'+type] ; i>0 ; i--) {
  8728. var tr = this['tr_'+type.toLowerCase()][i];
  8729. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  8730. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  8731. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  8732. var sonN = getXxxPosition(type, i)[2];
  8733. var d = getXxxDistance(type, i);
  8734. if(sonN==monN && d>=dmin && d<=dmax) {
  8735. var iconeAction = document.evaluate(
  8736. "./descendant::img[@alt='"+alt+"']",
  8737. tr, null, 9, null
  8738. ).singleNodeValue;
  8739. if(iconeAction) {
  8740. if(iconeAction.title) {
  8741. iconeAction.title += "\n"+message;
  8742. } else {
  8743. iconeAction.title = message;
  8744. }
  8745. iconeAction.src = urlIcon;
  8746. } else {
  8747. var tdAction = tr.getElementsByTagName('td')[1];
  8748. var icon = document.createElement('img');
  8749. icon.src = urlIcon;
  8750. icon.height = 20;
  8751. icon.alt = alt;
  8752. icon.title = message;
  8753. tdAction.appendChild(icon);
  8754. }
  8755. }
  8756. }
  8757. }
  8758. }
  8759.  
  8760. function computeCharge() {
  8761. computeActionDistante(1,
  8762. getPortee__Vue(
  8763. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  8764. MY_getValue(numTroll+".caracs.regeneration")
  8765. ),
  8766. {'Monstres':1, 'Trolls':1},
  8767. 'Attaquer',
  8768. MHicons+'E_Metal09.png',
  8769. 'Cible à portée de Charge'
  8770. );
  8771. }
  8772.  
  8773. function computeProjo() {
  8774. computeActionDistante(0,
  8775. getPortee__Vue(
  8776. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8777. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8778. ),
  8779. {'Monstres':1, 'Trolls':1},
  8780. 'Attaquer',
  8781. MHicons+'S_Fire05.png',
  8782. 'Cible à portée de Projo'
  8783. );
  8784. }
  8785.  
  8786. function computeTelek() {
  8787. computeActionDistante(0,
  8788. Math.floor((
  8789. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8790. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8791. )/2),
  8792. {'Tresors':1},
  8793. 'Telek',
  8794. MHicons+'S_Magic04.png',
  8795. 'Trésor à portée de Télékinésie'
  8796. );
  8797. }
  8798.  
  8799. function computeLdP() {
  8800. computeActionDistante(0,
  8801. 2+Math.floor((
  8802. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8803. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8804. )/5),
  8805. {'Monstres':1, 'Trolls':1},
  8806. 'self',
  8807. MHicons+'P_Red01.png',
  8808. 'Cible à portée de Lancer de Potions'
  8809. );
  8810. }
  8811.  
  8812.  
  8813. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  8814.  
  8815. function putScriptExterne() {
  8816. var infoit = MY_getValue(numTroll+'.INFOSIT');
  8817. if(!infoit || infoit=='') return;
  8818.  
  8819. var nomit = infoit.slice(0,infoit.indexOf('$'));
  8820. if(nomit=='bricol') {
  8821. var data = infoit.split('$');
  8822. try {
  8823. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  8824. // appendNewScript(URL_bricol+data[1]
  8825. // +'/mz.php?login='+data[2]
  8826. // +'&password='+data[3]
  8827. // );
  8828. FF_XMLHttpRequest({
  8829. method: 'GET',
  8830. url: URL_bricol+data[1]
  8831. +'/mz_json.php?login='+data[2]
  8832. +'&password='+data[3],
  8833. onload: function(responseDetails) {
  8834. try {
  8835. if (responseDetails.status == 0) {
  8836. if (isHTTPS) {
  8837. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  8838. } else {
  8839. window.console.log('status=0 à l\'appel bricol\'troll');
  8840. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  8841. }
  8842. return;
  8843. }
  8844. var ratibusData;
  8845. try {
  8846. ratibusData = JSON.parse(responseDetails.responseText);
  8847. } catch(e) {}
  8848. if (ratibusData === undefined) {
  8849. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  8850. return;
  8851. }
  8852. if (ratibusData.error) {
  8853. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  8854. } else {
  8855. putInfosTrolls(ratibusData.data.trolls);
  8856. }
  8857. } catch(e) {
  8858. window.console.log('exception retour bricol\'troll ' + e);
  8859. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  8860. }
  8861. }
  8862. });
  8863. } catch(e) {
  8864. if (isHTTPS) {
  8865. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  8866. } else {
  8867. window.console.log('exception appel bricol\'troll ' + e);
  8868. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  8869. }
  8870. }
  8871. }
  8872. }
  8873.  
  8874. /* Le script mz.php de Ratibus renvoie :
  8875. + infosTrolls = new Array();
  8876. + infosTrolls[numdutroll] =
  8877. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  8878. + etc ...
  8879. + putInfosTrolls();
  8880. *
  8881. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  8882. * Roule 07/11/2016, on utilise mz_json qui envoie
  8883. {
  8884. "data": {
  8885. "trolls": {
  8886. "59424": {
  8887. "id": 59424,
  8888. "pv": xx,
  8889. "pv_max": xx,
  8890. "updated_at": "2016-10-31 07:28:40",
  8891. "dla": "2016-10-05 07:28:04",
  8892. "pa": 0
  8893. },
  8894. }
  8895. }
  8896. }
  8897. */
  8898.  
  8899. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  8900. function corrigeBricolTrolls(infosTrolls) {
  8901. for(var i in infosTrolls) {
  8902. var pv = infosTrolls[i][0];
  8903. var pvmax = infosTrolls[i][1];
  8904. var pvmem = MY_getValue(i+'.caracs.pv.max');
  8905. if(pvmem && pvmem>pvmax) {
  8906. infosTrolls[i][1] = pvmem;
  8907. pvmax = pvmem;
  8908. }
  8909. if(pv>pvmax) {
  8910. var newpvmax = 5*Math.ceil(pv/5);
  8911. MY_setValue(i+'.caracs.pv.max',newpvmax);
  8912. infosTrolls[i][1] = newpvmax;
  8913. }
  8914. }
  8915. }
  8916.  
  8917. // insère 2 TD avant nextTD avec les infos venant de l'IT
  8918. function addTdInfosTroll(infos, nextTD) {
  8919. /* cadre barre PV */
  8920. var tab = document.createElement('div');
  8921. /* ancienne méthode par img, à supprimer
  8922. tab.width = 100;
  8923. tab.style.width = 100;
  8924. tab.height = 10;
  8925. tab.style.background = '#FFFFFF';
  8926. tab.style.border = 1;
  8927. */
  8928. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  8929. /* barre PV */
  8930. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  8931. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  8932. .vieContainer {
  8933. background-color: #CCC;
  8934. width: 50px;
  8935. height: 6px;
  8936. border: 1px solid #000;
  8937. text-align: left;
  8938. }
  8939. */
  8940. tab.style.width = '100px';
  8941. tab.style.height = '10px';
  8942. tab.style.border = '1px solid #000';
  8943. tab.style.textAlign = 'left';
  8944. var div2 = document.createElement('div');
  8945. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  8946. var dateLimite = new Date();
  8947. dateLimite.setDate(dateLimite.getDate() - 7);
  8948. if (infos.oUpdatedAt < dateLimite) {
  8949. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  8950. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  8951. } else if (pourcentVie > 66) {
  8952. div2.style.backgroundColor = '#77EE77';
  8953. } else if (pourcentVie > 33) {
  8954. div2.style.backgroundColor = '#EEEE77';
  8955. } else {
  8956. div2.style.backgroundColor = '#FF0000';
  8957. }
  8958. div2.style.width = pourcentVie + '%';
  8959. div2.style.height = '10px';
  8960. tab.appendChild(div2);
  8961. /* ancienne méthode par img, à supprimer
  8962. var img = document.createElement('img');
  8963. img.src = '../Images/Interface/milieu.gif';
  8964. img.height = 10;
  8965. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  8966. tab.appendChild(img);
  8967. */
  8968.  
  8969. /* lien vers l'IT */
  8970. var lien = document.createElement('a');
  8971. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  8972. lien.href = URL_bricol+nomit+'/index.php';
  8973. lien.target = '_blank';
  8974. lien.appendChild(tab);
  8975. insertTdElement(nextTD,lien);
  8976. /* PAs dispos */
  8977. var span = document.createElement('span');
  8978. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  8979. appendText(span, infos.pa +' PA' );
  8980. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  8981. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  8982. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  8983. span.style.backgroundColor = 'B8EEB8';
  8984. }
  8985. insertTdElement(nextTD, span);
  8986. }
  8987.  
  8988. function putInfosTrolls(infosTrolls) {
  8989. try {
  8990. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  8991. // supression des infos trop vieilles (un mois)
  8992. var IDs = Object.keys(infosTrolls);
  8993. var dateLimite = new Date();
  8994. dateLimite.setMonth(dateLimite.getMonth() - 1);
  8995. for (var i = 0; i < IDs.length; i++) {
  8996. var idTroll = IDs[i];
  8997. var infos = infosTrolls[idTroll];
  8998. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  8999. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9000. }
  9001. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9002. td.width = 40;
  9003. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9004. td.width = 105;
  9005.  
  9006. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9007. //corrigeBricolTrolls(infosTrolls);
  9008.  
  9009. for(i=nbTrolls ; i>0 ; i--) {
  9010. var infos = infosTrolls[getTrollID(i)];
  9011. if(infos && (!infos.bIgnore)) {
  9012. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9013. infos.done = true;
  9014. } else {
  9015. insertTd(tr_trolls[i].childNodes[6]);
  9016. insertTd(tr_trolls[i].childNodes[6]);
  9017. }
  9018. }
  9019. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9020. var str = MY_getValue(numTroll+'.INFOSIT');
  9021. if(!str) return;
  9022. var arr = str.split('$');
  9023. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9024.  
  9025. //window.console.log('nb Troll IT : ' + IDs.length);
  9026. var tBody = tr_trolls[0].parentNode;
  9027. if (tr_trolls[1] === undefined)
  9028. tBody = tr_trolls[0].parentNode;
  9029. else
  9030. tBody = tr_trolls[1].parentNode;
  9031. var pos = getPosition();
  9032. for (i = 0; i < IDs.length; i++) {
  9033. var idTroll = IDs[i];
  9034. infos = infosTrolls[idTroll];
  9035. if (infos.done) continue; // déjà vu
  9036. if (infos.bIgnore) continue; // trop vieux
  9037. if (idTroll == numTroll) continue; // pas nous-même
  9038. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9039. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9040. // trouver où insérer ce Troll
  9041. var next = undefined;
  9042. for(var j=0 ; j<tr_trolls.length ; j++) {
  9043. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9044. if (thisDist > distance) {
  9045. next = tr_trolls[j]
  9046. break;
  9047. }
  9048. }
  9049. var tr;
  9050. if (next !== undefined) {
  9051. tr = insertTr(next,'mh_tdpage')
  9052. } else {
  9053. tr = appendTr(tBody,'mh_tdpage');
  9054. }
  9055. var td = appendTd(tr); // distance
  9056. appendText(td, distance);
  9057. td = appendTd(tr); // actions
  9058. td = appendTd(tr); // ID
  9059. appendText(td, idTroll);
  9060. td = appendTd(tr); // Nom
  9061. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9062. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9063. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9064. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9065. td = appendTd(tr); // Niveau
  9066. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9067. td.align = 'center';
  9068. td = appendTd(tr); // Race
  9069. if (infos.race) appendText(td, infos.race);
  9070. // PV et PA ajoutés par addTdInfosTroll
  9071. td = appendTd(tr); // Guilde
  9072. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9073. td = appendTd(tr); // X
  9074. td.align = 'center';
  9075. if (infos.x !== undefined) appendText(td, infos.x);
  9076. td = appendTd(tr); // Y
  9077. td.align = 'center';
  9078. if (infos.y !== undefined) appendText(td, infos.y);
  9079. td = appendTd(tr); // N
  9080. td.align = 'center';
  9081. if (infos.n !== undefined) appendText(td, infos.n);
  9082. addTdInfosTroll(infos, tr.childNodes[6]);
  9083. }
  9084. } catch(e) {
  9085. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  9086. }
  9087. }
  9088.  
  9089.  
  9090. /* Mode Tétalanvert! ---------------------------------------------------------*/
  9091.  
  9092. function calculeDistance(maPos,posArr) {
  9093. return Math.max(
  9094. Math.abs(maPos[0]-posArr[0]),
  9095. Math.abs(maPos[1]-posArr[1]),
  9096. Math.abs(maPos[2]-posArr[2])
  9097. );
  9098. }
  9099.  
  9100. function inversionCoord() {
  9101. var maPos = getPosition();
  9102. var listeOffsets = {
  9103. 'monstres':checkBoxLevels.checked?4:3,
  9104. 'trolls':6,
  9105. };
  9106. for(var type in listeOffsets) {
  9107. var trList = this['tr_'+type];
  9108. var offset = listeOffsets[type];
  9109. for(var i=trList.length-1 ; i>0 ; i--) {
  9110. var oldX = parseInt(trList[i].cells[offset].textContent);
  9111. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  9112. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  9113. trList[i].cells[offset].innerHTML = oldY;
  9114. trList[i].cells[offset+1].innerHTML = oldX;
  9115. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  9116. }
  9117. }
  9118. }
  9119.  
  9120.  
  9121. /* Partie principale */
  9122. function do_vue() {
  9123. for(var type in typesAFetcher) {
  9124. fetchData(type);
  9125. }
  9126.  
  9127. // roule' 11/03/2016
  9128. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  9129. // je fais une recopie :(
  9130. tr_monstres = this['tr_monstres'];
  9131. tr_trolls = this['tr_trolls'];
  9132. tr_tresors = this['tr_tresors'];
  9133. tr_champignons = this['tr_champignons'];
  9134. tr_lieux = this['tr_lieux'];
  9135.  
  9136. nbMonstres = this['nbMonstres'];
  9137. nbTrolls = this['nbTrolls'];
  9138. nbTresors = this['nbTresors'];
  9139. nbChampignons = this['nbChampignons'];
  9140. nbLieux = this['nbLieux'];
  9141.  
  9142. try {
  9143. start_script(31);
  9144. initialiseInfos();
  9145. savePosition();
  9146.  
  9147. // Fonctionnalité "Têtalenvert" cachée, en test :
  9148. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  9149. inversionCoord();
  9150. }
  9151. ajoutDesFiltres();
  9152. set2DViewSystem();
  9153. //putBoutonTroogle();
  9154. putBoutonPXMP();
  9155. synchroniseFiltres();
  9156. toggleLevelColumn();
  9157.  
  9158. refreshDiplo();
  9159. //400 ms
  9160. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  9161. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  9162. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  9163. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  9164. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  9165. var noTresorsEngages =
  9166. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  9167. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  9168. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  9169. filtreMonstres();
  9170. if(noIntangibles) {
  9171. filtreTrolls();
  9172. }
  9173. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  9174. filtreTresors();
  9175. }
  9176. if(noTrou) {
  9177. filtreLieux();
  9178. }
  9179.  
  9180. initPopupVue();
  9181. initPXTroll();
  9182.  
  9183. if(getTalent("Projectile Magique")!=0) {
  9184. computeProjo();
  9185. }
  9186. if(getTalent("Charger")!=0) {
  9187. computeCharge();
  9188. }
  9189. if(getTalent("Télékinésie")!=0) {
  9190. computeTelek();
  9191. }
  9192. if(getTalent("Lancer de Potions")!=0) {
  9193. computeLdP();
  9194. }
  9195. putScriptExterne();
  9196. displayScriptTime();
  9197. } catch(e) {
  9198. avertissement("[MZ] Une erreur s'est produite.");
  9199. window.console.error("[MZ] Erreur générale Vue",e);
  9200. }
  9201. }
  9202.  
  9203.  
  9204.  
  9205. /*******************************************************************************
  9206. * This file is part of Mountyzilla. *
  9207. * *
  9208. * Mountyzilla is free software; you can redistribute it and/or modify *
  9209. * it under the terms of the GNU General Public License as published by *
  9210. * the Free Software Foundation; either version 2 of the License, or *
  9211. * (at your option) any later version. *
  9212. * *
  9213. * Mountyzilla is distributed in the hope that it will be useful, *
  9214. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9215. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9216. * GNU General Public License for more details. *
  9217. * *
  9218. * You should have received a copy of the GNU General Public License *
  9219. * along with Mountyzilla; if not, write to the Free Software *
  9220. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9221. *******************************************************************************/
  9222.  
  9223. // x~x profil2
  9224.  
  9225. /*---------------------------- Variables globales ----------------------------*/
  9226.  
  9227. var
  9228. // Anatrolliseur
  9229. urlAnatrolliseur,
  9230. // Infobulles talents
  9231. hauteur = 50, bulleStyle = null,
  9232. // Caracteristiques
  9233. // Infos troll
  9234. race, niv, idtroll, datecrea,
  9235. idguilde, nomguilde,
  9236. // Etats du troll
  9237. fatigue, bmfatigue,
  9238.  
  9239. // Experience, Pi, ...
  9240. pxdistribuables, pxperso,
  9241. piutilisable, pitotal,
  9242. nbmeurtres, nbmorts,
  9243. // utilisee pour les moyennes MM/jour, kill/jour, etc
  9244. NBjours,
  9245. // calcul des DLA suivantes
  9246. DLA, DLAsuiv, HeureServeur,
  9247. // details duree du tour (calcul pvdispo) :
  9248. dtb, pdm, bmt, adb, dpt,
  9249. //posale
  9250. posX, posY, posN,
  9251. // caracs physiques
  9252. vue, vuebp, vuebm, vuetotale,
  9253. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  9254. reg, regbp, regbm, regmoy,
  9255. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  9256. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  9257. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  9258. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  9259. rm, rmbp, rmbm, rmtotale,
  9260. mm, mmbp, mmbm, mmtotale,
  9261.  
  9262. // Variables speciales Kastars
  9263. pvActuelKastar, minParPV, overDLA,
  9264. // id pour edition manuelle de lastDLA :
  9265. inJour, inMois, inAn, inHr, inMin, inSec,
  9266. // id pour auto-refresh lastDLA :
  9267. lastDLAZone, maxAMZone, cumulZone,
  9268. lastDLA, DLAaccel;
  9269.  
  9270.  
  9271. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9272.  
  9273. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  9274. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  9275. function getUniqueValueBySelector(selector, defaultValue){
  9276. var valNode = document.querySelector(selector);
  9277. if(valNode!=null){
  9278. if(valNode.hasChildNodes()) {
  9279. return valNode.childNodes[0].nodeValue;
  9280. }else{
  9281. return defaultValue;
  9282. }
  9283. } else{
  9284. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  9285. return defaultValue;
  9286. }
  9287. }
  9288. function getUniqueStringValueBySelector(selector){
  9289. return getUniqueValueBySelector(selector,"");
  9290. }
  9291. function getUniqueIntValueBySelector(selector){
  9292. var ret = getUniqueValueBySelector(selector,0);
  9293. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9294. ret = 0;
  9295. }
  9296. return parseInt(ret);
  9297. }
  9298. function getUniqueFloatValueBySelector(selector){
  9299. var ret = getUniqueValueBySelector(selector,0.0);
  9300. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9301. ret = 0.0;
  9302. }
  9303. return parseFloat(ret);
  9304. }
  9305.  
  9306.  
  9307. function resiste(Ddeg,bm) {
  9308. // version naive mais compréhensible ^^
  9309. // DEBUG: à revoir
  9310. if(!bm) {
  9311. return 2*Math.floor(Ddeg/2);
  9312. }
  9313. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  9314. }
  9315.  
  9316. function retourAZero(fatig) {
  9317. var fat = fatig, raz = 0;
  9318. while(fat>0) {
  9319. raz++;
  9320. fat = Math.floor(fat/1.25);
  9321. }
  9322. return raz;
  9323. }
  9324.  
  9325. function decumulPumPrem(bonus) {
  9326. switch(bonus) {
  9327. case 20: return 33;
  9328. case 33: return 41;
  9329. case 41: return 46;
  9330. case 46: return 49;
  9331. case 49: return 51;
  9332. default: return 20;
  9333. }
  9334. }
  9335.  
  9336. function coefDecumul(i) {
  9337. switch(i) {
  9338. case 2: return 0.67;
  9339. case 3: return 0.4;
  9340. case 4: return 0.25;
  9341. case 5: return 0.15;
  9342. default: return 0.1;
  9343. }
  9344. }
  9345.  
  9346. function dureeHM(dmin) {
  9347. var ret = "";
  9348. dmin = Math.floor(dmin);
  9349. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  9350. var mins = dmin%60;
  9351. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  9352. return (ret) ? ret : "-";
  9353. }
  9354.  
  9355. // extraction d'une durée
  9356. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  9357. // c'est protégé (rend 0 si l'élément est absent)
  9358. // Roule' 24/12/2016
  9359. function extractionDuree(selecteur) {
  9360. var s = getUniqueStringValueBySelector(selecteur);
  9361. if (!s) return 0;
  9362. var tabN = getNumbers(s);
  9363. if (tabN.length < 2) return 0;
  9364. return tabN[0] * 60 + tabN[1];
  9365. }
  9366.  
  9367. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  9368.  
  9369. function extractionDonnees() {
  9370. // Variables temporaires
  9371. var Nbrs = {};
  9372.  
  9373. // *********************
  9374. // Cadre "Description"
  9375. // *********************
  9376. race = getUniqueStringValueBySelector('#descr #race');
  9377. debugMZ("Race : " + race);
  9378. idtroll = getUniqueStringValueBySelector('#descr #id');
  9379. debugMZ("Id troll : " + idtroll);
  9380. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  9381. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  9382. datecrea = new Date(StringToDate(strDateCrea));
  9383. debugMZ("Date creation : " + datecrea);
  9384. // Guilde
  9385. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  9386. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  9387. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  9388.  
  9389. // *******************
  9390. // Cadre "Experience"
  9391. // *******************
  9392. // Niveau de troll
  9393. niv = getUniqueIntValueBySelector('#exp #niv');
  9394. nivTroll = niv;
  9395. debugMZ("Niveau : " + niv);
  9396. // PX
  9397. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  9398. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  9399. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  9400. // PI
  9401. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  9402. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  9403. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  9404. // Meutres/Morts
  9405. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  9406. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  9407. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  9408.  
  9409. // *********************
  9410. // Cadre "Tour de Jeu"
  9411. // *********************
  9412. // DLA
  9413. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  9414. DLA = new Date(StringToDate(Nbrs["dla"]));
  9415. debugMZ("DLA: " + DLA);
  9416. // DLA suivante
  9417. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  9418. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  9419. debugMZ("DLAsuiv: " + DLAsuiv);
  9420. // Duree normale de mon Tour
  9421. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  9422. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  9423. dtb = extractionDuree("#dla #tour");
  9424. debugMZ("Duree normale de mon Tour : " + dtb);
  9425. // Bonus/Malus sur la duree
  9426. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  9427. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  9428. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  9429. debugMZ("Bonus/Malus sur la duree : " + bmt);
  9430. // Augmentation due aux blessures
  9431. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  9432. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  9433. adb = extractionDuree("#dla #blessure");
  9434. debugMZ("Augmentation due aux blessures : " + adb);
  9435. // Poids de l'equipement
  9436. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  9437. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  9438. pdm = extractionDuree("#dla #poids");
  9439. debugMZ("Poids de l'equipement : " + pdm);
  9440. // Duree de mon prochain Tour
  9441. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  9442. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  9443. dpt = extractionDuree("#dla #duree>b");
  9444. debugMZ('Duree de mon prochain Tour : ' + dpt);
  9445.  
  9446. // ****************
  9447. // Cadre "Etats"
  9448. // ****************
  9449. // Position du troll :
  9450. posX = getUniqueIntValueBySelector('#pos #x');
  9451. posY = getUniqueIntValueBySelector('#pos #y');
  9452. posN = getUniqueIntValueBySelector('#pos #n');
  9453. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  9454. // PV actuel
  9455. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  9456. pvActuelKastar = pvcourant;
  9457. debugMZ("PV actuel : " + pvcourant)
  9458. // Fatigue
  9459. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  9460. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  9461. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  9462.  
  9463. // **************************
  9464. // Cadre "Caracteristiques"
  9465. // **************************
  9466. // Attaque
  9467. att = getUniqueIntValueBySelector('#carac #att');
  9468. attbp = getUniqueIntValueBySelector('#carac #att_p');
  9469. attbm = getUniqueIntValueBySelector('#carac #att_m');
  9470. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  9471. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  9472. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  9473. attmoy = 3.5*att + attbp + attbm;
  9474. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9475. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  9476. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  9477. // Esquive
  9478. esq = getUniqueIntValueBySelector('#carac #esq');
  9479. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  9480. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  9481. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  9482. esqmoy = 3.5*esq + esqbp+esqbm;
  9483. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  9484. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  9485. // Degat
  9486. deg = getUniqueIntValueBySelector('#carac #deg');
  9487. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  9488. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  9489. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  9490. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  9491. degmoy = 2*deg + degbp+degbm;
  9492. degmoycrit = 3*deg + degbp+degbm;
  9493. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9494. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  9495. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  9496. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  9497. // PV
  9498. pvbase = getUniqueIntValueBySelector('#carac #pv');
  9499. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  9500. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  9501. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  9502. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  9503. // Regeneration
  9504. reg = getUniqueIntValueBySelector('#carac #reg');
  9505. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  9506. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  9507. regmoy = 2 * reg + regbp + regbm; // D3
  9508. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  9509. // Armure
  9510. arm = getUniqueIntValueBySelector('#carac #arm');
  9511. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  9512. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  9513. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  9514. armmoy = 2*arm + armbp+armbm;
  9515. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  9516. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  9517. // TODO : D d'armure non active
  9518. // Vue
  9519. vue = getUniqueIntValueBySelector('#carac #vue');
  9520. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  9521. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  9522. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  9523. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  9524. // RM
  9525. rm = getUniqueIntValueBySelector('#carac #rm');
  9526. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  9527. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  9528. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  9529. rmTroll = rmtotale;
  9530. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  9531. // MM
  9532. mm = getUniqueIntValueBySelector('#carac #mm');
  9533. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  9534. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  9535. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  9536. mmTroll = mmtotale;
  9537. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  9538.  
  9539. // Heure Serveur
  9540. try {
  9541. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  9542. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  9543. HeureServeur = new Date(StringToDate(heureServeurSTR));
  9544. } catch (e) {
  9545. window.console.warn(
  9546. "[MZ] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  9547. );
  9548. HeureServeur = new Date();
  9549. }
  9550. debugMZ("HeureServeur: " + HeureServeur);
  9551.  
  9552. // ***INIT GLOBALE*** NBjours
  9553. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  9554.  
  9555. // Calcul debut lien anatroliseur avec les caracteristiques connues
  9556. var amelio_dtb = function(dtb) {
  9557. if(dtb>555) {
  9558. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  9559. }
  9560. return 10+Math.ceil((555-dtb)/2.5);
  9561. },
  9562. amelio_pv = Math.floor(pvbase/10)-3,
  9563. amelio_vue = vue-3,
  9564. amelio_att = att-3,
  9565. amelio_esq = esq-3,
  9566. amelio_deg = deg-3,
  9567. amelio_reg = reg-1,
  9568. amelio_arm = arm-1;
  9569. if(race==="Darkling"){amelio_reg--; }
  9570. if(race==="Durakuir"){amelio_pv-- ; }
  9571. if(race==="Kastar") {amelio_deg--; }
  9572. if(race==="Skrim") {amelio_att--; }
  9573. if(race==="Tomawak") {amelio_vue--; }
  9574.  
  9575. urlAnatrolliseur = URL_AnatrolDispas
  9576. +"outils_anatrolliseur.php?anatrolliseur=v8"
  9577. +"|r="+race.toLowerCase()
  9578. +"|dla="+amelio_dtb(dtb)
  9579. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  9580. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  9581. +"|att="+amelio_att+","+attbp+","+attbm
  9582. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  9583. +"|deg="+amelio_deg+","+degbp+","+degbm
  9584. +"|reg="+amelio_reg+","+regbp+","+regbm
  9585. +"|arm="+amelio_arm+","+armbp+","+armbm
  9586. +"|mm="+mmtotale
  9587. +"|rm="+rmtotale+"|";
  9588. }
  9589.  
  9590. function saveProfil() {
  9591. MY_setValue(idtroll+'.caracs.attaque',att);
  9592. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  9593. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  9594. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  9595. if(atttourD||atttourP||atttourM) {
  9596. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9597. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  9598. }
  9599. MY_setValue(idtroll+'.caracs.esquive',esq);
  9600. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  9601. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  9602. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  9603. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  9604. MY_setValue(idtroll+'.caracs.degats',deg);
  9605. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  9606. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  9607. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  9608. if(degtourP||degtourM){
  9609. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9610. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  9611. }
  9612. MY_setValue(idtroll+'.caracs.regeneration',reg);
  9613. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  9614. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  9615. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  9616. MY_setValue(idtroll+'.caracs.vue',vue);
  9617. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  9618. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  9619. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  9620. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  9621. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  9622. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  9623. MY_setValue(idtroll+'.caracs.rm',rm);
  9624. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  9625. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  9626. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  9627. MY_setValue(idtroll+'.caracs.mm',mm);
  9628. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  9629. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  9630. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  9631. MY_setValue(idtroll+'.caracs.armure',arm);
  9632. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  9633. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  9634. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  9635. MY_setValue(idtroll+'.position.X',posX);
  9636. MY_setValue(idtroll+'.position.Y',posY);
  9637. MY_setValue(idtroll+'.position.N',posN);
  9638. MY_setValue(idtroll+'.race',race);
  9639. MY_setValue(idtroll+'.niveau',niv);
  9640. MY_setValue(idtroll+'.idguilde',idguilde);
  9641. MY_setValue(idtroll+'.nomguilde',nomguilde);
  9642. }
  9643.  
  9644.  
  9645. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  9646.  
  9647. function setInfosCaracteristiques() {
  9648. // Modification de l'entete
  9649. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  9650. thTotal.innerHTML+='|<i>Moyenne</i>';
  9651. thTotal.title="Moyenne (Moyenne ce tour)";
  9652.  
  9653. // Ajout des informations calculees
  9654. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  9655. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  9656. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  9657.  
  9658. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  9659. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  9660. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  9661.  
  9662. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  9663. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  9664. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  9665.  
  9666. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  9667. var tdRegTotal = trRegeneration.children[5];
  9668. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  9669. // Temps recupere par reg (propale R')
  9670. var regmoyTemp = Math.max(0, regmoy);
  9671. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  9672. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  9673. if (sec != 0) {
  9674. regTitle += " " + sec + " sec";
  9675. }
  9676. trRegeneration.title = regTitle;
  9677.  
  9678. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  9679. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  9680. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  9681.  
  9682. var trRM=document.querySelector("table#caracs #rm").parentElement;
  9683. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  9684. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  9685.  
  9686.  
  9687. var trMM=document.querySelector("table#caracs #mm").parentElement;
  9688. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  9689. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  9690.  
  9691. var tdRefl=document.querySelector("#refl");
  9692. // TODO : prendre en compte bonus/malus D esq du tour ?
  9693. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  9694. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  9695. }
  9696.  
  9697. function setLienAnatrolliseur(){
  9698. var pTableAmelio = document.querySelector("#carac>div>p");
  9699. pTableAmelio.innerHTML+=" - ";
  9700. var aElt = document.createElement("a");
  9701. aElt.setAttribute("href",urlAnatrolliseur);
  9702. aElt.setAttribute("target","_blank");
  9703. aElt.className="AllLinks";
  9704. aElt.innerHTML="Anatrolliser";
  9705. pTableAmelio.appendChild(aElt);
  9706. }
  9707. function setInfoDescription() {
  9708. var txtDateCrea = (NBjours!=1) ?
  9709. " ("+NBjours+" jours dans le hall)" :
  9710. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  9711. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  9712. }
  9713.  
  9714. function setInfosEtatLieux() {
  9715. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  9716. '?search=position&orderBy=distance&posx='+
  9717. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  9718. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  9719. appendBr(tdPosition);
  9720. var aElt = document.createElement("a");
  9721. aElt.setAttribute("href",urlBricol);
  9722. aElt.setAttribute("target","_blank");
  9723. aElt.className="AllLinks";
  9724. aElt.innerHTML="Lieux à proximité";
  9725. tdPosition.appendChild(aElt);
  9726. }
  9727.  
  9728. function setInfosEtatPV() { // pour AM et Sacro
  9729. var
  9730. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  9731. sec = Math.floor(15000/pvtotal)%60,
  9732. lifebar = document.querySelector("#pos .barre-vie");
  9733. if(sec!=0) { txt += " "+sec+" sec"; }
  9734. if(lifebar) { lifebar.title = txt; }
  9735. if(pvcourant<=0) { return; }
  9736. // Difference PV p/r a equilibre de temps (propale R')
  9737. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  9738. // ***INIT GLOBALE*** pvdispo
  9739. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  9740. var span = document.createElement("span");
  9741. span.title = txt;
  9742. span.style.fontStyle = "italic";
  9743. if(bmt+pdm>=0) {
  9744. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  9745. } else if(pvdispo>0) {
  9746. txt = "Vous pouvez encore perdre "+
  9747. Math.min(pvdispo,pvcourant)+
  9748. " PV sans malus de temps.";
  9749. } else if(pvdispo<0) {
  9750. txt = "Il vous manque "
  9751. +(-pvdispo)
  9752. +" PV pour ne plus avoir de malus de temps.";
  9753. } else {
  9754. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  9755. }
  9756. appendText(span,txt);
  9757. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  9758. }
  9759.  
  9760. // Complete le cadre "Experience"
  9761. function setInfosExp() {
  9762. var tdNiv = document.querySelector("#exp #niv");
  9763.  
  9764. // Calcul niveau monstre/troll min pour gain PX
  9765. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  9766. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  9767.  
  9768. // Calcul PX restant
  9769. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  9770. if (pxRestant >= 0) {
  9771. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  9772. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  9773. }
  9774.  
  9775. // Calul pi/jour
  9776. var
  9777. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  9778. tdPi = document.querySelector("#exp #pi").parentElement;
  9779. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  9780. tdPi.title = tdPiTotal.title;
  9781.  
  9782. // Rapports meurtres,morts
  9783. var tdKill = document.querySelector("#exp #kill");
  9784. tdKill.setAttribute("colspan", 1);
  9785. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  9786.  
  9787. var tdMort = document.querySelector("#exp #mort");
  9788. tdMort.setAttribute("colspan", 1);
  9789. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  9790.  
  9791. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  9792. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  9793. }
  9794.  
  9795.  
  9796. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  9797.  
  9798. function minParPVsac(fat,bm) {
  9799. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  9800. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  9801. var out = [];
  9802. out[0] = (fat>4) ?
  9803. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  9804. 30;
  9805. if(bm && bm>0) {
  9806. var totalfat=fat+bm;
  9807. out[1] = (totalfat>4) ?
  9808. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  9809. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  9810. }
  9811. return out;
  9812. }
  9813.  
  9814. function toInt(str) {
  9815. str = parseInt(str);
  9816. return (str) ? str : 0;
  9817. }
  9818.  
  9819. function saveLastDLA() {
  9820. // pour les calculs d'AM max
  9821. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  9822. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  9823. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  9824. lastDLA = new Date( StringToDate(str) );
  9825. MY_setValue(numTroll+'.DLA.ancienne',str);
  9826. lastDLAZone.innerHTML = '';
  9827. var b = document.createElement('b');
  9828. b.addEventListener('click',inputMode,false);
  9829. appendText(b,str);
  9830. lastDLAZone.appendChild(b);
  9831. refreshAccel();
  9832. }
  9833.  
  9834. function inputMode() {
  9835. // Edition manuelle lastDLA
  9836. var date;
  9837. if(lastDLA)
  9838. date = new Date( lastDLA );
  9839. else
  9840. date = new Date( DLAaccel );
  9841. lastDLAZone.innerHTML = '';
  9842. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  9843. appendText(lastDLAZone,'/');
  9844. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  9845. appendText(lastDLAZone,'/');
  9846. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  9847. appendText(lastDLAZone,' - ');
  9848. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  9849. appendText(lastDLAZone,':');
  9850. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  9851. appendText(lastDLAZone,':');
  9852. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  9853. appendText(lastDLAZone,' - ');
  9854. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  9855. }
  9856.  
  9857. function setAccel() {
  9858. var
  9859. BMfrais=false,
  9860. fat=fatigue, listeBmFat=[],
  9861. tr, th, insertPt;
  9862.  
  9863. // Creation ligne speciale pour AM dans le cadre "Etat"
  9864. tr = document.createElement('tr');
  9865. th = document.createElement('th');
  9866. appendText(th,'Fatigue et AM',true);
  9867. tr.appendChild(th);
  9868. insertPt = document.createElement('td');
  9869. tr.appendChild(insertPt);
  9870. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  9871.  
  9872. // Est-on en over-DLA ?
  9873. // ***INIT GLOBALE*** overDLA
  9874. overDLA = (HeureServeur>DLA.getTime()+3e5);
  9875. if(overDLA) {
  9876. fat=Math.floor(fatigue/1.25);
  9877. }
  9878.  
  9879. // Gestion des BM de fatigue
  9880. if(bmfatigue>0) {
  9881. // On tente de recuperer les BM de fatigue de la page des BM
  9882. if(MY_getValue(numTroll+'.bm.fatigue')) {
  9883. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  9884. BMmemoire.pop();
  9885. var tour = 0;
  9886. for(var i=0 ; i<BMmemoire.length ; i++) {
  9887. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  9888. while(tour<=parseInt(nbrs[0])) {
  9889. listeBmFat[tour]=parseInt(nbrs[1]);
  9890. tour++;
  9891. }
  9892. }
  9893. }
  9894. if(listeBmFat[0]==bmfatigue) {
  9895. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  9896. BMfrais = true;
  9897. MY_removeValue(numTroll+".bm.fatigue");
  9898. }
  9899. } else {
  9900. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  9901. BMfrais = true;
  9902. }
  9903. if(!BMfrais && bmfatigue>0) {
  9904. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  9905. if(bmfatigue==15) {
  9906. listeBmFat = [15,15,15];
  9907. } else {
  9908. listeBmFat = [30,30,15];
  9909. }
  9910. }
  9911. if(overDLA) {
  9912. // Si on est en over-DLA, on decale les bm d'un tour
  9913. listeBmFat.shift();
  9914. }
  9915. // Tableau des fatigues et accel futures
  9916. var
  9917. minppv = minParPVsac(fat,listeBmFat[0]),
  9918. table, tbody,
  9919. ligneTour, ligneFat, ligneMin,
  9920. col;
  9921. // ***INIT GLOBALE*** minParPV
  9922. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  9923. if(fat>0 || listeBmFat[0]>0) {
  9924. table = document.createElement('table');
  9925. table.className = 'mh_tdborder';
  9926. table.border = 0;
  9927. table.cellSpacing = 1;
  9928. table.cellPadding = 1;
  9929. table.style.textAlign = "center";
  9930. tbody = document.createElement('tbody');
  9931. table.appendChild(tbody);
  9932. insertPt.appendChild(table);
  9933. ligneTour = appendTr(tbody,'mh_tdtitre');
  9934. ligneTour.style.fontWeight = "bold";
  9935. var td = appendTdText(ligneTour,'Tour :',true);
  9936. td.align = 'left';
  9937. ligneFat = appendTr(tbody,'mh_tdpage');
  9938. td = appendTdText(ligneFat,'Fatigue :',true);
  9939. td.className = 'mh_tdtitre';
  9940. td.align = 'left';
  9941. ligneMin = appendTr(tbody,'mh_tdpage');
  9942. td = appendTdText(ligneMin,'1 PV =',true);
  9943. td.className = 'mh_tdtitre';
  9944. td.align = 'left';
  9945. col=0;
  9946. while(col<9 && (fat>0 || listeBmFat[col])) {
  9947. if(col==0) {
  9948. if(overDLA) {
  9949. var i = document.createElement('i');
  9950. appendText(i,'A activer');
  9951. ligneTour.appendChild(i);
  9952. } else {
  9953. appendTdText(ligneTour,'En cours');
  9954. }
  9955. } else {
  9956. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9957. }
  9958. if(listeBmFat[col]) {
  9959. if(BMfrais || (!overDLA && col==0)) {
  9960. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  9961. appendTdText(ligneMin,minppv[1]+'\'');
  9962. } else {
  9963. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  9964. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  9965. }
  9966. } else {
  9967. appendTdText(ligneFat,fat);
  9968. appendTdText(ligneMin,minppv[0]+'\'');
  9969. }
  9970. col++;
  9971. fat = Math.floor(fat / 1.25);
  9972. minppv = minParPVsac(fat,listeBmFat[col]);
  9973. }
  9974. if(fat>1 || (fat==1 && !overDLA)) {
  9975. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  9976. appendTdText(ligneFat,'-');
  9977. appendTdText(ligneMin,'-');
  9978. }
  9979. col = (overDLA) ?
  9980. Math.max(retourAZero(fatigue)-1,col) :
  9981. Math.max(retourAZero(fatigue),col);
  9982. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9983. appendTdText(ligneFat,'0');
  9984. appendTdText(ligneMin,'30\'');
  9985. if(!BMfrais && bmfatigue) {
  9986. // si les BM n'ont pas ete rafraichis, on signale:
  9987. appendText(
  9988. insertPt,
  9989. '/!\\ Visitez la page des Bonus/Malus '+
  9990. 'pour mettre à jour votre fatigue. /!\\',
  9991. true
  9992. );
  9993. appendBr(insertPt);
  9994. }
  9995. appendBr(insertPt);
  9996. }
  9997. if(pvcourant<=0) {
  9998. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  9999. return;
  10000. }
  10001. if(fatigue>30) {
  10002. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10003. return;
  10004. }
  10005. // Setup lastDLAZone
  10006. if(overDLA) {
  10007. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10008. DLAaccel = new Date( DLAsuiv );
  10009. lastDLA = new Date( DLA );
  10010. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10011. // ***INIT GLOBALE*** pvActuelKastar
  10012. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10013. appendText(
  10014. insertPt,
  10015. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10016. true
  10017. );
  10018. appendBr(insertPt);
  10019. } else {
  10020. DLAaccel = new Date( DLA );
  10021. pvActuelKastar = pvcourant;
  10022. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10023. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10024. } else {
  10025. lastDLA = false;
  10026. }
  10027. }
  10028. appendText(insertPt,'Dernière DLA enregistrée : ');
  10029. lastDLAZone = document.createElement('span');
  10030. lastDLAZone.style.cursor = 'pointer';
  10031. var b = document.createElement('b');
  10032. b.onclick = inputMode;
  10033. lastDLAZone.appendChild(b);
  10034. insertPt.appendChild(lastDLAZone);
  10035. if(lastDLA) {
  10036. appendText(b,DateToString(lastDLA));
  10037. } else {
  10038. appendText(b,'aucune');
  10039. }
  10040. appendBr(insertPt);
  10041. // Setup maxAMZone et cumulZone
  10042. appendText(insertPt,'Accélération maximale possible : ');
  10043. maxAMZone = document.createElement('b');
  10044. insertPt.appendChild(maxAMZone);
  10045. appendBr(insertPt);
  10046. cumulZone = document.createElement('span');
  10047. insertPt.appendChild(cumulZone);
  10048. refreshAccel();
  10049. }
  10050.  
  10051. function refreshAccel() {
  10052. var pvs, pvsmax;
  10053. // Acceleration pour cumul instantane
  10054. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10055. if(lastDLA) {
  10056. pvsmax = Math.min(
  10057. pvActuelKastar-1,
  10058. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10059. );
  10060. maxAMZone.innerHTML = pvsmax+" PV";
  10061. } else {
  10062. pvsmax = pvActuelKastar-1;
  10063. maxAMZone.innerHTML = "inconnue";
  10064. }
  10065. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10066. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10067. cumulZone.innerHTML = '';
  10068. if(pvs<=pvsmax) {
  10069. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10070. appendText(cumulZone,pvs+' PV', true);
  10071. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10072. if(pvs!=1) {
  10073. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10074. -(pvs-1)*60*minParPV;
  10075. appendText(
  10076. cumulZone,
  10077. ' ('+(pvs-1)+' PV dans '+
  10078. Math.floor(gainSec/60)+'min'+
  10079. addZero(gainSec%60)+'s)'
  10080. );
  10081. }
  10082. } else {
  10083. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10084. appendText(
  10085. cumulZone,
  10086. 'Après votre accélération maximale, il vous faudra encore attendre '+
  10087. dureeHM(avantDLA/6e4)+
  10088. ' avant de réactiver.'
  10089. );
  10090. }
  10091. }
  10092.  
  10093.  
  10094. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  10095.  
  10096. function traitementTalents() {
  10097. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  10098. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  10099. removeAllTalents();
  10100. var totalComp = injecteInfosBulles(trCompetence,'competences');
  10101. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  10102. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  10103. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  10104. }
  10105.  
  10106. function injecteInfosBulles(liste,fonction) {
  10107. var totalpc = 0;
  10108. // on parse la liste des talents du type 'fonction'
  10109. for(var i=0 ; i<liste.length ; i++) {
  10110. var
  10111. trTalent=liste[i],
  10112. node=trTalent.cells[1].querySelector('a'),
  10113. nomTalent=epure(trim(node.textContent)),
  10114. indiceTDniveaux=7,
  10115. indiceTDSousCompetence=2,
  10116. sousCompetences=undefined;
  10117. if(fonction=="competences"){
  10118. // un TD en plus pour des information complementaire liees a la comp
  10119. indiceTDniveaux++;
  10120. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  10121. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  10122. for (var j=0; j < sousCompetences.length; j++) {
  10123. sousCompetences[j] = sousCompetences[j].epure().trim();
  10124. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  10125. }
  10126. }
  10127. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  10128. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  10129. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  10130. totalpc += niveauxMaitrisesTalentArray[1];
  10131.  
  10132. // stockage des niveaux inferieurs du talent si presents
  10133. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  10134. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  10135. totalpc+=niveauxMaitrisesTalentArray[j+1];
  10136. }
  10137. }
  10138. return totalpc;
  10139. }
  10140.  
  10141. function setInfos(node,nom,fonction,niveau) {
  10142. node.nom = nom;
  10143. node.fonction = fonction;
  10144. node.niveau = niveau;
  10145. node.onmouseover = setBulle;
  10146. node.onmouseout = cacherBulle;
  10147. }
  10148.  
  10149. var arrayModifAnatroll = {
  10150. 'Glue':'Glu',
  10151. 'PuM':'PuiM',
  10152. 'HE':'Hurlement',
  10153. //'Insultes':'Insu',
  10154. 'Pistage':'Pist',
  10155. 'PuC':'Planter'
  10156. }
  10157.  
  10158. function setTalent(nom,pc,niveau,sousCompetences) {
  10159. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  10160. // (et pas les % dont osf) ne serait pas plus rentable
  10161. var nomEnBase = arrayTalents[epure(nom)];
  10162. if(!nomEnBase) { return; }
  10163. if(!niveau) { niveau = 1; }
  10164. switch(nomEnBase) {
  10165. case 'Insultes':
  10166. urlAnatrolliseur += 'Insu'+niveau+'|';
  10167. case 'IdT':
  10168. nomEnBase += niveau;
  10169. break;
  10170. case 'Golemo':
  10171. case 'Piege':
  10172. for (var i=0 ; i < sousCompetences.length ; i++) {
  10173. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  10174. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  10175. }
  10176. break;
  10177. case 'AP':
  10178. case 'Baroufle':
  10179. case 'CdB':
  10180. case 'CdM':
  10181. case 'Parer':
  10182. case 'Retraite':
  10183. case 'RB':
  10184. case 'SInterposer':
  10185. nomEnBase += niveau;
  10186. default:
  10187. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  10188. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  10189. }
  10190. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  10191. }
  10192.  
  10193. function creerBulleVide() {
  10194. var table = document.createElement('table');
  10195. table.id = 'bulle';
  10196. table.className = 'mh_tdborder';
  10197. table.width = 300;
  10198. table.border = 0;
  10199. table.cellPadding = 5;
  10200. table.cellSpacing = 1;
  10201. table.style =
  10202. 'position:absolute;'
  10203. +'visibility:hidden;'
  10204. +'z-index:800;'
  10205. +'height:auto;';
  10206. var tr = appendTr(table,'mh_tdtitre');
  10207. appendTdText(tr,'Titre');
  10208. tr = appendTr(table,'mh_tdpage');
  10209. appendTdText(tr,'Contenu');
  10210. var aList = document.getElementsByTagName('a');
  10211. aList[aList.length-1].parentNode.appendChild(table);
  10212. }
  10213.  
  10214. function cacherBulle() {
  10215. if(bulleStyle)
  10216. bulleStyle.visibility = 'hidden';
  10217. }
  10218.  
  10219. function setBulle(evt) {
  10220. var nom = this.nom;
  10221. var fonction = this.fonction;
  10222. var niveau = parseInt(this.niveau);
  10223. var str='';
  10224. if(fonction=='competences'){
  10225. str=competences(nom,niveau);
  10226. } else if(fonction=='sortileges') {
  10227. str=sortileges(nom,true);
  10228. }
  10229. if(str=='') return;
  10230. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  10231. var xfenetre, yfenetre, xpage, ypage, element = null;
  10232. var offset = 15;
  10233. var bulleWidth = 300;
  10234. if(!hauteur) hauteur = 50;
  10235. element = document.getElementById('bulle');
  10236. xfenetre = evt.clientX;
  10237. yfenetre = evt.clientY;
  10238. xpage = xfenetre;
  10239. ypage = yfenetre;
  10240. if(evt.pageX) xpage = evt.pageX;
  10241. if(evt.pageY) ypage = evt.pageY;
  10242. if(element) {
  10243. bulleStyle = element.style;
  10244. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  10245. element.childNodes[1].firstChild.innerHTML = str;
  10246. }
  10247. if(bulleStyle) {
  10248. if(xfenetre>bulleWidth+offset)
  10249. xpage -= bulleWidth+offset;
  10250. else
  10251. xpage += offset;
  10252. if(yfenetre>hauteur+offset)
  10253. ypage -= hauteur + offset;
  10254. bulleStyle.width = bulleWidth;
  10255. bulleStyle.left = xpage + 'px';
  10256. bulleStyle.top = ypage + 'px';
  10257. bulleStyle.visibility = 'visible';
  10258. }
  10259. }
  10260.  
  10261.  
  10262. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  10263.  
  10264. function competences(comp,niveau) {
  10265. var texte = '';
  10266. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  10267. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  10268. if(minParPV>1) texte += 's';
  10269. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  10270. }
  10271. else if(comp.indexOf('Attaque Precise')!=-1) {
  10272. var pc, lastmax=0, espatt=0;
  10273. var notMaxedOut = false;
  10274. for(var i=niveau ; i>0 ; i--) {
  10275. pc = getTalent(comp,i);
  10276. if(lastmax!=0 && pc<=lastmax) continue;
  10277. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  10278. attbp+attbm;
  10279. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10280. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  10281. ' => <b>'+jetatt+'</b><br/>';
  10282. espatt += (pc-lastmax)*jetatt;
  10283. lastmax = pc;
  10284. if(i<niveau) notMaxedOut = true;
  10285. }
  10286. if(notMaxedOut) {
  10287. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  10288. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  10289. }
  10290. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  10291. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10292. }
  10293. else if(comp.indexOf('Balayage')!=-1)
  10294. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  10295. +' => <b>'+attmoy+'</b><br/>'
  10296. +'Effet : <b>Met à terre l\'adversaire</b>';
  10297. else if(comp.indexOf('Bidouille')!=-1)
  10298. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  10299. +'de votre inventaire avec le texte de votre choix.';
  10300. else if(comp.indexOf('Baroufle')!=-1){
  10301. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  10302. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  10303. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  10304. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  10305. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  10306. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  10307. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  10308. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  10309. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  10310. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  10311. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  10312. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  10313. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  10314. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  10315. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  10316. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  10317. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  10318. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  10319. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  10320. '</tbody></table>';
  10321. }
  10322. else if(comp.indexOf('Botte Secrete')!=-1){
  10323. texte = 'Attaque : <b>'
  10324. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10325. +' => <b>'
  10326. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  10327. +'</b><br/>Dégâts : <b>'
  10328. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  10329. +' => <b>'
  10330. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  10331. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  10332. +'</b>';
  10333. }
  10334. else if(comp.indexOf('Camouflage')!=-1) {
  10335. var camou = getTalent('Camouflage');
  10336. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  10337. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  10338. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  10339. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  10340. }
  10341. else if(comp.indexOf('Charger')!=-1) {
  10342. if(pvcourant<=0)
  10343. return '<i>On ne peut charger personne quand on est mort !</i>';
  10344. var portee = Math.min(
  10345. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  10346. vuetotale);
  10347. if(portee<1)
  10348. return '<b>Impossible de charger</b>';
  10349. else {
  10350. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10351. +' => <b>'+attmoy+'</b><br/>'
  10352. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10353. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  10354. +'<br/>Portée : <b>'+portee+'</b> case';
  10355. if(portee>1) texte += 's';
  10356. }
  10357. }
  10358. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  10359. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  10360. if(vuetotale>1) texte += 's';
  10361. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10362. if(vuetotale>2) texte += 's';
  10363. }
  10364. else if(comp.indexOf('Piege')!=-1) {
  10365. if(comp.indexOf('Glue')!=-1)
  10366. texte = 'Et si vous colliez vos adversaires au sol ?';
  10367. if(comp.indexOf('Feu')!=-1) {
  10368. if(texte){
  10369. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  10370. }
  10371. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  10372. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  10373. }
  10374. }
  10375. else if(comp.indexOf('Contre-Attaquer')!=-1){
  10376. texte = 'Attaque : <b>'
  10377. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10378. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10379. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10380. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10381. }
  10382. else if(comp.indexOf('Coup de Butoir')!=-1) {
  10383. var pc, lastmax=0, espdeg=0;
  10384. var notMaxedOut = false;
  10385. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10386. +' => <b>'+attmoy+'</b>';
  10387. for(var i=niveau ; i>0 ; i--) {
  10388. pc = getTalent(comp,i);
  10389. if(lastmax!=0 && pc<=lastmax) continue;
  10390. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  10391. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10392. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  10393. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  10394. espdeg += (pc-lastmax)*jetdeg;
  10395. lastmax = pc;
  10396. if(i<niveau) notMaxedOut = true;
  10397. }
  10398. if(notMaxedOut) {
  10399. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  10400. Math.floor(10*espdeg/lastmax)/10+'/'+
  10401. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  10402. }
  10403. }
  10404. else if(comp.indexOf('Course')!=-1)
  10405. texte = 'Déplacement gratuit : <b>'
  10406. +Math.floor(getTalent('Course')/2)
  10407. +' %</b> de chance';
  10408. else if(comp.indexOf('Deplacement Eclair')!=-1)
  10409. texte = 'Permet d\'économiser <b>1</b> PA '
  10410. +'par rapport au déplacement classique';
  10411. else if(comp.indexOf('Dressage')!=-1)
  10412. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  10413. +'ou un gnu sauvage.';
  10414. else if(comp.indexOf('Ecriture Magique')!=-1)
  10415. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  10416. +'la formule nécessite de réunir les composants de cette formule, '
  10417. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  10418. +'un champignon adéquat pour confectionner l\'encre.';
  10419. else if(comp.indexOf('Frenesie')!=-1) {
  10420. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10421. +' => <b>'+attmoy+'</b><br/>'
  10422. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10423. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10424. }
  10425. else if(comp.indexOf('Golem')!=-1)
  10426. texte = 'Animez votre golem en assemblant divers matériaux '
  10427. +'autour d\'un cerveau minéral.'
  10428. else if(comp.indexOf('Grattage')!=-1) {
  10429. texte = 'Permet de confectionner un Parchemin Vierge '
  10430. +'à partir de composants et de Gigots de Gob\'.';
  10431. }
  10432. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  10433. texte = 'Fait fuir un monstre si tout se passe bien.'
  10434. +'<br/>Lui donne de gros bonus sinon...';
  10435. else if(comp.indexOf('Identification des Champignons')!=-1) {
  10436. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10437. if(vuetotale>2) texte += 's';
  10438. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  10439. if(vuetotale>4) texte += 's';
  10440. }
  10441. else if(comp.indexOf('Insultes')!=-1)
  10442. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  10443. else if(comp.indexOf('interposer')!=-1)
  10444. texte = 'Jet de réflexe : <b>'
  10445. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  10446. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  10447. else if(comp.indexOf('Lancer de Potions') != -1)
  10448. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  10449. else if(comp.indexOf('Marquage')!=-1)
  10450. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  10451. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  10452. +'se trouver dans la même caverne que le monstre pour le marquer.';
  10453. else if(comp.indexOf('Melange Magique')!=-1)
  10454. texte = 'Cette Compétence permet de combiner deux Potions pour '
  10455. +'en réaliser une nouvelle dont l\'effet est la somme '
  10456. +'des effets des potions initiales.';
  10457. else if(comp.indexOf('Miner')!=-1)
  10458. texte = 'Portée horizontale (officieuse) : <b>'
  10459. +2*vuetotale+'</b> cases<br/>'
  10460. +'Portée verticale (officieuse) : <b>'
  10461. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10462. else if(comp.indexOf('Necromancie')!=-1)
  10463. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  10464. +'de faire "revivre" ce monstre.';
  10465. else if(comp.indexOf('Painthure de Guerre')!=-1)
  10466. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  10467. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  10468. +'pour s\'inspirer, et laissez parler votre créativité.'
  10469. else if(comp.indexOf('Parer')!=-1)
  10470. texte = 'Jet de parade : <b>'
  10471. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  10472. +' => <b>'
  10473. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10474. +'</b><hr><i>Equivalent esquive : <b>'
  10475. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  10476. +' => <b>'
  10477. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  10478. +'</b></i>';
  10479. else if(comp.indexOf('Pistage')!=-1)
  10480. texte = 'Portée horizontale : <b>'
  10481. +2*vuetotale+'</b> cases<br/>'
  10482. +'Portée verticale : <b>'
  10483. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10484. else if(comp.indexOf('Planter un Champignon')!=-1)
  10485. texte = 'Planter un Champignon est une compétence qui vous permet de '
  10486. +'créer des colonies d\'une variété donnée de champignon à partir de '
  10487. +'quelques exemplaires préalablement enterrés.';
  10488. else if(comp.indexOf('Regeneration Accrue')!=-1)
  10489. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  10490. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  10491. else if(comp.indexOf('Reparation')!=-1)
  10492. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  10493. +'et réparez vous-même votre matériel !';
  10494. else if(comp.indexOf('Retraite')!=-1)
  10495. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  10496. +'préférable de préparer un repli stratégique pour déconcerter '
  10497. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  10498. +'Quelle intelligence démoniaque.';
  10499. else if(comp.indexOf('Rotobaffe')!=-1) {
  10500. var Datt = att, vattbm = attbp+attbm;
  10501. var Ddeg = deg, vdegbm = degbp+degbm;
  10502. for(var i=1 ; i<niveau+2 ; i++) {
  10503. texte += '<b>Attaque n°'+i+' :</b><br/>'
  10504. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  10505. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  10506. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  10507. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  10508. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  10509. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  10510. if(i<niveau+1) texte += '<hr>';
  10511. }
  10512. }
  10513. else if(comp.indexOf('Shamaner')!=-1)
  10514. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  10515. +'des monstres en utilisant des champignons (de 1 à 3).';
  10516. else if(comp.indexOf('Tailler')!=-1){
  10517. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  10518. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  10519. }
  10520. return texte;
  10521. }
  10522.  
  10523. function decumul_buff(nom,str,buff) {
  10524. // Decumul des sorts de buff
  10525. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  10526. var dec = buff, total = buff, i=1;
  10527. while(i<6) {
  10528. i++;
  10529. dec = Math.floor(coefDecumul(i)*buff);
  10530. if(dec<=1 || i==6) break;
  10531. total += dec;
  10532. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  10533. +str+' +'+dec+' (+'+total+')</i>';
  10534. }
  10535. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  10536. return ret;
  10537. }
  10538.  
  10539.  
  10540. function sortileges(sort,mainCall,pcA,pcD) {
  10541. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  10542. var texte = '';
  10543. if (mainCall) {
  10544. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  10545. pcA = (atttourP+atttourM);
  10546. pcD = (degtourP+degtourM);
  10547. }
  10548. if (sort.indexOf('Analyse Anatomique') != -1) {
  10549. texte = 'Portée horizontale : <b>'
  10550. + Math.floor(vuetotale / 2) + '</b> case';
  10551. if (vuetotale > 3){ texte += 's'; }
  10552. texte += '<br/>Portée verticale : <b>'
  10553. + Math.floor((vuetotale+1)/4)+'</b> case';
  10554. if (vuetotale > 7){ texte += 's'; }
  10555. }
  10556. else if (sort.indexOf('Armure Etheree') != -1){
  10557. texte = decumul_buff('AE', 'Armure magique', reg);
  10558. }
  10559. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  10560. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  10561. }
  10562. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  10563. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  10564. }
  10565. else if (sort.indexOf('Augmentation des Degats') != -1){
  10566. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  10567. }
  10568. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  10569. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  10570. }
  10571. else if(sort.indexOf('Bulle Magique')!=-1){
  10572. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  10573. }
  10574. else if(sort.indexOf('Explosion')!=-1){
  10575. texte = 'Dégâts : <b>'
  10576. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  10577. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  10578. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  10579. }
  10580. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  10581. if(pvcourant<=0)
  10582. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  10583. texte = 'Portée horizontale : <b>'
  10584. +Math.min(1,vuetotale)+'</b> case<br/>'
  10585. +'Dégâts physiques : <b>-'
  10586. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  10587. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  10588. +'Dégâts magiques : <b>-'
  10589. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  10590. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  10591. }
  10592. else if(sort.indexOf('Flash Aveuglant')!=-1){
  10593. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  10594. }
  10595. else if(sort.indexOf('Glue')!=-1) {
  10596. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  10597. if(vuetotale>2) texte += 's';
  10598. }
  10599. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  10600. /* Frappe */
  10601. var modD = 0;
  10602. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10603. if(pcA!=0){
  10604. modD = parseInt(att*pcA/100);
  10605. texte += '<i>'+aff(modD)+'D6</i> ';
  10606. }
  10607. texte += aff(attbm)
  10608. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  10609. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  10610. if(pcD!=0) {
  10611. modD = parseInt(Math.floor(deg/2)*pcD/100);
  10612. texte += '<i>'+aff(modD)+'D3</i> ';
  10613. }else
  10614. modD = 0;
  10615. texte += aff(degbm)+' => <b>'
  10616. +(2*(Math.floor(deg/2)+modD)+degbm)
  10617. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  10618. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  10619. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  10620. +')</b>';
  10621. if(!mainCall) return texte;
  10622. /* Venins */
  10623. function addVenin(type,effet,duree) {
  10624. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  10625. +' pendant <b>'+duree+'</b> tour';
  10626. if(duree>1) ret += 's';
  10627. var dred = Math.max(Math.floor(duree/2),1);
  10628. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  10629. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  10630. }
  10631. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  10632. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  10633. effet = Math.floor(1.5*effet);
  10634. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  10635. }
  10636. else if(sort.indexOf('Hypnotisme')!=-1)
  10637. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  10638. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  10639. else if(sort.indexOf('Identification des tresors')!=-1)
  10640. texte = 'Permet de connaitre les caractéristiques et effets précis '
  10641. +'d\'un trésor.';
  10642. else if(sort.indexOf('Invisibilite')!=-1)
  10643. texte = 'Un troll invisible est indétectable même quand on se trouve '
  10644. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  10645. +'fait disparaître l\'invisibilité.';
  10646. else if(sort.indexOf('Levitation')!=-1)
  10647. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  10648. +'Comme les pièges ou les trous par exemple...';
  10649. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  10650. var eps = 1,
  10651. pc = 20;
  10652. var str = 'PréM';
  10653. var newSort;
  10654. var sortAtt = [
  10655. 'Projectile Magique',
  10656. 'Rafale Psychique',
  10657. 'Siphon des Ames',
  10658. 'Vampirisme',
  10659. 'Griffe du Sorcier'
  10660. ];
  10661. if(sort.indexOf('Puissance')!=-1) {
  10662. eps = -1; str='PuM';
  10663. }
  10664. for(var i=1 ; i<4 ; i++) {
  10665. if(texte) { texte += '<hr>'; }
  10666. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  10667. newSort = false;
  10668. for(var j=0 ; j<sortAtt.length ; j++) {
  10669. if(getTalent(sortAtt[j])) {
  10670. if(newSort) { texte += '<br/><br/>'; }
  10671. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  10672. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  10673. newSort = true;
  10674. }
  10675. }
  10676. pc = decumulPumPrem(pc);
  10677. }
  10678. }
  10679. else if(sort.indexOf('Projectile Magique')!=-1) {
  10680. var modD = 0;
  10681. var portee = getPortee__Profil(vuetotale);
  10682. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  10683. if(pcA!=0) {
  10684. modD = parseInt(vue*pcA/100);
  10685. texte += '<i>'+aff(modD)+'D6</i> ';
  10686. }
  10687. texte += aff(attbm)
  10688. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  10689. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  10690. if(pcD!=0) {
  10691. modD = parseInt(Math.floor(vue/2)+pcD);
  10692. texte += '<i>'+aff(modD)+'D3</i> ';
  10693. }else
  10694. modD = 0;
  10695. texte += aff(degbm)
  10696. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  10697. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  10698. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  10699. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  10700. if(!mainCall) return texte;
  10701. texte += '<br/>Portée : <b>'+portee+'</b> case';
  10702. if(portee>1) texte += 's';
  10703. }
  10704. else if(sort.indexOf('Projection')!=-1) {
  10705. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  10706. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  10707. +'Si le jet de résistance de la victime est réussi:<br/>'
  10708. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  10709. }
  10710. else if(sort.indexOf('Rafale Psychique')!=-1) {
  10711. var modD = 0;
  10712. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  10713. if(pcD!=0) {
  10714. modD = parseInt(deg*pcD/100);
  10715. texte += '<i>'+aff(modD)+'D3</i> ';
  10716. }
  10717. texte += aff(degbm)
  10718. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  10719. if(!mainCall) return texte;
  10720. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  10721. }
  10722. else if(sort.indexOf('Sacrifice')!=-1) {
  10723. if(pvcourant<=0)
  10724. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  10725.  
  10726. function perteSacro(sac) {
  10727. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  10728. }
  10729.  
  10730. var sac = Math.floor((pvcourant-1)/2);
  10731. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10732. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  10733. /* Sacros max et optimal sans malus (propale R') */
  10734. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10735. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  10736. if(sac>0)
  10737. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  10738. else
  10739. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  10740. /*if(sac>3) {
  10741. sac = 5*Math.floor((sac+1)/5)-1;
  10742. texte += '<br/>Soin optimal sans malus de temps : <b>'
  10743. +sac+'</b> PV'+perteSacro(sac);
  10744. }*/
  10745. }
  10746. else if(sort.indexOf('Siphon')!=-1) {
  10747. var modD = 0;
  10748. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10749. if(pcA!=0) {
  10750. modD = parseInt(att*pcA/100);
  10751. texte += '<i>'+aff(modD)+'D6</i> ';
  10752. }
  10753. texte += aff(attbm)
  10754. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  10755. +'Dégâts : <b>'+reg+'</b> D3 ';
  10756. if(pcD!=0) {
  10757. modD = parseInt(reg*pcD/100);
  10758. texte += '<i>'+aff(modD)+'D3</i> ';
  10759. }else
  10760. modD = 0;
  10761. texte += aff(degbm)
  10762. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  10763. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  10764. if(!mainCall) return texte;
  10765. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  10766. }
  10767. else if(sort.indexOf('Telekinesie')!=-1) {
  10768. texte = 'Portée horizontale :';
  10769. var vt = Math.floor(vuetotale/2)+2;
  10770. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  10771. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  10772. for(var i=0 ; i<5 ; i++) {
  10773. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  10774. if(vt>1) texte += 's';
  10775. vt=Math.max(0,vt-1);
  10776. }
  10777. }
  10778. else if(sort.indexOf('Teleportation')!=-1) {
  10779. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  10780. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  10781. var pmh = (20+vue+portee);
  10782. var pmv = 3+Math.floor(portee/3);
  10783. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  10784. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  10785. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  10786. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  10787. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  10788. }
  10789. else if(sort.indexOf('Vampirisme')!=-1) {
  10790. var modD = 0;
  10791. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  10792. if(pcA!=0) {
  10793. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  10794. texte += '<i>'+aff(modD)+'D6</i> ';
  10795. }
  10796. texte += aff(attbm)
  10797. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  10798. +'Dégâts : <b>'+deg+'</b> D3 ';
  10799. if(pcD!=0) {
  10800. modD = parseInt(deg*pcD/100);
  10801. texte += '<i>'+aff(modD)+'D3</i> ';
  10802. }else
  10803. modD = 0;
  10804. texte += aff(degbm)
  10805. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  10806. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  10807. }
  10808. else if(sort.indexOf('Vision Accrue')!=-1)
  10809. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  10810. else if(sort.indexOf('Vision lointaine')!=-1)
  10811. texte = 'En ciblant une zone située n\'importe où dans le '
  10812. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  10813. else if(sort.indexOf('Voir le Cache')!=-1)
  10814. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  10815. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  10816. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  10817. +getPortee__Profil(vuetotale)+'</b> cases';
  10818. else if(sort.indexOf('Vue Troublee')!=-1)
  10819. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10820. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  10821. return texte;
  10822. }
  10823.  
  10824.  
  10825. /*---------------------------------- Main ------------------------------------*/
  10826.  
  10827. function do_profil2()
  10828. {
  10829. try {
  10830. start_script(31);
  10831.  
  10832. extractionDonnees();
  10833. setInfosCaracteristiques();
  10834. setInfoDescription();
  10835. setInfosEtatLieux();
  10836. setInfosEtatPV();
  10837. setInfosExp();
  10838.  
  10839. creerBulleVide();
  10840. traitementTalents();
  10841. setLienAnatrolliseur();
  10842.  
  10843. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  10844. if(race=='Kastar'){ setAccel(); }
  10845. saveProfil();
  10846. displayScriptTime();
  10847. } catch(e) {
  10848. avertissement("[MZ] Une erreur s'est produite.");
  10849. window.console.error("[MZ] Erreur générale Profil",e);
  10850. }
  10851. }
  10852.  
  10853. /*********************************************************************************
  10854. * This file is part of Mountyzilla. *
  10855. * *
  10856. * Mountyzilla is free software; you can redistribute it and/or modify *
  10857. * it under the terms of the GNU General Public License as published by *
  10858. * the Free Software Foundation; either version 2 of the License, or *
  10859. * (at your option) any later version. *
  10860. * *
  10861. * Mountyzilla is distributed in the hope that it will be useful, *
  10862. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10863. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10864. * GNU General Public License for more details. *
  10865. * *
  10866. * You should have received a copy of the GNU General Public License *
  10867. * along with Mountyzilla; if not, write to the Free Software *
  10868. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10869. *********************************************************************************/
  10870.  
  10871. // x~x tancompo
  10872.  
  10873. var popup;
  10874.  
  10875. function initPopupTancompo() {
  10876. popup = document.createElement('div');
  10877. popup.setAttribute('id', 'popup');
  10878. popup.setAttribute('class', 'mh_textbox');
  10879. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  10880. + 'display: inline; z-index: 3; max-width: 400px;');
  10881. document.body.appendChild(popup);
  10882. }
  10883.  
  10884. // roule 16/03/2016, existe déjà ailleurs
  10885. // function showPopup(evt) {
  10886. // var texte = this.getAttribute("texteinfo");
  10887. // popup.innerHTML = texte;
  10888. // popup.style.left = evt.pageX + 15 + 'px';
  10889. // popup.style.top = evt.pageY + 'px';
  10890. // popup.style.visibility = "visible";
  10891. // }
  10892.  
  10893. // roule 16/03/2016, existe déjà ailleurs
  10894. // function hidePopup() {
  10895. // popup.style.visibility = 'hidden';
  10896. // }
  10897.  
  10898. function createPopupImage(url, text)
  10899. {
  10900. var img = document.createElement('img');
  10901. img.setAttribute('src',url);
  10902. img.setAttribute('align','ABSMIDDLE');
  10903. img.setAttribute("texteinfo",text);
  10904. img.addEventListener("mouseover", showPopup,true);
  10905. img.addEventListener("mouseout", hidePopup,true);
  10906. return img;
  10907. }
  10908.  
  10909. function formateTexte(texte)
  10910. {
  10911. texte = texte.replace(/\n/g,"<br/>");
  10912. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  10913. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  10914. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  10915. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  10916. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  10917. return texte;
  10918. }
  10919.  
  10920. function arrondi(x) {
  10921. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  10922. }
  10923.  
  10924. function traiteMinerai() {
  10925. if (currentURL.indexOf("as_type=Divers")==-1) return;
  10926. try {
  10927. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  10928. +" and contains(./tr/th/text(),'Minerai')]",
  10929. document, null, 9, null).singleNodeValue;
  10930. node = node.nextSibling.nextSibling;
  10931. }
  10932. catch(e) {return;}
  10933. var trlist = document.evaluate('./tr', node, null, 7, null);
  10934. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  10935. var node = trlist.snapshotItem(i);
  10936. var nature = node.childNodes[5].textContent;
  10937. var caracs = node.childNodes[7].textContent;
  10938. var taille = caracs.match(/\d+/)[0];
  10939. var coef = 1;
  10940. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  10941. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  10942. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  10943. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  10944. if (nature.indexOf('Mithril')!=-1) {
  10945. coef = 0.2*coef;
  10946. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  10947. }
  10948. else {
  10949. coef = 0.75*coef+1.25;
  10950. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  10951. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  10952. }
  10953. }
  10954. }
  10955.  
  10956. function treateComposants() {
  10957. if (currentURL.indexOf("as_type=Compo")==-1) return;
  10958. //On récupère les composants
  10959. var nodes = document.evaluate(
  10960. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  10961. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  10962. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  10963. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10964. if (nodes.snapshotLength == 0) {
  10965. // window.alert('treateComposants DOWN');
  10966. return;
  10967. }
  10968. window.alert(nodes.snapshotLength);
  10969.  
  10970. var texte = "";
  10971. for (var i = 0; i < nodes.snapshotLength; i++) {
  10972. var n1 = nodes.snapshotItem(i).childNodes[1];
  10973. var n3 = nodes.snapshotItem(i).childNodes[3];
  10974. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  10975. var prix = n3.childNodes[0].nodeValue;
  10976. if (!prix)
  10977. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  10978. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  10979. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  10980. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  10981. + prix.replace(/\n/g, '') + "\n";
  10982. }
  10983.  
  10984. var c = document.evaluate("//div[@class = 'titre2']/text()",
  10985. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10986. var id_taniere = c.snapshotItem(0).nodeValue;
  10987. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  10988.  
  10989. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  10990. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  10991. if (form)
  10992. {
  10993. if(document.getElementsByTagName('form').length>0)
  10994. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  10995. else
  10996. {
  10997. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  10998. insertBefore(thisP, form);
  10999. }
  11000. }
  11001. }
  11002.  
  11003. function treateAllComposants() {
  11004. if(currentURL.indexOf("as_type=Compo")==-1) return;
  11005. //On récupère les composants
  11006. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  11007. document, null, 0, null ).numberValue;
  11008. var c = (categ == 0 ? 3 : 4);
  11009. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  11010. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  11011. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  11012. + "td["+c+"]/text()[1] = '\240-\240' "
  11013. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  11014. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  11015. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  11016. + "and td[1]/img/@alt = 'Identifié']",
  11017. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11018. if (nodes.snapshotLength == 0) {
  11019. // window.alert('treateAllComposants DOWN');
  11020. return;
  11021. }
  11022.  
  11023. var texte = "";
  11024. for (var i = 0; i < nodes.snapshotLength; i++) {
  11025. var n1 = nodes.snapshotItem(i).childNodes[1];
  11026. var n3 = nodes.snapshotItem(i).childNodes[3];
  11027. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  11028. var prix = n3.childNodes[0].nodeValue;
  11029. if (!prix)
  11030. {
  11031. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  11032. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  11033. }
  11034. else
  11035. {
  11036. prix= prix.replace(/[\240 ]/g, "");
  11037. if(prix=="-")
  11038. prix=null;
  11039. }
  11040. if(prix)
  11041. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  11042. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  11043. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  11044. + prix.replace(/\n/g, '') + "\n";
  11045. else
  11046. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  11047. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  11048. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  11049. }
  11050.  
  11051. var c = document.evaluate("//div[@class = 'titre2']/text()",
  11052. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11053. var id_taniere = c.snapshotItem(0).nodeValue;
  11054. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  11055.  
  11056. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  11057. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  11058. if (form)
  11059. {
  11060. if(document.getElementsByTagName('form').length>0)
  11061. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  11062. else
  11063. {
  11064. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  11065. insertBefore(thisP, form);
  11066. }
  11067. }
  11068. }
  11069.  
  11070. function treateEM()
  11071. {
  11072. if(currentURL.indexOf("as_type=Compo")==-1)
  11073. return false;
  11074. var urlImg = URL_MZimg + 'Competences/ecritureMagique.png';
  11075. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  11076. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11077. if (nodes.snapshotLength == 0)
  11078. return false;
  11079. for (var i = 0; i < nodes.snapshotLength; i++) {
  11080. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  11081. var link = desc[2].firstChild ;
  11082. var nomCompoTotal = desc[2].textContent ;
  11083. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  11084. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  11085. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  11086. var locqual = desc[3].textContent ;
  11087. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  11088. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  11089. if(isEM(nomMonstre).length>0)
  11090. {
  11091. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  11092. if(infos.length>0)
  11093. {
  11094. var shortDescr = "Variable";
  11095. var bold = 0;
  11096. if(infos != "Composant variable")
  11097. {
  11098. shortDescr = infos.substring(0,infos.indexOf(" "));
  11099. if(parseInt(shortDescr)>=0)
  11100. bold=1;
  11101. }
  11102. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  11103. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  11104. }
  11105. }
  11106. }
  11107. }
  11108.  
  11109. function treateChampi() {
  11110. if (currentURL.indexOf('as_type=Champi')==-1)
  11111. return false;
  11112. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  11113. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11114. if (nodes.snapshotLength == 0)
  11115. return false;
  11116.  
  11117. for (var i = 0; i < nodes.snapshotLength; i++) {
  11118. var node = nodes.snapshotItem(i);
  11119. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  11120. if (moisChampi[nomChampi])
  11121. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  11122. }
  11123. }
  11124.  
  11125. function treateEnchant()
  11126. {
  11127. if(currentURL.indexOf("as_type=Compo")==-1)
  11128. return false;
  11129. try
  11130. {
  11131. if(!listeMonstreEnchantement)
  11132. computeCompoEnchantement();
  11133. var nodes = document.evaluate(
  11134. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  11135. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  11136. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11137. if (nodes.snapshotLength == 0)
  11138. return false;
  11139. var urlImg = URL_MZimg + "enchant.png";
  11140. for (var i = 0; i < nodes.snapshotLength; i++) {
  11141. var link = nodes.snapshotItem(i);
  11142. var nomCompoTotal = link.firstChild.nodeValue;
  11143. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  11144. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  11145. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  11146. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  11147. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  11148. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  11149. if(isEnchant(nomMonstre).length>0)
  11150. {
  11151. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  11152. if(infos.length>0)
  11153. {
  11154. link.parentNode.appendChild(createImage(urlImg,infos));
  11155. }
  11156. }
  11157. }
  11158. }
  11159. catch(e)
  11160. {
  11161. window.alert(e);
  11162. }
  11163. }
  11164.  
  11165. function treateEquipEnchant()
  11166. {
  11167. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  11168. return false;
  11169. initPopupTancompo();
  11170. computeEnchantementEquipement(createPopupImage,formateTexte);
  11171. }
  11172.  
  11173. function do_tancompo()
  11174. {
  11175. start_script();
  11176.  
  11177. treateAllComposants();
  11178. treateComposants();
  11179. traiteMinerai();
  11180. if (MY_getValue('NOINFOEM')!='true') {
  11181. treateChampi();
  11182. treateEM();
  11183. }
  11184. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  11185. treateEnchant();
  11186. treateEquipEnchant();
  11187. }
  11188.  
  11189. displayScriptTime();
  11190. }
  11191.  
  11192.  
  11193.  
  11194.  
  11195.  
  11196. /*******************************************************************************
  11197. * This file is part of Mountyzilla. *
  11198. * *
  11199. * Mountyzilla is free software; you can redistribute it and/or modify *
  11200. * it under the terms of the GNU General Public License as published by *
  11201. * the Free Software Foundation; either version 2 of the License, or *
  11202. * (at your option) any later version. *
  11203. * *
  11204. * Mountyzilla is distributed in the hope that it will be useful, *
  11205. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11206. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11207. * GNU General Public License for more details. *
  11208. * *
  11209. * You should have received a copy of the GNU General Public License *
  11210. * along with Mountyzilla; if not, write to the Free Software *
  11211. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11212. *******************************************************************************/
  11213.  
  11214. // x~x script_principal
  11215.  
  11216. function isPage(url) {
  11217. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11218. }
  11219.  
  11220. // x~x md5.js
  11221. /*
  11222. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11223. * Digest Algorithm, as defined in RFC 1321.
  11224. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11225. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11226. * Distributed under the BSD License
  11227. * See http://pajhome.org.uk/crypt/md5 for more info.
  11228. */
  11229.  
  11230. /*
  11231. * Configurable variables. You may need to tweak these to be compatible with
  11232. * the server-side, but the defaults work in most cases.
  11233. */
  11234. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11235. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11236. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11237.  
  11238. /*
  11239. * These are the functions you'll usually want to call
  11240. * They take string arguments and return either hex or base-64 encoded strings
  11241. */
  11242. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11243. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11244. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11245. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11246. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11247. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11248.  
  11249. /*
  11250. * Perform a simple self-test to see if the VM is working
  11251. */
  11252. function md5_vm_test()
  11253. {
  11254. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11255. }
  11256.  
  11257. /*
  11258. * Calculate the MD5 of an array of little-endian words, and a bit length
  11259. */
  11260. function core_md5(x, len)
  11261. {
  11262. /* append padding */
  11263. x[len >> 5] |= 0x80 << ((len) % 32);
  11264. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11265.  
  11266. var a = 1732584193;
  11267. var b = -271733879;
  11268. var c = -1732584194;
  11269. var d = 271733878;
  11270.  
  11271. for(var i = 0; i < x.length; i += 16)
  11272. {
  11273. var olda = a;
  11274. var oldb = b;
  11275. var oldc = c;
  11276. var oldd = d;
  11277.  
  11278. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11279. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11280. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11281. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11282. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11283. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11284. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11285. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11286. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11287. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11288. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11289. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11290. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11291. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11292. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11293. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11294.  
  11295. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11296. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11297. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11298. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11299. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11300. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11301. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11302. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11303. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11304. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11305. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11306. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11307. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11308. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11309. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11310. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11311.  
  11312. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11313. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11314. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11315. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11316. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11317. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11318. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11319. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11320. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11321. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11322. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11323. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11324. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11325. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11326. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11327. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11328.  
  11329. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11330. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11331. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11332. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11333. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11334. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11335. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11336. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11337. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11338. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11339. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11340. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11341. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11342. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11343. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11344. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11345.  
  11346. a = safe_add(a, olda);
  11347. b = safe_add(b, oldb);
  11348. c = safe_add(c, oldc);
  11349. d = safe_add(d, oldd);
  11350. }
  11351. return Array(a, b, c, d);
  11352.  
  11353. }
  11354.  
  11355. /*
  11356. * These functions implement the four basic operations the algorithm uses.
  11357. */
  11358. function md5_cmn(q, a, b, x, s, t)
  11359. {
  11360. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11361. }
  11362. function md5_ff(a, b, c, d, x, s, t)
  11363. {
  11364. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11365. }
  11366. function md5_gg(a, b, c, d, x, s, t)
  11367. {
  11368. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11369. }
  11370. function md5_hh(a, b, c, d, x, s, t)
  11371. {
  11372. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11373. }
  11374. function md5_ii(a, b, c, d, x, s, t)
  11375. {
  11376. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11377. }
  11378.  
  11379. /*
  11380. * Calculate the HMAC-MD5, of a key and some data
  11381. */
  11382. function core_hmac_md5(key, data)
  11383. {
  11384. var bkey = str2binl(key);
  11385. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11386.  
  11387. var ipad = Array(16), opad = Array(16);
  11388. for(var i = 0; i < 16; i++)
  11389. {
  11390. ipad[i] = bkey[i] ^ 0x36363636;
  11391. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11392. }
  11393.  
  11394. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11395. return core_md5(opad.concat(hash), 512 + 128);
  11396. }
  11397.  
  11398. /*
  11399. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11400. * to work around bugs in some JS interpreters.
  11401. */
  11402. function safe_add(x, y)
  11403. {
  11404. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11405. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11406. return (msw << 16) | (lsw & 0xFFFF);
  11407. }
  11408.  
  11409. /*
  11410. * Bitwise rotate a 32-bit number to the left.
  11411. */
  11412. function bit_rol(num, cnt)
  11413. {
  11414. return (num << cnt) | (num >>> (32 - cnt));
  11415. }
  11416.  
  11417. /*
  11418. * Convert a string to an array of little-endian words
  11419. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11420. */
  11421. function str2binl(str)
  11422. {
  11423. var bin = Array();
  11424. var mask = (1 << chrsz) - 1;
  11425. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11426. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11427. return bin;
  11428. }
  11429.  
  11430. /*
  11431. * Convert an array of little-endian words to a string
  11432. */
  11433. function binl2str(bin)
  11434. {
  11435. var str = "";
  11436. var mask = (1 << chrsz) - 1;
  11437. for(var i = 0; i < bin.length * 32; i += chrsz)
  11438. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11439. return str;
  11440. }
  11441.  
  11442. /*
  11443. * Convert an array of little-endian words to a hex string.
  11444. */
  11445. function binl2hex(binarray)
  11446. {
  11447. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11448. var str = "";
  11449. for(var i = 0; i < binarray.length * 4; i++)
  11450. {
  11451. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11452. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11453. }
  11454. return str;
  11455. }
  11456.  
  11457. /*
  11458. * Convert an array of little-endian words to a base-64 string
  11459. */
  11460. function binl2b64(binarray)
  11461. {
  11462. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11463. var str = "";
  11464. for(var i = 0; i < binarray.length * 4; i += 3)
  11465. {
  11466. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11467. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11468. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11469. for(var j = 0; j < 4; j++)
  11470. {
  11471. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11472. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11473. }
  11474. }
  11475. return str;
  11476. }
  11477.  
  11478. ///////////////////////////////////////////
  11479. // debug cartes capitan Roule 07/12/2016
  11480. ///////////////////////////////////
  11481. // essais : objet
  11482. // .mode : description
  11483. // .essais : tableau d'objets essai
  11484. // .mode : description
  11485. // .essais : tableau de cartes
  11486. // .noCarte : id de la carte
  11487. // .essais : tableau d'essais, [x, y, n, nb]
  11488. function AfficheEssais(essais, sMode) {
  11489. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11490. if (!eBigDiv) {
  11491. var insertPoint = document.getElementById('footer1');
  11492. eBigDiv = document.createElement('table');
  11493. eBigDiv.id = 'ListeEssaiCapitan';
  11494. insertBefore(insertPoint, document.createElement('p'));
  11495. insertTitle(insertPoint,'Capitan : Liste des essais');
  11496. insertBefore(insertPoint, eBigDiv);
  11497. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11498. }
  11499. if (!essais) {
  11500. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11501. return;
  11502. }
  11503. var carte;
  11504. for (carte in essais) {
  11505. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11506. }
  11507. if (carte === undefined) {
  11508. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11509. }
  11510. }
  11511.  
  11512. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11513. var tr = appendTr(eTable);
  11514. var td = appendTd(tr);
  11515. appendText(td, sMode, bBold);
  11516. td = appendTd(tr);
  11517. appendText(td, sCarte, bBold);
  11518. td = appendTd(tr);
  11519. appendText(td, sText, bBold);
  11520. }
  11521.  
  11522. function getEssaiV1_0() {
  11523. try {
  11524. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11525. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11526. var tabK, nK;
  11527. prefs.getChildList('', nK, tabK);
  11528. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11529. //window.console.log('getEssaiV1_0, ' + nK);
  11530. return;
  11531. //return r;
  11532. } catch (e) {
  11533. window.console.log('Erreur getEssaiV1_0() :\n'+e);
  11534. }
  11535. }
  11536.  
  11537. function getEssaiV1_1() {
  11538. var locSto = window.localStorage;
  11539. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11540. var r = [];
  11541. for (var i = 0; i < locSto.length; i++) {
  11542. var k = locSto.key(i);
  11543. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11544. var t = k.split(/\./);
  11545. if (t[0] !== 'capitan') continue;
  11546. if (t[2] !== 'essai') continue;
  11547. var carte = 'carte n°' + t[1];
  11548. if (r[carte]) r[carte]++;
  11549. else r[carte] = 1;
  11550. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11551. }
  11552. return r;
  11553. }
  11554.  
  11555. function showEssaiCartes() {
  11556. window.console.log('début showEssai Tout_MZ');
  11557. var essais = getEssaiV1_0();
  11558. AfficheEssais(essais, 'V1.0');
  11559. essais = getEssaiV1_1();
  11560. AfficheEssais(essais, 'V1.1');
  11561. window.console.log('fin showEssai Tout_MZ');
  11562. }
  11563.  
  11564. /*--------------------------------- Dispatch ---------------------------------*/
  11565.  
  11566. //chargerScriptDev("libs");
  11567. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  11568.  
  11569. // Détection de la page à traiter
  11570. if(isPage("Messagerie/ViewMessageBot")) {
  11571. do_cdmbot();
  11572. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  11573. do_cdmcomp();
  11574. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  11575. do_diplo();
  11576. } else if(isPage("MH_Play/Play_equipement")) {
  11577. do_equip();
  11578. } else if(isPage("MH_Play/Play_menu")) {
  11579. do_menu();
  11580. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  11581. do_option();
  11582. //showEssaiCartes();
  11583. } else if(isPage("View/PJView")) {
  11584. do_pjview();
  11585. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  11586. do_profil();
  11587. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  11588. do_tancompo();
  11589. } else if(isPage("MH_Play/Play_vue")) {
  11590. do_vue();
  11591. } else if(isPage("MH_Play/Play_news")) {
  11592. do_news();
  11593. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  11594. do_move();
  11595. } else if(isPage("MH_Missions/Mission_Etape")) {
  11596. do_mission();
  11597. } else if(isPage("View/MonsterView")) {
  11598. do_infomonstre();
  11599. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  11600. do_attaque();
  11601. } else if(isPage("MH_Follower/FO_Ordres")) {
  11602. do_ordresgowap();
  11603. } else if(isPage("MH_Follower/FO_Equipement")) {
  11604. do_equipgowap();
  11605. } else if(isPage("MH_Play/Play_mouche")) {
  11606. do_mouches();
  11607. } else if(isPage("MH_Play/Play_BM")) {
  11608. do_malus();
  11609. } else if(isPage("MH_Play/Play_evenement")) {
  11610. do_myevent();
  11611. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  11612. do_enchant();
  11613. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  11614. do_pre_enchant();
  11615. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  11616. do_actions();
  11617. } 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')) {
  11618. do_mission_liste();
  11619. } else if(isPage('MH_Play/Play_action')) {
  11620. do_actions();
  11621. } else if(isPage('MH_Play/Play_profil2')) {
  11622. do_profil2();
  11623. }