Tout_MZ

Client MountyZilla

当前为 2017-01-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @version 1.2.13
  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 27/12/2016
  87. // Correction mode IP
  88. // Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)
  89. // V1.2.12.2 30/12/2016
  90. // retour en mode normal (http si jeu en http)
  91. // V1.2.13 01/01/2017
  92. // homogénéisation des messages d'erreur
  93. // Ajout du lien Troogle sur les étapes de mission monstre
  94.  
  95. /**********************************************************
  96. À faire / propositions d'évolutions
  97.  
  98. breizhou13 20/12/2016
  99. envoyer les données à l'IT (Bricol'Trolls) aussi
  100. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  101. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  102. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  103. Roule'
  104. Réactiver les jubilaires
  105. [Prioritaire] trajets Gowaps sans avoir besoin de URL_MZscriptCarte (voir comment c'est fait dans Trajet_des_gowap_MkII.user.js)
  106. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  107. Lien vers Troogle sur l'étape de mission active
  108. **********************************************************/
  109.  
  110. /**********************************************************
  111. **** Début de zone à déplacer dans une bibli commune ******
  112. **********************************************************/
  113.  
  114. // URL de base serveur MZ
  115. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  116. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  117. //var URL_MZ = 'http://192.99.225.92/mz';
  118.  
  119. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  120. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  121.  
  122. // URLs externes redirection (pas de souci CORS)
  123. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  124. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  125. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  126. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  127. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  128. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  129. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  130. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  131. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  132.  
  133. // URLs de test HTTPS
  134. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  135. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  136.  
  137. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  138. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  139. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  140.  
  141. // x~x Libs
  142.  
  143. /* ancien TODO
  144. * - revoir la gestion des CdM --> nott armure magique
  145. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  146. * - vérfier la gestion des enchants
  147. */
  148.  
  149. // Roule 04/09/2016 switch extern URLs to https if available
  150. var isHTTPS = false;
  151. if (window.location.protocol.indexOf('https') === 0) {
  152. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  153. URL_bricol = URL_bricol_https;
  154. isHTTPS = true;
  155. }
  156.  
  157. // Roule 23/12/2016 mode dev
  158. var isDEV = false;
  159. if (MY_getValue('MZ_dev')) {
  160. URL_MZ = URL_MZ.replace(/$/, 'dev');
  161. isDEV = true;
  162. }
  163.  
  164. // Images (pas de souci CORS)
  165. var URL_MZimg = URL_MZ + '/img/';
  166. // URLs externes ajax (CORS OK)
  167. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  168. var URL_pageDispatcher = URL_MZ + '/cdmdispatcher.php';
  169.  
  170. // liens externes détuits
  171. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  172. var MHicons = '/mountyhall/Images/Icones/';
  173. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  174. var MY_DEBUG = false;
  175.  
  176. /* remplacement fonction MZ */
  177. function MY_getValue(key) {
  178. return window.localStorage[key];
  179. }
  180.  
  181. function MY_removeValue(key) {
  182. window.localStorage.removeItem(key);
  183. }
  184.  
  185. function MY_setValue(key, val) {
  186. window.localStorage[key] = val;
  187. }
  188.  
  189. /*---------------- mise à jour de variables globales utiles ------------------*/
  190. // utilisé pour accès bdd (un peu partout) :
  191. var numTroll = MY_getValue('NUM_TROLL');
  192. // utilisé dans vue pour PX :
  193. var nivTroll = MY_getValue('NIV_TROLL');
  194. // utilisés dans actions et vue (calculs SR) :
  195. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  196. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  197.  
  198. /*-[functions]------------ Fonctions durée de script -------------------------*/
  199. var date_debut = null;
  200.  
  201. function start_script(nbJours_exp) {
  202. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  203. if(date_debut) return;
  204. date_debut = new Date();
  205. // Créé la variable expdate si demandé
  206. if(nbJours_exp) {
  207. expdate = new Date();
  208. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  209. }
  210. }
  211.  
  212. function displayScriptTime() {
  213. var footerNode = document.getElementById('footer2');
  214. if(!footerNode) return;
  215. try{
  216. var node = document.evaluate(
  217. ".//text()[contains(.,'Page générée en')]/../br",
  218. footerNode,null,9,null).singleNodeValue;
  219. }
  220. catch(e){return;}
  221. insertText(node,
  222. ' - [Script exécuté en '
  223. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  224. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  225. }
  226.  
  227. function traceStack(e, sModule) {
  228. var version = '';
  229. if (GM_info && GM_info.script && GM_info.script.version)
  230. version = ' ' + GM_info.script.version;
  231. sRet = '[MZ' + version + ']'
  232. if (sModule) sRet += ' {' + sModule + '}';
  233. if (e.message) sRet += ' ' + e.message;
  234. if (e.stack) {
  235. var sStack = e.stack;
  236. // enlever les infos confidentielles
  237. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  238. }
  239. return sRet;
  240. }
  241.  
  242. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  243.  
  244. function debugMZ(str){
  245. if(MY_DEBUG){
  246. window.console.debug('[MY_DEBUG] '+str);
  247. if(typeof str === "object"){
  248. window.console.debug(str);
  249. }
  250. }
  251. }
  252.  
  253. function FF_XMLHttpRequest(MY_XHR_Ob) {
  254. var request = new XMLHttpRequest();
  255. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  256. for(var head in MY_XHR_Ob.headers) {
  257. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  258. }
  259. request.onreadystatechange = function() {
  260. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  261. if(request.readyState!=4) { return; }
  262. if(request.error) {
  263. if(MY_XHR_Ob.onerror) {
  264. MY_XHR_Ob.onerror(request);
  265. }
  266. }
  267. else if(MY_XHR_Ob.onload) {
  268. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  269. MY_XHR_Ob.onload(request);
  270. }
  271. };
  272. request.send(MY_XHR_Ob.data);
  273. }
  274.  
  275.  
  276. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  277.  
  278. function avertissement(txt,duree) {
  279. if(!duree) duree = 15000;
  280. var div = document.createElement('div');
  281. // On numérote les avertissements pour destruction sélective
  282. var num = document.getElementsByName('avertissement').length;
  283. div.num = num;
  284. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  285. div.setAttribute('name','avertissement');
  286. div.className = 'mh_textbox';
  287. div.style.position = 'fixed';
  288. div.style.top = (10+15*num)+'px';
  289. div.style.left = (10+5*num)+'px';
  290. div.style.border = '5px solid red';
  291. div.style.zIndex = 2+num;
  292. div.style.cursor = 'pointer';
  293. div.style.fontSize = 'large';
  294. div.innerHTML = txt;
  295. div.onclick=function(){ tueAvertissement(this.num) };
  296.  
  297. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  298. var divcroix = document.createElement('div');
  299. divcroix.style.position = 'absolute';
  300. divcroix.style.top = 0;
  301. divcroix.style.right = 0;
  302. divcroix.style.color = 'black';
  303. divcroix.style.fontSize = 'inherit';
  304. divcroix.style.cursor = 'pointer'
  305. divcroix.style.zIndex = 2+num;
  306. divcroix.innerHTML = "X";
  307. div.appendChild(divcroix);
  308.  
  309. document.body.appendChild(div);
  310. // Destruction automatique de l'avertissement après "un certain temps"
  311. window.setTimeout(function(){ tueAvertissement(num) },duree);
  312. }
  313.  
  314. function tueAvertissement(num) {
  315. var divs = document.getElementsByName('avertissement');
  316. if(divs.length==0) { return; }
  317. for(var i=0 ; i<divs.length ; i++) {
  318. if(divs[i].num==num) {
  319. divs[i].parentNode.removeChild(divs[i]);
  320. return;
  321. }
  322. }
  323. }
  324.  
  325.  
  326. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  327.  
  328. function insertBefore(next,el) {
  329. next.parentNode.insertBefore(el,next);
  330. }
  331.  
  332. function appendTr(tbody,clas) {
  333. var tr = document.createElement('tr');
  334. if(clas) tr.className = clas;
  335. tbody.appendChild(tr);
  336. return tr;
  337. }
  338.  
  339. function insertTr(next,clas) {
  340. var tr = document.createElement('tr');
  341. if(clas) tr.className = clas;
  342. insertBefore(next,tr);
  343. return tr;
  344. }
  345.  
  346. function appendTd(tr) {
  347. var td = document.createElement('td');
  348. if(tr) tr.appendChild(td);
  349. return td;
  350. }
  351.  
  352. function insertTd(next) {
  353. var td = document.createElement('td');
  354. insertBefore(next,td);
  355. return td;
  356. }
  357.  
  358. function appendTdCenter(tr,colspan) {
  359. var td = appendTd(tr);
  360. td.align = 'center'; // WARNING - Obsolete
  361. if(colspan) td.colSpan = colspan;
  362. return td;
  363. }
  364.  
  365. function insertTdElement(next,el) {
  366. var td = insertTd(next);
  367. if(el) td.appendChild(el);
  368. return td;
  369. }
  370.  
  371. function appendA(paren,href,cssClass,text) {
  372. var a = document.createElement('a');
  373. if (href) a.href = href;
  374. if (cssClass) a.className = cssClass;
  375. if (text) a.appendChild(document.createTextNode(text));
  376. paren.appendChild(a);
  377. }
  378.  
  379. function appendText(paren,text,bold) {
  380. if(bold) {
  381. var b = document.createElement('b');
  382. b.appendChild(document.createTextNode(text));
  383. paren.appendChild(b);
  384. }
  385. else
  386. paren.appendChild(document.createTextNode(text));
  387. }
  388.  
  389. function insertText(next,text,bold) {
  390. if(bold) {
  391. var b = document.createElement('b');
  392. appendText(b,text);
  393. insertBefore(next,b);
  394. }
  395. else
  396. insertBefore(next,document.createTextNode(text));
  397. }
  398.  
  399. function appendTdText(tr,text,bold) {
  400. var td = appendTd(tr);
  401. appendText(td,text,bold);
  402. return td;
  403. }
  404.  
  405. function insertTdText(next,text,bold) {
  406. var td = insertTd(next);
  407. appendText(td,text,bold);
  408. return td;
  409. }
  410.  
  411. function appendBr(paren) {
  412. paren.appendChild(document.createElement('br'));
  413. }
  414.  
  415. function insertBr(next) {
  416. insertBefore(next,document.createElement('br'));
  417. }
  418.  
  419. function appendLI(ul,text) {
  420. // uniquement utilisé dans les options (crédits)
  421. var li = document.createElement('li');
  422. appendText(li,text);
  423. ul.appendChild(li);
  424. return li;
  425. }
  426.  
  427. function appendTextbox(paren,type,nam,size,maxlength,value) {
  428. var input = document.createElement('input');
  429. input.className = 'TextboxV2';
  430. input.type = type;
  431. input.name = nam;
  432. input.id = nam;
  433. input.size = size;
  434. input.maxLength = maxlength;
  435. if(value) input.value = value;
  436. paren.appendChild(input);
  437. return input;
  438. }
  439.  
  440. function appendCheckBox(paren,nam,checked,onClick) {
  441. var input = document.createElement('input');
  442. input.type = 'checkbox';
  443. input.name = nam;
  444. input.id = nam;
  445. if(checked) input.checked = true;
  446. if(onClick) input.onclick = onClick;
  447. paren.appendChild(input);
  448. return input;
  449. }
  450.  
  451. function appendNobr(paren,id,delgg,text) {
  452. var nobr = document.createElement('nobr');
  453. appendCheckBox(nobr,id,null,delgg);
  454. appendText(nobr,text);
  455. paren.appendChild(nobr);
  456. appendText(paren,' ');
  457. return nobr;
  458. }
  459.  
  460. function appendCheckBoxSpan(paren,id,onClick,text) {
  461. var span = document.createElement('span');
  462. span.style.whiteSpace = 'nowrap';
  463. appendCheckBox(span,id,false,onClick);
  464. appendText(span,text);
  465. paren.appendChild(span);
  466. appendText(paren,' ');
  467. return span;
  468. }
  469.  
  470. function appendOption(select,value,text) {
  471. var option = document.createElement('option');
  472. option.value = value;
  473. appendText(option,text);
  474. select.appendChild(option);
  475. return option;
  476. }
  477.  
  478. function appendHidden(form,nam,value) {
  479. var input = document.createElement('input');
  480. input.type = 'hidden';
  481. input.name = nam;
  482. input.id = nam;
  483. input.value = value;
  484. form.appendChild(input);
  485. }
  486.  
  487. function appendButton(paren,value,onClick) {
  488. var input = document.createElement('input');
  489. input.type = 'button';
  490. input.className = 'mh_form_submit';
  491. input.value = value;
  492. input.onmouseover = function(){this.style.cursor='pointer';};
  493. if(onClick) input.onclick = onClick;
  494. paren.appendChild(input);
  495. return input;
  496. }
  497.  
  498. function insertButton(next,value,onClick) {
  499. var input = document.createElement('input');
  500. input.type = 'button';
  501. input.className = 'mh_form_submit';
  502. input.value = value;
  503. input.onmouseover = function(){this.style.cursor='pointer';};
  504. input.onclick = onClick;
  505. insertBefore(next,input);
  506. return input;
  507. }
  508.  
  509. function appendSubmit(paren,value,onClick) {
  510. var input = document.createElement('input');
  511. input.type = 'submit';
  512. input.className = 'mh_form_submit';
  513. input.value = value;
  514. input.onmouseover = function(){this.style.cursor='pointer';};
  515. if(onClick) input.onclick = onClick;
  516. paren.appendChild(input);
  517. return input;
  518. }
  519.  
  520. function createImage(url,title) {
  521. var img = document.createElement('img');
  522. img.src = url;
  523. img.title = title;
  524. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  525. return img;
  526. }
  527.  
  528. function createAltImage(url,alt,title) {
  529. var img = document.createElement('img');
  530. img.src = url;
  531. img.alt = alt;
  532. img.title = title;
  533. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  534. return img;
  535. }
  536.  
  537. function createImageSpan(url,alt,title,text,bold) {
  538. var span = document.createElement('span');
  539. span.title = title;
  540. var img = document.createElement('img');
  541. img.src = url;
  542. img.alt = alt;
  543. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  544. span.appendChild(img);
  545. appendText(span,text,bold);
  546. return span;
  547. }
  548.  
  549. function createCase(titre,table,width) {
  550. if(!width) width=120;
  551. var tr = appendTr(table,'mh_tdpage');
  552. var td = appendTdText(tr,titre,true);
  553. td.className = 'mh_tdtitre';
  554. td.width = width;
  555. td = appendTdText(tr,'');
  556. td.className = 'mh_tdpage';
  557. return td;
  558. }
  559.  
  560. function getMyID(e) {
  561. var parent = e.parentNode;
  562. for(var i=0 ; i<parent.childNodes.length ; i++) {
  563. if(e==parent.childNodes[i])
  564. return i;
  565. }
  566. return -1;
  567. }
  568.  
  569. function insertAfter(elt,newElt) {
  570. var id = getMyID(elt);
  571. if(id==-1) return;
  572. if(id<elt.parentNode.childNodes.length-1)
  573. insertBefore(elt.nextSibling,newElt);
  574. else
  575. elt.parentNode.appendChild(newElt);
  576. }
  577.  
  578.  
  579. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  580.  
  581. function aff(nb) {
  582. return (nb>=0) ? '+'+nb : nb;
  583. }
  584.  
  585. function getNumber(str) {
  586. var nbr = str.match(/\d+/);
  587. return nbr ? Number(nbr[0]) : Number.NaN;
  588. }
  589.  
  590. function getNumbers(str) {
  591. var nbrs = str.match(/-?\d+/g);
  592. if (!nbrs) return [];
  593. for(var i=0 ; i<nbrs.length ; i++)
  594. nbrs[i] = Number(nbrs[i]);
  595. return nbrs;
  596. }
  597.  
  598. function trim(str) {
  599. return str.replace(/(^\s*)|(\s*$)/g,'');
  600. }
  601.  
  602. String.prototype.trim = function() {
  603. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  604. }
  605.  
  606. function epure(texte) {
  607. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  608. .replace(/[ç]/g,'c')
  609. .replace(/[éêèë]/g,'e')
  610. .replace(/[ïî]/g,'i')
  611. .replace(/[ôöõ]/g,'o')
  612. .replace(/[ùûü]/g,'u');
  613. }
  614.  
  615. String.prototype.epure = function () {
  616. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  617. .replace(/[ç]/g,'c')
  618. .replace(/[éêèë]/g,'e')
  619. .replace(/[ïî]/g,'i')
  620. .replace(/[ôöõ]/g,'o')
  621. .replace(/[ùûü]/g,'u');
  622. }
  623.  
  624. function bbcode(texte) {
  625. return texte.replace(/&/g,'&amp;')
  626. .replace(/"/g,'&quot;')
  627. .replace(/</g,'&lt;')
  628. .replace(/>/g,'&gt;')
  629. .replace(/'/g,'&#146;')
  630. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  631. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  632. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  633. }
  634.  
  635.  
  636. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  637.  
  638. function addZero(i) {
  639. return (i<10) ? '0'+i : i;
  640. }
  641.  
  642. function DateToString(date) {
  643. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  644. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  645. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  646. }
  647.  
  648. function StringToDate(str) {
  649. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  650. }
  651.  
  652. // fonctionne aussi avec datetime
  653. function SQLDateToFrench(str) {
  654. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  655. }
  656.  
  657. // ... et ajoute un "à" du plus bel effet
  658. function SQLDateToFrenchTime(str) {
  659. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  660. }
  661.  
  662. // SQLDate vers objet date Javascript
  663. function SQLDateToObject(str) {
  664. var t = str.split(/[- :]/);
  665. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  666. }
  667.  
  668. var mz_ie = (window.attachEvent)? true:false;
  669. if ("function" !== typeof addEvent) {
  670. if (mz_ie) {
  671. function addEvent(obj, typ, fn, sens) {
  672. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  673. obj["e"+typ+fn]( window.event );
  674. }
  675. obj.attachEvent("on"+typ, obj[typ+fn] );
  676. }
  677. }
  678. else {
  679. function addEvent(obj, typ, fn, sens) {
  680. obj.addEventListener(typ, fn, sens);
  681. }
  682. }
  683. }
  684.  
  685. // mise en commun du dessin des cartes (récupéré de Trajet_des_gowaps de feldspath et Vapulabehemot)
  686. function declare_css_carte_hall() {
  687. if(haut.getElementById("css_gow")) return;
  688. 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; }";
  689.  
  690. var node = document.createElement("style");
  691. node.type = "text/css";
  692. node.id = "css_gow";
  693. node.appendChild(document.createTextNode(css));
  694. document.getElementsByTagName("head")[0].appendChild(node);
  695. }
  696.  
  697. function ini_canvas_carte_hall() {
  698. var trajet = document.createElement("div");
  699. trajet.id = "carte_trajet";
  700.  
  701. var dessin = creer_canvas("trou");
  702. var dessin = document.createElement("canvas");
  703. dessin.id = ref;
  704. dessin.className = "mh_tdpage";
  705. trajet.appendChild(dessin);
  706. trajet.appendChild(creer_canvas("trajet"));
  707. trajet.appendChild(creer_canvas("danger"));
  708.  
  709. var dessin = creer_canvas("surligne");
  710. addEvent(dessin, "click", action_trajet, true);
  711. addEvent(dessin, "mousedown", start_v, true);
  712. addEvent(dessin, "mousemove", afficher_position, true);
  713. addEvent(dessin, "mouseout", function() { cacher_bulle(true) }, true);
  714. addEvent(dessin, "mouseover", function() { cacher_bulle(false) }, true);
  715. trajet.appendChild(dessin);
  716.  
  717. trajet.appendChild(creer_glissiere("gow", zoom));
  718.  
  719. var parp = document.getElementsByTagName('p');
  720. parp[parp.length-1].insertBefore(trajet,parp[parp.length-1].firstChild);
  721. }
  722.  
  723. /**********************
  724. * glissière en mode objet
  725. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  726. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  727. *
  728. * Usage:
  729. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  730. * ref : utilisé pour diversifier les IDs HTML
  731. * labelHTML : le label qui apparaît davant la glissière (peut contenir des balises HTML)
  732. * target : peut être de 3 types
  733. * - élément HTML : l'élément HTML à zoomer
  734. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  735. * - function : callback quand le curseur bouge
  736. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  737. * dans le mode dynamique, la callback est appelée sur mouseMove
  738. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  739. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  740. * autres méthodes
  741. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  742. **********************/
  743.  
  744. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  745. try {
  746. var mouseDown = false;
  747. var div_gliss = document.createElement("div"); // la DIV mère
  748. div_gliss.id = "MZ_gliss_"+ref;
  749. var div_label = document.createElement("div"); // le label
  750. div_label.innerHTML = labelHTML;
  751. div_gliss.appendChild(div_label);
  752. div_gliss.className = "choix_zoom";
  753. var dessin = document.createElement("canvas"); // le dessin lui-même
  754. dessin.id = "MZ_gliss_dessin_"+ref;
  755. dessin.width = 104;
  756. dessin.height = 12;
  757. div_gliss.appendChild(dessin);
  758. var pourcent = document.createElement("span"); // le pourcentage
  759. pourcent.id = "MZ_gliss_pourcent_"+ref;
  760. var pourcent_text = document.createTextNode('');
  761. pourcent.appendChild(pourcent_text);
  762. div_gliss.appendChild(pourcent);
  763.  
  764. var bulle_pourcent = document.createElement("div"); // la bulle
  765. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  766. bulle_pourcent.style.display = 'block';
  767. bulle_pourcent.style.visibility = 'hidden';
  768. bulle_pourcent.style.position = 'absolute';
  769. bulle_pourcent.style.zIndex = 3500;
  770. bulle_pourcent.style.border = '1px solid #a1927f';
  771. var bulle_pourcent_text = document.createTextNode('');
  772. bulle_pourcent.appendChild(bulle_pourcent_text);
  773. document.body.appendChild(bulle_pourcent);
  774.  
  775. this.getElt = function() {return div_gliss;};
  776.  
  777. ////////////////////////////////////
  778. // dessine et redessine le curseur
  779. ////////////////////////////////////
  780. var dessine_glissiere = function(val) {
  781. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  782. var ctx = dessin.getContext('2d');
  783. ctx.clearRect(0, 0,104, 12);
  784. ctx.fillStyle = "rgb(0,0,0)";
  785. ctx.fillRect(0,0,2,12);
  786. ctx.fillRect(102,0,2,12);
  787. ctx.fillRect(0,5,104,2);
  788.  
  789. ctx.fillStyle = "rgb(80,80,80)";
  790. ctx.fillRect(pos_0_100,0,5,12);
  791. ctx.fillStyle = "rgb(200,200,200)";
  792. ctx.fillRect(pos_0_100+1,1,3,10);
  793. pourcent_text.nodeValue = val+'%';
  794. };
  795.  
  796. ////////////////////////////////////
  797. // action qur mousedown et mousemove
  798. // stocker la nouvelle valeur
  799. // redessiner
  800. // afficher la nouvelle valeur
  801. // action selon ce qui a été demandé
  802. ////////////////////////////////////
  803. var doCallback_glissiere = function (evt) {
  804. try {
  805. if (evt.type === 'mousedown') mouseDown = true;
  806. if (evt.offsetX) {
  807. var xsouris = evt.offsetX;
  808. var xpos = evt.clientX;
  809. var ypos = evt.clientY + document.body.scrollTop;
  810. }
  811. else {
  812. var xsouris = evt.layerX;
  813. var xpos = evt.pageX;
  814. var ypos = evt.pageY;
  815. }
  816. var val = Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin));
  817. // afficher la nouvelle valeur dans la bulle
  818. bulle_pourcent_text.nodeValue = val + '%';
  819. bulle_pourcent.style.top = (ypos+3)+'px';
  820. bulle_pourcent.style.left = (xpos+16)+'px';
  821. if (evt.buttons === undefined) {
  822. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  823. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  824. } else {
  825. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  826. }
  827. // stocker la nouvelle valeur
  828. MY_setValue("MZ_glissiere_" + ref, val);
  829. // redessiner la glissière avec le curseur où il faut
  830. dessine_glissiere(val);
  831. // action selon ce qui a été demandé
  832. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  833. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  834. if (typeof paramTarget === 'object') {
  835. var elt = paramTarget;
  836. } else if (typeof paramTarget === 'string') {
  837. var elt = document.getElementById(paramTarget);
  838. } else if (typeof paramTarget === 'function') {
  839. paramTarget(val);
  840. return;
  841. }
  842. // à faire : zoom de l'elt
  843. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  844. };
  845.  
  846. ////////////////////////////////////
  847. // event mousedown et mousemove : redessiner et callback
  848. ////////////////////////////////////
  849. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  850. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  851. ////////////////////////////////////
  852. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  853. ////////////////////////////////////
  854. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  855. ////////////////////////////////////
  856. // event mouseout & mouseover : afficher/cacher la bulle
  857. ////////////////////////////////////
  858. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  859. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  860.  
  861. ////////////////////////////////////
  862. // dessiner la première fois
  863. ////////////////////////////////////
  864. var val_init = MY_getValue("MZ_glissiere_" + ref);
  865. if (val_init === undefined) val_init = valDef;
  866. dessine_glissiere(val_init);
  867. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  868. }
  869.  
  870.  
  871. /**********************************************************
  872. **** Fin de zone à déplacer dans une bibli commune ********
  873. **********************************************************/
  874.  
  875. /* DEBUG: NETTOYAGE TAGS */
  876. if(MY_getValue(numTroll+'.TAGSURL')) {
  877. MY_removeValue(numTroll+'.TAGSURL');
  878. }
  879.  
  880. // Alerte si mode dev
  881. if (isDEV) {
  882. var divpopup = document.createElement('div');
  883. divpopup.id = 'divDEV';
  884. divpopup.style =
  885. 'position: fixed;'+
  886. 'border: 15px solid red;'+
  887. 'top: 10px;right: 10px;'+
  888. 'background-color: white;'+
  889. 'color: black;'+
  890. 'font-size: large;'+
  891. 'padding: 5px'+
  892. 'z-index: 200;';
  893. appendText(divpopup, '[MZ] Mode DEV');
  894. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  895. document.body.appendChild(divpopup);
  896. }
  897.  
  898. /*---------- regroupement des getPortee() ------------------------------------*/
  899. // issu des script profil et profil2
  900. function getPortee__Profil(param) {
  901. param = Math.max(0,Number(param));
  902. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  903. // ça devrait être floor, +10.25, -2.5
  904. }
  905.  
  906. // issu du script vue
  907. function getPortee__Vue(param) {
  908. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  909. }
  910.  
  911.  
  912. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  913.  
  914. function getPXKill(niv) {
  915. return Math.max(0,10+3*niv-2*nivTroll);
  916. }
  917.  
  918. function getPXDeath(niv) {
  919. return Math.max(0,10+3*nivTroll-2*niv);
  920. }
  921.  
  922. function analysePX(niv) {
  923. niv = niv+'';
  924. var i = niv.indexOf('+');
  925. if(i!=-1) // si niv = 'XX+' ??
  926. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  927. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  928. if(i!=-1) {
  929. var max = getPXKill(niv.slice(i+2));
  930. if(max==0)
  931. return ' --> <b>0</b> PX';
  932. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  933. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  934. }
  935. i = niv.indexOf('='); // ???
  936. if(i!=-1) {
  937. var max = getPXKill(niv.slice(i+1));
  938. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  939. }
  940. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  941. }
  942.  
  943. function analysePXTroll(niv) {
  944. var str = analysePX(niv);
  945. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  946. return str;
  947. }
  948.  
  949.  
  950. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  951. // Refonte totale du code de Zorya
  952.  
  953. // Elements à implémenter en dur dans MZ2.0
  954. var numQualite = {
  955. 'Très Mauvaise':1,
  956. 'Mauvaise':2,
  957. 'Moyenne':3,
  958. 'Bonne':4,
  959. 'Très Bonne':5
  960. };
  961.  
  962. var qualiteNum = [
  963. '_dummy_',
  964. 'Très Mauvaise',
  965. 'Mauvaise',
  966. 'Moyenne',
  967. 'Bonne',
  968. 'Très Bonne'
  969. ];
  970.  
  971. var nival = {
  972. 'Abishaii Bleu':19,
  973. 'Abishaii Noir':10,
  974. 'Abishaii Rouge':23,
  975. 'Abishaii Vert':15,
  976. 'Ame-en-peine':8,
  977. 'Amibe Geante':9,
  978. 'Anaconda des Catacombes':8,
  979. 'Ankheg':10,
  980. 'Anoploure Purpurin':36,
  981. 'Araignee Geante':2,
  982. 'Ashashin':35,
  983. 'Balrog':50,
  984. 'Banshee':16,
  985. 'Barghest':36,
  986. 'Basilisk':11,
  987. 'Behemoth':34,
  988. 'Behir':14,
  989. 'Beholder':50,
  990. 'Boggart':3,
  991. 'Bondin':9,
  992. "Bouj'Dla Placide":37,
  993. "Bouj'Dla":19,
  994. 'Bulette':19,
  995. 'Caillouteux':1,
  996. 'Capitan':35,
  997. 'Carnosaure':25,
  998. 'Champi-Glouton':3,
  999. 'Chauve-Souris Geante':4,
  1000. 'Cheval a Dents de Sabre':23,
  1001. 'Chevalier du Chaos':20,
  1002. 'Chimere':13,
  1003. 'Chonchon':24,
  1004. 'Coccicruelle':22,
  1005. 'Cockatrice':5,
  1006. 'Crasc Medius':17,
  1007. 'Crasc Maexus':25,
  1008. 'Crasc':10,
  1009. 'Croquemitaine':6,
  1010. 'Cube Gelatineux':32,
  1011. 'Daemonite':27,
  1012. 'Diablotin':5,
  1013. 'Dindon du Chaos':1,
  1014. 'Djinn':29,
  1015. 'Ectoplasme':18,
  1016. 'Effrit':27,
  1017. "Elementaire d'Air":23,
  1018. "Elementaire d'Eau":17,
  1019. 'Elementaire de Feu':21,
  1020. 'Elementaire de Terre':21,
  1021. 'Elementaire du Chaos':26,
  1022. 'Erinyes':7,
  1023. 'Esprit-Follet':16,
  1024. 'Essaim Craterien':30,
  1025. 'Essaim Sanguinaire':25,
  1026. 'Ettin':8,
  1027. 'Familier':1,
  1028. 'Fantome':24,
  1029. 'Feu Follet':20,
  1030. 'Flagelleur Mental':33,
  1031. 'Foudroyeur':38,
  1032. 'Fumeux':22,
  1033. 'Fungus Geant':9,
  1034. 'Fungus Violet':4,
  1035. 'Furgolin':10,
  1036. 'Gargouille':3,
  1037. 'Geant de Pierre':13,
  1038. 'Geant des Gouffres':22,
  1039. "Geck'oo Majestueux":40,
  1040. "Geck'oo":15,
  1041. 'Glouton':20,
  1042. 'Gnoll':5,
  1043. 'Gnu Domestique':1,
  1044. 'Gnu Sauvage':1,
  1045. 'Goblin':4,
  1046. 'Goblours':4,
  1047. "Golem d'Argile":15,
  1048. 'Golem de cuir':1,
  1049. 'Golem de Chair':8,
  1050. 'Golem de Fer':31,
  1051. 'Golem de mithril':1,
  1052. 'Golem de metal':1,
  1053. 'Golem de papier':1,
  1054. 'Golem de Pierre':23,
  1055. 'Gorgone':11,
  1056. 'Goule':4,
  1057. 'Gowap Apprivoise':1,
  1058. 'Gowap Sauvage':1,
  1059. 'Gremlins':3,
  1060. 'Gritche':39,
  1061. 'Grouilleux':4,
  1062. 'Grylle':31,
  1063. 'Harpie':4,
  1064. 'Hellrot':18,
  1065. 'Homme-Lezard':4,
  1066. 'Hurleur':8,
  1067. 'Hydre':50,
  1068. 'Incube':13,
  1069. 'Kobold':2,
  1070. 'Labeilleux':26,
  1071. 'Lezard Geant':5,
  1072. 'Liche':50,
  1073. 'Limace Geante':10,
  1074. 'Loup-Garou':8,
  1075. 'Lutin':4,
  1076. 'Mante Fulcreuse':30,
  1077. 'Manticore':9,
  1078. 'Marilith':33,
  1079. 'Meduse':6,
  1080. 'Megacephale':38,
  1081. 'Mille-Pattes Geant':14,
  1082. 'Mimique':6,
  1083. 'Minotaure':7,
  1084. 'Molosse Satanique':8,
  1085. 'Momie':4,
  1086. 'Monstre Rouilleur':3,
  1087. "Mouch'oo Domestique":14,
  1088. "Mouch'oo Majestueux Sauvage":33,
  1089. "Mouch'oo Sauvage":14,
  1090. 'Na-Haniym-Heee':0,
  1091. 'Necrochore':37,
  1092. 'Necromant':39,
  1093. 'Necrophage':8,
  1094. 'Naga':10,
  1095. 'Nuee de Vermine':13,
  1096. "Nuage d'Insectes":7,
  1097. 'Ogre':7,
  1098. 'Ombre de Roches':13,
  1099. 'Ombre':2,
  1100. 'Orque':3,
  1101. 'Ours-Garou':18,
  1102. 'Palefroi Infernal':29,
  1103. 'Phoenix':32,
  1104. 'Pititabeille':0,
  1105. 'Plante Carnivore':4,
  1106. 'Pseudo-Dragon':5,
  1107. 'Rat Geant':2,
  1108. 'Rat-Garou':3,
  1109. 'Rocketeux':5,
  1110. 'Sagouin':3,
  1111. 'Scarabee Geant':4,
  1112. 'Scorpion Geant':10,
  1113. 'Shai':28,
  1114. 'Sirene':8,
  1115. 'Slaad':5,
  1116. 'Sorciere':17,
  1117. 'Spectre':14,
  1118. 'Sphinx':30,
  1119. 'Squelette':1,
  1120. 'Strige':2,
  1121. 'Succube':13,
  1122. 'Tertre Errant':20,
  1123. 'Thri-kreen':10,
  1124. 'Tigre-Garou':12,
  1125. 'Titan':26,
  1126. 'Trancheur':35,
  1127. 'Tubercule Tueur':14,
  1128. 'Tutoki':4,
  1129. 'Vampire':29,
  1130. 'Ver Carnivore Geant':12,
  1131. 'Ver Carnivore':11,
  1132. 'Veskan Du Chaos':14,
  1133. 'Vouivre':33,
  1134. 'Worg':5,
  1135. 'Xorn':14,
  1136. 'Yeti':8,
  1137. 'Yuan-ti':15,
  1138. 'Zombie':2
  1139. }
  1140.  
  1141. var tabEM = {
  1142. //Monstre: [Compo exact, Sort, Position, Localisation]
  1143. // AA
  1144. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1145. // AE
  1146. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1147. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1148. // AdA
  1149. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1150. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1151. // AdE
  1152. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1153. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1154. // AdD
  1155. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1156. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1157. // BAM
  1158. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1159. // BuM
  1160. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1161. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1162. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1163. // Explo
  1164. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1165. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1166. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1167. // FP
  1168. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1169. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1170. // FA
  1171. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1172. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1173. // Glue
  1174. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1175. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1176. // GdS
  1177. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1178. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1179. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1180. // Invi
  1181. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1182. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1183. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1184. // Lévitation
  1185. // ???
  1186. // PréM :
  1187. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1188. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1189. // Proj
  1190. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1191. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1192. // PuM :
  1193. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1194. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1195. // Sacro
  1196. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1197. // Télék
  1198. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1199. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1200. // TP
  1201. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1202. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1203. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1204. // VA
  1205. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1206. // VL
  1207. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1208. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1209. // VlC
  1210. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1211. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1212. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1213. // VT
  1214. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1215. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1216. // Variables
  1217. 'Rat':["d'un"],
  1218. 'Rat Géant':["d'un"],
  1219. 'Dindon':["d'un"],
  1220. 'Goblin':["d'un"],
  1221. 'Limace':["d'une"],
  1222. 'Limace Géante':["d'une"],
  1223. 'Ver':["d'un"],
  1224. 'Ver Carnivore':["d'un"],
  1225. 'Ver Carnivore Géant':["d'un"],
  1226. 'Fungus':["d'un"],
  1227. 'Vouivre':["d'une"],
  1228. 'Gnu':["d'un"],
  1229. 'Scarabée':["d'un"]
  1230. };
  1231.  
  1232. var mundiChampi = {
  1233. 'Préscientus Reguis':'du Phoenix',
  1234. 'Amanite Trolloïde':'de la Mouche',
  1235. 'Girolle Sanglante':'du Dindon',
  1236. 'Horreur Des Prés':'du Gobelin',
  1237. 'Bolet Péteur':'du Démon',
  1238. 'Pied Jaune':'de la Limace',
  1239. 'Agaric Sous-Terrain':'du Rat',
  1240. 'Suinte Cadavre':"de l'Hydre",
  1241. 'Cèpe Lumineux':'du Ver',
  1242. 'Fungus Rampant':'du Fungus',
  1243. 'Nez Noir':'de la Vouivre',
  1244. 'Pleurote Pleureuse':'du Gnu',
  1245. 'Phytomassus Xilénique':'du Scarabée'
  1246. };
  1247.  
  1248. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1249. appendText(node,' ');
  1250. var urlImg = URL_MZimg
  1251. +'Competences/melangeMagique.png';
  1252. var text = ' [-'+(niv+effetQ)+' %]';
  1253. var str = '';
  1254. switch(mob[0]) {
  1255. case 'A':
  1256. case 'E':
  1257. case 'I':
  1258. case 'O':
  1259. case 'U':
  1260. str = "Compo d'";
  1261. break;
  1262. default:
  1263. str = 'Compo de ';
  1264. }
  1265. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1266. var span = createImageSpan(urlImg,'MM:',title,text);
  1267. node.appendChild(span);
  1268. }
  1269. function addInfoEM(node,mob,compo,qualite,localisation) {
  1270. if(!tabEM[mob]) return;
  1271. var title = 'Composant variable', texte = 'Variable';
  1272. var bold = false;
  1273. if(tabEM[mob].length>1) {
  1274. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1275. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1276. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1277. if(pc<-20) return;
  1278. if(pc>=0) bold = true;
  1279. texte = aff(pc)+'%';
  1280. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1281. }
  1282. var urlImg = URL_MZimg
  1283. +'Competences/ecritureMagique.png';
  1284. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1285. node.appendChild(span);
  1286. }
  1287.  
  1288. function insererInfosEM(tbody) {
  1289. // lancé par equip, equipgowap
  1290. var trCompos = document.evaluate(
  1291. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1292. tbody,null,7,null);
  1293. var strCompos = '';
  1294. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1295. var node = trCompos.snapshotItem(i).childNodes[7];
  1296. var str = node.firstChild.textContent;
  1297. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1298. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1299. // Si non-EM on stoppe le traitement
  1300. if(!tabEM[mob]) continue;
  1301. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1302. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1303. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1304. addInfoEM(node,mob,compo,qualite,localisation);
  1305. }
  1306. }
  1307.  
  1308. function getQualite(qualite) {
  1309. var nb = numQualite[qualite];
  1310. return nb ? nb-1 : -1;
  1311. }
  1312.  
  1313. function getEM(nom) {
  1314. if(nom.indexOf('[')!=-1)
  1315. nom = trim(nom.substring(0,nom.indexOf('[')));
  1316. if(tabEM[nom]) return nom;
  1317. return '';
  1318. }
  1319.  
  1320. // DEBUG ex-fonction composantEM
  1321. function compoMobEM(mob) {
  1322. if(!tabEM[mob]) return '';
  1323. if(tabEM[mob].length==1)
  1324. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1325. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1326. +") pour l'écriture de "+tabEM[mob][1];
  1327. }
  1328.  
  1329. // DEBUG ex-fonction compoEM
  1330. function titreCompoEM(mob,compo,localisation,qualite) {
  1331. if(!tabEM[mob]) return '';
  1332. if(tabEM[mob].length==1) return 'Composant variable';
  1333. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1334. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1335. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1336. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1337. return '';
  1338. }
  1339.  
  1340. // DEBUG - rétrocompatibilité
  1341. function compoEM(mob) {
  1342. // appelé dans libs, vue
  1343. return compoMobEM(mob);
  1344. }
  1345. function composantEM(mob,compo,localisation,qualite) {
  1346. // appelé dans libs, tancompo
  1347. return titreCompoEM(mob,compo,localisation,qualite);
  1348. }
  1349. //
  1350.  
  1351.  
  1352. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1353.  
  1354. arrayTalents = {
  1355. /* Compétences */
  1356. 'Acceleration du Metabolisme':'AM',
  1357. 'Attaque Precise':'AP',
  1358. 'Balayage':'Balayage',
  1359. //'Balluchonnage':'Ballu',
  1360. 'Baroufle':'Baroufle',
  1361. 'Bidouille':'Bidouille',
  1362. 'Botte Secrete':'BS',
  1363. 'Camouflage':'Camou',
  1364. 'Charger':'Charger',
  1365. 'Connaissance des Monstres':'CdM',
  1366. 'Construire un Piege':'Piege',
  1367. 'Piege a Feu':'PiegeFeu',
  1368. 'Piege a Glue':'PiegeGlue',
  1369. 'Contre-Attaquer':'CA',
  1370. 'Coup de Butoir':'CdB',
  1371. 'Course':'Course',
  1372. 'Deplacement Eclair':'DE',
  1373. 'Dressage':'Dressage',
  1374. 'Ecriture Magique':'EM',
  1375. 'Frenesie':'Frenesie',
  1376. 'Golemologie':'Golemo',
  1377. 'Golem de cuir':'GolemCuir',
  1378. 'Golem de metal':'GolemMetal',
  1379. 'Golem de mithril':'GolemMithril',
  1380. 'Golem de papier':'GolemPapier',
  1381. 'Grattage':'Grattage',
  1382. 'Hurlement Effrayant':'HE',
  1383. 'Identification des Champignons':'IdC',
  1384. 'Insultes':'Insultes',
  1385. 'Lancer de Potions':'LdP',
  1386. 'Marquage':'Marquage',
  1387. 'Melange Magique':'Melange',
  1388. 'Miner':'Miner',
  1389. 'Necromancie':'Necro',
  1390. 'Painthure de Guerre':'PG',
  1391. 'Parer':'Parer',
  1392. 'Pistage':'Pistage',
  1393. 'Planter un Champignon':'PuC',
  1394. 'Regeneration Accrue':'RA',
  1395. 'Reparation':'Reparation',
  1396. 'Retraite':'Retraite',
  1397. 'Rotobaffe':'RB',
  1398. 'Shamaner':'Shamaner',
  1399. "S'interposer":'SInterposer',
  1400. 'Tailler':'Tailler',
  1401. //'Vol':'Vol',
  1402. /* Sortilèges */
  1403. 'Analyse Anatomique':'AA',
  1404. 'Armure Etheree':'AE',
  1405. 'Augmentation de l´Attaque':'AdA',
  1406. 'Augmentation de l´Esquive':'AdE',
  1407. 'Augmentation des Degats':'AdD',
  1408. 'Bulle Anti-Magie':'BAM',
  1409. 'Bulle Magique':'BuM',
  1410. 'Explosion':'Explo',
  1411. 'Faiblesse Passagere':'FP',
  1412. 'Flash Aveuglant':'FA',
  1413. 'Glue':'Glue',
  1414. 'Griffe du Sorcier':'GdS',
  1415. 'Hypnotisme':'Hypno',
  1416. 'Identification des tresors':'IdT',
  1417. 'Invisibilite':'Invi',
  1418. 'Levitation':'Levitation',
  1419. 'Precision Magique':'PreM',
  1420. 'Projectile Magique':'Projo',
  1421. 'Projection':'Proj',
  1422. 'Puissance Magique':'PuM',
  1423. 'Rafale Psychique':'Rafale',
  1424. 'Sacrifice':'Sacro',
  1425. 'Siphon des Ames':'Siphon',
  1426. 'Telekinesie':'Telek',
  1427. 'Teleportation':'TP',
  1428. 'Vampirisme':'Vampi',
  1429. 'Vision Accrue':'VA',
  1430. 'Vision lointaine':'VL',
  1431. 'Voir le Cache':'VlC',
  1432. 'Vue Troublee':'VT'
  1433. //'':''
  1434. }
  1435.  
  1436. // DEBUG - Pour rétrocompatibilité
  1437. function getSortComp(nom,niveau) {
  1438. return getTalent(nom,niveau);
  1439. }
  1440. //
  1441.  
  1442. function getTalent(nom,niveau) {
  1443. var nomEnBase = arrayTalents[epure(nom)];
  1444. if(!nomEnBase) return 0;
  1445. if(!niveau) var niveau = '';
  1446. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1447. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1448. return 0;
  1449. }
  1450.  
  1451. function removeAllTalents() {
  1452. for(var talent in arrayTalents) {
  1453. var nomEnBase = arrayTalents[talent];
  1454. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1455. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1456. continue;
  1457. }
  1458. var niveau = 1;
  1459. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1460. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1461. niveau++;
  1462. }
  1463. }
  1464. }
  1465.  
  1466. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1467. var att = MY_getValue(numTroll+'.caracs.attaque');
  1468. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1469. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1470. var mm = MY_getValue(numTroll+'.caracs.mm');
  1471. var deg = MY_getValue(numTroll+'.caracs.degats');
  1472. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1473. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1474. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1475. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1476. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1477. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1478. return false;
  1479. return true;
  1480. }
  1481.  
  1482.  
  1483. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1484.  
  1485. function getPVsRestants(pv,bless,vue) {
  1486. bless = Number(bless.match(/\d+/)[0]);
  1487. if(bless==0) return null;
  1488. var pvminmax = pv.match(/\d+/g);
  1489. if(bless==95) {
  1490. var pvb = 1;
  1491. var pvh = Math.floor( pvminmax[1]/20 );
  1492. }
  1493. else if(bless==5) {
  1494. var pvb = Math.floor( pvminmax[0]*19/20 );
  1495. var pvh = pvminmax[1];
  1496. }
  1497. else {
  1498. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1499. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1500. }
  1501. return vue ? ' ('+pvb+'-'+pvh+')' :
  1502. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1503. }
  1504.  
  1505. function insertButtonCdm(nextName,onClick,texte) {
  1506. if(texte==null) texte = 'Participer au bestiaire';
  1507. var nextNode = document.getElementsByName(nextName)[0];
  1508.  
  1509. var espace = document.createTextNode('\t');
  1510. insertBefore(nextNode,espace);
  1511.  
  1512. var button = document.createElement('input');
  1513. button.type = 'button';
  1514. button.className = 'mh_form_submit';
  1515. button.value = texte;
  1516. button.onmouseover = function(){this.style.cursor='pointer';};
  1517. if(onClick) button.onclick = onClick;
  1518. insertBefore(espace,button);
  1519. return button;
  1520. }
  1521.  
  1522. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1523. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1524. 'Capacité spéciale','Résistance Magique','Autres'];
  1525.  
  1526. function createImageTactique(url,id,nom) {
  1527. var img = document.createElement('img');
  1528. img.src = url;
  1529. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1530. img.id = id;
  1531. img.nom = nom;
  1532. img.onmouseover = showPopupTactique;
  1533. img.onmouseout = hidePopup;
  1534. return img;
  1535. }
  1536.  
  1537. function createCDMTable(id,nom,donneesMonstre) {
  1538. try {
  1539. var urlImg = URL_MZimg;
  1540. var table = document.createElement('table');
  1541. var profilActif = isProfilActif();
  1542. table.className = 'mh_tdborder';
  1543. table.border = 0;
  1544. table.cellSpacing = 1;
  1545. table.cellPadding = 4;
  1546. var thead = document.createElement('thead');
  1547. var tr = appendTr(thead,'mh_tdtitre');
  1548. var td = appendTdText(tr,
  1549. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1550. true
  1551. );
  1552. td.colSpan = 2;
  1553. table.appendChild(thead);
  1554. var tbody = document.createElement('tbody');
  1555. table.appendChild(tbody);
  1556. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1557. createCase(listeTitres[i],tbody,80);
  1558. }
  1559. var TypeMonstre = getEM(nom);
  1560. var infosCompo='';
  1561. if(TypeMonstre!='') {
  1562. infosCompo = compoEM(TypeMonstre);
  1563. }
  1564. var nodes = tbody.childNodes;
  1565. nodes[0].childNodes[1].innerHTML =
  1566. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1567. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1568. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1569. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1570. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1571. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1572. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1573. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1574. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1575. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1576. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1577. td = createCase(listeTitres[10],tbody);
  1578. td.innerHTML = bbcode(donneesMonstre[10]);
  1579. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1580. td.appendChild(document.createTextNode(" "));
  1581. if(donneesMonstre[16] == "De zone")
  1582. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1583. else if(donneesMonstre[16] == "Automatique")
  1584. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1585. else if(donneesMonstre[16] == "Au toucher")
  1586. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1587. }
  1588. }
  1589. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1590. {
  1591. td = createCase(listeTitres[11],tbody);
  1592. td.innerHTML = bbcode(donneesMonstre[9]);
  1593. // seuil de résistance du monstre
  1594. var lb = td.getElementsByTagName('b');
  1595. if(lb.length == 1) {
  1596. var mrm = lb[0].firstChild.nodeValue * 1;
  1597. var v = (mrm / mmTroll);
  1598. lb[0].firstChild.nodeValue += " ("
  1599. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1600. }
  1601. }
  1602. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1603. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1604. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1605. {
  1606. td = createCase(listeTitres[12],tbody);
  1607. if(donneesMonstre[12]==1)
  1608. {
  1609. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1610. }
  1611. if(donneesMonstre[13]==1)
  1612. {
  1613. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1614. }
  1615. else if(donneesMonstre[13]==0)
  1616. {
  1617. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1618. }
  1619. if(donneesMonstre[14]==1)
  1620. {
  1621. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1622. }
  1623. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1624. {
  1625. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1626. }
  1627. else if(donneesMonstre[14]>6)
  1628. {
  1629. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1630. }
  1631. if(donneesMonstre[15]=="Lente")
  1632. {
  1633. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1634. }
  1635. else if(donneesMonstre[15]=="Normale")
  1636. {
  1637. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1638. }
  1639. else if(donneesMonstre[15]=="Rapide")
  1640. {
  1641. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1642. }
  1643. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1644. {
  1645. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1646. }
  1647. if(infosCompo.length>0)
  1648. {
  1649. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1650. }
  1651. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1652. {
  1653. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1654. }
  1655. }
  1656. // pourcentage de blessure
  1657. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1658. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1659. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1660. if(pvs)
  1661. lb[0].firstChild.nodeValue += pvs;
  1662. }
  1663. return table;
  1664. }
  1665. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  1666. }
  1667.  
  1668.  
  1669. /*-[functions]------------ Gestion des enchantements -------------------------*/
  1670.  
  1671. var listeMonstreEnchantement = null,
  1672. listeEquipementEnchantement = null,
  1673. listeInfoEnchantement = null;
  1674.  
  1675. function computeCompoEnchantement()
  1676. {
  1677. listeMonstreEnchantement = new Array();
  1678. listeInfoEnchantement = new Array();
  1679. listeEquipementEnchantement = new Array();
  1680. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  1681. for(var i=0;i<liste.length;i++)
  1682. {
  1683. var idEquipement = liste[i]*1;
  1684. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  1685. continue;
  1686. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  1687. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  1688. var texteGlobal='';
  1689. for(var j=0;j<3;j++)
  1690. {
  1691. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  1692. listeMonstreEnchantement[infoComposant[2]] = 1;
  1693. var array = new Array();
  1694. array[0]=infoComposant[0].replace("Ril","Œil");
  1695. array[1]=infoComposant[1];
  1696. array[2]=infoComposant[2];
  1697. array[3]=getQualite(infoComposant[3]);
  1698. var texte = infoComposant[4].replace("Ril","Œil");
  1699. for(var k=5;k<infoComposant.length;k++)
  1700. {
  1701. texte += ";"+infoComposant[k].replace("Ril","Œil");
  1702. }
  1703. texteGlobal+=texte+'\n';
  1704. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1705. array[4]=texte;
  1706. listeInfoEnchantement.push(array);
  1707. }
  1708. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1709. listeEquipementEnchantement[idEquipement] = texteGlobal;
  1710. }
  1711. }
  1712.  
  1713. function isEnchant(nom) {
  1714. var monstreEnchant = '';
  1715. for(j in listeInfoEnchantement) {
  1716. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1717. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1718. monstreEnchant=monstre;
  1719. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  1720. }
  1721. }
  1722. return trim(monstreEnchant);
  1723. }
  1724.  
  1725. function getInfoEnchantementFromMonstre(nom)
  1726. {
  1727. try
  1728. {
  1729. if(!listeMonstreEnchantement)
  1730. {
  1731. computeCompoEnchantement();
  1732. }
  1733. var infosEnchant = '';
  1734. for(j in listeInfoEnchantement) {
  1735. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1736. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1737. if(infosEnchant=='')
  1738. infosEnchant=listeInfoEnchantement[j][4];
  1739. else
  1740. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  1741. }
  1742. }
  1743. return trim(infosEnchant);
  1744. }
  1745. catch(e)
  1746. {
  1747. window.alert(e);
  1748. }
  1749. }
  1750.  
  1751. function composantEnchant(Monstre,composant,localisation,qualite) {
  1752. var compo='';
  1753. for(var i=0; i<listeInfoEnchantement.length; i++) {
  1754. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  1755. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  1756. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  1757. listeInfoEnchantement[i][3]<=qualite
  1758. ) {
  1759. return listeInfoEnchantement[i][4];
  1760. }
  1761. }
  1762. return compo;
  1763. }
  1764.  
  1765. function insertEnchantInfos(tbody) {
  1766. try
  1767. {
  1768. if(!listeMonstreEnchantement)
  1769. computeCompoEnchantement();
  1770. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  1771. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1772. if(nodes.snapshotLength == 0)
  1773. return false;
  1774. var urlImg = URL_MZimg + 'enchant.png';
  1775. for(var i = 0; i < nodes.snapshotLength; i++) {
  1776. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  1777. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  1778. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  1779. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  1780. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  1781. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  1782. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  1783. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  1784. if(isEnchant(nomMonstre).length>0)
  1785. {
  1786. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  1787. if(infos.length>0)
  1788. {
  1789. if(link.parentNode == link.nextSibling.parentNode)
  1790. {
  1791. var tmp = link.nextSibling;
  1792. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  1793. }
  1794. else
  1795. {
  1796. link.parentNode.appendChild(createImage(urlImg,infos));
  1797. }
  1798. }
  1799. }
  1800. }
  1801. }
  1802. catch(e)
  1803. {
  1804. window.alert(e);
  1805. }
  1806. }
  1807.  
  1808. function computeEnchantementEquipement(fontionTexte,formateTexte)
  1809. {
  1810. try
  1811. {
  1812. if(!listeMonstreEnchantement)
  1813. computeCompoEnchantement();
  1814. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  1815. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1816. if(nodes.snapshotLength == 0)
  1817. return false;
  1818. var urlImg = URL_MZimg + 'enchant.png';
  1819. for(var i = 0; i < nodes.snapshotLength; i++)
  1820. {
  1821. var link = nodes.snapshotItem(i);
  1822. var idEquipement = link.getAttribute('href');
  1823. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  1824. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  1825. var nomEquipement = trim(link.firstChild.nodeValue);
  1826. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  1827. if(!enchanteur || enchanteur == '')
  1828. continue;
  1829. var infos = listeEquipementEnchantement[idEquipement];
  1830. infos=formateTexte(infos);
  1831. if(infos.length>0)
  1832. {
  1833. if(link.parentNode == link.nextSibling.parentNode)
  1834. {
  1835. var tmp = link.nextSibling;
  1836. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  1837. }
  1838. else
  1839. {
  1840. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  1841. }
  1842. }
  1843. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  1844. }
  1845. }
  1846. catch(e)
  1847. {
  1848. window.alert(e);
  1849. }
  1850. }
  1851.  
  1852. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  1853.  
  1854.  
  1855. // Les % de toucher
  1856. var c = new Array();
  1857.  
  1858. // coefficients binomiaux
  1859. function cnp(n,k)
  1860. {
  1861. if(c[n] != null && c[n][k] != null)
  1862. return c[n][k];
  1863. if(c[n] == null)
  1864. c[n] = new Array();
  1865. if(k==0)
  1866. {
  1867. c[n][k] = 1;
  1868. return 1;
  1869. }
  1870. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  1871. c[n][k] = result;
  1872. // Roule debug
  1873. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  1874. return result;
  1875. }
  1876.  
  1877. // by Dab, à comparer
  1878. function binom(n,p) {
  1879. if(p<0 || p>n) return 0;
  1880. if(c[n])
  1881. if(c[n][p]) return c[n][p];
  1882. else {
  1883. c[n]=[1];
  1884. c[n][n]=1;
  1885. if(p==0 || p==n) return 1;
  1886. }
  1887. if(2*p>n)
  1888. c[n][p]=binom(n,n-p);
  1889. else
  1890. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  1891. return c[n][p];
  1892. }
  1893.  
  1894. var coeff = new Array();
  1895.  
  1896. function coef(n,p)
  1897. {
  1898. if(n==0 && p==0)
  1899. return 1;
  1900. if(p>n*3.5)
  1901. p = 7*n-p
  1902. // roule désactive cache
  1903. if(coeff[n] != null && coeff[n][p] !=null)
  1904. return coeff[n][p];
  1905. if(coeff[n] == null)
  1906. coeff[n] = new Array();
  1907. var kmax = Math.floor((p-n)/6);
  1908. var x=0;
  1909. for(var k=0;k<=kmax;k++)
  1910. {
  1911. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  1912. }
  1913. coeff[n][p] = x;
  1914. // Roule debug
  1915. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  1916. return x;
  1917. }
  1918.  
  1919. function chanceEsquiveParfaite(a,d,ba,bd)
  1920. {
  1921. var win = 0;
  1922. var los = 0;
  1923. if(ba==null)
  1924. ba=0;
  1925. if(bd==null)
  1926. bd=0;
  1927. /* if(6*a+ba<2*(d+bd))
  1928. return 100;
  1929. if(a+ba>2*(6*d+bd))
  1930. return 0;*/
  1931. for(var ds=d;ds<=6*d;ds++)
  1932. {
  1933. var cd = coef(d,ds);
  1934. for(var as=a;as<=6*a;as++)
  1935. {
  1936. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  1937. win += cd * coef(a,as);
  1938. else
  1939. los += cd * coef(a,as);
  1940. }
  1941. }
  1942. // roule debug
  1943. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  1944. return Math.round(100*win/(win+los));
  1945. }
  1946.  
  1947. function chanceTouche(a,d,ba,bd)
  1948. {
  1949. var win = 0;
  1950. var los = 0;
  1951. if(ba==null)
  1952. ba=0;
  1953. if(bd==null)
  1954. bd=0;
  1955. if(a+ba>6*d+bd)
  1956. return 100;
  1957. if(6*a+ba<d+bd)
  1958. return 0;
  1959. for(var ds=d;ds<=6*d;ds++)
  1960. {
  1961. var cd = coef(d,ds);
  1962. for(var as=a;as<=6*a;as++)
  1963. {
  1964. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  1965. win += cd * coef(a,as);
  1966. else
  1967. los += cd * coef(a,as);
  1968. }
  1969. }
  1970. return Math.round(100*win/(win+los));
  1971. }
  1972.  
  1973. function chanceCritique(a,d,ba,bd)
  1974. {
  1975. var win = 0;
  1976. var los = 0;
  1977. if(ba==null)
  1978. ba=0;
  1979. if(bd==null)
  1980. bd=0;
  1981. if(a+ba>2*(6*d+bd))
  1982. return 100;
  1983. if(6*a+ba<2*(d+bd))
  1984. return 0;
  1985. for(var ds=d;ds<=6*d;ds++)
  1986. {
  1987. var cd = coef(d,ds);
  1988. for(var as=a;as<=6*a;as++)
  1989. {
  1990. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  1991. win += cd * coef(a,as);
  1992. else
  1993. los += cd * coef(a,as);
  1994. }
  1995. }
  1996. return Math.round(100*win/(win+los));
  1997. }
  1998.  
  1999. /***********************************************
  2000. Analyse tactique
  2001. ***********************************************/
  2002.  
  2003. function getTexteAnalyse(modificateur,chiffre)
  2004. {
  2005. if(chiffre==0)
  2006. return chiffre;
  2007. return modificateur+chiffre;
  2008. }
  2009.  
  2010. function getAnalyseTactique(id,nom)
  2011. {
  2012. var donneesMonstre = listeCDM[id];
  2013. var needAutres=false;
  2014. var i;
  2015. if(donneesMonstre == null)
  2016. return;
  2017. var array = analyseTactique(donneesMonstre,nom);
  2018. if(array==null)
  2019. return "";
  2020. 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>";
  2021. for(i=0;i<array.length;i++)
  2022. {
  2023. if(array[i][1]==100 && i>0)
  2024. {
  2025. needAutres=true;
  2026. break;
  2027. }
  2028. if(i==1 && array[i][4]>0)
  2029. 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>";
  2030. else if(i==0)
  2031. 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>";
  2032. else
  2033. 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>";
  2034. }
  2035. if(needAutres)
  2036. {
  2037. if(i==array.length-1)
  2038. 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>";
  2039. else if(i==1)
  2040. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2041. else
  2042. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2043. }
  2044. return str+"</table>";
  2045. }
  2046.  
  2047. function analyseTactique(donneesMonstre,nom) {
  2048. try
  2049. {
  2050. var listeAttaques = [];
  2051. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2052. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2053. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2054. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2055. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2056. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2057. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2058. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2059. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2060. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2061. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2062. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2063. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2064. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2065. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2066. var modificateurEsquive = '';
  2067. var modificateurArmure = '';
  2068. var modificateurMagie = '';
  2069. var modificateurEsquiveM = '';
  2070. var modificateurArmureM = '';
  2071. var pasDeSR=false;
  2072. var esqM,attM,armM,degM;
  2073. 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)
  2074. return null;
  2075. var td = document.createElement('td')
  2076. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2077. var esqM = 0;
  2078. try
  2079. {
  2080. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2081. }
  2082. catch(e)
  2083. {
  2084. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2085. modificateurEsquive = '<';
  2086. modificateurArmure = '<';
  2087. modificateurMagie = '<';
  2088. }
  2089. td.innerHTML = bbcode(donneesMonstre[3]);
  2090. var attM = 0;
  2091. try
  2092. {
  2093. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2094. }
  2095. catch(e)
  2096. {
  2097. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2098. modificateurEsquiveM = '>';
  2099. modificateurArmureM = '>';
  2100. }
  2101. td.innerHTML = bbcode(donneesMonstre[5]);
  2102. var degM = 0;
  2103. try
  2104. {
  2105. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2106. }
  2107. catch(e)
  2108. {
  2109. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2110. modificateurArmureM = '>';
  2111. }
  2112. td.innerHTML = bbcode(donneesMonstre[7]);
  2113. var armM = 0;
  2114. try
  2115. {
  2116. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2117. }
  2118. catch(e)
  2119. {
  2120. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2121. modificateurArmure = '<';
  2122. }
  2123. var coeffSeuil = 0.95;
  2124. try
  2125. {
  2126. td.innerHTML = bbcode(donneesMonstre[9]);
  2127. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2128. var v = (rm / mm);
  2129. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2130. coeffSeuil = (200-seuil)/200;
  2131. }
  2132. catch(e)
  2133. {
  2134. modificateurMagie = '<';
  2135. pasDeSR = true;
  2136. }
  2137. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2138. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2139. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2140. // roule debug
  2141. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2142. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2143. 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);
  2144. //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);
  2145. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2146. if(getSortComp("Vampirisme")>0)
  2147. {
  2148. var pour = getSortComp("Vampirisme");
  2149. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2150. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2151. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2152. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2153. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2154. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2155. }
  2156. if(getSortComp("Botte Secrète")>0)
  2157. {
  2158. var pour = getSortComp("Botte Secrète");
  2159. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2160. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2161. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2162. 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;
  2163. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2164. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2165. }
  2166. if(getSortComp("Rafale Psychique")>0)
  2167. {
  2168. var pour = getSortComp("Rafale Psychique");
  2169. chanceDEsquiveParfaite = 0;
  2170. chanceDeTouche = Math.round(100*pour/100);
  2171. chanceDeCritique = Math.round(0*pour/100);
  2172. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2173. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2174. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2175. }
  2176. if(getSortComp("Explosion")>0)
  2177. {
  2178. var pour = getSortComp("Explosion");
  2179. chanceDEsquiveParfaite = 0;
  2180. chanceDeTouche = Math.round(100*pour/100);
  2181. chanceDeCritique = Math.round(0*pour/100);
  2182. 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;
  2183. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2184. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2185. }
  2186. if(getSortComp("Projectile Magique")>0)
  2187. {
  2188. var pour = getSortComp("Projectile Magique");
  2189. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2190. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2191. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2192. 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;
  2193. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2194. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2195. }
  2196. if(getSortComp("Frénésie")>0)
  2197. {
  2198. var pour = getSortComp("Frénésie");
  2199. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2200. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2201. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2202. 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;
  2203. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2204. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2205. }
  2206. if(getSortComp("Charger")>0)
  2207. {
  2208. var pour = getSortComp("Charger");
  2209. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2210. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2211. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2212. 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;
  2213. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2214. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2215. }
  2216. if(getSortComp("Griffe du Sorcier")>0)
  2217. {
  2218. var pour = getSortComp("Griffe du Sorcier");
  2219. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2220. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2221. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2222. 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;
  2223. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2224. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2225. }
  2226. if(getSortComp("Attaque Précise",1)>0)
  2227. {
  2228. var niveau = 5;
  2229. var oldPour = 0;
  2230. var chanceDEsquiveParfaite = 0;
  2231. var chanceDeTouche = 0;
  2232. var chanceDeCritique = 0;
  2233. degats = 0;
  2234. while(niveau>0)
  2235. {
  2236. var pour = getSortComp("Attaque Précise",niveau);
  2237. if(pour>oldPour)
  2238. {
  2239. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2240. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2241. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2242. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2243. chanceDeTouche += chanceDeToucheNiveau;
  2244. chanceDeCritique += chanceDeCritiqueNiveau;
  2245. 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);
  2246. oldPour = pour;
  2247. }
  2248. niveau--;
  2249. }
  2250. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2251. 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));
  2252. }
  2253. if(getSortComp("Coup de Butoir",1)>0)
  2254. {
  2255. var niveau = 5;
  2256. var oldPour =0;
  2257. var chanceDEsquiveParfaite = 0;
  2258. var chanceDeTouche=0;
  2259. var chanceDeCritique=0;
  2260. degats=0;
  2261. while(niveau>0)
  2262. {
  2263. var pour = getSortComp("Coup de Butoir",niveau);
  2264. if(pour>oldPour)
  2265. {
  2266. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2267. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2268. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2269. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2270. chanceDeTouche += chanceDeToucheNiveau;
  2271. chanceDeCritique += chanceDeCritiqueNiveau;
  2272. 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);
  2273. oldPour = pour;
  2274. }
  2275. niveau--;
  2276. }
  2277. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2278. 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));
  2279. }
  2280. 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;});
  2281. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2282. {
  2283. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2284. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2285. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2286. }
  2287. else
  2288. {
  2289. chanceDEsquiveParfaite = 0;
  2290. chanceDeTouche = 100;
  2291. chanceDeCritique = 0;
  2292. }
  2293. 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;
  2294.  
  2295. 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));
  2296. return listeAttaques;
  2297. }
  2298. catch(e) { window.alert(e);}
  2299. }
  2300.  
  2301. // x~~x marque pour s'y retrouver sous l'éditeur
  2302.  
  2303. /*
  2304. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2305. * published under GNU License v2.
  2306. *
  2307. * Patch :
  2308. * gestion des missions terminées
  2309. */
  2310. // x~x mission_liste
  2311.  
  2312. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2313. try {
  2314. var titresMimis = document.evaluate(
  2315. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2316. document, null, 7, null
  2317. );
  2318. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2319. } catch(e) {
  2320. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2321. return;
  2322. }
  2323. var enCours = {};
  2324. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2325. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2326. enCours[num] = true;
  2327. }
  2328. for(var numMimi in obMissions) {
  2329. if(!enCours[numMimi]) {
  2330. delete obMissions[numMimi];
  2331. }
  2332. }
  2333. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2334. }
  2335.  
  2336. function do_mission_liste() {
  2337. checkLesMimis();
  2338. }
  2339.  
  2340. /*******************************************************************************
  2341. * This file is part of Mountyzilla. *
  2342. * *
  2343. * Mountyzilla is free software; you can redistribute it and/or modify *
  2344. * it under the terms of the GNU General Public License as published by *
  2345. * the Free Software Foundation; either version 2 of the License, or *
  2346. * (at your option) any later version. *
  2347. * *
  2348. * Mountyzilla is distributed in the hope that it will be useful, *
  2349. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2350. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2351. * GNU General Public License for more details. *
  2352. * *
  2353. * You should have received a copy of the GNU General Public License *
  2354. * along with Mountyzilla; if not, write to the Free Software *
  2355. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2356. *******************************************************************************/
  2357.  
  2358. // x~x actions
  2359.  
  2360. /* TODO
  2361. * getLvl pour Explo, Rotobaffe et cie
  2362. */
  2363.  
  2364.  
  2365.  
  2366. /* Page de combat */
  2367.  
  2368. function getLevel() {
  2369. var divList = document.getElementsByTagName('div');
  2370. if(divList.length <= 2)
  2371. return;
  2372. // On essaie de voir si cette action était une attaque
  2373. var pList = document.getElementsByTagName('p');
  2374. var nomM = '';
  2375. // Modification pour Frénésie by TetDure
  2376. var numAtt = 0;
  2377. for (var i = 0; i < pList.length; i++) {
  2378. if(pList[i].firstChild) {
  2379. nomM = pList[i].firstChild.nodeValue;
  2380. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2381. numAtt++;
  2382. }
  2383. }
  2384. if(nomM == '')
  2385. return;
  2386. // Si c'est une attaque normale, un seul PX
  2387. var comPX = 1;
  2388. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2389. comPX++;
  2390.  
  2391. // Extraction des infos du monstre attaqué
  2392. var idM;
  2393. var male;
  2394. if(nomM.slice(20, 21) == 'e') {
  2395. male = false;
  2396. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2397. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2398. }
  2399. else {
  2400. male = true;
  2401. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2402. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2403. }
  2404. if(idM == '')
  2405. return;
  2406. var bList = document.getElementsByTagName('b');
  2407. var niveau = '';
  2408. for (var i = 0; i < bList.length; i++) {
  2409. var b = bList[i];
  2410. if(b.childNodes[0].nodeValue != "TUÉ")
  2411. continue;
  2412. var nbPX = "";
  2413. for (i++; i < bList.length; i++) {
  2414. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2415. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2416. return;
  2417. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2418. nbPX = bList[i].childNodes[0].nodeValue;
  2419. break;
  2420. }
  2421. }
  2422. if(nbPX == '')
  2423. return;
  2424. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2425. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2426. if(!nbPX)
  2427. nbPX = 0;
  2428. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2429. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2430. if(comPX > nbPX) {
  2431. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2432. niveau = "";
  2433. } else if(Math.floor(niveau) == niveau) {
  2434. chaine += niveau + ".";
  2435. } else {
  2436. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2437. niveau = "";
  2438. }
  2439. insertBr(b.nextSibling.nextSibling.nextSibling);
  2440. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2441. }
  2442.  
  2443. if(niveau != '') {
  2444. var button = insertButtonCdm('as_Action');
  2445. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2446. + escape(nomM) + "&niveau=" + escape(niveau)
  2447. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2448. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2449. }
  2450. }
  2451.  
  2452.  
  2453. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2454.  
  2455. function insertInfoMagie(node, intitule, magie) {
  2456. if(node.nextSibling) {
  2457. node = node.nextSibling;
  2458. insertBr(node);
  2459. insertText(node, intitule);
  2460. insertText(node, magie, true);
  2461. } else {
  2462. node = node.parentNode;
  2463. appendBr(node);
  2464. appendText(node, intitule);
  2465. appendText(node, magie, true);
  2466. }
  2467. }
  2468.  
  2469. function getMM(sr) {
  2470. if(rmTroll<=0) {
  2471. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2472. }
  2473. sr = Number(sr.match(/\d+/)[0]);
  2474. if(sr==10) {
  2475. return '\u2265 '+5*rmTroll;
  2476. }
  2477. if(sr<=50) {
  2478. return Math.round(50*rmTroll/sr);
  2479. }
  2480. if(sr<90) {
  2481. return Math.round((100-sr)*rmTroll/50);
  2482. }
  2483. return '\u2264 '+Math.round(rmTroll/5);
  2484. }
  2485.  
  2486. function traiteMM() {
  2487. var node = document.evaluate(
  2488. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2489. document, null, 9, null).singleNodeValue;
  2490. if(node) {
  2491. var mm = getMM(node.nodeValue);
  2492. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2493. } else {
  2494. var node = document.evaluate(
  2495. "//p/text()[contains(., 'Seuil de Résistance')]",
  2496. document, null, 9, null).singleNodeValue;
  2497. if(!node) {
  2498. return;
  2499. }
  2500. var mm = getMM(node.nodeValue);
  2501. node = node.nextSibling.nextSibling;
  2502. }
  2503. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2504. }
  2505.  
  2506. function getRM(sr) {
  2507. if(mmTroll<=0) {
  2508. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2509. }
  2510. sr = Number(sr.match(/\d+/)[0]);
  2511. if(sr==10) {
  2512. return '\u2264 '+Math.round(mmTroll/5);
  2513. }
  2514. if(sr<=50) {
  2515. return Math.round(sr*mmTroll/50);
  2516. }
  2517. if(sr<90) {
  2518. return Math.round(50*mmTroll/(100-sr));
  2519. }
  2520. return '\u2265 '+5*mmTroll;
  2521. }
  2522.  
  2523. function traiteRM() {
  2524. var nodes = document.evaluate(
  2525. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2526. document, null, 7, null);
  2527. if(nodes.snapshotLength==0) {
  2528. return;
  2529. }
  2530. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2531. var node = nodes.snapshotItem(i);
  2532. var rm = getRM(node.nodeValue);
  2533. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2534. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2535. }
  2536. }
  2537.  
  2538.  
  2539. /* Fonction stats IdT par Raistlin */
  2540. /*function getIdt() {
  2541. if(MY_getValue("SEND_IDT") == "non")
  2542. return false;
  2543. var regExpBeginning = /^\s+/;
  2544. var regExpEnd = /\s+$/;
  2545.  
  2546. var nomIdt = document.evaluate(
  2547. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2548. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2549. if(!nomIdt)
  2550. return false;
  2551.  
  2552. var caracIdt;
  2553. if(nomIdt.indexOf("Malédiction !") != -1) {
  2554. caracIdt = "";
  2555. nomIdt = "Mission maudite";
  2556. } else {
  2557. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2558. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2559. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2560. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2561. }
  2562. FF_XMLHttpRequest({
  2563. method: 'GET',
  2564. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2565. headers : {
  2566. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2567. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2568. }
  2569. });
  2570. return true;
  2571. }*/
  2572.  
  2573.  
  2574. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2575.  
  2576. function confirmeDecalage() {
  2577. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2578. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2579. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2580. var newDLA = new Date( oldDLA );
  2581. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2582. return window.confirm(
  2583. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2584. +'\nConfirmez-vous ce décalage ?'
  2585. );
  2586. }
  2587.  
  2588. function newsubmitDLA(evt) {
  2589. evt.stopPropagation();
  2590. evt.preventDefault();
  2591. if(confirmeDecalage()) {
  2592. this.submit();
  2593. }
  2594. }
  2595.  
  2596. function changeActionDecalage() {
  2597. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2598. return;
  2599. }
  2600. try {
  2601. // On récupère le contenu du script JS MH de calcul du décalage
  2602. var scriptTxt = document.evaluate(
  2603. ".//script[ not(@src) ]",
  2604. document, null, 9, null
  2605. ).singleNodeValue.textContent;
  2606. // On en extrait la DLA courante
  2607. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2608. scriptTxt = scriptTxt.split('\n')[0];
  2609. var nbs = scriptTxt.match(/\d+/g);
  2610. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2611. } catch(e) {
  2612. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2613. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  2614. return;
  2615. }
  2616. var form = document.getElementsByName('ActionForm')[0];
  2617. if(form) {
  2618. form.addEventListener('submit', newsubmitDLA, true);
  2619. } else {
  2620. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2621. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2622. }
  2623. }
  2624.  
  2625. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2626.  
  2627. function prochainMundi() {
  2628. try {
  2629. var node = document.evaluate(
  2630. "//div[@class='dateAction']/b",
  2631. document, null, 9, null
  2632. ).singleNodeValue;
  2633. } catch(e) {
  2634. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  2635. return;
  2636. }
  2637. if(!node) { return; }
  2638.  
  2639. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2640. var jour = longueurMois+1-getNumber(node.textContent);
  2641. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2642. var txt = '[Prochain Mundidey ';
  2643. if(jour>1) {
  2644. txt += 'dans '+jour+' jours]';
  2645. } else {
  2646. txt += 'demain]';
  2647. }
  2648. insertText(node.parentNode.nextSibling,txt,true);
  2649. }
  2650.  
  2651.  
  2652. /* Fonction principale */
  2653.  
  2654. function dispatch() {
  2655. if(isPage('MH_Play/Play_action')) {
  2656. prochainMundi();
  2657. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2658. var oldDLA;
  2659. changeActionDecalage();
  2660. } else if(isPage('MH_Play/Actions')) {
  2661. if(document.evaluate(
  2662. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  2663. document, null, 2, null
  2664. ).stringValue) {
  2665. traiteMM();
  2666. } else if(document.evaluate(
  2667. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  2668. document, null, 2, null
  2669. ).stringValue) {
  2670. //getIdt();
  2671. traiteRM();
  2672. } /*else {
  2673. // Est censé se lancer sur quoi *précisément* ?
  2674. traiteRM();
  2675. getLevel();
  2676. }*/
  2677. } else {
  2678. /* Traitement des messages du bot */
  2679. var messageTitle = document.evaluate(
  2680. "//form/table/tbody/tr[1]/td[1]/"
  2681. +"descendant::text()[contains(.,'[MountyHall]')]",
  2682. document, null, 2, null
  2683. ).stringValue;
  2684. if(messageTitle.indexOf('Attaquant') != -1 &&
  2685. messageTitle.indexOf('sur') != -1) {
  2686. getLevel();
  2687. traiteRM();
  2688. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  2689. messageTitle.indexOf('Défenseur') != -1) {
  2690. traiteMM();
  2691. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  2692. // à replacer avec Attaque après révision getLvl :
  2693. messageTitle.indexOf('Explosion') != -1 ||
  2694. messageTitle.indexOf('Insulte') != -1) {
  2695. traiteRM();
  2696. }
  2697. }
  2698. }
  2699.  
  2700. function do_actions() {
  2701. start_script(31);
  2702. dispatch();
  2703. displayScriptTime();
  2704. }
  2705.  
  2706. /*********************************************************************************
  2707. * This file is part of Mountyzilla. *
  2708. * *
  2709. * Mountyzilla is free software; you can redistribute it and/or modify *
  2710. * it under the terms of the GNU General Public License as published by *
  2711. * the Free Software Foundation; either version 2 of the License, or *
  2712. * (at your option) any later version. *
  2713. * *
  2714. * Mountyzilla is distributed in the hope that it will be useful, *
  2715. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2716. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2717. * GNU General Public License for more details. *
  2718. * *
  2719. * You should have received a copy of the GNU General Public License *
  2720. * along with Mountyzilla; if not, write to the Free Software *
  2721. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2722. *********************************************************************************/
  2723.  
  2724. // x~x pre-enchant
  2725.  
  2726. /* 2013-08-19 : correction auto syntaxe alert */
  2727.  
  2728. var combobox=null;
  2729.  
  2730. function changeObject()
  2731. {
  2732. if(!combobox)
  2733. return ;
  2734. var id = combobox.options[combobox.selectedIndex].value;
  2735. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  2736. if(!id || id=="")
  2737. {
  2738. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2739. return;
  2740. }
  2741. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  2742. }
  2743.  
  2744. function treatePreEnchantement() {
  2745. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2746. if(!input || input.getAttribute("type")=="hidden")
  2747. {
  2748. return false;
  2749. }
  2750. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  2751. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2752. if(!combobox)
  2753. {
  2754. return true;
  2755. }
  2756. combobox.addEventListener('change', changeObject, true);
  2757. return true;
  2758. }
  2759.  
  2760. function treateEnchantement() {
  2761. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2762. if(!input || input.getAttribute("type")!="hidden")
  2763. {
  2764. return false;
  2765. }
  2766. var idEquipement = input.getAttribute("value");
  2767. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  2768. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  2769. if(enchanteur && enchanteur != null)
  2770. return true;
  2771. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2772. if(!input || input.getAttribute("type")!="hidden")
  2773. {
  2774. return false;
  2775. }
  2776. var idEnchanteur = input.getAttribute("value");
  2777. var nodes = document.evaluate(
  2778. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2779. if (nodes.snapshotLength != 3)
  2780. return;
  2781. for(var i=0;i<3;i++)
  2782. {
  2783. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2784. texte = texte.replace(" d'une "," d'un ");
  2785. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2786. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2787. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2788. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2789. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2790. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2791. }
  2792. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2793. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2794. var liste = MY_getValue(numTroll+".enchantement.liste");
  2795. if(!liste || liste=="")
  2796. {
  2797. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2798. }
  2799. else
  2800. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2801. }
  2802.  
  2803. function do_pre_enchant() {
  2804. start_script(60);
  2805. if(!treatePreEnchantement())
  2806. treateEnchantement();
  2807. displayScriptTime();
  2808. }
  2809.  
  2810. /*********************************************************************************
  2811. * This file is part of Mountyzilla. *
  2812. * *
  2813. * Mountyzilla is free software; you can redistribute it and/or modify *
  2814. * it under the terms of the GNU General Public License as published by *
  2815. * the Free Software Foundation; either version 2 of the License, or *
  2816. * (at your option) any later version. *
  2817. * *
  2818. * Mountyzilla is distributed in the hope that it will be useful, *
  2819. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2820. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2821. * GNU General Public License for more details. *
  2822. * *
  2823. * You should have received a copy of the GNU General Public License *
  2824. * along with Mountyzilla; if not, write to the Free Software *
  2825. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2826. *********************************************************************************/
  2827.  
  2828. // x~x enchant
  2829.  
  2830. /* 2013-08-19 : correction auto syntaxe alert */
  2831.  
  2832. function treateEnchantement() {
  2833. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  2834. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  2835. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  2836. return;
  2837. var tab = infoEquipement.split(";");
  2838. if(tab.length<2)
  2839. return;
  2840. var idEquipement = tab[0];
  2841. var nomEquipement = tab[1];
  2842. for(var i=2;i<tab.length;i++)
  2843. nomEquipement += ";"+tab[i];
  2844. var nodes = document.evaluate(
  2845. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2846. if (nodes.snapshotLength != 3)
  2847. return;
  2848. for(var i=0;i<3;i++)
  2849. {
  2850. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2851. texte = texte.replace(" d'une "," d'un ");
  2852. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2853. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2854. monstre = monstre.replace(/ Géante?/,"");
  2855. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2856. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2857. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2858. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2859. }
  2860. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2861. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2862. var liste = MY_getValue(numTroll+".enchantement.liste");
  2863. if(!liste || liste=="")
  2864. {
  2865. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2866. }
  2867. else
  2868. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2869. }
  2870.  
  2871. function do_enchant() {
  2872. start_script(60);
  2873.  
  2874. treateEnchantement();
  2875. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2876. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  2877. displayScriptTime();
  2878. }
  2879.  
  2880. /*********************************************************************************
  2881. * This file is part of Mountyzilla. *
  2882. * *
  2883. * Mountyzilla is free software; you can redistribute it and/or modify *
  2884. * it under the terms of the GNU General Public License as published by *
  2885. * the Free Software Foundation; either version 2 of the License, or *
  2886. * (at your option) any later version. *
  2887. * *
  2888. * Mountyzilla is distributed in the hope that it will be useful, *
  2889. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2890. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2891. * GNU General Public License for more details. *
  2892. * *
  2893. * You should have received a copy of the GNU General Public License *
  2894. * along with Mountyzilla; if not, write to the Free Software *
  2895. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2896. *********************************************************************************/
  2897.  
  2898. // x~x myevent
  2899.  
  2900. // Script désactivé en attendant la màj vers le nouveau système de missions.
  2901. function do_myevent() {
  2902. }
  2903.  
  2904. /*********************************************************************************
  2905. * This file is part of Mountyzilla. *
  2906. * *
  2907. * Mountyzilla is free software; you can redistribute it and/or modify *
  2908. * it under the terms of the GNU General Public License as published by *
  2909. * the Free Software Foundation; either version 2 of the License, or *
  2910. * (at your option) any later version. *
  2911. * *
  2912. * Mountyzilla is distributed in the hope that it will be useful, *
  2913. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2914. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2915. * GNU General Public License for more details. *
  2916. * *
  2917. * You should have received a copy of the GNU General Public License *
  2918. * along with Mountyzilla; if not, write to the Free Software *
  2919. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2920. *********************************************************************************/
  2921.  
  2922. // x~x malus
  2923.  
  2924. /* v1.4 - 2014-01-06
  2925. * - Gestion des sorts double composante
  2926. * v1.4.1 - 2014-01-22
  2927. * - Correction décumul
  2928. * TODO
  2929. * - Identifier la position de "PV" dans l'ordre MH
  2930. */
  2931.  
  2932. var listeBM;
  2933.  
  2934.  
  2935. /* [functions] Utilitaires */
  2936.  
  2937. function decumul(bmt,nbr) {
  2938. var bmr;
  2939. if(!nbr || nbr<2) bmr = bmt;
  2940. else if(nbr==2) bmr = parseInt(0.67*bmt);
  2941. else if(nbr==3) bmr = parseInt(0.40*bmt);
  2942. else if(nbr==4) bmr = parseInt(0.25*bmt);
  2943. else if(nbr==5) bmr = parseInt(0.15*bmt);
  2944. else bmr = parseInt(0.1*bmt);
  2945. if(bmt<0) return Math.min(-1,bmr);
  2946. return Math.max(1,bmr);
  2947. }
  2948.  
  2949. function triecaracs(a,b) { // version Yoyor, mod by Dab
  2950. // Roule 23/11/2016 ajout PV
  2951. switch( a ) {
  2952. case 'ATT':
  2953. return -1;
  2954. case 'ESQ':
  2955. if(b=='ATT') return 1;
  2956. return -1;
  2957. case 'DEG':
  2958. switch( b ) {
  2959. case 'ATT':
  2960. case 'ESQ':
  2961. return 1;
  2962. default:
  2963. return -1;
  2964. }
  2965. case 'REG':
  2966. switch( b ) {
  2967. case 'ATT':
  2968. case 'ESQ':
  2969. case 'DEG':
  2970. return 1;
  2971. default:
  2972. return -1;
  2973. }
  2974. case 'Vue':
  2975. switch( b ) {
  2976. case 'ATT':
  2977. case 'ESQ':
  2978. case 'DEG':
  2979. case 'REG':
  2980. return 1;
  2981. default:
  2982. return -1;
  2983. }
  2984. case 'TOUR':
  2985. switch( b ) {
  2986. case 'ATT':
  2987. case 'ESQ':
  2988. case 'DEG':
  2989. case 'REG':
  2990. case 'Vue':
  2991. return 1;
  2992. default:
  2993. return -1;
  2994. }
  2995. case 'PV':
  2996. switch( b ) {
  2997. case 'ATT':
  2998. case 'ESQ':
  2999. case 'DEG':
  3000. case 'REG':
  3001. case 'Vue':
  3002. case 'TOUR':
  3003. return 1;
  3004. default:
  3005. return -1;
  3006. }
  3007. case 'Armure':
  3008. switch( b ) {
  3009. case 'ATT':
  3010. case 'ESQ':
  3011. case 'DEG':
  3012. case 'REG':
  3013. case 'Vue':
  3014. case 'TOUR':
  3015. case 'PV':
  3016. return 1;
  3017. default:
  3018. return -1;
  3019. }
  3020. case 'RM':
  3021. switch( b ) {
  3022. case 'ATT':
  3023. case 'ESQ':
  3024. case 'DEG':
  3025. case 'REG':
  3026. case 'Vue':
  3027. case 'TOUR':
  3028. case 'PV':
  3029. case 'Armure':
  3030. return 1;
  3031. default:
  3032. return -1;
  3033. }
  3034. case 'MM':
  3035. switch( b ) {
  3036. case 'ATT':
  3037. case 'ESQ':
  3038. case 'DEG':
  3039. case 'REG':
  3040. case 'Vue':
  3041. case 'TOUR':
  3042. case 'PV':
  3043. case 'Armure':
  3044. case 'RM':
  3045. return 1;
  3046. default:
  3047. return -1;
  3048. }
  3049. case 'Concentration':
  3050. switch( b ) {
  3051. case 'ATT':
  3052. case 'ESQ':
  3053. case 'DEG':
  3054. case 'REG':
  3055. case 'Vue':
  3056. case 'TOUR':
  3057. case 'PV':
  3058. case 'Armure':
  3059. case 'RM':
  3060. case 'MM':
  3061. return 1;
  3062. default:
  3063. return -1;
  3064. }
  3065. case 'Fatigue':
  3066. switch( b ) {
  3067. case 'ATT':
  3068. case 'ESQ':
  3069. case 'DEG':
  3070. case 'REG':
  3071. case 'Vue':
  3072. case 'TOUR':
  3073. case 'PV':
  3074. case 'Armure':
  3075. case 'RM':
  3076. case 'MM':
  3077. case 'Concentration':
  3078. return 1;
  3079. default:
  3080. return -1;
  3081. }
  3082. case "Dés d'attaque":
  3083. switch( b ) {
  3084. case 'ATT':
  3085. case 'ESQ':
  3086. case 'DEG':
  3087. case 'REG':
  3088. case 'Vue':
  3089. case 'TOUR':
  3090. case 'PV':
  3091. case 'Armure':
  3092. case 'RM':
  3093. case 'MM':
  3094. case 'Concentration':
  3095. case 'Fatigue':
  3096. return 1;
  3097. default:
  3098. return -1;
  3099. }
  3100. case 'Dés de dégâts':
  3101. switch( b ) {
  3102. case 'ATT':
  3103. case 'ESQ':
  3104. case 'DEG':
  3105. case 'REG':
  3106. case 'Vue':
  3107. case 'TOUR':
  3108. case 'PV':
  3109. case 'Armure':
  3110. case 'RM':
  3111. case 'MM':
  3112. case 'Concentration':
  3113. case 'Fatigue':
  3114. case "Dés d'attaque":
  3115. return 1;
  3116. default:
  3117. return -1;
  3118. }
  3119. default :
  3120. switch( b ) {
  3121. case 'ATT':
  3122. case 'ESQ':
  3123. case 'DEG':
  3124. case 'REG':
  3125. case 'Vue':
  3126. case 'TOUR':
  3127. case 'PV':
  3128. case 'Armure':
  3129. case 'RM':
  3130. case 'MM':
  3131. case 'Concentration':
  3132. case 'Fatigue':
  3133. case "Dés d'attaque":
  3134. case 'Dés de dégâts':
  3135. return 1;
  3136. default:
  3137. return -1;
  3138. }
  3139. }
  3140. }
  3141.  
  3142.  
  3143. /* [functions] Fonctions hide / display */
  3144.  
  3145. function toggleDetailsBM() {
  3146. if(MY_getValue('BMDETAIL')!='false') {
  3147. MY_setValue('BMDETAIL','false');
  3148. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3149. for(var i=0 ; i<trlist.length ; i++)
  3150. trlist[i].style.display = 'none';
  3151. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3152. for(var i=0 ; i<trlist.length ; i++)
  3153. trlist[i].style = '';
  3154. }
  3155. else {
  3156. MY_setValue('BMDETAIL','true');
  3157. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3158. for(var i=0 ; i<trlist.length ; i++)
  3159. trlist[i].style.display = 'none';
  3160. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3161. for(var i=0 ; i<trlist.length ; i++)
  3162. trlist[i].style = '';
  3163. }
  3164. }
  3165.  
  3166. function toggleBMList() {
  3167. if(MY_getValue('BMHIDELIST')=='true') {
  3168. MY_setValue('BMHIDELIST','false');
  3169. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3170. listeBM.snapshotItem(i).style = '';
  3171. document.getElementsByTagName('thead')[0].style = '';
  3172. document.getElementById('trhelp').style = '';
  3173. }
  3174. else {
  3175. MY_setValue('BMHIDELIST','true');
  3176. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3177. listeBM.snapshotItem(i).style.display = 'none';
  3178. document.getElementsByTagName('thead')[0].style.display = 'none';
  3179. document.getElementById('trhelp').style.display = 'none';
  3180. }
  3181. }
  3182.  
  3183. function setDisplayBM() {
  3184. if(!listeBM) return;
  3185. var titre = document.getElementById('titre2');
  3186. if(titre) {
  3187. titre.style.cursor = 'pointer';
  3188. titre.onclick = toggleBMList;
  3189. }
  3190. var tfoot = document.getElementsByTagName('tfoot')[0];
  3191. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3192. tfoot, null, 9, null).singleNodeValue;
  3193. tr.id = 'trhelp';
  3194. if(MY_getValue('BMHIDELIST')=='true') {
  3195. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3196. listeBM.snapshotItem(i).style.display = 'none';
  3197. document.getElementsByTagName('thead')[0].style.display = 'none';
  3198. tr.style.display = 'none';
  3199. }
  3200. }
  3201.  
  3202.  
  3203. /* [functions] Fonction principale */
  3204.  
  3205. function traiteMalus() {
  3206. var mainTab = document.getElementsByTagName('table')[0];
  3207. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3208. if(listeBM.snapshotLength==0) return;
  3209. /* Suppression des BM de fatigue stockés */
  3210. if(MY_getValue(numTroll+'.bm.fatigue'))
  3211. MY_removeValue(numTroll+'.bm.fatigue');
  3212. /* Extraction des données */
  3213. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3214. var nb = 0;
  3215. while(nb<listeBM.snapshotLength) {
  3216. tr = listeBM.snapshotItem(nb); nb++;
  3217. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3218. var phymag = tr.childNodes[9].textContent;
  3219. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3220. var type = tr.childNodes[3].textContent, nom;
  3221. // si c'est un type à décumul
  3222. /*
  3223. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3224. switch(type) {
  3225. case 'Potion':
  3226. case 'Parchemin':
  3227. case 'Sortilège':
  3228. case 'Capacité Spéciale':
  3229. nom = tr.childNodes[1].textContent+phymag;
  3230. break;
  3231. default:
  3232. nom = 'pasdedecumul';
  3233. }
  3234. */
  3235. nom = tr.childNodes[1].textContent+phymag;
  3236. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3237. nom = 'pasdedecumul';
  3238. uniListe[nb] = {
  3239. 'duree':duree,
  3240. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3241. 'caracs':{}
  3242. }
  3243. for(var i=0 ; i<effetsT.length ; i++) {
  3244. if(effetsT[i].indexOf(':')==-1) continue;
  3245. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3246. // nom = 'pasdedecumul' si pas de décumul
  3247. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3248. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3249. uniListe[nb]['type'] = phymag;
  3250. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3251. uniListe[nb]['caracs'][carac] = bm;
  3252. listeDurees[duree] = true;
  3253. }
  3254. } // fin boucle sur les lignes de bonus/malus
  3255. /* Gestion des décumuls et cumuls des durées */
  3256. var toursGeres = [];
  3257. for(var d in listeDurees) toursGeres.push(d);
  3258. toursGeres.sort( function (a,b){return b-a;} );
  3259. // pour sauvegarder les bm de fatigue
  3260. var strfat = '';
  3261. // Pour affichage & adpatation à footable.js (statique)
  3262. var thead = document.getElementsByTagName('thead')[0];
  3263. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3264. thead, null, 7, null).snapshotLength;
  3265. var tfoot = document.getElementsByTagName('tfoot')[0];
  3266. for(var i=0 ; i<toursGeres.length ; i++) {
  3267. var tour = toursGeres[i];
  3268. var effetsCeTour = {}; decumulsCeTour = {};
  3269. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3270. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3271. continue;
  3272. var nom = uniListe[nb]['nom'];
  3273. if(nom!='pasdedecumul') {
  3274. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3275. decumulsCeTour[nom]++;
  3276. }
  3277. for(var carac in uniListe[nb]['caracs']) {
  3278. var bm = uniListe[nb]['caracs'][carac];
  3279. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3280. var type = uniListe[nb]['type'];
  3281. if(!effetsCeTour[carac])
  3282. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3283. if(nom=='pasdedecumul')
  3284. effetsCeTour[carac][type] += bm;
  3285. else
  3286. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  3287. } else {
  3288. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3289. var thisBm;
  3290. if(nom=='pasdedecumul' || carac=='Fatigue')
  3291. thisBm = bm;
  3292. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3293. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3294. else
  3295. thisBm = decumul(bm,decumulsCeTour[nom]);
  3296. effetsCeTour[carac] += thisBm;
  3297. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3298. }
  3299. } // fin boucle sur les caractéristiques
  3300. } // fin boucle sur les bonus/malus
  3301. /* Création du bilan du tour */
  3302. var texteD = '', texteS = '';
  3303. var caracGerees = [];
  3304. for(var k in effetsCeTour) caracGerees.push(k);
  3305. caracGerees.sort( triecaracs );
  3306. for(var j=0 ; j<caracGerees.length ; j++) {
  3307. var carac = caracGerees[j], str = '';
  3308. switch( carac ) {
  3309. case 'ATT':
  3310. case 'DEG':
  3311. case 'Armure':
  3312. var phy = effetsCeTour[carac]['Physique'];
  3313. var mag = effetsCeTour[carac]['Magie'];
  3314. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3315. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3316. break;
  3317. case 'TOUR':
  3318. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3319. break;
  3320. case 'Fatigue':
  3321. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3322. case 'PV':
  3323. case 'ESQ':
  3324. case 'REG':
  3325. case 'Vue':
  3326. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3327. break;
  3328. default:
  3329. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3330. }
  3331. if(str) {
  3332. texteD += str;
  3333. texteS += str;
  3334. }
  3335. } // fin boucle sur les caractéristiques
  3336. /* Affichage */
  3337. // Si rien à afficher on passe
  3338. if(!texteD) continue;
  3339. // Si BMM+BMP=0
  3340. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3341. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3342. if(MY_getValue('BMDETAIL')=='false')
  3343. tr.style.display = 'none';
  3344. var td = appendTdText(tr,texteD.substring(3));
  3345. td.colSpan = 5-nbHidden;
  3346. var txttour = toursGeres[i]+' Tour';
  3347. if(toursGeres[i]>1) txttour += 's';
  3348. appendTdText(tr,txttour);
  3349. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3350. if(MY_getValue('BMDETAIL')!='false')
  3351. tr.style.display = 'none';
  3352. td = appendTdText(tr,texteS);
  3353. td.colSpan = 5-nbHidden;
  3354. appendTdText(tr,txttour);
  3355. } // fin boucle sur les tours générés
  3356. /* mise en place toggleDetails */
  3357. tfoot.style.cursor = 'pointer';
  3358. tfoot.onclick = toggleDetailsBM;
  3359. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3360. if(strfat)
  3361. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3362. }
  3363.  
  3364. function do_malus() {
  3365. try {
  3366. start_script();
  3367. traiteMalus();
  3368. setDisplayBM();
  3369. displayScriptTime();
  3370. }
  3371. catch(e) {window.alert(e)};
  3372. }
  3373.  
  3374. /*******************************************************************************
  3375. * This file is part of Mountyzilla. *
  3376. * *
  3377. * Mountyzilla is free software; you can redistribute it and/or modify *
  3378. * it under the terms of the GNU General Public License as published by *
  3379. * the Free Software Foundation; either version 2 of the License, or *
  3380. * (at your option) any later version. *
  3381. * *
  3382. * Mountyzilla is distributed in the hope that it will be useful, *
  3383. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3384. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3385. * GNU General Public License for more details. *
  3386. * *
  3387. * You should have received a copy of the GNU General Public License *
  3388. * along with Mountyzilla; if not, write to the Free Software *
  3389. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3390. *******************************************************************************/
  3391.  
  3392. // x~x mouches
  3393.  
  3394. var mainTab, tr_mouches;
  3395.  
  3396. function initialiseMouches() {
  3397. // Lanceur global
  3398. try {
  3399. mainTab = document.getElementById('mouches');
  3400. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3401. } catch(e) {
  3402. avertissement('Erreur MZ:<br />Consulter la console.');
  3403. window.console.error(traceStack(e, 'mouches'));
  3404. return;
  3405. }
  3406. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3407. setDisplayMouches();
  3408. traiteMouches();
  3409. }
  3410.  
  3411. function setDisplayMouches() {
  3412. // Initialise l'affichage / l'effacement du détail des mouches
  3413. var titre = document.getElementById('titre2');
  3414. if(titre) {
  3415. titre.style.cursor = 'pointer';
  3416. titre.onclick = toggleMouches;
  3417. }
  3418. var tfoot = document.getElementsByTagName('tfoot')[0];
  3419. if(tfoot) {
  3420. tfoot.style.cursor = 'pointer';
  3421. tfoot.onclick = toggleMouches;
  3422. }
  3423. if(MY_getValue('HIDEMOUCHES')=='true') {
  3424. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3425. tr_mouches.snapshotItem(i).style.display = 'none';
  3426. }
  3427. document.getElementsByTagName('thead')[0].style.display = 'none';
  3428. }
  3429. }
  3430.  
  3431. function toggleMouches() {
  3432. // Handler pour afficher / masquer les détasil
  3433. if(MY_getValue('HIDEMOUCHES')=='true') {
  3434. MY_setValue('HIDEMOUCHES','false');
  3435. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3436. tr_mouches.snapshotItem(i).style.display = '';
  3437. }
  3438. document.getElementsByTagName('thead')[0].style.display = '';
  3439. } else {
  3440. MY_setValue('HIDEMOUCHES','true');
  3441. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3442. tr_mouches.snapshotItem(i).style.display = 'none';
  3443. }
  3444. document.getElementsByTagName('thead')[0].style.display = 'none';
  3445. }
  3446. }
  3447.  
  3448. function traiteMouches() {
  3449. // Traitement complet: présence et effets des mouches
  3450. var listeTypes = {}, effetsActifs = {};
  3451. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3452. var tr = tr_mouches.snapshotItem(i);
  3453. // La mouche est-elle présente?
  3454. var etat = document.evaluate(
  3455. './img',
  3456. tr.cells[6], null, 9, null
  3457. ).singleNodeValue.alt;
  3458. if(etat!='La Mouche est là') { continue; }
  3459. // Extraction du type de mouche
  3460. var type = trim(tr.cells[3].textContent);
  3461. if(!listeTypes[type]) {
  3462. listeTypes[type] = 1;
  3463. } else {
  3464. listeTypes[type]++;
  3465. }
  3466. // La mouche a-t-elle un effet?
  3467. var effet = trim(tr.cells[2].textContent);
  3468. if(etat!='La Mouche est là' || !effet) { continue; }
  3469. // Si oui, extraction des effets (multiples pour pogées)
  3470. var caracs = effet.split(' | ');
  3471. for(var j=0 ; j<caracs.length ; j++) {
  3472. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3473. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3474. if(effetsActifs[carac]===void(0)) {
  3475. effetsActifs[carac] = valeur;
  3476. } else {
  3477. effetsActifs[carac] += valeur;
  3478. }
  3479. }
  3480. }
  3481. // Extraction Effet total et affichage des différences à la normale
  3482. var tfoot = document.getElementsByTagName('tfoot')[0];
  3483. if(!tfoot) { return; }
  3484. var nodeTotal = document.evaluate(
  3485. ".//b[contains(./text(),'Effet total')]",
  3486. tfoot, null, 9, null
  3487. ).singleNodeValue.nextSibling;
  3488. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3489. var texte = ' ';
  3490. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3491. if(texte.length>1) { texte += ' | '; }
  3492. var carac = trim(
  3493. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3494. );
  3495. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3496. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3497. texte += effetsTheoriques[i];
  3498. } else {
  3499. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3500. if(carac=='TOUR') { texte += ' min'; }
  3501. texte += '</b>';
  3502. }
  3503. }
  3504. var span = document.createElement('span');
  3505. span.innerHTML = texte;
  3506. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3507. // Affichage des différences du nombre de mouches de chaque type
  3508. var mouchesParType = document.evaluate(
  3509. "./tr/td/ul/li/text()",
  3510. tfoot, null, 7, null
  3511. );
  3512. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3513. var node = mouchesParType.snapshotItem(i);
  3514. var mots = node.nodeValue.split(' ');
  3515. var type = mots.pop();
  3516. if(!listeTypes[type]) {
  3517. node.nodeValue += ' (0 présente)';
  3518. } else if(mots[0]!=listeTypes[type]) {
  3519. if(listeTypes[type]==1) {
  3520. node.nodeValue += ' (1 présente)';
  3521. } else {
  3522. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3523. }
  3524. }
  3525. }
  3526. }
  3527.  
  3528. function do_mouches() {
  3529. start_script();
  3530. initialiseMouches();
  3531. displayScriptTime();
  3532. }
  3533.  
  3534. /*********************************************************************************
  3535. * This file is part of Mountyzilla. *
  3536. * *
  3537. * Mountyzilla is free software; you can redistribute it and/or modify *
  3538. * it under the terms of the GNU General Public License as published by *
  3539. * the Free Software Foundation; either version 2 of the License, or *
  3540. * (at your option) any later version. *
  3541. * *
  3542. * Mountyzilla is distributed in the hope that it will be useful, *
  3543. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3544. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3545. * GNU General Public License for more details. *
  3546. * *
  3547. * You should have received a copy of the GNU General Public License *
  3548. * along with Mountyzilla; if not, write to the Free Software *
  3549. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3550. *********************************************************************************/
  3551.  
  3552. // x~x equipgowap
  3553.  
  3554. var popup;
  3555.  
  3556. function initPopupEquipgowap() {
  3557. popup = document.createElement('div');
  3558. popup.setAttribute('id', 'popup');
  3559. popup.setAttribute('class', 'mh_textbox');
  3560. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3561. 'display: inline; z-index: 3; max-width: 400px;');
  3562. document.body.appendChild(popup);
  3563. }
  3564.  
  3565. function showPopupEquipgowap(evt) {
  3566. var texte = this.getAttribute("texteinfo");
  3567. popup.innerHTML = texte;
  3568. popup.style.left = evt.pageX + 15 + 'px';
  3569. popup.style.top = evt.pageY + 'px';
  3570. popup.style.visibility = "visible";
  3571. }
  3572.  
  3573. function hidePopup() {
  3574. popup.style.visibility = "hidden";
  3575. }
  3576.  
  3577. function createPopupImage(url, text)
  3578. {
  3579. var img = document.createElement('img');
  3580. img.setAttribute('src',url);
  3581. img.setAttribute('align','ABSMIDDLE');
  3582. img.setAttribute("texteinfo",text);
  3583. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3584. img.addEventListener("mouseout", hidePopup,true);
  3585. return img;
  3586. }
  3587.  
  3588. function formateTexte(texte)
  3589. {
  3590. texte = texte.replace(/\n/g,"<br/>");
  3591. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3592. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3593. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3594. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3595. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3596. return texte;
  3597. }
  3598.  
  3599.  
  3600. function treateGowaps() {
  3601. //On récupère les gowaps possédants des composants
  3602. var tbodys = document.evaluate(
  3603. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3604. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3605. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3606. var tbody = tbodys.snapshotItem(j);
  3607. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3608. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3609. if(MY_getValue("NOINFOEM") != "true")
  3610. insertEMInfos(tbody);
  3611. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3612. insertEnchantInfos(tbody);
  3613. }
  3614. }
  3615.  
  3616. function treateChampi() {
  3617. if(MY_getValue("NOINFOEM") == "true")
  3618. return false;
  3619. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3620. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3621. if (nodes.snapshotLength == 0)
  3622. return false;
  3623.  
  3624. for (var i = 0; i < nodes.snapshotLength; i++) {
  3625. var node = nodes.snapshotItem(i);
  3626. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3627. if(texte.indexOf("*")!=-1)
  3628. texte = texte.substring(0,texte.lastIndexOf(" "));
  3629. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3630. if(moisChampi[nomChampi])
  3631. {
  3632. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3633. }
  3634. }
  3635. }
  3636.  
  3637. function do_equipgowap() {
  3638. start_script();
  3639.  
  3640. treateGowaps();
  3641. treateChampi();
  3642. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3643. {
  3644. initPopupEquipgowap();
  3645. computeEnchantementEquipement(createPopupImage,formateTexte);
  3646. }
  3647.  
  3648. displayScriptTime();
  3649. }
  3650.  
  3651. /*********************************************************************************
  3652. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3653. *********************************************************************************/
  3654.  
  3655. // x~x ordresgowap
  3656.  
  3657. /* v0.2 by Dab - 2013-08-31
  3658. * - correction acquisition posale initiale
  3659. * - correction tare et affichage mire
  3660. */
  3661.  
  3662. function setCarteGogo() {
  3663. try {
  3664. //var pars = document.getElementsByTagName('p');
  3665. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3666. var eTitle = document.getElementById('titre2');
  3667. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3668. var serv_img_trou = URL_MZimg + "carte_trou.png";
  3669. var serv_img_cible = URL_MZimg + "rep.png";
  3670.  
  3671. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  3672. //var lignes = pars[0].getElementsByTagName('tr');
  3673. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  3674. var nbpt = 0;
  3675. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  3676. for(var i=0 ; i<lignes.length ; i++) {
  3677. if(lignes[i].className == 'mh_tdpage_fo') {
  3678. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  3679. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  3680. if(point) {
  3681. nbpt++;
  3682. trajet += point[1]+','+point[2]+','+point[3]+',';
  3683. }
  3684. }
  3685. }
  3686. }
  3687. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  3688. 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'/>";
  3689. var base = [-229,-5];
  3690. if (nbpt>0) {
  3691. base = [-684,-5];
  3692. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  3693. }
  3694. 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;'/>";
  3695.  
  3696. 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>';
  3697.  
  3698. var nvspan = document.createElement('div');
  3699. nvspan.align = 'center';
  3700. nvspan.id = 'mz_mapdiv';
  3701. nvspan.valign = 'top';
  3702. nvspan.innerHTML = nvdiv;
  3703. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  3704. var footer = document.getElementById('footer1');
  3705. footer.parentNode.insertBefore(nvspan,footer);
  3706. }
  3707.  
  3708. function testeGlissiere() {
  3709. try {
  3710. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  3711. var footer = document.getElementById('footer1');
  3712. footer.parentNode.insertBefore(gliss.getElt(), footer);
  3713. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  3714. }
  3715.  
  3716. function do_ordresgowap() {
  3717. setCarteGogo(); // Via script des trouillots
  3718. if (isDEV) {
  3719. testeGlissiere();
  3720. }
  3721. }
  3722.  
  3723. /*********************************************************************************
  3724. * This file is part of Mountyzilla. *
  3725. * *
  3726. * Mountyzilla is free software; you can redistribute it and/or modify *
  3727. * it under the terms of the GNU General Public License as published by *
  3728. * the Free Software Foundation; either version 2 of the License, or *
  3729. * (at your option) any later version. *
  3730. * *
  3731. * Mountyzilla is distributed in the hope that it will be useful, *
  3732. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3733. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3734. * GNU General Public License for more details. *
  3735. * *
  3736. * You should have received a copy of the GNU General Public License *
  3737. * along with Mountyzilla; if not, write to the Free Software *
  3738. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3739. *********************************************************************************/
  3740.  
  3741. // x~x attaque
  3742.  
  3743. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3744.  
  3745. function do_attaque() {
  3746. }
  3747.  
  3748. /*******************************************************************************
  3749. * This file is part of Mountyzilla. *
  3750. * *
  3751. * Mountyzilla is free software; you can redistribute it and/or modify *
  3752. * it under the terms of the GNU General Public License as published by *
  3753. * the Free Software Foundation; either version 2 of the License, or *
  3754. * (at your option) any later version. *
  3755. * *
  3756. * Mountyzilla is distributed in the hope that it will be useful, *
  3757. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3758. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3759. * GNU General Public License for more details. *
  3760. * *
  3761. * You should have received a copy of the GNU General Public License *
  3762. * along with Mountyzilla; if not, write to the Free Software *
  3763. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3764. *******************************************************************************/
  3765.  
  3766. // x~x infomonstre
  3767.  
  3768. // DEBUG
  3769. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  3770. // À corriger, évidemment.
  3771. var listeCDM = {};
  3772. var nomMonstre='';
  3773. var idMonstre=-1;
  3774. var tbody;
  3775. var popup;
  3776.  
  3777. function traiteMonstre() {
  3778. try {
  3779. var nodeTitre = document.evaluate(
  3780. "//div[@class='titre2' and contains(text(),'(')]",
  3781. document, null, 9, null
  3782. ).singleNodeValue;
  3783. var texte = nodeTitre.firstChild.nodeValue;
  3784. } catch(e) {
  3785. window.console.log(traceStack(e, 'traiteMonstre'));
  3786. return;
  3787. }
  3788. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  3789. if(nomMonstre.indexOf(']')!=-1) {
  3790. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  3791. }
  3792. idMonstre = texte.match(/\d+/)[0];
  3793. FF_XMLHttpRequest({
  3794. method: 'GET',
  3795. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  3796. +MY_getValue('CDMID')
  3797. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  3798. headers : {
  3799. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3800. 'Accept': 'application/atom+xml,application/xml,text/xml'
  3801. },
  3802. onload: function(responseDetails) {
  3803. try {
  3804. var texte = responseDetails.responseText;
  3805. var lines = texte.split("\n");
  3806. if(lines.length>=1) {
  3807. var infos = lines[0].split(";");
  3808. if(infos.length<4) { return; }
  3809. var idMonstre = infos[0];
  3810. infos=infos.slice(3);
  3811. listeCDM[idMonstre]=infos;
  3812. computeMissionInfomonstre();
  3813. }
  3814. } catch(e) {
  3815. window.alert(e);
  3816. }
  3817. }
  3818. });
  3819. }
  3820.  
  3821. function initPopupInfomonstre() {
  3822. // Initialise le popup tactique (calculs att/deg)
  3823. popup = document.createElement('div');
  3824. popup.id = 'popup';
  3825. popup.className = 'mh_textbox';
  3826. popup.style =
  3827. 'position: absolute;'+
  3828. 'border: 1px solid #000000;'+
  3829. 'visibility: hidden;'+
  3830. 'display: inline;'+
  3831. 'z-index: 3;'+
  3832. 'max-width: 400px;';
  3833. document.body.appendChild(popup);
  3834. }
  3835.  
  3836. function showPopupTactique(evt) {
  3837. try {
  3838. var id = this.id;
  3839. var nom = this.nom;
  3840. var texte = getAnalyseTactique(id,nom);
  3841. if(texte=='') { return; }
  3842. popup.innerHTML = texte;
  3843. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  3844. if(isPage("View/MonsterView")) {
  3845. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  3846. } else {
  3847. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  3848. }
  3849. popup.style.top = evt.pageY+15+'px';
  3850. popup.style.visibility = 'visible';
  3851. } catch(e) {
  3852. window.alert(e);
  3853. }
  3854. }
  3855.  
  3856. // roule 16/03/2016, existe déjà ailleurs
  3857. // function hidePopup() {
  3858. // popup.style.visibility = 'hidden';
  3859. // }
  3860.  
  3861. function toggleTableau() {
  3862. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  3863. }
  3864.  
  3865. function computeMissionInfomonstre() {
  3866. // C'est quoi ce titre de fonction ? (O_o)
  3867. try {
  3868. var nodeInsert = document.evaluate(
  3869. "//div[@class = 'titre3']",
  3870. document, null, 9, null
  3871. ).singleNodeValue;
  3872. } catch(e) {
  3873. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  3874. return;
  3875. }
  3876. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  3877. table.align = 'center';
  3878. tbody = table.childNodes[1];
  3879. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  3880. table.firstChild.firstChild.onmouseover = function() {
  3881. this.style.cursor = 'pointer';
  3882. this.className = 'mh_tdpage';
  3883. };
  3884. table.firstChild.firstChild.onmouseout = function() {
  3885. this.className = 'mh_tdtitre';
  3886. };
  3887. tbody.style.display = 'none';
  3888. table.style.width = '350px';
  3889. insertBefore(nodeInsert,table);
  3890. }
  3891.  
  3892. function do_infomonstre() {
  3893. start_script();
  3894. try {
  3895. initPopupInfomonstre();
  3896. traiteMonstre();
  3897. } catch(e) {
  3898. window.alert('Erreur infoMonstre:\n'+e);
  3899. }
  3900. displayScriptTime();
  3901. }
  3902.  
  3903. /*******************************************************************************
  3904. * This file is part of Mountyzilla. *
  3905. * *
  3906. * Mountyzilla is free software; you can redistribute it and/or modify *
  3907. * it under the terms of the GNU General Public License as published by *
  3908. * the Free Software Foundation; either version 2 of the License, or *
  3909. * (at your option) any later version. *
  3910. * *
  3911. * Mountyzilla is distributed in the hope that it will be useful, *
  3912. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3913. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3914. * GNU General Public License for more details. *
  3915. * *
  3916. * You should have received a copy of the GNU General Public License *
  3917. * along with Mountyzilla; if not, write to the Free Software *
  3918. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3919. *******************************************************************************/
  3920.  
  3921. // x~x mission
  3922.  
  3923. /* TODO
  3924. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  3925. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  3926. *
  3927. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  3928. */
  3929.  
  3930. function saveMission(num,obEtape) {
  3931. var obMissions = {};
  3932. if(MY_getValue(numTroll+'.MISSIONS')) {
  3933. try {
  3934. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3935. } catch(e) {
  3936. window.console.error(traceStack(e, 'Mission parsage'));
  3937. return;
  3938. }
  3939. }
  3940. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  3941. if(obEtape) {
  3942. obMissions[num] = obEtape;
  3943. } else if(obMissions[num]) {
  3944. delete obMissions[num];
  3945. }
  3946. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3947. }
  3948.  
  3949. function addtroogle(tdLibelle, sRestrict) {
  3950. var img = document.createElement('img');
  3951. img.setAttribute('src', URL_MZimg + 'troogle.ico');
  3952. var a = document.createElement('a');
  3953. var url = URL_troogle + '?utf8' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  3954. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  3955. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  3956. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  3957. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  3958. a.href = url;
  3959. a.title = 'Chercher sur Troogle';
  3960. a.target = 'troogle';
  3961. a.appendChild(img);
  3962. tdLibelle.appendChild(a);
  3963. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  3964. }
  3965.  
  3966. function traiteMission() {
  3967. try {
  3968. var titreMission = document.getElementsByClassName('titre2')[0];
  3969. var numMission = titreMission.textContent.match(/\d+/)[0];
  3970. var missionForm = document.getElementsByName('ActionForm')[0];
  3971. var tdLibelle = document.evaluate(
  3972. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  3973. missionForm, null, 9, null).singleNodeValue;
  3974. } catch(e) {
  3975. window.console.error(traceStack(e, 'récupération mission'));
  3976. return;
  3977. }
  3978. if(!numMission) { return; }
  3979. try {
  3980. if(!tdLibelle) {
  3981. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  3982. saveMission(numMission,false);
  3983. return;
  3984. }
  3985.  
  3986. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  3987. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  3988. // debug Roule'
  3989. //for (var i =0; i < tdLibelle.childNodes.length; i++) window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  3990. if(libelle.indexOf('niveau égal à')!=-1) {
  3991. var nbKills = 1, niveau, mod;
  3992. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  3993. // Étape de kill multiple de niveau donné
  3994. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  3995. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  3996. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  3997. niveau = Number(mod[0]);
  3998. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  3999. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4000. } else {
  4001. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4002. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4003. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4004. mod = mod ? Number(mod[0]) : 'plus';
  4005. }
  4006. } else {
  4007. // Étape de kill unique de niveau donné
  4008. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4009. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4010. mod = mod ? Number(mod[0]) : 'plus';
  4011. }
  4012. // debug Roule'
  4013. //window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + ', libelle=' + libelle);
  4014. saveMission(numMission,{
  4015. type: 'Niveau',
  4016. niveau: niveau,
  4017. mod: mod,
  4018. mundidey: siMundidey,
  4019. libelle: libelle
  4020. });
  4021. if (mod == 'plus')
  4022. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4023. else
  4024. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4025. } else if(libelle.indexOf('de la race')!=-1) {
  4026. var nbKills = 1, race;
  4027. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4028. // Étape de kill multiple de race donnée
  4029. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4030. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4031. } else {
  4032. // Étape de kill unique de race donnée
  4033. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4034. }
  4035. saveMission(numMission,{
  4036. type: 'Race',
  4037. race: race.replace(/\"/g,''),
  4038. mundidey: siMundidey,
  4039. libelle: libelle
  4040. });
  4041. addtroogle(tdLibelle, '@monstre:' + race.replace(/\"/g,''));
  4042. } else if(libelle.indexOf('de la famille')!=-1) {
  4043. var nbKills = 1, famille;
  4044. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4045. // Étape de kill multiple de famille donnée
  4046. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4047. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4048. } else {
  4049. // Étape de kill unique de famille donnée
  4050. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4051. }
  4052. saveMission(numMission,{
  4053. type: 'Famille',
  4054. famille: famille,
  4055. mundidey: siMundidey,
  4056. libelle: libelle
  4057. });
  4058. addtroogle(tdLibelle, '@monstre ' + famille);
  4059. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4060. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4061. saveMission(numMission,{
  4062. type: 'Pouvoir',
  4063. pouvoir: pouvoir,
  4064. libelle: libelle
  4065. });
  4066. } else {
  4067. saveMission(numMission,false);
  4068. }
  4069. } catch(e) {
  4070. window.console.error(traceStack(e, 'récupération étape mission'));
  4071. return;
  4072. }
  4073. }
  4074.  
  4075. function do_mission() {
  4076. start_script(60);
  4077.  
  4078. traiteMission();
  4079.  
  4080. displayScriptTime();
  4081. }
  4082.  
  4083. /*******************************************************************************
  4084. * This file is part of Mountyzilla. *
  4085. * *
  4086. * Mountyzilla is free software; you can redistribute it and/or modify *
  4087. * it under the terms of the GNU General Public License as published by *
  4088. * the Free Software Foundation; either version 2 of the License, or *
  4089. * (at your option) any later version. *
  4090. * *
  4091. * Mountyzilla is distributed in the hope that it will be useful, *
  4092. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4093. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4094. * GNU General Public License for more details. *
  4095. * *
  4096. * You should have received a copy of the GNU General Public License *
  4097. * along with Mountyzilla; if not, write to the Free Software *
  4098. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4099. *******************************************************************************/
  4100.  
  4101. // x~x move
  4102.  
  4103. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4104.  
  4105. var petitsTrous = {
  4106. '-52;57': true,
  4107. '55;70': true,
  4108. '64;70': true,
  4109. '12;-15': true,
  4110. '30;-52': true,
  4111. '48;-39': true
  4112. };
  4113.  
  4114. var grosTrous = {
  4115. '-35;65': true,
  4116. '-13;73': true,
  4117. '-64;9': true,
  4118. '-35;15': true,
  4119. '5;32': true,
  4120. '10;64': true,
  4121. '21;36': true,
  4122. '46;52': true,
  4123. '74;32': true,
  4124. '-71;-7': true,
  4125. '-67;-37': true,
  4126. '-60;-32': true,
  4127. '-51;-22': true,
  4128. '-36;-51': true,
  4129. '5;-49': true
  4130. };
  4131.  
  4132. var centreCarmine_X = 56.5;
  4133. var centreCarmine_Y = 23.5;
  4134. var rayonCarmine = 8.7;
  4135.  
  4136. function isTrou(x,y,n) {
  4137. if(petitsTrous[x+';'+y]) {
  4138. return n<0 && n>-60;
  4139. }
  4140. if(grosTrous[x+';'+y]
  4141. || grosTrous[x-1+';'+y]
  4142. || grosTrous[x+';'+y+1]
  4143. || grosTrous[x-1+';'+y+1]) {
  4144. return n<0 && n>-70;
  4145. }
  4146. if(Math.sqrt(
  4147. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4148. )<=rayonCarmine) {
  4149. return n<0 && n>-100;
  4150. }
  4151. return false;
  4152. }
  4153.  
  4154. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4155.  
  4156. function validateDestination() {
  4157. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4158. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4159. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4160. var form = document.getElementsByName('ActionForm')[0];
  4161. if(form) {
  4162. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4163. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4164. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4165. }
  4166. }
  4167. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4168. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4169. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4170. }
  4171. }
  4172. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4173. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4174. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4175. }
  4176. }
  4177. if(isTrou(x,y,n)) {
  4178. return window.confirm(
  4179. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4180. +'Vous allez tomber dans un trou de météorite.\n'
  4181. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4182. );
  4183. }
  4184. }
  4185. return true;
  4186. }
  4187.  
  4188. function newsubmitDE(event) {
  4189. event.stopPropagation();
  4190. event.preventDefault();
  4191. if(validateDestination()) {
  4192. this.submit();
  4193. }
  4194. }
  4195.  
  4196. function changeValidation() {
  4197. var form = document.getElementsByName('ActionForm')[0];
  4198. if(form) {
  4199. form.addEventListener('submit', newsubmitDE, true);
  4200. }
  4201. }
  4202.  
  4203.  
  4204. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4205.  
  4206. function validateTPDestination() {
  4207. try {
  4208. var text = document.getElementsByTagName('B')[0];
  4209. var a = text.firstChild.nodeValue.split('|');
  4210. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4211. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4212. var pos_n = a[2].substring(5, a[2].length) * 1;
  4213.  
  4214. var nbtrous = 0;
  4215. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4216. for(var x=0 ; x<=2 ; x++) {
  4217. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4218. for(var y=0 ; y<=2 ; y++) {
  4219. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4220. for(var n = 0 ; n <= 1 ; n++) {
  4221. if(isTrou(
  4222. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4223. )) {
  4224. nbtrous++;
  4225. }
  4226. }
  4227. }
  4228. }
  4229. }
  4230. }
  4231. }
  4232. if(nbtrous>0 && nbtrous<72) {
  4233. return window.confirm(
  4234. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4235. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4236. +'% de risque de tomber dans un trou de météorite.\n'
  4237. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4238. );
  4239. }
  4240. else if(nbtrous>=72) {
  4241. return window.confirm(
  4242. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4243. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4244. +'% de risque de tomber dans un trou de météorite !\n'
  4245. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4246. );
  4247. }
  4248. return true;
  4249. }
  4250. catch(e) {
  4251. window.alert(e)
  4252. }
  4253. }
  4254.  
  4255. function newsubmitTP(event) {
  4256. event.stopPropagation();
  4257. event.preventDefault();
  4258. if(validateTPDestination()) {
  4259. this.submit();
  4260. }
  4261. }
  4262.  
  4263. function changeButtonValidate() {
  4264. var form = document.getElementsByName('Formulaire')[0];
  4265. if(form) {
  4266. if(!form.getAttribute('onsubmit')) {
  4267. form.setAttribute('onsubmit','return true;');
  4268. }
  4269. form.addEventListener('submit', newsubmitTP, true);
  4270. }
  4271. }
  4272.  
  4273.  
  4274. /*-[functions]---------------- Partie Principale -----------------------------*/
  4275.  
  4276. function do_move() {
  4277. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4278. changeValidation();
  4279. }
  4280. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4281. changeButtonValidate();
  4282. }
  4283. }
  4284.  
  4285. /*******************************************************************************
  4286. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4287. * Mountyzilla is free software; provided under the GNU General Public License *
  4288. *******************************************************************************/
  4289.  
  4290. // x~x news
  4291.  
  4292. // Nombre de news à afficher & nb max de caractères par news:
  4293. const nbItems = 5;
  4294. const maxCarDescription = 300;
  4295.  
  4296. /*-[functions]------------------- Utilitaires --------------------------------*/
  4297.  
  4298. // Ne semble avoir strictement aucun effet:
  4299. String.prototype.epureDescription = function() {
  4300. return this.replace(/\\(.)/g,"$1");
  4301. }
  4302.  
  4303. function appendTitledTable(node,titre,description) {
  4304. // Crée les tables contenant les infos (avec titre)
  4305. var table = document.createElement('table');
  4306. table.border = 0;
  4307. table.className = 'mh_tdborder';
  4308. table.cellSpacing = 1;
  4309. table.cellPadding = 1;
  4310. table.style.maxWidth = '98%';
  4311. table.style.marginLeft = 'auto';
  4312. table.style.marginRight = 'auto';
  4313. var tbody = document.createElement('tbody');
  4314. table.appendChild(tbody);
  4315. var tr = appendTr(tbody,'mh_tdtitre');
  4316. var td = appendTdCenter(tr,2);
  4317. var span = document.createElement('span');
  4318. appendText(span,titre,true);
  4319. if(description) {
  4320. span.title = description;
  4321. }
  4322. td.appendChild(span);
  4323. node.appendChild(table);
  4324. return tbody;
  4325. }
  4326.  
  4327. function testCertif(paramURL, callbackOnError) {
  4328. try {
  4329. FF_XMLHttpRequest({
  4330. method: 'GET',
  4331. url: paramURL,
  4332. onload: function(responseDetails) {
  4333. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4334. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4335. }
  4336. });
  4337. } catch(e) {
  4338. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4339. callbackOnError();
  4340. }
  4341. }
  4342.  
  4343. function createOrGetGrandCadre() {
  4344. var grandCadre = document.getElementById('grandCadre');
  4345. if (grandCadre) return grandCadre;
  4346. try {
  4347. var rappels = document.evaluate(
  4348. "//p[contains(a/text(),'messagerie')]",
  4349. document, null, 9, null).singleNodeValue;
  4350. }
  4351. catch(e) {
  4352. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4353. grandCadre = document.createElement('div');
  4354. return grandCadre;
  4355. }
  4356. grandCadre = document.createElement('div');
  4357. grandCadre.id = 'grandCadre';
  4358. var sousCadre = document.createElement('div');
  4359. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4360. sousCadre.style.textAlign = 'center';
  4361. sousCadre.style.fontSize = 'xx-large';
  4362. grandCadre.appendChild(sousCadre);
  4363.  
  4364. grandCadre.style.border = 'solid 5px red';
  4365. grandCadre.style.width = 'auto';
  4366. insertBefore(rappels,grandCadre);
  4367. return grandCadre;
  4368. }
  4369.  
  4370. function showHttpsErrorCadre1() {
  4371. var grandCadre = createOrGetGrandCadre();
  4372. var sousCadre = document.createElement('div');
  4373. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4374. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4375. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4376. + URL_CertifRaistlin1
  4377. + '" target="raistlin">clique ici</a>'
  4378. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4379. + ' « Confirmer l\'exception de sécurité »'
  4380. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4381. sousCadre.style.width = 'auto';
  4382. sousCadre.style.fontSize = 'large';
  4383. sousCadre.style.border = 'solid 1px black';
  4384. sousCadre.style.backgroundColor = 'red';
  4385. grandCadre.appendChild(sousCadre);
  4386. }
  4387.  
  4388. function showHttpsErrorCadre2() {
  4389. var grandCadre = createOrGetGrandCadre();
  4390. var sousCadre = document.createElement('div');
  4391. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  4392. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  4393. + '<a style="color:blue;font-size: inherits;" href="'
  4394. + URL_CertifRaistlin2
  4395. + '" target="raistlin">clique ici</a>'
  4396. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4397. + ' « Confirmer l\'exception de sécurité »'
  4398. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  4399. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4400. sousCadre.style.width = 'auto';
  4401. sousCadre.style.fontSize = 'large';
  4402. sousCadre.style.border = 'solid 1px black';
  4403. sousCadre.style.backgroundColor = 'red';
  4404. grandCadre.appendChild(sousCadre);
  4405. }
  4406.  
  4407. function showHttpsErrorContenuMixte() {
  4408. var grandCadre = createOrGetGrandCadre();
  4409. var sousCadre = document.createElement('div');
  4410. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  4411. + '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)'
  4412. + '<ul>'
  4413. + '<li>Interface Bricol\'Troll</li>'
  4414. + '<li>Nouveautés de Mountyzilla</li>'
  4415. + '</ul>'
  4416. + '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 />'
  4417. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  4418. sousCadre.style.width = 'auto';
  4419. sousCadre.style.fontSize = 'large';
  4420. sousCadre.style.border = 'solid 1px black';
  4421. grandCadre.appendChild(sousCadre);
  4422. }
  4423.  
  4424. /*-[functions]------------------- Jubilaires ---------------------------------*/
  4425.  
  4426. function traiterJubilaires() {
  4427. // à faire
  4428. }
  4429.  
  4430. function traiterJubilaires_a_supprimer() { // ancienne méthode
  4431. try {
  4432. FF_XMLHttpRequest({
  4433. method: 'GET',
  4434. url: URL_anniv,
  4435. headers: {
  4436. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4437. 'Accept': 'application/xml,text/xml',
  4438. },
  4439. onload: function(responseDetails) {
  4440. if ((responseDetails.status == 0) && isHTTPS) {
  4441. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  4442. showHttpsErrorContenuMixte();
  4443. return;
  4444. }
  4445. var listeTrolls = responseDetails.responseText.split('\n');
  4446. if(!listeTrolls || listeTrolls.length==0) {
  4447. return;
  4448. }
  4449. afficherJubilaires(listeTrolls);
  4450. },
  4451. });
  4452. }
  4453. catch(e) {
  4454. if (isHTTPS) {
  4455. window.console.log(traceStack(e, 'appel jubilaires'));
  4456. showHttpsErrorContenuMixte();
  4457. } else {
  4458. window.alert('Erreur Jubilaires:\n'+e);
  4459. }
  4460. }
  4461. }
  4462.  
  4463. function afficherJubilaires(listeTrolls) {
  4464. try {
  4465. var rappels = document.evaluate(
  4466. "//p[contains(a/text(),'messagerie')]",
  4467. document, null, 9, null).singleNodeValue;
  4468. }
  4469. catch(e) {
  4470. return;
  4471. }
  4472. var p = document.createElement('p');
  4473. var tbody = appendTitledTable(p,
  4474. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  4475. 'Envoyez leur un message ou un cadeau !'
  4476. );
  4477. tr = appendTr(tbody,'mh_tdpage');
  4478. td = appendTdCenter(tr);
  4479. var small = document.createElement('small');
  4480. td.appendChild(small);
  4481. var first = true;
  4482. for(var i=0 ; i<listeTrolls.length ; i++) {
  4483. var infos = listeTrolls[i].split(';');
  4484. if(infos.length!=3 || infos[2]==='0') {
  4485. continue;
  4486. }
  4487. if(first) {
  4488. first = false;
  4489. }
  4490. else {
  4491. appendText(small,', ');
  4492. }
  4493. var a = document.createElement('a');
  4494. a.href = 'javascript:EPV('+infos[0]+')';
  4495. appendText(a,infos[1]);
  4496. small.appendChild(a);
  4497. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  4498. }
  4499. insertBefore(rappels,p);
  4500. }
  4501.  
  4502.  
  4503. /*-[functions]--------------------- News MZ ----------------------------------*/
  4504.  
  4505. function traiterNouvelles() {
  4506. var news = new Array;
  4507. 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 ;).']);
  4508. news.push(['24/12/2016', 'Retour de la carte montrant les déplacements des Gowaps']);
  4509. news.push(['24/12/2016', 'Le lien avec Bricol\'Troll est maintenant disponible en https']);
  4510. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  4511. afficherNouvelles(news);
  4512. }
  4513.  
  4514. function afficherNouvelles(items) {
  4515. var footer = document.getElementById('footer1');
  4516. if(!footer) {
  4517. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  4518. return;
  4519. }
  4520. var p = document.createElement('p');
  4521. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  4522. for(var i=0 ; i<items.length ; i++) {
  4523. var tr = appendTr(tbody,'mh_tdpage');
  4524. var td = appendTdCenter(tr);
  4525. td.style.verticalAlign = 'top'; // semble sans effet
  4526. appendText(td,items[i][0],true);
  4527. td = appendTd(tr);
  4528. td.innerHTML = items[i][1];
  4529. }
  4530. insertBefore(footer,p);
  4531. }
  4532.  
  4533.  
  4534. /*---------------------------------- Main ------------------------------------*/
  4535.  
  4536. function do_news() {
  4537. start_script();
  4538.  
  4539. traiterJubilaires();
  4540. traiterNouvelles();
  4541.  
  4542. if (isHTTPS) {
  4543. // test si les certificats raistlin ont été acceptés
  4544. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  4545. var infoit = MY_getValue(numTroll+'.INFOSIT');
  4546. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  4547. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  4548. }
  4549. }
  4550.  
  4551. displayScriptTime();
  4552. }
  4553.  
  4554. /*********************************************************************************
  4555. * This file is part of Mountyzilla. *
  4556. * *
  4557. * Mountyzilla is free software; you can redistribute it and/or modify *
  4558. * it under the terms of the GNU General Public License as published by *
  4559. * the Free Software Foundation; either version 2 of the License, or *
  4560. * (at your option) any later version. *
  4561. * *
  4562. * Mountyzilla is distributed in the hope that it will be useful, *
  4563. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4564. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4565. * GNU General Public License for more details. *
  4566. * *
  4567. * You should have received a copy of the GNU General Public License *
  4568. * along with Mountyzilla; if not, write to the Free Software *
  4569. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4570. *********************************************************************************/
  4571.  
  4572. // x~x tabcompo
  4573.  
  4574. var popup;
  4575.  
  4576. function initPopupTabcompo() {
  4577. popup = document.createElement('div');
  4578. popup.setAttribute('id', 'popup');
  4579. popup.setAttribute('class', 'mh_textbox');
  4580. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  4581. + 'display: inline; z-index: 3; max-width: 400px;');
  4582. document.body.appendChild(popup);
  4583. }
  4584.  
  4585. function showPopup(evt) {
  4586. var texte = this.getAttribute("texteinfo");
  4587. popup.innerHTML = texte;
  4588. popup.style.left = evt.pageX + 15 + 'px';
  4589. popup.style.top = evt.pageY + 'px';
  4590. popup.style.visibility = "visible";
  4591. }
  4592.  
  4593. // roule 16/03/2016, existe déjà ailleurs
  4594. // function hidePopup() {
  4595. // popup.style.visibility = 'hidden';
  4596. // }
  4597.  
  4598. function createPopupImage(url, text)
  4599. {
  4600. var img = document.createElement('img');
  4601. img.setAttribute('src',url);
  4602. img.setAttribute('align','ABSMIDDLE');
  4603. img.setAttribute("texteinfo",text);
  4604. img.addEventListener("mouseover", showPopup,true);
  4605. img.addEventListener("mouseout", hidePopup,true);
  4606. return img;
  4607. }
  4608.  
  4609. function formateTexte(texte)
  4610. {
  4611. texte = texte.replace(/\n/g,"<br/>");
  4612. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4613. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4614. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4615. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4616. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4617. return texte;
  4618. }
  4619.  
  4620. function arrondi(x) {
  4621. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  4622. }
  4623.  
  4624. function traiteMinerai() {
  4625. if (currentURL.indexOf("as_type=Divers")==-1) return;
  4626. try {
  4627. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  4628. +" and contains(./tr/th/text(),'Minerai')]",
  4629. document, null, 9, null).singleNodeValue;
  4630. node = node.nextSibling.nextSibling;
  4631. }
  4632. catch(e) {return;}
  4633. var trlist = document.evaluate('./tr', node, null, 7, null);
  4634. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  4635. var node = trlist.snapshotItem(i);
  4636. var nature = node.childNodes[5].textContent;
  4637. var caracs = node.childNodes[7].textContent;
  4638. var taille = caracs.match(/\d+/)[0];
  4639. var coef = 1;
  4640. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  4641. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  4642. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  4643. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  4644. if (nature.indexOf('Mithril')!=-1) {
  4645. coef = 0.2*coef;
  4646. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  4647. }
  4648. else {
  4649. coef = 0.75*coef+1.25;
  4650. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  4651. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  4652. }
  4653. }
  4654. }
  4655.  
  4656. function treateComposants() {
  4657. if (currentURL.indexOf("as_type=Compo")==-1) return;
  4658. //On récupère les composants
  4659. var nodes = document.evaluate(
  4660. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4661. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4662. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  4663. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4664. if (nodes.snapshotLength == 0) {
  4665. // window.alert('treateComposants DOWN');
  4666. return;
  4667. }
  4668. window.alert(nodes.snapshotLength);
  4669.  
  4670. var texte = "";
  4671. for (var i = 0; i < nodes.snapshotLength; i++) {
  4672. var n1 = nodes.snapshotItem(i).childNodes[1];
  4673. var n3 = nodes.snapshotItem(i).childNodes[3];
  4674. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4675. var prix = n3.childNodes[0].nodeValue;
  4676. if (!prix)
  4677. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4678. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4679. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4680. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4681. + prix.replace(/\n/g, '') + "\n";
  4682. }
  4683.  
  4684. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4685. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4686. var id_taniere = c.snapshotItem(0).nodeValue;
  4687. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  4688.  
  4689. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4690. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  4691. if (form)
  4692. {
  4693. if(document.getElementsByTagName('form').length>0)
  4694. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4695. else
  4696. {
  4697. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4698. insertBefore(thisP, form);
  4699. }
  4700. }
  4701. }
  4702.  
  4703. function treateAllComposants() {
  4704. if(currentURL.indexOf("as_type=Compo")==-1) return;
  4705. //On récupère les composants
  4706. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  4707. document, null, 0, null ).numberValue;
  4708. var c = (categ == 0 ? 3 : 4);
  4709. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  4710. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  4711. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  4712. + "td["+c+"]/text()[1] = '\240-\240' "
  4713. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  4714. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  4715. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  4716. + "and td[1]/img/@alt = 'Identifié']",
  4717. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4718. if (nodes.snapshotLength == 0) {
  4719. // window.alert('treateAllComposants DOWN');
  4720. return;
  4721. }
  4722.  
  4723. var texte = "";
  4724. for (var i = 0; i < nodes.snapshotLength; i++) {
  4725. var n1 = nodes.snapshotItem(i).childNodes[1];
  4726. var n3 = nodes.snapshotItem(i).childNodes[3];
  4727. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4728. var prix = n3.childNodes[0].nodeValue;
  4729. if (!prix)
  4730. {
  4731. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  4732. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4733. }
  4734. else
  4735. {
  4736. prix= prix.replace(/[\240 ]/g, "");
  4737. if(prix=="-")
  4738. prix=null;
  4739. }
  4740. if(prix)
  4741. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4742. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4743. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4744. + prix.replace(/\n/g, '') + "\n";
  4745. else
  4746. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4747. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4748. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  4749. }
  4750.  
  4751. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4752. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4753. var id_taniere = c.snapshotItem(0).nodeValue;
  4754. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  4755.  
  4756. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4757. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  4758. if (form)
  4759. {
  4760. if(document.getElementsByTagName('form').length>0)
  4761. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4762. else
  4763. {
  4764. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4765. insertBefore(thisP, form);
  4766. }
  4767. }
  4768. }
  4769.  
  4770. function treateEM()
  4771. {
  4772. if(currentURL.indexOf("as_type=Compo")==-1)
  4773. return false;
  4774. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  4775. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  4776. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4777. if (nodes.snapshotLength == 0)
  4778. return false;
  4779. for (var i = 0; i < nodes.snapshotLength; i++) {
  4780. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  4781. var link = desc[2].firstChild ;
  4782. var nomCompoTotal = desc[2].textContent ;
  4783. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4784. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4785. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  4786. var locqual = desc[3].textContent ;
  4787. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  4788. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  4789. if(isEM(nomMonstre).length>0)
  4790. {
  4791. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  4792. if(infos.length>0)
  4793. {
  4794. var shortDescr = "Variable";
  4795. var bold = 0;
  4796. if(infos != "Composant variable")
  4797. {
  4798. shortDescr = infos.substring(0,infos.indexOf(" "));
  4799. if(parseInt(shortDescr)>=0)
  4800. bold=1;
  4801. }
  4802. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  4803. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  4804. }
  4805. }
  4806. }
  4807. }
  4808.  
  4809. function treateChampi() {
  4810. if (currentURL.indexOf('as_type=Champi')==-1)
  4811. return false;
  4812. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  4813. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4814. if (nodes.snapshotLength == 0)
  4815. return false;
  4816.  
  4817. for (var i = 0; i < nodes.snapshotLength; i++) {
  4818. var node = nodes.snapshotItem(i);
  4819. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  4820. if (moisChampi[nomChampi])
  4821. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  4822. }
  4823. }
  4824.  
  4825. function treateEnchant()
  4826. {
  4827. if(currentURL.indexOf("as_type=Compo")==-1)
  4828. return false;
  4829. try
  4830. {
  4831. if(!listeMonstreEnchantement)
  4832. computeCompoEnchantement();
  4833. var nodes = document.evaluate(
  4834. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4835. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4836. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4837. if (nodes.snapshotLength == 0)
  4838. return false;
  4839. var urlImg = URL_MZimg + "enchant.png";
  4840. for (var i = 0; i < nodes.snapshotLength; i++) {
  4841. var link = nodes.snapshotItem(i);
  4842. var nomCompoTotal = link.firstChild.nodeValue;
  4843. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4844. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4845. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  4846. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  4847. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  4848. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  4849. if(isEnchant(nomMonstre).length>0)
  4850. {
  4851. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  4852. if(infos.length>0)
  4853. {
  4854. link.parentNode.appendChild(createImage(urlImg,infos));
  4855. }
  4856. }
  4857. }
  4858. }
  4859. catch(e)
  4860. {
  4861. window.alert(e);
  4862. }
  4863. }
  4864.  
  4865. function treateEquipEnchant()
  4866. {
  4867. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  4868. return false;
  4869. initPopupTabcompo();
  4870. computeEnchantementEquipement(createPopupImage,formateTexte);
  4871. }
  4872.  
  4873. function do_tancompo() {
  4874. start_script();
  4875.  
  4876. treateAllComposants();
  4877. treateComposants();
  4878. traiteMinerai();
  4879. if (MY_getValue('NOINFOEM')!='true') {
  4880. treateChampi();
  4881. treateEM();
  4882. }
  4883. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  4884. treateEnchant();
  4885. treateEquipEnchant();
  4886. }
  4887.  
  4888. displayScriptTime();
  4889. }
  4890.  
  4891. /*******************************************************************************
  4892. * This file is part of Mountyzilla. *
  4893. * *
  4894. * Mountyzilla is free software; you can redistribute it and/or modify *
  4895. * it under the terms of the GNU General Public License as published by *
  4896. * the Free Software Foundation; either version 2 of the License, or *
  4897. * (at your option) any later version. *
  4898. * *
  4899. * Mountyzilla is distributed in the hope that it will be useful, *
  4900. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4901. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4902. * GNU General Public License for more details. *
  4903. * *
  4904. * You should have received a copy of the GNU General Public License *
  4905. * along with Mountyzilla; if not, write to the Free Software *
  4906. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4907. *******************************************************************************/
  4908.  
  4909. // x~x pjview
  4910.  
  4911. /* TODO
  4912. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  4913. */
  4914.  
  4915. // Bulle d'infos
  4916. var DivInfo;
  4917. // Booléen stockant l'état de freezing de la bulle
  4918. var freezed = false;
  4919.  
  4920. // liste du matos
  4921. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  4922. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4923. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  4924. var mh_caracs = {
  4925. 'anneau de protection':
  4926. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  4927. "armure d'anneaux":
  4928. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  4929. 'armure de bois':
  4930. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  4931. 'armure de cuir':
  4932. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  4933. 'armure de peaux':
  4934. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  4935. 'armure de pierre':
  4936. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  4937. 'armure de plates':
  4938. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  4939. 'baton lesté':
  4940. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4941. 'bâtons de parade':
  4942. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4943. 'bottes':
  4944. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4945. 'bouclier à pointes':
  4946. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4947. 'boulet et chaîne':
  4948. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4949. 'cagoule':
  4950. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  4951. 'casque à cornes':
  4952. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4953. 'casque à pointes':
  4954. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  4955. 'casque en cuir':
  4956. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  4957. 'casque en métal':
  4958. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4959. 'chaîne cloutée':
  4960. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4961. 'chapeau pointu':
  4962. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  4963. 'collier de dents':
  4964. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  4965. 'collier de pierre':
  4966. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4967. 'collier à pointes':
  4968. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4969. 'cotte de mailles':
  4970. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  4971. 'couronne de cristal':
  4972. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  4973. "couronne d'obsidienne":
  4974. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  4975. "coutelas d'obsidienne":
  4976. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  4977. 'coutelas en os':
  4978. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  4979. 'crochet':
  4980. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  4981. 'cuir bouilli':
  4982. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  4983. "cuirasse d'ossements":
  4984. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  4985. "cuirasse d'écailles":
  4986. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  4987. 'culotte en cuir':
  4988. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4989. 'dague':
  4990. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4991. 'epée courte':
  4992. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  4993. 'epée longue':
  4994. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  4995. 'espadon':
  4996. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  4997. 'fouet':
  4998. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  4999. 'fourrures':
  5000. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5001. 'gantelet':
  5002. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5003. 'gorgeron en cuir':
  5004. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5005. 'gorgeron en métal':
  5006. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5007. 'gourdin':
  5008. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5009. 'gourdin clouté':
  5010. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5011. 'grimoire':
  5012. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5013. "gros'porte":
  5014. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5015. 'grosse racine':
  5016. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5017. 'grosse stalagmite':
  5018. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5019. 'hache de bataille':
  5020. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5021. 'hache de guerre en os':
  5022. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5023. 'hache de guerre en pierre':
  5024. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5025. "hache à deux mains d'obsidienne":
  5026. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5027. 'hallebarde':
  5028. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5029. "haubert d'écailles":
  5030. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5031. 'haubert de mailles':
  5032. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5033. 'heaume':
  5034. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5035. 'jambières en cuir':
  5036. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5037. 'jambières en fourrure':
  5038. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5039. 'jambières en maille':
  5040. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5041. 'jambières en métal':
  5042. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5043. 'jambières en os':
  5044. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5045. "lame d'obsidienne":
  5046. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5047. 'lame en os':
  5048. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5049. 'lame en pierre':
  5050. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5051. 'lorgnons':
  5052. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5053. 'machette':
  5054. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5055. "masse d'arme":
  5056. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5057. 'pagne de mailles':
  5058. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5059. 'pagne en cuir':
  5060. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5061. 'robe de mage':
  5062. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5063. 'rondache en bois':
  5064. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5065. 'rondache en métal':
  5066. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5067. 'sandales':
  5068. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5069. 'souliers dorés':
  5070. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5071. "talisman d'obsidienne":
  5072. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5073. 'talisman de pierre':
  5074. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5075. 'targe':
  5076. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5077. 'torche':
  5078. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5079. 'torque de pierre':
  5080. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5081. 'tunique':
  5082. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5083. "tunique d'écailles":
  5084. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5085. 'turban':
  5086. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5087. }
  5088.  
  5089. // liste des templates
  5090. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5091. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5092. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5093. var mh_templates = {
  5094. 'de Feu':
  5095. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5096. 'de Résistance':
  5097. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5098. "de l'Aigle":
  5099. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5100. 'de la Salamandre':
  5101. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5102. 'des Cyclopes':
  5103. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5104. 'des Enragés':
  5105. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5106. 'des Tortues':
  5107. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5108. 'des Vampires':
  5109. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5110. 'du Glacier':
  5111. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5112. 'du Rat':
  5113. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5114. 'du Roc':
  5115. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5116. 'du Temps':
  5117. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5118. 'du Vent':
  5119. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5120. 'en Mithril':
  5121. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5122. 'des Anciens':
  5123. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5124. 'des Champions':
  5125. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5126. 'des Duellistes':
  5127. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5128. 'de la Terre':
  5129. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5130. "de l'Orage":
  5131. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5132. "de l'Ours":
  5133. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5134. 'des Béhémoths':
  5135. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5136. 'des Mages':
  5137. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5138. 'du Pic':
  5139. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5140. 'du Sable':
  5141. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5142. 'acéré':
  5143. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5144. 'acérée':
  5145. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5146. 'équilibré':
  5147. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5148. 'équilibrée':
  5149. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5150. 'léger':
  5151. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5152. 'légère':
  5153. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5154. 'renforcé':
  5155. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5156. 'renforcée':
  5157. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5158. 'robuste':
  5159. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5160. }
  5161.  
  5162. function clone(arr) {
  5163. // Clonage rapide
  5164. return arr.slice(0);
  5165. }
  5166.  
  5167. function addArray(arr1,arr2) {
  5168. // Somme matricielle
  5169. var res = clone(arr1);
  5170. for(i=res.length-1 ; i>=0 ; i--) {
  5171. res[i] += arr2[i];
  5172. }
  5173. return res;
  5174. }
  5175.  
  5176. function getTemplates(nomItem) {
  5177. // Déstructure le nom de l'item en array [nom, template1, ...]
  5178. var tempFound = true;
  5179. var str = nomItem.trim();
  5180. var arr = [];
  5181. while(tempFound) {
  5182. tempFound = false;
  5183. for(var temp in mh_templates) {
  5184. // on teste la fin du nom contre chaque template
  5185. if(str.slice(-temp.length)!=temp) { continue; }
  5186. tempFound = true;
  5187. str = str.slice(0,-temp.length-1);
  5188. arr.unshift(temp);
  5189. if(str.slice(-3)==' et') {
  5190. str = str.slice(0,-3);
  5191. }
  5192. }
  5193. }
  5194. arr.unshift(str);
  5195. return arr;
  5196. }
  5197.  
  5198. function addMithril(arrayCaracs,typeItem) {
  5199. // Ajoute l'effet du Mithril sur les caracs
  5200. if(typeItem=='arme') {
  5201. if(arrayCaracs[0]<0) {
  5202. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5203. }
  5204. }
  5205. else {
  5206. if(arrayCaracs[4]<0) {
  5207. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5208. }
  5209. }
  5210. arrayCaracs[15] /= 2;
  5211. arrayCaracs[16] /= 2;
  5212. return arrayCaracs;
  5213. }
  5214.  
  5215. function addRenfort(arrayCaracs,template) {
  5216. // Ajoute l'effet des pseudo-templates sur les caracs
  5217. // S'applique APRÈS le mithril
  5218. // WARNING - Cette formule n'a rien d'officiel, gare !
  5219. var coef = 0;
  5220. if(/^lég[e,è]re?$/.test(template)) {
  5221. coef = -1;
  5222. }
  5223. else if(/^renforcée?$/.test(template)
  5224. || template==='robuste') {
  5225. coef = 1;
  5226. }
  5227. if(coef) {
  5228. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5229. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5230. }
  5231. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5232. return arrayCaracs;
  5233. }
  5234.  
  5235. function getCaracs(item) {
  5236. // Calcule les caractéristiques de l'item
  5237. var templates = getTemplates(item);
  5238. if(!mh_caracs[templates[0]]) {
  5239. // Si l'item est inconnu
  5240. return [];
  5241. }
  5242. var caracs = clone(mh_caracs[templates[0]]);
  5243. var typeItem = caracs[0];
  5244. caracs.shift();
  5245. templates.shift();
  5246. if(templates[templates.length-1]=='en Mithril') {
  5247. caracs = addMithril(caracs,typeItem);
  5248. templates.pop();
  5249. }
  5250. if(/^acérée?$/.test(templates[0])
  5251. || /^équilibrée?$/.test(templates[0])
  5252. || /^lég[e,è]re?$/.test(templates[0])
  5253. || /^renforcée?$/.test(templates[0])
  5254. || templates[0]=='robuste') {
  5255. caracs = addRenfort(caracs,templates[0]);
  5256. templates.shift();
  5257. }
  5258. for(var i=templates.length-1 ; i>=0 ; i--) {
  5259. caracs = addArray(caracs,mh_templates[templates[i]]);
  5260. }
  5261. return caracs;
  5262. }
  5263.  
  5264. function getLine(tab) {
  5265. // Préparation de la ligne à afficher lors d'un mouseover
  5266. var str = '';
  5267. if(tab[0]!=0 || tab[1]!=0) {
  5268. str += '<b>Att : </b>'+aff(tab[0]);
  5269. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5270. str += ' | ';
  5271. }
  5272. if(tab[4]!=0) {
  5273. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5274. }
  5275. if(tab[2]!=0 || tab[3]!=0) {
  5276. str += '<b>Deg : </b>'+aff(tab[2]);
  5277. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5278. str += ' | ';
  5279. }
  5280. if(tab[8]!=0) {
  5281. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5282. }
  5283. if(tab[7]!=0) {
  5284. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5285. }
  5286. if(tab[5]!=0 || tab[6]!=0) {
  5287. str += '<b>Arm : </b>'+aff(tab[5]);
  5288. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5289. str += ' | ';
  5290. }
  5291. if(tab[9]!=0 || tab[10]!=0) {
  5292. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5293. if(tab[9]!=tab[10]) {
  5294. str += '/'+aff(tab[10])+'%';
  5295. }
  5296. str += ' | ';
  5297. }
  5298. if(tab[11]!=0 || tab[12]!=0) {
  5299. str += '<b>MM : </b>'+aff(tab[11])+'%';
  5300. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  5301. str += ' | ';
  5302. }
  5303. if(tab[13]!=0) {
  5304. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5305. }
  5306. if(tab[14]!=0) {
  5307. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5308. }
  5309. str += '<b>Poids : </b>'+tab[15]+' min';
  5310. if(tab[15]!=tab[16]) {
  5311. str += ' / '+tab[16]+' min';
  5312. }
  5313. return str;
  5314. }
  5315.  
  5316. function toolTipInit() {
  5317. DivInfo = document.createElement('div');
  5318. DivInfo.id = 'infosVue';
  5319. DivInfo.className = 'mh_textbox';
  5320. DivInfo.style =
  5321. 'position: absolute;'
  5322. +'border: 1px solid #000000;'
  5323. +'visibility:hidden;'
  5324. +'display:inline;'
  5325. +'z-index:99;';
  5326. document.body.appendChild(DivInfo);
  5327. document.onmousemove = getXY;
  5328. document.onclick = changeFreezeStatus;
  5329. }
  5330.  
  5331. function getXY(evt) {
  5332. if(!freezed && DivInfo.style.visibility=='visible') {
  5333. DivInfo.style.left = evt.pageX+'px';
  5334. DivInfo.style.top = evt.pageY+10+'px';
  5335. }
  5336. }
  5337.  
  5338. function changeFreezeStatus() {
  5339. if(DivInfo.style.visibility=='visible') {
  5340. freezed = !freezed;
  5341. if(!freezed) { hideInfos(); }
  5342. }
  5343. }
  5344.  
  5345. function showInfos() {
  5346. if(freezed) { return; }
  5347. var currentInfos = this.infos;
  5348. DivInfo.innerHTML = currentInfos;
  5349. DivInfo.style.visibility = 'visible';
  5350. }
  5351.  
  5352. function hideInfos() {
  5353. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  5354. }
  5355.  
  5356. function treateEquipement() {
  5357. // Extrait les données du matos et réinjecte les infos déduites
  5358. if(MY_getValue('INFOCARAC')=='false') { return; }
  5359. var faireLigne = false;
  5360. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  5361. var nodes = document.evaluate(
  5362. "//td/b[text()='Equipement Utilisé']/../../"
  5363. +"td[2]/img[contains(@src,bullet)]",
  5364. document, null, 7, null);
  5365. if(nodes.snapshotLength>0) {
  5366. // Si CSS de base
  5367. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5368. var node = nodes.snapshotItem(i);
  5369. var next = node.nextSibling;
  5370. var nnext = next.nextSibling;
  5371. var nom = next.nodeValue.toLowerCase();
  5372. if(nnext.childNodes.length==1) {
  5373. nom += nnext.firstChild.nodeValue;
  5374. }
  5375. nom = nom.trim();
  5376. // gestion winpostrophe
  5377. var c = String.fromCharCode(180);
  5378. while(nom.indexOf(c)!=-1) {
  5379. nom = nom.replace(c,"'");
  5380. }
  5381. var arr = getCaracs(nom);
  5382. if(arr.length>0) {
  5383. faireLigne = true;
  5384. caracs = addArray(caracs,arr);
  5385. var span = document.createElement('span');
  5386. span.appendChild(next);
  5387. span.appendChild(nnext);
  5388. span.infos = getLine(arr);
  5389. span.onmouseover = showInfos;
  5390. span.onmouseout = hideInfos;
  5391. insertBefore(node.nextSibling,span);
  5392. }
  5393. }
  5394. if(faireLigne) {
  5395. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  5396. document, null, 9, null).singleNodeValue;
  5397. node.infos = getLine(caracs);
  5398. node.onmouseover = showInfos;
  5399. node.onmouseout = hideInfos;
  5400. }
  5401. }
  5402. else {
  5403. // Si CSS avancée
  5404. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  5405. document, null, 7, null);
  5406. if(nodes.snapshotLength>0) {
  5407. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5408. var node = nodes.snapshotItem(i);
  5409. var nom = node.firstChild.nodeValue.toLowerCase();
  5410. if(node.childNodes.length>1) {
  5411. nom += node.childNodes[1].firstChild.nodeValue;
  5412. }
  5413. nom = nom.trim();
  5414. // gestion winpostrophe
  5415. var c = String.fromCharCode(180);
  5416. while(nom.indexOf(c)!=-1) {
  5417. nom = nom.replace(c,"'");
  5418. }
  5419. var arr = getCaracs(nom);
  5420. if(arr.length!=0) {
  5421. caracs = addArray(caracs,arr);
  5422. node.infos = getLine(arr);
  5423. node.onmouseover = showInfos;
  5424. node.onmouseout = hideInfos;
  5425. }
  5426. }
  5427. var nodes = document.evaluate("//dt[@class='equipement']",
  5428. document, null, 7, null);
  5429. var node = nodes.snapshotItem(0);
  5430. node.infos = getLine(caracs);
  5431. node.onmouseover = showInfos;
  5432. node.onmouseout = hideInfos;
  5433. }
  5434. }
  5435. }
  5436.  
  5437. function do_pjview() {
  5438. treateEquipement();
  5439. toolTipInit();
  5440. }
  5441.  
  5442. /*******************************************************************************
  5443. * This file is part of Mountyzilla. *
  5444. * *
  5445. * Mountyzilla is free software; you can redistribute it and/or modify *
  5446. * it under the terms of the GNU General Public License as published by *
  5447. * the Free Software Foundation; either version 2 of the License, or *
  5448. * (at your option) any later version. *
  5449. * *
  5450. * Mountyzilla is distributed in the hope that it will be useful, *
  5451. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5452. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5453. * GNU General Public License for more details. *
  5454. * *
  5455. * You should have received a copy of the GNU General Public License *
  5456. * along with Mountyzilla; if not, write to the Free Software *
  5457. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5458. *******************************************************************************/
  5459.  
  5460. // x~x option
  5461.  
  5462. /* TODO
  5463. * Passer le HTML injecté aux conventions HTML5
  5464. */
  5465.  
  5466.  
  5467. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  5468.  
  5469. function saveITData() {
  5470. var IT = document.getElementById('itSelect').value;
  5471. if(IT=='bricol') {
  5472. var system = document.getElementById('urlbricol').value;
  5473. var login = document.getElementById('loginbricol').value;
  5474. var pass = document.getElementById('passbricol').value;
  5475. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  5476. if(system && login) {
  5477. if (pass) {
  5478. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  5479. MY_setValue(numTroll+'.INFOSIT', v);
  5480. //window.console.log('v=' + v);
  5481. } else {
  5482. // vérif que rien n'a changé
  5483. var str = MY_getValue(numTroll+'.INFOSIT');
  5484. if(str) {
  5485. var arr = str.split('$');
  5486. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  5487. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  5488. }
  5489. }
  5490. }
  5491. }
  5492. }
  5493. else {
  5494. MY_removeValue(numTroll+'.INFOSIT');
  5495. }
  5496. }
  5497.  
  5498. function saveLinks() {
  5499. var numLinks = document.getElementById('linksBody').childNodes.length;
  5500. var data=[ [] ];
  5501. /* Récupération et tri des liens */
  5502. for(var i=1 ; i<=numLinks ; i++) {
  5503. MY_removeValue('URL'+i);
  5504. MY_removeValue('URL'+i+'.nom');
  5505. MY_removeValue('URL'+i+'.ico');
  5506. var url = document.getElementById('url'+i).value;
  5507. var nom = document.getElementById('nom'+i).value;
  5508. var ico = document.getElementById('ico'+i).value;
  5509. if(url && (nom || ico) ) {
  5510. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5511. }
  5512. }
  5513. /* Sauvegarde */
  5514. for(var i=1 ; i<data.length ; i++) {
  5515. MY_setValue('URL'+i,data[i][0]);
  5516. MY_setValue('URL'+i+'.nom',data[i][1]);
  5517. MY_setValue('URL'+i+'.ico',data[i][2]);
  5518. }
  5519. }
  5520.  
  5521. function saveAll() {
  5522. var urlIco = document.getElementById('icoMenuIco').value;
  5523. if(urlIco) {
  5524. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5525. }
  5526. else {
  5527. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5528. document.getElementById('icoMenuIco').value = '';
  5529. }
  5530. saveLinks();
  5531. refreshLinks();
  5532. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5533. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5534. if(maxcdm) {
  5535. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5536. }
  5537. else {
  5538. MY_removeValue(numTroll+'.MAXCDM');
  5539. document.getElementById('maxcdm').value = '';
  5540. }
  5541.  
  5542. MY_setValue('NOINFOEM',
  5543. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5544. // Pourquoi Tilk stockait-il tout en str ?
  5545. // -> parce que les booléens c'est foireux (vérifié)
  5546. MY_setValue(numTroll+'.USECSS',
  5547. document.getElementById('usecss').checked ? 'true':'false');
  5548. MY_setValue('INFOCARAC',
  5549. document.getElementById('infocarac').checked ? 'true' : 'false');
  5550. //MY_setValue(numTroll+'.SEND_IDT',
  5551. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  5552. // Fonctionnalité désactivée
  5553.  
  5554. MY_setValue(numTroll+'.AUTOCDM',
  5555. document.getElementById('autoCdM').checked ? 'true' : 'false');
  5556. MY_setValue('VUECARAC',
  5557. document.getElementById('vueCarac').checked ? 'true' : 'false');
  5558. MY_setValue('CONFIRMEDECALAGE',
  5559. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  5560. MY_setValue(numTroll+".OLDSCHOOL",
  5561. document.getElementById("oldShoolStyle").checked ? "true" : "false");
  5562.  
  5563. saveITData();
  5564. var bouton = document.getElementById('saveAll');
  5565. bouton.value = (bouton.value=='Sauvegardé !') ?
  5566. 'Re-sauvegardé !' : 'Sauvegardé !';
  5567. }
  5568.  
  5569.  
  5570. /*-[functions]----------------- EventListeners -------------------------------*/
  5571.  
  5572. function onChangeIT() {
  5573. var IT = document.getElementById('itSelect').value;
  5574. var itBody = document.getElementById('itBody');
  5575. itBody.innerHTML = '';
  5576. if(IT=='bricol') {
  5577. var tr = appendTr(itBody,'mh_tdpage')
  5578. var td = appendTd(tr);
  5579. var str = MY_getValue(numTroll+'.INFOSIT');
  5580. //window.console.log('onChangeIT str=' + str);
  5581. if(str) {
  5582. var arr = str.split('$');
  5583. var system = arr[1];
  5584. var login = arr[2];
  5585. var affhv = arr[4];
  5586. }
  5587. appendText(td,'Nom du système : ');
  5588. appendTextbox(td,'text','urlbricol',20,50,system);
  5589. td = appendTd(tr);
  5590. appendText(td,'Login du compte : ');
  5591. appendTextbox(td,'text','loginbricol',20,50,login);
  5592. td = appendTd(tr);
  5593. appendText(td,'Mot de passe du compte : ');
  5594. appendTextbox(td,'password','passbricol',20,50);
  5595. td = appendTd(tr);
  5596. appendText(td,'Affichage des Trõlls hors vue : ');
  5597. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  5598. appendCheckBox(td,'affhvbricol', (affhv>0));
  5599. }
  5600. }
  5601.  
  5602. function refreshLinks() {
  5603. document.getElementById('linksBody').innerHTML = '';
  5604. var anotherURL = MY_getValue('URL1');
  5605. if(!anotherURL) { addLinkField(); }
  5606. var i=1;
  5607. while(anotherURL && i<99) {
  5608. addLinkField(i,anotherURL,
  5609. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  5610. i++;
  5611. anotherURL = MY_getValue('URL'+i);
  5612. }
  5613. }
  5614.  
  5615. function addLinkField(i,url,nom,ico) {
  5616. var linksBody = document.getElementById('linksBody');
  5617. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  5618. var tr = appendTr(linksBody);
  5619. var td = appendTdCenter(tr);
  5620. appendText(td,'Lien '+i+' : ');
  5621. appendTextbox(td,'text','url'+i,40,150,url);
  5622. td = appendTdCenter(tr);
  5623. appendText(td,'Nom : ');
  5624. appendTextbox(td,'text','nom'+i,20,150,nom);
  5625. td = appendTdCenter(tr);
  5626. appendText(td,'Icône : ');
  5627. appendTextbox(td,'text','ico'+i,40,150,ico);
  5628. }
  5629.  
  5630. function removeLinkField() {
  5631. var linksBody = document.getElementById('linksBody');
  5632. var i = linksBody.childNodes.length;
  5633. MY_removeValue('URL'+i);
  5634. MY_removeValue('URL'+i+'.nom');
  5635. MY_removeValue('URL'+i+'.ico');
  5636. linksBody.removeChild(linksBody.lastChild);
  5637. if(linksBody.childNodes.length==0) { addLinkField(); }
  5638. }
  5639.  
  5640. function resetMainIco() {
  5641. document.getElementById('icoMenuIco').value=
  5642. URL_MZimg + 'mz_logo_small.png';
  5643. }
  5644.  
  5645.  
  5646. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  5647.  
  5648. function insertTitle(next,txt) {
  5649. var div = document.createElement('div');
  5650. div.className = 'titre2';
  5651. appendText(div,txt);
  5652. insertBefore(next,div);
  5653. return div;
  5654. }
  5655.  
  5656. function insertMainTable(next) {
  5657. var table = document.createElement('table');
  5658. table.width = '98%';
  5659. table.border = 0;
  5660. table.align = 'center';
  5661. table.cellPadding = 2;
  5662. table.cellSpacing = 1;
  5663. table.className = 'mh_tdborder';
  5664. var tbody = document.createElement('tbody');
  5665. table.appendChild(tbody);
  5666. insertBefore(next,table);
  5667. return tbody;
  5668. }
  5669.  
  5670. function appendSubTable(node) {
  5671. var table = document.createElement('table');
  5672. table.width = '100%';
  5673. var tbody = document.createElement('tbody');
  5674. table.appendChild(tbody);
  5675. node.appendChild(table);
  5676. return tbody;
  5677. }
  5678.  
  5679. function insertOptionTable(insertPt) {
  5680. var mainBody = insertMainTable(insertPt);
  5681. /* Liens dans le Menu */
  5682. var tr = appendTr(mainBody,'mh_tdtitre');
  5683. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  5684. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5685. appendText(td,'Icône du Menu: ');
  5686. var url = MY_getValue(numTroll+'.ICOMENU');
  5687. if(!url) {
  5688. url = URL_MZimg + 'mz_logo_small.png';
  5689. }
  5690. appendTextbox(td,'text','icoMenuIco',50,200,url);
  5691. appendButton(td,'Réinitialiser',resetMainIco);
  5692. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5693. var tbody = appendSubTable(td);
  5694. tbody.id = 'linksBody';
  5695. refreshLinks();
  5696. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  5697. appendButton(td,'Ajouter',addLinkField);
  5698. appendButton(td,'Supprimer',removeLinkField);
  5699. /* Options de la Vue : vue externe, nb de CdM, etc */
  5700. tr = appendTr(mainBody,'mh_tdtitre');
  5701. appendTdText(tr,'Options de la Vue :',true);
  5702. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5703. tbody = appendSubTable(td);
  5704. tr = appendTr(tbody);
  5705. td = appendTdText(tr,'Vue externe : ');
  5706. var select = document.createElement('select');
  5707. select.id = 'vueext';
  5708. td.appendChild(select);
  5709. var listeVues2D = [
  5710. 'Bricol\' Vue',
  5711. 'Vue du CCM',
  5712. 'Vue Gloumfs 2D',
  5713. 'Vue Gloumfs 3D',
  5714. 'Grouky Vue!'
  5715. ];
  5716. for(var i=0 ; i<listeVues2D.length ; i++) {
  5717. appendOption(select,listeVues2D[i],listeVues2D[i]);
  5718. }
  5719. if(MY_getValue('VUEEXT')) {
  5720. select.value = MY_getValue('VUEEXT');
  5721. }
  5722. td = appendTd(tr);
  5723. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  5724. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  5725. tr = appendTr(tbody);
  5726. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  5727. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  5728. td = appendTd(tr);
  5729. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  5730. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  5731. /* Interface Tactique */
  5732. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5733. appendText(td,'Interface Tactique : ',true);
  5734. select = document.createElement('select');
  5735. select.id = 'itSelect';
  5736. appendOption(select,'none','Aucune');
  5737. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  5738. // seule interface supportée !
  5739. td.appendChild(select);
  5740. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5741. tbody = appendSubTable(td);
  5742. tbody.id = 'itBody';
  5743. select.onchange = onChangeIT;
  5744. var str = MY_getValue(numTroll+'.INFOSIT');
  5745. if(str) {
  5746. select.value = str.slice(0,str.indexOf('$'));
  5747. onChangeIT();
  5748. }
  5749. /* Options diverses */
  5750. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5751. appendText(td,'Options diverses :',true);
  5752. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5753. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  5754. appendText(td,
  5755. ' Afficher les caractéristiques des équipements des autres Trõlls');
  5756. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5757. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  5758. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  5759. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5760. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  5761. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  5762. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5763. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  5764. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  5765. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5766. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  5767. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  5768. td = appendTd(appendTr(mainBody,"mh_tdpage"));
  5769. appendCheckBox(td,"oldShoolStyle",MY_getValue(numTroll+".OLDSCHOOL")=="true");
  5770. appendText(td," Ouvrir l'ancien profil par défaut");
  5771. /* Bouton SaveAll */
  5772. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  5773. input = appendButton(td,'Sauvegarder',saveAll);
  5774. input.id = 'saveAll';
  5775. }
  5776.  
  5777. function insertCreditsTable(insertPt) {
  5778. var tbody = insertMainTable(insertPt);
  5779. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  5780. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  5781. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  5782.  
  5783. var ul = document.createElement('ul');
  5784. td.appendChild(ul);
  5785. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  5786. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  5787. appendLI(ul,'Reivax (4234) pour les infos bulles');
  5788. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  5789. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  5790. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  5791. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  5792. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  5793. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  5794. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  5795. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  5796. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  5797. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  5798. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  5799. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  5800. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  5801. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  5802. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  5803. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  5804. }
  5805.  
  5806.  
  5807. /* [functions] Obsolètes */
  5808. function deleteEnchantement()
  5809. {
  5810. try
  5811. {
  5812. var idEquipement = this.getAttribute('name');
  5813. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  5814. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  5815. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  5816. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  5817. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  5818. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5819. var string = "";
  5820. for(var i=0;i<listeEquipement.length;i++)
  5821. {
  5822. if(listeEquipement[i]!=idEquipement)
  5823. if(string=="")
  5824. string = listeEquipement[i];
  5825. else
  5826. string += ";"+listeEquipement[i];
  5827. }
  5828. if(string=="")
  5829. {
  5830. MY_removeValue(numTroll+".enchantement.liste");
  5831. var table = this.parentNode.parentNode.parentNode.parentNode;
  5832. var parent = table.parentNode;
  5833. for(var i=0;i<parent.childNodes.length;i++)
  5834. {
  5835. if(parent.childNodes[i]==table)
  5836. {
  5837. parent.removeChild(parent.childNodes[i-1]);
  5838. parent.removeChild(parent.childNodes[i-1]);
  5839. parent.removeChild(parent.childNodes[i-1]);
  5840. break;
  5841. }
  5842. }
  5843. }
  5844. else
  5845. {
  5846. MY_getValue(numTroll+".enchantement.liste",string);
  5847. this.parentNode.parentNode.parentNode
  5848. .removeChild(this.parentNode.parentNode);
  5849. }
  5850. }
  5851. catch(e)
  5852. {
  5853. window.alert(e);
  5854. }
  5855. }
  5856. /* [functions] fin Obsolètes */
  5857.  
  5858. /*-[functions]---------------- Partie principale -----------------------------*/
  5859.  
  5860. function do_option() {
  5861. start_script(712);
  5862.  
  5863. // Pour cryptage des mdp IT
  5864. //appendNewScript(URL_tilk_js + 'md5.js'); // source intégré dans tout_MZ
  5865.  
  5866. var insertPoint = document.getElementById('footer1');
  5867. insertBefore(insertPoint,document.createElement('p'));
  5868. var ti = insertTitle(insertPoint,'Mountyzilla : Options');
  5869. ti.title = 'Version ' + GM_info.script.version;
  5870. insertOptionTable(insertPoint);
  5871. /* insertion enchantements ici
  5872. if(...)
  5873. insertEnchantementTable();
  5874. */
  5875. insertBefore(insertPoint,document.createElement('p'));
  5876. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  5877. ti.onclick = function (e) {
  5878. var evt = e || window.event;
  5879. if (evt.shiftKey) {
  5880. var oldDev = MY_getValue('MZ_dev');
  5881. if (oldDev) {
  5882. MY_removeValue('MZ_dev');
  5883. } else {
  5884. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  5885. MY_setValue('MZ_dev', 1);
  5886. }
  5887. document.location.href = document.location.href;
  5888. }
  5889. }
  5890. insertCreditsTable(insertPoint);
  5891. insertBefore(insertPoint,document.createElement('p'));
  5892.  
  5893. /* [zone] Obsolète ?? */
  5894. if(MY_getValue(numTroll+".enchantement.liste")
  5895. && MY_getValue(numTroll+".enchantement.liste")!="" )
  5896. {
  5897. insertTitle(insertPoint, 'Les Enchantements en cours');
  5898. table = document.createElement('table');
  5899. table.setAttribute('width', '98%');
  5900. table.setAttribute('border', '0');
  5901. table.setAttribute('align', 'center');
  5902. table.setAttribute('cellpadding', '2');
  5903. table.setAttribute('cellspacing', '1');
  5904. table.setAttribute('class', 'mh_tdborder');
  5905.  
  5906. tbody = document.createElement('tbody');
  5907. table.appendChild(tbody);
  5908. tr = appendTr(tbody, 'mh_tdtitre');
  5909. appendTdText(tr, 'Equipement',1);
  5910. appendTdText(tr, 'Composants',1);
  5911. appendTdText(tr, 'Enchanteur',1);
  5912. appendTdText(tr, 'Action',1);
  5913. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5914. for(var i=0;i<listeEquipement.length;i++)
  5915. {
  5916. try
  5917. {
  5918. var idEquipement = listeEquipement[i];
  5919. var nomEquipement = MY_getValue(numTroll+".enchantement."
  5920. +idEquipement+".objet");
  5921. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  5922. +idEquipement+".enchanteur").split(";");
  5923. var ul = document.createElement('UL');
  5924. for(var j=0;j<3;j++)
  5925. {
  5926. var infoComposant = MY_getValue(numTroll+".enchantement."
  5927. +idEquipement+".composant."+j).split(";");
  5928. var texte = infoComposant[4].replace("Ril ","Œil ");
  5929. for(var k=5;k<infoComposant.length;k++)
  5930. {
  5931. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  5932. }
  5933. li = appendLI(ul,texte);
  5934. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  5935. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  5936. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  5937. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  5938. string+= '<input type="hidden" name="q" value="min" />';
  5939. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  5940. 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>';
  5941.  
  5942. string+= '</form>';
  5943. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  5944. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  5945. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  5946. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  5947. li.innerHTML += string;
  5948. }
  5949. tr = appendTr(tbody, 'mh_tdpage');
  5950. td = appendTdText(tr, nomEquipement);
  5951. td.setAttribute('valign', 'center');
  5952. td = document.createElement('td');
  5953. td.appendChild(ul);
  5954. tr.appendChild(td);
  5955. td.setAttribute('valign', 'center');
  5956. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  5957. td.setAttribute('valign', 'center');
  5958. td = document.createElement('td');
  5959. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  5960. input.setAttribute('name', idEquipement);
  5961. tr.appendChild(td);
  5962. td.setAttribute('valign', 'center');
  5963. }
  5964. catch(e)
  5965. {
  5966. }
  5967. }
  5968. insertBefore(insertPoint, table);
  5969. insertBefore(insertPoint, document.createElement('p'));
  5970. }
  5971. /* [zone] fin Obsolète ?? */
  5972.  
  5973.  
  5974. displayScriptTime();
  5975. }
  5976.  
  5977. /*******************************************************************************
  5978. * This file is part of Mountyzilla. *
  5979. * *
  5980. * Mountyzilla is free software; you can redistribute it and/or modify *
  5981. * it under the terms of the GNU General Public License as published by *
  5982. * the Free Software Foundation; either version 2 of the License, or *
  5983. * (at your option) any later version. *
  5984. * *
  5985. * Mountyzilla is distributed in the hope that it will be useful, *
  5986. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5987. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5988. * GNU General Public License for more details. *
  5989. * *
  5990. * You should have received a copy of the GNU General Public License *
  5991. * along with Mountyzilla; if not, write to the Free Software *
  5992. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5993. *******************************************************************************/
  5994.  
  5995. // x~x equip
  5996.  
  5997. /**
  5998. * 2014-02-08 - v2.0a (from scratch)
  5999. * 2014-02-18 - v2.0a0
  6000. * - ajout calcul Carats / UM des minerais + totaux
  6001. * 2014-03-06 - v2.0a1
  6002. * - retour Infos EM des Champis
  6003. * TODO
  6004. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6005. */
  6006.  
  6007. function traiteChampis() {
  6008. try{
  6009. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6010. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6011. }
  6012. catch(e){return;}
  6013. if(trlist.length<=0) return;
  6014. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6015. var node = trlist.snapshotItem(i).childNodes[7];
  6016. var str = node.textContent.trim();
  6017. var type = str.slice(0,str.lastIndexOf(' '));
  6018. var mundi = mundiChampi[type];
  6019. if(!mundi) continue;
  6020. var urlImg = URL_MZimg
  6021. +'Competences/ecritureMagique.png';
  6022. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6023. appendText(node,' ');
  6024. node.appendChild(img);
  6025. }
  6026. }
  6027.  
  6028. function traiteCompos() {
  6029. try {
  6030. var tr = document.getElementById('mh_objet_hidden_Composant');
  6031. var tbody = document.evaluate("./td/table/tbody",
  6032. tr, null, 9, null).singleNodeValue;
  6033. }
  6034. catch(e) {return;}
  6035. insererInfosEM(tbody);
  6036. }
  6037.  
  6038. function traiteMinerai() {
  6039. try{
  6040. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6041. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6042. }
  6043. catch(e){return;}
  6044. if(trlist.length<=0) return;
  6045. var totaux = {};
  6046. var str;
  6047. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6048. var node = trlist.snapshotItem(i);
  6049. var nature = node.childNodes[7].textContent,
  6050. caracs = node.childNodes[9].textContent;
  6051. var taille = Number(caracs.match(/\d+/)[0]);
  6052. var coef = 1;
  6053. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6054. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6055. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6056. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6057. if(nature.indexOf('Mithril')!=-1) {
  6058. coef = 0.2*coef;
  6059. str = ' | UM: ';
  6060. }
  6061. else {
  6062. coef = 0.75*coef+1.25;
  6063. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6064. str = ' | Carats: ';
  6065. }
  6066. var carats = Math.round(taille*coef)
  6067. appendText(node.childNodes[9], str+carats );
  6068. if(!totaux[nature]) {
  6069. totaux[nature] = [taille,carats];
  6070. }
  6071. else {
  6072. totaux[nature][0] += taille;
  6073. totaux[nature][1] += carats;
  6074. }
  6075. }
  6076. str = 'Total : ';
  6077. for(var nature in totaux) {
  6078. if(str.length>8) str += ', ';
  6079. if(nature.indexOf('Mithril')!=-1) {
  6080. str += nature+totaux[nature][1]+' UM';
  6081. }
  6082. else {
  6083. str += nature+totaux[nature][0]+'U/'
  6084. +totaux[nature][1]+'c';
  6085. }
  6086. }
  6087. /*var node = document.getElementById('mh_plus_Minerai');
  6088. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6089. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6090. if(!titre) return;*/
  6091. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6092. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6093. td.colSpan = 7;
  6094. }
  6095.  
  6096. function do_equip() {
  6097. start_script();
  6098.  
  6099. traiteChampis();
  6100. traiteCompos();
  6101. traiteMinerai();
  6102.  
  6103. displayScriptTime();
  6104. }
  6105.  
  6106. /*******************************************************************************
  6107. * This file is part of Mountyzilla. *
  6108. * *
  6109. * Mountyzilla is free software; you can redistribute it and/or modify *
  6110. * it under the terms of the GNU General Public License as published by *
  6111. * the Free Software Foundation; either version 2 of the License, or *
  6112. * (at your option) any later version. *
  6113. * *
  6114. * Mountyzilla is distributed in the hope that it will be useful, *
  6115. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6116. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6117. * GNU General Public License for more details. *
  6118. * *
  6119. * You should have received a copy of the GNU General Public License *
  6120. * along with Mountyzilla; if not, write to the Free Software *
  6121. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6122. *******************************************************************************/
  6123.  
  6124. // x~x diplo
  6125.  
  6126. /*
  6127. TODO:
  6128. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6129. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6130. V Étape 3: Ajout de la diplo perso
  6131. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6132. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6133. Options Globales:
  6134. Actuelles:
  6135. numTroll.USECSS,
  6136. numTroll.NODIPLO
  6137. NOMYTH
  6138. Nouvelles:
  6139. TODO numTroll.USECSS
  6140. numTroll.diplo.off (remplace NODIPLO)
  6141. numTroll.diplo.guilde
  6142. numTroll.diplo.perso
  6143. Structure de diplo.guilde:
  6144. isOn: 'true' ou 'false'
  6145. isDetailOn: 'true' ou 'false'
  6146. guilde
  6147. > id
  6148. > couleur
  6149. AllAmis,AllEnnemis: couleur
  6150. Amis0,...,Ennemis5
  6151. > Troll: idTroll1;...;
  6152. > Guilde: idGuilde1;...;
  6153. > titre
  6154. > couleur
  6155. Structure de diplo.perso:
  6156. isOn: 'true' ou 'false'
  6157. mythiques: couleur
  6158. Troll,Guilde,Monstre:
  6159. > id
  6160. > couleur
  6161. > description
  6162. */
  6163.  
  6164. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6165.  
  6166. function couleurAleatoire() {
  6167. var alph = '0123456789ABCDEF'.split('');
  6168. var clr = '#';
  6169. for (var i=0; i<6; i++) {
  6170. clr+=alph[ Math.floor(16*Math.random()) ];
  6171. }
  6172. return clr;
  6173. }
  6174.  
  6175. function isCouleur(str) {
  6176. return /^#[0-9A-F]{6}$/i.test(str);
  6177. }
  6178.  
  6179. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6180.  
  6181. function appendChoixCouleur(node,id) {
  6182. var span = document.createElement('span');
  6183. span.id = 'span'+id;
  6184. if(isDetailOn) {
  6185. span.style.display = 'none';
  6186. }
  6187. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6188. if(diploGuilde[id]) {
  6189. couleur = diploGuilde[id];
  6190. }
  6191. appendText(span,' - Couleur HTML: ');
  6192. var input = appendTextbox(span,'text',id,7,7,couleur);
  6193. input.onkeyup = previewCouleur;
  6194. input.onchange = previewCouleur;
  6195. input.onkeyup();
  6196. node.appendChild(span);
  6197. }
  6198.  
  6199. function insertChoixCouleur(node,id) {
  6200. var span = document.createElement('span');
  6201. span.id = 'span'+id;
  6202. // La couleur détaillée passera à une valeur aléatoire
  6203. // si toggle vers isDetailOn
  6204. var couleur = couleurAleatoire();
  6205. if(!isDetailOn) {
  6206. span.style.display = 'none';
  6207. } else if(diploGuilde[id]) {
  6208. couleur = diploGuilde[id].couleur;
  6209. }
  6210. appendText(span,' - Couleur HTML: ');
  6211. var input = appendTextbox(span,'text',id,7,7,couleur);
  6212. input.onkeyup = previewCouleur;
  6213. input.onchange = previewCouleur;
  6214. input.onkeyup();
  6215. insertBefore(node,span);
  6216. }
  6217.  
  6218. function setChoixCouleurs() {
  6219. try {
  6220. var form = document.getElementsByName('ActionForm')[0];
  6221. var nodesAE = document.evaluate(
  6222. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6223. form, null, 7, null
  6224. );
  6225. var nodes = document.evaluate(
  6226. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6227. form, null, 7, null
  6228. );
  6229. } catch(e) {
  6230. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6231. return false;
  6232. };
  6233. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6234. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6235. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6236. for(var i=0 ; i<5 ; i++) {
  6237. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6238. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6239. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6240. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6241. }
  6242. return true;
  6243. }
  6244.  
  6245. function fetchDiploGuilde() {
  6246. try {
  6247. for(var AE in {Amis:0,Ennemis:0}) {
  6248. for(var i=0 ; i<5 ; i++) {
  6249. /* Récup des A/E de rang i */
  6250. var td = document.getElementById('td'+AE+i);
  6251. var ligne = td.getElementsByTagName('table')[0].rows;
  6252. var titre = trim(td.firstChild.textContent);
  6253. // On laisse la gestion des couleurs à setChoixCouleurs:
  6254. var couleur = document.getElementById(AE+i).value;
  6255. diploGuilde[AE+i] = {
  6256. Troll:'',
  6257. Guilde:'',
  6258. titre: titre,
  6259. couleur: couleur
  6260. };
  6261. for(var j=1 ; j<ligne.length ; j++) {
  6262. var str = trim(ligne[j].cells[0].textContent);
  6263. var idx = str.lastIndexOf('(');
  6264. var num = str.slice(idx+1,-1);
  6265. var type = trim(ligne[j].cells[1].textContent);
  6266. diploGuilde[AE+i][type] += num+';';
  6267. }
  6268. }
  6269. }
  6270. } catch(e) {
  6271. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6272. return false;
  6273. }
  6274. return true;
  6275. }
  6276.  
  6277.  
  6278. /*-[functions]--------------------- Handlers ---------------------------------*/
  6279.  
  6280. function toggleDetails() {
  6281. isDetailOn = !isDetailOn;
  6282. for(var AE in {Amis:0,Ennemis:0}) {
  6283. document.getElementById('spanAll'+AE).style.display =
  6284. (isDetailOn?'none':'');
  6285. for(var i=0 ; i<5 ; i++) {
  6286. document.getElementById('span'+AE+i).style.display =
  6287. (isDetailOn?'':'none');
  6288. }
  6289. }
  6290. }
  6291.  
  6292. function toggleMythiques() {
  6293. isMythiquesOn = !isMythiquesOn;
  6294. document.getElementById('spanMythiques').style.display =
  6295. (isMythiquesOn?'':'none');
  6296. }
  6297.  
  6298. function previewCouleur() {
  6299. var value = this.value;
  6300. if(isCouleur(value)) {
  6301. this.style.backgroundColor = value;
  6302. this.title = '';
  6303. } else {
  6304. this.style.backgroundColor = '';
  6305. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  6306. }
  6307. }
  6308.  
  6309. function appendMenuType(node,duType) {
  6310. var select = document.createElement('select');
  6311. select.className = 'SelectboxV2';
  6312. var type = ['Guilde','Troll','Monstre'];
  6313. for(var i=0 ; i<3 ; i++) {
  6314. appendOption(select,type[i],type[i]);
  6315. if(type[i]==duType) { select.selectedIndex=i; }
  6316. }
  6317. node.appendChild(select);
  6318. }
  6319.  
  6320. function ajouteChamp(type,num,couleur,descr) {
  6321. var champs = document.getElementById('diploPerso');
  6322. var nb = champs.rows.length;
  6323. var tr = champs.insertRow(-1);
  6324. var td = appendTd(tr);
  6325. appendMenuType(td,type);
  6326. td = appendTd(tr);
  6327. appendText(td,' n°');
  6328. appendTextbox(td,'text','num'+nb,6,15,num);
  6329. td = appendTd(tr);
  6330. appendText(td,' couleur HTML:');
  6331. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  6332. input.onkeyup = previewCouleur;
  6333. input.onchange = previewCouleur;
  6334. input.onkeyup();
  6335. td = appendTd(tr);
  6336. appendText(td,' Description:');
  6337. appendTextbox(td,'text','descr'+nb,30,150,descr);
  6338. td = appendTd(tr);
  6339. var span = document.createElement('span');
  6340. appendText(span,'[ok!]',true);
  6341. span.style.visibility = 'hidden';
  6342. td.appendChild(span);
  6343. td = appendTd(tr);
  6344. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  6345. }
  6346.  
  6347. function retireCeChamp() {
  6348. var thisTr = this.parentNode.parentNode;
  6349. thisTr.parentNode.removeChild(thisTr);
  6350. var champs = document.getElementById('diploPerso');
  6351. if(champs.rows.length==0) { ajouteChamp(); }
  6352. }
  6353.  
  6354. function valideChamp(champ) {
  6355. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  6356. isCouleur(champ.cells[2].childNodes[1].value);
  6357. if(isValide) {
  6358. champ.cells[4].firstChild.style.visibility = 'visible';
  6359. } else {
  6360. champ.cells[4].firstChild.style.visibility = 'hidden';
  6361. }
  6362. return isValide;
  6363. }
  6364.  
  6365. function sauvegarderTout() {
  6366. /* Diplo de guilde */
  6367. diploGuilde.isOn =
  6368. document.getElementById('isGuildeOn').checked?'true':'false';
  6369. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  6370. var numGuilde = Number(document.getElementById('numGuilde').value);
  6371. var couleur = document.getElementById('couleurGuilde').value;
  6372. if(numGuilde) {
  6373. diploGuilde.guilde = {
  6374. id: numGuilde,
  6375. couleur: couleur
  6376. };
  6377. } else {
  6378. delete diploGuilde.guilde;
  6379. }
  6380. for(var AE in {Amis:0,Ennemis:0}) {
  6381. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  6382. for(var i=0 ; i<5 ; i++) {
  6383. if(isDetailOn) {
  6384. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  6385. } else {
  6386. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  6387. }
  6388. }
  6389. }
  6390. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  6391. /* Diplo personnelle (ex-fonction saveChamps) */
  6392. var champs = document.getElementById('diploPerso');
  6393. diploPerso = {
  6394. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  6395. Guilde: {},
  6396. Troll: {},
  6397. Monstre: {}
  6398. };
  6399. if(isMythiquesOn &&
  6400. isCouleur(document.getElementById('couleurMythiques').value)) {
  6401. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  6402. }
  6403. for(var i=0 ; i<champs.rows.length ; i++) {
  6404. if(valideChamp(champs.rows[i])) {
  6405. var type = champs.rows[i].cells[0].firstChild.value;
  6406. var num = champs.rows[i].cells[1].childNodes[1].value;
  6407. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  6408. var descr = champs.rows[i].cells[3].childNodes[1].value;
  6409. diploPerso[type][num] = {
  6410. couleur: couleur
  6411. };
  6412. if(descr) {
  6413. diploPerso[type][num].titre = descr;
  6414. }
  6415. }
  6416. }
  6417. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  6418.  
  6419. avertissement('Données sauvegardées');
  6420. }
  6421.  
  6422.  
  6423. /*-[functions]------------- Modifications de la page -------------------------*/
  6424.  
  6425. function creeTablePrincipale() {
  6426. var insertPt = document.getElementById('insertPt');
  6427. /* Titre + bouton de Sauvegarde */
  6428. var tr = insertTr(insertPt,'mh_tdtitre');
  6429. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  6430. appendButton(td,'Sauvegarder',sauvegarderTout);
  6431. /* Options fixes */
  6432. tr = insertTr(insertPt,'mh_tdpage');
  6433. td = appendTdText(tr,'Diplomatie de guilde:',true);
  6434. appendBr(td);
  6435. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  6436. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  6437. appendBr(td);
  6438. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  6439. appendText(td,'Utiliser des couleurs détaillées (10)');
  6440. /* Diplo personnelle */
  6441. tr = insertTr(insertPt,'mh_tdpage');
  6442. td = appendTdText(tr,'Diplomatie personnelle:',true);
  6443. appendBr(td);
  6444. // Diplo Mythiques
  6445. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  6446. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  6447. var span = document.createElement('span');
  6448. span.id = 'spanMythiques';
  6449. if(!isMythiquesOn) {
  6450. span.style.display = 'none';
  6451. }
  6452. var couleur = '#FFAAAA';
  6453. if(diploPerso.mythiques) {
  6454. couleur = diploPerso.mythiques;
  6455. }
  6456. appendText(span,' - couleur HTML:');
  6457. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  6458. input.onkeyup = previewCouleur;
  6459. input.onchange = previewCouleur;
  6460. input.onkeyup();
  6461. td.appendChild(span);
  6462. appendBr(td);
  6463. // Diplo éditable
  6464. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  6465. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  6466. appendBr(td);
  6467. var table = document.createElement('table');
  6468. table.id = 'diploPerso'
  6469. td.appendChild(table);
  6470. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  6471. for(var num in diploPerso[type]) {
  6472. ajouteChamp(
  6473. type,
  6474. num,
  6475. diploPerso[type][num].couleur,
  6476. diploPerso[type][num].titre
  6477. );
  6478. }
  6479. }
  6480. if(table.rows.length==0) {
  6481. ajouteChamp();
  6482. }
  6483. appendButton(td,'Ajouter',ajouteChamp)
  6484. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  6485. appendText(td,' ');
  6486. appendButton(td,
  6487. 'Exemples de couleur',
  6488. function() {
  6489. var fenetre = window.open(
  6490. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  6491. 'Divers',
  6492. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  6493. 'status=0,menubar=0,resizable=1,scrollbars=1'
  6494. );
  6495. fenetre.focus();
  6496. }
  6497. );
  6498. /* Couleur de Guilde */
  6499. tr = insertTr(insertPt,'mh_tdtitre');
  6500. td = appendTdText(tr,'GUILDE',true);
  6501. appendText(td,' - n°');
  6502. appendTextbox(td,'text','numGuilde',5,10,
  6503. diploGuilde.guilde && diploGuilde.guilde.id ?
  6504. diploGuilde.guilde.id : ''
  6505. );
  6506. appendText(td,' - Couleur HTML: ');
  6507. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  6508. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  6509. diploGuilde.guilde.couleur : '#BBBBFF'
  6510. );
  6511. input.onkeyup = previewCouleur;
  6512. input.onchange = previewCouleur;
  6513. input.onkeyup();
  6514. }
  6515.  
  6516.  
  6517. /*-[functions]----------------------- Main -----------------------------------*/
  6518.  
  6519. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6520. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6521. var isDetailOn = diploGuilde.isDetailOn=='true';
  6522. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6523. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6524. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6525.  
  6526. function do_diplo() {
  6527. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6528. creeTablePrincipale();
  6529. }
  6530. }
  6531.  
  6532. /*******************************************************************************
  6533. * This file is part of Mountyzilla. *
  6534. * *
  6535. * Mountyzilla is free software; you can redistribute it and/or modify *
  6536. * it under the terms of the GNU General Public License as published by *
  6537. * the Free Software Foundation; either version 2 of the License, or *
  6538. * (at your option) any later version. *
  6539. * *
  6540. * Mountyzilla is distributed in the hope that it will be useful, *
  6541. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6542. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6543. * GNU General Public License for more details. *
  6544. * *
  6545. * You should have received a copy of the GNU General Public License *
  6546. * along with Mountyzilla; if not, write to the Free Software *
  6547. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6548. *******************************************************************************/
  6549.  
  6550. // x~x cdmcomp
  6551.  
  6552. var cdm = '';
  6553.  
  6554. function getNonNegInts(str) {
  6555. var nbrs = str.match(/\d+/g);
  6556. for(var i=0 ; i<nbrs.length ; i++) {
  6557. nbrs[i] = Number(nbrs[i]);
  6558. }
  6559. return nbrs;
  6560. }
  6561.  
  6562. function traiteCdMcomp() {
  6563. try {
  6564. var msgEffet = document.getElementById('msgEffet');
  6565. } catch(e) {
  6566. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  6567. return;
  6568. }
  6569.  
  6570. // Teste si ce message du bot est un message de CdM
  6571. if(!document.evaluate(
  6572. "./p/b/text()[contains(.,'fait partie')]",
  6573. msgEffet, null, 9, null
  6574. ).singleNodeValue) {
  6575. return;
  6576. }
  6577. // Début de récupération de la CdM
  6578. cdm = document.evaluate(
  6579. "./p/b/text()[contains(.,'fait partie')]",
  6580. msgEffet, null, 9, null
  6581. ).singleNodeValue.nodeValue+'\n';
  6582. var tbody = document.evaluate(
  6583. "descendant::table/tbody",
  6584. msgEffet, null, 9, null
  6585. ).singleNodeValue;
  6586. var nomStat = document.evaluate(
  6587. "./tr/td[1]/b/text()",
  6588. tbody, null, 7, null
  6589. );
  6590. var valStat = document.evaluate(
  6591. "./tr/td[2]/descendant::text()",
  6592. tbody, null, 7, null
  6593. );
  6594. var i=0;
  6595. while(i<nomStat.snapshotLength) {
  6596. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  6597. cdm += 'Armure : ';
  6598. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  6599. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  6600. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  6601. armp = [0,armp[0]];
  6602. }
  6603. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  6604. armm = [0,armm[0]];
  6605. }
  6606. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  6607. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  6608. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  6609. } else {
  6610. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6611. }
  6612. cdm += ')\n';
  6613. i++;
  6614. } else {
  6615. cdm += nomStat.snapshotItem(i).nodeValue+
  6616. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  6617. }
  6618. i++;
  6619. }
  6620. // Envoi auto ou insertion bouton envoi (suivant option)
  6621. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  6622. sendInfoCDM();
  6623. var p = document.createElement('p');
  6624. p.style.color = 'green';
  6625. appendText(p,'CdM envoyée vers la base MountyZilla !');
  6626. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  6627. } else {
  6628. insertButtonCdm('as_Action', sendInfoCDM);
  6629. }
  6630.  
  6631. // Insertion de l'estimation des PV restants
  6632. var pv = valStat.snapshotItem(1).nodeValue;
  6633. if(pv.indexOf("entre")==-1) {
  6634. return;
  6635. }
  6636. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  6637. if(pv) {
  6638. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  6639. appendTdText(tr, pv[0], true);
  6640. appendTdText(tr, pv[1], true);
  6641. }
  6642. }
  6643.  
  6644. function sendInfoCDM() {
  6645. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  6646. var buttonCDM = this;
  6647. var texte = '';
  6648. FF_XMLHttpRequest({
  6649. method: 'GET',
  6650. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6651. headers : {
  6652. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6653. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6654. },
  6655. onload: function(responseDetails) {
  6656. texte = responseDetails.responseText;
  6657. buttonCDM.value = texte;
  6658. buttonCDM.disabled = true;
  6659. }
  6660. });
  6661. }
  6662.  
  6663. function do_cdmcomp() {
  6664. start_script(31);
  6665. traiteCdMcomp();
  6666. displayScriptTime();
  6667. }
  6668.  
  6669. /*********************************************************************************
  6670. * This file is part of Mountyzilla. *
  6671. * *
  6672. * Mountyzilla is free software; you can redistribute it and/or modify *
  6673. * it under the terms of the GNU General Public License as published by *
  6674. * the Free Software Foundation; either version 2 of the License, or *
  6675. * (at your option) any later version. *
  6676. * *
  6677. * Mountyzilla is distributed in the hope that it will be useful, *
  6678. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6679. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6680. * GNU General Public License for more details. *
  6681. * *
  6682. * You should have received a copy of the GNU General Public License *
  6683. * along with Mountyzilla; if not, write to the Free Software *
  6684. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6685. *********************************************************************************/
  6686.  
  6687. // x~x cmdbot
  6688.  
  6689. /* v0.2 by Dab - 2013-08-20
  6690. * - patch dégueu pour gérer la décomposition P/M de l'armure
  6691. */
  6692.  
  6693. var buttonCDM;
  6694.  
  6695. /*******************************************************************************************
  6696. CDM :
  6697. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  6698.  
  6699. Il ne vous est pas possible d'améliorer cette compétence.
  6700.  
  6701. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  6702. Niveau : Inimaginable (entre 49 et 51)
  6703. Points de Vie : Surtrollesque (entre 450 et 470)
  6704. Blessure (Approximatif) : 0 %
  6705. Dés d'Attaque : Impressionnant (entre 30 et 32)
  6706. Dés d'Esquive : Impressionnant (entre 28 et 30)
  6707. Dés de Dégat : Très Fort (entre 18 et 20)
  6708. Dés de Régénération : Excellent (égal à 13)
  6709. Armure Physique : Moyen (entre 10 et 12)
  6710. Armure Magique : Faible (inférieur à 6)
  6711. Vue : Moyen (entre 9 et 11)
  6712. Maitrise Magique : Inimaginable (supérieur à 6000)
  6713. Résistance Magique : Inimaginable (supérieur à 6000)
  6714. Nombre d'attaques : 1
  6715. Vitesse de Déplacement : Normale
  6716. Voir le Caché : Oui
  6717. Attaque à distance : Non
  6718. Attaque magique : Oui
  6719. Vole : Non
  6720. Sang froid : Inexistant
  6721. DLA : Milieu
  6722. Durée Tour : Remarquable (entre 9 et 11)
  6723. Chargement : Vide
  6724. Bonus Malus : Aucun
  6725.  
  6726. Vous avez également gagné 1 PX pour la réussite.
  6727. *******************************************************************************************
  6728. BOT :
  6729. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  6730.  
  6731. Le Monstre ciblé fait partie des : Mort-Vivant
  6732.  
  6733. Niveau : Incroyable (entre 36 et 38)
  6734. *******************************************************************************************/
  6735.  
  6736. function getNNInt(str) {
  6737. var nbrs = str.match(/\d+/g);
  6738. for (var i=0 ; i<nbrs.length ; i++)
  6739. nbrs[i] = parseInt(nbrs[i]);
  6740. return nbrs;
  6741. }
  6742.  
  6743. function sendCDM() {
  6744. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6745. document, null, 9, null).singleNodeValue;
  6746. cdm = td.innerHTML;
  6747. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  6748. "$3$4 ($1 - N°$2)<br>");
  6749. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  6750. 'Blessure : XX % (approximativement)');
  6751. // Supprime la décomposition P/M de l'Armure
  6752. var bgn = cdm.indexOf('Armure Physique');
  6753. if (bgn!=-1) {
  6754. var end = cdm.indexOf('Vue')-2;
  6755. var lines = cdm.substring(bgn,end).split('<br>');
  6756. var armp = getNNInt(lines[0]);
  6757. var armm = getNNInt(lines[1]);
  6758. if (lines[0].indexOf('(inf')!=-1)
  6759. armp = [0,armp[0]];
  6760. if (lines[1].indexOf('(inf')!=-1)
  6761. armm = [0,armm[0]];
  6762. var insrt = 'Armure : ';
  6763. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  6764. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  6765. else
  6766. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6767. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  6768. }
  6769. cdm = cdm.replace(/<br>/g,'\n');
  6770. FF_XMLHttpRequest({
  6771. method: 'GET',
  6772. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6773. headers : {
  6774. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6775. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6776. },
  6777. onload: function(responseDetails) {
  6778. buttonCDM.value=responseDetails.responseText;
  6779. buttonCDM.disabled = true;
  6780. }
  6781. });
  6782. }
  6783.  
  6784. function traiteCdMmsg() {
  6785. // Teste si ce message du bot est un message de CdM
  6786. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6787. document, null, 9, null).singleNodeValue;
  6788. if (!td) return false;
  6789. cdm = td.innerHTML;
  6790. // Insertion de l'estimation des PV restants
  6791. var des = cdm.indexOf('Dés');
  6792. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  6793. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  6794. if(pv)
  6795. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  6796.  
  6797. // Insertion bouton envoi + espace
  6798. buttonCDM = insertButtonCdm('bClose',sendCDM);
  6799. }
  6800.  
  6801. /*function traitePouvoir() {
  6802. // Teste si ce message du bot est un message de CdM
  6803. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  6804. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  6805. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6806. if (!td)
  6807. return false;
  6808. var infos = td.innerHTML;
  6809. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  6810. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  6811. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  6812. var date = /alors : ([^<]+)\./.exec(infos)[1];
  6813. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  6814. var effetPouvoir="";
  6815. var full=false;
  6816. if(infos.indexOf("REDUIT")!=-1) {
  6817. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  6818. }
  6819. else {
  6820. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  6821. full=true;
  6822. }
  6823. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  6824. // On insère le bouton et un espace
  6825. //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));
  6826. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  6827. if(!MY_getValue('AUTOSENDPOUV'))
  6828. {
  6829. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  6830. button.setAttribute("onClick", "window.open('" + url
  6831. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  6832. + "this.value='Merci de votre participation'; this.disabled = true;");
  6833. }
  6834. else
  6835. {
  6836. FF_XMLHttpRequest({
  6837. method: 'GET',
  6838. url: url,
  6839. headers : {
  6840. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6841. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6842. }});
  6843. }
  6844. }*/
  6845.  
  6846. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  6847. traiteCdMmsg();
  6848. }
  6849. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  6850.  
  6851. /*******************************************************************************
  6852. * This file is part of Mountyzilla. *
  6853. * *
  6854. * Mountyzilla is free software; you can redistribute it and/or modify *
  6855. * it under the terms of the GNU General Public License as published by *
  6856. * the Free Software Foundation; either version 2 of the License, or *
  6857. * (at your option) any later version. *
  6858. * *
  6859. * Mountyzilla is distributed in the hope that it will be useful, *
  6860. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6861. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6862. * GNU General Public License for more details. *
  6863. * *
  6864. * You should have received a copy of the GNU General Public License *
  6865. * along with Mountyzilla; if not, write to the Free Software *
  6866. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6867. *******************************************************************************/
  6868.  
  6869. // x~x menu
  6870. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  6871.  
  6872. var menuRac, mainIco;
  6873.  
  6874. function updateData() {
  6875. var inputs = document.getElementsByTagName('input');
  6876. var divs = document.getElementsByTagName('div');
  6877. numTroll = inputs[0].value;
  6878. MY_setValue('NUM_TROLL', numTroll);
  6879. MY_setValue('NIV_TROLL',inputs[1].value);
  6880. if(!MY_getValue(numTroll+'.caracs.rm')) {
  6881. MY_setValue(numTroll+'.caracs.rm',0);
  6882. // assure l'init des 4 var de libs
  6883. }
  6884. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  6885. var DLA = new Date(
  6886. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  6887. );
  6888. if(MY_getValue(numTroll+'.DLA.encours')) {
  6889. var DLAstockee = new Date(
  6890. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  6891. );
  6892. if(DLA>DLAstockee) {
  6893. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  6894. // Pose un pb en cas de décalage de DLA
  6895. }
  6896. }
  6897. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  6898. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  6899. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  6900. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  6901. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  6902. }
  6903.  
  6904. function initRaccourcis() {
  6905. var anotherURL = MY_getValue('URL1');
  6906. if(!anotherURL) { return; }
  6907. /* Création de l'icône faisant apparaître le menu */
  6908. mainIco = document.createElement('img');
  6909. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  6910. if(!urlIco) {
  6911. urlIco =
  6912. URL_MZimg + 'mz_logo_small.png';
  6913. }
  6914. mainIco.src = urlIco;
  6915. mainIco.alt = 'MZ';
  6916. mainIco.style = 'position:fixed; top:0px; left:0px';
  6917. mainIco.onmouseover = afficheMenu;
  6918. document.body.appendChild(mainIco);
  6919. /* Création du menu des Raccourcis */
  6920. menuRac = document.createElement('div');
  6921. menuRac.className = 'mh_textbox';
  6922. menuRac.style =
  6923. 'position:fixed; top:10px; left:10px;'+
  6924. 'max-width:190px;'+
  6925. 'border-radius: 4px; padding: 4px;'+
  6926. 'z-index: 500;'+
  6927. 'visibility: hidden;';
  6928. document.body.appendChild(menuRac);
  6929. document.addEventListener('mousemove',cacheMenu,false);
  6930. var i=1;
  6931. while(anotherURL) {
  6932. var a = document.createElement('a');
  6933. var url = MY_getValue('URL'+i);
  6934. var nom = MY_getValue('URL'+i+'.nom');
  6935. var ico = MY_getValue('URL'+i+'.ico');
  6936. a.href = url;
  6937. a.target = '_blank';
  6938. if(ico) {
  6939. var txt = nom ? nom : '';
  6940. var img = createImage(ico,txt);
  6941. a.appendChild(img);
  6942. }
  6943. else {
  6944. appendText(a,'['+nom+']');
  6945. }
  6946. menuRac.appendChild(a);
  6947. appendBr(menuRac);
  6948. i++;
  6949. anotherURL = MY_getValue('URL'+i);
  6950. }
  6951. }
  6952.  
  6953. function afficheMenu() {
  6954. menuRac.style.visibility = 'visible';
  6955. }
  6956.  
  6957. function cacheMenu(e) {
  6958. if(menuRac.style.visibility=='hidden') { return; }
  6959. // Position souris
  6960. var ptX = e.clientX;
  6961. var ptY = e.clientY;
  6962. // On recalcule en live les BoundingBox pour mainIco et menuRac
  6963. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  6964. var menuRect = menuRac.getBoundingClientRect();
  6965. var icoRect = mainIco.getBoundingClientRect();
  6966. if((ptX>icoRect.width || ptY>icoRect.height) &&
  6967. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  6968. menuRac.style.visibility = 'hidden';
  6969. }
  6970. }
  6971.  
  6972. function oldSchoolProfile() {
  6973. try {
  6974. var lienProfil = document.getElementById("Image1").parentNode;
  6975. lienProfil.href = "Play_profil.php";
  6976. } catch(e) {
  6977. avertissement();
  6978. window.console.log(traceStack(e, 'menu Lien vers le profil non trouvé'));
  6979. }
  6980. }
  6981.  
  6982. function do_menu() {
  6983. updateData();
  6984. initRaccourcis();
  6985. if(MY_getValue(numTroll+".OLDSCHOOL")=="true") {
  6986. oldSchoolProfile();
  6987. }
  6988. }
  6989.  
  6990. /*******************************************************************************
  6991. * This file is part of Mountyzilla. *
  6992. * *
  6993. * Mountyzilla is free software; you can redistribute it and/or modify *
  6994. * it under the terms of the GNU General Public License as published by *
  6995. * the Free Software Foundation; either version 2 of the License, or *
  6996. * (at your option) any later version. *
  6997. * *
  6998. * Mountyzilla is distributed in the hope that it will be useful, *
  6999. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7000. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7001. * GNU General Public License for more details. *
  7002. * *
  7003. * You should have received a copy of the GNU General Public License *
  7004. * along with Mountyzilla; if not, write to the Free Software *
  7005. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7006. *******************************************************************************/
  7007.  
  7008. // x~x vue
  7009.  
  7010. /* TODO
  7011. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7012. * prévoir fix ("delete infos")
  7013. */
  7014.  
  7015. /*--------------------------- Variables Globales -----------------------------*/
  7016.  
  7017. // Infos remplies par des scripts extérieurs
  7018. var listeCDM = [], listeLevels = [];
  7019.  
  7020. // Position actuelle
  7021. var currentPosition=[0,0,0];
  7022.  
  7023. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7024. var porteeVue=[0,0,0,0];
  7025.  
  7026. // Fenêtres déplaçables
  7027. var winCurr = null;
  7028. var offsetX, offsetY;
  7029. document.onmousemove = drag;
  7030.  
  7031. // Diplomatie
  7032. var Diplo = {
  7033. Guilde: {},
  7034. Troll: {},
  7035. Monstre: {}
  7036. // .mythiques: uniquement si option activée
  7037. };
  7038. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7039.  
  7040. // Infos tactiques
  7041. var popup;
  7042.  
  7043. // Gère l'affichage en cascade des popups de CdM
  7044. var nbCDM = 0;
  7045.  
  7046. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7047.  
  7048. // Utilisé pour supprimer les monstres "engagés"
  7049. var listeEngages = {};
  7050. var isEngagesComputed = false;
  7051. var cursorOnLink = false; // DEBUG: wtf ?
  7052.  
  7053. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7054. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7055.  
  7056. // Checkboxes de filtrage
  7057. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7058. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7059. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  7060. comboBoxNiveauMin, comboBoxNiveauMax;
  7061.  
  7062. /* Acquisition & Stockage des données de DB */
  7063. const typesAFetcher = {
  7064. 'monstres':1,
  7065. 'trolls':1,
  7066. 'tresors':1,
  7067. 'champignons':1,
  7068. 'lieux':1
  7069. }
  7070. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7071. tr_champignons = {}, tr_lieux = {};
  7072. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7073. nbChampignons = 0, nbLieux = 0;
  7074.  
  7075. function fetchData(type) {
  7076. try {
  7077. var node = document.getElementById('mh_vue_hidden_'+type);
  7078. // this = MZ.global = sandBox de travail de MZ
  7079. // On définit donc des variables MZ-globales
  7080. this['tr_'+type] = node.getElementsByTagName('tr');
  7081. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7082. } catch(e) {
  7083. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7084. }
  7085. }
  7086.  
  7087.  
  7088. /*---------------------------------- DEBUG -----------------------------------*/
  7089. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7090. var x_monstres = tr_monstres;
  7091. var x_trolls = tr_trolls;
  7092. var x_tresors = tr_tresors;
  7093. var x_champis = tr_champignons;
  7094. var x_lieux = tr_lieux;
  7095. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7096.  
  7097.  
  7098. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7099.  
  7100. function positionToString(arr) {
  7101. return arr.join(';');
  7102. }
  7103.  
  7104. function savePosition() {
  7105. // Stocke la position (à jour) de la vue pour les autres scripts
  7106. // DEBUG: Lesquels et pourquoi?
  7107. var pos = getPosition();
  7108. MY_setValue(numTroll+'.position.X',pos[0]);
  7109. MY_setValue(numTroll+'.position.Y',pos[1]);
  7110. MY_setValue(numTroll+'.position.N',pos[2]);
  7111. }
  7112.  
  7113.  
  7114. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7115. /* INFOS :
  7116. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7117. * sont identifiables via leur Name
  7118. * les tables-listings sont identifiables via l'ID du tr conteneur
  7119. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7120. */
  7121.  
  7122. /* [functions] Récup données Utilisateur */
  7123. function getPosition() {
  7124. // Pour rétrocompatibilité
  7125. return currentPosition;
  7126. }
  7127.  
  7128. function getPorteVue() {
  7129. // Pour rétrocompatibilité
  7130. return porteeVue;
  7131. }
  7132.  
  7133. function getVue() {
  7134. // Retourne [vueHpure, vueVpure]
  7135. var vues = getPorteVue();
  7136. return [ vues[0], vues[1] ];
  7137. }
  7138.  
  7139. // Roule 11/03/2016
  7140. /* [functions] Récup données monstres, trolls, etc. */
  7141. function getXxxDistance(xxx, i) {
  7142. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7143. }
  7144. function getXxxPosition(xxx, i) {
  7145. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7146. var l = tds.length;
  7147. return [
  7148. parseInt(tds[l-3].textContent),
  7149. parseInt(tds[l-2].textContent),
  7150. parseInt(tds[l-1].textContent)
  7151. ];
  7152. }
  7153.  
  7154.  
  7155. /* [functions] Récup données monstres */
  7156. function getMonstreDistance(i) {
  7157. return parseInt(tr_monstres[i].cells[0].textContent);
  7158. }
  7159.  
  7160. function getMonstreID(i) {
  7161. return tr_monstres[i].cells[2].firstChild.nodeValue;
  7162. }
  7163.  
  7164. function getMonstreIDByTR(tr) {
  7165. return tr.cells[2].firstChild.nodeValue;
  7166. }
  7167.  
  7168. function getMonstreLevelNode(i) {
  7169. return tr_monstres[i].cells[3];
  7170. }
  7171.  
  7172. function getMonstreLevel(i) {
  7173. if(!isCDMsRetrieved) return -1;
  7174. var donneesMonstre = listeCDM[getMonstreID(i)];
  7175. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  7176. }
  7177.  
  7178. function getMonstreNomNode(i) {
  7179. try {
  7180. var td = document.evaluate(
  7181. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  7182. tr_monstres[i], null, 9, null
  7183. ).singleNodeValue;
  7184. return td;
  7185. } catch(e) {
  7186. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  7187. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  7188. }
  7189. }
  7190.  
  7191. function getMonstreNom(i) {
  7192. return getMonstreNomByTR(tr_monstres[i]);
  7193. }
  7194.  
  7195. function getMonstreNomByTR(tr) {
  7196. try {
  7197. var nom = document.evaluate(
  7198. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  7199. tr, null, 2, null
  7200. ).stringValue;
  7201. return nom;
  7202. } catch(e) {
  7203. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  7204. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  7205. }
  7206. }
  7207.  
  7208. function getMonstrePosition(i) {
  7209. var tds = tr_monstres[i].childNodes;
  7210. var l = tds.length;
  7211. return [
  7212. parseInt(tds[l-3].textContent),
  7213. parseInt(tds[l-2].textContent),
  7214. parseInt(tds[l-1].textContent)
  7215. ];
  7216. }
  7217.  
  7218. function appendMonstres(txt) {
  7219. for(var i=1; i<=nbMonstres ; i++)
  7220. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  7221. return txt;
  7222. }
  7223.  
  7224. function getMonstres() {
  7225. var vue = getVue();
  7226. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7227. }
  7228.  
  7229. function bddMonstres(start,stop) {
  7230. if(!start) { var start = 1; }
  7231. if(!stop) { var stop = nbMonstres; }
  7232. stop = Math.min(nbMonstres,stop);
  7233. var txt='';
  7234. for(var i=start ; i<=stop ; i++) {
  7235. txt += getMonstreID(i)+';'+
  7236. getMonstreNom(i)+';'+
  7237. positionToString(getMonstrePosition(i))+'\n';
  7238. }
  7239. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  7240. }
  7241.  
  7242. /* [functions] Récup données Trolls */
  7243. function getTrollDistance(i) {
  7244. return parseInt(tr_trolls[i].cells[0].textContent);
  7245. }
  7246.  
  7247. function getTrollID(i) {
  7248. return parseInt(tr_trolls[i].cells[2].textContent);
  7249. }
  7250.  
  7251. function getTrollNomNode(i) {
  7252. var isEnvoiOn =
  7253. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  7254. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  7255. }
  7256.  
  7257. function getTrollNivNode(i) {
  7258. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  7259. return tr_trolls[i].cells[4];
  7260. }
  7261.  
  7262. function getTrollGuilde(i) {
  7263. return trim(tr_trolls[i].cells[6].textContent);
  7264. }
  7265.  
  7266. function getTrollGuildeID(i) {
  7267. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  7268. var href;
  7269. try {
  7270. 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"
  7271. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  7272. } catch(e) { // debug pb remonté par Marsak
  7273. window.console.error(traceStack(e, 'getTrollGuildeID')
  7274. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  7275. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  7276. return -1;
  7277. }
  7278. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  7279. }
  7280. return -1;
  7281. }
  7282.  
  7283. function getTrollPosition(i) {
  7284. var tds = tr_trolls[i].childNodes;
  7285. var l = tds.length;
  7286. return [
  7287. parseInt(tds[l-3].textContent),
  7288. parseInt(tds[l-2].textContent),
  7289. parseInt(tds[l-1].textContent)
  7290. ];
  7291. }
  7292.  
  7293. function bddTrolls() {
  7294. var txt='#DEBUT TROLLS\n'+
  7295. numTroll+';'+positionToString(getPosition())+'\n';
  7296. for(var i=1 ; i<=nbTrolls ; i++) {
  7297. txt += getTrollID(i)+';'+
  7298. positionToString(getTrollPosition(i))+'\n';
  7299. }
  7300. return txt+'#FIN TROLLS';
  7301. }
  7302.  
  7303. /* [functions] Récup données Trésors */
  7304. function getTresorDistance(i) {
  7305. return tr_tresors[i].cells[0].firstChild.nodeValue;
  7306. }
  7307.  
  7308. function getTresorID(i) {
  7309. return trim(tr_tresors[i].cells[2].textContent);
  7310. }
  7311.  
  7312. function getTresorNom(i) {
  7313. // Utilisation de textContent pour régler le "bug de Pollux"
  7314. return trim(tr_tresors[i].cells[3].textContent);
  7315. }
  7316.  
  7317. function getTresorPosition(i) {
  7318. var tds = tr_tresors[i].childNodes;
  7319. var l = tds.length;
  7320. return [
  7321. parseInt(tds[l-3].textContent),
  7322. parseInt(tds[l-2].textContent),
  7323. parseInt(tds[l-1].textContent),
  7324. ];
  7325. }
  7326.  
  7327. function bddTresors(dmin,start,stop) {
  7328. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  7329. if(!dmin) { var dmin = 0; }
  7330. if(!start) { var start = 1; }
  7331. if(!stop) { var stop = nbTresors; }
  7332. stop = Math.min(nbTresors,stop);
  7333. var txt='';
  7334. for(var i=start ; i<=stop ; i++) {
  7335. if(getTresorDistance(i)>=dmin) {
  7336. txt += getTresorID(i)+';'+
  7337. getTresorNom(i)+';'+
  7338. positionToString(getTresorPosition(i))+'\n';
  7339. }
  7340. }
  7341. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  7342. }
  7343.  
  7344. /* [functions] Récup données Champignons */
  7345. // DEBUG: Pas de colonne "Référence" sur serveur de test
  7346. function getChampignonNom(i) {
  7347. return trim(tr_champignons[i].cells[2].textContent);
  7348. }
  7349.  
  7350. function getChampignonPosition(i) {
  7351. var tds = tr_champignons[i].childNodes;
  7352. var l = tds.length;
  7353. return [
  7354. parseInt(tds[l-3].textContent),
  7355. parseInt(tds[l-2].textContent),
  7356. parseInt(tds[l-1].textContent)
  7357. ];
  7358. }
  7359.  
  7360. function bddChampignons() {
  7361. var txt='';
  7362. for(var i=1 ; i<=nbChampignons ; i++) {
  7363. txt += ';'+ // Les champis n'ont pas de Référence
  7364. getChampignonNom(i)+';'+
  7365. positionToString(getChampignonPosition(i))+'\n';
  7366. }
  7367. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  7368. }
  7369.  
  7370. /* [functions] Récup données Lieux */
  7371. function getLieuDistance(i) {
  7372. return parseInt(tr_lieux[i].cells[0].textContent);
  7373. }
  7374.  
  7375. function getLieuID(i) {
  7376. return parseInt(tr_lieux[i].cells[2].textContent);
  7377. }
  7378.  
  7379. function getLieuNom(i) {
  7380. // Conversion ASCII pour éviter les bugs des Vues externes
  7381. return trim(tr_lieux[i].cells[3].textContent);
  7382. }
  7383.  
  7384. function getLieuPosition(i) {
  7385. var tds = tr_lieux[i].childNodes;
  7386. var l = tds.length;
  7387. return [
  7388. parseInt(tds[l-3].textContent),
  7389. parseInt(tds[l-2].textContent),
  7390. parseInt(tds[l-1].textContent)
  7391. ];
  7392. }
  7393.  
  7394. function appendLieux(txt) {
  7395. for(var i = 1; i < nbLieux+1; i++) {
  7396. var tds = x_lieux[i].childNodes;
  7397. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  7398. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  7399. }
  7400. return txt;
  7401. }
  7402.  
  7403. function getLieux() {
  7404. var vue = getVue();
  7405. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7406. }
  7407.  
  7408. function bddLieux(start,stop) {
  7409. if(!start) { var start = 1; }
  7410. if(!stop) { var stop = nbLieux; }
  7411. stop = Math.min(nbLieux,stop);
  7412. var txt='';
  7413. for(var i=start ; i<=stop ; i++) {
  7414. txt += getLieuID(i)+';'+
  7415. epure(getLieuNom(i))+';'+
  7416. positionToString(getLieuPosition(i))+'\n';
  7417. }
  7418. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  7419. }
  7420.  
  7421.  
  7422. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  7423.  
  7424. function saveCheckBox(chkbo, pref) {
  7425. // Enregistre et retourne l'état d'une CheckBox
  7426. var etat = chkbo.checked;
  7427. MY_setValue(pref, etat ? 'true' : 'false' );
  7428. return etat;
  7429. }
  7430.  
  7431. function recallCheckBox(chkbox, pref) {
  7432. // Restitue l'état d'une CheckBox
  7433. chkbox.checked = (MY_getValue(pref)=='true');
  7434. }
  7435.  
  7436. function saveComboBox(cbb, pref) {
  7437. // Enregistre et retourne l'état d'une ComboBox
  7438. var etat = cbb.selectedIndex;
  7439. MY_setValue(pref, etat);
  7440. return etat;
  7441. }
  7442.  
  7443. function recallComboBox(cbb, pref) {
  7444. // Restitue l'état d'une ComboBox
  7445. var nb = MY_getValue(pref);
  7446. if(nb) cbb.value = nb;
  7447. return nb;
  7448. }
  7449.  
  7450. function synchroniseFiltres() {
  7451. // Récupération de toutes les options de la vue
  7452. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  7453. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  7454. if(numBool) {
  7455. debutFiltrage('Monstres');
  7456. }
  7457. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  7458. recallCheckBox(checkBoxMythiques,'NOMYTH');
  7459. recallCheckBox(checkBoxEngages,'NOENGAGE');
  7460. recallCheckBox(checkBoxLevels,'NOLEVEL');
  7461. recallCheckBox(checkBoxIntangibles,'NOINT');
  7462. recallCheckBox(checkBoxGG,'NOGG');
  7463. recallCheckBox(checkBoxCompos,'NOCOMP');
  7464. recallCheckBox(checkBoxBidouilles,'NOBID');
  7465. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  7466. recallCheckBox(checkBoxTrou,'NOTROU');
  7467. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  7468. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  7469. if(MY_getValue('NOINFOEM')!='true')
  7470. recallCheckBox(checkBoxEM,'NOEM');
  7471. }
  7472.  
  7473.  
  7474. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  7475.  
  7476. /* [functions] Menu Vue 2D */
  7477. var vue2Ddata = {
  7478. 'Bricol\' Vue': {
  7479. url: URL_bricol_mountyhall + 'vue_form.php',
  7480. paramid: 'vue',
  7481. func: getVueScript,
  7482. extra_params: {
  7483. 'mode': 'vue_SP_Vue2',
  7484. 'screen_width': window.screen.width
  7485. }
  7486. },
  7487. 'Vue du CCM': {
  7488. url: URL_vue_CCM,
  7489. paramid: 'vue',
  7490. func: getVueScript,
  7491. extra_params: {
  7492. 'id': numTroll+';'+positionToString(getPosition())
  7493. }
  7494. },
  7495. 'Vue Gloumfs 2D': {
  7496. url: URL_vue_Gloumfs2D,
  7497. paramid: 'vue_mountyzilla',
  7498. func: getVueScript,
  7499. extra_params: {}
  7500. },
  7501. 'Vue Gloumfs 3D': {
  7502. url: URL_vue_Gloumfs3D,
  7503. paramid: 'vue_mountyzilla',
  7504. func: getVueScript,
  7505. extra_params: {}
  7506. },
  7507. 'Grouky Vue!': {
  7508. url: URL_vue_Grouky,
  7509. paramid: 'vue',
  7510. func: getVueScript,
  7511. extra_params: {
  7512. 'type_vue': 'V5b1'
  7513. }
  7514. },
  7515. /*'DEBUG': {
  7516. url: 'http://weblocal/testeur.php',
  7517. paramid: 'vue',
  7518. func: getVueScript,
  7519. extra_params: {}
  7520. }*/
  7521. };
  7522.  
  7523. function getVueScript() {
  7524. try {
  7525. var txt = bddTrolls()+
  7526. bddMonstres()+
  7527. bddChampignons()+
  7528. bddTresors()+
  7529. bddLieux()+
  7530. '#DEBUT ORIGINE\n'+
  7531. getPorteVue()[2]+';'+positionToString(getPosition())+
  7532. '\n#FIN ORIGINE\n';
  7533. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  7534. return txt;
  7535. } catch(e) {
  7536. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7537. window.console.error(traceStack(e, 'getVueScript'))
  7538. }
  7539. }
  7540.  
  7541. function refresh2DViewButton() {
  7542. // = EventListener menu+bouton vue 2D
  7543. var vueext = document.getElementById('selectVue2D').value;
  7544. MY_setValue('VUEEXT',vueext);
  7545. var form = document.getElementById('viewForm');
  7546. form.innerHTML = '';
  7547. form.method = 'post';
  7548. form.action = vue2Ddata[vueext].url;
  7549. form.target = '_blank';
  7550. appendHidden(form, vue2Ddata[vueext].paramid, '');
  7551. for(var key in vue2Ddata[vueext].extra_params) {
  7552. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  7553. }
  7554. appendSubmit(form, 'Voir',
  7555. function() {
  7556. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  7557. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  7558. vue2Ddata[vueext].func();
  7559. }
  7560. );
  7561. }
  7562.  
  7563. function set2DViewSystem() {
  7564. // Initialise le système de vue 2D
  7565. // Recherche du point d'insertion
  7566. try {
  7567. var center = document.evaluate(
  7568. "//h2[@id='titre2']/following-sibling::center",
  7569. document, null, 9, null
  7570. ).singleNodeValue;
  7571. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  7572. if (!center) center = document.evaluate(
  7573. "//h2[@id='titre2']/following-sibling::div",
  7574. document, null, 9, null
  7575. ).singleNodeValue;
  7576. } catch(e) {
  7577. avertissement("Erreur d'initialisation du système de vue 2D");
  7578. window.console.error(traceStack(e, 'set2DViewSystem'));
  7579. return;
  7580. }
  7581. // Récupération de la dernière vue utilisée
  7582. var vueext = MY_getValue('VUEEXT');
  7583. if(!vueext || !vue2Ddata[vueext]) {
  7584. // sinon, la vue Bricol'Trolls est employée par défaut
  7585. vueext = 'Bricol\' Vue';
  7586. }
  7587. try {
  7588. // Création du sélecteur de vue externe
  7589. selectVue2D = document.createElement('select');
  7590. selectVue2D.id = 'selectVue2D';
  7591. selectVue2D.className = 'SelectboxV2';
  7592. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  7593. for(var view in vue2Ddata) {
  7594. appendOption(selectVue2D, view, view);
  7595. }
  7596. selectVue2D.value = vueext;
  7597. selectVue2D.onchange = refresh2DViewButton;
  7598. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  7599. var form = document.createElement('form');
  7600. form.id = 'viewForm';
  7601. // Insertion du système de vue
  7602. var table = document.createElement('table');
  7603. var tr = appendTr(table);
  7604. var td = appendTd(tr);
  7605. td.appendChild(selectVue2D);
  7606. td = appendTd(tr);
  7607. td.style.fontSize = '0px'; // gère le bug de l'extra character
  7608. td.appendChild(form);
  7609. center.insertBefore(table,center.firstChild);
  7610. insertBr(center.childNodes[1]);
  7611. // Appelle le handler pour initialiser le bouton de submit
  7612. refresh2DViewButton();
  7613. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  7614. } catch(e) {
  7615. avertissement("Erreur de traitement du système de vue 2D");
  7616. window.console.error(traceStack(e, 'set2DViewSystem'));
  7617. }
  7618. }
  7619.  
  7620. /* [functions] Tableau d'Infos */
  7621. function initialiseInfos() {
  7622. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  7623. var
  7624. infoTab = document.getElementsByName('LimitViewForm')[0].
  7625. getElementsByTagName('table')[0],
  7626. tbody = infoTab.tBodies[0],
  7627. thead = infoTab.createTHead(),
  7628. tr = appendTr(thead,'mh_tdtitre'),
  7629. td = appendTdText(tr,'INFORMATIONS',true),
  7630. span = document.createElement('span');
  7631. // Récupération de la position du joueur
  7632. try {
  7633. var strPos = document.evaluate(
  7634. ".//li/b/text()[contains(.,'X = ')]",
  7635. infoTab, null, 9, null
  7636. ).singleNodeValue.nodeValue;
  7637. // ***INIT GLOBALE*** currentPosition
  7638. currentPosition = getNumbers(strPos);
  7639. debugMZ("retrievePosition(): "+currentPosition);
  7640. } catch(e) {
  7641. // Si on ne trouve pas le "X ="
  7642. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  7643. }
  7644. // Récupération des portées (max et limitée) de la vue
  7645. try {
  7646. var
  7647. nodes = document.evaluate(
  7648. ".//li/b/text()[contains(.,'horizontalement') "+
  7649. "or contains(.,'verticalement')]",
  7650. infoTab, null, 7, null
  7651. ),
  7652. array = [];
  7653. for(var i=0 ; i<4 ; i++) {
  7654. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  7655. }
  7656. // ***INIT GLOBALE*** porteeVue
  7657. porteeVue = array;
  7658. } catch(e) {
  7659. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  7660. }
  7661.  
  7662. infoTab.id = 'infoTab'; // Pour scripts externes
  7663. tbody.id = 'corpsInfoTab';
  7664. tbody.rows[0].cells[0].colSpan = 2;
  7665. td.colSpan = 3;
  7666. td.onmouseover = function() {
  7667. this.style.cursor = 'pointer';
  7668. this.className = 'mh_tdpage';
  7669. };
  7670. td.onmouseout = function() {
  7671. this.className = 'mh_tdtitre';
  7672. };
  7673. td.onclick = function() {
  7674. toggleTableauInfos(false);
  7675. };
  7676. span.id = 'msgInfoTab';
  7677. span.style.display = 'none';
  7678. appendText(
  7679. span,
  7680. ' => Position : X = '+currentPosition[0]+
  7681. ', Y = '+currentPosition[1]+
  7682. ', N = '+currentPosition[2]+
  7683. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  7684. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  7685. true
  7686. );
  7687. td.appendChild(span);
  7688. tr = appendTr(tbody,'mh_tdpage');
  7689. td = appendTdText(tr,'EFFACER : ',true);
  7690. td.align = 'center';
  7691. td.className = 'mh_tdtitre';
  7692. td.width = 100;
  7693. td = appendTdCenter(tr,2);
  7694. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  7695. checkBoxGG = appendCheckBoxSpan(
  7696. td,'delgg',filtreTresors," Les GG'"
  7697. ).firstChild;
  7698. checkBoxCompos = appendCheckBoxSpan(
  7699. td,'delcomp',filtreTresors,' Les Compos'
  7700. ).firstChild;
  7701. checkBoxBidouilles = appendCheckBoxSpan(
  7702. td,'delbid',filtreTresors,' Les Bidouilles'
  7703. ).firstChild;
  7704. checkBoxIntangibles = appendCheckBoxSpan(
  7705. td,'delint',filtreTrolls,' Les Intangibles'
  7706. ).firstChild;
  7707. checkBoxGowaps = appendCheckBoxSpan(
  7708. td,'delgowap',filtreMonstres,' Les Gowaps'
  7709. ).firstChild;
  7710. checkBoxEngages = appendCheckBoxSpan(
  7711. td,'delengage',filtreMonstres,' Les Engagés'
  7712. ).firstChild;
  7713. checkBoxLevels = appendCheckBoxSpan(
  7714. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  7715. ).firstChild;
  7716. checkBoxDiplo = appendCheckBoxSpan(
  7717. td,'delDiplo',refreshDiplo,' La Diplomatie'
  7718. ).firstChild;
  7719. checkBoxTrou = appendCheckBoxSpan(
  7720. td,'deltrou',filtreLieux,' Les Trous'
  7721. ).firstChild;
  7722. checkBoxMythiques = appendCheckBoxSpan(
  7723. td,'delmyth',filtreMonstres,' Les Mythiques'
  7724. ).firstChild;
  7725. if(MY_getValue('NOINFOEM')!='true') {
  7726. checkBoxEM = appendCheckBoxSpan(
  7727. td,'delem',filtreMonstres,' Les Composants EM'
  7728. ).firstChild;
  7729. }
  7730. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  7731. td,'deltres',filtreTresors,' Les Trésors non libres'
  7732. ).firstChild;
  7733. checkBoxTactique = appendCheckBoxSpan(
  7734. td,'deltactique',updateTactique,' Les Infos tactiques'
  7735. ).firstChild;
  7736. if(MY_getValue('INFOPLIE')) {
  7737. toggleTableauInfos(true);
  7738. }
  7739. }
  7740.  
  7741. function toggleTableauInfos(firstRun) {
  7742. var
  7743. msg = document.getElementById('msgInfoTab'),
  7744. corps = document.getElementById('corpsInfoTab'),
  7745. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7746. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  7747. if(!firstRun) {
  7748. infoplie = !infoplie;
  7749. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7750. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  7751. }
  7752. if(infoplie) {
  7753. msg.style.display = '';
  7754. corps.style.display = 'none';
  7755. } else {
  7756. msg.style.display = 'none';
  7757. corps.style.display = '';
  7758. }
  7759. }
  7760.  
  7761. /* [functions] Filtres */
  7762. function prepareFiltrage(ref,width) {
  7763. // = Initialise le filtre 'ref'
  7764. try {
  7765. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  7766. } catch(e) {
  7767. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  7768. return false;
  7769. }
  7770. if(width) { tdTitre.width = width; }
  7771. // Ajout du tr de Filtrage (masqué)
  7772. var tbody = tdTitre.parentNode.parentNode;
  7773. var tr = appendTr(tbody,'mh_tdpage');
  7774. tr.style.display = 'none';
  7775. tr.id = 'trFiltre'+ref;
  7776. var td = appendTd(tr);
  7777. td.colSpan = 5;
  7778. // Ajout du bouton de gestion de Filtrage
  7779. var tdBtn = insertTd(tdTitre.nextSibling);
  7780. tdBtn.id = 'tdInsert'+ref;
  7781. var btn = appendButton(tdBtn,'Filtrer');
  7782. btn.id = 'btnFiltre'+ref;
  7783. btn.onclick = function() {
  7784. debutFiltrage(ref)
  7785. };
  7786. return td;
  7787. }
  7788.  
  7789. function debutFiltrage(ref) {
  7790. // = Handler de début de filtrage (filtre 'ref')
  7791. document.getElementById('trFiltre'+ref).style.display = '';
  7792. var btn = document.getElementById('btnFiltre'+ref);
  7793. btn.value = 'Annuler Filtre';
  7794. btn.onclick = function() {
  7795. finFiltrage(ref);
  7796. };
  7797. }
  7798.  
  7799. function finFiltrage(ref) {
  7800. // = Handler de fin de filtrage (filtre 'ref')
  7801. /* On réassigne le bouton 'Filtrer' */
  7802. document.getElementById('trFiltre'+ref).style.display = 'none';
  7803. var btn = document.getElementById('btnFiltre'+ref);
  7804. btn.value = 'Filtrer';
  7805. btn.onclick = function() {
  7806. debutFiltrage(ref);
  7807. };
  7808. /* Réinitialisation filtres */
  7809. document.getElementById('str'+ref).value = '';
  7810. switch(ref) {
  7811. case 'Monstres':
  7812. document.getElementById('nivMinMonstres').value = 0;
  7813. document.getElementById('nivMaxMonstres').value = 0;
  7814. break;
  7815. case 'Trolls':
  7816. document.getElementById('strGuildes').value = '';
  7817. }
  7818. /* Nettoyage (=lance le filtre) */
  7819. // Ici this = MZ.global = sandBox de travail de MZ
  7820. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  7821. //this['filtre'+ref]();
  7822. switch (ref) {
  7823. case 'Monstres':
  7824. filtreMonstres();
  7825. break;
  7826. case 'Trolls':
  7827. filtreTrolls();
  7828. break;
  7829. case 'Tresors':
  7830. filtreTresors();
  7831. break;
  7832. case 'Lieux':
  7833. filtreLieux();
  7834. break;
  7835. default:
  7836. window.console.log('cas incongru dans finFiltrage : ' + ref);
  7837. break;
  7838. }
  7839. }
  7840.  
  7841. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  7842. var bouton = appendButton(td,nomBouton,onClick);
  7843. appendText(td,'\u00a0');
  7844. var textbox = appendTextbox(td,'text',id,15,30);
  7845. textbox.onkeypress = function(event) {
  7846. try {
  7847. if(event.keyCode==13) {
  7848. event.preventDefault();
  7849. bouton.click();
  7850. }
  7851. }
  7852. catch(e){
  7853. window.alert(e)
  7854. }
  7855. };
  7856. }
  7857.  
  7858. function ajoutFiltreMenu(tr,id,onChange) {
  7859. var select = document.createElement('select');
  7860. select.id = id;
  7861. select.onchange = onChange;
  7862. appendOption(select,0,'Aucun');
  7863. for(var i=1 ; i<=60 ; i++) {
  7864. appendOption(select,i,i);
  7865. }
  7866. tr.appendChild(select);
  7867. return select;
  7868. }
  7869.  
  7870. function ajoutDesFiltres() {
  7871. /* Monstres */
  7872. var td = prepareFiltrage('Monstres',120);
  7873. if(td) {
  7874. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  7875. appendText(td,'\u00a0\u00a0\u00a0');
  7876. appendText(td,'Niveau Min: ');
  7877. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  7878. appendText(td,'\u00a0');
  7879. appendText(td,'Niveau Max: ');
  7880. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  7881. }
  7882. /* Trõlls */
  7883. td = prepareFiltrage('Trolls',50);
  7884. if(td) {
  7885. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  7886. appendText(td,'\u00a0\u00a0\u00a0');
  7887. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  7888. }
  7889. /* Trésors */
  7890. td = prepareFiltrage('Tresors',55);
  7891. if(td) {
  7892. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  7893. }
  7894. /* Lieux */
  7895. td = prepareFiltrage('Lieux',40);
  7896. if(td) {
  7897. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  7898. }
  7899. }
  7900.  
  7901. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  7902.  
  7903. /* [functions] Affichage de la colonne des niveaux */
  7904. function insertLevelColumn() {
  7905. // Déclenché si bascule vers affichage des niveaux des mobs
  7906. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7907. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  7908. td.width = 25;
  7909. for(var i=1 ; i<=nbMonstres ; i++) {
  7910. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7911. td = insertTdText(getMonstreLevelNode(i), '-');
  7912. td.onclick = function() {
  7913. basculeCDM(
  7914. getMonstreNomByTR(this.parentNode),
  7915. getMonstreIDByTR(this.parentNode)
  7916. );
  7917. };
  7918. td.onmouseover = function() {
  7919. this.style.cursor = 'pointer';
  7920. this.className = 'mh_tdtitre';
  7921. };
  7922. td.onmouseout = function() {
  7923. if(this.parentNode.diploActive=='oui') {
  7924. this.className = '';
  7925. } else {
  7926. this.className = 'mh_tdpage';
  7927. }
  7928. };
  7929. td.style = 'font-weight:bold;text-align:center;';
  7930. if(isCDMsRetrieved) {
  7931. // Rappel des niveaux si mémorisés
  7932. td.innerHTML = listeLevels[i];
  7933. }
  7934. }
  7935. }
  7936.  
  7937. function toggleLevelColumn() {
  7938. // = Handler checkBox noLevel
  7939. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  7940. insertLevelColumn();
  7941. if(!isCDMsRetrieved) { retrieveCDMs(); }
  7942. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  7943. for(var i=0 ; i<=nbMonstres ; i++) {
  7944. if(isCDMsRetrieved) {
  7945. // Mémorisation des niveaux pour rappel éventuel
  7946. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  7947. }
  7948. // Suppression du td Niveau
  7949. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  7950. }
  7951. }
  7952. }
  7953.  
  7954. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  7955. function basculeCDM(nom,id) {
  7956. // = Bascule l'affichage des popups CdM
  7957. if(listeCDM[id]) {
  7958. if(!document.getElementById('popupCDM'+id)) {
  7959. afficherCDM(nom, id);
  7960. } else {
  7961. cacherPopupCDM('popupCDM'+id);
  7962. }
  7963. }
  7964. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  7965. }
  7966.  
  7967. function cacherPopupCDM(titre) {
  7968. var popup = document.getElementById(titre);
  7969. popup.parentNode.removeChild(popup);
  7970. }
  7971.  
  7972. /* DEBUG: Section à mettre à jour */
  7973. var selectionFunction;
  7974.  
  7975. function startDrag(evt) {
  7976. winCurr = this.parentNode;
  7977. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  7978. offsetX = evt.pageX - parseInt( winCurr.style.left );
  7979. offsetY = evt.pageY - parseInt( winCurr.style.top );
  7980. selectionFunction = document.body.style.MozUserSelect;
  7981. document.body.style.MozUserSelect = 'none';
  7982. winCurr.style.MozUserSelect = 'none';
  7983. return false;
  7984. }
  7985.  
  7986. function stopDrag(evt) {
  7987. winCurr.style.MozUserSelect = selectionFunction;
  7988. document.body.style.MozUserSelect = selectionFunction;
  7989. winCurr = null;
  7990. }
  7991.  
  7992. function drag(evt) {
  7993. if(winCurr==null) { return; }
  7994. evt = evt || window.event;
  7995. winCurr.style.left = (evt.pageX - offsetX)+'px';
  7996. winCurr.style.top = (evt.pageY - offsetY)+'px';
  7997. return false;
  7998. }
  7999. /* FIN DEBUG */
  8000.  
  8001. function afficherCDM(nom,id) {
  8002. // Crée la table de CdM du mob n° id
  8003. var donneesMonstre = listeCDM[id];
  8004. /* Début création table */
  8005. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8006. table.id = 'popupCDM'+id;
  8007. table.style =
  8008. 'position:fixed;'+
  8009. 'z-index:1;'+
  8010. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8011. 'left:'+(window.innerWidth-365)+'px;'+
  8012. 'width:300px;'+
  8013. 'height:200px;';
  8014. /* Ajout du titre avec gestion Drag & Drop */
  8015. var tr = table.firstChild;
  8016. tr.style.cursor = 'move';
  8017. tr.onmousedown = startDrag;
  8018. tr.onmouseup = stopDrag;
  8019. /* Ajout du bouton "Fermer" */
  8020. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8021. tr.onmouseover = function() {
  8022. this.style.cursor = 'pointer';
  8023. this.className = 'mh_tdpage';
  8024. };
  8025. tr.onmouseout = function() {
  8026. this.className = 'mh_tdtitre';
  8027. };
  8028. tr.idcdm = id;
  8029. tr.onclick = function() {
  8030. cacherPopupCDM('popupCDM'+this.idcdm);
  8031. this.className = 'mh_tdtitre';
  8032. };
  8033. td = appendTdText(tr,'Fermer',true);
  8034. td.colSpan = 2;
  8035. td.style = 'text-align:center;';
  8036. nbCDM++;
  8037. /* Fin création table & Affichage */
  8038. document.body.appendChild(table);
  8039. }
  8040.  
  8041. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8042. function initPopupVue() {
  8043. popup = document.createElement('div');
  8044. popup.id = 'popup';
  8045. popup.className = 'mh_textbox';
  8046. popup.style =
  8047. 'position: absolute;'+
  8048. 'border: 1px solid #000000;'+
  8049. 'visibility: hidden;'+
  8050. 'display: inline;'+
  8051. 'z-index: 3;'+
  8052. 'max-width: 400px;';
  8053. document.body.appendChild(popup);
  8054. }
  8055.  
  8056. // roule 16/03/2016 supprimé, existe déjà dans vue
  8057. // function showPopupTactique(evt) {
  8058. // var id = this.id;
  8059. // var nom = this.nom;
  8060. // var texte = getAnalyseTactique(id,nom);
  8061. // if(texte=='') { return; }
  8062. // popup.innerHTML = texte;
  8063. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  8064. // popup.style.top = (evt.pageY+15)+'px';
  8065. // popup.style.visibility = 'visible';
  8066. // }
  8067.  
  8068. // roule 16/03/2016, existe déjà ailleurs
  8069. // function hidePopup() {
  8070. // popup.style.visibility = 'hidden';
  8071. // }
  8072.  
  8073. /* [functions] Récupération / Computation des Infos Tactiques */
  8074. // TODO à revoir
  8075. function retireMarquage(nom) {
  8076. var i = nom.indexOf(']');
  8077. switch(i) {
  8078. case -1:
  8079. case nom.length-1:
  8080. return nom;
  8081. default:
  8082. return nom.slice(0,i+1);
  8083. }
  8084. }
  8085.  
  8086. function showPopupError(sHTML) {
  8087. var divpopup = document.createElement('div');
  8088. divpopup.id = 'divpopup';
  8089. divpopup.style =
  8090. 'position: fixed;'+
  8091. 'border: 3px solid #000000;'+
  8092. 'top: 300px;left: 10px;'+
  8093. 'background-color: red;'+
  8094. 'color: white;'+
  8095. 'font-size: xx-large;'+
  8096. 'z-index: 200;';
  8097. divpopup.innerHTML = sHTML;
  8098. var divcroix = document.createElement('div');
  8099. divcroix.style =
  8100. 'position: absolute;'+
  8101. 'top: 0;right: 0;'+
  8102. 'color: inherit;'+
  8103. 'font-size: inherit;'+
  8104. 'cursor: pointer;'+
  8105. 'z-index: 201;';
  8106. divcroix.innerHTML = "X";
  8107. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8108. document.body.appendChild(divpopup);
  8109. divpopup.appendChild(divcroix);
  8110. }
  8111.  
  8112. function retrieveCDMs() {
  8113. // Récupère les CdM disponibles dans la BDD
  8114. // Lancé uniquement sur toggleLevelColumn
  8115. if(checkBoxLevels.checked) { return; }
  8116. var str = '';
  8117. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8118. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8119. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8120. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  8121. for(var i=1 ; i<=cdmMax ; i++) {
  8122. var nomMonstre = retireMarquage(getMonstreNom(i));
  8123. if(nomMonstre.indexOf(']') != -1) {
  8124. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  8125. }
  8126. // *** WARNING : PROXY RATIBUS ***
  8127. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  8128. str += 'nom[]='+escape(nomMonstre)+'$'+(
  8129. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  8130. )+'&';
  8131. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  8132. FF_XMLHttpRequest({
  8133. method: 'POST',
  8134. url: URL_MZinfoMonstre,
  8135. headers : {
  8136. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8137. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8138. 'Content-type':'application/x-www-form-urlencoded'
  8139. },
  8140. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  8141. onload: function(responseDetails) {
  8142. try {
  8143. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  8144. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  8145. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  8146. '" target="raistlin">Mountyzilla - https<br />'+
  8147. 'Tu dois accepter le certificat de Raistlin<br />'+
  8148. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  8149. ' « Confirmer l\'exception de sécurité »</a>');
  8150. return;
  8151. }
  8152. var texte = responseDetails.responseText;
  8153. var lines = texte.split('\n');
  8154. if(lines.length==0) { return; }
  8155. var begin2, end2, index;
  8156. for(var j=0 ; j<lines.length ; j++) {
  8157. var infos = lines[j].split(';');
  8158. if(infos.length<4) { continue; }
  8159. var idMonstre=infos[0];
  8160. var isCDM = infos[1];
  8161. index = parseInt(infos[2]);
  8162. var level = infos[3];
  8163. infos = infos.slice(3);
  8164. if(begin2==null) { begin2 = index; }
  8165. end2 = index;
  8166. listeCDM[idMonstre] = infos;
  8167. if(isCDM==1) {
  8168. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  8169. } else {
  8170. getMonstreLevelNode(index).innerHTML = level;
  8171. }
  8172. }
  8173. computeMission(begin2,end2);
  8174. } catch(e) {
  8175. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  8176. }
  8177. }
  8178. });
  8179. str = '';
  8180. begin = i+1;
  8181. }
  8182. }
  8183. isCDMsRetrieved=true;
  8184. }
  8185.  
  8186. function computeMission(begin,end) {
  8187. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  8188. computeVLC(begin,end);
  8189. if(!begin) begin=1;
  8190. if(!end) end=nbMonstres;
  8191. var str = MY_getValue(numTroll+'.MISSIONS');
  8192. if(!str) { return; }
  8193. var urlImg = URL_MZimg+'mission.png';
  8194. var obMissions = JSON.parse(str);
  8195. for(var i=end ; i>=begin ; i--) {
  8196. var mess = '';
  8197. for(var num in obMissions) {
  8198. var mobMission = false;
  8199. switch(obMissions[num].type) {
  8200. case 'Race':
  8201. var race = epure(obMissions[num].race.toLowerCase());
  8202. var nom = epure(getMonstreNom(i).toLowerCase());
  8203. if(nom.indexOf(race)!=-1) {
  8204. mobMission = true;
  8205. }
  8206. break;
  8207. case 'Niveau':
  8208. var donneesMonstre = listeCDM[getMonstreID(i)];
  8209. if(donneesMonstre) {
  8210. var nivMob = Number(donneesMonstre[0]);
  8211. var nivMimi = Number(obMissions[num].niveau),
  8212. mod = obMissions[num].mod;
  8213. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  8214. || (isNaN(mod) && nivMob>=nivMimi)) {
  8215. mobMission = true;
  8216. }
  8217. }
  8218. break;
  8219. case 'Famille':
  8220. var donneesMonstre = listeCDM[getMonstreID(i)];
  8221. if(donneesMonstre) {
  8222. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  8223. var familleMob = epure(donneesMonstre[1].toLowerCase());
  8224. if(familleMob.indexOf(familleMimi)!=-1) {
  8225. mobMission = true;
  8226. }
  8227. }
  8228. break;
  8229. case 'Pouvoir':
  8230. var donneesMonstre = listeCDM[getMonstreID(i)];
  8231. if(donneesMonstre) {
  8232. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  8233. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  8234. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8235. mobMission = true;
  8236. }
  8237. }
  8238. }
  8239. if(mobMission) {
  8240. mess += mess ? '\n\n' : '';
  8241. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8242. }
  8243. }
  8244. if(mess) {
  8245. var td = getMonstreNomNode(i);
  8246. appendText(td,' ');
  8247. td.appendChild(createImage(urlImg,mess));
  8248. }
  8249. }
  8250. }
  8251.  
  8252. function computeVLC(begin,end) {
  8253. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8254. computeTactique(begin,end);
  8255. if(!begin) begin=1;
  8256. if(!end) end=nbMonstres;
  8257. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8258. if(!cache)
  8259. return false;
  8260. var urlImg = URL_MZimg + "oeil.png";
  8261. for(var i = end; i >= begin;i--)
  8262. {
  8263. var id = getMonstreID(i);
  8264. var donneesMonstre = listeCDM[id];
  8265. if(donneesMonstre && donneesMonstre.length>12)
  8266. {
  8267. if(donneesMonstre[12]==1)
  8268. {
  8269. var td = getMonstreNomNode(i);
  8270. td.appendChild(document.createTextNode(" "));
  8271. td.appendChild(createImage(urlImg, "Voit le caché"));
  8272. }
  8273. }
  8274. }
  8275. }
  8276.  
  8277. function computeTactique(begin, end) {
  8278. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8279. try {
  8280. if(!begin) begin = 1;
  8281. if(!end) end = nbMonstres;
  8282. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8283. if(noTactique || !isProfilActif()) return;
  8284. for(var j=end ; j>=begin ; j--) {
  8285. var id = getMonstreID(j);
  8286. var nom = getMonstreNom(j);
  8287. var donneesMonstre = listeCDM[id];
  8288. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8289. var td = getMonstreNomNode(j);
  8290. appendText(td,' ');
  8291. td.appendChild(
  8292. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  8293. );
  8294. }
  8295. }
  8296. }
  8297. catch(e) {
  8298. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8299. }
  8300. filtreMonstres();
  8301. }
  8302.  
  8303. function updateTactique() {
  8304. // = Handler checkBox noTactique
  8305. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8306. if(!isCDMsRetrieved) return;
  8307. if(noTactique) {
  8308. for(var i=nbMonstres ; i>0 ; i--) {
  8309. var tr = getMonstreNomNode(i);
  8310. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  8311. tr, null, 9, null).singleNodeValue;
  8312. if(img) {
  8313. img.parentNode.removeChild(img.previousSibling);
  8314. img.parentNode.removeChild(img);
  8315. }
  8316. }
  8317. }
  8318. else
  8319. computeTactique();
  8320. }
  8321.  
  8322. function filtreMonstres() {
  8323. // = Handler universel pour les fonctions liées aux monstres
  8324. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  8325. urlEnchantImg = URL_MZimg+'images/enchant.png';
  8326. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  8327. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  8328. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  8329. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  8330. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  8331. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  8332. // old/new : détermine s'il faut ou non nettoyer les tr
  8333. var oldNOEM = true, noEM = true;
  8334. if(MY_getValue('NOINFOEM')!='true') {
  8335. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  8336. }
  8337. // Filtrage par nom
  8338. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  8339. // Génère la liste des mobs engagés (si filtrés)
  8340. if(noEngages && !isEngagesComputed) {
  8341. for(var i=nbTrolls ; i>0 ; i--) {
  8342. var pos = getTrollPosition(i);
  8343. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  8344. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  8345. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  8346. }
  8347. isEngagesComputed = true;
  8348. }
  8349. /*** FILTRAGE ***/
  8350. /* À computer :
  8351. * - EM (nom suffit)
  8352. * - Enchant (nom suffit)
  8353. * - Mission (nécessite CdM)
  8354. * - mob VlC (nécessite CdM)
  8355. * Sans computation :
  8356. * - Gowap ? engagé ?
  8357. */
  8358. for(var i=nbMonstres ; i>0 ; i--) {
  8359. var pos = getMonstrePosition(i);
  8360. var nom = getMonstreNom(i).toLowerCase();
  8361. if(noEM!=oldNOEM) {
  8362. if(noEM) {
  8363. // Si noEM passe de false à true, on nettoie les td "Nom"
  8364. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  8365. var tr = getMonstreNomNode(i);
  8366. while(tr.childNodes.length>1) {
  8367. tr.removeChild(tr.childNodes[1]);
  8368. }
  8369. } else {
  8370. var tr = getMonstreNomNode(i);
  8371. var TypeMonstre=getEM(nom);
  8372. if(TypeMonstre!='') {
  8373. var infosCompo=compoMobEM(TypeMonstre);
  8374. if(infosCompo.length>0) {
  8375. tr.appendChild(document.createTextNode(' '));
  8376. tr.appendChild(createImage(urlImg, infosCompo));
  8377. }
  8378. }
  8379. }
  8380. }
  8381. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  8382. var texte = getInfoEnchantementFromMonstre(nom);
  8383. if(texte!='') {
  8384. var td = getMonstreNomNode(i);
  8385. td.appendChild(document.createTextNode(' '));
  8386. td.appendChild(createImage(urlEnchantImg, texte));
  8387. }
  8388. }
  8389. tr_monstres[i].style.display = (
  8390. noGowaps &&
  8391. nom.indexOf('gowap apprivoisé')!=-1 &&
  8392. getMonstreDistance(i)>1
  8393. ) || (
  8394. noEngages &&
  8395. getMonstreDistance(i)!=0 &&
  8396. listeEngages[pos[0]] &&
  8397. listeEngages[pos[0]][pos[1]] &&
  8398. listeEngages[pos[0]][pos[1]][pos[2]]
  8399. ) || (
  8400. strMonstre!='' &&
  8401. nom.indexOf(strMonstre)==-1
  8402. ) || (
  8403. nivMin>0 &&
  8404. getMonstreLevel(i)!=-1 &&
  8405. getMonstreLevel(i)<nivMin &&
  8406. getMonstreDistance(i)>1 &&
  8407. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  8408. ) || (
  8409. nivMax>0 &&
  8410. getMonstreLevel(i)>nivMax &&
  8411. getMonstreDistance(i)>1 &&
  8412. nom.toLowerCase().indexOf("kilamo")==-1
  8413. ) ? 'none' : '';
  8414. }
  8415. if(MY_getValue('NOINFOEM')!='true') {
  8416. if(noEM != oldNOEM) {
  8417. if(noEM && isCDMsRetrieved) computeMission();
  8418. }
  8419. oldNOEM = noEM;
  8420. }
  8421. needComputeEnchantement = false;
  8422. }
  8423.  
  8424.  
  8425. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  8426.  
  8427. function filtreTrolls() {
  8428. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  8429. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  8430. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  8431. for(var i=1 ; i<=nbTrolls ; i++) {
  8432. tr_trolls[i].style.display = (
  8433. noIntangibles &&
  8434. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  8435. ) || (
  8436. strTroll!='' &&
  8437. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  8438. ) || (
  8439. strGuilde!='' &&
  8440. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  8441. ) ? 'none' : '';
  8442. }
  8443. }
  8444.  
  8445. /* [functions] Bulle PX Trolls */
  8446. var bulle;
  8447.  
  8448. function initPXTroll() {
  8449. bulle = document.createElement('div');
  8450. bulle.id = 'bulle';
  8451. bulle.className = 'mh_textbox';
  8452. bulle.style =
  8453. 'position: absolute;'+
  8454. 'border: 1px solid #000000;'+
  8455. 'visibility: hidden;'+
  8456. 'display: inline;'+
  8457. 'z-index: 2;';
  8458. document.body.appendChild(bulle);
  8459.  
  8460. for(var i=nbTrolls ; i>0 ; i--) {
  8461. var td_niv = getTrollNivNode(i);
  8462. td_niv.onmouseover = showPXTroll;
  8463. td_niv.onmouseout = hidePXTroll;
  8464. }
  8465. }
  8466.  
  8467. function showPXTroll(evt) {
  8468. var lvl = this.firstChild.nodeValue;
  8469. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  8470. bulle.style.left = evt.pageX+15+'px';
  8471. bulle.style.top = evt.pageY+'px';
  8472. bulle.style.visibility = 'visible';
  8473. }
  8474.  
  8475. function hidePXTroll() {
  8476. bulle.style.visibility = 'hidden';
  8477. }
  8478.  
  8479. /* [functions] Envoi PX / MP */
  8480. function putBoutonPXMP() {
  8481. // Bouton d'initialisation du mode Envoi
  8482. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8483. var td = document.getElementById('tdInsertTrolls');
  8484. if(!td) { return; }
  8485. td.width = 100;
  8486. td = insertTd(td.nextSibling);
  8487. td.style.verticalAlign = 'top';
  8488. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8489. bouton.id = 'btnEnvoi';
  8490. }
  8491.  
  8492. function prepareEnvoi() {
  8493. // = 1er Handler du bouton d'envoi
  8494. /* Ajout de la colonne des CheckBoxes */
  8495. var td = insertTdText(getTrollNomNode(0),'');
  8496. td.width = 5;
  8497. for(var i=nbTrolls ; i>0 ; i--) {
  8498. td = insertTd(getTrollNomNode(i));
  8499. appendCheckBox(td,'envoi'+i);
  8500. }
  8501. /* Ajout du radio de choix PX ou MP */
  8502. var btnEnvoi = document.getElementById('btnEnvoi');
  8503. if(!btnEnvoi) { return; }
  8504. var tdEnvoi = btnEnvoi.parentNode;
  8505. appendText(tdEnvoi,' ');
  8506. var span = document.createElement('span');
  8507. span.style.whiteSpace = 'nowrap';
  8508. var radioElt = document.createElement('input');
  8509. radioElt.type = 'radio';
  8510. radioElt.name = 'envoiPXMP';
  8511. radioElt.id = 'radioPX';
  8512. span.appendChild(radioElt);
  8513. appendText(span,' des PX ');
  8514. radioElt = document.createElement('input');
  8515. radioElt.type = 'radio';
  8516. radioElt.name = 'envoiPXMP';
  8517. radioElt.checked = true;
  8518. span.appendChild(radioElt);
  8519. appendText(span,' un MP');
  8520. tdEnvoi.appendChild(span);
  8521. /* Insertion du bouton Annuler */
  8522. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8523. /* Modification de l'effet du bouton Envoi */
  8524. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8525. }
  8526.  
  8527. function annuleEnvoi() {
  8528. // = Handler bouton Annuler
  8529. /* Nettoyage du td du bouton Envoi */
  8530. var btnEnvoi = document.getElementById('btnEnvoi');
  8531. var tdEnvoi = btnEnvoi.parentNode;
  8532. while(tdEnvoi.firstChild) {
  8533. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8534. }
  8535. /* Retour à l'effet de base du bouton Envoi */
  8536. btnEnvoi.onclick = prepareEnvoi;
  8537. tdEnvoi.appendChild(btnEnvoi);
  8538. /* Suppression CheckBoxes */
  8539. for(var i=nbTrolls ; i>=0 ; i--) {
  8540. var td = getTrollNomNode(i);
  8541. td.parentNode.removeChild(td);
  8542. }
  8543. }
  8544.  
  8545. function effectueEnvoi() {
  8546. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  8547. var str='';
  8548. for(var i=nbTrolls ; i>0 ; i--) {
  8549. var chb = document.getElementById('envoi'+i);
  8550. if(chb.checked) {
  8551. str += (str?',':'')+getTrollID(i);
  8552. }
  8553. }
  8554. var PXchecked = document.getElementById('radioPX').checked;
  8555. if(PXchecked) {
  8556. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  8557. } else {
  8558. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  8559. }
  8560. }
  8561.  
  8562. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  8563.  
  8564. function filtreTresors() {
  8565. // += Handler checkboxes : gg, compos, bidouilles, non libres
  8566. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  8567. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  8568. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  8569. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8570. if(noEngages && !isEngagesComputed) {
  8571. for(var i=nbTrolls ; i>0 ; i--) {
  8572. var pos = getTrollPosition(i);
  8573. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  8574. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  8575. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  8576. }
  8577. isEngagesComputed = true;
  8578. }
  8579. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  8580. for(var i=nbTresors ; i>0 ; i--) {
  8581. var nom = getTresorNom(i);
  8582. var pos = getTresorPosition(i);
  8583. tr_tresors[i].style.display = (
  8584. noGG &&
  8585. nom.indexOf('Gigots de Gob')!=-1
  8586. ) || (
  8587. noCompos &&
  8588. nom.indexOf('Composant')!=-1
  8589. ) || (
  8590. noEngages &&
  8591. listeEngages[pos[2]] &&
  8592. listeEngages[pos[2]][pos[1]] &&
  8593. listeEngages[pos[2]][pos[1]][pos[0]] &&
  8594. getTresorDistance(i)>0
  8595. ) || (
  8596. strTresor!='' &&
  8597. nom.toLowerCase().indexOf(strTresor)==-1
  8598. ) || (
  8599. noBidouilles &&
  8600. nom.indexOf('Bidouille')!=-1
  8601. ) ? 'none' : '';
  8602. }
  8603. }
  8604.  
  8605.  
  8606. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  8607.  
  8608. function filtreLieux() {
  8609. // += Handler checkbox trous
  8610. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  8611. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  8612. for(var i=nbLieux ; i>0 ; i--) {
  8613. tr_lieux[i].style.display = (
  8614. strLieu &&
  8615. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  8616. ) || (
  8617. noTrou &&
  8618. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  8619. getLieuDistance(i)>1
  8620. ) ? 'none' : '';
  8621. }
  8622. }
  8623.  
  8624.  
  8625. /*-[functions]-------------------- Diplomatie --------------------------------*/
  8626.  
  8627. function refreshDiplo() {
  8628. MY_setValue(numTroll+'.diplo.off',
  8629. checkBoxDiplo.checked?'true':'false'
  8630. );
  8631. if(isDiploRaw) { computeDiplo(); }
  8632. appliqueDiplo();
  8633. }
  8634.  
  8635. function computeDiplo() {
  8636. // On extrait les données de couleur et on les stocke par id
  8637. // Ordre de préséance :
  8638. // source Guilde < source Perso
  8639. // guilde cible < troll cible
  8640. /* Diplo de Guilde */
  8641. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  8642. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  8643. if(diploGuilde && diploGuilde.isOn=='true') {
  8644. // Guilde perso
  8645. if(diploGuilde.guilde) {
  8646. Diplo.Guilde[diploGuilde.guilde.id] = {
  8647. couleur: diploGuilde.guilde.couleur,
  8648. titre: 'Ma Guilde'
  8649. };
  8650. }
  8651. // Guildes/Trolls A/E
  8652. for(var AE in {Amis:0,Ennemis:0}) {
  8653. for(var i=0 ; i<5 ; i++) {
  8654. if(diploGuilde[AE+i]) {
  8655. for(var type in {Guilde:0,Troll:0}) {
  8656. var liste = diploGuilde[AE+i][type].split(';');
  8657. for(var j=liste.length-2 ; j>=0 ; j--) {
  8658. Diplo[type][liste[j]] = {
  8659. couleur: diploGuilde[AE+i].couleur,
  8660. titre: diploGuilde[AE+i].titre
  8661. };
  8662. }
  8663. }
  8664. }
  8665. }
  8666. }
  8667. }
  8668. /* Diplo Perso */
  8669. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  8670. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  8671. if(diploPerso && diploPerso.isOn=='true') {
  8672. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8673. for(var id in diploPerso[type]) {
  8674. Diplo[type][id] = diploPerso[type][id];
  8675. }
  8676. }
  8677. }
  8678. if(diploPerso.mythiques) {
  8679. Diplo.mythiques = diploPerso.mythiques;
  8680. }
  8681. isDiploRaw = false;
  8682. }
  8683.  
  8684. function appliqueDiplo() {
  8685. var aAppliquer = Diplo;
  8686. if(checkBoxDiplo.checked) {
  8687. // Pour retour à l'affichage basique sur désactivation de la diplo
  8688. aAppliquer = {
  8689. Guilde: {},
  8690. Troll: {},
  8691. Monstre: {}
  8692. };
  8693. }
  8694. /* On applique "aAppliquer" */
  8695. // Diplo Trõlls
  8696. for(var i=nbTrolls ; i>0 ; i--) {
  8697. var idG = getTrollGuildeID(i);
  8698. var idT = getTrollID(i);
  8699. var tr = tr_trolls[i];
  8700. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  8701. if(aAppliquer.Troll[idT]) {
  8702. tr.className = '';
  8703. var descr = aAppliquer.Troll[idT].titre;
  8704. if(descr) {
  8705. getTrollNomNode(i).title = descr
  8706. }
  8707. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  8708. } else if(aAppliquer.Guilde[idG]) {
  8709. tr.className = '';
  8710. var descr = aAppliquer.Guilde[idG].titre;
  8711. if(descr) {
  8712. getTrollNomNode(i).title = descr
  8713. }
  8714. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  8715. } else {
  8716. tr.className = 'mh_tdpage';
  8717. getTrollNomNode(i).title = '';
  8718. }
  8719. }
  8720. // Diplo Monstres
  8721. for(var i=nbMonstres ; i>0 ; i--) {
  8722. var id = getMonstreID(i);
  8723. var nom = getMonstreNom(i).toLowerCase();
  8724. if(aAppliquer.Monstre[id]) {
  8725. tr_monstres[i].className = '';
  8726. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  8727. tr_monstres[i].diploActive = 'oui';
  8728. var descr = aAppliquer.Monstre[id].titre;
  8729. if(descr) {
  8730. getMonstreNomNode(i).title = descr;
  8731. }
  8732. } else if(aAppliquer.mythiques &&
  8733. (nom.indexOf('liche')==0 ||
  8734. nom.indexOf('hydre')==0 ||
  8735. nom.indexOf('balrog')==0 ||
  8736. nom.indexOf('beholder')==0)) {
  8737. tr_monstres[i].className = '';
  8738. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  8739. tr_monstres[i].diploActive = 'oui';
  8740. getMonstreNomNode(i).title = 'Monstre Mythique';
  8741. } else {
  8742. tr_monstres[i].className = 'mh_tdpage';
  8743. tr_monstres[i].diploActive = '';
  8744. }
  8745. }
  8746. }
  8747.  
  8748.  
  8749. /*-[functions]---------------- Actions à distance ----------------------------*/
  8750.  
  8751. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  8752. var monN = parseInt(getPosition()[2]);
  8753. for(var type in keltypes) {
  8754. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  8755. for(var i=this['nb'+type] ; i>0 ; i--) {
  8756. var tr = this['tr_'+type.toLowerCase()][i];
  8757. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  8758. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  8759. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  8760. var sonN = getXxxPosition(type, i)[2];
  8761. var d = getXxxDistance(type, i);
  8762. if(sonN==monN && d>=dmin && d<=dmax) {
  8763. var iconeAction = document.evaluate(
  8764. "./descendant::img[@alt='"+alt+"']",
  8765. tr, null, 9, null
  8766. ).singleNodeValue;
  8767. if(iconeAction) {
  8768. if(iconeAction.title) {
  8769. iconeAction.title += "\n"+message;
  8770. } else {
  8771. iconeAction.title = message;
  8772. }
  8773. iconeAction.src = urlIcon;
  8774. } else {
  8775. var tdAction = tr.getElementsByTagName('td')[1];
  8776. var icon = document.createElement('img');
  8777. icon.src = urlIcon;
  8778. icon.height = 20;
  8779. icon.alt = alt;
  8780. icon.title = message;
  8781. tdAction.appendChild(icon);
  8782. }
  8783. }
  8784. }
  8785. }
  8786. }
  8787.  
  8788. function computeCharge() {
  8789. computeActionDistante(1,
  8790. getPortee__Vue(
  8791. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  8792. MY_getValue(numTroll+".caracs.regeneration")
  8793. ),
  8794. {'Monstres':1, 'Trolls':1},
  8795. 'Attaquer',
  8796. MHicons+'E_Metal09.png',
  8797. 'Cible à portée de Charge'
  8798. );
  8799. }
  8800.  
  8801. function computeProjo() {
  8802. computeActionDistante(0,
  8803. getPortee__Vue(
  8804. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8805. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8806. ),
  8807. {'Monstres':1, 'Trolls':1},
  8808. 'Attaquer',
  8809. MHicons+'S_Fire05.png',
  8810. 'Cible à portée de Projo'
  8811. );
  8812. }
  8813.  
  8814. function computeTelek() {
  8815. computeActionDistante(0,
  8816. Math.floor((
  8817. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8818. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8819. )/2),
  8820. {'Tresors':1},
  8821. 'Telek',
  8822. MHicons+'S_Magic04.png',
  8823. 'Trésor à portée de Télékinésie'
  8824. );
  8825. }
  8826.  
  8827. function computeLdP() {
  8828. computeActionDistante(0,
  8829. 2+Math.floor((
  8830. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8831. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8832. )/5),
  8833. {'Monstres':1, 'Trolls':1},
  8834. 'self',
  8835. MHicons+'P_Red01.png',
  8836. 'Cible à portée de Lancer de Potions'
  8837. );
  8838. }
  8839.  
  8840.  
  8841. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  8842.  
  8843. function putScriptExterne() {
  8844. var infoit = MY_getValue(numTroll+'.INFOSIT');
  8845. if(!infoit || infoit=='') return;
  8846.  
  8847. var nomit = infoit.slice(0,infoit.indexOf('$'));
  8848. if(nomit=='bricol') {
  8849. var data = infoit.split('$');
  8850. try {
  8851. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  8852. // appendNewScript(URL_bricol+data[1]
  8853. // +'/mz.php?login='+data[2]
  8854. // +'&password='+data[3]
  8855. // );
  8856. FF_XMLHttpRequest({
  8857. method: 'GET',
  8858. url: URL_bricol+data[1]
  8859. +'/mz_json.php?login='+data[2]
  8860. +'&password='+data[3],
  8861. onload: function(responseDetails) {
  8862. try {
  8863. if (responseDetails.status == 0) {
  8864. if (isHTTPS) {
  8865. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  8866. } else {
  8867. window.console.log('status=0 à l\'appel bricol\'troll');
  8868. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  8869. }
  8870. return;
  8871. }
  8872. var ratibusData;
  8873. try {
  8874. ratibusData = JSON.parse(responseDetails.responseText);
  8875. } catch(e) {}
  8876. if (ratibusData === undefined) {
  8877. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  8878. return;
  8879. }
  8880. if (ratibusData.error) {
  8881. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  8882. } else {
  8883. putInfosTrolls(ratibusData.data.trolls);
  8884. }
  8885. } catch(e) {
  8886. window.console.log(traceStack(e, 'retour bricol\'troll'));
  8887. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  8888. }
  8889. }
  8890. });
  8891. } catch(e) {
  8892. if (isHTTPS) {
  8893. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  8894. } else {
  8895. window.console.log(traceStack(e, 'appel bricol\'troll'));
  8896. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  8897. }
  8898. }
  8899. }
  8900. }
  8901.  
  8902. /* Le script mz.php de Ratibus renvoie :
  8903. + infosTrolls = new Array();
  8904. + infosTrolls[numdutroll] =
  8905. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  8906. + etc ...
  8907. + putInfosTrolls();
  8908. *
  8909. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  8910. * Roule 07/11/2016, on utilise mz_json qui envoie
  8911. {
  8912. "data": {
  8913. "trolls": {
  8914. "59424": {
  8915. "id": 59424,
  8916. "pv": xx,
  8917. "pv_max": xx,
  8918. "updated_at": "2016-10-31 07:28:40",
  8919. "dla": "2016-10-05 07:28:04",
  8920. "pa": 0
  8921. },
  8922. }
  8923. }
  8924. }
  8925. */
  8926.  
  8927. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  8928. function corrigeBricolTrolls(infosTrolls) {
  8929. for(var i in infosTrolls) {
  8930. var pv = infosTrolls[i][0];
  8931. var pvmax = infosTrolls[i][1];
  8932. var pvmem = MY_getValue(i+'.caracs.pv.max');
  8933. if(pvmem && pvmem>pvmax) {
  8934. infosTrolls[i][1] = pvmem;
  8935. pvmax = pvmem;
  8936. }
  8937. if(pv>pvmax) {
  8938. var newpvmax = 5*Math.ceil(pv/5);
  8939. MY_setValue(i+'.caracs.pv.max',newpvmax);
  8940. infosTrolls[i][1] = newpvmax;
  8941. }
  8942. }
  8943. }
  8944.  
  8945. // insère 2 TD avant nextTD avec les infos venant de l'IT
  8946. function addTdInfosTroll(infos, nextTD) {
  8947. /* cadre barre PV */
  8948. var tab = document.createElement('div');
  8949. /* ancienne méthode par img, à supprimer
  8950. tab.width = 100;
  8951. tab.style.width = 100;
  8952. tab.height = 10;
  8953. tab.style.background = '#FFFFFF';
  8954. tab.style.border = 1;
  8955. */
  8956. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  8957. /* barre PV */
  8958. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  8959. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  8960. .vieContainer {
  8961. background-color: #CCC;
  8962. width: 50px;
  8963. height: 6px;
  8964. border: 1px solid #000;
  8965. text-align: left;
  8966. }
  8967. */
  8968. tab.style.width = '100px';
  8969. tab.style.height = '10px';
  8970. tab.style.border = '1px solid #000';
  8971. tab.style.textAlign = 'left';
  8972. var div2 = document.createElement('div');
  8973. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  8974. var dateLimite = new Date();
  8975. dateLimite.setDate(dateLimite.getDate() - 7);
  8976. if (infos.oUpdatedAt < dateLimite) {
  8977. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  8978. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  8979. } else if (pourcentVie > 66) {
  8980. div2.style.backgroundColor = '#77EE77';
  8981. } else if (pourcentVie > 33) {
  8982. div2.style.backgroundColor = '#EEEE77';
  8983. } else {
  8984. div2.style.backgroundColor = '#FF0000';
  8985. }
  8986. div2.style.width = pourcentVie + '%';
  8987. div2.style.height = '10px';
  8988. tab.appendChild(div2);
  8989. /* ancienne méthode par img, à supprimer
  8990. var img = document.createElement('img');
  8991. img.src = '../Images/Interface/milieu.gif';
  8992. img.height = 10;
  8993. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  8994. tab.appendChild(img);
  8995. */
  8996.  
  8997. /* lien vers l'IT */
  8998. var lien = document.createElement('a');
  8999. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9000. lien.href = URL_bricol+nomit+'/index.php';
  9001. lien.target = '_blank';
  9002. lien.appendChild(tab);
  9003. insertTdElement(nextTD,lien);
  9004. /* PAs dispos */
  9005. var span = document.createElement('span');
  9006. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9007. appendText(span, infos.pa +' PA' );
  9008. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9009. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9010. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9011. span.style.backgroundColor = 'B8EEB8';
  9012. }
  9013. insertTdElement(nextTD, span);
  9014. }
  9015.  
  9016. function putInfosTrolls(infosTrolls) {
  9017. try {
  9018. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9019. // supression des infos trop vieilles (un mois)
  9020. var IDs = Object.keys(infosTrolls);
  9021. var dateLimite = new Date();
  9022. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9023. for (var i = 0; i < IDs.length; i++) {
  9024. var idTroll = IDs[i];
  9025. var infos = infosTrolls[idTroll];
  9026. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9027. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9028. }
  9029. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9030. td.width = 40;
  9031. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9032. td.width = 105;
  9033.  
  9034. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9035. //corrigeBricolTrolls(infosTrolls);
  9036.  
  9037. for(i=nbTrolls ; i>0 ; i--) {
  9038. var infos = infosTrolls[getTrollID(i)];
  9039. if(infos && (!infos.bIgnore)) {
  9040. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9041. infos.done = true;
  9042. } else {
  9043. insertTd(tr_trolls[i].childNodes[6]);
  9044. insertTd(tr_trolls[i].childNodes[6]);
  9045. }
  9046. }
  9047. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9048. var str = MY_getValue(numTroll+'.INFOSIT');
  9049. if(!str) return;
  9050. var arr = str.split('$');
  9051. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9052.  
  9053. //window.console.log('nb Troll IT : ' + IDs.length);
  9054. var tBody = tr_trolls[0].parentNode;
  9055. if (tr_trolls[1] === undefined)
  9056. tBody = tr_trolls[0].parentNode;
  9057. else
  9058. tBody = tr_trolls[1].parentNode;
  9059. var pos = getPosition();
  9060. for (i = 0; i < IDs.length; i++) {
  9061. var idTroll = IDs[i];
  9062. infos = infosTrolls[idTroll];
  9063. if (infos.done) continue; // déjà vu
  9064. if (infos.bIgnore) continue; // trop vieux
  9065. if (idTroll == numTroll) continue; // pas nous-même
  9066. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9067. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9068. // trouver où insérer ce Troll
  9069. var next = undefined;
  9070. for(var j=0 ; j<tr_trolls.length ; j++) {
  9071. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9072. if (thisDist > distance) {
  9073. next = tr_trolls[j]
  9074. break;
  9075. }
  9076. }
  9077. var tr;
  9078. if (next !== undefined) {
  9079. tr = insertTr(next,'mh_tdpage')
  9080. } else {
  9081. tr = appendTr(tBody,'mh_tdpage');
  9082. }
  9083. var td = appendTd(tr); // distance
  9084. appendText(td, distance);
  9085. td = appendTd(tr); // actions
  9086. td = appendTd(tr); // ID
  9087. appendText(td, idTroll);
  9088. td = appendTd(tr); // Nom
  9089. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9090. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9091. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9092. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9093. td = appendTd(tr); // Niveau
  9094. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9095. td.align = 'center';
  9096. td = appendTd(tr); // Race
  9097. if (infos.race) appendText(td, infos.race);
  9098. // PV et PA ajoutés par addTdInfosTroll
  9099. td = appendTd(tr); // Guilde
  9100. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9101. td = appendTd(tr); // X
  9102. td.align = 'center';
  9103. if (infos.x !== undefined) appendText(td, infos.x);
  9104. td = appendTd(tr); // Y
  9105. td.align = 'center';
  9106. if (infos.y !== undefined) appendText(td, infos.y);
  9107. td = appendTd(tr); // N
  9108. td.align = 'center';
  9109. if (infos.n !== undefined) appendText(td, infos.n);
  9110. addTdInfosTroll(infos, tr.childNodes[6]);
  9111. }
  9112. } catch(e) {
  9113. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  9114. }
  9115. }
  9116.  
  9117.  
  9118. /* Mode Tétalanvert! ---------------------------------------------------------*/
  9119.  
  9120. function calculeDistance(maPos,posArr) {
  9121. return Math.max(
  9122. Math.abs(maPos[0]-posArr[0]),
  9123. Math.abs(maPos[1]-posArr[1]),
  9124. Math.abs(maPos[2]-posArr[2])
  9125. );
  9126. }
  9127.  
  9128. function inversionCoord() {
  9129. var maPos = getPosition();
  9130. var listeOffsets = {
  9131. 'monstres':checkBoxLevels.checked?4:3,
  9132. 'trolls':6,
  9133. };
  9134. for(var type in listeOffsets) {
  9135. var trList = this['tr_'+type];
  9136. var offset = listeOffsets[type];
  9137. for(var i=trList.length-1 ; i>0 ; i--) {
  9138. var oldX = parseInt(trList[i].cells[offset].textContent);
  9139. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  9140. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  9141. trList[i].cells[offset].innerHTML = oldY;
  9142. trList[i].cells[offset+1].innerHTML = oldX;
  9143. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  9144. }
  9145. }
  9146. }
  9147.  
  9148.  
  9149. /* Partie principale */
  9150. function do_vue() {
  9151. for(var type in typesAFetcher) {
  9152. fetchData(type);
  9153. }
  9154.  
  9155. // roule' 11/03/2016
  9156. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  9157. // je fais une recopie :(
  9158. tr_monstres = this['tr_monstres'];
  9159. tr_trolls = this['tr_trolls'];
  9160. tr_tresors = this['tr_tresors'];
  9161. tr_champignons = this['tr_champignons'];
  9162. tr_lieux = this['tr_lieux'];
  9163.  
  9164. nbMonstres = this['nbMonstres'];
  9165. nbTrolls = this['nbTrolls'];
  9166. nbTresors = this['nbTresors'];
  9167. nbChampignons = this['nbChampignons'];
  9168. nbLieux = this['nbLieux'];
  9169.  
  9170. try {
  9171. start_script(31);
  9172. initialiseInfos();
  9173. savePosition();
  9174.  
  9175. // Fonctionnalité "Têtalenvert" cachée, en test :
  9176. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  9177. inversionCoord();
  9178. }
  9179. ajoutDesFiltres();
  9180. set2DViewSystem();
  9181. //putBoutonTroogle();
  9182. putBoutonPXMP();
  9183. synchroniseFiltres();
  9184. toggleLevelColumn();
  9185.  
  9186. refreshDiplo();
  9187. //400 ms
  9188. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  9189. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  9190. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  9191. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  9192. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  9193. var noTresorsEngages =
  9194. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  9195. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  9196. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  9197. filtreMonstres();
  9198. if(noIntangibles) {
  9199. filtreTrolls();
  9200. }
  9201. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  9202. filtreTresors();
  9203. }
  9204. if(noTrou) {
  9205. filtreLieux();
  9206. }
  9207.  
  9208. initPopupVue();
  9209. initPXTroll();
  9210.  
  9211. if(getTalent("Projectile Magique")!=0) {
  9212. computeProjo();
  9213. }
  9214. if(getTalent("Charger")!=0) {
  9215. computeCharge();
  9216. }
  9217. if(getTalent("Télékinésie")!=0) {
  9218. computeTelek();
  9219. }
  9220. if(getTalent("Lancer de Potions")!=0) {
  9221. computeLdP();
  9222. }
  9223. putScriptExterne();
  9224. displayScriptTime();
  9225. } catch(e) {
  9226. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  9227. window.console.error(traceStack(e, 'vue'));
  9228. }
  9229. }
  9230.  
  9231.  
  9232.  
  9233. /*******************************************************************************
  9234. * This file is part of Mountyzilla. *
  9235. * *
  9236. * Mountyzilla is free software; you can redistribute it and/or modify *
  9237. * it under the terms of the GNU General Public License as published by *
  9238. * the Free Software Foundation; either version 2 of the License, or *
  9239. * (at your option) any later version. *
  9240. * *
  9241. * Mountyzilla is distributed in the hope that it will be useful, *
  9242. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9243. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9244. * GNU General Public License for more details. *
  9245. * *
  9246. * You should have received a copy of the GNU General Public License *
  9247. * along with Mountyzilla; if not, write to the Free Software *
  9248. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9249. *******************************************************************************/
  9250.  
  9251. // x~x profil2
  9252.  
  9253. /*---------------------------- Variables globales ----------------------------*/
  9254.  
  9255. var
  9256. // Anatrolliseur
  9257. urlAnatrolliseur,
  9258. // Infobulles talents
  9259. hauteur = 50, bulleStyle = null,
  9260. // Caracteristiques
  9261. // Infos troll
  9262. race, niv, idtroll, datecrea,
  9263. idguilde, nomguilde,
  9264. // Etats du troll
  9265. fatigue, bmfatigue,
  9266.  
  9267. // Experience, Pi, ...
  9268. pxdistribuables, pxperso,
  9269. piutilisable, pitotal,
  9270. nbmeurtres, nbmorts,
  9271. // utilisee pour les moyennes MM/jour, kill/jour, etc
  9272. NBjours,
  9273. // calcul des DLA suivantes
  9274. DLA, DLAsuiv, HeureServeur,
  9275. // details duree du tour (calcul pvdispo) :
  9276. dtb, pdm, bmt, adb, dpt,
  9277. //posale
  9278. posX, posY, posN,
  9279. // caracs physiques
  9280. vue, vuebp, vuebm, vuetotale,
  9281. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  9282. reg, regbp, regbm, regmoy,
  9283. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  9284. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  9285. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  9286. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  9287. rm, rmbp, rmbm, rmtotale,
  9288. mm, mmbp, mmbm, mmtotale,
  9289.  
  9290. // Variables speciales Kastars
  9291. pvActuelKastar, minParPV, overDLA,
  9292. // id pour edition manuelle de lastDLA :
  9293. inJour, inMois, inAn, inHr, inMin, inSec,
  9294. // id pour auto-refresh lastDLA :
  9295. lastDLAZone, maxAMZone, cumulZone,
  9296. lastDLA, DLAaccel;
  9297.  
  9298.  
  9299. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9300.  
  9301. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  9302. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  9303. function getUniqueValueBySelector(selector, defaultValue){
  9304. var valNode = document.querySelector(selector);
  9305. if(valNode!=null){
  9306. if(valNode.hasChildNodes()) {
  9307. return valNode.childNodes[0].nodeValue;
  9308. }else{
  9309. return defaultValue;
  9310. }
  9311. } else{
  9312. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  9313. return defaultValue;
  9314. }
  9315. }
  9316. function getUniqueStringValueBySelector(selector){
  9317. return getUniqueValueBySelector(selector,"");
  9318. }
  9319. function getUniqueIntValueBySelector(selector){
  9320. var ret = getUniqueValueBySelector(selector,0);
  9321. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9322. ret = 0;
  9323. }
  9324. return parseInt(ret);
  9325. }
  9326. function getUniqueFloatValueBySelector(selector){
  9327. var ret = getUniqueValueBySelector(selector,0.0);
  9328. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9329. ret = 0.0;
  9330. }
  9331. return parseFloat(ret);
  9332. }
  9333.  
  9334.  
  9335. function resiste(Ddeg,bm) {
  9336. // version naive mais compréhensible ^^
  9337. // DEBUG: à revoir
  9338. if(!bm) {
  9339. return 2*Math.floor(Ddeg/2);
  9340. }
  9341. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  9342. }
  9343.  
  9344. function retourAZero(fatig) {
  9345. var fat = fatig, raz = 0;
  9346. while(fat>0) {
  9347. raz++;
  9348. fat = Math.floor(fat/1.25);
  9349. }
  9350. return raz;
  9351. }
  9352.  
  9353. function decumulPumPrem(bonus) {
  9354. switch(bonus) {
  9355. case 20: return 33;
  9356. case 33: return 41;
  9357. case 41: return 46;
  9358. case 46: return 49;
  9359. case 49: return 51;
  9360. default: return 20;
  9361. }
  9362. }
  9363.  
  9364. function coefDecumul(i) {
  9365. switch(i) {
  9366. case 2: return 0.67;
  9367. case 3: return 0.4;
  9368. case 4: return 0.25;
  9369. case 5: return 0.15;
  9370. default: return 0.1;
  9371. }
  9372. }
  9373.  
  9374. function dureeHM(dmin) {
  9375. var ret = "";
  9376. dmin = Math.floor(dmin);
  9377. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  9378. var mins = dmin%60;
  9379. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  9380. return (ret) ? ret : "-";
  9381. }
  9382.  
  9383. // extraction d'une durée
  9384. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  9385. // c'est protégé (rend 0 si l'élément est absent)
  9386. // Roule' 24/12/2016
  9387. function extractionDuree(selecteur) {
  9388. var s = getUniqueStringValueBySelector(selecteur);
  9389. if (!s) return 0;
  9390. var tabN = getNumbers(s);
  9391. if (tabN.length < 2) return 0;
  9392. return tabN[0] * 60 + tabN[1];
  9393. }
  9394.  
  9395. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  9396.  
  9397. function extractionDonnees() {
  9398. // Variables temporaires
  9399. var Nbrs = {};
  9400.  
  9401. // *********************
  9402. // Cadre "Description"
  9403. // *********************
  9404. race = getUniqueStringValueBySelector('#descr #race');
  9405. debugMZ("Race : " + race);
  9406. idtroll = getUniqueStringValueBySelector('#descr #id');
  9407. debugMZ("Id troll : " + idtroll);
  9408. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  9409. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  9410. datecrea = new Date(StringToDate(strDateCrea));
  9411. debugMZ("Date creation : " + datecrea);
  9412. // Guilde
  9413. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  9414. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  9415. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  9416.  
  9417. // *******************
  9418. // Cadre "Experience"
  9419. // *******************
  9420. // Niveau de troll
  9421. niv = getUniqueIntValueBySelector('#exp #niv');
  9422. nivTroll = niv;
  9423. debugMZ("Niveau : " + niv);
  9424. // PX
  9425. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  9426. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  9427. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  9428. // PI
  9429. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  9430. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  9431. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  9432. // Meutres/Morts
  9433. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  9434. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  9435. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  9436.  
  9437. // *********************
  9438. // Cadre "Tour de Jeu"
  9439. // *********************
  9440. // DLA
  9441. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  9442. DLA = new Date(StringToDate(Nbrs["dla"]));
  9443. debugMZ("DLA: " + DLA);
  9444. // DLA suivante
  9445. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  9446. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  9447. debugMZ("DLAsuiv: " + DLAsuiv);
  9448. // Duree normale de mon Tour
  9449. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  9450. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  9451. dtb = extractionDuree("#dla #tour");
  9452. debugMZ("Duree normale de mon Tour : " + dtb);
  9453. // Bonus/Malus sur la duree
  9454. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  9455. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  9456. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  9457. debugMZ("Bonus/Malus sur la duree : " + bmt);
  9458. // Augmentation due aux blessures
  9459. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  9460. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  9461. adb = extractionDuree("#dla #blessure");
  9462. debugMZ("Augmentation due aux blessures : " + adb);
  9463. // Poids de l'equipement
  9464. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  9465. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  9466. pdm = extractionDuree("#dla #poids");
  9467. debugMZ("Poids de l'equipement : " + pdm);
  9468. // Duree de mon prochain Tour
  9469. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  9470. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  9471. dpt = extractionDuree("#dla #duree>b");
  9472. debugMZ('Duree de mon prochain Tour : ' + dpt);
  9473.  
  9474. // ****************
  9475. // Cadre "Etats"
  9476. // ****************
  9477. // Position du troll :
  9478. posX = getUniqueIntValueBySelector('#pos #x');
  9479. posY = getUniqueIntValueBySelector('#pos #y');
  9480. posN = getUniqueIntValueBySelector('#pos #n');
  9481. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  9482. // PV actuel
  9483. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  9484. pvActuelKastar = pvcourant;
  9485. debugMZ("PV actuel : " + pvcourant)
  9486. // Fatigue
  9487. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  9488. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  9489. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  9490.  
  9491. // **************************
  9492. // Cadre "Caracteristiques"
  9493. // **************************
  9494. // Attaque
  9495. att = getUniqueIntValueBySelector('#carac #att');
  9496. attbp = getUniqueIntValueBySelector('#carac #att_p');
  9497. attbm = getUniqueIntValueBySelector('#carac #att_m');
  9498. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  9499. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  9500. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  9501. attmoy = 3.5*att + attbp + attbm;
  9502. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9503. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  9504. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  9505. // Esquive
  9506. esq = getUniqueIntValueBySelector('#carac #esq');
  9507. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  9508. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  9509. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  9510. esqmoy = 3.5*esq + esqbp+esqbm;
  9511. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  9512. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  9513. // Degat
  9514. deg = getUniqueIntValueBySelector('#carac #deg');
  9515. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  9516. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  9517. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  9518. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  9519. degmoy = 2*deg + degbp+degbm;
  9520. degmoycrit = 3*deg + degbp+degbm;
  9521. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9522. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  9523. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  9524. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  9525. // PV
  9526. pvbase = getUniqueIntValueBySelector('#carac #pv');
  9527. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  9528. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  9529. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  9530. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  9531. // Regeneration
  9532. reg = getUniqueIntValueBySelector('#carac #reg');
  9533. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  9534. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  9535. regmoy = 2 * reg + regbp + regbm; // D3
  9536. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  9537. // Armure
  9538. arm = getUniqueIntValueBySelector('#carac #arm');
  9539. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  9540. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  9541. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  9542. armmoy = 2*arm + armbp+armbm;
  9543. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  9544. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  9545. // TODO : D d'armure non active
  9546. // Vue
  9547. vue = getUniqueIntValueBySelector('#carac #vue');
  9548. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  9549. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  9550. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  9551. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  9552. // RM
  9553. rm = getUniqueIntValueBySelector('#carac #rm');
  9554. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  9555. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  9556. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  9557. rmTroll = rmtotale;
  9558. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  9559. // MM
  9560. mm = getUniqueIntValueBySelector('#carac #mm');
  9561. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  9562. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  9563. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  9564. mmTroll = mmtotale;
  9565. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  9566.  
  9567. // Heure Serveur
  9568. try {
  9569. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  9570. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  9571. HeureServeur = new Date(StringToDate(heureServeurSTR));
  9572. } catch (e) {
  9573. window.console.warn(
  9574. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  9575. );
  9576. HeureServeur = new Date();
  9577. }
  9578. debugMZ("HeureServeur: " + HeureServeur);
  9579.  
  9580. // ***INIT GLOBALE*** NBjours
  9581. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  9582.  
  9583. // Calcul debut lien anatroliseur avec les caracteristiques connues
  9584. var amelio_dtb = function(dtb) {
  9585. if(dtb>555) {
  9586. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  9587. }
  9588. return 10+Math.ceil((555-dtb)/2.5);
  9589. },
  9590. amelio_pv = Math.floor(pvbase/10)-3,
  9591. amelio_vue = vue-3,
  9592. amelio_att = att-3,
  9593. amelio_esq = esq-3,
  9594. amelio_deg = deg-3,
  9595. amelio_reg = reg-1,
  9596. amelio_arm = arm-1;
  9597. if(race==="Darkling"){amelio_reg--; }
  9598. if(race==="Durakuir"){amelio_pv-- ; }
  9599. if(race==="Kastar") {amelio_deg--; }
  9600. if(race==="Skrim") {amelio_att--; }
  9601. if(race==="Tomawak") {amelio_vue--; }
  9602.  
  9603. urlAnatrolliseur = URL_AnatrolDispas
  9604. +"outils_anatrolliseur.php?anatrolliseur=v8"
  9605. +"|r="+race.toLowerCase()
  9606. +"|dla="+amelio_dtb(dtb)
  9607. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  9608. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  9609. +"|att="+amelio_att+","+attbp+","+attbm
  9610. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  9611. +"|deg="+amelio_deg+","+degbp+","+degbm
  9612. +"|reg="+amelio_reg+","+regbp+","+regbm
  9613. +"|arm="+amelio_arm+","+armbp+","+armbm
  9614. +"|mm="+mmtotale
  9615. +"|rm="+rmtotale+"|";
  9616. }
  9617.  
  9618. function saveProfil() {
  9619. MY_setValue(idtroll+'.caracs.attaque',att);
  9620. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  9621. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  9622. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  9623. if(atttourD||atttourP||atttourM) {
  9624. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9625. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  9626. }
  9627. MY_setValue(idtroll+'.caracs.esquive',esq);
  9628. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  9629. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  9630. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  9631. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  9632. MY_setValue(idtroll+'.caracs.degats',deg);
  9633. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  9634. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  9635. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  9636. if(degtourP||degtourM){
  9637. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9638. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  9639. }
  9640. MY_setValue(idtroll+'.caracs.regeneration',reg);
  9641. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  9642. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  9643. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  9644. MY_setValue(idtroll+'.caracs.vue',vue);
  9645. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  9646. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  9647. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  9648. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  9649. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  9650. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  9651. MY_setValue(idtroll+'.caracs.rm',rm);
  9652. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  9653. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  9654. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  9655. MY_setValue(idtroll+'.caracs.mm',mm);
  9656. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  9657. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  9658. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  9659. MY_setValue(idtroll+'.caracs.armure',arm);
  9660. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  9661. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  9662. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  9663. MY_setValue(idtroll+'.position.X',posX);
  9664. MY_setValue(idtroll+'.position.Y',posY);
  9665. MY_setValue(idtroll+'.position.N',posN);
  9666. MY_setValue(idtroll+'.race',race);
  9667. MY_setValue(idtroll+'.niveau',niv);
  9668. MY_setValue(idtroll+'.idguilde',idguilde);
  9669. MY_setValue(idtroll+'.nomguilde',nomguilde);
  9670. }
  9671.  
  9672.  
  9673. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  9674.  
  9675. function setInfosCaracteristiques() {
  9676. // Modification de l'entete
  9677. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  9678. thTotal.innerHTML+='|<i>Moyenne</i>';
  9679. thTotal.title="Moyenne (Moyenne ce tour)";
  9680.  
  9681. // Ajout des informations calculees
  9682. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  9683. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  9684. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  9685.  
  9686. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  9687. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  9688. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  9689.  
  9690. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  9691. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  9692. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  9693.  
  9694. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  9695. var tdRegTotal = trRegeneration.children[5];
  9696. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  9697. // Temps recupere par reg (propale R')
  9698. var regmoyTemp = Math.max(0, regmoy);
  9699. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  9700. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  9701. if (sec != 0) {
  9702. regTitle += " " + sec + " sec";
  9703. }
  9704. trRegeneration.title = regTitle;
  9705.  
  9706. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  9707. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  9708. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  9709.  
  9710. var trRM=document.querySelector("table#caracs #rm").parentElement;
  9711. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  9712. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  9713.  
  9714.  
  9715. var trMM=document.querySelector("table#caracs #mm").parentElement;
  9716. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  9717. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  9718.  
  9719. var tdRefl=document.querySelector("#refl");
  9720. // TODO : prendre en compte bonus/malus D esq du tour ?
  9721. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  9722. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  9723. }
  9724.  
  9725. function setLienAnatrolliseur(){
  9726. var pTableAmelio = document.querySelector("#carac>div>p");
  9727. pTableAmelio.innerHTML+=" - ";
  9728. var aElt = document.createElement("a");
  9729. aElt.setAttribute("href",urlAnatrolliseur);
  9730. aElt.setAttribute("target","_blank");
  9731. aElt.className="AllLinks";
  9732. aElt.innerHTML="Anatrolliser";
  9733. pTableAmelio.appendChild(aElt);
  9734. }
  9735. function setInfoDescription() {
  9736. var txtDateCrea = (NBjours!=1) ?
  9737. " ("+NBjours+" jours dans le hall)" :
  9738. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  9739. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  9740. }
  9741.  
  9742. function setInfosEtatLieux() {
  9743. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  9744. '?search=position&orderBy=distance&posx='+
  9745. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  9746. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  9747. appendBr(tdPosition);
  9748. var aElt = document.createElement("a");
  9749. aElt.setAttribute("href",urlBricol);
  9750. aElt.setAttribute("target","_blank");
  9751. aElt.className="AllLinks";
  9752. aElt.innerHTML="Lieux à proximité";
  9753. tdPosition.appendChild(aElt);
  9754. }
  9755.  
  9756. function setInfosEtatPV() { // pour AM et Sacro
  9757. var
  9758. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  9759. sec = Math.floor(15000/pvtotal)%60,
  9760. lifebar = document.querySelector("#pos .barre-vie");
  9761. if(sec!=0) { txt += " "+sec+" sec"; }
  9762. if(lifebar) { lifebar.title = txt; }
  9763. if(pvcourant<=0) { return; }
  9764. // Difference PV p/r a equilibre de temps (propale R')
  9765. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  9766. // ***INIT GLOBALE*** pvdispo
  9767. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  9768. var span = document.createElement("span");
  9769. span.title = txt;
  9770. span.style.fontStyle = "italic";
  9771. if(bmt+pdm>=0) {
  9772. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  9773. } else if(pvdispo>0) {
  9774. txt = "Vous pouvez encore perdre "+
  9775. Math.min(pvdispo,pvcourant)+
  9776. " PV sans malus de temps.";
  9777. } else if(pvdispo<0) {
  9778. txt = "Il vous manque "
  9779. +(-pvdispo)
  9780. +" PV pour ne plus avoir de malus de temps.";
  9781. } else {
  9782. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  9783. }
  9784. appendText(span,txt);
  9785. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  9786. }
  9787.  
  9788. // Complete le cadre "Experience"
  9789. function setInfosExp() {
  9790. var tdNiv = document.querySelector("#exp #niv");
  9791.  
  9792. // Calcul niveau monstre/troll min pour gain PX
  9793. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  9794. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  9795.  
  9796. // Calcul PX restant
  9797. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  9798. if (pxRestant >= 0) {
  9799. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  9800. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  9801. }
  9802.  
  9803. // Calul pi/jour
  9804. var
  9805. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  9806. tdPi = document.querySelector("#exp #pi").parentElement;
  9807. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  9808. tdPi.title = tdPiTotal.title;
  9809.  
  9810. // Rapports meurtres,morts
  9811. var tdKill = document.querySelector("#exp #kill");
  9812. tdKill.setAttribute("colspan", 1);
  9813. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  9814.  
  9815. var tdMort = document.querySelector("#exp #mort");
  9816. tdMort.setAttribute("colspan", 1);
  9817. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  9818.  
  9819. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  9820. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  9821. }
  9822.  
  9823.  
  9824. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  9825.  
  9826. function minParPVsac(fat,bm) {
  9827. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  9828. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  9829. var out = [];
  9830. out[0] = (fat>4) ?
  9831. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  9832. 30;
  9833. if(bm && bm>0) {
  9834. var totalfat=fat+bm;
  9835. out[1] = (totalfat>4) ?
  9836. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  9837. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  9838. }
  9839. return out;
  9840. }
  9841.  
  9842. function toInt(str) {
  9843. str = parseInt(str);
  9844. return (str) ? str : 0;
  9845. }
  9846.  
  9847. function saveLastDLA() {
  9848. // pour les calculs d'AM max
  9849. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  9850. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  9851. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  9852. lastDLA = new Date( StringToDate(str) );
  9853. MY_setValue(numTroll+'.DLA.ancienne',str);
  9854. lastDLAZone.innerHTML = '';
  9855. var b = document.createElement('b');
  9856. b.addEventListener('click',inputMode,false);
  9857. appendText(b,str);
  9858. lastDLAZone.appendChild(b);
  9859. refreshAccel();
  9860. }
  9861.  
  9862. function inputMode() {
  9863. // Edition manuelle lastDLA
  9864. var date;
  9865. if(lastDLA)
  9866. date = new Date( lastDLA );
  9867. else
  9868. date = new Date( DLAaccel );
  9869. lastDLAZone.innerHTML = '';
  9870. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  9871. appendText(lastDLAZone,'/');
  9872. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  9873. appendText(lastDLAZone,'/');
  9874. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  9875. appendText(lastDLAZone,' - ');
  9876. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  9877. appendText(lastDLAZone,':');
  9878. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  9879. appendText(lastDLAZone,':');
  9880. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  9881. appendText(lastDLAZone,' - ');
  9882. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  9883. }
  9884.  
  9885. function setAccel() {
  9886. var
  9887. BMfrais=false,
  9888. fat=fatigue, listeBmFat=[],
  9889. tr, th, insertPt;
  9890.  
  9891. // Creation ligne speciale pour AM dans le cadre "Etat"
  9892. tr = document.createElement('tr');
  9893. th = document.createElement('th');
  9894. appendText(th,'Fatigue et AM',true);
  9895. tr.appendChild(th);
  9896. insertPt = document.createElement('td');
  9897. tr.appendChild(insertPt);
  9898. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  9899.  
  9900. // Est-on en over-DLA ?
  9901. // ***INIT GLOBALE*** overDLA
  9902. overDLA = (HeureServeur>DLA.getTime()+3e5);
  9903. if(overDLA) {
  9904. fat=Math.floor(fatigue/1.25);
  9905. }
  9906.  
  9907. // Gestion des BM de fatigue
  9908. if(bmfatigue>0) {
  9909. // On tente de recuperer les BM de fatigue de la page des BM
  9910. if(MY_getValue(numTroll+'.bm.fatigue')) {
  9911. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  9912. BMmemoire.pop();
  9913. var tour = 0;
  9914. for(var i=0 ; i<BMmemoire.length ; i++) {
  9915. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  9916. while(tour<=parseInt(nbrs[0])) {
  9917. listeBmFat[tour]=parseInt(nbrs[1]);
  9918. tour++;
  9919. }
  9920. }
  9921. }
  9922. if(listeBmFat[0]==bmfatigue) {
  9923. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  9924. BMfrais = true;
  9925. MY_removeValue(numTroll+".bm.fatigue");
  9926. }
  9927. } else {
  9928. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  9929. BMfrais = true;
  9930. }
  9931. if(!BMfrais && bmfatigue>0) {
  9932. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  9933. if(bmfatigue==15) {
  9934. listeBmFat = [15,15,15];
  9935. } else {
  9936. listeBmFat = [30,30,15];
  9937. }
  9938. }
  9939. if(overDLA) {
  9940. // Si on est en over-DLA, on decale les bm d'un tour
  9941. listeBmFat.shift();
  9942. }
  9943. // Tableau des fatigues et accel futures
  9944. var
  9945. minppv = minParPVsac(fat,listeBmFat[0]),
  9946. table, tbody,
  9947. ligneTour, ligneFat, ligneMin,
  9948. col;
  9949. // ***INIT GLOBALE*** minParPV
  9950. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  9951. if(fat>0 || listeBmFat[0]>0) {
  9952. table = document.createElement('table');
  9953. table.className = 'mh_tdborder';
  9954. table.border = 0;
  9955. table.cellSpacing = 1;
  9956. table.cellPadding = 1;
  9957. table.style.textAlign = "center";
  9958. tbody = document.createElement('tbody');
  9959. table.appendChild(tbody);
  9960. insertPt.appendChild(table);
  9961. ligneTour = appendTr(tbody,'mh_tdtitre');
  9962. ligneTour.style.fontWeight = "bold";
  9963. var td = appendTdText(ligneTour,'Tour :',true);
  9964. td.align = 'left';
  9965. ligneFat = appendTr(tbody,'mh_tdpage');
  9966. td = appendTdText(ligneFat,'Fatigue :',true);
  9967. td.className = 'mh_tdtitre';
  9968. td.align = 'left';
  9969. ligneMin = appendTr(tbody,'mh_tdpage');
  9970. td = appendTdText(ligneMin,'1 PV =',true);
  9971. td.className = 'mh_tdtitre';
  9972. td.align = 'left';
  9973. col=0;
  9974. while(col<9 && (fat>0 || listeBmFat[col])) {
  9975. if(col==0) {
  9976. if(overDLA) {
  9977. var i = document.createElement('i');
  9978. appendText(i,'A activer');
  9979. ligneTour.appendChild(i);
  9980. } else {
  9981. appendTdText(ligneTour,'En cours');
  9982. }
  9983. } else {
  9984. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  9985. }
  9986. if(listeBmFat[col]) {
  9987. if(BMfrais || (!overDLA && col==0)) {
  9988. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  9989. appendTdText(ligneMin,minppv[1]+'\'');
  9990. } else {
  9991. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  9992. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  9993. }
  9994. } else {
  9995. appendTdText(ligneFat,fat);
  9996. appendTdText(ligneMin,minppv[0]+'\'');
  9997. }
  9998. col++;
  9999. fat = Math.floor(fat / 1.25);
  10000. minppv = minParPVsac(fat,listeBmFat[col]);
  10001. }
  10002. if(fat>1 || (fat==1 && !overDLA)) {
  10003. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10004. appendTdText(ligneFat,'-');
  10005. appendTdText(ligneMin,'-');
  10006. }
  10007. col = (overDLA) ?
  10008. Math.max(retourAZero(fatigue)-1,col) :
  10009. Math.max(retourAZero(fatigue),col);
  10010. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10011. appendTdText(ligneFat,'0');
  10012. appendTdText(ligneMin,'30\'');
  10013. if(!BMfrais && bmfatigue) {
  10014. // si les BM n'ont pas ete rafraichis, on signale:
  10015. appendText(
  10016. insertPt,
  10017. '/!\\ Visitez la page des Bonus/Malus '+
  10018. 'pour mettre à jour votre fatigue. /!\\',
  10019. true
  10020. );
  10021. appendBr(insertPt);
  10022. }
  10023. appendBr(insertPt);
  10024. }
  10025. if(pvcourant<=0) {
  10026. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10027. return;
  10028. }
  10029. if(fatigue>30) {
  10030. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10031. return;
  10032. }
  10033. // Setup lastDLAZone
  10034. if(overDLA) {
  10035. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10036. DLAaccel = new Date( DLAsuiv );
  10037. lastDLA = new Date( DLA );
  10038. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10039. // ***INIT GLOBALE*** pvActuelKastar
  10040. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10041. appendText(
  10042. insertPt,
  10043. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10044. true
  10045. );
  10046. appendBr(insertPt);
  10047. } else {
  10048. DLAaccel = new Date( DLA );
  10049. pvActuelKastar = pvcourant;
  10050. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10051. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10052. } else {
  10053. lastDLA = false;
  10054. }
  10055. }
  10056. appendText(insertPt,'Dernière DLA enregistrée : ');
  10057. lastDLAZone = document.createElement('span');
  10058. lastDLAZone.style.cursor = 'pointer';
  10059. var b = document.createElement('b');
  10060. b.onclick = inputMode;
  10061. lastDLAZone.appendChild(b);
  10062. insertPt.appendChild(lastDLAZone);
  10063. if(lastDLA) {
  10064. appendText(b,DateToString(lastDLA));
  10065. } else {
  10066. appendText(b,'aucune');
  10067. }
  10068. appendBr(insertPt);
  10069. // Setup maxAMZone et cumulZone
  10070. appendText(insertPt,'Accélération maximale possible : ');
  10071. maxAMZone = document.createElement('b');
  10072. insertPt.appendChild(maxAMZone);
  10073. appendBr(insertPt);
  10074. cumulZone = document.createElement('span');
  10075. insertPt.appendChild(cumulZone);
  10076. refreshAccel();
  10077. }
  10078.  
  10079. function refreshAccel() {
  10080. var pvs, pvsmax;
  10081. // Acceleration pour cumul instantane
  10082. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10083. if(lastDLA) {
  10084. pvsmax = Math.min(
  10085. pvActuelKastar-1,
  10086. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10087. );
  10088. maxAMZone.innerHTML = pvsmax+" PV";
  10089. } else {
  10090. pvsmax = pvActuelKastar-1;
  10091. maxAMZone.innerHTML = "inconnue";
  10092. }
  10093. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10094. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10095. cumulZone.innerHTML = '';
  10096. if(pvs<=pvsmax) {
  10097. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10098. appendText(cumulZone,pvs+' PV', true);
  10099. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10100. if(pvs!=1) {
  10101. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10102. -(pvs-1)*60*minParPV;
  10103. appendText(
  10104. cumulZone,
  10105. ' ('+(pvs-1)+' PV dans '+
  10106. Math.floor(gainSec/60)+'min'+
  10107. addZero(gainSec%60)+'s)'
  10108. );
  10109. }
  10110. } else {
  10111. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10112. appendText(
  10113. cumulZone,
  10114. 'Après votre accélération maximale, il vous faudra encore attendre '+
  10115. dureeHM(avantDLA/6e4)+
  10116. ' avant de réactiver.'
  10117. );
  10118. }
  10119. }
  10120.  
  10121.  
  10122. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  10123.  
  10124. function traitementTalents() {
  10125. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  10126. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  10127. removeAllTalents();
  10128. var totalComp = injecteInfosBulles(trCompetence,'competences');
  10129. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  10130. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  10131. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  10132. }
  10133.  
  10134. function injecteInfosBulles(liste,fonction) {
  10135. var totalpc = 0;
  10136. // on parse la liste des talents du type 'fonction'
  10137. for(var i=0 ; i<liste.length ; i++) {
  10138. var
  10139. trTalent=liste[i],
  10140. node=trTalent.cells[1].querySelector('a'),
  10141. nomTalent=epure(trim(node.textContent)),
  10142. indiceTDniveaux=7,
  10143. indiceTDSousCompetence=2,
  10144. sousCompetences=undefined;
  10145. if(fonction=="competences"){
  10146. // un TD en plus pour des information complementaire liees a la comp
  10147. indiceTDniveaux++;
  10148. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  10149. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  10150. for (var j=0; j < sousCompetences.length; j++) {
  10151. sousCompetences[j] = sousCompetences[j].epure().trim();
  10152. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  10153. }
  10154. }
  10155. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  10156. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  10157. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  10158. totalpc += niveauxMaitrisesTalentArray[1];
  10159.  
  10160. // stockage des niveaux inferieurs du talent si presents
  10161. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  10162. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  10163. totalpc+=niveauxMaitrisesTalentArray[j+1];
  10164. }
  10165. }
  10166. return totalpc;
  10167. }
  10168.  
  10169. function setInfos(node,nom,fonction,niveau) {
  10170. node.nom = nom;
  10171. node.fonction = fonction;
  10172. node.niveau = niveau;
  10173. node.onmouseover = setBulle;
  10174. node.onmouseout = cacherBulle;
  10175. }
  10176.  
  10177. var arrayModifAnatroll = {
  10178. 'Glue':'Glu',
  10179. 'PuM':'PuiM',
  10180. 'HE':'Hurlement',
  10181. //'Insultes':'Insu',
  10182. 'Pistage':'Pist',
  10183. 'PuC':'Planter'
  10184. }
  10185.  
  10186. function setTalent(nom,pc,niveau,sousCompetences) {
  10187. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  10188. // (et pas les % dont osf) ne serait pas plus rentable
  10189. var nomEnBase = arrayTalents[epure(nom)];
  10190. if(!nomEnBase) { return; }
  10191. if(!niveau) { niveau = 1; }
  10192. switch(nomEnBase) {
  10193. case 'Insultes':
  10194. urlAnatrolliseur += 'Insu'+niveau+'|';
  10195. case 'IdT':
  10196. nomEnBase += niveau;
  10197. break;
  10198. case 'Golemo':
  10199. case 'Piege':
  10200. for (var i=0 ; i < sousCompetences.length ; i++) {
  10201. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  10202. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  10203. }
  10204. break;
  10205. case 'AP':
  10206. case 'Baroufle':
  10207. case 'CdB':
  10208. case 'CdM':
  10209. case 'Parer':
  10210. case 'Retraite':
  10211. case 'RB':
  10212. case 'SInterposer':
  10213. nomEnBase += niveau;
  10214. default:
  10215. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  10216. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  10217. }
  10218. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  10219. }
  10220.  
  10221. function creerBulleVide() {
  10222. var table = document.createElement('table');
  10223. table.id = 'bulle';
  10224. table.className = 'mh_tdborder';
  10225. table.width = 300;
  10226. table.border = 0;
  10227. table.cellPadding = 5;
  10228. table.cellSpacing = 1;
  10229. table.style =
  10230. 'position:absolute;'
  10231. +'visibility:hidden;'
  10232. +'z-index:800;'
  10233. +'height:auto;';
  10234. var tr = appendTr(table,'mh_tdtitre');
  10235. appendTdText(tr,'Titre');
  10236. tr = appendTr(table,'mh_tdpage');
  10237. appendTdText(tr,'Contenu');
  10238. var aList = document.getElementsByTagName('a');
  10239. aList[aList.length-1].parentNode.appendChild(table);
  10240. }
  10241.  
  10242. function cacherBulle() {
  10243. if(bulleStyle)
  10244. bulleStyle.visibility = 'hidden';
  10245. }
  10246.  
  10247. function setBulle(evt) {
  10248. var nom = this.nom;
  10249. var fonction = this.fonction;
  10250. var niveau = parseInt(this.niveau);
  10251. var str='';
  10252. if(fonction=='competences'){
  10253. str=competences(nom,niveau);
  10254. } else if(fonction=='sortileges') {
  10255. str=sortileges(nom,true);
  10256. }
  10257. if(str=='') return;
  10258. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  10259. var xfenetre, yfenetre, xpage, ypage, element = null;
  10260. var offset = 15;
  10261. var bulleWidth = 300;
  10262. if(!hauteur) hauteur = 50;
  10263. element = document.getElementById('bulle');
  10264. xfenetre = evt.clientX;
  10265. yfenetre = evt.clientY;
  10266. xpage = xfenetre;
  10267. ypage = yfenetre;
  10268. if(evt.pageX) xpage = evt.pageX;
  10269. if(evt.pageY) ypage = evt.pageY;
  10270. if(element) {
  10271. bulleStyle = element.style;
  10272. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  10273. element.childNodes[1].firstChild.innerHTML = str;
  10274. }
  10275. if(bulleStyle) {
  10276. if(xfenetre>bulleWidth+offset)
  10277. xpage -= bulleWidth+offset;
  10278. else
  10279. xpage += offset;
  10280. if(yfenetre>hauteur+offset)
  10281. ypage -= hauteur + offset;
  10282. bulleStyle.width = bulleWidth;
  10283. bulleStyle.left = xpage + 'px';
  10284. bulleStyle.top = ypage + 'px';
  10285. bulleStyle.visibility = 'visible';
  10286. }
  10287. }
  10288.  
  10289.  
  10290. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  10291.  
  10292. function competences(comp,niveau) {
  10293. var texte = '';
  10294. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  10295. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  10296. if(minParPV>1) texte += 's';
  10297. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  10298. }
  10299. else if(comp.indexOf('Attaque Precise')!=-1) {
  10300. var pc, lastmax=0, espatt=0;
  10301. var notMaxedOut = false;
  10302. for(var i=niveau ; i>0 ; i--) {
  10303. pc = getTalent(comp,i);
  10304. if(lastmax!=0 && pc<=lastmax) continue;
  10305. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  10306. attbp+attbm;
  10307. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10308. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  10309. ' => <b>'+jetatt+'</b><br/>';
  10310. espatt += (pc-lastmax)*jetatt;
  10311. lastmax = pc;
  10312. if(i<niveau) notMaxedOut = true;
  10313. }
  10314. if(notMaxedOut) {
  10315. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  10316. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  10317. }
  10318. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  10319. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10320. }
  10321. else if(comp.indexOf('Balayage')!=-1)
  10322. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  10323. +' => <b>'+attmoy+'</b><br/>'
  10324. +'Effet : <b>Met à terre l\'adversaire</b>';
  10325. else if(comp.indexOf('Bidouille')!=-1)
  10326. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  10327. +'de votre inventaire avec le texte de votre choix.';
  10328. else if(comp.indexOf('Baroufle')!=-1){
  10329. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  10330. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  10331. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  10332. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  10333. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  10334. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  10335. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  10336. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  10337. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  10338. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  10339. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  10340. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  10341. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  10342. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  10343. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  10344. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  10345. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  10346. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  10347. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  10348. '</tbody></table>';
  10349. }
  10350. else if(comp.indexOf('Botte Secrete')!=-1){
  10351. texte = 'Attaque : <b>'
  10352. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10353. +' => <b>'
  10354. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  10355. +'</b><br/>Dégâts : <b>'
  10356. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  10357. +' => <b>'
  10358. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  10359. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  10360. +'</b>';
  10361. }
  10362. else if(comp.indexOf('Camouflage')!=-1) {
  10363. var camou = getTalent('Camouflage');
  10364. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  10365. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  10366. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  10367. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  10368. }
  10369. else if(comp.indexOf('Charger')!=-1) {
  10370. if(pvcourant<=0)
  10371. return '<i>On ne peut charger personne quand on est mort !</i>';
  10372. var portee = Math.min(
  10373. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  10374. vuetotale);
  10375. if(portee<1)
  10376. return '<b>Impossible de charger</b>';
  10377. else {
  10378. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10379. +' => <b>'+attmoy+'</b><br/>'
  10380. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10381. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  10382. +'<br/>Portée : <b>'+portee+'</b> case';
  10383. if(portee>1) texte += 's';
  10384. }
  10385. }
  10386. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  10387. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  10388. if(vuetotale>1) texte += 's';
  10389. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10390. if(vuetotale>2) texte += 's';
  10391. }
  10392. else if(comp.indexOf('Piege')!=-1) {
  10393. if(comp.indexOf('Glue')!=-1)
  10394. texte = 'Et si vous colliez vos adversaires au sol ?';
  10395. if(comp.indexOf('Feu')!=-1) {
  10396. if(texte){
  10397. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  10398. }
  10399. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  10400. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  10401. }
  10402. }
  10403. else if(comp.indexOf('Contre-Attaquer')!=-1){
  10404. texte = 'Attaque : <b>'
  10405. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10406. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10407. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10408. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10409. }
  10410. else if(comp.indexOf('Coup de Butoir')!=-1) {
  10411. var pc, lastmax=0, espdeg=0;
  10412. var notMaxedOut = false;
  10413. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10414. +' => <b>'+attmoy+'</b>';
  10415. for(var i=niveau ; i>0 ; i--) {
  10416. pc = getTalent(comp,i);
  10417. if(lastmax!=0 && pc<=lastmax) continue;
  10418. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  10419. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10420. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  10421. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  10422. espdeg += (pc-lastmax)*jetdeg;
  10423. lastmax = pc;
  10424. if(i<niveau) notMaxedOut = true;
  10425. }
  10426. if(notMaxedOut) {
  10427. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  10428. Math.floor(10*espdeg/lastmax)/10+'/'+
  10429. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  10430. }
  10431. }
  10432. else if(comp.indexOf('Course')!=-1)
  10433. texte = 'Déplacement gratuit : <b>'
  10434. +Math.floor(getTalent('Course')/2)
  10435. +' %</b> de chance';
  10436. else if(comp.indexOf('Deplacement Eclair')!=-1)
  10437. texte = 'Permet d\'économiser <b>1</b> PA '
  10438. +'par rapport au déplacement classique';
  10439. else if(comp.indexOf('Dressage')!=-1)
  10440. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  10441. +'ou un gnu sauvage.';
  10442. else if(comp.indexOf('Ecriture Magique')!=-1)
  10443. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  10444. +'la formule nécessite de réunir les composants de cette formule, '
  10445. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  10446. +'un champignon adéquat pour confectionner l\'encre.';
  10447. else if(comp.indexOf('Frenesie')!=-1) {
  10448. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10449. +' => <b>'+attmoy+'</b><br/>'
  10450. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10451. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10452. }
  10453. else if(comp.indexOf('Golem')!=-1)
  10454. texte = 'Animez votre golem en assemblant divers matériaux '
  10455. +'autour d\'un cerveau minéral.'
  10456. else if(comp.indexOf('Grattage')!=-1) {
  10457. texte = 'Permet de confectionner un Parchemin Vierge '
  10458. +'à partir de composants et de Gigots de Gob\'.';
  10459. }
  10460. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  10461. texte = 'Fait fuir un monstre si tout se passe bien.'
  10462. +'<br/>Lui donne de gros bonus sinon...';
  10463. else if(comp.indexOf('Identification des Champignons')!=-1) {
  10464. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10465. if(vuetotale>2) texte += 's';
  10466. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  10467. if(vuetotale>4) texte += 's';
  10468. }
  10469. else if(comp.indexOf('Insultes')!=-1)
  10470. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  10471. else if(comp.indexOf('interposer')!=-1)
  10472. texte = 'Jet de réflexe : <b>'
  10473. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  10474. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  10475. else if(comp.indexOf('Lancer de Potions') != -1)
  10476. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  10477. else if(comp.indexOf('Marquage')!=-1)
  10478. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  10479. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  10480. +'se trouver dans la même caverne que le monstre pour le marquer.';
  10481. else if(comp.indexOf('Melange Magique')!=-1)
  10482. texte = 'Cette Compétence permet de combiner deux Potions pour '
  10483. +'en réaliser une nouvelle dont l\'effet est la somme '
  10484. +'des effets des potions initiales.';
  10485. else if(comp.indexOf('Miner')!=-1)
  10486. texte = 'Portée horizontale (officieuse) : <b>'
  10487. +2*vuetotale+'</b> cases<br/>'
  10488. +'Portée verticale (officieuse) : <b>'
  10489. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10490. else if(comp.indexOf('Necromancie')!=-1)
  10491. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  10492. +'de faire "revivre" ce monstre.';
  10493. else if(comp.indexOf('Painthure de Guerre')!=-1)
  10494. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  10495. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  10496. +'pour s\'inspirer, et laissez parler votre créativité.'
  10497. else if(comp.indexOf('Parer')!=-1)
  10498. texte = 'Jet de parade : <b>'
  10499. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  10500. +' => <b>'
  10501. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10502. +'</b><hr><i>Equivalent esquive : <b>'
  10503. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  10504. +' => <b>'
  10505. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  10506. +'</b></i>';
  10507. else if(comp.indexOf('Pistage')!=-1)
  10508. texte = 'Portée horizontale : <b>'
  10509. +2*vuetotale+'</b> cases<br/>'
  10510. +'Portée verticale : <b>'
  10511. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10512. else if(comp.indexOf('Planter un Champignon')!=-1)
  10513. texte = 'Planter un Champignon est une compétence qui vous permet de '
  10514. +'créer des colonies d\'une variété donnée de champignon à partir de '
  10515. +'quelques exemplaires préalablement enterrés.';
  10516. else if(comp.indexOf('Regeneration Accrue')!=-1)
  10517. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  10518. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  10519. else if(comp.indexOf('Reparation')!=-1)
  10520. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  10521. +'et réparez vous-même votre matériel !';
  10522. else if(comp.indexOf('Retraite')!=-1)
  10523. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  10524. +'préférable de préparer un repli stratégique pour déconcerter '
  10525. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  10526. +'Quelle intelligence démoniaque.';
  10527. else if(comp.indexOf('Rotobaffe')!=-1) {
  10528. var Datt = att, vattbm = attbp+attbm;
  10529. var Ddeg = deg, vdegbm = degbp+degbm;
  10530. for(var i=1 ; i<niveau+2 ; i++) {
  10531. texte += '<b>Attaque n°'+i+' :</b><br/>'
  10532. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  10533. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  10534. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  10535. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  10536. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  10537. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  10538. if(i<niveau+1) texte += '<hr>';
  10539. }
  10540. }
  10541. else if(comp.indexOf('Shamaner')!=-1)
  10542. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  10543. +'des monstres en utilisant des champignons (de 1 à 3).';
  10544. else if(comp.indexOf('Tailler')!=-1){
  10545. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  10546. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  10547. }
  10548. return texte;
  10549. }
  10550.  
  10551. function decumul_buff(nom,str,buff) {
  10552. // Decumul des sorts de buff
  10553. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  10554. var dec = buff, total = buff, i=1;
  10555. while(i<6) {
  10556. i++;
  10557. dec = Math.floor(coefDecumul(i)*buff);
  10558. if(dec<=1 || i==6) break;
  10559. total += dec;
  10560. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  10561. +str+' +'+dec+' (+'+total+')</i>';
  10562. }
  10563. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  10564. return ret;
  10565. }
  10566.  
  10567.  
  10568. function sortileges(sort,mainCall,pcA,pcD) {
  10569. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  10570. var texte = '';
  10571. if (mainCall) {
  10572. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  10573. pcA = (atttourP+atttourM);
  10574. pcD = (degtourP+degtourM);
  10575. }
  10576. if (sort.indexOf('Analyse Anatomique') != -1) {
  10577. texte = 'Portée horizontale : <b>'
  10578. + Math.floor(vuetotale / 2) + '</b> case';
  10579. if (vuetotale > 3){ texte += 's'; }
  10580. texte += '<br/>Portée verticale : <b>'
  10581. + Math.floor((vuetotale+1)/4)+'</b> case';
  10582. if (vuetotale > 7){ texte += 's'; }
  10583. }
  10584. else if (sort.indexOf('Armure Etheree') != -1){
  10585. texte = decumul_buff('AE', 'Armure magique', reg);
  10586. }
  10587. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  10588. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  10589. }
  10590. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  10591. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  10592. }
  10593. else if (sort.indexOf('Augmentation des Degats') != -1){
  10594. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  10595. }
  10596. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  10597. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  10598. }
  10599. else if(sort.indexOf('Bulle Magique')!=-1){
  10600. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  10601. }
  10602. else if(sort.indexOf('Explosion')!=-1){
  10603. texte = 'Dégâts : <b>'
  10604. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  10605. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  10606. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  10607. }
  10608. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  10609. if(pvcourant<=0)
  10610. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  10611. texte = 'Portée horizontale : <b>'
  10612. +Math.min(1,vuetotale)+'</b> case<br/>'
  10613. +'Dégâts physiques : <b>-'
  10614. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  10615. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  10616. +'Dégâts magiques : <b>-'
  10617. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  10618. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  10619. }
  10620. else if(sort.indexOf('Flash Aveuglant')!=-1){
  10621. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  10622. }
  10623. else if(sort.indexOf('Glue')!=-1) {
  10624. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  10625. if(vuetotale>2) texte += 's';
  10626. }
  10627. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  10628. /* Frappe */
  10629. var modD = 0;
  10630. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10631. if(pcA!=0){
  10632. modD = parseInt(att*pcA/100);
  10633. texte += '<i>'+aff(modD)+'D6</i> ';
  10634. }
  10635. texte += aff(attbm)
  10636. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  10637. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  10638. if(pcD!=0) {
  10639. modD = parseInt(Math.floor(deg/2)*pcD/100);
  10640. texte += '<i>'+aff(modD)+'D3</i> ';
  10641. }else
  10642. modD = 0;
  10643. texte += aff(degbm)+' => <b>'
  10644. +(2*(Math.floor(deg/2)+modD)+degbm)
  10645. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  10646. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  10647. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  10648. +')</b>';
  10649. if(!mainCall) return texte;
  10650. /* Venins */
  10651. function addVenin(type,effet,duree) {
  10652. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  10653. +' pendant <b>'+duree+'</b> tour';
  10654. if(duree>1) ret += 's';
  10655. var dred = Math.max(Math.floor(duree/2),1);
  10656. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  10657. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  10658. }
  10659. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  10660. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  10661. effet = Math.floor(1.5*effet);
  10662. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  10663. }
  10664. else if(sort.indexOf('Hypnotisme')!=-1)
  10665. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  10666. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  10667. else if(sort.indexOf('Identification des tresors')!=-1)
  10668. texte = 'Permet de connaitre les caractéristiques et effets précis '
  10669. +'d\'un trésor.';
  10670. else if(sort.indexOf('Invisibilite')!=-1)
  10671. texte = 'Un troll invisible est indétectable même quand on se trouve '
  10672. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  10673. +'fait disparaître l\'invisibilité.';
  10674. else if(sort.indexOf('Levitation')!=-1)
  10675. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  10676. +'Comme les pièges ou les trous par exemple...';
  10677. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  10678. var eps = 1,
  10679. pc = 20;
  10680. var str = 'PréM';
  10681. var newSort;
  10682. var sortAtt = [
  10683. 'Projectile Magique',
  10684. 'Rafale Psychique',
  10685. 'Siphon des Ames',
  10686. 'Vampirisme',
  10687. 'Griffe du Sorcier'
  10688. ];
  10689. if(sort.indexOf('Puissance')!=-1) {
  10690. eps = -1; str='PuM';
  10691. }
  10692. for(var i=1 ; i<4 ; i++) {
  10693. if(texte) { texte += '<hr>'; }
  10694. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  10695. newSort = false;
  10696. for(var j=0 ; j<sortAtt.length ; j++) {
  10697. if(getTalent(sortAtt[j])) {
  10698. if(newSort) { texte += '<br/><br/>'; }
  10699. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  10700. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  10701. newSort = true;
  10702. }
  10703. }
  10704. pc = decumulPumPrem(pc);
  10705. }
  10706. }
  10707. else if(sort.indexOf('Projectile Magique')!=-1) {
  10708. var modD = 0;
  10709. var portee = getPortee__Profil(vuetotale);
  10710. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  10711. if(pcA!=0) {
  10712. modD = parseInt(vue*pcA/100);
  10713. texte += '<i>'+aff(modD)+'D6</i> ';
  10714. }
  10715. texte += aff(attbm)
  10716. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  10717. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  10718. if(pcD!=0) {
  10719. modD = parseInt(Math.floor(vue/2)+pcD);
  10720. texte += '<i>'+aff(modD)+'D3</i> ';
  10721. }else
  10722. modD = 0;
  10723. texte += aff(degbm)
  10724. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  10725. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  10726. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  10727. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  10728. if(!mainCall) return texte;
  10729. texte += '<br/>Portée : <b>'+portee+'</b> case';
  10730. if(portee>1) texte += 's';
  10731. }
  10732. else if(sort.indexOf('Projection')!=-1) {
  10733. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  10734. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  10735. +'Si le jet de résistance de la victime est réussi:<br/>'
  10736. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  10737. }
  10738. else if(sort.indexOf('Rafale Psychique')!=-1) {
  10739. var modD = 0;
  10740. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  10741. if(pcD!=0) {
  10742. modD = parseInt(deg*pcD/100);
  10743. texte += '<i>'+aff(modD)+'D3</i> ';
  10744. }
  10745. texte += aff(degbm)
  10746. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  10747. if(!mainCall) return texte;
  10748. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  10749. }
  10750. else if(sort.indexOf('Sacrifice')!=-1) {
  10751. if(pvcourant<=0)
  10752. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  10753.  
  10754. function perteSacro(sac) {
  10755. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  10756. }
  10757.  
  10758. var sac = Math.floor((pvcourant-1)/2);
  10759. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10760. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  10761. /* Sacros max et optimal sans malus (propale R') */
  10762. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10763. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  10764. if(sac>0)
  10765. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  10766. else
  10767. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  10768. /*if(sac>3) {
  10769. sac = 5*Math.floor((sac+1)/5)-1;
  10770. texte += '<br/>Soin optimal sans malus de temps : <b>'
  10771. +sac+'</b> PV'+perteSacro(sac);
  10772. }*/
  10773. }
  10774. else if(sort.indexOf('Siphon')!=-1) {
  10775. var modD = 0;
  10776. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10777. if(pcA!=0) {
  10778. modD = parseInt(att*pcA/100);
  10779. texte += '<i>'+aff(modD)+'D6</i> ';
  10780. }
  10781. texte += aff(attbm)
  10782. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  10783. +'Dégâts : <b>'+reg+'</b> D3 ';
  10784. if(pcD!=0) {
  10785. modD = parseInt(reg*pcD/100);
  10786. texte += '<i>'+aff(modD)+'D3</i> ';
  10787. }else
  10788. modD = 0;
  10789. texte += aff(degbm)
  10790. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  10791. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  10792. if(!mainCall) return texte;
  10793. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  10794. }
  10795. else if(sort.indexOf('Telekinesie')!=-1) {
  10796. texte = 'Portée horizontale :';
  10797. var vt = Math.floor(vuetotale/2)+2;
  10798. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  10799. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  10800. for(var i=0 ; i<5 ; i++) {
  10801. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  10802. if(vt>1) texte += 's';
  10803. vt=Math.max(0,vt-1);
  10804. }
  10805. }
  10806. else if(sort.indexOf('Teleportation')!=-1) {
  10807. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  10808. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  10809. var pmh = (20+vue+portee);
  10810. var pmv = 3+Math.floor(portee/3);
  10811. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  10812. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  10813. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  10814. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  10815. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  10816. }
  10817. else if(sort.indexOf('Vampirisme')!=-1) {
  10818. var modD = 0;
  10819. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  10820. if(pcA!=0) {
  10821. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  10822. texte += '<i>'+aff(modD)+'D6</i> ';
  10823. }
  10824. texte += aff(attbm)
  10825. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  10826. +'Dégâts : <b>'+deg+'</b> D3 ';
  10827. if(pcD!=0) {
  10828. modD = parseInt(deg*pcD/100);
  10829. texte += '<i>'+aff(modD)+'D3</i> ';
  10830. }else
  10831. modD = 0;
  10832. texte += aff(degbm)
  10833. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  10834. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  10835. }
  10836. else if(sort.indexOf('Vision Accrue')!=-1)
  10837. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  10838. else if(sort.indexOf('Vision lointaine')!=-1)
  10839. texte = 'En ciblant une zone située n\'importe où dans le '
  10840. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  10841. else if(sort.indexOf('Voir le Cache')!=-1)
  10842. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  10843. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  10844. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  10845. +getPortee__Profil(vuetotale)+'</b> cases';
  10846. else if(sort.indexOf('Vue Troublee')!=-1)
  10847. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10848. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  10849. return texte;
  10850. }
  10851.  
  10852.  
  10853. /*---------------------------------- Main ------------------------------------*/
  10854.  
  10855. function do_profil2()
  10856. {
  10857. try {
  10858. start_script(31);
  10859.  
  10860. extractionDonnees();
  10861. setInfosCaracteristiques();
  10862. setInfoDescription();
  10863. setInfosEtatLieux();
  10864. setInfosEtatPV();
  10865. setInfosExp();
  10866.  
  10867. creerBulleVide();
  10868. traitementTalents();
  10869. setLienAnatrolliseur();
  10870.  
  10871. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  10872. if(race=='Kastar'){ setAccel(); }
  10873. saveProfil();
  10874. displayScriptTime();
  10875. } catch(e) {
  10876. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10877. window.console.error(traceStack(e, 'profil2'));
  10878. }
  10879. }
  10880.  
  10881. /*********************************************************************************
  10882. * This file is part of Mountyzilla. *
  10883. * *
  10884. * Mountyzilla is free software; you can redistribute it and/or modify *
  10885. * it under the terms of the GNU General Public License as published by *
  10886. * the Free Software Foundation; either version 2 of the License, or *
  10887. * (at your option) any later version. *
  10888. * *
  10889. * Mountyzilla is distributed in the hope that it will be useful, *
  10890. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10891. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10892. * GNU General Public License for more details. *
  10893. * *
  10894. * You should have received a copy of the GNU General Public License *
  10895. * along with Mountyzilla; if not, write to the Free Software *
  10896. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10897. *********************************************************************************/
  10898.  
  10899. // x~x tancompo
  10900.  
  10901. var popup;
  10902.  
  10903. function initPopupTancompo() {
  10904. popup = document.createElement('div');
  10905. popup.setAttribute('id', 'popup');
  10906. popup.setAttribute('class', 'mh_textbox');
  10907. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  10908. + 'display: inline; z-index: 3; max-width: 400px;');
  10909. document.body.appendChild(popup);
  10910. }
  10911.  
  10912. // roule 16/03/2016, existe déjà ailleurs
  10913. // function showPopup(evt) {
  10914. // var texte = this.getAttribute("texteinfo");
  10915. // popup.innerHTML = texte;
  10916. // popup.style.left = evt.pageX + 15 + 'px';
  10917. // popup.style.top = evt.pageY + 'px';
  10918. // popup.style.visibility = "visible";
  10919. // }
  10920.  
  10921. // roule 16/03/2016, existe déjà ailleurs
  10922. // function hidePopup() {
  10923. // popup.style.visibility = 'hidden';
  10924. // }
  10925.  
  10926. function createPopupImage(url, text)
  10927. {
  10928. var img = document.createElement('img');
  10929. img.setAttribute('src',url);
  10930. img.setAttribute('align','ABSMIDDLE');
  10931. img.setAttribute("texteinfo",text);
  10932. img.addEventListener("mouseover", showPopup,true);
  10933. img.addEventListener("mouseout", hidePopup,true);
  10934. return img;
  10935. }
  10936.  
  10937. function formateTexte(texte)
  10938. {
  10939. texte = texte.replace(/\n/g,"<br/>");
  10940. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  10941. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  10942. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  10943. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  10944. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  10945. return texte;
  10946. }
  10947.  
  10948. function arrondi(x) {
  10949. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  10950. }
  10951.  
  10952. function traiteMinerai() {
  10953. if (currentURL.indexOf("as_type=Divers")==-1) return;
  10954. try {
  10955. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  10956. +" and contains(./tr/th/text(),'Minerai')]",
  10957. document, null, 9, null).singleNodeValue;
  10958. node = node.nextSibling.nextSibling;
  10959. }
  10960. catch(e) {return;}
  10961. var trlist = document.evaluate('./tr', node, null, 7, null);
  10962. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  10963. var node = trlist.snapshotItem(i);
  10964. var nature = node.childNodes[5].textContent;
  10965. var caracs = node.childNodes[7].textContent;
  10966. var taille = caracs.match(/\d+/)[0];
  10967. var coef = 1;
  10968. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  10969. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  10970. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  10971. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  10972. if (nature.indexOf('Mithril')!=-1) {
  10973. coef = 0.2*coef;
  10974. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  10975. }
  10976. else {
  10977. coef = 0.75*coef+1.25;
  10978. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  10979. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  10980. }
  10981. }
  10982. }
  10983.  
  10984. function treateComposants() {
  10985. if (currentURL.indexOf("as_type=Compo")==-1) return;
  10986. //On récupère les composants
  10987. var nodes = document.evaluate(
  10988. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  10989. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  10990. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  10991. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  10992. if (nodes.snapshotLength == 0) {
  10993. // window.alert('treateComposants DOWN');
  10994. return;
  10995. }
  10996. window.alert(nodes.snapshotLength);
  10997.  
  10998. var texte = "";
  10999. for (var i = 0; i < nodes.snapshotLength; i++) {
  11000. var n1 = nodes.snapshotItem(i).childNodes[1];
  11001. var n3 = nodes.snapshotItem(i).childNodes[3];
  11002. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  11003. var prix = n3.childNodes[0].nodeValue;
  11004. if (!prix)
  11005. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  11006. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  11007. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  11008. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  11009. + prix.replace(/\n/g, '') + "\n";
  11010. }
  11011.  
  11012. var c = document.evaluate("//div[@class = 'titre2']/text()",
  11013. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11014. var id_taniere = c.snapshotItem(0).nodeValue;
  11015. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  11016.  
  11017. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  11018. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  11019. if (form)
  11020. {
  11021. if(document.getElementsByTagName('form').length>0)
  11022. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  11023. else
  11024. {
  11025. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  11026. insertBefore(thisP, form);
  11027. }
  11028. }
  11029. }
  11030.  
  11031. function treateAllComposants() {
  11032. if(currentURL.indexOf("as_type=Compo")==-1) return;
  11033. //On récupère les composants
  11034. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  11035. document, null, 0, null ).numberValue;
  11036. var c = (categ == 0 ? 3 : 4);
  11037. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  11038. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  11039. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  11040. + "td["+c+"]/text()[1] = '\240-\240' "
  11041. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  11042. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  11043. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  11044. + "and td[1]/img/@alt = 'Identifié']",
  11045. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11046. if (nodes.snapshotLength == 0) {
  11047. // window.alert('treateAllComposants DOWN');
  11048. return;
  11049. }
  11050.  
  11051. var texte = "";
  11052. for (var i = 0; i < nodes.snapshotLength; i++) {
  11053. var n1 = nodes.snapshotItem(i).childNodes[1];
  11054. var n3 = nodes.snapshotItem(i).childNodes[3];
  11055. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  11056. var prix = n3.childNodes[0].nodeValue;
  11057. if (!prix)
  11058. {
  11059. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  11060. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  11061. }
  11062. else
  11063. {
  11064. prix= prix.replace(/[\240 ]/g, "");
  11065. if(prix=="-")
  11066. prix=null;
  11067. }
  11068. if(prix)
  11069. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  11070. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  11071. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  11072. + prix.replace(/\n/g, '') + "\n";
  11073. else
  11074. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  11075. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  11076. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  11077. }
  11078.  
  11079. var c = document.evaluate("//div[@class = 'titre2']/text()",
  11080. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11081. var id_taniere = c.snapshotItem(0).nodeValue;
  11082. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  11083.  
  11084. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  11085. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  11086. if (form)
  11087. {
  11088. if(document.getElementsByTagName('form').length>0)
  11089. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  11090. else
  11091. {
  11092. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  11093. insertBefore(thisP, form);
  11094. }
  11095. }
  11096. }
  11097.  
  11098. function treateEM()
  11099. {
  11100. if(currentURL.indexOf("as_type=Compo")==-1)
  11101. return false;
  11102. var urlImg = URL_MZimg + 'Competences/ecritureMagique.png';
  11103. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  11104. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11105. if (nodes.snapshotLength == 0)
  11106. return false;
  11107. for (var i = 0; i < nodes.snapshotLength; i++) {
  11108. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  11109. var link = desc[2].firstChild ;
  11110. var nomCompoTotal = desc[2].textContent ;
  11111. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  11112. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  11113. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  11114. var locqual = desc[3].textContent ;
  11115. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  11116. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  11117. if(isEM(nomMonstre).length>0)
  11118. {
  11119. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  11120. if(infos.length>0)
  11121. {
  11122. var shortDescr = "Variable";
  11123. var bold = 0;
  11124. if(infos != "Composant variable")
  11125. {
  11126. shortDescr = infos.substring(0,infos.indexOf(" "));
  11127. if(parseInt(shortDescr)>=0)
  11128. bold=1;
  11129. }
  11130. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  11131. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  11132. }
  11133. }
  11134. }
  11135. }
  11136.  
  11137. function treateChampi() {
  11138. if (currentURL.indexOf('as_type=Champi')==-1)
  11139. return false;
  11140. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  11141. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11142. if (nodes.snapshotLength == 0)
  11143. return false;
  11144.  
  11145. for (var i = 0; i < nodes.snapshotLength; i++) {
  11146. var node = nodes.snapshotItem(i);
  11147. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  11148. if (moisChampi[nomChampi])
  11149. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  11150. }
  11151. }
  11152.  
  11153. function treateEnchant()
  11154. {
  11155. if(currentURL.indexOf("as_type=Compo")==-1)
  11156. return false;
  11157. try
  11158. {
  11159. if(!listeMonstreEnchantement)
  11160. computeCompoEnchantement();
  11161. var nodes = document.evaluate(
  11162. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  11163. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  11164. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  11165. if (nodes.snapshotLength == 0)
  11166. return false;
  11167. var urlImg = URL_MZimg + "enchant.png";
  11168. for (var i = 0; i < nodes.snapshotLength; i++) {
  11169. var link = nodes.snapshotItem(i);
  11170. var nomCompoTotal = link.firstChild.nodeValue;
  11171. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  11172. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  11173. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  11174. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  11175. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  11176. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  11177. if(isEnchant(nomMonstre).length>0)
  11178. {
  11179. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  11180. if(infos.length>0)
  11181. {
  11182. link.parentNode.appendChild(createImage(urlImg,infos));
  11183. }
  11184. }
  11185. }
  11186. }
  11187. catch(e)
  11188. {
  11189. window.alert(e);
  11190. }
  11191. }
  11192.  
  11193. function treateEquipEnchant()
  11194. {
  11195. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  11196. return false;
  11197. initPopupTancompo();
  11198. computeEnchantementEquipement(createPopupImage,formateTexte);
  11199. }
  11200.  
  11201. function do_tancompo()
  11202. {
  11203. start_script();
  11204.  
  11205. treateAllComposants();
  11206. treateComposants();
  11207. traiteMinerai();
  11208. if (MY_getValue('NOINFOEM')!='true') {
  11209. treateChampi();
  11210. treateEM();
  11211. }
  11212. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  11213. treateEnchant();
  11214. treateEquipEnchant();
  11215. }
  11216.  
  11217. displayScriptTime();
  11218. }
  11219.  
  11220.  
  11221.  
  11222.  
  11223.  
  11224. /*******************************************************************************
  11225. * This file is part of Mountyzilla. *
  11226. * *
  11227. * Mountyzilla is free software; you can redistribute it and/or modify *
  11228. * it under the terms of the GNU General Public License as published by *
  11229. * the Free Software Foundation; either version 2 of the License, or *
  11230. * (at your option) any later version. *
  11231. * *
  11232. * Mountyzilla is distributed in the hope that it will be useful, *
  11233. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11234. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11235. * GNU General Public License for more details. *
  11236. * *
  11237. * You should have received a copy of the GNU General Public License *
  11238. * along with Mountyzilla; if not, write to the Free Software *
  11239. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11240. *******************************************************************************/
  11241.  
  11242. // x~x script_principal
  11243.  
  11244. function isPage(url) {
  11245. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11246. }
  11247.  
  11248. // x~x md5.js
  11249. /*
  11250. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11251. * Digest Algorithm, as defined in RFC 1321.
  11252. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11253. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11254. * Distributed under the BSD License
  11255. * See http://pajhome.org.uk/crypt/md5 for more info.
  11256. */
  11257.  
  11258. /*
  11259. * Configurable variables. You may need to tweak these to be compatible with
  11260. * the server-side, but the defaults work in most cases.
  11261. */
  11262. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11263. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11264. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11265.  
  11266. /*
  11267. * These are the functions you'll usually want to call
  11268. * They take string arguments and return either hex or base-64 encoded strings
  11269. */
  11270. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11271. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11272. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11273. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11274. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11275. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11276.  
  11277. /*
  11278. * Perform a simple self-test to see if the VM is working
  11279. */
  11280. function md5_vm_test()
  11281. {
  11282. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11283. }
  11284.  
  11285. /*
  11286. * Calculate the MD5 of an array of little-endian words, and a bit length
  11287. */
  11288. function core_md5(x, len)
  11289. {
  11290. /* append padding */
  11291. x[len >> 5] |= 0x80 << ((len) % 32);
  11292. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11293.  
  11294. var a = 1732584193;
  11295. var b = -271733879;
  11296. var c = -1732584194;
  11297. var d = 271733878;
  11298.  
  11299. for(var i = 0; i < x.length; i += 16)
  11300. {
  11301. var olda = a;
  11302. var oldb = b;
  11303. var oldc = c;
  11304. var oldd = d;
  11305.  
  11306. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11307. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11308. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11309. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11310. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11311. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11312. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11313. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11314. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11315. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11316. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11317. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11318. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11319. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11320. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11321. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11322.  
  11323. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11324. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11325. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11326. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11327. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11328. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11329. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11330. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11331. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11332. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11333. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11334. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11335. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11336. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11337. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11338. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11339.  
  11340. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11341. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11342. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11343. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11344. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11345. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11346. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11347. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11348. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11349. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11350. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11351. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11352. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11353. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11354. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11355. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11356.  
  11357. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11358. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11359. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11360. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11361. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11362. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11363. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11364. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11365. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11366. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11367. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11368. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11369. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11370. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11371. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11372. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11373.  
  11374. a = safe_add(a, olda);
  11375. b = safe_add(b, oldb);
  11376. c = safe_add(c, oldc);
  11377. d = safe_add(d, oldd);
  11378. }
  11379. return Array(a, b, c, d);
  11380.  
  11381. }
  11382.  
  11383. /*
  11384. * These functions implement the four basic operations the algorithm uses.
  11385. */
  11386. function md5_cmn(q, a, b, x, s, t)
  11387. {
  11388. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11389. }
  11390. function md5_ff(a, b, c, d, x, s, t)
  11391. {
  11392. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11393. }
  11394. function md5_gg(a, b, c, d, x, s, t)
  11395. {
  11396. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11397. }
  11398. function md5_hh(a, b, c, d, x, s, t)
  11399. {
  11400. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11401. }
  11402. function md5_ii(a, b, c, d, x, s, t)
  11403. {
  11404. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11405. }
  11406.  
  11407. /*
  11408. * Calculate the HMAC-MD5, of a key and some data
  11409. */
  11410. function core_hmac_md5(key, data)
  11411. {
  11412. var bkey = str2binl(key);
  11413. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11414.  
  11415. var ipad = Array(16), opad = Array(16);
  11416. for(var i = 0; i < 16; i++)
  11417. {
  11418. ipad[i] = bkey[i] ^ 0x36363636;
  11419. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11420. }
  11421.  
  11422. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11423. return core_md5(opad.concat(hash), 512 + 128);
  11424. }
  11425.  
  11426. /*
  11427. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11428. * to work around bugs in some JS interpreters.
  11429. */
  11430. function safe_add(x, y)
  11431. {
  11432. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11433. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11434. return (msw << 16) | (lsw & 0xFFFF);
  11435. }
  11436.  
  11437. /*
  11438. * Bitwise rotate a 32-bit number to the left.
  11439. */
  11440. function bit_rol(num, cnt)
  11441. {
  11442. return (num << cnt) | (num >>> (32 - cnt));
  11443. }
  11444.  
  11445. /*
  11446. * Convert a string to an array of little-endian words
  11447. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11448. */
  11449. function str2binl(str)
  11450. {
  11451. var bin = Array();
  11452. var mask = (1 << chrsz) - 1;
  11453. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11454. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11455. return bin;
  11456. }
  11457.  
  11458. /*
  11459. * Convert an array of little-endian words to a string
  11460. */
  11461. function binl2str(bin)
  11462. {
  11463. var str = "";
  11464. var mask = (1 << chrsz) - 1;
  11465. for(var i = 0; i < bin.length * 32; i += chrsz)
  11466. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11467. return str;
  11468. }
  11469.  
  11470. /*
  11471. * Convert an array of little-endian words to a hex string.
  11472. */
  11473. function binl2hex(binarray)
  11474. {
  11475. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11476. var str = "";
  11477. for(var i = 0; i < binarray.length * 4; i++)
  11478. {
  11479. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11480. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11481. }
  11482. return str;
  11483. }
  11484.  
  11485. /*
  11486. * Convert an array of little-endian words to a base-64 string
  11487. */
  11488. function binl2b64(binarray)
  11489. {
  11490. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11491. var str = "";
  11492. for(var i = 0; i < binarray.length * 4; i += 3)
  11493. {
  11494. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11495. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11496. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11497. for(var j = 0; j < 4; j++)
  11498. {
  11499. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11500. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11501. }
  11502. }
  11503. return str;
  11504. }
  11505.  
  11506. ///////////////////////////////////////////
  11507. // debug cartes capitan Roule 07/12/2016
  11508. ///////////////////////////////////
  11509. // essais : objet
  11510. // .mode : description
  11511. // .essais : tableau d'objets essai
  11512. // .mode : description
  11513. // .essais : tableau de cartes
  11514. // .noCarte : id de la carte
  11515. // .essais : tableau d'essais, [x, y, n, nb]
  11516. function AfficheEssais(essais, sMode) {
  11517. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11518. if (!eBigDiv) {
  11519. var insertPoint = document.getElementById('footer1');
  11520. eBigDiv = document.createElement('table');
  11521. eBigDiv.id = 'ListeEssaiCapitan';
  11522. insertBefore(insertPoint, document.createElement('p'));
  11523. insertTitle(insertPoint,'Capitan : Liste des essais');
  11524. insertBefore(insertPoint, eBigDiv);
  11525. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11526. }
  11527. if (!essais) {
  11528. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11529. return;
  11530. }
  11531. var carte;
  11532. for (carte in essais) {
  11533. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11534. }
  11535. if (carte === undefined) {
  11536. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11537. }
  11538. }
  11539.  
  11540. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11541. var tr = appendTr(eTable);
  11542. var td = appendTd(tr);
  11543. appendText(td, sMode, bBold);
  11544. td = appendTd(tr);
  11545. appendText(td, sCarte, bBold);
  11546. td = appendTd(tr);
  11547. appendText(td, sText, bBold);
  11548. }
  11549.  
  11550. function getEssaiV1_0() {
  11551. try {
  11552. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11553. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11554. var tabK, nK;
  11555. prefs.getChildList('', nK, tabK);
  11556. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11557. //window.console.log('getEssaiV1_0, ' + nK);
  11558. return;
  11559. //return r;
  11560. } catch (e) {
  11561. window.console.log(traceStack(e, 'getEssaiV1_0'));
  11562. }
  11563. }
  11564.  
  11565. function getEssaiV1_1() {
  11566. var locSto = window.localStorage;
  11567. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11568. var r = [];
  11569. for (var i = 0; i < locSto.length; i++) {
  11570. var k = locSto.key(i);
  11571. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11572. var t = k.split(/\./);
  11573. if (t[0] !== 'capitan') continue;
  11574. if (t[2] !== 'essai') continue;
  11575. var carte = 'carte n°' + t[1];
  11576. if (r[carte]) r[carte]++;
  11577. else r[carte] = 1;
  11578. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11579. }
  11580. return r;
  11581. }
  11582.  
  11583. function showEssaiCartes() {
  11584. window.console.log('début showEssai Tout_MZ');
  11585. var essais = getEssaiV1_0();
  11586. AfficheEssais(essais, 'V1.0');
  11587. essais = getEssaiV1_1();
  11588. AfficheEssais(essais, 'V1.1');
  11589. window.console.log('fin showEssai Tout_MZ');
  11590. }
  11591.  
  11592. /*--------------------------------- Dispatch ---------------------------------*/
  11593.  
  11594. //chargerScriptDev("libs");
  11595. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  11596.  
  11597. try {
  11598. // Détection de la page à traiter
  11599. if(isPage("Messagerie/ViewMessageBot")) {
  11600. do_cdmbot();
  11601. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  11602. do_cdmcomp();
  11603. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  11604. do_diplo();
  11605. } else if(isPage("MH_Play/Play_equipement")) {
  11606. do_equip();
  11607. } else if(isPage("MH_Play/Play_menu")) {
  11608. do_menu();
  11609. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  11610. do_option();
  11611. //showEssaiCartes();
  11612. } else if(isPage("View/PJView")) {
  11613. do_pjview();
  11614. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  11615. do_profil();
  11616. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  11617. do_tancompo();
  11618. } else if(isPage("MH_Play/Play_vue")) {
  11619. do_vue();
  11620. } else if(isPage("MH_Play/Play_news")) {
  11621. do_news();
  11622. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  11623. do_move();
  11624. } else if(isPage("MH_Missions/Mission_Etape")) {
  11625. do_mission();
  11626. } else if(isPage("View/MonsterView")) {
  11627. do_infomonstre();
  11628. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  11629. do_attaque();
  11630. } else if(isPage("MH_Follower/FO_Ordres")) {
  11631. do_ordresgowap();
  11632. } else if(isPage("MH_Follower/FO_Equipement")) {
  11633. do_equipgowap();
  11634. } else if(isPage("MH_Play/Play_mouche")) {
  11635. do_mouches();
  11636. } else if(isPage("MH_Play/Play_BM")) {
  11637. do_malus();
  11638. } else if(isPage("MH_Play/Play_evenement")) {
  11639. do_myevent();
  11640. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  11641. do_enchant();
  11642. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  11643. do_pre_enchant();
  11644. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  11645. do_actions();
  11646. } 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')) {
  11647. do_mission_liste();
  11648. } else if(isPage('MH_Play/Play_action')) {
  11649. do_actions();
  11650. } else if(isPage('MH_Play/Play_profil2')) {
  11651. do_profil2();
  11652. }
  11653. } catch(e) {
  11654. if (e.stack) {
  11655. var sStack = e.stack;
  11656. // enlever les infos confidentielles
  11657. sStack = sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  11658. } else {var sStack = '';}
  11659. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  11660. }