Tout_MZ

Client MountyZilla

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

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @version 1.2.13.5
  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. // V1.2.13.1 06/01/2017
  95. // Suppression oldSchoolProfile qui n'existe plus
  96. // Ajout du "refresh" du cadre de gauche
  97. // V1.2.13.2 07/01/2017
  98. // Correction missions, recherche troogle (familles et types de monstres)
  99. // V1.2.13.3 07/01/2017
  100. // Correction erreur sur un commentaire qui bloquait la compilation javascript
  101. // V1.2.13.4 07/01/2017
  102. // Plus de traces en mode debug pour l'analyse des étapes de mission
  103. // V1.2.13.5 07/01/2017
  104. // Correction bug qui se manisfestait sous LINUX
  105.  
  106. /**********************************************************
  107. À faire / propositions d'évolutions
  108.  
  109. breizhou13 20/12/2016
  110. envoyer les données à l'IT (Bricol'Trolls) aussi
  111. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  112. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  113. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  114. Roule'
  115. Réactiver les jubilaires
  116. [Prioritaire] trajets Gowaps sans avoir besoin de URL_MZscriptCarte (voir comment c'est fait dans Trajet_des_gowap_MkII.user.js)
  117. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  118. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  119. - voir l'intérêt de refaire fonctionner
  120. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  121. **********************************************************/
  122.  
  123. /**********************************************************
  124. **** Début de zone à déplacer dans une bibli commune ******
  125. **********************************************************/
  126.  
  127. // URL de base serveur MZ
  128. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  129. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  130. //var URL_MZ = 'http://192.99.225.92/mz';
  131.  
  132. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  133. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  134.  
  135. // URLs externes redirection (pas de souci CORS)
  136. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  137. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  138. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  139. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  140. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  141. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  142. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  143. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  144. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  145.  
  146. // URLs de test HTTPS
  147. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  148. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  149.  
  150. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  151. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  152. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  153.  
  154. // x~x Libs
  155.  
  156. /* ancien TODO
  157. * - revoir la gestion des CdM --> nott armure magique
  158. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  159. * - vérfier la gestion des enchants
  160. */
  161.  
  162. // Roule 04/09/2016 switch extern URLs to https if available
  163. var isHTTPS = false;
  164. if (window.location.protocol.indexOf('https') === 0) {
  165. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  166. URL_bricol = URL_bricol_https;
  167. isHTTPS = true;
  168. }
  169.  
  170. // Roule 23/12/2016 mode dev
  171. var isDEV = false;
  172. if (MY_getValue('MZ_dev')) {
  173. URL_MZ = URL_MZ.replace(/$/, 'dev');
  174. isDEV = true;
  175. }
  176.  
  177. // Images (pas de souci CORS)
  178. var URL_MZimg = URL_MZ + '/img/';
  179. // URLs externes ajax (CORS OK)
  180. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  181. var URL_pageDispatcher = URL_MZ + '/cdmdispatcher.php';
  182.  
  183. // liens externes détuits
  184. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  185. var MHicons = '/mountyhall/Images/Icones/';
  186. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  187. var MY_DEBUG = false;
  188.  
  189. /* remplacement fonction MZ */
  190. function MY_getValue(key) {
  191. return window.localStorage[key];
  192. }
  193.  
  194. function MY_removeValue(key) {
  195. window.localStorage.removeItem(key);
  196. }
  197.  
  198. function MY_setValue(key, val) {
  199. window.localStorage[key] = val;
  200. }
  201.  
  202. /*---------------- mise à jour de variables globales utiles ------------------*/
  203. // utilisé pour accès bdd (un peu partout) :
  204. var numTroll = MY_getValue('NUM_TROLL');
  205. // utilisé dans vue pour PX :
  206. var nivTroll = MY_getValue('NIV_TROLL');
  207. // utilisés dans actions et vue (calculs SR) :
  208. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  209. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  210. var currentURL = window.location.href;
  211.  
  212. /*-[functions]------------ Fonctions durée de script -------------------------*/
  213. var date_debut = null;
  214.  
  215. function start_script(nbJours_exp) {
  216. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  217. if(date_debut) return;
  218. date_debut = new Date();
  219. // Créé la variable expdate si demandé
  220. if(nbJours_exp) {
  221. expdate = new Date();
  222. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  223. }
  224. }
  225.  
  226. function displayScriptTime() {
  227. var footerNode = document.getElementById('footer2');
  228. if(!footerNode) return;
  229. try{
  230. var node = document.evaluate(
  231. ".//text()[contains(.,'Page générée en')]/../br",
  232. footerNode,null,9,null).singleNodeValue;
  233. }
  234. catch(e){return;}
  235. insertText(node,
  236. ' - [Script exécuté en '
  237. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  238. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  239. }
  240.  
  241. function traceStack(e, sModule) {
  242. var version = '';
  243. if (GM_info && GM_info.script && GM_info.script.version)
  244. version = ' ' + GM_info.script.version;
  245. sRet = '[MZ' + version + ']'
  246. if (sModule) sRet += ' {' + sModule + '}';
  247. if (e.message) sRet += ' ' + e.message;
  248. if (e.stack) {
  249. var sStack = e.stack;
  250. // enlever les infos confidentielles
  251. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  252. }
  253. return sRet;
  254. }
  255.  
  256. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  257.  
  258. function debugMZ(str){
  259. if(MY_DEBUG){
  260. window.console.debug('[MY_DEBUG] '+str);
  261. if(typeof str === "object"){
  262. window.console.debug(str);
  263. }
  264. }
  265. }
  266.  
  267. function FF_XMLHttpRequest(MY_XHR_Ob) {
  268. var request = new XMLHttpRequest();
  269. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  270. for(var head in MY_XHR_Ob.headers) {
  271. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  272. }
  273. request.onreadystatechange = function() {
  274. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  275. if(request.readyState!=4) { return; }
  276. if(request.error) {
  277. if(MY_XHR_Ob.onerror) {
  278. MY_XHR_Ob.onerror(request);
  279. }
  280. }
  281. else if(MY_XHR_Ob.onload) {
  282. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  283. MY_XHR_Ob.onload(request);
  284. }
  285. };
  286. request.send(MY_XHR_Ob.data);
  287. }
  288.  
  289.  
  290. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  291.  
  292. function avertissement(txt,duree) {
  293. if(!duree) duree = 15000;
  294. var div = document.createElement('div');
  295. // On numérote les avertissements pour destruction sélective
  296. var num = document.getElementsByName('avertissement').length;
  297. div.num = num;
  298. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  299. div.setAttribute('name','avertissement');
  300. div.className = 'mh_textbox';
  301. div.style.position = 'fixed';
  302. div.style.top = (10+15*num)+'px';
  303. div.style.left = (10+5*num)+'px';
  304. div.style.border = '5px solid red';
  305. div.style.zIndex = 2+num;
  306. div.style.cursor = 'pointer';
  307. div.style.fontSize = 'large';
  308. div.innerHTML = txt;
  309. div.onclick=function(){ tueAvertissement(this.num) };
  310.  
  311. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  312. var divcroix = document.createElement('div');
  313. divcroix.style.position = 'absolute';
  314. divcroix.style.top = 0;
  315. divcroix.style.right = 0;
  316. divcroix.style.color = 'black';
  317. divcroix.style.fontSize = 'inherit';
  318. divcroix.style.cursor = 'pointer'
  319. divcroix.style.zIndex = 2+num;
  320. divcroix.innerHTML = "X";
  321. div.appendChild(divcroix);
  322.  
  323. document.body.appendChild(div);
  324. // Destruction automatique de l'avertissement après "un certain temps"
  325. window.setTimeout(function(){ tueAvertissement(num) },duree);
  326. }
  327.  
  328. function tueAvertissement(num) {
  329. var divs = document.getElementsByName('avertissement');
  330. if(divs.length==0) { return; }
  331. for(var i=0 ; i<divs.length ; i++) {
  332. if(divs[i].num==num) {
  333. divs[i].parentNode.removeChild(divs[i]);
  334. return;
  335. }
  336. }
  337. }
  338.  
  339.  
  340. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  341.  
  342. function insertBefore(next,el) {
  343. next.parentNode.insertBefore(el,next);
  344. }
  345.  
  346. function appendTr(tbody,clas) {
  347. var tr = document.createElement('tr');
  348. if(clas) tr.className = clas;
  349. tbody.appendChild(tr);
  350. return tr;
  351. }
  352.  
  353. function insertTr(next,clas) {
  354. var tr = document.createElement('tr');
  355. if(clas) tr.className = clas;
  356. insertBefore(next,tr);
  357. return tr;
  358. }
  359.  
  360. function appendTd(tr) {
  361. var td = document.createElement('td');
  362. if(tr) tr.appendChild(td);
  363. return td;
  364. }
  365.  
  366. function insertTd(next) {
  367. var td = document.createElement('td');
  368. insertBefore(next,td);
  369. return td;
  370. }
  371.  
  372. function appendTdCenter(tr,colspan) {
  373. var td = appendTd(tr);
  374. td.align = 'center'; // WARNING - Obsolete
  375. if(colspan) td.colSpan = colspan;
  376. return td;
  377. }
  378.  
  379. function insertTdElement(next,el) {
  380. var td = insertTd(next);
  381. if(el) td.appendChild(el);
  382. return td;
  383. }
  384.  
  385. function appendA(paren,href,cssClass,text) {
  386. var a = document.createElement('a');
  387. if (href) a.href = href;
  388. if (cssClass) a.className = cssClass;
  389. if (text) a.appendChild(document.createTextNode(text));
  390. paren.appendChild(a);
  391. }
  392.  
  393. function appendText(paren,text,bold) {
  394. if(bold) {
  395. var b = document.createElement('b');
  396. b.appendChild(document.createTextNode(text));
  397. paren.appendChild(b);
  398. }
  399. else
  400. paren.appendChild(document.createTextNode(text));
  401. }
  402.  
  403. function insertText(next,text,bold) {
  404. if(bold) {
  405. var b = document.createElement('b');
  406. appendText(b,text);
  407. insertBefore(next,b);
  408. }
  409. else
  410. insertBefore(next,document.createTextNode(text));
  411. }
  412.  
  413. function appendTdText(tr,text,bold) {
  414. var td = appendTd(tr);
  415. appendText(td,text,bold);
  416. return td;
  417. }
  418.  
  419. function insertTdText(next,text,bold) {
  420. var td = insertTd(next);
  421. appendText(td,text,bold);
  422. return td;
  423. }
  424.  
  425. function appendBr(paren) {
  426. paren.appendChild(document.createElement('br'));
  427. }
  428.  
  429. function insertBr(next) {
  430. insertBefore(next,document.createElement('br'));
  431. }
  432.  
  433. function appendLI(ul,text) {
  434. // uniquement utilisé dans les options (crédits)
  435. var li = document.createElement('li');
  436. appendText(li,text);
  437. ul.appendChild(li);
  438. return li;
  439. }
  440.  
  441. function appendTextbox(paren,type,nam,size,maxlength,value) {
  442. var input = document.createElement('input');
  443. input.className = 'TextboxV2';
  444. input.type = type;
  445. input.name = nam;
  446. input.id = nam;
  447. input.size = size;
  448. input.maxLength = maxlength;
  449. if(value) input.value = value;
  450. paren.appendChild(input);
  451. return input;
  452. }
  453.  
  454. function appendCheckBox(paren,nam,checked,onClick) {
  455. var input = document.createElement('input');
  456. input.type = 'checkbox';
  457. input.name = nam;
  458. input.id = nam;
  459. if(checked) input.checked = true;
  460. if(onClick) input.onclick = onClick;
  461. paren.appendChild(input);
  462. return input;
  463. }
  464.  
  465. function appendNobr(paren,id,delgg,text) {
  466. var nobr = document.createElement('nobr');
  467. appendCheckBox(nobr,id,null,delgg);
  468. appendText(nobr,text);
  469. paren.appendChild(nobr);
  470. appendText(paren,' ');
  471. return nobr;
  472. }
  473.  
  474. function appendCheckBoxSpan(paren,id,onClick,text) {
  475. var span = document.createElement('span');
  476. span.style.whiteSpace = 'nowrap';
  477. appendCheckBox(span,id,false,onClick);
  478. appendText(span,text);
  479. paren.appendChild(span);
  480. appendText(paren,' ');
  481. return span;
  482. }
  483.  
  484. function appendOption(select,value,text) {
  485. var option = document.createElement('option');
  486. option.value = value;
  487. appendText(option,text);
  488. select.appendChild(option);
  489. return option;
  490. }
  491.  
  492. function appendHidden(form,nam,value) {
  493. var input = document.createElement('input');
  494. input.type = 'hidden';
  495. input.name = nam;
  496. input.id = nam;
  497. input.value = value;
  498. form.appendChild(input);
  499. }
  500.  
  501. function appendButton(paren,value,onClick) {
  502. var input = document.createElement('input');
  503. input.type = 'button';
  504. input.className = 'mh_form_submit';
  505. input.value = value;
  506. input.onmouseover = function(){this.style.cursor='pointer';};
  507. if(onClick) input.onclick = onClick;
  508. paren.appendChild(input);
  509. return input;
  510. }
  511.  
  512. function insertButton(next,value,onClick) {
  513. var input = document.createElement('input');
  514. input.type = 'button';
  515. input.className = 'mh_form_submit';
  516. input.value = value;
  517. input.onmouseover = function(){this.style.cursor='pointer';};
  518. input.onclick = onClick;
  519. insertBefore(next,input);
  520. return input;
  521. }
  522.  
  523. function appendSubmit(paren,value,onClick) {
  524. var input = document.createElement('input');
  525. input.type = 'submit';
  526. input.className = 'mh_form_submit';
  527. input.value = value;
  528. input.onmouseover = function(){this.style.cursor='pointer';};
  529. if(onClick) input.onclick = onClick;
  530. paren.appendChild(input);
  531. return input;
  532. }
  533.  
  534. function createImage(url,title) {
  535. var img = document.createElement('img');
  536. img.src = url;
  537. img.title = title;
  538. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  539. return img;
  540. }
  541.  
  542. function createAltImage(url,alt,title) {
  543. var img = document.createElement('img');
  544. img.src = url;
  545. img.alt = alt;
  546. img.title = title;
  547. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  548. return img;
  549. }
  550.  
  551. function createImageSpan(url,alt,title,text,bold) {
  552. var span = document.createElement('span');
  553. span.title = title;
  554. var img = document.createElement('img');
  555. img.src = url;
  556. img.alt = alt;
  557. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  558. span.appendChild(img);
  559. appendText(span,text,bold);
  560. return span;
  561. }
  562.  
  563. function createCase(titre,table,width) {
  564. if(!width) width=120;
  565. var tr = appendTr(table,'mh_tdpage');
  566. var td = appendTdText(tr,titre,true);
  567. td.className = 'mh_tdtitre';
  568. td.width = width;
  569. td = appendTdText(tr,'');
  570. td.className = 'mh_tdpage';
  571. return td;
  572. }
  573.  
  574. function getMyID(e) {
  575. var parent = e.parentNode;
  576. for(var i=0 ; i<parent.childNodes.length ; i++) {
  577. if(e==parent.childNodes[i])
  578. return i;
  579. }
  580. return -1;
  581. }
  582.  
  583. function insertAfter(elt,newElt) {
  584. var id = getMyID(elt);
  585. if(id==-1) return;
  586. if(id<elt.parentNode.childNodes.length-1)
  587. insertBefore(elt.nextSibling,newElt);
  588. else
  589. elt.parentNode.appendChild(newElt);
  590. }
  591.  
  592.  
  593. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  594.  
  595. function aff(nb) {
  596. return (nb>=0) ? '+'+nb : nb;
  597. }
  598.  
  599. function getNumber(str) {
  600. var nbr = str.match(/\d+/);
  601. return nbr ? Number(nbr[0]) : Number.NaN;
  602. }
  603.  
  604. function getNumbers(str) {
  605. var nbrs = str.match(/-?\d+/g);
  606. if (!nbrs) return [];
  607. for(var i=0 ; i<nbrs.length ; i++)
  608. nbrs[i] = Number(nbrs[i]);
  609. return nbrs;
  610. }
  611.  
  612. function trim(str) {
  613. return str.replace(/(^\s*)|(\s*$)/g,'');
  614. }
  615.  
  616. String.prototype.trim = function() {
  617. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  618. }
  619.  
  620. function epure(texte) {
  621. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  622. .replace(/[ç]/g,'c')
  623. .replace(/[éêèë]/g,'e')
  624. .replace(/[ïî]/g,'i')
  625. .replace(/[ôöõ]/g,'o')
  626. .replace(/[ùûü]/g,'u');
  627. }
  628.  
  629. String.prototype.epure = function () {
  630. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  631. .replace(/[ç]/g,'c')
  632. .replace(/[éêèë]/g,'e')
  633. .replace(/[ïî]/g,'i')
  634. .replace(/[ôöõ]/g,'o')
  635. .replace(/[ùûü]/g,'u');
  636. }
  637.  
  638. function bbcode(texte) {
  639. return texte.replace(/&/g,'&amp;')
  640. .replace(/"/g,'&quot;')
  641. .replace(/</g,'&lt;')
  642. .replace(/>/g,'&gt;')
  643. .replace(/'/g,'&#146;')
  644. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  645. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  646. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  647. }
  648.  
  649.  
  650. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  651.  
  652. function addZero(i) {
  653. return (i<10) ? '0'+i : i;
  654. }
  655.  
  656. function DateToString(date) {
  657. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  658. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  659. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  660. }
  661.  
  662. function StringToDate(str) {
  663. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  664. }
  665.  
  666. // fonctionne aussi avec datetime
  667. function SQLDateToFrench(str) {
  668. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  669. }
  670.  
  671. // ... et ajoute un "à" du plus bel effet
  672. function SQLDateToFrenchTime(str) {
  673. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  674. }
  675.  
  676. // SQLDate vers objet date Javascript
  677. function SQLDateToObject(str) {
  678. var t = str.split(/[- :]/);
  679. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  680. }
  681.  
  682. var mz_ie = (window.attachEvent)? true:false;
  683. if ("function" !== typeof addEvent) {
  684. if (mz_ie) {
  685. function addEvent(obj, typ, fn, sens) {
  686. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  687. obj["e"+typ+fn]( window.event );
  688. }
  689. obj.attachEvent("on"+typ, obj[typ+fn] );
  690. }
  691. }
  692. else {
  693. function addEvent(obj, typ, fn, sens) {
  694. obj.addEventListener(typ, fn, sens);
  695. }
  696. }
  697. }
  698.  
  699. // mise en commun du dessin des cartes (récupéré de Trajet_des_gowaps de feldspath et Vapulabehemot)
  700. function declare_css_carte_hall() {
  701. if(haut.getElementById("css_gow")) return;
  702. 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; }";
  703.  
  704. var node = document.createElement("style");
  705. node.type = "text/css";
  706. node.id = "css_gow";
  707. node.appendChild(document.createTextNode(css));
  708. document.getElementsByTagName("head")[0].appendChild(node);
  709. }
  710.  
  711. function ini_canvas_carte_hall() {
  712. var trajet = document.createElement("div");
  713. trajet.id = "carte_trajet";
  714.  
  715. var dessin = creer_canvas("trou");
  716. var dessin = document.createElement("canvas");
  717. dessin.id = ref;
  718. dessin.className = "mh_tdpage";
  719. trajet.appendChild(dessin);
  720. trajet.appendChild(creer_canvas("trajet"));
  721. trajet.appendChild(creer_canvas("danger"));
  722.  
  723. var dessin = creer_canvas("surligne");
  724. addEvent(dessin, "click", action_trajet, true);
  725. addEvent(dessin, "mousedown", start_v, true);
  726. addEvent(dessin, "mousemove", afficher_position, true);
  727. addEvent(dessin, "mouseout", function() { cacher_bulle(true) }, true);
  728. addEvent(dessin, "mouseover", function() { cacher_bulle(false) }, true);
  729. trajet.appendChild(dessin);
  730.  
  731. trajet.appendChild(creer_glissiere("gow", zoom));
  732.  
  733. var parp = document.getElementsByTagName('p');
  734. parp[parp.length-1].insertBefore(trajet,parp[parp.length-1].firstChild);
  735. }
  736.  
  737. /**********************
  738. * glissière en mode objet
  739. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  740. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  741. *
  742. * Usage:
  743. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  744. * ref : utilisé pour diversifier les IDs HTML
  745. * labelHTML : le label qui apparaît davant la glissière (peut contenir des balises HTML)
  746. * target : peut être de 3 types
  747. * - élément HTML : l'élément HTML à zoomer
  748. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  749. * - function : callback quand le curseur bouge
  750. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  751. * dans le mode dynamique, la callback est appelée sur mouseMove
  752. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  753. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  754. * autres méthodes
  755. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  756. **********************/
  757.  
  758. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  759. try {
  760. var mouseDown = false;
  761. var div_gliss = document.createElement("div"); // la DIV mère
  762. div_gliss.id = "MZ_gliss_"+ref;
  763. var div_label = document.createElement("div"); // le label
  764. div_label.innerHTML = labelHTML;
  765. div_gliss.appendChild(div_label);
  766. div_gliss.className = "choix_zoom";
  767. var dessin = document.createElement("canvas"); // le dessin lui-même
  768. dessin.id = "MZ_gliss_dessin_"+ref;
  769. dessin.width = 104;
  770. dessin.height = 12;
  771. div_gliss.appendChild(dessin);
  772. var pourcent = document.createElement("span"); // le pourcentage
  773. pourcent.id = "MZ_gliss_pourcent_"+ref;
  774. var pourcent_text = document.createTextNode('');
  775. pourcent.appendChild(pourcent_text);
  776. div_gliss.appendChild(pourcent);
  777.  
  778. var bulle_pourcent = document.createElement("div"); // la bulle
  779. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  780. bulle_pourcent.style.display = 'block';
  781. bulle_pourcent.style.visibility = 'hidden';
  782. bulle_pourcent.style.position = 'absolute';
  783. bulle_pourcent.style.zIndex = 3500;
  784. bulle_pourcent.style.border = '1px solid #a1927f';
  785. var bulle_pourcent_text = document.createTextNode('');
  786. bulle_pourcent.appendChild(bulle_pourcent_text);
  787. document.body.appendChild(bulle_pourcent);
  788.  
  789. this.getElt = function() {return div_gliss;};
  790.  
  791. ////////////////////////////////////
  792. // dessine et redessine le curseur
  793. ////////////////////////////////////
  794. var dessine_glissiere = function(val) {
  795. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  796. var ctx = dessin.getContext('2d');
  797. ctx.clearRect(0, 0,104, 12);
  798. ctx.fillStyle = "rgb(0,0,0)";
  799. ctx.fillRect(0,0,2,12);
  800. ctx.fillRect(102,0,2,12);
  801. ctx.fillRect(0,5,104,2);
  802.  
  803. ctx.fillStyle = "rgb(80,80,80)";
  804. ctx.fillRect(pos_0_100,0,5,12);
  805. ctx.fillStyle = "rgb(200,200,200)";
  806. ctx.fillRect(pos_0_100+1,1,3,10);
  807. pourcent_text.nodeValue = val+'%';
  808. };
  809.  
  810. ////////////////////////////////////
  811. // action qur mousedown et mousemove
  812. // stocker la nouvelle valeur
  813. // redessiner
  814. // afficher la nouvelle valeur
  815. // action selon ce qui a été demandé
  816. ////////////////////////////////////
  817. var doCallback_glissiere = function (evt) {
  818. try {
  819. if (evt.type === 'mousedown') mouseDown = true;
  820. if (evt.offsetX) {
  821. var xsouris = evt.offsetX;
  822. var xpos = evt.clientX;
  823. var ypos = evt.clientY + document.body.scrollTop;
  824. }
  825. else {
  826. var xsouris = evt.layerX;
  827. var xpos = evt.pageX;
  828. var ypos = evt.pageY;
  829. }
  830. var val = Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin));
  831. // afficher la nouvelle valeur dans la bulle
  832. bulle_pourcent_text.nodeValue = val + '%';
  833. bulle_pourcent.style.top = (ypos+3)+'px';
  834. bulle_pourcent.style.left = (xpos+16)+'px';
  835. if (evt.buttons === undefined) {
  836. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  837. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  838. } else {
  839. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  840. }
  841. // stocker la nouvelle valeur
  842. MY_setValue("MZ_glissiere_" + ref, val);
  843. // redessiner la glissière avec le curseur où il faut
  844. dessine_glissiere(val);
  845. // action selon ce qui a été demandé
  846. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  847. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  848. if (typeof paramTarget === 'object') {
  849. var elt = paramTarget;
  850. } else if (typeof paramTarget === 'string') {
  851. var elt = document.getElementById(paramTarget);
  852. } else if (typeof paramTarget === 'function') {
  853. paramTarget(val);
  854. return;
  855. }
  856. // à faire : zoom de l'elt
  857. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  858. };
  859.  
  860. ////////////////////////////////////
  861. // event mousedown et mousemove : redessiner et callback
  862. ////////////////////////////////////
  863. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  864. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  865. ////////////////////////////////////
  866. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  867. ////////////////////////////////////
  868. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  869. ////////////////////////////////////
  870. // event mouseout & mouseover : afficher/cacher la bulle
  871. ////////////////////////////////////
  872. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  873. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  874.  
  875. ////////////////////////////////////
  876. // dessiner la première fois
  877. ////////////////////////////////////
  878. var val_init = MY_getValue("MZ_glissiere_" + ref);
  879. if (val_init === undefined) val_init = valDef;
  880. dessine_glissiere(val_init);
  881. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  882. }
  883.  
  884.  
  885. /**********************************************************
  886. **** Fin de zone à déplacer dans une bibli commune ********
  887. **********************************************************/
  888.  
  889. /* DEBUG: NETTOYAGE TAGS */
  890. if(MY_getValue(numTroll+'.TAGSURL')) {
  891. MY_removeValue(numTroll+'.TAGSURL');
  892. }
  893.  
  894. // Alerte si mode dev
  895. if (isDEV) {
  896. var divpopup = document.createElement('div');
  897. divpopup.id = 'divDEV';
  898. divpopup.style =
  899. 'position: fixed;'+
  900. 'border: 15px solid red;'+
  901. 'top: 10px;right: 10px;'+
  902. 'background-color: white;'+
  903. 'color: black;'+
  904. 'font-size: large;'+
  905. 'padding: 5px'+
  906. 'z-index: 200;';
  907. appendText(divpopup, '[MZ] Mode DEV');
  908. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  909. document.body.appendChild(divpopup);
  910. }
  911.  
  912. /*---------- regroupement des getPortee() ------------------------------------*/
  913. // issu des script profil et profil2
  914. function getPortee__Profil(param) {
  915. param = Math.max(0,Number(param));
  916. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  917. // ça devrait être floor, +10.25, -2.5
  918. }
  919.  
  920. // issu du script vue
  921. function getPortee__Vue(param) {
  922. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  923. }
  924.  
  925.  
  926. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  927.  
  928. function getPXKill(niv) {
  929. return Math.max(0,10+3*niv-2*nivTroll);
  930. }
  931.  
  932. function getPXDeath(niv) {
  933. return Math.max(0,10+3*nivTroll-2*niv);
  934. }
  935.  
  936. function analysePX(niv) {
  937. niv = niv+'';
  938. var i = niv.indexOf('+');
  939. if(i!=-1) // si niv = 'XX+' ??
  940. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  941. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  942. if(i!=-1) {
  943. var max = getPXKill(niv.slice(i+2));
  944. if(max==0)
  945. return ' --> <b>0</b> PX';
  946. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  947. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  948. }
  949. i = niv.indexOf('='); // ???
  950. if(i!=-1) {
  951. var max = getPXKill(niv.slice(i+1));
  952. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  953. }
  954. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  955. }
  956.  
  957. function analysePXTroll(niv) {
  958. var str = analysePX(niv);
  959. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  960. return str;
  961. }
  962.  
  963.  
  964. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  965. // Refonte totale du code de Zorya
  966.  
  967. // Elements à implémenter en dur dans MZ2.0
  968. var numQualite = {
  969. 'Très Mauvaise':1,
  970. 'Mauvaise':2,
  971. 'Moyenne':3,
  972. 'Bonne':4,
  973. 'Très Bonne':5
  974. };
  975.  
  976. var qualiteNum = [
  977. '_dummy_',
  978. 'Très Mauvaise',
  979. 'Mauvaise',
  980. 'Moyenne',
  981. 'Bonne',
  982. 'Très Bonne'
  983. ];
  984.  
  985. var nival = {
  986. 'Abishaii Bleu':19,
  987. 'Abishaii Noir':10,
  988. 'Abishaii Rouge':23,
  989. 'Abishaii Vert':15,
  990. 'Ame-en-peine':8,
  991. 'Amibe Geante':9,
  992. 'Anaconda des Catacombes':8,
  993. 'Ankheg':10,
  994. 'Anoploure Purpurin':36,
  995. 'Araignee Geante':2,
  996. 'Ashashin':35,
  997. 'Balrog':50,
  998. 'Banshee':16,
  999. 'Barghest':36,
  1000. 'Basilisk':11,
  1001. 'Behemoth':34,
  1002. 'Behir':14,
  1003. 'Beholder':50,
  1004. 'Boggart':3,
  1005. 'Bondin':9,
  1006. "Bouj'Dla Placide":37,
  1007. "Bouj'Dla":19,
  1008. 'Bulette':19,
  1009. 'Caillouteux':1,
  1010. 'Capitan':35,
  1011. 'Carnosaure':25,
  1012. 'Champi-Glouton':3,
  1013. 'Chauve-Souris Geante':4,
  1014. 'Cheval a Dents de Sabre':23,
  1015. 'Chevalier du Chaos':20,
  1016. 'Chimere':13,
  1017. 'Chonchon':24,
  1018. 'Coccicruelle':22,
  1019. 'Cockatrice':5,
  1020. 'Crasc Medius':17,
  1021. 'Crasc Maexus':25,
  1022. 'Crasc':10,
  1023. 'Croquemitaine':6,
  1024. 'Cube Gelatineux':32,
  1025. 'Daemonite':27,
  1026. 'Diablotin':5,
  1027. 'Dindon du Chaos':1,
  1028. 'Djinn':29,
  1029. 'Ectoplasme':18,
  1030. 'Effrit':27,
  1031. "Elementaire d'Air":23,
  1032. "Elementaire d'Eau":17,
  1033. 'Elementaire de Feu':21,
  1034. 'Elementaire de Terre':21,
  1035. 'Elementaire du Chaos':26,
  1036. 'Erinyes':7,
  1037. 'Esprit-Follet':16,
  1038. 'Essaim Craterien':30,
  1039. 'Essaim Sanguinaire':25,
  1040. 'Ettin':8,
  1041. 'Familier':1,
  1042. 'Fantome':24,
  1043. 'Feu Follet':20,
  1044. 'Flagelleur Mental':33,
  1045. 'Foudroyeur':38,
  1046. 'Fumeux':22,
  1047. 'Fungus Geant':9,
  1048. 'Fungus Violet':4,
  1049. 'Furgolin':10,
  1050. 'Gargouille':3,
  1051. 'Geant de Pierre':13,
  1052. 'Geant des Gouffres':22,
  1053. "Geck'oo Majestueux":40,
  1054. "Geck'oo":15,
  1055. 'Glouton':20,
  1056. 'Gnoll':5,
  1057. 'Gnu Domestique':1,
  1058. 'Gnu Sauvage':1,
  1059. 'Goblin':4,
  1060. 'Goblours':4,
  1061. "Golem d'Argile":15,
  1062. 'Golem de cuir':1,
  1063. 'Golem de Chair':8,
  1064. 'Golem de Fer':31,
  1065. 'Golem de mithril':1,
  1066. 'Golem de metal':1,
  1067. 'Golem de papier':1,
  1068. 'Golem de Pierre':23,
  1069. 'Gorgone':11,
  1070. 'Goule':4,
  1071. 'Gowap Apprivoise':1,
  1072. 'Gowap Sauvage':1,
  1073. 'Gremlins':3,
  1074. 'Gritche':39,
  1075. 'Grouilleux':4,
  1076. 'Grylle':31,
  1077. 'Harpie':4,
  1078. 'Hellrot':18,
  1079. 'Homme-Lezard':4,
  1080. 'Hurleur':8,
  1081. 'Hydre':50,
  1082. 'Incube':13,
  1083. 'Kobold':2,
  1084. 'Labeilleux':26,
  1085. 'Lezard Geant':5,
  1086. 'Liche':50,
  1087. 'Limace Geante':10,
  1088. 'Loup-Garou':8,
  1089. 'Lutin':4,
  1090. 'Mante Fulcreuse':30,
  1091. 'Manticore':9,
  1092. 'Marilith':33,
  1093. 'Meduse':6,
  1094. 'Megacephale':38,
  1095. 'Mille-Pattes Geant':14,
  1096. 'Mimique':6,
  1097. 'Minotaure':7,
  1098. 'Molosse Satanique':8,
  1099. 'Momie':4,
  1100. 'Monstre Rouilleur':3,
  1101. "Mouch'oo Domestique":14,
  1102. "Mouch'oo Majestueux Sauvage":33,
  1103. "Mouch'oo Sauvage":14,
  1104. 'Na-Haniym-Heee':0,
  1105. 'Necrochore':37,
  1106. 'Necromant':39,
  1107. 'Necrophage':8,
  1108. 'Naga':10,
  1109. 'Nuee de Vermine':13,
  1110. "Nuage d'Insectes":7,
  1111. 'Ogre':7,
  1112. 'Ombre de Roches':13,
  1113. 'Ombre':2,
  1114. 'Orque':3,
  1115. 'Ours-Garou':18,
  1116. 'Palefroi Infernal':29,
  1117. 'Phoenix':32,
  1118. 'Pititabeille':0,
  1119. 'Plante Carnivore':4,
  1120. 'Pseudo-Dragon':5,
  1121. 'Rat Geant':2,
  1122. 'Rat-Garou':3,
  1123. 'Rocketeux':5,
  1124. 'Sagouin':3,
  1125. 'Scarabee Geant':4,
  1126. 'Scorpion Geant':10,
  1127. 'Shai':28,
  1128. 'Sirene':8,
  1129. 'Slaad':5,
  1130. 'Sorciere':17,
  1131. 'Spectre':14,
  1132. 'Sphinx':30,
  1133. 'Squelette':1,
  1134. 'Strige':2,
  1135. 'Succube':13,
  1136. 'Tertre Errant':20,
  1137. 'Thri-kreen':10,
  1138. 'Tigre-Garou':12,
  1139. 'Titan':26,
  1140. 'Trancheur':35,
  1141. 'Tubercule Tueur':14,
  1142. 'Tutoki':4,
  1143. 'Vampire':29,
  1144. 'Ver Carnivore Geant':12,
  1145. 'Ver Carnivore':11,
  1146. 'Veskan Du Chaos':14,
  1147. 'Vouivre':33,
  1148. 'Worg':5,
  1149. 'Xorn':14,
  1150. 'Yeti':8,
  1151. 'Yuan-ti':15,
  1152. 'Zombie':2
  1153. }
  1154.  
  1155. var tabEM = {
  1156. //Monstre: [Compo exact, Sort, Position, Localisation]
  1157. // AA
  1158. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1159. // AE
  1160. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1161. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1162. // AdA
  1163. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1164. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1165. // AdE
  1166. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1167. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1168. // AdD
  1169. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1170. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1171. // BAM
  1172. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1173. // BuM
  1174. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1175. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1176. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1177. // Explo
  1178. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1179. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1180. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1181. // FP
  1182. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1183. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1184. // FA
  1185. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1186. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1187. // Glue
  1188. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1189. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1190. // GdS
  1191. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1192. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1193. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1194. // Invi
  1195. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1196. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1197. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1198. // Lévitation
  1199. // ???
  1200. // PréM :
  1201. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1202. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1203. // Proj
  1204. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1205. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1206. // PuM :
  1207. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1208. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1209. // Sacro
  1210. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1211. // Télék
  1212. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1213. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1214. // TP
  1215. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1216. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1217. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1218. // VA
  1219. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1220. // VL
  1221. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1222. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1223. // VlC
  1224. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1225. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1226. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1227. // VT
  1228. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1229. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1230. // Variables
  1231. 'Rat':["d'un"],
  1232. 'Rat Géant':["d'un"],
  1233. 'Dindon':["d'un"],
  1234. 'Goblin':["d'un"],
  1235. 'Limace':["d'une"],
  1236. 'Limace Géante':["d'une"],
  1237. 'Ver':["d'un"],
  1238. 'Ver Carnivore':["d'un"],
  1239. 'Ver Carnivore Géant':["d'un"],
  1240. 'Fungus':["d'un"],
  1241. 'Vouivre':["d'une"],
  1242. 'Gnu':["d'un"],
  1243. 'Scarabée':["d'un"]
  1244. };
  1245.  
  1246. var mundiChampi = {
  1247. 'Préscientus Reguis':'du Phoenix',
  1248. 'Amanite Trolloïde':'de la Mouche',
  1249. 'Girolle Sanglante':'du Dindon',
  1250. 'Horreur Des Prés':'du Gobelin',
  1251. 'Bolet Péteur':'du Démon',
  1252. 'Pied Jaune':'de la Limace',
  1253. 'Agaric Sous-Terrain':'du Rat',
  1254. 'Suinte Cadavre':"de l'Hydre",
  1255. 'Cèpe Lumineux':'du Ver',
  1256. 'Fungus Rampant':'du Fungus',
  1257. 'Nez Noir':'de la Vouivre',
  1258. 'Pleurote Pleureuse':'du Gnu',
  1259. 'Phytomassus Xilénique':'du Scarabée'
  1260. };
  1261.  
  1262. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1263. appendText(node,' ');
  1264. var urlImg = URL_MZimg
  1265. +'Competences/melangeMagique.png';
  1266. var text = ' [-'+(niv+effetQ)+' %]';
  1267. var str = '';
  1268. switch(mob[0]) {
  1269. case 'A':
  1270. case 'E':
  1271. case 'I':
  1272. case 'O':
  1273. case 'U':
  1274. str = "Compo d'";
  1275. break;
  1276. default:
  1277. str = 'Compo de ';
  1278. }
  1279. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1280. var span = createImageSpan(urlImg,'MM:',title,text);
  1281. node.appendChild(span);
  1282. }
  1283. function addInfoEM(node,mob,compo,qualite,localisation) {
  1284. if(!tabEM[mob]) return;
  1285. var title = 'Composant variable', texte = 'Variable';
  1286. var bold = false;
  1287. if(tabEM[mob].length>1) {
  1288. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1289. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1290. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1291. if(pc<-20) return;
  1292. if(pc>=0) bold = true;
  1293. texte = aff(pc)+'%';
  1294. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1295. }
  1296. var urlImg = URL_MZimg
  1297. +'Competences/ecritureMagique.png';
  1298. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1299. node.appendChild(span);
  1300. }
  1301.  
  1302. function insererInfosEM(tbody) {
  1303. // lancé par equip, equipgowap
  1304. var trCompos = document.evaluate(
  1305. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1306. tbody,null,7,null);
  1307. var strCompos = '';
  1308. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1309. var node = trCompos.snapshotItem(i).childNodes[7];
  1310. var str = node.firstChild.textContent;
  1311. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1312. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1313. // Si non-EM on stoppe le traitement
  1314. if(!tabEM[mob]) continue;
  1315. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1316. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1317. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1318. addInfoEM(node,mob,compo,qualite,localisation);
  1319. }
  1320. }
  1321.  
  1322. function getQualite(qualite) {
  1323. var nb = numQualite[qualite];
  1324. return nb ? nb-1 : -1;
  1325. }
  1326.  
  1327. function getEM(nom) {
  1328. if(nom.indexOf('[')!=-1)
  1329. nom = trim(nom.substring(0,nom.indexOf('[')));
  1330. if(tabEM[nom]) return nom;
  1331. return '';
  1332. }
  1333.  
  1334. // DEBUG ex-fonction composantEM
  1335. function compoMobEM(mob) {
  1336. if(!tabEM[mob]) return '';
  1337. if(tabEM[mob].length==1)
  1338. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1339. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1340. +") pour l'écriture de "+tabEM[mob][1];
  1341. }
  1342.  
  1343. // DEBUG ex-fonction compoEM
  1344. function titreCompoEM(mob,compo,localisation,qualite) {
  1345. if(!tabEM[mob]) return '';
  1346. if(tabEM[mob].length==1) return 'Composant variable';
  1347. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1348. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1349. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1350. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1351. return '';
  1352. }
  1353.  
  1354. // DEBUG - rétrocompatibilité
  1355. function compoEM(mob) {
  1356. // appelé dans libs, vue
  1357. return compoMobEM(mob);
  1358. }
  1359. function composantEM(mob,compo,localisation,qualite) {
  1360. // appelé dans libs, tancompo
  1361. return titreCompoEM(mob,compo,localisation,qualite);
  1362. }
  1363. //
  1364.  
  1365.  
  1366. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1367.  
  1368. arrayTalents = {
  1369. /* Compétences */
  1370. 'Acceleration du Metabolisme':'AM',
  1371. 'Attaque Precise':'AP',
  1372. 'Balayage':'Balayage',
  1373. //'Balluchonnage':'Ballu',
  1374. 'Baroufle':'Baroufle',
  1375. 'Bidouille':'Bidouille',
  1376. 'Botte Secrete':'BS',
  1377. 'Camouflage':'Camou',
  1378. 'Charger':'Charger',
  1379. 'Connaissance des Monstres':'CdM',
  1380. 'Construire un Piege':'Piege',
  1381. 'Piege a Feu':'PiegeFeu',
  1382. 'Piege a Glue':'PiegeGlue',
  1383. 'Contre-Attaquer':'CA',
  1384. 'Coup de Butoir':'CdB',
  1385. 'Course':'Course',
  1386. 'Deplacement Eclair':'DE',
  1387. 'Dressage':'Dressage',
  1388. 'Ecriture Magique':'EM',
  1389. 'Frenesie':'Frenesie',
  1390. 'Golemologie':'Golemo',
  1391. 'Golem de cuir':'GolemCuir',
  1392. 'Golem de metal':'GolemMetal',
  1393. 'Golem de mithril':'GolemMithril',
  1394. 'Golem de papier':'GolemPapier',
  1395. 'Grattage':'Grattage',
  1396. 'Hurlement Effrayant':'HE',
  1397. 'Identification des Champignons':'IdC',
  1398. 'Insultes':'Insultes',
  1399. 'Lancer de Potions':'LdP',
  1400. 'Marquage':'Marquage',
  1401. 'Melange Magique':'Melange',
  1402. 'Miner':'Miner',
  1403. 'Necromancie':'Necro',
  1404. 'Painthure de Guerre':'PG',
  1405. 'Parer':'Parer',
  1406. 'Pistage':'Pistage',
  1407. 'Planter un Champignon':'PuC',
  1408. 'Regeneration Accrue':'RA',
  1409. 'Reparation':'Reparation',
  1410. 'Retraite':'Retraite',
  1411. 'Rotobaffe':'RB',
  1412. 'Shamaner':'Shamaner',
  1413. "S'interposer":'SInterposer',
  1414. 'Tailler':'Tailler',
  1415. //'Vol':'Vol',
  1416. /* Sortilèges */
  1417. 'Analyse Anatomique':'AA',
  1418. 'Armure Etheree':'AE',
  1419. 'Augmentation de l´Attaque':'AdA',
  1420. 'Augmentation de l´Esquive':'AdE',
  1421. 'Augmentation des Degats':'AdD',
  1422. 'Bulle Anti-Magie':'BAM',
  1423. 'Bulle Magique':'BuM',
  1424. 'Explosion':'Explo',
  1425. 'Faiblesse Passagere':'FP',
  1426. 'Flash Aveuglant':'FA',
  1427. 'Glue':'Glue',
  1428. 'Griffe du Sorcier':'GdS',
  1429. 'Hypnotisme':'Hypno',
  1430. 'Identification des tresors':'IdT',
  1431. 'Invisibilite':'Invi',
  1432. 'Levitation':'Levitation',
  1433. 'Precision Magique':'PreM',
  1434. 'Projectile Magique':'Projo',
  1435. 'Projection':'Proj',
  1436. 'Puissance Magique':'PuM',
  1437. 'Rafale Psychique':'Rafale',
  1438. 'Sacrifice':'Sacro',
  1439. 'Siphon des Ames':'Siphon',
  1440. 'Telekinesie':'Telek',
  1441. 'Teleportation':'TP',
  1442. 'Vampirisme':'Vampi',
  1443. 'Vision Accrue':'VA',
  1444. 'Vision lointaine':'VL',
  1445. 'Voir le Cache':'VlC',
  1446. 'Vue Troublee':'VT'
  1447. //'':''
  1448. }
  1449.  
  1450. // DEBUG - Pour rétrocompatibilité
  1451. function getSortComp(nom,niveau) {
  1452. return getTalent(nom,niveau);
  1453. }
  1454. //
  1455.  
  1456. function getTalent(nom,niveau) {
  1457. var nomEnBase = arrayTalents[epure(nom)];
  1458. if(!nomEnBase) return 0;
  1459. if(!niveau) var niveau = '';
  1460. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1461. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1462. return 0;
  1463. }
  1464.  
  1465. function removeAllTalents() {
  1466. for(var talent in arrayTalents) {
  1467. var nomEnBase = arrayTalents[talent];
  1468. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1469. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1470. continue;
  1471. }
  1472. var niveau = 1;
  1473. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1474. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1475. niveau++;
  1476. }
  1477. }
  1478. }
  1479.  
  1480. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1481. var att = MY_getValue(numTroll+'.caracs.attaque');
  1482. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1483. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1484. var mm = MY_getValue(numTroll+'.caracs.mm');
  1485. var deg = MY_getValue(numTroll+'.caracs.degats');
  1486. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1487. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1488. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1489. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1490. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1491. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1492. return false;
  1493. return true;
  1494. }
  1495.  
  1496.  
  1497. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1498.  
  1499. function getPVsRestants(pv,bless,vue) {
  1500. bless = Number(bless.match(/\d+/)[0]);
  1501. if(bless==0) return null;
  1502. var pvminmax = pv.match(/\d+/g);
  1503. if(bless==95) {
  1504. var pvb = 1;
  1505. var pvh = Math.floor( pvminmax[1]/20 );
  1506. }
  1507. else if(bless==5) {
  1508. var pvb = Math.floor( pvminmax[0]*19/20 );
  1509. var pvh = pvminmax[1];
  1510. }
  1511. else {
  1512. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1513. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1514. }
  1515. return vue ? ' ('+pvb+'-'+pvh+')' :
  1516. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1517. }
  1518.  
  1519. function insertButtonCdm(nextName,onClick,texte) {
  1520. if(texte==null) texte = 'Participer au bestiaire';
  1521. var nextNode = document.getElementsByName(nextName)[0];
  1522.  
  1523. var espace = document.createTextNode('\t');
  1524. insertBefore(nextNode,espace);
  1525.  
  1526. var button = document.createElement('input');
  1527. button.type = 'button';
  1528. button.className = 'mh_form_submit';
  1529. button.value = texte;
  1530. button.onmouseover = function(){this.style.cursor='pointer';};
  1531. if(onClick) button.onclick = onClick;
  1532. insertBefore(espace,button);
  1533. return button;
  1534. }
  1535.  
  1536. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1537. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1538. 'Capacité spéciale','Résistance Magique','Autres'];
  1539.  
  1540. function createImageTactique(url,id,nom) {
  1541. var img = document.createElement('img');
  1542. img.src = url;
  1543. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1544. img.id = id;
  1545. img.nom = nom;
  1546. img.onmouseover = showPopupTactique;
  1547. img.onmouseout = hidePopup;
  1548. return img;
  1549. }
  1550.  
  1551. function createCDMTable(id,nom,donneesMonstre) {
  1552. try {
  1553. var urlImg = URL_MZimg;
  1554. var table = document.createElement('table');
  1555. var profilActif = isProfilActif();
  1556. table.className = 'mh_tdborder';
  1557. table.border = 0;
  1558. table.cellSpacing = 1;
  1559. table.cellPadding = 4;
  1560. var thead = document.createElement('thead');
  1561. var tr = appendTr(thead,'mh_tdtitre');
  1562. var td = appendTdText(tr,
  1563. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1564. true
  1565. );
  1566. td.colSpan = 2;
  1567. table.appendChild(thead);
  1568. var tbody = document.createElement('tbody');
  1569. table.appendChild(tbody);
  1570. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1571. createCase(listeTitres[i],tbody,80);
  1572. }
  1573. var TypeMonstre = getEM(nom);
  1574. var infosCompo='';
  1575. if(TypeMonstre!='') {
  1576. infosCompo = compoEM(TypeMonstre);
  1577. }
  1578. var nodes = tbody.childNodes;
  1579. nodes[0].childNodes[1].innerHTML =
  1580. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1581. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1582. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1583. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1584. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1585. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1586. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1587. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1588. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1589. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1590. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1591. td = createCase(listeTitres[10],tbody);
  1592. td.innerHTML = bbcode(donneesMonstre[10]);
  1593. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1594. td.appendChild(document.createTextNode(" "));
  1595. if(donneesMonstre[16] == "De zone")
  1596. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1597. else if(donneesMonstre[16] == "Automatique")
  1598. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1599. else if(donneesMonstre[16] == "Au toucher")
  1600. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1601. }
  1602. }
  1603. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1604. {
  1605. td = createCase(listeTitres[11],tbody);
  1606. td.innerHTML = bbcode(donneesMonstre[9]);
  1607. // seuil de résistance du monstre
  1608. var lb = td.getElementsByTagName('b');
  1609. if(lb.length == 1) {
  1610. var mrm = lb[0].firstChild.nodeValue * 1;
  1611. var v = (mrm / mmTroll);
  1612. lb[0].firstChild.nodeValue += " ("
  1613. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1614. }
  1615. }
  1616. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1617. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1618. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1619. {
  1620. td = createCase(listeTitres[12],tbody);
  1621. if(donneesMonstre[12]==1)
  1622. {
  1623. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1624. }
  1625. if(donneesMonstre[13]==1)
  1626. {
  1627. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1628. }
  1629. else if(donneesMonstre[13]==0)
  1630. {
  1631. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1632. }
  1633. if(donneesMonstre[14]==1)
  1634. {
  1635. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1636. }
  1637. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1638. {
  1639. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1640. }
  1641. else if(donneesMonstre[14]>6)
  1642. {
  1643. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1644. }
  1645. if(donneesMonstre[15]=="Lente")
  1646. {
  1647. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1648. }
  1649. else if(donneesMonstre[15]=="Normale")
  1650. {
  1651. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1652. }
  1653. else if(donneesMonstre[15]=="Rapide")
  1654. {
  1655. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1656. }
  1657. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1658. {
  1659. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1660. }
  1661. if(infosCompo.length>0)
  1662. {
  1663. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1664. }
  1665. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1666. {
  1667. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1668. }
  1669. }
  1670. // pourcentage de blessure
  1671. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1672. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1673. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1674. if(pvs)
  1675. lb[0].firstChild.nodeValue += pvs;
  1676. }
  1677. return table;
  1678. }
  1679. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  1680. }
  1681.  
  1682.  
  1683. /*-[functions]------------ Gestion des enchantements -------------------------*/
  1684.  
  1685. var listeMonstreEnchantement = null,
  1686. listeEquipementEnchantement = null,
  1687. listeInfoEnchantement = null;
  1688.  
  1689. function computeCompoEnchantement()
  1690. {
  1691. listeMonstreEnchantement = new Array();
  1692. listeInfoEnchantement = new Array();
  1693. listeEquipementEnchantement = new Array();
  1694. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  1695. for(var i=0;i<liste.length;i++)
  1696. {
  1697. var idEquipement = liste[i]*1;
  1698. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  1699. continue;
  1700. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  1701. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  1702. var texteGlobal='';
  1703. for(var j=0;j<3;j++)
  1704. {
  1705. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  1706. listeMonstreEnchantement[infoComposant[2]] = 1;
  1707. var array = new Array();
  1708. array[0]=infoComposant[0].replace("Ril","Œil");
  1709. array[1]=infoComposant[1];
  1710. array[2]=infoComposant[2];
  1711. array[3]=getQualite(infoComposant[3]);
  1712. var texte = infoComposant[4].replace("Ril","Œil");
  1713. for(var k=5;k<infoComposant.length;k++)
  1714. {
  1715. texte += ";"+infoComposant[k].replace("Ril","Œil");
  1716. }
  1717. texteGlobal+=texte+'\n';
  1718. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1719. array[4]=texte;
  1720. listeInfoEnchantement.push(array);
  1721. }
  1722. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1723. listeEquipementEnchantement[idEquipement] = texteGlobal;
  1724. }
  1725. }
  1726.  
  1727. function isEnchant(nom) {
  1728. var monstreEnchant = '';
  1729. for(j in listeInfoEnchantement) {
  1730. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1731. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1732. monstreEnchant=monstre;
  1733. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  1734. }
  1735. }
  1736. return trim(monstreEnchant);
  1737. }
  1738.  
  1739. function getInfoEnchantementFromMonstre(nom)
  1740. {
  1741. try
  1742. {
  1743. if(!listeMonstreEnchantement)
  1744. {
  1745. computeCompoEnchantement();
  1746. }
  1747. var infosEnchant = '';
  1748. for(j in listeInfoEnchantement) {
  1749. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1750. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1751. if(infosEnchant=='')
  1752. infosEnchant=listeInfoEnchantement[j][4];
  1753. else
  1754. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  1755. }
  1756. }
  1757. return trim(infosEnchant);
  1758. }
  1759. catch(e)
  1760. {
  1761. window.alert(e);
  1762. }
  1763. }
  1764.  
  1765. function composantEnchant(Monstre,composant,localisation,qualite) {
  1766. var compo='';
  1767. for(var i=0; i<listeInfoEnchantement.length; i++) {
  1768. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  1769. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  1770. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  1771. listeInfoEnchantement[i][3]<=qualite
  1772. ) {
  1773. return listeInfoEnchantement[i][4];
  1774. }
  1775. }
  1776. return compo;
  1777. }
  1778.  
  1779. function insertEnchantInfos(tbody) {
  1780. try
  1781. {
  1782. if(!listeMonstreEnchantement)
  1783. computeCompoEnchantement();
  1784. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  1785. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1786. if(nodes.snapshotLength == 0)
  1787. return false;
  1788. var urlImg = URL_MZimg + 'enchant.png';
  1789. for(var i = 0; i < nodes.snapshotLength; i++) {
  1790. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  1791. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  1792. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  1793. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  1794. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  1795. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  1796. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  1797. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  1798. if(isEnchant(nomMonstre).length>0)
  1799. {
  1800. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  1801. if(infos.length>0)
  1802. {
  1803. if(link.parentNode == link.nextSibling.parentNode)
  1804. {
  1805. var tmp = link.nextSibling;
  1806. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  1807. }
  1808. else
  1809. {
  1810. link.parentNode.appendChild(createImage(urlImg,infos));
  1811. }
  1812. }
  1813. }
  1814. }
  1815. }
  1816. catch(e)
  1817. {
  1818. window.alert(e);
  1819. }
  1820. }
  1821.  
  1822. function computeEnchantementEquipement(fontionTexte,formateTexte)
  1823. {
  1824. try
  1825. {
  1826. if(!listeMonstreEnchantement)
  1827. computeCompoEnchantement();
  1828. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  1829. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1830. if(nodes.snapshotLength == 0)
  1831. return false;
  1832. var urlImg = URL_MZimg + 'enchant.png';
  1833. for(var i = 0; i < nodes.snapshotLength; i++)
  1834. {
  1835. var link = nodes.snapshotItem(i);
  1836. var idEquipement = link.getAttribute('href');
  1837. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  1838. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  1839. var nomEquipement = trim(link.firstChild.nodeValue);
  1840. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  1841. if(!enchanteur || enchanteur == '')
  1842. continue;
  1843. var infos = listeEquipementEnchantement[idEquipement];
  1844. infos=formateTexte(infos);
  1845. if(infos.length>0)
  1846. {
  1847. if(link.parentNode == link.nextSibling.parentNode)
  1848. {
  1849. var tmp = link.nextSibling;
  1850. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  1851. }
  1852. else
  1853. {
  1854. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  1855. }
  1856. }
  1857. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  1858. }
  1859. }
  1860. catch(e)
  1861. {
  1862. window.alert(e);
  1863. }
  1864. }
  1865.  
  1866. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  1867.  
  1868.  
  1869. // Les % de toucher
  1870. var c = new Array();
  1871.  
  1872. // coefficients binomiaux
  1873. function cnp(n,k)
  1874. {
  1875. if(c[n] != null && c[n][k] != null)
  1876. return c[n][k];
  1877. if(c[n] == null)
  1878. c[n] = new Array();
  1879. if(k==0)
  1880. {
  1881. c[n][k] = 1;
  1882. return 1;
  1883. }
  1884. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  1885. c[n][k] = result;
  1886. // Roule debug
  1887. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  1888. return result;
  1889. }
  1890.  
  1891. // by Dab, à comparer
  1892. function binom(n,p) {
  1893. if(p<0 || p>n) return 0;
  1894. if(c[n])
  1895. if(c[n][p]) return c[n][p];
  1896. else {
  1897. c[n]=[1];
  1898. c[n][n]=1;
  1899. if(p==0 || p==n) return 1;
  1900. }
  1901. if(2*p>n)
  1902. c[n][p]=binom(n,n-p);
  1903. else
  1904. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  1905. return c[n][p];
  1906. }
  1907.  
  1908. var coeff = new Array();
  1909.  
  1910. function coef(n,p)
  1911. {
  1912. if(n==0 && p==0)
  1913. return 1;
  1914. if(p>n*3.5)
  1915. p = 7*n-p
  1916. // roule désactive cache
  1917. if(coeff[n] != null && coeff[n][p] !=null)
  1918. return coeff[n][p];
  1919. if(coeff[n] == null)
  1920. coeff[n] = new Array();
  1921. var kmax = Math.floor((p-n)/6);
  1922. var x=0;
  1923. for(var k=0;k<=kmax;k++)
  1924. {
  1925. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  1926. }
  1927. coeff[n][p] = x;
  1928. // Roule debug
  1929. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  1930. return x;
  1931. }
  1932.  
  1933. function chanceEsquiveParfaite(a,d,ba,bd)
  1934. {
  1935. var win = 0;
  1936. var los = 0;
  1937. if(ba==null)
  1938. ba=0;
  1939. if(bd==null)
  1940. bd=0;
  1941. /* if(6*a+ba<2*(d+bd))
  1942. return 100;
  1943. if(a+ba>2*(6*d+bd))
  1944. return 0;*/
  1945. for(var ds=d;ds<=6*d;ds++)
  1946. {
  1947. var cd = coef(d,ds);
  1948. for(var as=a;as<=6*a;as++)
  1949. {
  1950. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  1951. win += cd * coef(a,as);
  1952. else
  1953. los += cd * coef(a,as);
  1954. }
  1955. }
  1956. // roule debug
  1957. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  1958. return Math.round(100*win/(win+los));
  1959. }
  1960.  
  1961. function chanceTouche(a,d,ba,bd)
  1962. {
  1963. var win = 0;
  1964. var los = 0;
  1965. if(ba==null)
  1966. ba=0;
  1967. if(bd==null)
  1968. bd=0;
  1969. if(a+ba>6*d+bd)
  1970. return 100;
  1971. if(6*a+ba<d+bd)
  1972. return 0;
  1973. for(var ds=d;ds<=6*d;ds++)
  1974. {
  1975. var cd = coef(d,ds);
  1976. for(var as=a;as<=6*a;as++)
  1977. {
  1978. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  1979. win += cd * coef(a,as);
  1980. else
  1981. los += cd * coef(a,as);
  1982. }
  1983. }
  1984. return Math.round(100*win/(win+los));
  1985. }
  1986.  
  1987. function chanceCritique(a,d,ba,bd)
  1988. {
  1989. var win = 0;
  1990. var los = 0;
  1991. if(ba==null)
  1992. ba=0;
  1993. if(bd==null)
  1994. bd=0;
  1995. if(a+ba>2*(6*d+bd))
  1996. return 100;
  1997. if(6*a+ba<2*(d+bd))
  1998. return 0;
  1999. for(var ds=d;ds<=6*d;ds++)
  2000. {
  2001. var cd = coef(d,ds);
  2002. for(var as=a;as<=6*a;as++)
  2003. {
  2004. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2005. win += cd * coef(a,as);
  2006. else
  2007. los += cd * coef(a,as);
  2008. }
  2009. }
  2010. return Math.round(100*win/(win+los));
  2011. }
  2012.  
  2013. /***********************************************
  2014. Analyse tactique
  2015. ***********************************************/
  2016.  
  2017. function getTexteAnalyse(modificateur,chiffre)
  2018. {
  2019. if(chiffre==0)
  2020. return chiffre;
  2021. return modificateur+chiffre;
  2022. }
  2023.  
  2024. function getAnalyseTactique(id,nom)
  2025. {
  2026. var donneesMonstre = listeCDM[id];
  2027. var needAutres=false;
  2028. var i;
  2029. if(donneesMonstre == null)
  2030. return;
  2031. var array = analyseTactique(donneesMonstre,nom);
  2032. if(array==null)
  2033. return "";
  2034. 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>";
  2035. for(i=0;i<array.length;i++)
  2036. {
  2037. if(array[i][1]==100 && i>0)
  2038. {
  2039. needAutres=true;
  2040. break;
  2041. }
  2042. if(i==1 && array[i][4]>0)
  2043. 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>";
  2044. else if(i==0)
  2045. 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>";
  2046. else
  2047. 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>";
  2048. }
  2049. if(needAutres)
  2050. {
  2051. if(i==array.length-1)
  2052. 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>";
  2053. else if(i==1)
  2054. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2055. else
  2056. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2057. }
  2058. return str+"</table>";
  2059. }
  2060.  
  2061. function analyseTactique(donneesMonstre,nom) {
  2062. try
  2063. {
  2064. var listeAttaques = [];
  2065. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2066. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2067. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2068. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2069. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2070. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2071. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2072. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2073. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2074. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2075. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2076. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2077. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2078. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2079. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2080. var modificateurEsquive = '';
  2081. var modificateurArmure = '';
  2082. var modificateurMagie = '';
  2083. var modificateurEsquiveM = '';
  2084. var modificateurArmureM = '';
  2085. var pasDeSR=false;
  2086. var esqM,attM,armM,degM;
  2087. 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)
  2088. return null;
  2089. var td = document.createElement('td')
  2090. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2091. var esqM = 0;
  2092. try
  2093. {
  2094. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2095. }
  2096. catch(e)
  2097. {
  2098. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2099. modificateurEsquive = '<';
  2100. modificateurArmure = '<';
  2101. modificateurMagie = '<';
  2102. }
  2103. td.innerHTML = bbcode(donneesMonstre[3]);
  2104. var attM = 0;
  2105. try
  2106. {
  2107. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2108. }
  2109. catch(e)
  2110. {
  2111. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2112. modificateurEsquiveM = '>';
  2113. modificateurArmureM = '>';
  2114. }
  2115. td.innerHTML = bbcode(donneesMonstre[5]);
  2116. var degM = 0;
  2117. try
  2118. {
  2119. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2120. }
  2121. catch(e)
  2122. {
  2123. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2124. modificateurArmureM = '>';
  2125. }
  2126. td.innerHTML = bbcode(donneesMonstre[7]);
  2127. var armM = 0;
  2128. try
  2129. {
  2130. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2131. }
  2132. catch(e)
  2133. {
  2134. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2135. modificateurArmure = '<';
  2136. }
  2137. var coeffSeuil = 0.95;
  2138. try
  2139. {
  2140. td.innerHTML = bbcode(donneesMonstre[9]);
  2141. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2142. var v = (rm / mm);
  2143. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2144. coeffSeuil = (200-seuil)/200;
  2145. }
  2146. catch(e)
  2147. {
  2148. modificateurMagie = '<';
  2149. pasDeSR = true;
  2150. }
  2151. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2152. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2153. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2154. // roule debug
  2155. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2156. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2157. 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);
  2158. //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);
  2159. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2160. if(getSortComp("Vampirisme")>0)
  2161. {
  2162. var pour = getSortComp("Vampirisme");
  2163. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2164. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2165. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2166. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2167. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2168. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2169. }
  2170. if(getSortComp("Botte Secrète")>0)
  2171. {
  2172. var pour = getSortComp("Botte Secrète");
  2173. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2174. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2175. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2176. 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;
  2177. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2178. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2179. }
  2180. if(getSortComp("Rafale Psychique")>0)
  2181. {
  2182. var pour = getSortComp("Rafale Psychique");
  2183. chanceDEsquiveParfaite = 0;
  2184. chanceDeTouche = Math.round(100*pour/100);
  2185. chanceDeCritique = Math.round(0*pour/100);
  2186. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2187. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2188. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2189. }
  2190. if(getSortComp("Explosion")>0)
  2191. {
  2192. var pour = getSortComp("Explosion");
  2193. chanceDEsquiveParfaite = 0;
  2194. chanceDeTouche = Math.round(100*pour/100);
  2195. chanceDeCritique = Math.round(0*pour/100);
  2196. 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;
  2197. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2198. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2199. }
  2200. if(getSortComp("Projectile Magique")>0)
  2201. {
  2202. var pour = getSortComp("Projectile Magique");
  2203. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2204. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2205. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2206. 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;
  2207. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2208. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2209. }
  2210. if(getSortComp("Frénésie")>0)
  2211. {
  2212. var pour = getSortComp("Frénésie");
  2213. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2214. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2215. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2216. 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;
  2217. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2218. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2219. }
  2220. if(getSortComp("Charger")>0)
  2221. {
  2222. var pour = getSortComp("Charger");
  2223. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2224. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2225. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2226. 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;
  2227. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2228. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2229. }
  2230. if(getSortComp("Griffe du Sorcier")>0)
  2231. {
  2232. var pour = getSortComp("Griffe du Sorcier");
  2233. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2234. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2235. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2236. 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;
  2237. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2238. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2239. }
  2240. if(getSortComp("Attaque Précise",1)>0)
  2241. {
  2242. var niveau = 5;
  2243. var oldPour = 0;
  2244. var chanceDEsquiveParfaite = 0;
  2245. var chanceDeTouche = 0;
  2246. var chanceDeCritique = 0;
  2247. degats = 0;
  2248. while(niveau>0)
  2249. {
  2250. var pour = getSortComp("Attaque Précise",niveau);
  2251. if(pour>oldPour)
  2252. {
  2253. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2254. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2255. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2256. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2257. chanceDeTouche += chanceDeToucheNiveau;
  2258. chanceDeCritique += chanceDeCritiqueNiveau;
  2259. 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);
  2260. oldPour = pour;
  2261. }
  2262. niveau--;
  2263. }
  2264. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2265. 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));
  2266. }
  2267. if(getSortComp("Coup de Butoir",1)>0)
  2268. {
  2269. var niveau = 5;
  2270. var oldPour =0;
  2271. var chanceDEsquiveParfaite = 0;
  2272. var chanceDeTouche=0;
  2273. var chanceDeCritique=0;
  2274. degats=0;
  2275. while(niveau>0)
  2276. {
  2277. var pour = getSortComp("Coup de Butoir",niveau);
  2278. if(pour>oldPour)
  2279. {
  2280. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2281. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2282. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2283. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2284. chanceDeTouche += chanceDeToucheNiveau;
  2285. chanceDeCritique += chanceDeCritiqueNiveau;
  2286. 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);
  2287. oldPour = pour;
  2288. }
  2289. niveau--;
  2290. }
  2291. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2292. 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));
  2293. }
  2294. 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;});
  2295. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2296. {
  2297. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2298. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2299. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2300. }
  2301. else
  2302. {
  2303. chanceDEsquiveParfaite = 0;
  2304. chanceDeTouche = 100;
  2305. chanceDeCritique = 0;
  2306. }
  2307. 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;
  2308.  
  2309. 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));
  2310. return listeAttaques;
  2311. }
  2312. catch(e) { window.alert(e);}
  2313. }
  2314.  
  2315. // x~~x marque pour s'y retrouver sous l'éditeur
  2316.  
  2317. /*
  2318. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2319. * published under GNU License v2.
  2320. *
  2321. * Patch :
  2322. * gestion des missions terminées
  2323. */
  2324. // x~x mission_liste
  2325.  
  2326. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2327. try {
  2328. var titresMimis = document.evaluate(
  2329. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2330. document, null, 7, null
  2331. );
  2332. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2333. } catch(e) {
  2334. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2335. return;
  2336. }
  2337. var enCours = {};
  2338. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2339. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2340. enCours[num] = true;
  2341. }
  2342. for(var numMimi in obMissions) {
  2343. if(!enCours[numMimi]) {
  2344. delete obMissions[numMimi];
  2345. }
  2346. }
  2347. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2348. }
  2349.  
  2350. function do_mission_liste() {
  2351. checkLesMimis();
  2352. }
  2353.  
  2354. /*******************************************************************************
  2355. * This file is part of Mountyzilla. *
  2356. * *
  2357. * Mountyzilla is free software; you can redistribute it and/or modify *
  2358. * it under the terms of the GNU General Public License as published by *
  2359. * the Free Software Foundation; either version 2 of the License, or *
  2360. * (at your option) any later version. *
  2361. * *
  2362. * Mountyzilla is distributed in the hope that it will be useful, *
  2363. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2364. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2365. * GNU General Public License for more details. *
  2366. * *
  2367. * You should have received a copy of the GNU General Public License *
  2368. * along with Mountyzilla; if not, write to the Free Software *
  2369. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2370. *******************************************************************************/
  2371.  
  2372. // x~x actions
  2373.  
  2374. /* TODO
  2375. * getLvl pour Explo, Rotobaffe et cie
  2376. */
  2377.  
  2378.  
  2379.  
  2380. /* Page de combat */
  2381.  
  2382. function getLevel() {
  2383. var divList = document.getElementsByTagName('div');
  2384. if(divList.length <= 2)
  2385. return;
  2386. // On essaie de voir si cette action était une attaque
  2387. var pList = document.getElementsByTagName('p');
  2388. var nomM = '';
  2389. // Modification pour Frénésie by TetDure
  2390. var numAtt = 0;
  2391. for (var i = 0; i < pList.length; i++) {
  2392. if(pList[i].firstChild) {
  2393. nomM = pList[i].firstChild.nodeValue;
  2394. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2395. numAtt++;
  2396. }
  2397. }
  2398. if(nomM == '')
  2399. return;
  2400. // Si c'est une attaque normale, un seul PX
  2401. var comPX = 1;
  2402. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2403. comPX++;
  2404.  
  2405. // Extraction des infos du monstre attaqué
  2406. var idM;
  2407. var male;
  2408. if(nomM.slice(20, 21) == 'e') {
  2409. male = false;
  2410. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2411. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2412. }
  2413. else {
  2414. male = true;
  2415. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2416. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2417. }
  2418. if(idM == '')
  2419. return;
  2420. var bList = document.getElementsByTagName('b');
  2421. var niveau = '';
  2422. for (var i = 0; i < bList.length; i++) {
  2423. var b = bList[i];
  2424. if(b.childNodes[0].nodeValue != "TUÉ")
  2425. continue;
  2426. var nbPX = "";
  2427. for (i++; i < bList.length; i++) {
  2428. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2429. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2430. return;
  2431. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2432. nbPX = bList[i].childNodes[0].nodeValue;
  2433. break;
  2434. }
  2435. }
  2436. if(nbPX == '')
  2437. return;
  2438. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2439. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2440. if(!nbPX)
  2441. nbPX = 0;
  2442. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2443. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2444. if(comPX > nbPX) {
  2445. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2446. niveau = "";
  2447. } else if(Math.floor(niveau) == niveau) {
  2448. chaine += niveau + ".";
  2449. } else {
  2450. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2451. niveau = "";
  2452. }
  2453. insertBr(b.nextSibling.nextSibling.nextSibling);
  2454. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2455. }
  2456.  
  2457. if(niveau != '') {
  2458. var button = insertButtonCdm('as_Action');
  2459. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2460. + escape(nomM) + "&niveau=" + escape(niveau)
  2461. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2462. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2463. }
  2464. }
  2465.  
  2466.  
  2467. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2468.  
  2469. function insertInfoMagie(node, intitule, magie) {
  2470. if(node.nextSibling) {
  2471. node = node.nextSibling;
  2472. insertBr(node);
  2473. insertText(node, intitule);
  2474. insertText(node, magie, true);
  2475. } else {
  2476. node = node.parentNode;
  2477. appendBr(node);
  2478. appendText(node, intitule);
  2479. appendText(node, magie, true);
  2480. }
  2481. }
  2482.  
  2483. function getMM(sr) {
  2484. if(rmTroll<=0) {
  2485. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2486. }
  2487. sr = Number(sr.match(/\d+/)[0]);
  2488. if(sr==10) {
  2489. return '\u2265 '+5*rmTroll;
  2490. }
  2491. if(sr<=50) {
  2492. return Math.round(50*rmTroll/sr);
  2493. }
  2494. if(sr<90) {
  2495. return Math.round((100-sr)*rmTroll/50);
  2496. }
  2497. return '\u2264 '+Math.round(rmTroll/5);
  2498. }
  2499.  
  2500. function traiteMM() {
  2501. var node = document.evaluate(
  2502. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2503. document, null, 9, null).singleNodeValue;
  2504. if(node) {
  2505. var mm = getMM(node.nodeValue);
  2506. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2507. } else {
  2508. var node = document.evaluate(
  2509. "//p/text()[contains(., 'Seuil de Résistance')]",
  2510. document, null, 9, null).singleNodeValue;
  2511. if(!node) {
  2512. return;
  2513. }
  2514. var mm = getMM(node.nodeValue);
  2515. node = node.nextSibling.nextSibling;
  2516. }
  2517. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2518. }
  2519.  
  2520. function getRM(sr) {
  2521. if(mmTroll<=0) {
  2522. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2523. }
  2524. sr = Number(sr.match(/\d+/)[0]);
  2525. if(sr==10) {
  2526. return '\u2264 '+Math.round(mmTroll/5);
  2527. }
  2528. if(sr<=50) {
  2529. return Math.round(sr*mmTroll/50);
  2530. }
  2531. if(sr<90) {
  2532. return Math.round(50*mmTroll/(100-sr));
  2533. }
  2534. return '\u2265 '+5*mmTroll;
  2535. }
  2536.  
  2537. function traiteRM() {
  2538. var nodes = document.evaluate(
  2539. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2540. document, null, 7, null);
  2541. if(nodes.snapshotLength==0) {
  2542. return;
  2543. }
  2544. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2545. var node = nodes.snapshotItem(i);
  2546. var rm = getRM(node.nodeValue);
  2547. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2548. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2549. }
  2550. }
  2551.  
  2552.  
  2553. /* Fonction stats IdT par Raistlin */
  2554. /*function getIdt() {
  2555. if(MY_getValue("SEND_IDT") == "non")
  2556. return false;
  2557. var regExpBeginning = /^\s+/;
  2558. var regExpEnd = /\s+$/;
  2559.  
  2560. var nomIdt = document.evaluate(
  2561. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2562. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2563. if(!nomIdt)
  2564. return false;
  2565.  
  2566. var caracIdt;
  2567. if(nomIdt.indexOf("Malédiction !") != -1) {
  2568. caracIdt = "";
  2569. nomIdt = "Mission maudite";
  2570. } else {
  2571. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2572. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2573. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2574. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2575. }
  2576. FF_XMLHttpRequest({
  2577. method: 'GET',
  2578. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2579. headers : {
  2580. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2581. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2582. }
  2583. });
  2584. return true;
  2585. }*/
  2586.  
  2587.  
  2588. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2589.  
  2590. function confirmeDecalage() {
  2591. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2592. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2593. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2594. var newDLA = new Date( oldDLA );
  2595. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2596. return window.confirm(
  2597. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2598. +'\nConfirmez-vous ce décalage ?'
  2599. );
  2600. }
  2601.  
  2602. function newsubmitDLA(evt) {
  2603. evt.stopPropagation();
  2604. evt.preventDefault();
  2605. if(confirmeDecalage()) {
  2606. this.submit();
  2607. }
  2608. }
  2609.  
  2610. function changeActionDecalage() {
  2611. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2612. return;
  2613. }
  2614. try {
  2615. // On récupère le contenu du script JS MH de calcul du décalage
  2616. var scriptTxt = document.evaluate(
  2617. ".//script[ not(@src) ]",
  2618. document, null, 9, null
  2619. ).singleNodeValue.textContent;
  2620. // On en extrait la DLA courante
  2621. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2622. scriptTxt = scriptTxt.split('\n')[0];
  2623. var nbs = scriptTxt.match(/\d+/g);
  2624. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2625. } catch(e) {
  2626. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2627. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  2628. return;
  2629. }
  2630. var form = document.getElementsByName('ActionForm')[0];
  2631. if(form) {
  2632. form.addEventListener('submit', newsubmitDLA, true);
  2633. } else {
  2634. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2635. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2636. }
  2637. }
  2638.  
  2639. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2640.  
  2641. function prochainMundi() {
  2642. try {
  2643. var node = document.evaluate(
  2644. "//div[@class='dateAction']/b",
  2645. document, null, 9, null
  2646. ).singleNodeValue;
  2647. } catch(e) {
  2648. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  2649. return;
  2650. }
  2651. if(!node) { return; }
  2652.  
  2653. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2654. var jour = longueurMois+1-getNumber(node.textContent);
  2655. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2656. var txt = '[Prochain Mundidey ';
  2657. if(jour>1) {
  2658. txt += 'dans '+jour+' jours]';
  2659. } else {
  2660. txt += 'demain]';
  2661. }
  2662. insertText(node.parentNode.nextSibling,txt,true);
  2663. }
  2664.  
  2665.  
  2666. /* Fonction principale */
  2667.  
  2668. function dispatch() {
  2669. if(isPage('MH_Play/Play_action')) {
  2670. prochainMundi();
  2671. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2672. var oldDLA;
  2673. changeActionDecalage();
  2674. } else if(isPage('MH_Play/Actions')) {
  2675. if(document.evaluate(
  2676. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  2677. document, null, 2, null
  2678. ).stringValue) {
  2679. traiteMM();
  2680. } else if(document.evaluate(
  2681. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  2682. document, null, 2, null
  2683. ).stringValue) {
  2684. //getIdt();
  2685. traiteRM();
  2686. } /*else {
  2687. // Est censé se lancer sur quoi *précisément* ?
  2688. traiteRM();
  2689. getLevel();
  2690. }*/
  2691. } else {
  2692. /* Traitement des messages du bot */
  2693. var messageTitle = document.evaluate(
  2694. "//form/table/tbody/tr[1]/td[1]/"
  2695. +"descendant::text()[contains(.,'[MountyHall]')]",
  2696. document, null, 2, null
  2697. ).stringValue;
  2698. if(messageTitle.indexOf('Attaquant') != -1 &&
  2699. messageTitle.indexOf('sur') != -1) {
  2700. getLevel();
  2701. traiteRM();
  2702. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  2703. messageTitle.indexOf('Défenseur') != -1) {
  2704. traiteMM();
  2705. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  2706. // à replacer avec Attaque après révision getLvl :
  2707. messageTitle.indexOf('Explosion') != -1 ||
  2708. messageTitle.indexOf('Insulte') != -1) {
  2709. traiteRM();
  2710. }
  2711. }
  2712. }
  2713.  
  2714. function do_actions() {
  2715. start_script(31);
  2716. dispatch();
  2717. displayScriptTime();
  2718. }
  2719.  
  2720. /*********************************************************************************
  2721. * This file is part of Mountyzilla. *
  2722. * *
  2723. * Mountyzilla is free software; you can redistribute it and/or modify *
  2724. * it under the terms of the GNU General Public License as published by *
  2725. * the Free Software Foundation; either version 2 of the License, or *
  2726. * (at your option) any later version. *
  2727. * *
  2728. * Mountyzilla is distributed in the hope that it will be useful, *
  2729. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2730. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2731. * GNU General Public License for more details. *
  2732. * *
  2733. * You should have received a copy of the GNU General Public License *
  2734. * along with Mountyzilla; if not, write to the Free Software *
  2735. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2736. *********************************************************************************/
  2737.  
  2738. // x~x pre-enchant
  2739.  
  2740. /* 2013-08-19 : correction auto syntaxe alert */
  2741.  
  2742. var combobox=null;
  2743.  
  2744. function changeObject()
  2745. {
  2746. if(!combobox)
  2747. return ;
  2748. var id = combobox.options[combobox.selectedIndex].value;
  2749. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  2750. if(!id || id=="")
  2751. {
  2752. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2753. return;
  2754. }
  2755. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  2756. }
  2757.  
  2758. function treatePreEnchantement() {
  2759. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2760. if(!input || input.getAttribute("type")=="hidden")
  2761. {
  2762. return false;
  2763. }
  2764. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  2765. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2766. if(!combobox)
  2767. {
  2768. return true;
  2769. }
  2770. combobox.addEventListener('change', changeObject, true);
  2771. return true;
  2772. }
  2773.  
  2774. function treateEnchantement() {
  2775. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2776. if(!input || input.getAttribute("type")!="hidden")
  2777. {
  2778. return false;
  2779. }
  2780. var idEquipement = input.getAttribute("value");
  2781. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  2782. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  2783. if(enchanteur && enchanteur != null)
  2784. return true;
  2785. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2786. if(!input || input.getAttribute("type")!="hidden")
  2787. {
  2788. return false;
  2789. }
  2790. var idEnchanteur = input.getAttribute("value");
  2791. var nodes = document.evaluate(
  2792. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2793. if (nodes.snapshotLength != 3)
  2794. return;
  2795. for(var i=0;i<3;i++)
  2796. {
  2797. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2798. texte = texte.replace(" d'une "," d'un ");
  2799. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2800. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2801. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2802. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2803. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2804. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2805. }
  2806. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2807. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2808. var liste = MY_getValue(numTroll+".enchantement.liste");
  2809. if(!liste || liste=="")
  2810. {
  2811. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2812. }
  2813. else
  2814. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2815. }
  2816.  
  2817. function do_pre_enchant() {
  2818. start_script(60);
  2819. if(!treatePreEnchantement())
  2820. treateEnchantement();
  2821. displayScriptTime();
  2822. }
  2823.  
  2824. /*********************************************************************************
  2825. * This file is part of Mountyzilla. *
  2826. * *
  2827. * Mountyzilla is free software; you can redistribute it and/or modify *
  2828. * it under the terms of the GNU General Public License as published by *
  2829. * the Free Software Foundation; either version 2 of the License, or *
  2830. * (at your option) any later version. *
  2831. * *
  2832. * Mountyzilla is distributed in the hope that it will be useful, *
  2833. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2834. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2835. * GNU General Public License for more details. *
  2836. * *
  2837. * You should have received a copy of the GNU General Public License *
  2838. * along with Mountyzilla; if not, write to the Free Software *
  2839. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2840. *********************************************************************************/
  2841.  
  2842. // x~x enchant
  2843.  
  2844. /* 2013-08-19 : correction auto syntaxe alert */
  2845.  
  2846. function treateEnchantement() {
  2847. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  2848. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  2849. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  2850. return;
  2851. var tab = infoEquipement.split(";");
  2852. if(tab.length<2)
  2853. return;
  2854. var idEquipement = tab[0];
  2855. var nomEquipement = tab[1];
  2856. for(var i=2;i<tab.length;i++)
  2857. nomEquipement += ";"+tab[i];
  2858. var nodes = document.evaluate(
  2859. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2860. if (nodes.snapshotLength != 3)
  2861. return;
  2862. for(var i=0;i<3;i++)
  2863. {
  2864. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2865. texte = texte.replace(" d'une "," d'un ");
  2866. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2867. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2868. monstre = monstre.replace(/ Géante?/,"");
  2869. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2870. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2871. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2872. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2873. }
  2874. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2875. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2876. var liste = MY_getValue(numTroll+".enchantement.liste");
  2877. if(!liste || liste=="")
  2878. {
  2879. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2880. }
  2881. else
  2882. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2883. }
  2884.  
  2885. function do_enchant() {
  2886. start_script(60);
  2887.  
  2888. treateEnchantement();
  2889. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2890. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  2891. displayScriptTime();
  2892. }
  2893.  
  2894. /*********************************************************************************
  2895. * This file is part of Mountyzilla. *
  2896. * *
  2897. * Mountyzilla is free software; you can redistribute it and/or modify *
  2898. * it under the terms of the GNU General Public License as published by *
  2899. * the Free Software Foundation; either version 2 of the License, or *
  2900. * (at your option) any later version. *
  2901. * *
  2902. * Mountyzilla is distributed in the hope that it will be useful, *
  2903. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2904. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2905. * GNU General Public License for more details. *
  2906. * *
  2907. * You should have received a copy of the GNU General Public License *
  2908. * along with Mountyzilla; if not, write to the Free Software *
  2909. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2910. *********************************************************************************/
  2911.  
  2912. // x~x myevent
  2913.  
  2914. // Script désactivé en attendant la màj vers le nouveau système de missions.
  2915. function do_myevent() {
  2916. }
  2917.  
  2918. /*********************************************************************************
  2919. * This file is part of Mountyzilla. *
  2920. * *
  2921. * Mountyzilla is free software; you can redistribute it and/or modify *
  2922. * it under the terms of the GNU General Public License as published by *
  2923. * the Free Software Foundation; either version 2 of the License, or *
  2924. * (at your option) any later version. *
  2925. * *
  2926. * Mountyzilla is distributed in the hope that it will be useful, *
  2927. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2928. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2929. * GNU General Public License for more details. *
  2930. * *
  2931. * You should have received a copy of the GNU General Public License *
  2932. * along with Mountyzilla; if not, write to the Free Software *
  2933. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2934. *********************************************************************************/
  2935.  
  2936. // x~x malus
  2937.  
  2938. /* v1.4 - 2014-01-06
  2939. * - Gestion des sorts double composante
  2940. * v1.4.1 - 2014-01-22
  2941. * - Correction décumul
  2942. * TODO
  2943. * - Identifier la position de "PV" dans l'ordre MH
  2944. */
  2945.  
  2946. var listeBM;
  2947.  
  2948.  
  2949. /* [functions] Utilitaires */
  2950.  
  2951. function decumul(bmt,nbr) {
  2952. var bmr;
  2953. if(!nbr || nbr<2) bmr = bmt;
  2954. else if(nbr==2) bmr = parseInt(0.67*bmt);
  2955. else if(nbr==3) bmr = parseInt(0.40*bmt);
  2956. else if(nbr==4) bmr = parseInt(0.25*bmt);
  2957. else if(nbr==5) bmr = parseInt(0.15*bmt);
  2958. else bmr = parseInt(0.1*bmt);
  2959. if(bmt<0) return Math.min(-1,bmr);
  2960. return Math.max(1,bmr);
  2961. }
  2962.  
  2963. function triecaracs(a,b) { // version Yoyor, mod by Dab
  2964. // Roule 23/11/2016 ajout PV
  2965. switch( a ) {
  2966. case 'ATT':
  2967. return -1;
  2968. case 'ESQ':
  2969. if(b=='ATT') return 1;
  2970. return -1;
  2971. case 'DEG':
  2972. switch( b ) {
  2973. case 'ATT':
  2974. case 'ESQ':
  2975. return 1;
  2976. default:
  2977. return -1;
  2978. }
  2979. case 'REG':
  2980. switch( b ) {
  2981. case 'ATT':
  2982. case 'ESQ':
  2983. case 'DEG':
  2984. return 1;
  2985. default:
  2986. return -1;
  2987. }
  2988. case 'Vue':
  2989. switch( b ) {
  2990. case 'ATT':
  2991. case 'ESQ':
  2992. case 'DEG':
  2993. case 'REG':
  2994. return 1;
  2995. default:
  2996. return -1;
  2997. }
  2998. case 'TOUR':
  2999. switch( b ) {
  3000. case 'ATT':
  3001. case 'ESQ':
  3002. case 'DEG':
  3003. case 'REG':
  3004. case 'Vue':
  3005. return 1;
  3006. default:
  3007. return -1;
  3008. }
  3009. case 'PV':
  3010. switch( b ) {
  3011. case 'ATT':
  3012. case 'ESQ':
  3013. case 'DEG':
  3014. case 'REG':
  3015. case 'Vue':
  3016. case 'TOUR':
  3017. return 1;
  3018. default:
  3019. return -1;
  3020. }
  3021. case 'Armure':
  3022. switch( b ) {
  3023. case 'ATT':
  3024. case 'ESQ':
  3025. case 'DEG':
  3026. case 'REG':
  3027. case 'Vue':
  3028. case 'TOUR':
  3029. case 'PV':
  3030. return 1;
  3031. default:
  3032. return -1;
  3033. }
  3034. case 'RM':
  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. return 1;
  3045. default:
  3046. return -1;
  3047. }
  3048. case 'MM':
  3049. switch( b ) {
  3050. case 'ATT':
  3051. case 'ESQ':
  3052. case 'DEG':
  3053. case 'REG':
  3054. case 'Vue':
  3055. case 'TOUR':
  3056. case 'PV':
  3057. case 'Armure':
  3058. case 'RM':
  3059. return 1;
  3060. default:
  3061. return -1;
  3062. }
  3063. case 'Concentration':
  3064. switch( b ) {
  3065. case 'ATT':
  3066. case 'ESQ':
  3067. case 'DEG':
  3068. case 'REG':
  3069. case 'Vue':
  3070. case 'TOUR':
  3071. case 'PV':
  3072. case 'Armure':
  3073. case 'RM':
  3074. case 'MM':
  3075. return 1;
  3076. default:
  3077. return -1;
  3078. }
  3079. case 'Fatigue':
  3080. switch( b ) {
  3081. case 'ATT':
  3082. case 'ESQ':
  3083. case 'DEG':
  3084. case 'REG':
  3085. case 'Vue':
  3086. case 'TOUR':
  3087. case 'PV':
  3088. case 'Armure':
  3089. case 'RM':
  3090. case 'MM':
  3091. case 'Concentration':
  3092. return 1;
  3093. default:
  3094. return -1;
  3095. }
  3096. case "Dés d'attaque":
  3097. switch( b ) {
  3098. case 'ATT':
  3099. case 'ESQ':
  3100. case 'DEG':
  3101. case 'REG':
  3102. case 'Vue':
  3103. case 'TOUR':
  3104. case 'PV':
  3105. case 'Armure':
  3106. case 'RM':
  3107. case 'MM':
  3108. case 'Concentration':
  3109. case 'Fatigue':
  3110. return 1;
  3111. default:
  3112. return -1;
  3113. }
  3114. case 'Dés de dégâts':
  3115. switch( b ) {
  3116. case 'ATT':
  3117. case 'ESQ':
  3118. case 'DEG':
  3119. case 'REG':
  3120. case 'Vue':
  3121. case 'TOUR':
  3122. case 'PV':
  3123. case 'Armure':
  3124. case 'RM':
  3125. case 'MM':
  3126. case 'Concentration':
  3127. case 'Fatigue':
  3128. case "Dés d'attaque":
  3129. return 1;
  3130. default:
  3131. return -1;
  3132. }
  3133. default :
  3134. switch( b ) {
  3135. case 'ATT':
  3136. case 'ESQ':
  3137. case 'DEG':
  3138. case 'REG':
  3139. case 'Vue':
  3140. case 'TOUR':
  3141. case 'PV':
  3142. case 'Armure':
  3143. case 'RM':
  3144. case 'MM':
  3145. case 'Concentration':
  3146. case 'Fatigue':
  3147. case "Dés d'attaque":
  3148. case 'Dés de dégâts':
  3149. return 1;
  3150. default:
  3151. return -1;
  3152. }
  3153. }
  3154. }
  3155.  
  3156.  
  3157. /* [functions] Fonctions hide / display */
  3158.  
  3159. function toggleDetailsBM() {
  3160. if(MY_getValue('BMDETAIL')!='false') {
  3161. MY_setValue('BMDETAIL','false');
  3162. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3163. for(var i=0 ; i<trlist.length ; i++)
  3164. trlist[i].style.display = 'none';
  3165. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3166. for(var i=0 ; i<trlist.length ; i++)
  3167. trlist[i].style = '';
  3168. }
  3169. else {
  3170. MY_setValue('BMDETAIL','true');
  3171. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3172. for(var i=0 ; i<trlist.length ; i++)
  3173. trlist[i].style.display = 'none';
  3174. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3175. for(var i=0 ; i<trlist.length ; i++)
  3176. trlist[i].style = '';
  3177. }
  3178. }
  3179.  
  3180. function toggleBMList() {
  3181. if(MY_getValue('BMHIDELIST')=='true') {
  3182. MY_setValue('BMHIDELIST','false');
  3183. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3184. listeBM.snapshotItem(i).style = '';
  3185. document.getElementsByTagName('thead')[0].style = '';
  3186. document.getElementById('trhelp').style = '';
  3187. }
  3188. else {
  3189. MY_setValue('BMHIDELIST','true');
  3190. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3191. listeBM.snapshotItem(i).style.display = 'none';
  3192. document.getElementsByTagName('thead')[0].style.display = 'none';
  3193. document.getElementById('trhelp').style.display = 'none';
  3194. }
  3195. }
  3196.  
  3197. function setDisplayBM() {
  3198. if(!listeBM) return;
  3199. var titre = document.getElementById('titre2');
  3200. if(titre) {
  3201. titre.style.cursor = 'pointer';
  3202. titre.onclick = toggleBMList;
  3203. }
  3204. var tfoot = document.getElementsByTagName('tfoot')[0];
  3205. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3206. tfoot, null, 9, null).singleNodeValue;
  3207. tr.id = 'trhelp';
  3208. if(MY_getValue('BMHIDELIST')=='true') {
  3209. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3210. listeBM.snapshotItem(i).style.display = 'none';
  3211. document.getElementsByTagName('thead')[0].style.display = 'none';
  3212. tr.style.display = 'none';
  3213. }
  3214. }
  3215.  
  3216.  
  3217. /* [functions] Fonction principale */
  3218.  
  3219. function traiteMalus() {
  3220. var mainTab = document.getElementsByTagName('table')[0];
  3221. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3222. if(listeBM.snapshotLength==0) return;
  3223. /* Suppression des BM de fatigue stockés */
  3224. if(MY_getValue(numTroll+'.bm.fatigue'))
  3225. MY_removeValue(numTroll+'.bm.fatigue');
  3226. /* Extraction des données */
  3227. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3228. var nb = 0;
  3229. while(nb<listeBM.snapshotLength) {
  3230. tr = listeBM.snapshotItem(nb); nb++;
  3231. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3232. var phymag = tr.childNodes[9].textContent;
  3233. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3234. var type = tr.childNodes[3].textContent, nom;
  3235. // si c'est un type à décumul
  3236. /*
  3237. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3238. switch(type) {
  3239. case 'Potion':
  3240. case 'Parchemin':
  3241. case 'Sortilège':
  3242. case 'Capacité Spéciale':
  3243. nom = tr.childNodes[1].textContent+phymag;
  3244. break;
  3245. default:
  3246. nom = 'pasdedecumul';
  3247. }
  3248. */
  3249. nom = tr.childNodes[1].textContent+phymag;
  3250. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3251. nom = 'pasdedecumul';
  3252. uniListe[nb] = {
  3253. 'duree':duree,
  3254. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3255. 'caracs':{}
  3256. }
  3257. for(var i=0 ; i<effetsT.length ; i++) {
  3258. if(effetsT[i].indexOf(':')==-1) continue;
  3259. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3260. // nom = 'pasdedecumul' si pas de décumul
  3261. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3262. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3263. uniListe[nb]['type'] = phymag;
  3264. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3265. uniListe[nb]['caracs'][carac] = bm;
  3266. listeDurees[duree] = true;
  3267. }
  3268. } // fin boucle sur les lignes de bonus/malus
  3269. /* Gestion des décumuls et cumuls des durées */
  3270. var toursGeres = [];
  3271. for(var d in listeDurees) toursGeres.push(d);
  3272. toursGeres.sort( function (a,b){return b-a;} );
  3273. // pour sauvegarder les bm de fatigue
  3274. var strfat = '';
  3275. // Pour affichage & adpatation à footable.js (statique)
  3276. var thead = document.getElementsByTagName('thead')[0];
  3277. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3278. thead, null, 7, null).snapshotLength;
  3279. var tfoot = document.getElementsByTagName('tfoot')[0];
  3280. for(var i=0 ; i<toursGeres.length ; i++) {
  3281. var tour = toursGeres[i];
  3282. var effetsCeTour = {}; decumulsCeTour = {};
  3283. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3284. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3285. continue;
  3286. var nom = uniListe[nb]['nom'];
  3287. if(nom!='pasdedecumul') {
  3288. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3289. decumulsCeTour[nom]++;
  3290. }
  3291. for(var carac in uniListe[nb]['caracs']) {
  3292. var bm = uniListe[nb]['caracs'][carac];
  3293. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3294. var type = uniListe[nb]['type'];
  3295. if(!effetsCeTour[carac])
  3296. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3297. if(nom=='pasdedecumul')
  3298. effetsCeTour[carac][type] += bm;
  3299. else
  3300. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  3301. } else {
  3302. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3303. var thisBm;
  3304. if(nom=='pasdedecumul' || carac=='Fatigue')
  3305. thisBm = bm;
  3306. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3307. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3308. else
  3309. thisBm = decumul(bm,decumulsCeTour[nom]);
  3310. effetsCeTour[carac] += thisBm;
  3311. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3312. }
  3313. } // fin boucle sur les caractéristiques
  3314. } // fin boucle sur les bonus/malus
  3315. /* Création du bilan du tour */
  3316. var texteD = '', texteS = '';
  3317. var caracGerees = [];
  3318. for(var k in effetsCeTour) caracGerees.push(k);
  3319. caracGerees.sort( triecaracs );
  3320. for(var j=0 ; j<caracGerees.length ; j++) {
  3321. var carac = caracGerees[j], str = '';
  3322. switch( carac ) {
  3323. case 'ATT':
  3324. case 'DEG':
  3325. case 'Armure':
  3326. var phy = effetsCeTour[carac]['Physique'];
  3327. var mag = effetsCeTour[carac]['Magie'];
  3328. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3329. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3330. break;
  3331. case 'TOUR':
  3332. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3333. break;
  3334. case 'Fatigue':
  3335. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3336. case 'PV':
  3337. case 'ESQ':
  3338. case 'REG':
  3339. case 'Vue':
  3340. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3341. break;
  3342. default:
  3343. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3344. }
  3345. if(str) {
  3346. texteD += str;
  3347. texteS += str;
  3348. }
  3349. } // fin boucle sur les caractéristiques
  3350. /* Affichage */
  3351. // Si rien à afficher on passe
  3352. if(!texteD) continue;
  3353. // Si BMM+BMP=0
  3354. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3355. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3356. if(MY_getValue('BMDETAIL')=='false')
  3357. tr.style.display = 'none';
  3358. var td = appendTdText(tr,texteD.substring(3));
  3359. td.colSpan = 5-nbHidden;
  3360. var txttour = toursGeres[i]+' Tour';
  3361. if(toursGeres[i]>1) txttour += 's';
  3362. appendTdText(tr,txttour);
  3363. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3364. if(MY_getValue('BMDETAIL')!='false')
  3365. tr.style.display = 'none';
  3366. td = appendTdText(tr,texteS);
  3367. td.colSpan = 5-nbHidden;
  3368. appendTdText(tr,txttour);
  3369. } // fin boucle sur les tours générés
  3370. /* mise en place toggleDetails */
  3371. tfoot.style.cursor = 'pointer';
  3372. tfoot.onclick = toggleDetailsBM;
  3373. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3374. if(strfat)
  3375. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3376. }
  3377.  
  3378. function do_malus() {
  3379. try {
  3380. start_script();
  3381. traiteMalus();
  3382. setDisplayBM();
  3383. displayScriptTime();
  3384. }
  3385. catch(e) {window.alert(e)};
  3386. }
  3387.  
  3388. /*******************************************************************************
  3389. * This file is part of Mountyzilla. *
  3390. * *
  3391. * Mountyzilla is free software; you can redistribute it and/or modify *
  3392. * it under the terms of the GNU General Public License as published by *
  3393. * the Free Software Foundation; either version 2 of the License, or *
  3394. * (at your option) any later version. *
  3395. * *
  3396. * Mountyzilla is distributed in the hope that it will be useful, *
  3397. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3398. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3399. * GNU General Public License for more details. *
  3400. * *
  3401. * You should have received a copy of the GNU General Public License *
  3402. * along with Mountyzilla; if not, write to the Free Software *
  3403. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3404. *******************************************************************************/
  3405.  
  3406. // x~x mouches
  3407.  
  3408. var mainTab, tr_mouches;
  3409.  
  3410. function initialiseMouches() {
  3411. // Lanceur global
  3412. try {
  3413. mainTab = document.getElementById('mouches');
  3414. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3415. } catch(e) {
  3416. avertissement('Erreur MZ:<br />Consulter la console.');
  3417. window.console.error(traceStack(e, 'mouches'));
  3418. return;
  3419. }
  3420. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3421. setDisplayMouches();
  3422. traiteMouches();
  3423. }
  3424.  
  3425. function setDisplayMouches() {
  3426. // Initialise l'affichage / l'effacement du détail des mouches
  3427. var titre = document.getElementById('titre2');
  3428. if(titre) {
  3429. titre.style.cursor = 'pointer';
  3430. titre.onclick = toggleMouches;
  3431. }
  3432. var tfoot = document.getElementsByTagName('tfoot')[0];
  3433. if(tfoot) {
  3434. tfoot.style.cursor = 'pointer';
  3435. tfoot.onclick = toggleMouches;
  3436. }
  3437. if(MY_getValue('HIDEMOUCHES')=='true') {
  3438. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3439. tr_mouches.snapshotItem(i).style.display = 'none';
  3440. }
  3441. document.getElementsByTagName('thead')[0].style.display = 'none';
  3442. }
  3443. }
  3444.  
  3445. function toggleMouches() {
  3446. // Handler pour afficher / masquer les détasil
  3447. if(MY_getValue('HIDEMOUCHES')=='true') {
  3448. MY_setValue('HIDEMOUCHES','false');
  3449. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3450. tr_mouches.snapshotItem(i).style.display = '';
  3451. }
  3452. document.getElementsByTagName('thead')[0].style.display = '';
  3453. } else {
  3454. MY_setValue('HIDEMOUCHES','true');
  3455. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3456. tr_mouches.snapshotItem(i).style.display = 'none';
  3457. }
  3458. document.getElementsByTagName('thead')[0].style.display = 'none';
  3459. }
  3460. }
  3461.  
  3462. function traiteMouches() {
  3463. // Traitement complet: présence et effets des mouches
  3464. var listeTypes = {}, effetsActifs = {};
  3465. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3466. var tr = tr_mouches.snapshotItem(i);
  3467. // La mouche est-elle présente?
  3468. var etat = document.evaluate(
  3469. './img',
  3470. tr.cells[6], null, 9, null
  3471. ).singleNodeValue.alt;
  3472. if(etat!='La Mouche est là') { continue; }
  3473. // Extraction du type de mouche
  3474. var type = trim(tr.cells[3].textContent);
  3475. if(!listeTypes[type]) {
  3476. listeTypes[type] = 1;
  3477. } else {
  3478. listeTypes[type]++;
  3479. }
  3480. // La mouche a-t-elle un effet?
  3481. var effet = trim(tr.cells[2].textContent);
  3482. if(etat!='La Mouche est là' || !effet) { continue; }
  3483. // Si oui, extraction des effets (multiples pour pogées)
  3484. var caracs = effet.split(' | ');
  3485. for(var j=0 ; j<caracs.length ; j++) {
  3486. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3487. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3488. if(effetsActifs[carac]===void(0)) {
  3489. effetsActifs[carac] = valeur;
  3490. } else {
  3491. effetsActifs[carac] += valeur;
  3492. }
  3493. }
  3494. }
  3495. // Extraction Effet total et affichage des différences à la normale
  3496. var tfoot = document.getElementsByTagName('tfoot')[0];
  3497. if(!tfoot) { return; }
  3498. var nodeTotal = document.evaluate(
  3499. ".//b[contains(./text(),'Effet total')]",
  3500. tfoot, null, 9, null
  3501. ).singleNodeValue.nextSibling;
  3502. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3503. var texte = ' ';
  3504. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3505. if(texte.length>1) { texte += ' | '; }
  3506. var carac = trim(
  3507. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3508. );
  3509. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3510. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3511. texte += effetsTheoriques[i];
  3512. } else {
  3513. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3514. if(carac=='TOUR') { texte += ' min'; }
  3515. texte += '</b>';
  3516. }
  3517. }
  3518. var span = document.createElement('span');
  3519. span.innerHTML = texte;
  3520. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3521. // Affichage des différences du nombre de mouches de chaque type
  3522. var mouchesParType = document.evaluate(
  3523. "./tr/td/ul/li/text()",
  3524. tfoot, null, 7, null
  3525. );
  3526. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3527. var node = mouchesParType.snapshotItem(i);
  3528. var mots = node.nodeValue.split(' ');
  3529. var type = mots.pop();
  3530. if(!listeTypes[type]) {
  3531. node.nodeValue += ' (0 présente)';
  3532. } else if(mots[0]!=listeTypes[type]) {
  3533. if(listeTypes[type]==1) {
  3534. node.nodeValue += ' (1 présente)';
  3535. } else {
  3536. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3537. }
  3538. }
  3539. }
  3540. }
  3541.  
  3542. function do_mouches() {
  3543. start_script();
  3544. initialiseMouches();
  3545. displayScriptTime();
  3546. }
  3547.  
  3548. /*********************************************************************************
  3549. * This file is part of Mountyzilla. *
  3550. * *
  3551. * Mountyzilla is free software; you can redistribute it and/or modify *
  3552. * it under the terms of the GNU General Public License as published by *
  3553. * the Free Software Foundation; either version 2 of the License, or *
  3554. * (at your option) any later version. *
  3555. * *
  3556. * Mountyzilla is distributed in the hope that it will be useful, *
  3557. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3558. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3559. * GNU General Public License for more details. *
  3560. * *
  3561. * You should have received a copy of the GNU General Public License *
  3562. * along with Mountyzilla; if not, write to the Free Software *
  3563. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3564. *********************************************************************************/
  3565.  
  3566. // x~x equipgowap
  3567.  
  3568. var popup;
  3569.  
  3570. function initPopupEquipgowap() {
  3571. popup = document.createElement('div');
  3572. popup.setAttribute('id', 'popup');
  3573. popup.setAttribute('class', 'mh_textbox');
  3574. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3575. 'display: inline; z-index: 3; max-width: 400px;');
  3576. document.body.appendChild(popup);
  3577. }
  3578.  
  3579. function showPopupEquipgowap(evt) {
  3580. var texte = this.getAttribute("texteinfo");
  3581. popup.innerHTML = texte;
  3582. popup.style.left = evt.pageX + 15 + 'px';
  3583. popup.style.top = evt.pageY + 'px';
  3584. popup.style.visibility = "visible";
  3585. }
  3586.  
  3587. function hidePopup() {
  3588. popup.style.visibility = "hidden";
  3589. }
  3590.  
  3591. function createPopupImage(url, text)
  3592. {
  3593. var img = document.createElement('img');
  3594. img.setAttribute('src',url);
  3595. img.setAttribute('align','ABSMIDDLE');
  3596. img.setAttribute("texteinfo",text);
  3597. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3598. img.addEventListener("mouseout", hidePopup,true);
  3599. return img;
  3600. }
  3601.  
  3602. function formateTexte(texte)
  3603. {
  3604. texte = texte.replace(/\n/g,"<br/>");
  3605. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3606. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3607. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3608. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3609. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3610. return texte;
  3611. }
  3612.  
  3613.  
  3614. function treateGowaps() {
  3615. //On récupère les gowaps possédants des composants
  3616. var tbodys = document.evaluate(
  3617. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3618. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3619. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3620. var tbody = tbodys.snapshotItem(j);
  3621. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3622. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3623. if(MY_getValue("NOINFOEM") != "true")
  3624. insertEMInfos(tbody);
  3625. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3626. insertEnchantInfos(tbody);
  3627. }
  3628. }
  3629.  
  3630. function treateChampi() {
  3631. if(MY_getValue("NOINFOEM") == "true")
  3632. return false;
  3633. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3634. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3635. if (nodes.snapshotLength == 0)
  3636. return false;
  3637.  
  3638. for (var i = 0; i < nodes.snapshotLength; i++) {
  3639. var node = nodes.snapshotItem(i);
  3640. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3641. if(texte.indexOf("*")!=-1)
  3642. texte = texte.substring(0,texte.lastIndexOf(" "));
  3643. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3644. if(moisChampi[nomChampi])
  3645. {
  3646. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3647. }
  3648. }
  3649. }
  3650.  
  3651. function do_equipgowap() {
  3652. start_script();
  3653.  
  3654. treateGowaps();
  3655. treateChampi();
  3656. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3657. {
  3658. initPopupEquipgowap();
  3659. computeEnchantementEquipement(createPopupImage,formateTexte);
  3660. }
  3661.  
  3662. displayScriptTime();
  3663. }
  3664.  
  3665. /*********************************************************************************
  3666. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3667. *********************************************************************************/
  3668.  
  3669. // x~x ordresgowap
  3670.  
  3671. /* v0.2 by Dab - 2013-08-31
  3672. * - correction acquisition posale initiale
  3673. * - correction tare et affichage mire
  3674. */
  3675.  
  3676. function setCarteGogo() {
  3677. try {
  3678. //var pars = document.getElementsByTagName('p');
  3679. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3680. var eTitle = document.getElementById('titre2');
  3681. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3682. var serv_img_trou = URL_MZimg + "carte_trou.png";
  3683. var serv_img_cible = URL_MZimg + "rep.png";
  3684.  
  3685. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  3686. //var lignes = pars[0].getElementsByTagName('tr');
  3687. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  3688. var nbpt = 0;
  3689. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  3690. for(var i=0 ; i<lignes.length ; i++) {
  3691. if(lignes[i].className == 'mh_tdpage_fo') {
  3692. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  3693. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  3694. if(point) {
  3695. nbpt++;
  3696. trajet += point[1]+','+point[2]+','+point[3]+',';
  3697. }
  3698. }
  3699. }
  3700. }
  3701. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  3702. 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'/>";
  3703. var base = [-229,-5];
  3704. if (nbpt>0) {
  3705. base = [-684,-5];
  3706. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  3707. }
  3708. 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;'/>";
  3709.  
  3710. 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>';
  3711.  
  3712. var nvspan = document.createElement('div');
  3713. nvspan.align = 'center';
  3714. nvspan.id = 'mz_mapdiv';
  3715. nvspan.valign = 'top';
  3716. nvspan.innerHTML = nvdiv;
  3717. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  3718. var footer = document.getElementById('footer1');
  3719. footer.parentNode.insertBefore(nvspan,footer);
  3720. }
  3721.  
  3722. function testeGlissiere() {
  3723. try {
  3724. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  3725. var footer = document.getElementById('footer1');
  3726. footer.parentNode.insertBefore(gliss.getElt(), footer);
  3727. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  3728. }
  3729.  
  3730. function do_ordresgowap() {
  3731. setCarteGogo(); // Via script des trouillots
  3732. if (isDEV) {
  3733. testeGlissiere();
  3734. }
  3735. }
  3736.  
  3737. /*********************************************************************************
  3738. * This file is part of Mountyzilla. *
  3739. * *
  3740. * Mountyzilla is free software; you can redistribute it and/or modify *
  3741. * it under the terms of the GNU General Public License as published by *
  3742. * the Free Software Foundation; either version 2 of the License, or *
  3743. * (at your option) any later version. *
  3744. * *
  3745. * Mountyzilla is distributed in the hope that it will be useful, *
  3746. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3747. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3748. * GNU General Public License for more details. *
  3749. * *
  3750. * You should have received a copy of the GNU General Public License *
  3751. * along with Mountyzilla; if not, write to the Free Software *
  3752. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3753. *********************************************************************************/
  3754.  
  3755. // x~x attaque
  3756.  
  3757. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3758.  
  3759. function do_attaque() {
  3760. }
  3761.  
  3762. /*******************************************************************************
  3763. * This file is part of Mountyzilla. *
  3764. * *
  3765. * Mountyzilla is free software; you can redistribute it and/or modify *
  3766. * it under the terms of the GNU General Public License as published by *
  3767. * the Free Software Foundation; either version 2 of the License, or *
  3768. * (at your option) any later version. *
  3769. * *
  3770. * Mountyzilla is distributed in the hope that it will be useful, *
  3771. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3772. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3773. * GNU General Public License for more details. *
  3774. * *
  3775. * You should have received a copy of the GNU General Public License *
  3776. * along with Mountyzilla; if not, write to the Free Software *
  3777. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3778. *******************************************************************************/
  3779.  
  3780. // x~x infomonstre
  3781.  
  3782. // DEBUG
  3783. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  3784. // À corriger, évidemment.
  3785. var listeCDM = {};
  3786. var nomMonstre='';
  3787. var idMonstre=-1;
  3788. var tbody;
  3789. var popup;
  3790.  
  3791. function traiteMonstre() {
  3792. try {
  3793. var nodeTitre = document.evaluate(
  3794. "//div[@class='titre2' and contains(text(),'(')]",
  3795. document, null, 9, null
  3796. ).singleNodeValue;
  3797. var texte = nodeTitre.firstChild.nodeValue;
  3798. } catch(e) {
  3799. window.console.log(traceStack(e, 'traiteMonstre'));
  3800. return;
  3801. }
  3802. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  3803. if(nomMonstre.indexOf(']')!=-1) {
  3804. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  3805. }
  3806. idMonstre = texte.match(/\d+/)[0];
  3807. FF_XMLHttpRequest({
  3808. method: 'GET',
  3809. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  3810. +MY_getValue('CDMID')
  3811. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  3812. headers : {
  3813. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3814. 'Accept': 'application/atom+xml,application/xml,text/xml'
  3815. },
  3816. onload: function(responseDetails) {
  3817. try {
  3818. var texte = responseDetails.responseText;
  3819. var lines = texte.split("\n");
  3820. if(lines.length>=1) {
  3821. var infos = lines[0].split(";");
  3822. if(infos.length<4) { return; }
  3823. var idMonstre = infos[0];
  3824. infos=infos.slice(3);
  3825. listeCDM[idMonstre]=infos;
  3826. computeMissionInfomonstre();
  3827. }
  3828. } catch(e) {
  3829. window.alert(e);
  3830. }
  3831. }
  3832. });
  3833. }
  3834.  
  3835. function initPopupInfomonstre() {
  3836. // Initialise le popup tactique (calculs att/deg)
  3837. popup = document.createElement('div');
  3838. popup.id = 'popup';
  3839. popup.className = 'mh_textbox';
  3840. popup.style =
  3841. 'position: absolute;'+
  3842. 'border: 1px solid #000000;'+
  3843. 'visibility: hidden;'+
  3844. 'display: inline;'+
  3845. 'z-index: 3;'+
  3846. 'max-width: 400px;';
  3847. document.body.appendChild(popup);
  3848. }
  3849.  
  3850. function showPopupTactique(evt) {
  3851. try {
  3852. var id = this.id;
  3853. var nom = this.nom;
  3854. var texte = getAnalyseTactique(id,nom);
  3855. if(texte=='') { return; }
  3856. popup.innerHTML = texte;
  3857. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  3858. if(isPage("View/MonsterView")) {
  3859. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  3860. } else {
  3861. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  3862. }
  3863. popup.style.top = evt.pageY+15+'px';
  3864. popup.style.visibility = 'visible';
  3865. } catch(e) {
  3866. window.alert(e);
  3867. }
  3868. }
  3869.  
  3870. // roule 16/03/2016, existe déjà ailleurs
  3871. // function hidePopup() {
  3872. // popup.style.visibility = 'hidden';
  3873. // }
  3874.  
  3875. function toggleTableau() {
  3876. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  3877. }
  3878.  
  3879. function computeMissionInfomonstre() {
  3880. // C'est quoi ce titre de fonction ? (O_o)
  3881. try {
  3882. var nodeInsert = document.evaluate(
  3883. "//div[@class = 'titre3']",
  3884. document, null, 9, null
  3885. ).singleNodeValue;
  3886. } catch(e) {
  3887. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  3888. return;
  3889. }
  3890. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  3891. table.align = 'center';
  3892. tbody = table.childNodes[1];
  3893. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  3894. table.firstChild.firstChild.onmouseover = function() {
  3895. this.style.cursor = 'pointer';
  3896. this.className = 'mh_tdpage';
  3897. };
  3898. table.firstChild.firstChild.onmouseout = function() {
  3899. this.className = 'mh_tdtitre';
  3900. };
  3901. tbody.style.display = 'none';
  3902. table.style.width = '350px';
  3903. insertBefore(nodeInsert,table);
  3904. }
  3905.  
  3906. function do_infomonstre() {
  3907. start_script();
  3908. try {
  3909. initPopupInfomonstre();
  3910. traiteMonstre();
  3911. } catch(e) {
  3912. window.alert('Erreur infoMonstre:\n'+e);
  3913. }
  3914. displayScriptTime();
  3915. }
  3916.  
  3917. /*******************************************************************************
  3918. * This file is part of Mountyzilla. *
  3919. * *
  3920. * Mountyzilla is free software; you can redistribute it and/or modify *
  3921. * it under the terms of the GNU General Public License as published by *
  3922. * the Free Software Foundation; either version 2 of the License, or *
  3923. * (at your option) any later version. *
  3924. * *
  3925. * Mountyzilla is distributed in the hope that it will be useful, *
  3926. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3927. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3928. * GNU General Public License for more details. *
  3929. * *
  3930. * You should have received a copy of the GNU General Public License *
  3931. * along with Mountyzilla; if not, write to the Free Software *
  3932. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3933. *******************************************************************************/
  3934.  
  3935. // x~x mission
  3936.  
  3937. /* TODO
  3938. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  3939. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  3940. *
  3941. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  3942. */
  3943.  
  3944. function saveMission(num,obEtape) {
  3945. var obMissions = {};
  3946. if(MY_getValue(numTroll+'.MISSIONS')) {
  3947. try {
  3948. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3949. } catch(e) {
  3950. window.console.error(traceStack(e, 'Mission parsage'));
  3951. return;
  3952. }
  3953. }
  3954. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  3955. if(obEtape) {
  3956. obMissions[num] = obEtape;
  3957. } else if(obMissions[num]) {
  3958. delete obMissions[num];
  3959. }
  3960. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3961. }
  3962.  
  3963. function addtroogle(tdLibelle, sRestrict) {
  3964. var img = document.createElement('img');
  3965. img.src = URL_MZimg + 'troogle.ico';
  3966. img.alt = 'Troogle logo';
  3967. var a = document.createElement('a');
  3968. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  3969. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  3970. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  3971. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  3972. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  3973. a.href = url;
  3974. a.title = 'Chercher sur Troogle';
  3975. a.target = 'troogle';
  3976. a.appendChild(img);
  3977. tdLibelle.appendChild(a);
  3978. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  3979. }
  3980.  
  3981. function traiteMission() {
  3982. try {
  3983. var titreMission = document.getElementsByClassName('titre2')[0];
  3984. var numMission = titreMission.textContent.match(/\d+/)[0];
  3985. var missionForm = document.getElementsByName('ActionForm')[0];
  3986. var tdLibelle = document.evaluate(
  3987. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  3988. missionForm, null, 9, null).singleNodeValue;
  3989. } catch(e) {
  3990. window.console.error(traceStack(e, 'récupération mission'));
  3991. return;
  3992. }
  3993. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  3994. try {
  3995. if(!tdLibelle) {
  3996. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  3997. debugMZ('traiteMission, la mission semble terminée');
  3998. saveMission(numMission,false);
  3999. return;
  4000. }
  4001.  
  4002. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4003. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4004. // debug Roule'
  4005. if (MY_DEBUG) {
  4006. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4007. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4008. }
  4009. if(libelle.indexOf('niveau égal à')!=-1) {
  4010. var nbKills = 1, niveau, mod;
  4011. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4012. // Étape de kill multiple de niveau donné
  4013. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4014. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4015. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4016. niveau = Number(mod[0]);
  4017. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4018. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4019. } else {
  4020. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4021. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4022. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4023. mod = mod ? Number(mod[0]) : 'plus';
  4024. }
  4025. } else {
  4026. // Étape de kill unique de niveau donné
  4027. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4028. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4029. mod = mod ? Number(mod[0]) : 'plus';
  4030. }
  4031. // debug Roule'
  4032. if (MY_DEBUG) {
  4033. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4034. }
  4035. saveMission(numMission,{
  4036. type: 'Niveau',
  4037. niveau: niveau,
  4038. mod: mod,
  4039. mundidey: siMundidey,
  4040. libelle: libelle
  4041. });
  4042. if (mod == 'plus')
  4043. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4044. else
  4045. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4046. } else if(libelle.indexOf('de la race')!=-1) {
  4047. var nbKills = 1, race;
  4048. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4049. // Étape de kill multiple de race donnée
  4050. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4051. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4052. } else {
  4053. // Étape de kill unique de race donnée
  4054. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4055. }
  4056. race = race.replace(/\"/g,'');
  4057. saveMission(numMission,{
  4058. type: 'Race',
  4059. race: race,
  4060. mundidey: siMundidey,
  4061. libelle: libelle
  4062. });
  4063. addtroogle(tdLibelle, '@monstre ' + race);
  4064. } else if(libelle.indexOf('de la famille')!=-1) {
  4065. var nbKills = 1, famille;
  4066. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4067. // Étape de kill multiple de famille donnée
  4068. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4069. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4070. } else {
  4071. // Étape de kill unique de famille donnée
  4072. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4073. }
  4074. famille = famille.replace(/\"/g,'');
  4075. saveMission(numMission,{
  4076. type: 'Famille',
  4077. famille: famille,
  4078. mundidey: siMundidey,
  4079. libelle: libelle
  4080. });
  4081. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4082. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4083. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4084. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4085. debugMZ('traiteMission étape capacité spéciale');
  4086. saveMission(numMission,{
  4087. type: 'Pouvoir',
  4088. pouvoir: pouvoir,
  4089. libelle: libelle
  4090. });
  4091. } else {
  4092. debugMZ('traiteMission étape pas pour troogle');
  4093. saveMission(numMission,false);
  4094. }
  4095. } catch(e) {
  4096. window.console.error(traceStack(e, 'récupération étape mission'));
  4097. return;
  4098. }
  4099. }
  4100.  
  4101. function do_mission() {
  4102. start_script(60);
  4103.  
  4104. traiteMission();
  4105.  
  4106. displayScriptTime();
  4107. }
  4108.  
  4109. /*******************************************************************************
  4110. * This file is part of Mountyzilla. *
  4111. * *
  4112. * Mountyzilla is free software; you can redistribute it and/or modify *
  4113. * it under the terms of the GNU General Public License as published by *
  4114. * the Free Software Foundation; either version 2 of the License, or *
  4115. * (at your option) any later version. *
  4116. * *
  4117. * Mountyzilla is distributed in the hope that it will be useful, *
  4118. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4119. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4120. * GNU General Public License for more details. *
  4121. * *
  4122. * You should have received a copy of the GNU General Public License *
  4123. * along with Mountyzilla; if not, write to the Free Software *
  4124. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4125. *******************************************************************************/
  4126.  
  4127. // x~x move
  4128.  
  4129. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4130.  
  4131. var petitsTrous = {
  4132. '-52;57': true,
  4133. '55;70': true,
  4134. '64;70': true,
  4135. '12;-15': true,
  4136. '30;-52': true,
  4137. '48;-39': true
  4138. };
  4139.  
  4140. var grosTrous = {
  4141. '-35;65': true,
  4142. '-13;73': true,
  4143. '-64;9': true,
  4144. '-35;15': true,
  4145. '5;32': true,
  4146. '10;64': true,
  4147. '21;36': true,
  4148. '46;52': true,
  4149. '74;32': true,
  4150. '-71;-7': true,
  4151. '-67;-37': true,
  4152. '-60;-32': true,
  4153. '-51;-22': true,
  4154. '-36;-51': true,
  4155. '5;-49': true
  4156. };
  4157.  
  4158. var centreCarmine_X = 56.5;
  4159. var centreCarmine_Y = 23.5;
  4160. var rayonCarmine = 8.7;
  4161.  
  4162. function isTrou(x,y,n) {
  4163. if(petitsTrous[x+';'+y]) {
  4164. return n<0 && n>-60;
  4165. }
  4166. if(grosTrous[x+';'+y]
  4167. || grosTrous[x-1+';'+y]
  4168. || grosTrous[x+';'+y+1]
  4169. || grosTrous[x-1+';'+y+1]) {
  4170. return n<0 && n>-70;
  4171. }
  4172. if(Math.sqrt(
  4173. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4174. )<=rayonCarmine) {
  4175. return n<0 && n>-100;
  4176. }
  4177. return false;
  4178. }
  4179.  
  4180. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4181.  
  4182. function validateDestination() {
  4183. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4184. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4185. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4186. var form = document.getElementsByName('ActionForm')[0];
  4187. if(form) {
  4188. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4189. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4190. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4191. }
  4192. }
  4193. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4194. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4195. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4196. }
  4197. }
  4198. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4199. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4200. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4201. }
  4202. }
  4203. if(isTrou(x,y,n)) {
  4204. return window.confirm(
  4205. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4206. +'Vous allez tomber dans un trou de météorite.\n'
  4207. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4208. );
  4209. }
  4210. }
  4211. return true;
  4212. }
  4213.  
  4214. function newsubmitDE(event) {
  4215. event.stopPropagation();
  4216. event.preventDefault();
  4217. if(validateDestination()) {
  4218. this.submit();
  4219. }
  4220. }
  4221.  
  4222. function changeValidation() {
  4223. var form = document.getElementsByName('ActionForm')[0];
  4224. if(form) {
  4225. form.addEventListener('submit', newsubmitDE, true);
  4226. }
  4227. }
  4228.  
  4229.  
  4230. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4231.  
  4232. function validateTPDestination() {
  4233. try {
  4234. var text = document.getElementsByTagName('B')[0];
  4235. var a = text.firstChild.nodeValue.split('|');
  4236. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4237. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4238. var pos_n = a[2].substring(5, a[2].length) * 1;
  4239.  
  4240. var nbtrous = 0;
  4241. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4242. for(var x=0 ; x<=2 ; x++) {
  4243. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4244. for(var y=0 ; y<=2 ; y++) {
  4245. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4246. for(var n = 0 ; n <= 1 ; n++) {
  4247. if(isTrou(
  4248. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4249. )) {
  4250. nbtrous++;
  4251. }
  4252. }
  4253. }
  4254. }
  4255. }
  4256. }
  4257. }
  4258. if(nbtrous>0 && nbtrous<72) {
  4259. return window.confirm(
  4260. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4261. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4262. +'% de risque de tomber dans un trou de météorite.\n'
  4263. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4264. );
  4265. }
  4266. else if(nbtrous>=72) {
  4267. return window.confirm(
  4268. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4269. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4270. +'% de risque de tomber dans un trou de météorite !\n'
  4271. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4272. );
  4273. }
  4274. return true;
  4275. }
  4276. catch(e) {
  4277. window.alert(e)
  4278. }
  4279. }
  4280.  
  4281. function newsubmitTP(event) {
  4282. event.stopPropagation();
  4283. event.preventDefault();
  4284. if(validateTPDestination()) {
  4285. this.submit();
  4286. }
  4287. }
  4288.  
  4289. function changeButtonValidate() {
  4290. var form = document.getElementsByName('Formulaire')[0];
  4291. if(form) {
  4292. if(!form.getAttribute('onsubmit')) {
  4293. form.setAttribute('onsubmit','return true;');
  4294. }
  4295. form.addEventListener('submit', newsubmitTP, true);
  4296. }
  4297. }
  4298.  
  4299.  
  4300. /*-[functions]---------------- Partie Principale -----------------------------*/
  4301.  
  4302. function do_move() {
  4303. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4304. changeValidation();
  4305. }
  4306. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4307. changeButtonValidate();
  4308. }
  4309. }
  4310.  
  4311. /*******************************************************************************
  4312. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4313. * Mountyzilla is free software; provided under the GNU General Public License *
  4314. *******************************************************************************/
  4315.  
  4316. // x~x news
  4317.  
  4318. // Nombre de news à afficher & nb max de caractères par news:
  4319. const nbItems = 5;
  4320. const maxCarDescription = 300;
  4321.  
  4322. /*-[functions]------------------- Utilitaires --------------------------------*/
  4323.  
  4324. // Ne semble avoir strictement aucun effet:
  4325. String.prototype.epureDescription = function() {
  4326. return this.replace(/\\(.)/g,"$1");
  4327. }
  4328.  
  4329. function appendTitledTable(node,titre,description) {
  4330. // Crée les tables contenant les infos (avec titre)
  4331. var table = document.createElement('table');
  4332. table.border = 0;
  4333. table.className = 'mh_tdborder';
  4334. table.cellSpacing = 1;
  4335. table.cellPadding = 1;
  4336. table.style.maxWidth = '98%';
  4337. table.style.marginLeft = 'auto';
  4338. table.style.marginRight = 'auto';
  4339. var tbody = document.createElement('tbody');
  4340. table.appendChild(tbody);
  4341. var tr = appendTr(tbody,'mh_tdtitre');
  4342. var td = appendTdCenter(tr,2);
  4343. var span = document.createElement('span');
  4344. appendText(span,titre,true);
  4345. if(description) {
  4346. span.title = description;
  4347. }
  4348. td.appendChild(span);
  4349. node.appendChild(table);
  4350. return tbody;
  4351. }
  4352.  
  4353. function testCertif(paramURL, callbackOnError) {
  4354. try {
  4355. FF_XMLHttpRequest({
  4356. method: 'GET',
  4357. url: paramURL,
  4358. onload: function(responseDetails) {
  4359. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4360. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4361. }
  4362. });
  4363. } catch(e) {
  4364. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4365. callbackOnError();
  4366. }
  4367. }
  4368.  
  4369. function createOrGetGrandCadre() {
  4370. var grandCadre = document.getElementById('grandCadre');
  4371. if (grandCadre) return grandCadre;
  4372. try {
  4373. var rappels = document.evaluate(
  4374. "//p[contains(a/text(),'messagerie')]",
  4375. document, null, 9, null).singleNodeValue;
  4376. }
  4377. catch(e) {
  4378. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4379. grandCadre = document.createElement('div');
  4380. return grandCadre;
  4381. }
  4382. grandCadre = document.createElement('div');
  4383. grandCadre.id = 'grandCadre';
  4384. var sousCadre = document.createElement('div');
  4385. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4386. sousCadre.style.textAlign = 'center';
  4387. sousCadre.style.fontSize = 'xx-large';
  4388. grandCadre.appendChild(sousCadre);
  4389.  
  4390. grandCadre.style.border = 'solid 5px red';
  4391. grandCadre.style.width = 'auto';
  4392. insertBefore(rappels,grandCadre);
  4393. return grandCadre;
  4394. }
  4395.  
  4396. function showHttpsErrorCadre1() {
  4397. var grandCadre = createOrGetGrandCadre();
  4398. var sousCadre = document.createElement('div');
  4399. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4400. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4401. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4402. + URL_CertifRaistlin1
  4403. + '" target="raistlin">clique ici</a>'
  4404. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4405. + ' « Confirmer l\'exception de sécurité »'
  4406. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4407. sousCadre.style.width = 'auto';
  4408. sousCadre.style.fontSize = 'large';
  4409. sousCadre.style.border = 'solid 1px black';
  4410. sousCadre.style.backgroundColor = 'red';
  4411. grandCadre.appendChild(sousCadre);
  4412. }
  4413.  
  4414. function showHttpsErrorCadre2() {
  4415. var grandCadre = createOrGetGrandCadre();
  4416. var sousCadre = document.createElement('div');
  4417. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  4418. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  4419. + '<a style="color:blue;font-size: inherits;" href="'
  4420. + URL_CertifRaistlin2
  4421. + '" target="raistlin">clique ici</a>'
  4422. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4423. + ' « Confirmer l\'exception de sécurité »'
  4424. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  4425. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4426. sousCadre.style.width = 'auto';
  4427. sousCadre.style.fontSize = 'large';
  4428. sousCadre.style.border = 'solid 1px black';
  4429. sousCadre.style.backgroundColor = 'red';
  4430. grandCadre.appendChild(sousCadre);
  4431. }
  4432.  
  4433. function showHttpsErrorContenuMixte() {
  4434. var grandCadre = createOrGetGrandCadre();
  4435. var sousCadre = document.createElement('div');
  4436. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  4437. + '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)'
  4438. + '<ul>'
  4439. + '<li>Interface Bricol\'Troll</li>'
  4440. + '<li>Nouveautés de Mountyzilla</li>'
  4441. + '</ul>'
  4442. + '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 />'
  4443. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  4444. sousCadre.style.width = 'auto';
  4445. sousCadre.style.fontSize = 'large';
  4446. sousCadre.style.border = 'solid 1px black';
  4447. grandCadre.appendChild(sousCadre);
  4448. }
  4449.  
  4450. /*-[functions]------------------- Jubilaires ---------------------------------*/
  4451.  
  4452. function traiterJubilaires() {
  4453. // à faire
  4454. }
  4455.  
  4456. function traiterJubilaires_a_supprimer() { // ancienne méthode
  4457. try {
  4458. FF_XMLHttpRequest({
  4459. method: 'GET',
  4460. url: URL_anniv,
  4461. headers: {
  4462. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4463. 'Accept': 'application/xml,text/xml',
  4464. },
  4465. onload: function(responseDetails) {
  4466. if ((responseDetails.status == 0) && isHTTPS) {
  4467. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  4468. showHttpsErrorContenuMixte();
  4469. return;
  4470. }
  4471. var listeTrolls = responseDetails.responseText.split('\n');
  4472. if(!listeTrolls || listeTrolls.length==0) {
  4473. return;
  4474. }
  4475. afficherJubilaires(listeTrolls);
  4476. },
  4477. });
  4478. }
  4479. catch(e) {
  4480. if (isHTTPS) {
  4481. window.console.log(traceStack(e, 'appel jubilaires'));
  4482. showHttpsErrorContenuMixte();
  4483. } else {
  4484. window.alert('Erreur Jubilaires:\n'+e);
  4485. }
  4486. }
  4487. }
  4488.  
  4489. function afficherJubilaires(listeTrolls) {
  4490. try {
  4491. var rappels = document.evaluate(
  4492. "//p[contains(a/text(),'messagerie')]",
  4493. document, null, 9, null).singleNodeValue;
  4494. }
  4495. catch(e) {
  4496. return;
  4497. }
  4498. var p = document.createElement('p');
  4499. var tbody = appendTitledTable(p,
  4500. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  4501. 'Envoyez leur un message ou un cadeau !'
  4502. );
  4503. tr = appendTr(tbody,'mh_tdpage');
  4504. td = appendTdCenter(tr);
  4505. var small = document.createElement('small');
  4506. td.appendChild(small);
  4507. var first = true;
  4508. for(var i=0 ; i<listeTrolls.length ; i++) {
  4509. var infos = listeTrolls[i].split(';');
  4510. if(infos.length!=3 || infos[2]==='0') {
  4511. continue;
  4512. }
  4513. if(first) {
  4514. first = false;
  4515. }
  4516. else {
  4517. appendText(small,', ');
  4518. }
  4519. var a = document.createElement('a');
  4520. a.href = 'javascript:EPV('+infos[0]+')';
  4521. appendText(a,infos[1]);
  4522. small.appendChild(a);
  4523. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  4524. }
  4525. insertBefore(rappels,p);
  4526. }
  4527.  
  4528.  
  4529. /*-[functions]--------------------- News MZ ----------------------------------*/
  4530.  
  4531. function traiterNouvelles() {
  4532. var news = new Array;
  4533. 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 ;).']);
  4534. news.push(['24/12/2016', 'Retour de la carte montrant les déplacements des Gowaps']);
  4535. news.push(['24/12/2016', 'Le lien avec Bricol\'Troll est maintenant disponible en https']);
  4536. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  4537. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  4538. afficherNouvelles(news);
  4539. }
  4540.  
  4541. function afficherNouvelles(items) {
  4542. var footer = document.getElementById('footer1');
  4543. if(!footer) {
  4544. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  4545. return;
  4546. }
  4547. var p = document.createElement('p');
  4548. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  4549. for(var i=0 ; i<items.length ; i++) {
  4550. var tr = appendTr(tbody,'mh_tdpage');
  4551. var td = appendTdCenter(tr);
  4552. td.style.verticalAlign = 'top'; // semble sans effet
  4553. appendText(td,items[i][0],true);
  4554. td = appendTd(tr);
  4555. td.innerHTML = items[i][1];
  4556. }
  4557. insertBefore(footer,p);
  4558. }
  4559.  
  4560.  
  4561. /*---------------------------------- Main ------------------------------------*/
  4562.  
  4563. function do_news() {
  4564. start_script();
  4565.  
  4566. traiterJubilaires();
  4567. traiterNouvelles();
  4568.  
  4569. if (isHTTPS) {
  4570. // test si les certificats raistlin ont été acceptés
  4571. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  4572. var infoit = MY_getValue(numTroll+'.INFOSIT');
  4573. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  4574. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  4575. }
  4576. }
  4577.  
  4578. displayScriptTime();
  4579. }
  4580.  
  4581. /*********************************************************************************
  4582. * This file is part of Mountyzilla. *
  4583. * *
  4584. * Mountyzilla is free software; you can redistribute it and/or modify *
  4585. * it under the terms of the GNU General Public License as published by *
  4586. * the Free Software Foundation; either version 2 of the License, or *
  4587. * (at your option) any later version. *
  4588. * *
  4589. * Mountyzilla is distributed in the hope that it will be useful, *
  4590. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4591. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4592. * GNU General Public License for more details. *
  4593. * *
  4594. * You should have received a copy of the GNU General Public License *
  4595. * along with Mountyzilla; if not, write to the Free Software *
  4596. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4597. *********************************************************************************/
  4598.  
  4599. // x~x tabcompo
  4600.  
  4601. var popup;
  4602.  
  4603. function initPopupTabcompo() {
  4604. popup = document.createElement('div');
  4605. popup.setAttribute('id', 'popup');
  4606. popup.setAttribute('class', 'mh_textbox');
  4607. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  4608. + 'display: inline; z-index: 3; max-width: 400px;');
  4609. document.body.appendChild(popup);
  4610. }
  4611.  
  4612. function showPopup(evt) {
  4613. var texte = this.getAttribute("texteinfo");
  4614. popup.innerHTML = texte;
  4615. popup.style.left = evt.pageX + 15 + 'px';
  4616. popup.style.top = evt.pageY + 'px';
  4617. popup.style.visibility = "visible";
  4618. }
  4619.  
  4620. // roule 16/03/2016, existe déjà ailleurs
  4621. // function hidePopup() {
  4622. // popup.style.visibility = 'hidden';
  4623. // }
  4624.  
  4625. function createPopupImage(url, text)
  4626. {
  4627. var img = document.createElement('img');
  4628. img.setAttribute('src',url);
  4629. img.setAttribute('align','ABSMIDDLE');
  4630. img.setAttribute("texteinfo",text);
  4631. img.addEventListener("mouseover", showPopup,true);
  4632. img.addEventListener("mouseout", hidePopup,true);
  4633. return img;
  4634. }
  4635.  
  4636. function formateTexte(texte)
  4637. {
  4638. texte = texte.replace(/\n/g,"<br/>");
  4639. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4640. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4641. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4642. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4643. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4644. return texte;
  4645. }
  4646.  
  4647. function arrondi(x) {
  4648. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  4649. }
  4650.  
  4651. function traiteMinerai() {
  4652. if (currentURL.indexOf("as_type=Divers")==-1) return;
  4653. try {
  4654. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  4655. +" and contains(./tr/th/text(),'Minerai')]",
  4656. document, null, 9, null).singleNodeValue;
  4657. node = node.nextSibling.nextSibling;
  4658. }
  4659. catch(e) {return;}
  4660. var trlist = document.evaluate('./tr', node, null, 7, null);
  4661. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  4662. var node = trlist.snapshotItem(i);
  4663. var nature = node.childNodes[5].textContent;
  4664. var caracs = node.childNodes[7].textContent;
  4665. var taille = caracs.match(/\d+/)[0];
  4666. var coef = 1;
  4667. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  4668. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  4669. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  4670. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  4671. if (nature.indexOf('Mithril')!=-1) {
  4672. coef = 0.2*coef;
  4673. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  4674. }
  4675. else {
  4676. coef = 0.75*coef+1.25;
  4677. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  4678. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  4679. }
  4680. }
  4681. }
  4682.  
  4683. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  4684. function treateComposants() {
  4685. if (currentURL.indexOf("as_type=Compo")==-1) return;
  4686. //On récupère les composants
  4687. var nodes = document.evaluate(
  4688. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4689. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4690. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  4691. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4692. if (nodes.snapshotLength == 0) {
  4693. //window.console.log('[MZ] treateComposants DOWN');
  4694. return;
  4695. }
  4696. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  4697.  
  4698. var texte = "";
  4699. for (var i = 0; i < nodes.snapshotLength; i++) {
  4700. var n1 = nodes.snapshotItem(i).childNodes[1];
  4701. var n3 = nodes.snapshotItem(i).childNodes[3];
  4702. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4703. var prix = n3.childNodes[0].nodeValue;
  4704. if (!prix)
  4705. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4706. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4707. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4708. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4709. + prix.replace(/\n/g, '') + "\n";
  4710. }
  4711.  
  4712. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4713. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4714. var id_taniere = c.snapshotItem(0).nodeValue;
  4715. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  4716.  
  4717. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4718. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  4719. if (form)
  4720. {
  4721. if(document.getElementsByTagName('form').length>0)
  4722. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4723. else
  4724. {
  4725. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4726. insertBefore(thisP, form);
  4727. }
  4728. }
  4729. }
  4730.  
  4731. function treateAllComposants() {
  4732. if(currentURL.indexOf("as_type=Compo")==-1) return;
  4733. //On récupère les composants
  4734. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  4735. document, null, 0, null ).numberValue;
  4736. var c = (categ == 0 ? 3 : 4);
  4737. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  4738. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  4739. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  4740. + "td["+c+"]/text()[1] = '\240-\240' "
  4741. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  4742. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  4743. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  4744. + "and td[1]/img/@alt = 'Identifié']",
  4745. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4746. if (nodes.snapshotLength == 0) {
  4747. // window.alert('treateAllComposants DOWN');
  4748. return;
  4749. }
  4750.  
  4751. var texte = "";
  4752. for (var i = 0; i < nodes.snapshotLength; i++) {
  4753. var n1 = nodes.snapshotItem(i).childNodes[1];
  4754. var n3 = nodes.snapshotItem(i).childNodes[3];
  4755. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4756. var prix = n3.childNodes[0].nodeValue;
  4757. if (!prix)
  4758. {
  4759. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  4760. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4761. }
  4762. else
  4763. {
  4764. prix= prix.replace(/[\240 ]/g, "");
  4765. if(prix=="-")
  4766. prix=null;
  4767. }
  4768. if(prix)
  4769. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4770. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4771. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4772. + prix.replace(/\n/g, '') + "\n";
  4773. else
  4774. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4775. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4776. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  4777. }
  4778.  
  4779. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4780. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4781. var id_taniere = c.snapshotItem(0).nodeValue;
  4782. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  4783.  
  4784. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4785. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  4786. if (form)
  4787. {
  4788. if(document.getElementsByTagName('form').length>0)
  4789. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4790. else
  4791. {
  4792. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4793. insertBefore(thisP, form);
  4794. }
  4795. }
  4796. }
  4797.  
  4798. function treateEM()
  4799. {
  4800. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  4801. if(currentURL.indexOf("as_type=Compo")==-1)
  4802. return false;
  4803. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  4804. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  4805. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4806. if (nodes.snapshotLength == 0)
  4807. return false;
  4808. for (var i = 0; i < nodes.snapshotLength; i++) {
  4809. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  4810. var link = desc[2].firstChild ;
  4811. var nomCompoTotal = desc[2].textContent ;
  4812. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4813. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4814. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  4815. var locqual = desc[3].textContent ;
  4816. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  4817. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  4818. if(isEM(nomMonstre).length>0)
  4819. {
  4820. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  4821. if(infos.length>0)
  4822. {
  4823. var shortDescr = "Variable";
  4824. var bold = 0;
  4825. if(infos != "Composant variable")
  4826. {
  4827. shortDescr = infos.substring(0,infos.indexOf(" "));
  4828. if(parseInt(shortDescr)>=0)
  4829. bold=1;
  4830. }
  4831. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  4832. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  4833. }
  4834. }
  4835. }
  4836. }
  4837.  
  4838. function treateChampi() {
  4839. if (currentURL.indexOf('as_type=Champi')==-1)
  4840. return false;
  4841. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  4842. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4843. if (nodes.snapshotLength == 0)
  4844. return false;
  4845.  
  4846. for (var i = 0; i < nodes.snapshotLength; i++) {
  4847. var node = nodes.snapshotItem(i);
  4848. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  4849. if (moisChampi[nomChampi])
  4850. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  4851. }
  4852. }
  4853.  
  4854. function treateEnchant()
  4855. {
  4856. if(currentURL.indexOf("as_type=Compo")==-1)
  4857. return false;
  4858. try
  4859. {
  4860. if(!listeMonstreEnchantement)
  4861. computeCompoEnchantement();
  4862. var nodes = document.evaluate(
  4863. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4864. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4865. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4866. if (nodes.snapshotLength == 0)
  4867. return false;
  4868. var urlImg = URL_MZimg + "enchant.png";
  4869. for (var i = 0; i < nodes.snapshotLength; i++) {
  4870. var link = nodes.snapshotItem(i);
  4871. var nomCompoTotal = link.firstChild.nodeValue;
  4872. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4873. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4874. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  4875. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  4876. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  4877. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  4878. if(isEnchant(nomMonstre).length>0)
  4879. {
  4880. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  4881. if(infos.length>0)
  4882. {
  4883. link.parentNode.appendChild(createImage(urlImg,infos));
  4884. }
  4885. }
  4886. }
  4887. }
  4888. catch(e)
  4889. {
  4890. window.alert(e);
  4891. }
  4892. }
  4893.  
  4894. function treateEquipEnchant()
  4895. {
  4896. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  4897. return false;
  4898. initPopupTabcompo();
  4899. computeEnchantementEquipement(createPopupImage,formateTexte);
  4900. }
  4901.  
  4902. function do_tancompo() {
  4903. start_script();
  4904.  
  4905. treateAllComposants();
  4906. treateComposants();
  4907. traiteMinerai();
  4908. if (MY_getValue('NOINFOEM')!='true') {
  4909. treateChampi();
  4910. treateEM();
  4911. }
  4912. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  4913. treateEnchant();
  4914. treateEquipEnchant();
  4915. }
  4916.  
  4917. displayScriptTime();
  4918. }
  4919.  
  4920. /*******************************************************************************
  4921. * This file is part of Mountyzilla. *
  4922. * *
  4923. * Mountyzilla is free software; you can redistribute it and/or modify *
  4924. * it under the terms of the GNU General Public License as published by *
  4925. * the Free Software Foundation; either version 2 of the License, or *
  4926. * (at your option) any later version. *
  4927. * *
  4928. * Mountyzilla is distributed in the hope that it will be useful, *
  4929. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4930. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4931. * GNU General Public License for more details. *
  4932. * *
  4933. * You should have received a copy of the GNU General Public License *
  4934. * along with Mountyzilla; if not, write to the Free Software *
  4935. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4936. *******************************************************************************/
  4937.  
  4938. // x~x pjview
  4939.  
  4940. /* TODO
  4941. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  4942. */
  4943.  
  4944. // Bulle d'infos
  4945. var DivInfo;
  4946. // Booléen stockant l'état de freezing de la bulle
  4947. var freezed = false;
  4948.  
  4949. // liste du matos
  4950. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  4951. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4952. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  4953. var mh_caracs = {
  4954. 'anneau de protection':
  4955. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  4956. "armure d'anneaux":
  4957. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  4958. 'armure de bois':
  4959. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  4960. 'armure de cuir':
  4961. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  4962. 'armure de peaux':
  4963. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  4964. 'armure de pierre':
  4965. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  4966. 'armure de plates':
  4967. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  4968. 'baton lesté':
  4969. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4970. 'bâtons de parade':
  4971. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4972. 'bottes':
  4973. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  4974. 'bouclier à pointes':
  4975. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4976. 'boulet et chaîne':
  4977. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  4978. 'cagoule':
  4979. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  4980. 'casque à cornes':
  4981. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4982. 'casque à pointes':
  4983. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  4984. 'casque en cuir':
  4985. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  4986. 'casque en métal':
  4987. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  4988. 'chaîne cloutée':
  4989. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  4990. 'chapeau pointu':
  4991. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  4992. 'collier de dents':
  4993. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  4994. 'collier de pierre':
  4995. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  4996. 'collier à pointes':
  4997. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  4998. 'cotte de mailles':
  4999. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5000. 'couronne de cristal':
  5001. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5002. "couronne d'obsidienne":
  5003. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5004. "coutelas d'obsidienne":
  5005. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5006. 'coutelas en os':
  5007. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5008. 'crochet':
  5009. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5010. 'cuir bouilli':
  5011. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5012. "cuirasse d'ossements":
  5013. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5014. "cuirasse d'écailles":
  5015. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5016. 'culotte en cuir':
  5017. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5018. 'dague':
  5019. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5020. 'epée courte':
  5021. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5022. 'epée longue':
  5023. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5024. 'espadon':
  5025. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5026. 'fouet':
  5027. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5028. 'fourrures':
  5029. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5030. 'gantelet':
  5031. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5032. 'gorgeron en cuir':
  5033. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5034. 'gorgeron en métal':
  5035. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5036. 'gourdin':
  5037. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5038. 'gourdin clouté':
  5039. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5040. 'grimoire':
  5041. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5042. "gros'porte":
  5043. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5044. 'grosse racine':
  5045. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5046. 'grosse stalagmite':
  5047. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5048. 'hache de bataille':
  5049. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5050. 'hache de guerre en os':
  5051. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5052. 'hache de guerre en pierre':
  5053. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5054. "hache à deux mains d'obsidienne":
  5055. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5056. 'hallebarde':
  5057. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5058. "haubert d'écailles":
  5059. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5060. 'haubert de mailles':
  5061. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5062. 'heaume':
  5063. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5064. 'jambières en cuir':
  5065. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5066. 'jambières en fourrure':
  5067. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5068. 'jambières en maille':
  5069. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5070. 'jambières en métal':
  5071. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5072. 'jambières en os':
  5073. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5074. "lame d'obsidienne":
  5075. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5076. 'lame en os':
  5077. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5078. 'lame en pierre':
  5079. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5080. 'lorgnons':
  5081. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5082. 'machette':
  5083. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5084. "masse d'arme":
  5085. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5086. 'pagne de mailles':
  5087. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5088. 'pagne en cuir':
  5089. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5090. 'robe de mage':
  5091. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5092. 'rondache en bois':
  5093. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5094. 'rondache en métal':
  5095. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5096. 'sandales':
  5097. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5098. 'souliers dorés':
  5099. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5100. "talisman d'obsidienne":
  5101. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5102. 'talisman de pierre':
  5103. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5104. 'targe':
  5105. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5106. 'torche':
  5107. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5108. 'torque de pierre':
  5109. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5110. 'tunique':
  5111. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5112. "tunique d'écailles":
  5113. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5114. 'turban':
  5115. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5116. }
  5117.  
  5118. // liste des templates
  5119. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5120. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5121. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5122. var mh_templates = {
  5123. 'de Feu':
  5124. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5125. 'de Résistance':
  5126. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5127. "de l'Aigle":
  5128. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5129. 'de la Salamandre':
  5130. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5131. 'des Cyclopes':
  5132. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5133. 'des Enragés':
  5134. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5135. 'des Tortues':
  5136. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5137. 'des Vampires':
  5138. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5139. 'du Glacier':
  5140. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5141. 'du Rat':
  5142. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5143. 'du Roc':
  5144. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5145. 'du Temps':
  5146. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5147. 'du Vent':
  5148. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5149. 'en Mithril':
  5150. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5151. 'des Anciens':
  5152. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5153. 'des Champions':
  5154. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5155. 'des Duellistes':
  5156. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5157. 'de la Terre':
  5158. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5159. "de l'Orage":
  5160. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5161. "de l'Ours":
  5162. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5163. 'des Béhémoths':
  5164. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5165. 'des Mages':
  5166. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5167. 'du Pic':
  5168. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5169. 'du Sable':
  5170. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5171. 'acéré':
  5172. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5173. 'acérée':
  5174. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5175. 'équilibré':
  5176. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5177. 'équilibrée':
  5178. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5179. 'léger':
  5180. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5181. 'légère':
  5182. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5183. 'renforcé':
  5184. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5185. 'renforcée':
  5186. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5187. 'robuste':
  5188. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5189. }
  5190.  
  5191. function clone(arr) {
  5192. // Clonage rapide
  5193. return arr.slice(0);
  5194. }
  5195.  
  5196. function addArray(arr1,arr2) {
  5197. // Somme matricielle
  5198. var res = clone(arr1);
  5199. for(i=res.length-1 ; i>=0 ; i--) {
  5200. res[i] += arr2[i];
  5201. }
  5202. return res;
  5203. }
  5204.  
  5205. function getTemplates(nomItem) {
  5206. // Déstructure le nom de l'item en array [nom, template1, ...]
  5207. var tempFound = true;
  5208. var str = nomItem.trim();
  5209. var arr = [];
  5210. while(tempFound) {
  5211. tempFound = false;
  5212. for(var temp in mh_templates) {
  5213. // on teste la fin du nom contre chaque template
  5214. if(str.slice(-temp.length)!=temp) { continue; }
  5215. tempFound = true;
  5216. str = str.slice(0,-temp.length-1);
  5217. arr.unshift(temp);
  5218. if(str.slice(-3)==' et') {
  5219. str = str.slice(0,-3);
  5220. }
  5221. }
  5222. }
  5223. arr.unshift(str);
  5224. return arr;
  5225. }
  5226.  
  5227. function addMithril(arrayCaracs,typeItem) {
  5228. // Ajoute l'effet du Mithril sur les caracs
  5229. if(typeItem=='arme') {
  5230. if(arrayCaracs[0]<0) {
  5231. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5232. }
  5233. }
  5234. else {
  5235. if(arrayCaracs[4]<0) {
  5236. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5237. }
  5238. }
  5239. arrayCaracs[15] /= 2;
  5240. arrayCaracs[16] /= 2;
  5241. return arrayCaracs;
  5242. }
  5243.  
  5244. function addRenfort(arrayCaracs,template) {
  5245. // Ajoute l'effet des pseudo-templates sur les caracs
  5246. // S'applique APRÈS le mithril
  5247. // WARNING - Cette formule n'a rien d'officiel, gare !
  5248. var coef = 0;
  5249. if(/^lég[e,è]re?$/.test(template)) {
  5250. coef = -1;
  5251. }
  5252. else if(/^renforcée?$/.test(template)
  5253. || template==='robuste') {
  5254. coef = 1;
  5255. }
  5256. if(coef) {
  5257. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5258. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5259. }
  5260. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5261. return arrayCaracs;
  5262. }
  5263.  
  5264. function getCaracs(item) {
  5265. // Calcule les caractéristiques de l'item
  5266. var templates = getTemplates(item);
  5267. if(!mh_caracs[templates[0]]) {
  5268. // Si l'item est inconnu
  5269. return [];
  5270. }
  5271. var caracs = clone(mh_caracs[templates[0]]);
  5272. var typeItem = caracs[0];
  5273. caracs.shift();
  5274. templates.shift();
  5275. if(templates[templates.length-1]=='en Mithril') {
  5276. caracs = addMithril(caracs,typeItem);
  5277. templates.pop();
  5278. }
  5279. if(/^acérée?$/.test(templates[0])
  5280. || /^équilibrée?$/.test(templates[0])
  5281. || /^lég[e,è]re?$/.test(templates[0])
  5282. || /^renforcée?$/.test(templates[0])
  5283. || templates[0]=='robuste') {
  5284. caracs = addRenfort(caracs,templates[0]);
  5285. templates.shift();
  5286. }
  5287. for(var i=templates.length-1 ; i>=0 ; i--) {
  5288. caracs = addArray(caracs,mh_templates[templates[i]]);
  5289. }
  5290. return caracs;
  5291. }
  5292.  
  5293. function getLine(tab) {
  5294. // Préparation de la ligne à afficher lors d'un mouseover
  5295. var str = '';
  5296. if(tab[0]!=0 || tab[1]!=0) {
  5297. str += '<b>Att : </b>'+aff(tab[0]);
  5298. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5299. str += ' | ';
  5300. }
  5301. if(tab[4]!=0) {
  5302. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5303. }
  5304. if(tab[2]!=0 || tab[3]!=0) {
  5305. str += '<b>Deg : </b>'+aff(tab[2]);
  5306. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5307. str += ' | ';
  5308. }
  5309. if(tab[8]!=0) {
  5310. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5311. }
  5312. if(tab[7]!=0) {
  5313. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5314. }
  5315. if(tab[5]!=0 || tab[6]!=0) {
  5316. str += '<b>Arm : </b>'+aff(tab[5]);
  5317. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5318. str += ' | ';
  5319. }
  5320. if(tab[9]!=0 || tab[10]!=0) {
  5321. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5322. if(tab[9]!=tab[10]) {
  5323. str += '/'+aff(tab[10])+'%';
  5324. }
  5325. str += ' | ';
  5326. }
  5327. if(tab[11]!=0 || tab[12]!=0) {
  5328. str += '<b>MM : </b>'+aff(tab[11])+'%';
  5329. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  5330. str += ' | ';
  5331. }
  5332. if(tab[13]!=0) {
  5333. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5334. }
  5335. if(tab[14]!=0) {
  5336. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5337. }
  5338. str += '<b>Poids : </b>'+tab[15]+' min';
  5339. if(tab[15]!=tab[16]) {
  5340. str += ' / '+tab[16]+' min';
  5341. }
  5342. return str;
  5343. }
  5344.  
  5345. function toolTipInit() {
  5346. DivInfo = document.createElement('div');
  5347. DivInfo.id = 'infosVue';
  5348. DivInfo.className = 'mh_textbox';
  5349. DivInfo.style =
  5350. 'position: absolute;'
  5351. +'border: 1px solid #000000;'
  5352. +'visibility:hidden;'
  5353. +'display:inline;'
  5354. +'z-index:99;';
  5355. document.body.appendChild(DivInfo);
  5356. document.onmousemove = getXY;
  5357. document.onclick = changeFreezeStatus;
  5358. }
  5359.  
  5360. function getXY(evt) {
  5361. if(!freezed && DivInfo.style.visibility=='visible') {
  5362. DivInfo.style.left = evt.pageX+'px';
  5363. DivInfo.style.top = evt.pageY+10+'px';
  5364. }
  5365. }
  5366.  
  5367. function changeFreezeStatus() {
  5368. if(DivInfo.style.visibility=='visible') {
  5369. freezed = !freezed;
  5370. if(!freezed) { hideInfos(); }
  5371. }
  5372. }
  5373.  
  5374. function showInfos() {
  5375. if(freezed) { return; }
  5376. var currentInfos = this.infos;
  5377. DivInfo.innerHTML = currentInfos;
  5378. DivInfo.style.visibility = 'visible';
  5379. }
  5380.  
  5381. function hideInfos() {
  5382. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  5383. }
  5384.  
  5385. function treateEquipement() {
  5386. // Extrait les données du matos et réinjecte les infos déduites
  5387. if(MY_getValue('INFOCARAC')=='false') { return; }
  5388. var faireLigne = false;
  5389. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  5390. var nodes = document.evaluate(
  5391. "//td/b[text()='Equipement Utilisé']/../../"
  5392. +"td[2]/img[contains(@src,bullet)]",
  5393. document, null, 7, null);
  5394. if(nodes.snapshotLength>0) {
  5395. // Si CSS de base
  5396. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5397. var node = nodes.snapshotItem(i);
  5398. var next = node.nextSibling;
  5399. var nnext = next.nextSibling;
  5400. var nom = next.nodeValue.toLowerCase();
  5401. if(nnext.childNodes.length==1) {
  5402. nom += nnext.firstChild.nodeValue;
  5403. }
  5404. nom = nom.trim();
  5405. // gestion winpostrophe
  5406. var c = String.fromCharCode(180);
  5407. while(nom.indexOf(c)!=-1) {
  5408. nom = nom.replace(c,"'");
  5409. }
  5410. var arr = getCaracs(nom);
  5411. if(arr.length>0) {
  5412. faireLigne = true;
  5413. caracs = addArray(caracs,arr);
  5414. var span = document.createElement('span');
  5415. span.appendChild(next);
  5416. span.appendChild(nnext);
  5417. span.infos = getLine(arr);
  5418. span.onmouseover = showInfos;
  5419. span.onmouseout = hideInfos;
  5420. insertBefore(node.nextSibling,span);
  5421. }
  5422. }
  5423. if(faireLigne) {
  5424. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  5425. document, null, 9, null).singleNodeValue;
  5426. node.infos = getLine(caracs);
  5427. node.onmouseover = showInfos;
  5428. node.onmouseout = hideInfos;
  5429. }
  5430. }
  5431. else {
  5432. // Si CSS avancée
  5433. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  5434. document, null, 7, null);
  5435. if(nodes.snapshotLength>0) {
  5436. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5437. var node = nodes.snapshotItem(i);
  5438. var nom = node.firstChild.nodeValue.toLowerCase();
  5439. if(node.childNodes.length>1) {
  5440. nom += node.childNodes[1].firstChild.nodeValue;
  5441. }
  5442. nom = nom.trim();
  5443. // gestion winpostrophe
  5444. var c = String.fromCharCode(180);
  5445. while(nom.indexOf(c)!=-1) {
  5446. nom = nom.replace(c,"'");
  5447. }
  5448. var arr = getCaracs(nom);
  5449. if(arr.length!=0) {
  5450. caracs = addArray(caracs,arr);
  5451. node.infos = getLine(arr);
  5452. node.onmouseover = showInfos;
  5453. node.onmouseout = hideInfos;
  5454. }
  5455. }
  5456. var nodes = document.evaluate("//dt[@class='equipement']",
  5457. document, null, 7, null);
  5458. var node = nodes.snapshotItem(0);
  5459. node.infos = getLine(caracs);
  5460. node.onmouseover = showInfos;
  5461. node.onmouseout = hideInfos;
  5462. }
  5463. }
  5464. }
  5465.  
  5466. function do_pjview() {
  5467. treateEquipement();
  5468. toolTipInit();
  5469. }
  5470.  
  5471. /*******************************************************************************
  5472. * This file is part of Mountyzilla. *
  5473. * *
  5474. * Mountyzilla is free software; you can redistribute it and/or modify *
  5475. * it under the terms of the GNU General Public License as published by *
  5476. * the Free Software Foundation; either version 2 of the License, or *
  5477. * (at your option) any later version. *
  5478. * *
  5479. * Mountyzilla is distributed in the hope that it will be useful, *
  5480. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5481. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5482. * GNU General Public License for more details. *
  5483. * *
  5484. * You should have received a copy of the GNU General Public License *
  5485. * along with Mountyzilla; if not, write to the Free Software *
  5486. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5487. *******************************************************************************/
  5488.  
  5489. // x~x option
  5490.  
  5491. /* TODO
  5492. * Passer le HTML injecté aux conventions HTML5
  5493. */
  5494.  
  5495.  
  5496. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  5497.  
  5498. function saveITData() {
  5499. var IT = document.getElementById('itSelect').value;
  5500. if(IT=='bricol') {
  5501. var system = document.getElementById('urlbricol').value;
  5502. var login = document.getElementById('loginbricol').value;
  5503. var pass = document.getElementById('passbricol').value;
  5504. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  5505. if(system && login) {
  5506. if (pass) {
  5507. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  5508. MY_setValue(numTroll+'.INFOSIT', v);
  5509. //window.console.log('v=' + v);
  5510. } else {
  5511. // vérif que rien n'a changé
  5512. var str = MY_getValue(numTroll+'.INFOSIT');
  5513. if(str) {
  5514. var arr = str.split('$');
  5515. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  5516. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  5517. }
  5518. }
  5519. }
  5520. }
  5521. }
  5522. else {
  5523. MY_removeValue(numTroll+'.INFOSIT');
  5524. }
  5525. }
  5526.  
  5527. function saveLinks() {
  5528. var numLinks = document.getElementById('linksBody').childNodes.length;
  5529. var data=[ [] ];
  5530. /* Récupération et tri des liens */
  5531. for(var i=1 ; i<=numLinks ; i++) {
  5532. MY_removeValue('URL'+i);
  5533. MY_removeValue('URL'+i+'.nom');
  5534. MY_removeValue('URL'+i+'.ico');
  5535. var url = document.getElementById('url'+i).value;
  5536. var nom = document.getElementById('nom'+i).value;
  5537. var ico = document.getElementById('ico'+i).value;
  5538. if(url && (nom || ico) ) {
  5539. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5540. }
  5541. }
  5542. /* Sauvegarde */
  5543. for(var i=1 ; i<data.length ; i++) {
  5544. MY_setValue('URL'+i,data[i][0]);
  5545. MY_setValue('URL'+i+'.nom',data[i][1]);
  5546. MY_setValue('URL'+i+'.ico',data[i][2]);
  5547. }
  5548. }
  5549.  
  5550. function saveAll() {
  5551. var urlIco = document.getElementById('icoMenuIco').value;
  5552. if(urlIco) {
  5553. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5554. }
  5555. else {
  5556. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5557. document.getElementById('icoMenuIco').value = '';
  5558. }
  5559. saveLinks();
  5560. refreshLinks();
  5561. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5562. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5563. if(maxcdm) {
  5564. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5565. }
  5566. else {
  5567. MY_removeValue(numTroll+'.MAXCDM');
  5568. document.getElementById('maxcdm').value = '';
  5569. }
  5570.  
  5571. MY_setValue('NOINFOEM',
  5572. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5573. // Pourquoi Tilk stockait-il tout en str ?
  5574. // -> parce que les booléens c'est foireux (vérifié)
  5575. MY_setValue(numTroll+'.USECSS',
  5576. document.getElementById('usecss').checked ? 'true':'false');
  5577. MY_setValue('INFOCARAC',
  5578. document.getElementById('infocarac').checked ? 'true' : 'false');
  5579. //MY_setValue(numTroll+'.SEND_IDT',
  5580. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  5581. // Fonctionnalité désactivée
  5582.  
  5583. MY_setValue(numTroll+'.AUTOCDM',
  5584. document.getElementById('autoCdM').checked ? 'true' : 'false');
  5585. MY_setValue('VUECARAC',
  5586. document.getElementById('vueCarac').checked ? 'true' : 'false');
  5587. MY_setValue('CONFIRMEDECALAGE',
  5588. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  5589.  
  5590. saveITData();
  5591. var bouton = document.getElementById('saveAll');
  5592. bouton.value = (bouton.value=='Sauvegardé !') ?
  5593. 'Re-sauvegardé !' : 'Sauvegardé !';
  5594. }
  5595.  
  5596.  
  5597. /*-[functions]----------------- EventListeners -------------------------------*/
  5598.  
  5599. function onChangeIT() {
  5600. var IT = document.getElementById('itSelect').value;
  5601. var itBody = document.getElementById('itBody');
  5602. itBody.innerHTML = '';
  5603. if(IT=='bricol') {
  5604. var tr = appendTr(itBody,'mh_tdpage')
  5605. var td = appendTd(tr);
  5606. var str = MY_getValue(numTroll+'.INFOSIT');
  5607. //window.console.log('onChangeIT str=' + str);
  5608. if(str) {
  5609. var arr = str.split('$');
  5610. var system = arr[1];
  5611. var login = arr[2];
  5612. var affhv = arr[4];
  5613. }
  5614. appendText(td,'Nom du système : ');
  5615. appendTextbox(td,'text','urlbricol',20,50,system);
  5616. td = appendTd(tr);
  5617. appendText(td,'Login du compte : ');
  5618. appendTextbox(td,'text','loginbricol',20,50,login);
  5619. td = appendTd(tr);
  5620. appendText(td,'Mot de passe du compte : ');
  5621. appendTextbox(td,'password','passbricol',20,50);
  5622. td = appendTd(tr);
  5623. appendText(td,'Affichage des Trõlls hors vue : ');
  5624. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  5625. appendCheckBox(td,'affhvbricol', (affhv>0));
  5626. }
  5627. }
  5628.  
  5629. function refreshLinks() {
  5630. document.getElementById('linksBody').innerHTML = '';
  5631. var anotherURL = MY_getValue('URL1');
  5632. if(!anotherURL) { addLinkField(); }
  5633. var i=1;
  5634. while(anotherURL && i<99) {
  5635. addLinkField(i,anotherURL,
  5636. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  5637. i++;
  5638. anotherURL = MY_getValue('URL'+i);
  5639. }
  5640. }
  5641.  
  5642. function addLinkField(i,url,nom,ico) {
  5643. var linksBody = document.getElementById('linksBody');
  5644. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  5645. var tr = appendTr(linksBody);
  5646. var td = appendTdCenter(tr);
  5647. appendText(td,'Lien '+i+' : ');
  5648. appendTextbox(td,'text','url'+i,40,150,url);
  5649. td = appendTdCenter(tr);
  5650. appendText(td,'Nom : ');
  5651. appendTextbox(td,'text','nom'+i,20,150,nom);
  5652. td = appendTdCenter(tr);
  5653. appendText(td,'Icône : ');
  5654. appendTextbox(td,'text','ico'+i,40,150,ico);
  5655. }
  5656.  
  5657. function removeLinkField() {
  5658. var linksBody = document.getElementById('linksBody');
  5659. var i = linksBody.childNodes.length;
  5660. MY_removeValue('URL'+i);
  5661. MY_removeValue('URL'+i+'.nom');
  5662. MY_removeValue('URL'+i+'.ico');
  5663. linksBody.removeChild(linksBody.lastChild);
  5664. if(linksBody.childNodes.length==0) { addLinkField(); }
  5665. }
  5666.  
  5667. function resetMainIco() {
  5668. document.getElementById('icoMenuIco').value=
  5669. URL_MZimg + 'mz_logo_small.png';
  5670. }
  5671.  
  5672.  
  5673. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  5674.  
  5675. function insertTitle(next,txt) {
  5676. var div = document.createElement('div');
  5677. div.className = 'titre2';
  5678. appendText(div,txt);
  5679. insertBefore(next,div);
  5680. return div;
  5681. }
  5682.  
  5683. function insertMainTable(next) {
  5684. var table = document.createElement('table');
  5685. table.width = '98%';
  5686. table.border = 0;
  5687. table.align = 'center';
  5688. table.cellPadding = 2;
  5689. table.cellSpacing = 1;
  5690. table.className = 'mh_tdborder';
  5691. var tbody = document.createElement('tbody');
  5692. table.appendChild(tbody);
  5693. insertBefore(next,table);
  5694. return tbody;
  5695. }
  5696.  
  5697. function appendSubTable(node) {
  5698. var table = document.createElement('table');
  5699. table.width = '100%';
  5700. var tbody = document.createElement('tbody');
  5701. table.appendChild(tbody);
  5702. node.appendChild(table);
  5703. return tbody;
  5704. }
  5705.  
  5706. function insertOptionTable(insertPt) {
  5707. var mainBody = insertMainTable(insertPt);
  5708. /* Liens dans le Menu */
  5709. var tr = appendTr(mainBody,'mh_tdtitre');
  5710. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  5711. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5712. appendText(td,'Icône du Menu: ');
  5713. var url = MY_getValue(numTroll+'.ICOMENU');
  5714. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  5715. url = URL_MZimg + 'mz_logo_small.png';
  5716. }
  5717. appendTextbox(td,'text','icoMenuIco',50,200,url);
  5718. appendButton(td,'Réinitialiser',resetMainIco);
  5719. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5720. var tbody = appendSubTable(td);
  5721. tbody.id = 'linksBody';
  5722. refreshLinks();
  5723. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  5724. appendButton(td,'Ajouter',addLinkField);
  5725. appendButton(td,'Supprimer',removeLinkField);
  5726. /* Options de la Vue : vue externe, nb de CdM, etc */
  5727. tr = appendTr(mainBody,'mh_tdtitre');
  5728. appendTdText(tr,'Options de la Vue :',true);
  5729. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5730. tbody = appendSubTable(td);
  5731. tr = appendTr(tbody);
  5732. td = appendTdText(tr,'Vue externe : ');
  5733. var select = document.createElement('select');
  5734. select.id = 'vueext';
  5735. td.appendChild(select);
  5736. var listeVues2D = [
  5737. 'Bricol\' Vue',
  5738. 'Vue du CCM',
  5739. 'Vue Gloumfs 2D',
  5740. 'Vue Gloumfs 3D',
  5741. 'Grouky Vue!'
  5742. ];
  5743. for(var i=0 ; i<listeVues2D.length ; i++) {
  5744. appendOption(select,listeVues2D[i],listeVues2D[i]);
  5745. }
  5746. if(MY_getValue('VUEEXT')) {
  5747. select.value = MY_getValue('VUEEXT');
  5748. }
  5749. td = appendTd(tr);
  5750. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  5751. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  5752. tr = appendTr(tbody);
  5753. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  5754. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  5755. td = appendTd(tr);
  5756. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  5757. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  5758. /* Interface Tactique */
  5759. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5760. appendText(td,'Interface Tactique : ',true);
  5761. select = document.createElement('select');
  5762. select.id = 'itSelect';
  5763. appendOption(select,'none','Aucune');
  5764. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  5765. // seule interface supportée !
  5766. td.appendChild(select);
  5767. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5768. tbody = appendSubTable(td);
  5769. tbody.id = 'itBody';
  5770. select.onchange = onChangeIT;
  5771. var str = MY_getValue(numTroll+'.INFOSIT');
  5772. if(str) {
  5773. select.value = str.slice(0,str.indexOf('$'));
  5774. onChangeIT();
  5775. }
  5776. /* Options diverses */
  5777. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5778. appendText(td,'Options diverses :',true);
  5779. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5780. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  5781. appendText(td,
  5782. ' Afficher les caractéristiques des équipements des autres Trõlls');
  5783. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5784. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  5785. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  5786. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5787. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  5788. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  5789. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5790. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  5791. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  5792. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5793. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  5794. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  5795. /* Bouton SaveAll */
  5796. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  5797. input = appendButton(td,'Sauvegarder',saveAll);
  5798. input.id = 'saveAll';
  5799. }
  5800.  
  5801. function insertCreditsTable(insertPt) {
  5802. var tbody = insertMainTable(insertPt);
  5803. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  5804. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  5805. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  5806.  
  5807. var ul = document.createElement('ul');
  5808. td.appendChild(ul);
  5809. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  5810. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  5811. appendLI(ul,'Reivax (4234) pour les infos bulles');
  5812. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  5813. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  5814. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  5815. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  5816. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  5817. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  5818. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  5819. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  5820. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  5821. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  5822. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  5823. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  5824. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  5825. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  5826. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  5827. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  5828. }
  5829.  
  5830.  
  5831. /* [functions] Obsolètes */
  5832. function deleteEnchantement()
  5833. {
  5834. try
  5835. {
  5836. var idEquipement = this.getAttribute('name');
  5837. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  5838. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  5839. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  5840. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  5841. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  5842. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5843. var string = "";
  5844. for(var i=0;i<listeEquipement.length;i++)
  5845. {
  5846. if(listeEquipement[i]!=idEquipement)
  5847. if(string=="")
  5848. string = listeEquipement[i];
  5849. else
  5850. string += ";"+listeEquipement[i];
  5851. }
  5852. if(string=="")
  5853. {
  5854. MY_removeValue(numTroll+".enchantement.liste");
  5855. var table = this.parentNode.parentNode.parentNode.parentNode;
  5856. var parent = table.parentNode;
  5857. for(var i=0;i<parent.childNodes.length;i++)
  5858. {
  5859. if(parent.childNodes[i]==table)
  5860. {
  5861. parent.removeChild(parent.childNodes[i-1]);
  5862. parent.removeChild(parent.childNodes[i-1]);
  5863. parent.removeChild(parent.childNodes[i-1]);
  5864. break;
  5865. }
  5866. }
  5867. }
  5868. else
  5869. {
  5870. MY_getValue(numTroll+".enchantement.liste",string);
  5871. this.parentNode.parentNode.parentNode
  5872. .removeChild(this.parentNode.parentNode);
  5873. }
  5874. }
  5875. catch(e)
  5876. {
  5877. window.alert(e);
  5878. }
  5879. }
  5880. /* [functions] fin Obsolètes */
  5881.  
  5882. /*-[functions]---------------- Partie principale -----------------------------*/
  5883.  
  5884. function do_option() {
  5885. start_script(712);
  5886.  
  5887. // Pour cryptage des mdp IT
  5888. //appendNewScript(URL_tilk_js + 'md5.js'); // source intégré dans tout_MZ
  5889.  
  5890. var insertPoint = document.getElementById('footer1');
  5891. insertBefore(insertPoint,document.createElement('p'));
  5892. var ti = insertTitle(insertPoint,'Mountyzilla : Options');
  5893. ti.title = 'Version ' + GM_info.script.version;
  5894. insertOptionTable(insertPoint);
  5895. /* insertion enchantements ici
  5896. if(...)
  5897. insertEnchantementTable();
  5898. */
  5899. insertBefore(insertPoint,document.createElement('p'));
  5900. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  5901. ti.onclick = function (e) {
  5902. var evt = e || window.event;
  5903. if (evt.shiftKey) {
  5904. var oldDev = MY_getValue('MZ_dev');
  5905. if (oldDev) {
  5906. MY_removeValue('MZ_dev');
  5907. } else {
  5908. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  5909. MY_setValue('MZ_dev', 1);
  5910. }
  5911. document.location.href = document.location.href;
  5912. }
  5913. }
  5914. insertCreditsTable(insertPoint);
  5915. insertBefore(insertPoint,document.createElement('p'));
  5916.  
  5917. /* [zone] Obsolète ?? */
  5918. if(MY_getValue(numTroll+".enchantement.liste")
  5919. && MY_getValue(numTroll+".enchantement.liste")!="" )
  5920. {
  5921. insertTitle(insertPoint, 'Les Enchantements en cours');
  5922. table = document.createElement('table');
  5923. table.setAttribute('width', '98%');
  5924. table.setAttribute('border', '0');
  5925. table.setAttribute('align', 'center');
  5926. table.setAttribute('cellpadding', '2');
  5927. table.setAttribute('cellspacing', '1');
  5928. table.setAttribute('class', 'mh_tdborder');
  5929.  
  5930. tbody = document.createElement('tbody');
  5931. table.appendChild(tbody);
  5932. tr = appendTr(tbody, 'mh_tdtitre');
  5933. appendTdText(tr, 'Equipement',1);
  5934. appendTdText(tr, 'Composants',1);
  5935. appendTdText(tr, 'Enchanteur',1);
  5936. appendTdText(tr, 'Action',1);
  5937. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5938. for(var i=0;i<listeEquipement.length;i++)
  5939. {
  5940. try
  5941. {
  5942. var idEquipement = listeEquipement[i];
  5943. var nomEquipement = MY_getValue(numTroll+".enchantement."
  5944. +idEquipement+".objet");
  5945. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  5946. +idEquipement+".enchanteur").split(";");
  5947. var ul = document.createElement('UL');
  5948. for(var j=0;j<3;j++)
  5949. {
  5950. var infoComposant = MY_getValue(numTroll+".enchantement."
  5951. +idEquipement+".composant."+j).split(";");
  5952. var texte = infoComposant[4].replace("Ril ","Œil ");
  5953. for(var k=5;k<infoComposant.length;k++)
  5954. {
  5955. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  5956. }
  5957. li = appendLI(ul,texte);
  5958. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  5959. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  5960. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  5961. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  5962. string+= '<input type="hidden" name="q" value="min" />';
  5963. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  5964. 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>';
  5965.  
  5966. string+= '</form>';
  5967. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  5968. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  5969. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  5970. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  5971. li.innerHTML += string;
  5972. }
  5973. tr = appendTr(tbody, 'mh_tdpage');
  5974. td = appendTdText(tr, nomEquipement);
  5975. td.setAttribute('valign', 'center');
  5976. td = document.createElement('td');
  5977. td.appendChild(ul);
  5978. tr.appendChild(td);
  5979. td.setAttribute('valign', 'center');
  5980. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  5981. td.setAttribute('valign', 'center');
  5982. td = document.createElement('td');
  5983. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  5984. input.setAttribute('name', idEquipement);
  5985. tr.appendChild(td);
  5986. td.setAttribute('valign', 'center');
  5987. }
  5988. catch(e)
  5989. {
  5990. }
  5991. }
  5992. insertBefore(insertPoint, table);
  5993. insertBefore(insertPoint, document.createElement('p'));
  5994. }
  5995. /* [zone] fin Obsolète ?? */
  5996.  
  5997.  
  5998. displayScriptTime();
  5999. }
  6000.  
  6001. /*******************************************************************************
  6002. * This file is part of Mountyzilla. *
  6003. * *
  6004. * Mountyzilla is free software; you can redistribute it and/or modify *
  6005. * it under the terms of the GNU General Public License as published by *
  6006. * the Free Software Foundation; either version 2 of the License, or *
  6007. * (at your option) any later version. *
  6008. * *
  6009. * Mountyzilla is distributed in the hope that it will be useful, *
  6010. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6011. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6012. * GNU General Public License for more details. *
  6013. * *
  6014. * You should have received a copy of the GNU General Public License *
  6015. * along with Mountyzilla; if not, write to the Free Software *
  6016. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6017. *******************************************************************************/
  6018.  
  6019. // x~x equip
  6020.  
  6021. /**
  6022. * 2014-02-08 - v2.0a (from scratch)
  6023. * 2014-02-18 - v2.0a0
  6024. * - ajout calcul Carats / UM des minerais + totaux
  6025. * 2014-03-06 - v2.0a1
  6026. * - retour Infos EM des Champis
  6027. * TODO
  6028. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6029. */
  6030.  
  6031. function traiteChampis() {
  6032. try{
  6033. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6034. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6035. }
  6036. catch(e){return;}
  6037. if(trlist.length<=0) return;
  6038. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6039. var node = trlist.snapshotItem(i).childNodes[7];
  6040. var str = node.textContent.trim();
  6041. var type = str.slice(0,str.lastIndexOf(' '));
  6042. var mundi = mundiChampi[type];
  6043. if(!mundi) continue;
  6044. var urlImg = URL_MZimg
  6045. +'Competences/ecritureMagique.png';
  6046. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6047. appendText(node,' ');
  6048. node.appendChild(img);
  6049. }
  6050. }
  6051.  
  6052. function traiteCompos() {
  6053. try {
  6054. var tr = document.getElementById('mh_objet_hidden_Composant');
  6055. var tbody = document.evaluate("./td/table/tbody",
  6056. tr, null, 9, null).singleNodeValue;
  6057. }
  6058. catch(e) {return;}
  6059. insererInfosEM(tbody);
  6060. }
  6061.  
  6062. function traiteMinerai() {
  6063. try{
  6064. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6065. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6066. }
  6067. catch(e){return;}
  6068. if(trlist.length<=0) return;
  6069. var totaux = {};
  6070. var str;
  6071. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6072. var node = trlist.snapshotItem(i);
  6073. var nature = node.childNodes[7].textContent,
  6074. caracs = node.childNodes[9].textContent;
  6075. var taille = Number(caracs.match(/\d+/)[0]);
  6076. var coef = 1;
  6077. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6078. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6079. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6080. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6081. if(nature.indexOf('Mithril')!=-1) {
  6082. coef = 0.2*coef;
  6083. str = ' | UM: ';
  6084. }
  6085. else {
  6086. coef = 0.75*coef+1.25;
  6087. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6088. str = ' | Carats: ';
  6089. }
  6090. var carats = Math.round(taille*coef)
  6091. appendText(node.childNodes[9], str+carats );
  6092. if(!totaux[nature]) {
  6093. totaux[nature] = [taille,carats];
  6094. }
  6095. else {
  6096. totaux[nature][0] += taille;
  6097. totaux[nature][1] += carats;
  6098. }
  6099. }
  6100. str = 'Total : ';
  6101. for(var nature in totaux) {
  6102. if(str.length>8) str += ', ';
  6103. if(nature.indexOf('Mithril')!=-1) {
  6104. str += nature+totaux[nature][1]+' UM';
  6105. }
  6106. else {
  6107. str += nature+totaux[nature][0]+'U/'
  6108. +totaux[nature][1]+'c';
  6109. }
  6110. }
  6111. /*var node = document.getElementById('mh_plus_Minerai');
  6112. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6113. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6114. if(!titre) return;*/
  6115. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6116. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6117. td.colSpan = 7;
  6118. }
  6119.  
  6120. function do_equip() {
  6121. start_script();
  6122.  
  6123. traiteChampis();
  6124. traiteCompos();
  6125. traiteMinerai();
  6126.  
  6127. displayScriptTime();
  6128. }
  6129.  
  6130. /*******************************************************************************
  6131. * This file is part of Mountyzilla. *
  6132. * *
  6133. * Mountyzilla is free software; you can redistribute it and/or modify *
  6134. * it under the terms of the GNU General Public License as published by *
  6135. * the Free Software Foundation; either version 2 of the License, or *
  6136. * (at your option) any later version. *
  6137. * *
  6138. * Mountyzilla is distributed in the hope that it will be useful, *
  6139. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6140. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6141. * GNU General Public License for more details. *
  6142. * *
  6143. * You should have received a copy of the GNU General Public License *
  6144. * along with Mountyzilla; if not, write to the Free Software *
  6145. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6146. *******************************************************************************/
  6147.  
  6148. // x~x diplo
  6149.  
  6150. /*
  6151. TODO:
  6152. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6153. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6154. V Étape 3: Ajout de la diplo perso
  6155. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6156. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6157. Options Globales:
  6158. Actuelles:
  6159. numTroll.USECSS,
  6160. numTroll.NODIPLO
  6161. NOMYTH
  6162. Nouvelles:
  6163. TODO numTroll.USECSS
  6164. numTroll.diplo.off (remplace NODIPLO)
  6165. numTroll.diplo.guilde
  6166. numTroll.diplo.perso
  6167. Structure de diplo.guilde:
  6168. isOn: 'true' ou 'false'
  6169. isDetailOn: 'true' ou 'false'
  6170. guilde
  6171. > id
  6172. > couleur
  6173. AllAmis,AllEnnemis: couleur
  6174. Amis0,...,Ennemis5
  6175. > Troll: idTroll1;...;
  6176. > Guilde: idGuilde1;...;
  6177. > titre
  6178. > couleur
  6179. Structure de diplo.perso:
  6180. isOn: 'true' ou 'false'
  6181. mythiques: couleur
  6182. Troll,Guilde,Monstre:
  6183. > id
  6184. > couleur
  6185. > description
  6186. */
  6187.  
  6188. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6189.  
  6190. function couleurAleatoire() {
  6191. var alph = '0123456789ABCDEF'.split('');
  6192. var clr = '#';
  6193. for (var i=0; i<6; i++) {
  6194. clr+=alph[ Math.floor(16*Math.random()) ];
  6195. }
  6196. return clr;
  6197. }
  6198.  
  6199. function isCouleur(str) {
  6200. return /^#[0-9A-F]{6}$/i.test(str);
  6201. }
  6202.  
  6203. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6204.  
  6205. function appendChoixCouleur(node,id) {
  6206. var span = document.createElement('span');
  6207. span.id = 'span'+id;
  6208. if(isDetailOn) {
  6209. span.style.display = 'none';
  6210. }
  6211. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6212. if(diploGuilde[id]) {
  6213. couleur = diploGuilde[id];
  6214. }
  6215. appendText(span,' - Couleur HTML: ');
  6216. var input = appendTextbox(span,'text',id,7,7,couleur);
  6217. input.onkeyup = previewCouleur;
  6218. input.onchange = previewCouleur;
  6219. input.onkeyup();
  6220. node.appendChild(span);
  6221. }
  6222.  
  6223. function insertChoixCouleur(node,id) {
  6224. var span = document.createElement('span');
  6225. span.id = 'span'+id;
  6226. // La couleur détaillée passera à une valeur aléatoire
  6227. // si toggle vers isDetailOn
  6228. var couleur = couleurAleatoire();
  6229. if(!isDetailOn) {
  6230. span.style.display = 'none';
  6231. } else if(diploGuilde[id]) {
  6232. couleur = diploGuilde[id].couleur;
  6233. }
  6234. appendText(span,' - Couleur HTML: ');
  6235. var input = appendTextbox(span,'text',id,7,7,couleur);
  6236. input.onkeyup = previewCouleur;
  6237. input.onchange = previewCouleur;
  6238. input.onkeyup();
  6239. insertBefore(node,span);
  6240. }
  6241.  
  6242. function setChoixCouleurs() {
  6243. try {
  6244. var form = document.getElementsByName('ActionForm')[0];
  6245. var nodesAE = document.evaluate(
  6246. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6247. form, null, 7, null
  6248. );
  6249. var nodes = document.evaluate(
  6250. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6251. form, null, 7, null
  6252. );
  6253. } catch(e) {
  6254. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6255. return false;
  6256. };
  6257. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6258. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6259. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6260. for(var i=0 ; i<5 ; i++) {
  6261. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6262. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6263. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6264. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6265. }
  6266. return true;
  6267. }
  6268.  
  6269. function fetchDiploGuilde() {
  6270. try {
  6271. for(var AE in {Amis:0,Ennemis:0}) {
  6272. for(var i=0 ; i<5 ; i++) {
  6273. /* Récup des A/E de rang i */
  6274. var td = document.getElementById('td'+AE+i);
  6275. var ligne = td.getElementsByTagName('table')[0].rows;
  6276. var titre = trim(td.firstChild.textContent);
  6277. // On laisse la gestion des couleurs à setChoixCouleurs:
  6278. var couleur = document.getElementById(AE+i).value;
  6279. diploGuilde[AE+i] = {
  6280. Troll:'',
  6281. Guilde:'',
  6282. titre: titre,
  6283. couleur: couleur
  6284. };
  6285. for(var j=1 ; j<ligne.length ; j++) {
  6286. var str = trim(ligne[j].cells[0].textContent);
  6287. var idx = str.lastIndexOf('(');
  6288. var num = str.slice(idx+1,-1);
  6289. var type = trim(ligne[j].cells[1].textContent);
  6290. diploGuilde[AE+i][type] += num+';';
  6291. }
  6292. }
  6293. }
  6294. } catch(e) {
  6295. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6296. return false;
  6297. }
  6298. return true;
  6299. }
  6300.  
  6301.  
  6302. /*-[functions]--------------------- Handlers ---------------------------------*/
  6303.  
  6304. function toggleDetails() {
  6305. isDetailOn = !isDetailOn;
  6306. for(var AE in {Amis:0,Ennemis:0}) {
  6307. document.getElementById('spanAll'+AE).style.display =
  6308. (isDetailOn?'none':'');
  6309. for(var i=0 ; i<5 ; i++) {
  6310. document.getElementById('span'+AE+i).style.display =
  6311. (isDetailOn?'':'none');
  6312. }
  6313. }
  6314. }
  6315.  
  6316. function toggleMythiques() {
  6317. isMythiquesOn = !isMythiquesOn;
  6318. document.getElementById('spanMythiques').style.display =
  6319. (isMythiquesOn?'':'none');
  6320. }
  6321.  
  6322. function previewCouleur() {
  6323. var value = this.value;
  6324. if(isCouleur(value)) {
  6325. this.style.backgroundColor = value;
  6326. this.title = '';
  6327. } else {
  6328. this.style.backgroundColor = '';
  6329. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  6330. }
  6331. }
  6332.  
  6333. function appendMenuType(node,duType) {
  6334. var select = document.createElement('select');
  6335. select.className = 'SelectboxV2';
  6336. var type = ['Guilde','Troll','Monstre'];
  6337. for(var i=0 ; i<3 ; i++) {
  6338. appendOption(select,type[i],type[i]);
  6339. if(type[i]==duType) { select.selectedIndex=i; }
  6340. }
  6341. node.appendChild(select);
  6342. }
  6343.  
  6344. function ajouteChamp(type,num,couleur,descr) {
  6345. var champs = document.getElementById('diploPerso');
  6346. var nb = champs.rows.length;
  6347. var tr = champs.insertRow(-1);
  6348. var td = appendTd(tr);
  6349. appendMenuType(td,type);
  6350. td = appendTd(tr);
  6351. appendText(td,' n°');
  6352. appendTextbox(td,'text','num'+nb,6,15,num);
  6353. td = appendTd(tr);
  6354. appendText(td,' couleur HTML:');
  6355. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  6356. input.onkeyup = previewCouleur;
  6357. input.onchange = previewCouleur;
  6358. input.onkeyup();
  6359. td = appendTd(tr);
  6360. appendText(td,' Description:');
  6361. appendTextbox(td,'text','descr'+nb,30,150,descr);
  6362. td = appendTd(tr);
  6363. var span = document.createElement('span');
  6364. appendText(span,'[ok!]',true);
  6365. span.style.visibility = 'hidden';
  6366. td.appendChild(span);
  6367. td = appendTd(tr);
  6368. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  6369. }
  6370.  
  6371. function retireCeChamp() {
  6372. var thisTr = this.parentNode.parentNode;
  6373. thisTr.parentNode.removeChild(thisTr);
  6374. var champs = document.getElementById('diploPerso');
  6375. if(champs.rows.length==0) { ajouteChamp(); }
  6376. }
  6377.  
  6378. function valideChamp(champ) {
  6379. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  6380. isCouleur(champ.cells[2].childNodes[1].value);
  6381. if(isValide) {
  6382. champ.cells[4].firstChild.style.visibility = 'visible';
  6383. } else {
  6384. champ.cells[4].firstChild.style.visibility = 'hidden';
  6385. }
  6386. return isValide;
  6387. }
  6388.  
  6389. function sauvegarderTout() {
  6390. /* Diplo de guilde */
  6391. diploGuilde.isOn =
  6392. document.getElementById('isGuildeOn').checked?'true':'false';
  6393. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  6394. var numGuilde = Number(document.getElementById('numGuilde').value);
  6395. var couleur = document.getElementById('couleurGuilde').value;
  6396. if(numGuilde) {
  6397. diploGuilde.guilde = {
  6398. id: numGuilde,
  6399. couleur: couleur
  6400. };
  6401. } else {
  6402. delete diploGuilde.guilde;
  6403. }
  6404. for(var AE in {Amis:0,Ennemis:0}) {
  6405. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  6406. for(var i=0 ; i<5 ; i++) {
  6407. if(isDetailOn) {
  6408. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  6409. } else {
  6410. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  6411. }
  6412. }
  6413. }
  6414. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  6415. /* Diplo personnelle (ex-fonction saveChamps) */
  6416. var champs = document.getElementById('diploPerso');
  6417. diploPerso = {
  6418. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  6419. Guilde: {},
  6420. Troll: {},
  6421. Monstre: {}
  6422. };
  6423. if(isMythiquesOn &&
  6424. isCouleur(document.getElementById('couleurMythiques').value)) {
  6425. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  6426. }
  6427. for(var i=0 ; i<champs.rows.length ; i++) {
  6428. if(valideChamp(champs.rows[i])) {
  6429. var type = champs.rows[i].cells[0].firstChild.value;
  6430. var num = champs.rows[i].cells[1].childNodes[1].value;
  6431. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  6432. var descr = champs.rows[i].cells[3].childNodes[1].value;
  6433. diploPerso[type][num] = {
  6434. couleur: couleur
  6435. };
  6436. if(descr) {
  6437. diploPerso[type][num].titre = descr;
  6438. }
  6439. }
  6440. }
  6441. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  6442.  
  6443. avertissement('Données sauvegardées');
  6444. }
  6445.  
  6446.  
  6447. /*-[functions]------------- Modifications de la page -------------------------*/
  6448.  
  6449. function creeTablePrincipale() {
  6450. var insertPt = document.getElementById('insertPt');
  6451. /* Titre + bouton de Sauvegarde */
  6452. var tr = insertTr(insertPt,'mh_tdtitre');
  6453. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  6454. appendButton(td,'Sauvegarder',sauvegarderTout);
  6455. /* Options fixes */
  6456. tr = insertTr(insertPt,'mh_tdpage');
  6457. td = appendTdText(tr,'Diplomatie de guilde:',true);
  6458. appendBr(td);
  6459. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  6460. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  6461. appendBr(td);
  6462. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  6463. appendText(td,'Utiliser des couleurs détaillées (10)');
  6464. /* Diplo personnelle */
  6465. tr = insertTr(insertPt,'mh_tdpage');
  6466. td = appendTdText(tr,'Diplomatie personnelle:',true);
  6467. appendBr(td);
  6468. // Diplo Mythiques
  6469. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  6470. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  6471. var span = document.createElement('span');
  6472. span.id = 'spanMythiques';
  6473. if(!isMythiquesOn) {
  6474. span.style.display = 'none';
  6475. }
  6476. var couleur = '#FFAAAA';
  6477. if(diploPerso.mythiques) {
  6478. couleur = diploPerso.mythiques;
  6479. }
  6480. appendText(span,' - couleur HTML:');
  6481. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  6482. input.onkeyup = previewCouleur;
  6483. input.onchange = previewCouleur;
  6484. input.onkeyup();
  6485. td.appendChild(span);
  6486. appendBr(td);
  6487. // Diplo éditable
  6488. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  6489. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  6490. appendBr(td);
  6491. var table = document.createElement('table');
  6492. table.id = 'diploPerso'
  6493. td.appendChild(table);
  6494. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  6495. for(var num in diploPerso[type]) {
  6496. ajouteChamp(
  6497. type,
  6498. num,
  6499. diploPerso[type][num].couleur,
  6500. diploPerso[type][num].titre
  6501. );
  6502. }
  6503. }
  6504. if(table.rows.length==0) {
  6505. ajouteChamp();
  6506. }
  6507. appendButton(td,'Ajouter',ajouteChamp)
  6508. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  6509. appendText(td,' ');
  6510. appendButton(td,
  6511. 'Exemples de couleur',
  6512. function() {
  6513. var fenetre = window.open(
  6514. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  6515. 'Divers',
  6516. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  6517. 'status=0,menubar=0,resizable=1,scrollbars=1'
  6518. );
  6519. fenetre.focus();
  6520. }
  6521. );
  6522. /* Couleur de Guilde */
  6523. tr = insertTr(insertPt,'mh_tdtitre');
  6524. td = appendTdText(tr,'GUILDE',true);
  6525. appendText(td,' - n°');
  6526. appendTextbox(td,'text','numGuilde',5,10,
  6527. diploGuilde.guilde && diploGuilde.guilde.id ?
  6528. diploGuilde.guilde.id : ''
  6529. );
  6530. appendText(td,' - Couleur HTML: ');
  6531. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  6532. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  6533. diploGuilde.guilde.couleur : '#BBBBFF'
  6534. );
  6535. input.onkeyup = previewCouleur;
  6536. input.onchange = previewCouleur;
  6537. input.onkeyup();
  6538. }
  6539.  
  6540.  
  6541. /*-[functions]----------------------- Main -----------------------------------*/
  6542.  
  6543. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6544. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6545. var isDetailOn = diploGuilde.isDetailOn=='true';
  6546. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6547. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6548. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6549.  
  6550. function do_diplo() {
  6551. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6552. creeTablePrincipale();
  6553. }
  6554. }
  6555.  
  6556. /*******************************************************************************
  6557. * This file is part of Mountyzilla. *
  6558. * *
  6559. * Mountyzilla is free software; you can redistribute it and/or modify *
  6560. * it under the terms of the GNU General Public License as published by *
  6561. * the Free Software Foundation; either version 2 of the License, or *
  6562. * (at your option) any later version. *
  6563. * *
  6564. * Mountyzilla is distributed in the hope that it will be useful, *
  6565. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6566. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6567. * GNU General Public License for more details. *
  6568. * *
  6569. * You should have received a copy of the GNU General Public License *
  6570. * along with Mountyzilla; if not, write to the Free Software *
  6571. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6572. *******************************************************************************/
  6573.  
  6574. // x~x cdmcomp
  6575.  
  6576. var cdm = '';
  6577.  
  6578. function getNonNegInts(str) {
  6579. var nbrs = str.match(/\d+/g);
  6580. for(var i=0 ; i<nbrs.length ; i++) {
  6581. nbrs[i] = Number(nbrs[i]);
  6582. }
  6583. return nbrs;
  6584. }
  6585.  
  6586. function traiteCdMcomp() {
  6587. try {
  6588. var msgEffet = document.getElementById('msgEffet');
  6589. } catch(e) {
  6590. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  6591. return;
  6592. }
  6593.  
  6594. // Teste si ce message du bot est un message de CdM
  6595. if(!document.evaluate(
  6596. "./p/b/text()[contains(.,'fait partie')]",
  6597. msgEffet, null, 9, null
  6598. ).singleNodeValue) {
  6599. return;
  6600. }
  6601. // Début de récupération de la CdM
  6602. cdm = document.evaluate(
  6603. "./p/b/text()[contains(.,'fait partie')]",
  6604. msgEffet, null, 9, null
  6605. ).singleNodeValue.nodeValue+'\n';
  6606. var tbody = document.evaluate(
  6607. "descendant::table/tbody",
  6608. msgEffet, null, 9, null
  6609. ).singleNodeValue;
  6610. var nomStat = document.evaluate(
  6611. "./tr/td[1]/b/text()",
  6612. tbody, null, 7, null
  6613. );
  6614. var valStat = document.evaluate(
  6615. "./tr/td[2]/descendant::text()",
  6616. tbody, null, 7, null
  6617. );
  6618. var i=0;
  6619. while(i<nomStat.snapshotLength) {
  6620. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  6621. cdm += 'Armure : ';
  6622. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  6623. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  6624. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  6625. armp = [0,armp[0]];
  6626. }
  6627. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  6628. armm = [0,armm[0]];
  6629. }
  6630. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  6631. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  6632. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  6633. } else {
  6634. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6635. }
  6636. cdm += ')\n';
  6637. i++;
  6638. } else {
  6639. cdm += nomStat.snapshotItem(i).nodeValue+
  6640. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  6641. }
  6642. i++;
  6643. }
  6644. // Envoi auto ou insertion bouton envoi (suivant option)
  6645. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  6646. sendInfoCDM();
  6647. var p = document.createElement('p');
  6648. p.style.color = 'green';
  6649. appendText(p,'CdM envoyée vers la base MountyZilla !');
  6650. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  6651. } else {
  6652. insertButtonCdm('as_Action', sendInfoCDM);
  6653. }
  6654.  
  6655. // Insertion de l'estimation des PV restants
  6656. var pv = valStat.snapshotItem(1).nodeValue;
  6657. if(pv.indexOf("entre")==-1) {
  6658. return;
  6659. }
  6660. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  6661. if(pv) {
  6662. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  6663. appendTdText(tr, pv[0], true);
  6664. appendTdText(tr, pv[1], true);
  6665. }
  6666. }
  6667.  
  6668. function sendInfoCDM() {
  6669. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  6670. var buttonCDM = this;
  6671. var texte = '';
  6672. FF_XMLHttpRequest({
  6673. method: 'GET',
  6674. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6675. headers : {
  6676. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6677. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6678. },
  6679. onload: function(responseDetails) {
  6680. texte = responseDetails.responseText;
  6681. buttonCDM.value = texte;
  6682. buttonCDM.disabled = true;
  6683. }
  6684. });
  6685. }
  6686.  
  6687. function do_cdmcomp() {
  6688. start_script(31);
  6689. traiteCdMcomp();
  6690. displayScriptTime();
  6691. }
  6692.  
  6693. /*********************************************************************************
  6694. * This file is part of Mountyzilla. *
  6695. * *
  6696. * Mountyzilla is free software; you can redistribute it and/or modify *
  6697. * it under the terms of the GNU General Public License as published by *
  6698. * the Free Software Foundation; either version 2 of the License, or *
  6699. * (at your option) any later version. *
  6700. * *
  6701. * Mountyzilla is distributed in the hope that it will be useful, *
  6702. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6703. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6704. * GNU General Public License for more details. *
  6705. * *
  6706. * You should have received a copy of the GNU General Public License *
  6707. * along with Mountyzilla; if not, write to the Free Software *
  6708. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6709. *********************************************************************************/
  6710.  
  6711. // x~x cmdbot
  6712.  
  6713. /* v0.2 by Dab - 2013-08-20
  6714. * - patch dégueu pour gérer la décomposition P/M de l'armure
  6715. */
  6716.  
  6717. var buttonCDM;
  6718.  
  6719. /*******************************************************************************************
  6720. CDM :
  6721. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  6722.  
  6723. Il ne vous est pas possible d'améliorer cette compétence.
  6724.  
  6725. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  6726. Niveau : Inimaginable (entre 49 et 51)
  6727. Points de Vie : Surtrollesque (entre 450 et 470)
  6728. Blessure (Approximatif) : 0 %
  6729. Dés d'Attaque : Impressionnant (entre 30 et 32)
  6730. Dés d'Esquive : Impressionnant (entre 28 et 30)
  6731. Dés de Dégat : Très Fort (entre 18 et 20)
  6732. Dés de Régénération : Excellent (égal à 13)
  6733. Armure Physique : Moyen (entre 10 et 12)
  6734. Armure Magique : Faible (inférieur à 6)
  6735. Vue : Moyen (entre 9 et 11)
  6736. Maitrise Magique : Inimaginable (supérieur à 6000)
  6737. Résistance Magique : Inimaginable (supérieur à 6000)
  6738. Nombre d'attaques : 1
  6739. Vitesse de Déplacement : Normale
  6740. Voir le Caché : Oui
  6741. Attaque à distance : Non
  6742. Attaque magique : Oui
  6743. Vole : Non
  6744. Sang froid : Inexistant
  6745. DLA : Milieu
  6746. Durée Tour : Remarquable (entre 9 et 11)
  6747. Chargement : Vide
  6748. Bonus Malus : Aucun
  6749.  
  6750. Vous avez également gagné 1 PX pour la réussite.
  6751. *******************************************************************************************
  6752. BOT :
  6753. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  6754.  
  6755. Le Monstre ciblé fait partie des : Mort-Vivant
  6756.  
  6757. Niveau : Incroyable (entre 36 et 38)
  6758. *******************************************************************************************/
  6759.  
  6760. function getNNInt(str) {
  6761. var nbrs = str.match(/\d+/g);
  6762. for (var i=0 ; i<nbrs.length ; i++)
  6763. nbrs[i] = parseInt(nbrs[i]);
  6764. return nbrs;
  6765. }
  6766.  
  6767. function sendCDM() {
  6768. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6769. document, null, 9, null).singleNodeValue;
  6770. cdm = td.innerHTML;
  6771. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  6772. "$3$4 ($1 - N°$2)<br>");
  6773. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  6774. 'Blessure : XX % (approximativement)');
  6775. // Supprime la décomposition P/M de l'Armure
  6776. var bgn = cdm.indexOf('Armure Physique');
  6777. if (bgn!=-1) {
  6778. var end = cdm.indexOf('Vue')-2;
  6779. var lines = cdm.substring(bgn,end).split('<br>');
  6780. var armp = getNNInt(lines[0]);
  6781. var armm = getNNInt(lines[1]);
  6782. if (lines[0].indexOf('(inf')!=-1)
  6783. armp = [0,armp[0]];
  6784. if (lines[1].indexOf('(inf')!=-1)
  6785. armm = [0,armm[0]];
  6786. var insrt = 'Armure : ';
  6787. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  6788. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  6789. else
  6790. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6791. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  6792. }
  6793. cdm = cdm.replace(/<br>/g,'\n');
  6794. FF_XMLHttpRequest({
  6795. method: 'GET',
  6796. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6797. headers : {
  6798. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6799. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6800. },
  6801. onload: function(responseDetails) {
  6802. buttonCDM.value=responseDetails.responseText;
  6803. buttonCDM.disabled = true;
  6804. }
  6805. });
  6806. }
  6807.  
  6808. function traiteCdMmsg() {
  6809. // Teste si ce message du bot est un message de CdM
  6810. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6811. document, null, 9, null).singleNodeValue;
  6812. if (!td) return false;
  6813. cdm = td.innerHTML;
  6814. // Insertion de l'estimation des PV restants
  6815. var des = cdm.indexOf('Dés');
  6816. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  6817. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  6818. if(pv)
  6819. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  6820.  
  6821. // Insertion bouton envoi + espace
  6822. buttonCDM = insertButtonCdm('bClose',sendCDM);
  6823. }
  6824.  
  6825. /*function traitePouvoir() {
  6826. // Teste si ce message du bot est un message de CdM
  6827. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  6828. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  6829. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6830. if (!td)
  6831. return false;
  6832. var infos = td.innerHTML;
  6833. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  6834. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  6835. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  6836. var date = /alors : ([^<]+)\./.exec(infos)[1];
  6837. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  6838. var effetPouvoir="";
  6839. var full=false;
  6840. if(infos.indexOf("REDUIT")!=-1) {
  6841. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  6842. }
  6843. else {
  6844. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  6845. full=true;
  6846. }
  6847. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  6848. // On insère le bouton et un espace
  6849. //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));
  6850. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  6851. if(!MY_getValue('AUTOSENDPOUV'))
  6852. {
  6853. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  6854. button.setAttribute("onClick", "window.open('" + url
  6855. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  6856. + "this.value='Merci de votre participation'; this.disabled = true;");
  6857. }
  6858. else
  6859. {
  6860. FF_XMLHttpRequest({
  6861. method: 'GET',
  6862. url: url,
  6863. headers : {
  6864. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6865. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6866. }});
  6867. }
  6868. }*/
  6869.  
  6870. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  6871. traiteCdMmsg();
  6872. }
  6873. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  6874.  
  6875. /*******************************************************************************
  6876. * This file is part of Mountyzilla. *
  6877. * *
  6878. * Mountyzilla is free software; you can redistribute it and/or modify *
  6879. * it under the terms of the GNU General Public License as published by *
  6880. * the Free Software Foundation; either version 2 of the License, or *
  6881. * (at your option) any later version. *
  6882. * *
  6883. * Mountyzilla is distributed in the hope that it will be useful, *
  6884. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6885. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6886. * GNU General Public License for more details. *
  6887. * *
  6888. * You should have received a copy of the GNU General Public License *
  6889. * along with Mountyzilla; if not, write to the Free Software *
  6890. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6891. *******************************************************************************/
  6892.  
  6893. // x~x menu
  6894. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  6895.  
  6896. var menuRac, mainIco;
  6897.  
  6898. // met à jour les carac sauvegardées (position, DLA, etc.)
  6899. function updateData() {
  6900. var inputs = document.getElementsByTagName('input');
  6901. var divs = document.getElementsByTagName('div');
  6902. numTroll = inputs[0].value;
  6903. MY_setValue('NUM_TROLL', numTroll);
  6904. MY_setValue('NIV_TROLL',inputs[1].value);
  6905. if(!MY_getValue(numTroll+'.caracs.rm')) {
  6906. MY_setValue(numTroll+'.caracs.rm',0);
  6907. // assure l'init des 4 var de libs
  6908. }
  6909. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  6910. var DLA = new Date(
  6911. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  6912. );
  6913. if(MY_getValue(numTroll+'.DLA.encours')) {
  6914. var DLAstockee = new Date(
  6915. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  6916. );
  6917. if(DLA>DLAstockee) {
  6918. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  6919. // Pose un pb en cas de décalage de DLA
  6920. }
  6921. }
  6922. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  6923. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  6924. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  6925. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  6926. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  6927. }
  6928.  
  6929. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  6930. function initRaccourcis() {
  6931. var anotherURL = MY_getValue('URL1');
  6932. if(!anotherURL) { return; }
  6933. /* Création de l'icône faisant apparaître le menu */
  6934. mainIco = document.createElement('img');
  6935. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  6936. if(!urlIco) {
  6937. urlIco =
  6938. URL_MZimg + 'mz_logo_small.png';
  6939. }
  6940. mainIco.src = urlIco;
  6941. mainIco.alt = 'MZ';
  6942. mainIco.style = 'position:fixed; top:0px; left:0px';
  6943. mainIco.onmouseover = afficheMenu;
  6944. document.body.appendChild(mainIco);
  6945. /* Création du menu des Raccourcis */
  6946. menuRac = document.createElement('div');
  6947. menuRac.className = 'mh_textbox';
  6948. menuRac.style =
  6949. 'position:fixed; top:10px; left:10px;'+
  6950. 'max-width:190px;'+
  6951. 'border-radius: 4px; padding: 4px;'+
  6952. 'z-index: 500;'+
  6953. 'visibility: hidden;';
  6954. document.body.appendChild(menuRac);
  6955. document.addEventListener('mousemove',cacheMenu,false);
  6956. var i=1;
  6957. while(anotherURL) {
  6958. var a = document.createElement('a');
  6959. var url = MY_getValue('URL'+i);
  6960. var nom = MY_getValue('URL'+i+'.nom');
  6961. var ico = MY_getValue('URL'+i+'.ico');
  6962. a.href = url;
  6963. a.target = '_blank';
  6964. if(ico) {
  6965. var txt = nom ? nom : '';
  6966. var img = createImage(ico,txt);
  6967. a.appendChild(img);
  6968. }
  6969. else {
  6970. appendText(a,'['+nom+']');
  6971. }
  6972. menuRac.appendChild(a);
  6973. appendBr(menuRac);
  6974. i++;
  6975. anotherURL = MY_getValue('URL'+i);
  6976. }
  6977. }
  6978.  
  6979. function afficheMenu() {
  6980. menuRac.style.visibility = 'visible';
  6981. }
  6982.  
  6983. function cacheMenu(e) {
  6984. if(menuRac.style.visibility=='hidden') { return; }
  6985. // Position souris
  6986. var ptX = e.clientX;
  6987. var ptY = e.clientY;
  6988. // On recalcule en live les BoundingBox pour mainIco et menuRac
  6989. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  6990. var menuRect = menuRac.getBoundingClientRect();
  6991. var icoRect = mainIco.getBoundingClientRect();
  6992. if((ptX>icoRect.width || ptY>icoRect.height) &&
  6993. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  6994. menuRac.style.visibility = 'hidden';
  6995. }
  6996. }
  6997.  
  6998. // ajout de l'icône, branchée sur un refresh
  6999. function initUpdateCoordGauche() {
  7000. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7001. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7002. var img = document.createElement('img');
  7003. img.src = URL_MZimg + 'recycl.png'
  7004. img.onclick = function(evt) {
  7005. document.location.href = document.location.href;
  7006. };
  7007. img.title = 'Mise à jour de la localisation';
  7008. img.style.cursor = 'pointer';
  7009. img.style.position = 'absolute';
  7010. img.style.bottom = 0;
  7011. img.style.left = 0;
  7012. div.appendChild(img);
  7013. }
  7014.  
  7015. function do_menu() {
  7016. // met à jour les carac sauvegardées (position, DLA, etc.)
  7017. updateData();
  7018. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7019. initRaccourcis();
  7020. // Ajout bouton de mise à jour coordonnées
  7021. initUpdateCoordGauche();
  7022. }
  7023.  
  7024. /*******************************************************************************
  7025. * This file is part of Mountyzilla. *
  7026. * *
  7027. * Mountyzilla is free software; you can redistribute it and/or modify *
  7028. * it under the terms of the GNU General Public License as published by *
  7029. * the Free Software Foundation; either version 2 of the License, or *
  7030. * (at your option) any later version. *
  7031. * *
  7032. * Mountyzilla is distributed in the hope that it will be useful, *
  7033. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7034. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7035. * GNU General Public License for more details. *
  7036. * *
  7037. * You should have received a copy of the GNU General Public License *
  7038. * along with Mountyzilla; if not, write to the Free Software *
  7039. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7040. *******************************************************************************/
  7041.  
  7042. // x~x vue
  7043.  
  7044. /* TODO
  7045. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7046. * prévoir fix ("delete infos")
  7047. */
  7048.  
  7049. /*--------------------------- Variables Globales -----------------------------*/
  7050.  
  7051. // Infos remplies par des scripts extérieurs
  7052. var listeCDM = [], listeLevels = [];
  7053.  
  7054. // Position actuelle
  7055. var currentPosition=[0,0,0];
  7056.  
  7057. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7058. var porteeVue=[0,0,0,0];
  7059.  
  7060. // Fenêtres déplaçables
  7061. var winCurr = null;
  7062. var offsetX, offsetY;
  7063. document.onmousemove = drag;
  7064.  
  7065. // Diplomatie
  7066. var Diplo = {
  7067. Guilde: {},
  7068. Troll: {},
  7069. Monstre: {}
  7070. // .mythiques: uniquement si option activée
  7071. };
  7072. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7073.  
  7074. // Infos tactiques
  7075. var popup;
  7076.  
  7077. // Gère l'affichage en cascade des popups de CdM
  7078. var nbCDM = 0;
  7079.  
  7080. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7081.  
  7082. // Utilisé pour supprimer les monstres "engagés"
  7083. var listeEngages = {};
  7084. var isEngagesComputed = false;
  7085. var cursorOnLink = false; // DEBUG: wtf ?
  7086.  
  7087. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7088. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7089.  
  7090. // Checkboxes de filtrage
  7091. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7092. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7093. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  7094. comboBoxNiveauMin, comboBoxNiveauMax;
  7095.  
  7096. /* Acquisition & Stockage des données de DB */
  7097. const typesAFetcher = {
  7098. 'monstres':1,
  7099. 'trolls':1,
  7100. 'tresors':1,
  7101. 'champignons':1,
  7102. 'lieux':1
  7103. }
  7104. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7105. tr_champignons = {}, tr_lieux = {};
  7106. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7107. nbChampignons = 0, nbLieux = 0;
  7108.  
  7109. function fetchData(type) {
  7110. try {
  7111. var node = document.getElementById('mh_vue_hidden_'+type);
  7112. // this = MZ.global = sandBox de travail de MZ
  7113. // On définit donc des variables MZ-globales
  7114. this['tr_'+type] = node.getElementsByTagName('tr');
  7115. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7116. } catch(e) {
  7117. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7118. }
  7119. }
  7120.  
  7121.  
  7122. /*---------------------------------- DEBUG -----------------------------------*/
  7123. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7124. var x_monstres = tr_monstres;
  7125. var x_trolls = tr_trolls;
  7126. var x_tresors = tr_tresors;
  7127. var x_champis = tr_champignons;
  7128. var x_lieux = tr_lieux;
  7129. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7130.  
  7131.  
  7132. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7133.  
  7134. function positionToString(arr) {
  7135. return arr.join(';');
  7136. }
  7137.  
  7138. function savePosition() {
  7139. // Stocke la position (à jour) de la vue pour les autres scripts
  7140. // DEBUG: Lesquels et pourquoi?
  7141. var pos = getPosition();
  7142. MY_setValue(numTroll+'.position.X',pos[0]);
  7143. MY_setValue(numTroll+'.position.Y',pos[1]);
  7144. MY_setValue(numTroll+'.position.N',pos[2]);
  7145. }
  7146.  
  7147.  
  7148. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7149. /* INFOS :
  7150. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7151. * sont identifiables via leur Name
  7152. * les tables-listings sont identifiables via l'ID du tr conteneur
  7153. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7154. */
  7155.  
  7156. /* [functions] Récup données Utilisateur */
  7157. function getPosition() {
  7158. // Pour rétrocompatibilité
  7159. return currentPosition;
  7160. }
  7161.  
  7162. function getPorteVue() {
  7163. // Pour rétrocompatibilité
  7164. return porteeVue;
  7165. }
  7166.  
  7167. function getVue() {
  7168. // Retourne [vueHpure, vueVpure]
  7169. var vues = getPorteVue();
  7170. return [ vues[0], vues[1] ];
  7171. }
  7172.  
  7173. // Roule 11/03/2016
  7174. /* [functions] Récup données monstres, trolls, etc. */
  7175. function getXxxDistance(xxx, i) {
  7176. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7177. }
  7178. function getXxxPosition(xxx, i) {
  7179. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7180. var l = tds.length;
  7181. return [
  7182. parseInt(tds[l-3].textContent),
  7183. parseInt(tds[l-2].textContent),
  7184. parseInt(tds[l-1].textContent)
  7185. ];
  7186. }
  7187.  
  7188.  
  7189. /* [functions] Récup données monstres */
  7190. function getMonstreDistance(i) {
  7191. return parseInt(tr_monstres[i].cells[0].textContent);
  7192. }
  7193.  
  7194. function getMonstreID(i) {
  7195. return tr_monstres[i].cells[2].firstChild.nodeValue;
  7196. }
  7197.  
  7198. function getMonstreIDByTR(tr) {
  7199. return tr.cells[2].firstChild.nodeValue;
  7200. }
  7201.  
  7202. function getMonstreLevelNode(i) {
  7203. return tr_monstres[i].cells[3];
  7204. }
  7205.  
  7206. function getMonstreLevel(i) {
  7207. if(!isCDMsRetrieved) return -1;
  7208. var donneesMonstre = listeCDM[getMonstreID(i)];
  7209. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  7210. }
  7211.  
  7212. function getMonstreNomNode(i) {
  7213. try {
  7214. var td = document.evaluate(
  7215. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  7216. tr_monstres[i], null, 9, null
  7217. ).singleNodeValue;
  7218. return td;
  7219. } catch(e) {
  7220. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  7221. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  7222. }
  7223. }
  7224.  
  7225. function getMonstreNom(i) {
  7226. return getMonstreNomByTR(tr_monstres[i]);
  7227. }
  7228.  
  7229. function getMonstreNomByTR(tr) {
  7230. try {
  7231. var nom = document.evaluate(
  7232. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  7233. tr, null, 2, null
  7234. ).stringValue;
  7235. return nom;
  7236. } catch(e) {
  7237. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  7238. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  7239. }
  7240. }
  7241.  
  7242. function getMonstrePosition(i) {
  7243. var tds = tr_monstres[i].childNodes;
  7244. var l = tds.length;
  7245. return [
  7246. parseInt(tds[l-3].textContent),
  7247. parseInt(tds[l-2].textContent),
  7248. parseInt(tds[l-1].textContent)
  7249. ];
  7250. }
  7251.  
  7252. function appendMonstres(txt) {
  7253. for(var i=1; i<=nbMonstres ; i++)
  7254. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  7255. return txt;
  7256. }
  7257.  
  7258. function getMonstres() {
  7259. var vue = getVue();
  7260. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7261. }
  7262.  
  7263. function bddMonstres(start,stop) {
  7264. if(!start) { var start = 1; }
  7265. if(!stop) { var stop = nbMonstres; }
  7266. stop = Math.min(nbMonstres,stop);
  7267. var txt='';
  7268. for(var i=start ; i<=stop ; i++) {
  7269. txt += getMonstreID(i)+';'+
  7270. getMonstreNom(i)+';'+
  7271. positionToString(getMonstrePosition(i))+'\n';
  7272. }
  7273. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  7274. }
  7275.  
  7276. /* [functions] Récup données Trolls */
  7277. function getTrollDistance(i) {
  7278. return parseInt(tr_trolls[i].cells[0].textContent);
  7279. }
  7280.  
  7281. function getTrollID(i) {
  7282. return parseInt(tr_trolls[i].cells[2].textContent);
  7283. }
  7284.  
  7285. function getTrollNomNode(i) {
  7286. var isEnvoiOn =
  7287. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  7288. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  7289. }
  7290.  
  7291. function getTrollNivNode(i) {
  7292. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  7293. return tr_trolls[i].cells[4];
  7294. }
  7295.  
  7296. function getTrollGuilde(i) {
  7297. return trim(tr_trolls[i].cells[6].textContent);
  7298. }
  7299.  
  7300. function getTrollGuildeID(i) {
  7301. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  7302. var href;
  7303. try {
  7304. 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"
  7305. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  7306. } catch(e) { // debug pb remonté par Marsak
  7307. window.console.error(traceStack(e, 'getTrollGuildeID')
  7308. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  7309. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  7310. return -1;
  7311. }
  7312. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  7313. }
  7314. return -1;
  7315. }
  7316.  
  7317. function getTrollPosition(i) {
  7318. var tds = tr_trolls[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 bddTrolls() {
  7328. var txt='#DEBUT TROLLS\n'+
  7329. numTroll+';'+positionToString(getPosition())+'\n';
  7330. for(var i=1 ; i<=nbTrolls ; i++) {
  7331. txt += getTrollID(i)+';'+
  7332. positionToString(getTrollPosition(i))+'\n';
  7333. }
  7334. return txt+'#FIN TROLLS';
  7335. }
  7336.  
  7337. /* [functions] Récup données Trésors */
  7338. function getTresorDistance(i) {
  7339. return tr_tresors[i].cells[0].firstChild.nodeValue;
  7340. }
  7341.  
  7342. function getTresorID(i) {
  7343. return trim(tr_tresors[i].cells[2].textContent);
  7344. }
  7345.  
  7346. function getTresorNom(i) {
  7347. // Utilisation de textContent pour régler le "bug de Pollux"
  7348. return trim(tr_tresors[i].cells[3].textContent);
  7349. }
  7350.  
  7351. function getTresorPosition(i) {
  7352. var tds = tr_tresors[i].childNodes;
  7353. var l = tds.length;
  7354. return [
  7355. parseInt(tds[l-3].textContent),
  7356. parseInt(tds[l-2].textContent),
  7357. parseInt(tds[l-1].textContent),
  7358. ];
  7359. }
  7360.  
  7361. function bddTresors(dmin,start,stop) {
  7362. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  7363. if(!dmin) { var dmin = 0; }
  7364. if(!start) { var start = 1; }
  7365. if(!stop) { var stop = nbTresors; }
  7366. stop = Math.min(nbTresors,stop);
  7367. var txt='';
  7368. for(var i=start ; i<=stop ; i++) {
  7369. if(getTresorDistance(i)>=dmin) {
  7370. txt += getTresorID(i)+';'+
  7371. getTresorNom(i)+';'+
  7372. positionToString(getTresorPosition(i))+'\n';
  7373. }
  7374. }
  7375. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  7376. }
  7377.  
  7378. /* [functions] Récup données Champignons */
  7379. // DEBUG: Pas de colonne "Référence" sur serveur de test
  7380. function getChampignonNom(i) {
  7381. return trim(tr_champignons[i].cells[2].textContent);
  7382. }
  7383.  
  7384. function getChampignonPosition(i) {
  7385. var tds = tr_champignons[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 bddChampignons() {
  7395. var txt='';
  7396. for(var i=1 ; i<=nbChampignons ; i++) {
  7397. txt += ';'+ // Les champis n'ont pas de Référence
  7398. getChampignonNom(i)+';'+
  7399. positionToString(getChampignonPosition(i))+'\n';
  7400. }
  7401. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  7402. }
  7403.  
  7404. /* [functions] Récup données Lieux */
  7405. function getLieuDistance(i) {
  7406. return parseInt(tr_lieux[i].cells[0].textContent);
  7407. }
  7408.  
  7409. function getLieuID(i) {
  7410. return parseInt(tr_lieux[i].cells[2].textContent);
  7411. }
  7412.  
  7413. function getLieuNom(i) {
  7414. // Conversion ASCII pour éviter les bugs des Vues externes
  7415. return trim(tr_lieux[i].cells[3].textContent);
  7416. }
  7417.  
  7418. function getLieuPosition(i) {
  7419. var tds = tr_lieux[i].childNodes;
  7420. var l = tds.length;
  7421. return [
  7422. parseInt(tds[l-3].textContent),
  7423. parseInt(tds[l-2].textContent),
  7424. parseInt(tds[l-1].textContent)
  7425. ];
  7426. }
  7427.  
  7428. function appendLieux(txt) {
  7429. for(var i = 1; i < nbLieux+1; i++) {
  7430. var tds = x_lieux[i].childNodes;
  7431. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  7432. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  7433. }
  7434. return txt;
  7435. }
  7436.  
  7437. function getLieux() {
  7438. var vue = getVue();
  7439. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7440. }
  7441.  
  7442. function bddLieux(start,stop) {
  7443. if(!start) { var start = 1; }
  7444. if(!stop) { var stop = nbLieux; }
  7445. stop = Math.min(nbLieux,stop);
  7446. var txt='';
  7447. for(var i=start ; i<=stop ; i++) {
  7448. txt += getLieuID(i)+';'+
  7449. epure(getLieuNom(i))+';'+
  7450. positionToString(getLieuPosition(i))+'\n';
  7451. }
  7452. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  7453. }
  7454.  
  7455.  
  7456. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  7457.  
  7458. function saveCheckBox(chkbo, pref) {
  7459. // Enregistre et retourne l'état d'une CheckBox
  7460. var etat = chkbo.checked;
  7461. MY_setValue(pref, etat ? 'true' : 'false' );
  7462. return etat;
  7463. }
  7464.  
  7465. function recallCheckBox(chkbox, pref) {
  7466. // Restitue l'état d'une CheckBox
  7467. chkbox.checked = (MY_getValue(pref)=='true');
  7468. }
  7469.  
  7470. function saveComboBox(cbb, pref) {
  7471. // Enregistre et retourne l'état d'une ComboBox
  7472. var etat = cbb.selectedIndex;
  7473. MY_setValue(pref, etat);
  7474. return etat;
  7475. }
  7476.  
  7477. function recallComboBox(cbb, pref) {
  7478. // Restitue l'état d'une ComboBox
  7479. var nb = MY_getValue(pref);
  7480. if(nb) cbb.value = nb;
  7481. return nb;
  7482. }
  7483.  
  7484. function synchroniseFiltres() {
  7485. // Récupération de toutes les options de la vue
  7486. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  7487. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  7488. if(numBool) {
  7489. debutFiltrage('Monstres');
  7490. }
  7491. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  7492. recallCheckBox(checkBoxMythiques,'NOMYTH');
  7493. recallCheckBox(checkBoxEngages,'NOENGAGE');
  7494. recallCheckBox(checkBoxLevels,'NOLEVEL');
  7495. recallCheckBox(checkBoxIntangibles,'NOINT');
  7496. recallCheckBox(checkBoxGG,'NOGG');
  7497. recallCheckBox(checkBoxCompos,'NOCOMP');
  7498. recallCheckBox(checkBoxBidouilles,'NOBID');
  7499. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  7500. recallCheckBox(checkBoxTrou,'NOTROU');
  7501. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  7502. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  7503. if(MY_getValue('NOINFOEM')!='true')
  7504. recallCheckBox(checkBoxEM,'NOEM');
  7505. }
  7506.  
  7507.  
  7508. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  7509.  
  7510. /* [functions] Menu Vue 2D */
  7511. var vue2Ddata = {
  7512. 'Bricol\' Vue': {
  7513. url: URL_bricol_mountyhall + 'vue_form.php',
  7514. paramid: 'vue',
  7515. func: getVueScript,
  7516. extra_params: {
  7517. 'mode': 'vue_SP_Vue2',
  7518. 'screen_width': window.screen.width
  7519. }
  7520. },
  7521. 'Vue du CCM': {
  7522. url: URL_vue_CCM,
  7523. paramid: 'vue',
  7524. func: getVueScript,
  7525. extra_params: {
  7526. 'id': numTroll+';'+positionToString(getPosition())
  7527. }
  7528. },
  7529. 'Vue Gloumfs 2D': {
  7530. url: URL_vue_Gloumfs2D,
  7531. paramid: 'vue_mountyzilla',
  7532. func: getVueScript,
  7533. extra_params: {}
  7534. },
  7535. 'Vue Gloumfs 3D': {
  7536. url: URL_vue_Gloumfs3D,
  7537. paramid: 'vue_mountyzilla',
  7538. func: getVueScript,
  7539. extra_params: {}
  7540. },
  7541. 'Grouky Vue!': {
  7542. url: URL_vue_Grouky,
  7543. paramid: 'vue',
  7544. func: getVueScript,
  7545. extra_params: {
  7546. 'type_vue': 'V5b1'
  7547. }
  7548. },
  7549. /*'DEBUG': {
  7550. url: 'http://weblocal/testeur.php',
  7551. paramid: 'vue',
  7552. func: getVueScript,
  7553. extra_params: {}
  7554. }*/
  7555. };
  7556.  
  7557. function getVueScript() {
  7558. try {
  7559. var txt = bddTrolls()+
  7560. bddMonstres()+
  7561. bddChampignons()+
  7562. bddTresors()+
  7563. bddLieux()+
  7564. '#DEBUT ORIGINE\n'+
  7565. getPorteVue()[2]+';'+positionToString(getPosition())+
  7566. '\n#FIN ORIGINE\n';
  7567. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  7568. return txt;
  7569. } catch(e) {
  7570. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7571. window.console.error(traceStack(e, 'getVueScript'))
  7572. }
  7573. }
  7574.  
  7575. function refresh2DViewButton() {
  7576. // = EventListener menu+bouton vue 2D
  7577. var vueext = document.getElementById('selectVue2D').value;
  7578. MY_setValue('VUEEXT',vueext);
  7579. var form = document.getElementById('viewForm');
  7580. form.innerHTML = '';
  7581. form.method = 'post';
  7582. form.action = vue2Ddata[vueext].url;
  7583. form.target = '_blank';
  7584. appendHidden(form, vue2Ddata[vueext].paramid, '');
  7585. for(var key in vue2Ddata[vueext].extra_params) {
  7586. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  7587. }
  7588. appendSubmit(form, 'Voir',
  7589. function() {
  7590. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  7591. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  7592. vue2Ddata[vueext].func();
  7593. }
  7594. );
  7595. }
  7596.  
  7597. function set2DViewSystem() {
  7598. // Initialise le système de vue 2D
  7599. // Recherche du point d'insertion
  7600. try {
  7601. var center = document.evaluate(
  7602. "//h2[@id='titre2']/following-sibling::center",
  7603. document, null, 9, null
  7604. ).singleNodeValue;
  7605. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  7606. if (!center) center = document.evaluate(
  7607. "//h2[@id='titre2']/following-sibling::div",
  7608. document, null, 9, null
  7609. ).singleNodeValue;
  7610. } catch(e) {
  7611. avertissement("Erreur d'initialisation du système de vue 2D");
  7612. window.console.error(traceStack(e, 'set2DViewSystem'));
  7613. return;
  7614. }
  7615. // Récupération de la dernière vue utilisée
  7616. var vueext = MY_getValue('VUEEXT');
  7617. if(!vueext || !vue2Ddata[vueext]) {
  7618. // sinon, la vue Bricol'Trolls est employée par défaut
  7619. vueext = 'Bricol\' Vue';
  7620. }
  7621. try {
  7622. // Création du sélecteur de vue externe
  7623. selectVue2D = document.createElement('select');
  7624. selectVue2D.id = 'selectVue2D';
  7625. selectVue2D.className = 'SelectboxV2';
  7626. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  7627. for(var view in vue2Ddata) {
  7628. appendOption(selectVue2D, view, view);
  7629. }
  7630. selectVue2D.value = vueext;
  7631. selectVue2D.onchange = refresh2DViewButton;
  7632. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  7633. var form = document.createElement('form');
  7634. form.id = 'viewForm';
  7635. // Insertion du système de vue
  7636. var table = document.createElement('table');
  7637. var tr = appendTr(table);
  7638. var td = appendTd(tr);
  7639. td.appendChild(selectVue2D);
  7640. td = appendTd(tr);
  7641. td.style.fontSize = '0px'; // gère le bug de l'extra character
  7642. td.appendChild(form);
  7643. center.insertBefore(table,center.firstChild);
  7644. insertBr(center.childNodes[1]);
  7645. // Appelle le handler pour initialiser le bouton de submit
  7646. refresh2DViewButton();
  7647. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  7648. } catch(e) {
  7649. avertissement("Erreur de traitement du système de vue 2D");
  7650. window.console.error(traceStack(e, 'set2DViewSystem'));
  7651. }
  7652. }
  7653.  
  7654. /* [functions] Tableau d'Infos */
  7655. function initialiseInfos() {
  7656. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  7657. var
  7658. infoTab = document.getElementsByName('LimitViewForm')[0].
  7659. getElementsByTagName('table')[0],
  7660. tbody = infoTab.tBodies[0],
  7661. thead = infoTab.createTHead(),
  7662. tr = appendTr(thead,'mh_tdtitre'),
  7663. td = appendTdText(tr,'INFORMATIONS',true),
  7664. span = document.createElement('span');
  7665. // Récupération de la position du joueur
  7666. try {
  7667. var strPos = document.evaluate(
  7668. ".//li/b/text()[contains(.,'X = ')]",
  7669. infoTab, null, 9, null
  7670. ).singleNodeValue.nodeValue;
  7671. // ***INIT GLOBALE*** currentPosition
  7672. currentPosition = getNumbers(strPos);
  7673. debugMZ("retrievePosition(): "+currentPosition);
  7674. } catch(e) {
  7675. // Si on ne trouve pas le "X ="
  7676. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  7677. }
  7678. // Récupération des portées (max et limitée) de la vue
  7679. try {
  7680. var
  7681. nodes = document.evaluate(
  7682. ".//li/b/text()[contains(.,'horizontalement') "+
  7683. "or contains(.,'verticalement')]",
  7684. infoTab, null, 7, null
  7685. ),
  7686. array = [];
  7687. for(var i=0 ; i<4 ; i++) {
  7688. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  7689. }
  7690. // ***INIT GLOBALE*** porteeVue
  7691. porteeVue = array;
  7692. } catch(e) {
  7693. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  7694. }
  7695.  
  7696. infoTab.id = 'infoTab'; // Pour scripts externes
  7697. tbody.id = 'corpsInfoTab';
  7698. tbody.rows[0].cells[0].colSpan = 2;
  7699. td.colSpan = 3;
  7700. td.onmouseover = function() {
  7701. this.style.cursor = 'pointer';
  7702. this.className = 'mh_tdpage';
  7703. };
  7704. td.onmouseout = function() {
  7705. this.className = 'mh_tdtitre';
  7706. };
  7707. td.onclick = function() {
  7708. toggleTableauInfos(false);
  7709. };
  7710. span.id = 'msgInfoTab';
  7711. span.style.display = 'none';
  7712. appendText(
  7713. span,
  7714. ' => Position : X = '+currentPosition[0]+
  7715. ', Y = '+currentPosition[1]+
  7716. ', N = '+currentPosition[2]+
  7717. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  7718. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  7719. true
  7720. );
  7721. td.appendChild(span);
  7722. tr = appendTr(tbody,'mh_tdpage');
  7723. td = appendTdText(tr,'EFFACER : ',true);
  7724. td.align = 'center';
  7725. td.className = 'mh_tdtitre';
  7726. td.width = 100;
  7727. td = appendTdCenter(tr,2);
  7728. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  7729. checkBoxGG = appendCheckBoxSpan(
  7730. td,'delgg',filtreTresors," Les GG'"
  7731. ).firstChild;
  7732. checkBoxCompos = appendCheckBoxSpan(
  7733. td,'delcomp',filtreTresors,' Les Compos'
  7734. ).firstChild;
  7735. checkBoxBidouilles = appendCheckBoxSpan(
  7736. td,'delbid',filtreTresors,' Les Bidouilles'
  7737. ).firstChild;
  7738. checkBoxIntangibles = appendCheckBoxSpan(
  7739. td,'delint',filtreTrolls,' Les Intangibles'
  7740. ).firstChild;
  7741. checkBoxGowaps = appendCheckBoxSpan(
  7742. td,'delgowap',filtreMonstres,' Les Gowaps'
  7743. ).firstChild;
  7744. checkBoxEngages = appendCheckBoxSpan(
  7745. td,'delengage',filtreMonstres,' Les Engagés'
  7746. ).firstChild;
  7747. checkBoxLevels = appendCheckBoxSpan(
  7748. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  7749. ).firstChild;
  7750. checkBoxDiplo = appendCheckBoxSpan(
  7751. td,'delDiplo',refreshDiplo,' La Diplomatie'
  7752. ).firstChild;
  7753. checkBoxTrou = appendCheckBoxSpan(
  7754. td,'deltrou',filtreLieux,' Les Trous'
  7755. ).firstChild;
  7756. checkBoxMythiques = appendCheckBoxSpan(
  7757. td,'delmyth',filtreMonstres,' Les Mythiques'
  7758. ).firstChild;
  7759. if(MY_getValue('NOINFOEM')!='true') {
  7760. checkBoxEM = appendCheckBoxSpan(
  7761. td,'delem',filtreMonstres,' Les Composants EM'
  7762. ).firstChild;
  7763. }
  7764. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  7765. td,'deltres',filtreTresors,' Les Trésors non libres'
  7766. ).firstChild;
  7767. checkBoxTactique = appendCheckBoxSpan(
  7768. td,'deltactique',updateTactique,' Les Infos tactiques'
  7769. ).firstChild;
  7770. if(MY_getValue('INFOPLIE')) {
  7771. toggleTableauInfos(true);
  7772. }
  7773. }
  7774.  
  7775. function toggleTableauInfos(firstRun) {
  7776. var
  7777. msg = document.getElementById('msgInfoTab'),
  7778. corps = document.getElementById('corpsInfoTab'),
  7779. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7780. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  7781. if(!firstRun) {
  7782. infoplie = !infoplie;
  7783. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7784. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  7785. }
  7786. if(infoplie) {
  7787. msg.style.display = '';
  7788. corps.style.display = 'none';
  7789. } else {
  7790. msg.style.display = 'none';
  7791. corps.style.display = '';
  7792. }
  7793. }
  7794.  
  7795. /* [functions] Filtres */
  7796. function prepareFiltrage(ref,width) {
  7797. // = Initialise le filtre 'ref'
  7798. try {
  7799. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  7800. } catch(e) {
  7801. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  7802. return false;
  7803. }
  7804. if(width) { tdTitre.width = width; }
  7805. // Ajout du tr de Filtrage (masqué)
  7806. var tbody = tdTitre.parentNode.parentNode;
  7807. var tr = appendTr(tbody,'mh_tdpage');
  7808. tr.style.display = 'none';
  7809. tr.id = 'trFiltre'+ref;
  7810. var td = appendTd(tr);
  7811. td.colSpan = 5;
  7812. // Ajout du bouton de gestion de Filtrage
  7813. var tdBtn = insertTd(tdTitre.nextSibling);
  7814. tdBtn.id = 'tdInsert'+ref;
  7815. var btn = appendButton(tdBtn,'Filtrer');
  7816. btn.id = 'btnFiltre'+ref;
  7817. btn.onclick = function() {
  7818. debutFiltrage(ref)
  7819. };
  7820. return td;
  7821. }
  7822.  
  7823. function debutFiltrage(ref) {
  7824. // = Handler de début de filtrage (filtre 'ref')
  7825. document.getElementById('trFiltre'+ref).style.display = '';
  7826. var btn = document.getElementById('btnFiltre'+ref);
  7827. btn.value = 'Annuler Filtre';
  7828. btn.onclick = function() {
  7829. finFiltrage(ref);
  7830. };
  7831. }
  7832.  
  7833. function finFiltrage(ref) {
  7834. // = Handler de fin de filtrage (filtre 'ref')
  7835. /* On réassigne le bouton 'Filtrer' */
  7836. document.getElementById('trFiltre'+ref).style.display = 'none';
  7837. var btn = document.getElementById('btnFiltre'+ref);
  7838. btn.value = 'Filtrer';
  7839. btn.onclick = function() {
  7840. debutFiltrage(ref);
  7841. };
  7842. /* Réinitialisation filtres */
  7843. document.getElementById('str'+ref).value = '';
  7844. switch(ref) {
  7845. case 'Monstres':
  7846. document.getElementById('nivMinMonstres').value = 0;
  7847. document.getElementById('nivMaxMonstres').value = 0;
  7848. break;
  7849. case 'Trolls':
  7850. document.getElementById('strGuildes').value = '';
  7851. }
  7852. /* Nettoyage (=lance le filtre) */
  7853. // Ici this = MZ.global = sandBox de travail de MZ
  7854. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  7855. //this['filtre'+ref]();
  7856. switch (ref) {
  7857. case 'Monstres':
  7858. filtreMonstres();
  7859. break;
  7860. case 'Trolls':
  7861. filtreTrolls();
  7862. break;
  7863. case 'Tresors':
  7864. filtreTresors();
  7865. break;
  7866. case 'Lieux':
  7867. filtreLieux();
  7868. break;
  7869. default:
  7870. window.console.log('cas incongru dans finFiltrage : ' + ref);
  7871. break;
  7872. }
  7873. }
  7874.  
  7875. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  7876. var bouton = appendButton(td,nomBouton,onClick);
  7877. appendText(td,'\u00a0');
  7878. var textbox = appendTextbox(td,'text',id,15,30);
  7879. textbox.onkeypress = function(event) {
  7880. try {
  7881. if(event.keyCode==13) {
  7882. event.preventDefault();
  7883. bouton.click();
  7884. }
  7885. }
  7886. catch(e){
  7887. window.alert(e)
  7888. }
  7889. };
  7890. }
  7891.  
  7892. function ajoutFiltreMenu(tr,id,onChange) {
  7893. var select = document.createElement('select');
  7894. select.id = id;
  7895. select.onchange = onChange;
  7896. appendOption(select,0,'Aucun');
  7897. for(var i=1 ; i<=60 ; i++) {
  7898. appendOption(select,i,i);
  7899. }
  7900. tr.appendChild(select);
  7901. return select;
  7902. }
  7903.  
  7904. function ajoutDesFiltres() {
  7905. /* Monstres */
  7906. var td = prepareFiltrage('Monstres',120);
  7907. if(td) {
  7908. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  7909. appendText(td,'\u00a0\u00a0\u00a0');
  7910. appendText(td,'Niveau Min: ');
  7911. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  7912. appendText(td,'\u00a0');
  7913. appendText(td,'Niveau Max: ');
  7914. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  7915. }
  7916. /* Trõlls */
  7917. td = prepareFiltrage('Trolls',50);
  7918. if(td) {
  7919. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  7920. appendText(td,'\u00a0\u00a0\u00a0');
  7921. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  7922. }
  7923. /* Trésors */
  7924. td = prepareFiltrage('Tresors',55);
  7925. if(td) {
  7926. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  7927. }
  7928. /* Lieux */
  7929. td = prepareFiltrage('Lieux',40);
  7930. if(td) {
  7931. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  7932. }
  7933. }
  7934.  
  7935. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  7936.  
  7937. /* [functions] Affichage de la colonne des niveaux */
  7938. function insertLevelColumn() {
  7939. // Déclenché si bascule vers affichage des niveaux des mobs
  7940. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7941. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  7942. td.width = 25;
  7943. for(var i=1 ; i<=nbMonstres ; i++) {
  7944. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7945. td = insertTdText(getMonstreLevelNode(i), '-');
  7946. td.onclick = function() {
  7947. basculeCDM(
  7948. getMonstreNomByTR(this.parentNode),
  7949. getMonstreIDByTR(this.parentNode)
  7950. );
  7951. };
  7952. td.onmouseover = function() {
  7953. this.style.cursor = 'pointer';
  7954. this.className = 'mh_tdtitre';
  7955. };
  7956. td.onmouseout = function() {
  7957. if(this.parentNode.diploActive=='oui') {
  7958. this.className = '';
  7959. } else {
  7960. this.className = 'mh_tdpage';
  7961. }
  7962. };
  7963. td.style = 'font-weight:bold;text-align:center;';
  7964. if(isCDMsRetrieved) {
  7965. // Rappel des niveaux si mémorisés
  7966. td.innerHTML = listeLevels[i];
  7967. }
  7968. }
  7969. }
  7970.  
  7971. function toggleLevelColumn() {
  7972. // = Handler checkBox noLevel
  7973. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  7974. insertLevelColumn();
  7975. if(!isCDMsRetrieved) { retrieveCDMs(); }
  7976. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  7977. for(var i=0 ; i<=nbMonstres ; i++) {
  7978. if(isCDMsRetrieved) {
  7979. // Mémorisation des niveaux pour rappel éventuel
  7980. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  7981. }
  7982. // Suppression du td Niveau
  7983. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  7984. }
  7985. }
  7986. }
  7987.  
  7988. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  7989. function basculeCDM(nom,id) {
  7990. // = Bascule l'affichage des popups CdM
  7991. if(listeCDM[id]) {
  7992. if(!document.getElementById('popupCDM'+id)) {
  7993. afficherCDM(nom, id);
  7994. } else {
  7995. cacherPopupCDM('popupCDM'+id);
  7996. }
  7997. }
  7998. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  7999. }
  8000.  
  8001. function cacherPopupCDM(titre) {
  8002. var popup = document.getElementById(titre);
  8003. popup.parentNode.removeChild(popup);
  8004. }
  8005.  
  8006. /* DEBUG: Section à mettre à jour */
  8007. var selectionFunction;
  8008.  
  8009. function startDrag(evt) {
  8010. winCurr = this.parentNode;
  8011. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8012. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8013. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8014. selectionFunction = document.body.style.MozUserSelect;
  8015. document.body.style.MozUserSelect = 'none';
  8016. winCurr.style.MozUserSelect = 'none';
  8017. return false;
  8018. }
  8019.  
  8020. function stopDrag(evt) {
  8021. winCurr.style.MozUserSelect = selectionFunction;
  8022. document.body.style.MozUserSelect = selectionFunction;
  8023. winCurr = null;
  8024. }
  8025.  
  8026. function drag(evt) {
  8027. if(winCurr==null) { return; }
  8028. evt = evt || window.event;
  8029. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8030. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8031. return false;
  8032. }
  8033. /* FIN DEBUG */
  8034.  
  8035. function afficherCDM(nom,id) {
  8036. // Crée la table de CdM du mob n° id
  8037. var donneesMonstre = listeCDM[id];
  8038. /* Début création table */
  8039. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8040. table.id = 'popupCDM'+id;
  8041. table.style =
  8042. 'position:fixed;'+
  8043. 'z-index:1;'+
  8044. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8045. 'left:'+(window.innerWidth-365)+'px;'+
  8046. 'width:300px;'+
  8047. 'height:200px;';
  8048. /* Ajout du titre avec gestion Drag & Drop */
  8049. var tr = table.firstChild;
  8050. tr.style.cursor = 'move';
  8051. tr.onmousedown = startDrag;
  8052. tr.onmouseup = stopDrag;
  8053. /* Ajout du bouton "Fermer" */
  8054. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8055. tr.onmouseover = function() {
  8056. this.style.cursor = 'pointer';
  8057. this.className = 'mh_tdpage';
  8058. };
  8059. tr.onmouseout = function() {
  8060. this.className = 'mh_tdtitre';
  8061. };
  8062. tr.idcdm = id;
  8063. tr.onclick = function() {
  8064. cacherPopupCDM('popupCDM'+this.idcdm);
  8065. this.className = 'mh_tdtitre';
  8066. };
  8067. td = appendTdText(tr,'Fermer',true);
  8068. td.colSpan = 2;
  8069. td.style = 'text-align:center;';
  8070. nbCDM++;
  8071. /* Fin création table & Affichage */
  8072. document.body.appendChild(table);
  8073. }
  8074.  
  8075. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8076. function initPopupVue() {
  8077. popup = document.createElement('div');
  8078. popup.id = 'popup';
  8079. popup.className = 'mh_textbox';
  8080. popup.style =
  8081. 'position: absolute;'+
  8082. 'border: 1px solid #000000;'+
  8083. 'visibility: hidden;'+
  8084. 'display: inline;'+
  8085. 'z-index: 3;'+
  8086. 'max-width: 400px;';
  8087. document.body.appendChild(popup);
  8088. }
  8089.  
  8090. // roule 16/03/2016 supprimé, existe déjà dans vue
  8091. // function showPopupTactique(evt) {
  8092. // var id = this.id;
  8093. // var nom = this.nom;
  8094. // var texte = getAnalyseTactique(id,nom);
  8095. // if(texte=='') { return; }
  8096. // popup.innerHTML = texte;
  8097. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  8098. // popup.style.top = (evt.pageY+15)+'px';
  8099. // popup.style.visibility = 'visible';
  8100. // }
  8101.  
  8102. // roule 16/03/2016, existe déjà ailleurs
  8103. // function hidePopup() {
  8104. // popup.style.visibility = 'hidden';
  8105. // }
  8106.  
  8107. /* [functions] Récupération / Computation des Infos Tactiques */
  8108. // TODO à revoir
  8109. function retireMarquage(nom) {
  8110. var i = nom.indexOf(']');
  8111. switch(i) {
  8112. case -1:
  8113. case nom.length-1:
  8114. return nom;
  8115. default:
  8116. return nom.slice(0,i+1);
  8117. }
  8118. }
  8119.  
  8120. function showPopupError(sHTML) {
  8121. var divpopup = document.createElement('div');
  8122. divpopup.id = 'divpopup';
  8123. divpopup.style =
  8124. 'position: fixed;'+
  8125. 'border: 3px solid #000000;'+
  8126. 'top: 300px;left: 10px;'+
  8127. 'background-color: red;'+
  8128. 'color: white;'+
  8129. 'font-size: xx-large;'+
  8130. 'z-index: 200;';
  8131. divpopup.innerHTML = sHTML;
  8132. var divcroix = document.createElement('div');
  8133. divcroix.style =
  8134. 'position: absolute;'+
  8135. 'top: 0;right: 0;'+
  8136. 'color: inherit;'+
  8137. 'font-size: inherit;'+
  8138. 'cursor: pointer;'+
  8139. 'z-index: 201;';
  8140. divcroix.innerHTML = "X";
  8141. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8142. document.body.appendChild(divpopup);
  8143. divpopup.appendChild(divcroix);
  8144. }
  8145.  
  8146. function retrieveCDMs() {
  8147. // Récupère les CdM disponibles dans la BDD
  8148. // Lancé uniquement sur toggleLevelColumn
  8149. if(checkBoxLevels.checked) { return; }
  8150. var str = '';
  8151. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8152. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8153. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8154. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  8155. for(var i=1 ; i<=cdmMax ; i++) {
  8156. var nomMonstre = retireMarquage(getMonstreNom(i));
  8157. if(nomMonstre.indexOf(']') != -1) {
  8158. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  8159. }
  8160. // *** WARNING : PROXY RATIBUS ***
  8161. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  8162. str += 'nom[]='+escape(nomMonstre)+'$'+(
  8163. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  8164. )+'&';
  8165. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  8166. FF_XMLHttpRequest({
  8167. method: 'POST',
  8168. url: URL_MZinfoMonstre,
  8169. headers : {
  8170. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8171. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8172. 'Content-type':'application/x-www-form-urlencoded'
  8173. },
  8174. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  8175. onload: function(responseDetails) {
  8176. try {
  8177. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  8178. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  8179. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  8180. '" target="raistlin">Mountyzilla - https<br />'+
  8181. 'Tu dois accepter le certificat de Raistlin<br />'+
  8182. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  8183. ' « Confirmer l\'exception de sécurité »</a>');
  8184. return;
  8185. }
  8186. var texte = responseDetails.responseText;
  8187. var lines = texte.split('\n');
  8188. if(lines.length==0) { return; }
  8189. var begin2, end2, index;
  8190. for(var j=0 ; j<lines.length ; j++) {
  8191. var infos = lines[j].split(';');
  8192. if(infos.length<4) { continue; }
  8193. var idMonstre=infos[0];
  8194. var isCDM = infos[1];
  8195. index = parseInt(infos[2]);
  8196. var level = infos[3];
  8197. infos = infos.slice(3);
  8198. if(begin2==null) { begin2 = index; }
  8199. end2 = index;
  8200. listeCDM[idMonstre] = infos;
  8201. if(isCDM==1) {
  8202. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  8203. } else {
  8204. getMonstreLevelNode(index).innerHTML = level;
  8205. }
  8206. }
  8207. computeMission(begin2,end2);
  8208. } catch(e) {
  8209. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  8210. }
  8211. }
  8212. });
  8213. str = '';
  8214. begin = i+1;
  8215. }
  8216. }
  8217. isCDMsRetrieved=true;
  8218. }
  8219.  
  8220. function computeMission(begin,end) {
  8221. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  8222. computeVLC(begin,end);
  8223. if(!begin) begin=1;
  8224. if(!end) end=nbMonstres;
  8225. var str = MY_getValue(numTroll+'.MISSIONS');
  8226. if(!str) { return; }
  8227. var urlImg = URL_MZimg+'mission.png';
  8228. var obMissions = JSON.parse(str);
  8229. for(var i=end ; i>=begin ; i--) {
  8230. var mess = '';
  8231. for(var num in obMissions) {
  8232. var mobMission = false;
  8233. switch(obMissions[num].type) {
  8234. case 'Race':
  8235. var race = epure(obMissions[num].race.toLowerCase());
  8236. var nom = epure(getMonstreNom(i).toLowerCase());
  8237. if(nom.indexOf(race)!=-1) {
  8238. mobMission = true;
  8239. }
  8240. break;
  8241. case 'Niveau':
  8242. var donneesMonstre = listeCDM[getMonstreID(i)];
  8243. if(donneesMonstre) {
  8244. var nivMob = Number(donneesMonstre[0]);
  8245. var nivMimi = Number(obMissions[num].niveau),
  8246. mod = obMissions[num].mod;
  8247. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  8248. || (isNaN(mod) && nivMob>=nivMimi)) {
  8249. mobMission = true;
  8250. }
  8251. }
  8252. break;
  8253. case 'Famille':
  8254. var donneesMonstre = listeCDM[getMonstreID(i)];
  8255. if(donneesMonstre) {
  8256. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  8257. var familleMob = epure(donneesMonstre[1].toLowerCase());
  8258. if(familleMob.indexOf(familleMimi)!=-1) {
  8259. mobMission = true;
  8260. }
  8261. }
  8262. break;
  8263. case 'Pouvoir':
  8264. var donneesMonstre = listeCDM[getMonstreID(i)];
  8265. if(donneesMonstre) {
  8266. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  8267. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  8268. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8269. mobMission = true;
  8270. }
  8271. }
  8272. }
  8273. if(mobMission) {
  8274. mess += mess ? '\n\n' : '';
  8275. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8276. }
  8277. }
  8278. if(mess) {
  8279. var td = getMonstreNomNode(i);
  8280. appendText(td,' ');
  8281. td.appendChild(createImage(urlImg,mess));
  8282. }
  8283. }
  8284. }
  8285.  
  8286. function computeVLC(begin,end) {
  8287. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8288. computeTactique(begin,end);
  8289. if(!begin) begin=1;
  8290. if(!end) end=nbMonstres;
  8291. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8292. if(!cache)
  8293. return false;
  8294. var urlImg = URL_MZimg + "oeil.png";
  8295. for(var i = end; i >= begin;i--)
  8296. {
  8297. var id = getMonstreID(i);
  8298. var donneesMonstre = listeCDM[id];
  8299. if(donneesMonstre && donneesMonstre.length>12)
  8300. {
  8301. if(donneesMonstre[12]==1)
  8302. {
  8303. var td = getMonstreNomNode(i);
  8304. td.appendChild(document.createTextNode(" "));
  8305. td.appendChild(createImage(urlImg, "Voit le caché"));
  8306. }
  8307. }
  8308. }
  8309. }
  8310.  
  8311. function computeTactique(begin, end) {
  8312. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8313. try {
  8314. if(!begin) begin = 1;
  8315. if(!end) end = nbMonstres;
  8316. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8317. if(noTactique || !isProfilActif()) return;
  8318. for(var j=end ; j>=begin ; j--) {
  8319. var id = getMonstreID(j);
  8320. var nom = getMonstreNom(j);
  8321. var donneesMonstre = listeCDM[id];
  8322. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8323. var td = getMonstreNomNode(j);
  8324. appendText(td,' ');
  8325. td.appendChild(
  8326. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  8327. );
  8328. }
  8329. }
  8330. }
  8331. catch(e) {
  8332. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8333. }
  8334. filtreMonstres();
  8335. }
  8336.  
  8337. function updateTactique() {
  8338. // = Handler checkBox noTactique
  8339. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8340. if(!isCDMsRetrieved) return;
  8341. if(noTactique) {
  8342. for(var i=nbMonstres ; i>0 ; i--) {
  8343. var tr = getMonstreNomNode(i);
  8344. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  8345. tr, null, 9, null).singleNodeValue;
  8346. if(img) {
  8347. img.parentNode.removeChild(img.previousSibling);
  8348. img.parentNode.removeChild(img);
  8349. }
  8350. }
  8351. }
  8352. else
  8353. computeTactique();
  8354. }
  8355.  
  8356. function filtreMonstres() {
  8357. // = Handler universel pour les fonctions liées aux monstres
  8358. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  8359. urlEnchantImg = URL_MZimg+'images/enchant.png';
  8360. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  8361. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  8362. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  8363. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  8364. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  8365. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  8366. // old/new : détermine s'il faut ou non nettoyer les tr
  8367. var oldNOEM = true, noEM = true;
  8368. if(MY_getValue('NOINFOEM')!='true') {
  8369. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  8370. }
  8371. // Filtrage par nom
  8372. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  8373. // Génère la liste des mobs engagés (si filtrés)
  8374. if(noEngages && !isEngagesComputed) {
  8375. for(var i=nbTrolls ; i>0 ; i--) {
  8376. var pos = getTrollPosition(i);
  8377. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  8378. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  8379. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  8380. }
  8381. isEngagesComputed = true;
  8382. }
  8383. /*** FILTRAGE ***/
  8384. /* À computer :
  8385. * - EM (nom suffit)
  8386. * - Enchant (nom suffit)
  8387. * - Mission (nécessite CdM)
  8388. * - mob VlC (nécessite CdM)
  8389. * Sans computation :
  8390. * - Gowap ? engagé ?
  8391. */
  8392. for(var i=nbMonstres ; i>0 ; i--) {
  8393. var pos = getMonstrePosition(i);
  8394. var nom = getMonstreNom(i).toLowerCase();
  8395. if(noEM!=oldNOEM) {
  8396. if(noEM) {
  8397. // Si noEM passe de false à true, on nettoie les td "Nom"
  8398. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  8399. var tr = getMonstreNomNode(i);
  8400. while(tr.childNodes.length>1) {
  8401. tr.removeChild(tr.childNodes[1]);
  8402. }
  8403. } else {
  8404. var tr = getMonstreNomNode(i);
  8405. var TypeMonstre=getEM(nom);
  8406. if(TypeMonstre!='') {
  8407. var infosCompo=compoMobEM(TypeMonstre);
  8408. if(infosCompo.length>0) {
  8409. tr.appendChild(document.createTextNode(' '));
  8410. tr.appendChild(createImage(urlImg, infosCompo));
  8411. }
  8412. }
  8413. }
  8414. }
  8415. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  8416. var texte = getInfoEnchantementFromMonstre(nom);
  8417. if(texte!='') {
  8418. var td = getMonstreNomNode(i);
  8419. td.appendChild(document.createTextNode(' '));
  8420. td.appendChild(createImage(urlEnchantImg, texte));
  8421. }
  8422. }
  8423. tr_monstres[i].style.display = (
  8424. noGowaps &&
  8425. nom.indexOf('gowap apprivoisé')!=-1 &&
  8426. getMonstreDistance(i)>1
  8427. ) || (
  8428. noEngages &&
  8429. getMonstreDistance(i)!=0 &&
  8430. listeEngages[pos[0]] &&
  8431. listeEngages[pos[0]][pos[1]] &&
  8432. listeEngages[pos[0]][pos[1]][pos[2]]
  8433. ) || (
  8434. strMonstre!='' &&
  8435. nom.indexOf(strMonstre)==-1
  8436. ) || (
  8437. nivMin>0 &&
  8438. getMonstreLevel(i)!=-1 &&
  8439. getMonstreLevel(i)<nivMin &&
  8440. getMonstreDistance(i)>1 &&
  8441. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  8442. ) || (
  8443. nivMax>0 &&
  8444. getMonstreLevel(i)>nivMax &&
  8445. getMonstreDistance(i)>1 &&
  8446. nom.toLowerCase().indexOf("kilamo")==-1
  8447. ) ? 'none' : '';
  8448. }
  8449. if(MY_getValue('NOINFOEM')!='true') {
  8450. if(noEM != oldNOEM) {
  8451. if(noEM && isCDMsRetrieved) computeMission();
  8452. }
  8453. oldNOEM = noEM;
  8454. }
  8455. needComputeEnchantement = false;
  8456. }
  8457.  
  8458.  
  8459. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  8460.  
  8461. function filtreTrolls() {
  8462. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  8463. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  8464. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  8465. for(var i=1 ; i<=nbTrolls ; i++) {
  8466. tr_trolls[i].style.display = (
  8467. noIntangibles &&
  8468. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  8469. ) || (
  8470. strTroll!='' &&
  8471. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  8472. ) || (
  8473. strGuilde!='' &&
  8474. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  8475. ) ? 'none' : '';
  8476. }
  8477. }
  8478.  
  8479. /* [functions] Bulle PX Trolls */
  8480. var bulle;
  8481.  
  8482. function initPXTroll() {
  8483. bulle = document.createElement('div');
  8484. bulle.id = 'bulle';
  8485. bulle.className = 'mh_textbox';
  8486. bulle.style =
  8487. 'position: absolute;'+
  8488. 'border: 1px solid #000000;'+
  8489. 'visibility: hidden;'+
  8490. 'display: inline;'+
  8491. 'z-index: 2;';
  8492. document.body.appendChild(bulle);
  8493.  
  8494. for(var i=nbTrolls ; i>0 ; i--) {
  8495. var td_niv = getTrollNivNode(i);
  8496. td_niv.onmouseover = showPXTroll;
  8497. td_niv.onmouseout = hidePXTroll;
  8498. }
  8499. }
  8500.  
  8501. function showPXTroll(evt) {
  8502. var lvl = this.firstChild.nodeValue;
  8503. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  8504. bulle.style.left = evt.pageX+15+'px';
  8505. bulle.style.top = evt.pageY+'px';
  8506. bulle.style.visibility = 'visible';
  8507. }
  8508.  
  8509. function hidePXTroll() {
  8510. bulle.style.visibility = 'hidden';
  8511. }
  8512.  
  8513. /* [functions] Envoi PX / MP */
  8514. function putBoutonPXMP() {
  8515. // Bouton d'initialisation du mode Envoi
  8516. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8517. var td = document.getElementById('tdInsertTrolls');
  8518. if(!td) { return; }
  8519. td.width = 100;
  8520. td = insertTd(td.nextSibling);
  8521. td.style.verticalAlign = 'top';
  8522. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8523. bouton.id = 'btnEnvoi';
  8524. }
  8525.  
  8526. function prepareEnvoi() {
  8527. // = 1er Handler du bouton d'envoi
  8528. /* Ajout de la colonne des CheckBoxes */
  8529. var td = insertTdText(getTrollNomNode(0),'');
  8530. td.width = 5;
  8531. for(var i=nbTrolls ; i>0 ; i--) {
  8532. td = insertTd(getTrollNomNode(i));
  8533. appendCheckBox(td,'envoi'+i);
  8534. }
  8535. /* Ajout du radio de choix PX ou MP */
  8536. var btnEnvoi = document.getElementById('btnEnvoi');
  8537. if(!btnEnvoi) { return; }
  8538. var tdEnvoi = btnEnvoi.parentNode;
  8539. appendText(tdEnvoi,' ');
  8540. var span = document.createElement('span');
  8541. span.style.whiteSpace = 'nowrap';
  8542. var radioElt = document.createElement('input');
  8543. radioElt.type = 'radio';
  8544. radioElt.name = 'envoiPXMP';
  8545. radioElt.id = 'radioPX';
  8546. span.appendChild(radioElt);
  8547. appendText(span,' des PX ');
  8548. radioElt = document.createElement('input');
  8549. radioElt.type = 'radio';
  8550. radioElt.name = 'envoiPXMP';
  8551. radioElt.checked = true;
  8552. span.appendChild(radioElt);
  8553. appendText(span,' un MP');
  8554. tdEnvoi.appendChild(span);
  8555. /* Insertion du bouton Annuler */
  8556. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8557. /* Modification de l'effet du bouton Envoi */
  8558. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8559. }
  8560.  
  8561. function annuleEnvoi() {
  8562. // = Handler bouton Annuler
  8563. /* Nettoyage du td du bouton Envoi */
  8564. var btnEnvoi = document.getElementById('btnEnvoi');
  8565. var tdEnvoi = btnEnvoi.parentNode;
  8566. while(tdEnvoi.firstChild) {
  8567. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8568. }
  8569. /* Retour à l'effet de base du bouton Envoi */
  8570. btnEnvoi.onclick = prepareEnvoi;
  8571. tdEnvoi.appendChild(btnEnvoi);
  8572. /* Suppression CheckBoxes */
  8573. for(var i=nbTrolls ; i>=0 ; i--) {
  8574. var td = getTrollNomNode(i);
  8575. td.parentNode.removeChild(td);
  8576. }
  8577. }
  8578.  
  8579. function effectueEnvoi() {
  8580. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  8581. var str='';
  8582. for(var i=nbTrolls ; i>0 ; i--) {
  8583. var chb = document.getElementById('envoi'+i);
  8584. if(chb.checked) {
  8585. str += (str?',':'')+getTrollID(i);
  8586. }
  8587. }
  8588. var PXchecked = document.getElementById('radioPX').checked;
  8589. if(PXchecked) {
  8590. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  8591. } else {
  8592. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  8593. }
  8594. }
  8595.  
  8596. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  8597.  
  8598. function filtreTresors() {
  8599. // += Handler checkboxes : gg, compos, bidouilles, non libres
  8600. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  8601. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  8602. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  8603. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8604. if(noEngages && !isEngagesComputed) {
  8605. for(var i=nbTrolls ; i>0 ; i--) {
  8606. var pos = getTrollPosition(i);
  8607. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  8608. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  8609. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  8610. }
  8611. isEngagesComputed = true;
  8612. }
  8613. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  8614. for(var i=nbTresors ; i>0 ; i--) {
  8615. var nom = getTresorNom(i);
  8616. var pos = getTresorPosition(i);
  8617. tr_tresors[i].style.display = (
  8618. noGG &&
  8619. nom.indexOf('Gigots de Gob')!=-1
  8620. ) || (
  8621. noCompos &&
  8622. nom.indexOf('Composant')!=-1
  8623. ) || (
  8624. noEngages &&
  8625. listeEngages[pos[2]] &&
  8626. listeEngages[pos[2]][pos[1]] &&
  8627. listeEngages[pos[2]][pos[1]][pos[0]] &&
  8628. getTresorDistance(i)>0
  8629. ) || (
  8630. strTresor!='' &&
  8631. nom.toLowerCase().indexOf(strTresor)==-1
  8632. ) || (
  8633. noBidouilles &&
  8634. nom.indexOf('Bidouille')!=-1
  8635. ) ? 'none' : '';
  8636. }
  8637. }
  8638.  
  8639.  
  8640. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  8641.  
  8642. function filtreLieux() {
  8643. // += Handler checkbox trous
  8644. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  8645. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  8646. for(var i=nbLieux ; i>0 ; i--) {
  8647. tr_lieux[i].style.display = (
  8648. strLieu &&
  8649. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  8650. ) || (
  8651. noTrou &&
  8652. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  8653. getLieuDistance(i)>1
  8654. ) ? 'none' : '';
  8655. }
  8656. }
  8657.  
  8658.  
  8659. /*-[functions]-------------------- Diplomatie --------------------------------*/
  8660.  
  8661. function refreshDiplo() {
  8662. MY_setValue(numTroll+'.diplo.off',
  8663. checkBoxDiplo.checked?'true':'false'
  8664. );
  8665. if(isDiploRaw) { computeDiplo(); }
  8666. appliqueDiplo();
  8667. }
  8668.  
  8669. function computeDiplo() {
  8670. // On extrait les données de couleur et on les stocke par id
  8671. // Ordre de préséance :
  8672. // source Guilde < source Perso
  8673. // guilde cible < troll cible
  8674. /* Diplo de Guilde */
  8675. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  8676. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  8677. if(diploGuilde && diploGuilde.isOn=='true') {
  8678. // Guilde perso
  8679. if(diploGuilde.guilde) {
  8680. Diplo.Guilde[diploGuilde.guilde.id] = {
  8681. couleur: diploGuilde.guilde.couleur,
  8682. titre: 'Ma Guilde'
  8683. };
  8684. }
  8685. // Guildes/Trolls A/E
  8686. for(var AE in {Amis:0,Ennemis:0}) {
  8687. for(var i=0 ; i<5 ; i++) {
  8688. if(diploGuilde[AE+i]) {
  8689. for(var type in {Guilde:0,Troll:0}) {
  8690. var liste = diploGuilde[AE+i][type].split(';');
  8691. for(var j=liste.length-2 ; j>=0 ; j--) {
  8692. Diplo[type][liste[j]] = {
  8693. couleur: diploGuilde[AE+i].couleur,
  8694. titre: diploGuilde[AE+i].titre
  8695. };
  8696. }
  8697. }
  8698. }
  8699. }
  8700. }
  8701. }
  8702. /* Diplo Perso */
  8703. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  8704. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  8705. if(diploPerso && diploPerso.isOn=='true') {
  8706. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8707. for(var id in diploPerso[type]) {
  8708. Diplo[type][id] = diploPerso[type][id];
  8709. }
  8710. }
  8711. }
  8712. if(diploPerso.mythiques) {
  8713. Diplo.mythiques = diploPerso.mythiques;
  8714. }
  8715. isDiploRaw = false;
  8716. }
  8717.  
  8718. function appliqueDiplo() {
  8719. var aAppliquer = Diplo;
  8720. if(checkBoxDiplo.checked) {
  8721. // Pour retour à l'affichage basique sur désactivation de la diplo
  8722. aAppliquer = {
  8723. Guilde: {},
  8724. Troll: {},
  8725. Monstre: {}
  8726. };
  8727. }
  8728. /* On applique "aAppliquer" */
  8729. // Diplo Trõlls
  8730. for(var i=nbTrolls ; i>0 ; i--) {
  8731. var idG = getTrollGuildeID(i);
  8732. var idT = getTrollID(i);
  8733. var tr = tr_trolls[i];
  8734. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  8735. if(aAppliquer.Troll[idT]) {
  8736. tr.className = '';
  8737. var descr = aAppliquer.Troll[idT].titre;
  8738. if(descr) {
  8739. getTrollNomNode(i).title = descr
  8740. }
  8741. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  8742. } else if(aAppliquer.Guilde[idG]) {
  8743. tr.className = '';
  8744. var descr = aAppliquer.Guilde[idG].titre;
  8745. if(descr) {
  8746. getTrollNomNode(i).title = descr
  8747. }
  8748. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  8749. } else {
  8750. tr.className = 'mh_tdpage';
  8751. getTrollNomNode(i).title = '';
  8752. }
  8753. }
  8754. // Diplo Monstres
  8755. for(var i=nbMonstres ; i>0 ; i--) {
  8756. var id = getMonstreID(i);
  8757. var nom = getMonstreNom(i).toLowerCase();
  8758. if(aAppliquer.Monstre[id]) {
  8759. tr_monstres[i].className = '';
  8760. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  8761. tr_monstres[i].diploActive = 'oui';
  8762. var descr = aAppliquer.Monstre[id].titre;
  8763. if(descr) {
  8764. getMonstreNomNode(i).title = descr;
  8765. }
  8766. } else if(aAppliquer.mythiques &&
  8767. (nom.indexOf('liche')==0 ||
  8768. nom.indexOf('hydre')==0 ||
  8769. nom.indexOf('balrog')==0 ||
  8770. nom.indexOf('beholder')==0)) {
  8771. tr_monstres[i].className = '';
  8772. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  8773. tr_monstres[i].diploActive = 'oui';
  8774. getMonstreNomNode(i).title = 'Monstre Mythique';
  8775. } else {
  8776. tr_monstres[i].className = 'mh_tdpage';
  8777. tr_monstres[i].diploActive = '';
  8778. }
  8779. }
  8780. }
  8781.  
  8782.  
  8783. /*-[functions]---------------- Actions à distance ----------------------------*/
  8784.  
  8785. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  8786. var monN = parseInt(getPosition()[2]);
  8787. for(var type in keltypes) {
  8788. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  8789. for(var i=this['nb'+type] ; i>0 ; i--) {
  8790. var tr = this['tr_'+type.toLowerCase()][i];
  8791. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  8792. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  8793. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  8794. var sonN = getXxxPosition(type, i)[2];
  8795. var d = getXxxDistance(type, i);
  8796. if(sonN==monN && d>=dmin && d<=dmax) {
  8797. var iconeAction = document.evaluate(
  8798. "./descendant::img[@alt='"+alt+"']",
  8799. tr, null, 9, null
  8800. ).singleNodeValue;
  8801. if(iconeAction) {
  8802. if(iconeAction.title) {
  8803. iconeAction.title += "\n"+message;
  8804. } else {
  8805. iconeAction.title = message;
  8806. }
  8807. iconeAction.src = urlIcon;
  8808. } else {
  8809. var tdAction = tr.getElementsByTagName('td')[1];
  8810. var icon = document.createElement('img');
  8811. icon.src = urlIcon;
  8812. icon.height = 20;
  8813. icon.alt = alt;
  8814. icon.title = message;
  8815. tdAction.appendChild(icon);
  8816. }
  8817. }
  8818. }
  8819. }
  8820. }
  8821.  
  8822. function computeCharge() {
  8823. computeActionDistante(1,
  8824. getPortee__Vue(
  8825. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  8826. MY_getValue(numTroll+".caracs.regeneration")
  8827. ),
  8828. {'Monstres':1, 'Trolls':1},
  8829. 'Attaquer',
  8830. MHicons+'E_Metal09.png',
  8831. 'Cible à portée de Charge'
  8832. );
  8833. }
  8834.  
  8835. function computeProjo() {
  8836. computeActionDistante(0,
  8837. getPortee__Vue(
  8838. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8839. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8840. ),
  8841. {'Monstres':1, 'Trolls':1},
  8842. 'Attaquer',
  8843. MHicons+'S_Fire05.png',
  8844. 'Cible à portée de Projo'
  8845. );
  8846. }
  8847.  
  8848. function computeTelek() {
  8849. computeActionDistante(0,
  8850. Math.floor((
  8851. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8852. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8853. )/2),
  8854. {'Tresors':1},
  8855. 'Telek',
  8856. MHicons+'S_Magic04.png',
  8857. 'Trésor à portée de Télékinésie'
  8858. );
  8859. }
  8860.  
  8861. function computeLdP() {
  8862. computeActionDistante(0,
  8863. 2+Math.floor((
  8864. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8865. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8866. )/5),
  8867. {'Monstres':1, 'Trolls':1},
  8868. 'self',
  8869. MHicons+'P_Red01.png',
  8870. 'Cible à portée de Lancer de Potions'
  8871. );
  8872. }
  8873.  
  8874.  
  8875. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  8876.  
  8877. function putScriptExterne() {
  8878. var infoit = MY_getValue(numTroll+'.INFOSIT');
  8879. if(!infoit || infoit=='') return;
  8880.  
  8881. var nomit = infoit.slice(0,infoit.indexOf('$'));
  8882. if(nomit=='bricol') {
  8883. var data = infoit.split('$');
  8884. try {
  8885. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  8886. // appendNewScript(URL_bricol+data[1]
  8887. // +'/mz.php?login='+data[2]
  8888. // +'&password='+data[3]
  8889. // );
  8890. FF_XMLHttpRequest({
  8891. method: 'GET',
  8892. url: URL_bricol+data[1]
  8893. +'/mz_json.php?login='+data[2]
  8894. +'&password='+data[3],
  8895. onload: function(responseDetails) {
  8896. try {
  8897. if (responseDetails.status == 0) {
  8898. if (isHTTPS) {
  8899. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  8900. } else {
  8901. window.console.log('status=0 à l\'appel bricol\'troll');
  8902. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  8903. }
  8904. return;
  8905. }
  8906. var ratibusData;
  8907. try {
  8908. ratibusData = JSON.parse(responseDetails.responseText);
  8909. } catch(e) {}
  8910. if (ratibusData === undefined) {
  8911. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  8912. return;
  8913. }
  8914. if (ratibusData.error) {
  8915. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  8916. } else {
  8917. putInfosTrolls(ratibusData.data.trolls);
  8918. }
  8919. } catch(e) {
  8920. window.console.log(traceStack(e, 'retour bricol\'troll'));
  8921. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  8922. }
  8923. }
  8924. });
  8925. } catch(e) {
  8926. if (isHTTPS) {
  8927. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  8928. } else {
  8929. window.console.log(traceStack(e, 'appel bricol\'troll'));
  8930. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  8931. }
  8932. }
  8933. }
  8934. }
  8935.  
  8936. /* Le script mz.php de Ratibus renvoie :
  8937. + infosTrolls = new Array();
  8938. + infosTrolls[numdutroll] =
  8939. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  8940. + etc ...
  8941. + putInfosTrolls();
  8942. *
  8943. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  8944. * Roule 07/11/2016, on utilise mz_json qui envoie
  8945. {
  8946. "data": {
  8947. "trolls": {
  8948. "59424": {
  8949. "id": 59424,
  8950. "pv": xx,
  8951. "pv_max": xx,
  8952. "updated_at": "2016-10-31 07:28:40",
  8953. "dla": "2016-10-05 07:28:04",
  8954. "pa": 0
  8955. },
  8956. }
  8957. }
  8958. }
  8959. */
  8960.  
  8961. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  8962. function corrigeBricolTrolls(infosTrolls) {
  8963. for(var i in infosTrolls) {
  8964. var pv = infosTrolls[i][0];
  8965. var pvmax = infosTrolls[i][1];
  8966. var pvmem = MY_getValue(i+'.caracs.pv.max');
  8967. if(pvmem && pvmem>pvmax) {
  8968. infosTrolls[i][1] = pvmem;
  8969. pvmax = pvmem;
  8970. }
  8971. if(pv>pvmax) {
  8972. var newpvmax = 5*Math.ceil(pv/5);
  8973. MY_setValue(i+'.caracs.pv.max',newpvmax);
  8974. infosTrolls[i][1] = newpvmax;
  8975. }
  8976. }
  8977. }
  8978.  
  8979. // insère 2 TD avant nextTD avec les infos venant de l'IT
  8980. function addTdInfosTroll(infos, nextTD) {
  8981. /* cadre barre PV */
  8982. var tab = document.createElement('div');
  8983. /* ancienne méthode par img, à supprimer
  8984. tab.width = 100;
  8985. tab.style.width = 100;
  8986. tab.height = 10;
  8987. tab.style.background = '#FFFFFF';
  8988. tab.style.border = 1;
  8989. */
  8990. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  8991. /* barre PV */
  8992. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  8993. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  8994. .vieContainer {
  8995. background-color: #CCC;
  8996. width: 50px;
  8997. height: 6px;
  8998. border: 1px solid #000;
  8999. text-align: left;
  9000. }
  9001. */
  9002. tab.style.width = '100px';
  9003. tab.style.height = '10px';
  9004. tab.style.border = '1px solid #000';
  9005. tab.style.textAlign = 'left';
  9006. var div2 = document.createElement('div');
  9007. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9008. var dateLimite = new Date();
  9009. dateLimite.setDate(dateLimite.getDate() - 7);
  9010. if (infos.oUpdatedAt < dateLimite) {
  9011. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9012. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9013. } else if (pourcentVie > 66) {
  9014. div2.style.backgroundColor = '#77EE77';
  9015. } else if (pourcentVie > 33) {
  9016. div2.style.backgroundColor = '#EEEE77';
  9017. } else {
  9018. div2.style.backgroundColor = '#FF0000';
  9019. }
  9020. div2.style.width = pourcentVie + '%';
  9021. div2.style.height = '10px';
  9022. tab.appendChild(div2);
  9023. /* ancienne méthode par img, à supprimer
  9024. var img = document.createElement('img');
  9025. img.src = '../Images/Interface/milieu.gif';
  9026. img.height = 10;
  9027. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9028. tab.appendChild(img);
  9029. */
  9030.  
  9031. /* lien vers l'IT */
  9032. var lien = document.createElement('a');
  9033. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9034. lien.href = URL_bricol+nomit+'/index.php';
  9035. lien.target = '_blank';
  9036. lien.appendChild(tab);
  9037. insertTdElement(nextTD,lien);
  9038. /* PAs dispos */
  9039. var span = document.createElement('span');
  9040. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9041. appendText(span, infos.pa +' PA' );
  9042. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9043. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9044. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9045. span.style.backgroundColor = 'B8EEB8';
  9046. }
  9047. insertTdElement(nextTD, span);
  9048. }
  9049.  
  9050. function putInfosTrolls(infosTrolls) {
  9051. try {
  9052. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9053. // supression des infos trop vieilles (un mois)
  9054. var IDs = Object.keys(infosTrolls);
  9055. var dateLimite = new Date();
  9056. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9057. for (var i = 0; i < IDs.length; i++) {
  9058. var idTroll = IDs[i];
  9059. var infos = infosTrolls[idTroll];
  9060. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9061. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9062. }
  9063. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9064. td.width = 40;
  9065. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9066. td.width = 105;
  9067.  
  9068. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9069. //corrigeBricolTrolls(infosTrolls);
  9070.  
  9071. for(i=nbTrolls ; i>0 ; i--) {
  9072. var infos = infosTrolls[getTrollID(i)];
  9073. if(infos && (!infos.bIgnore)) {
  9074. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9075. infos.done = true;
  9076. } else {
  9077. insertTd(tr_trolls[i].childNodes[6]);
  9078. insertTd(tr_trolls[i].childNodes[6]);
  9079. }
  9080. }
  9081. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9082. var str = MY_getValue(numTroll+'.INFOSIT');
  9083. if(!str) return;
  9084. var arr = str.split('$');
  9085. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9086.  
  9087. //window.console.log('nb Troll IT : ' + IDs.length);
  9088. var tBody = tr_trolls[0].parentNode;
  9089. if (tr_trolls[1] === undefined)
  9090. tBody = tr_trolls[0].parentNode;
  9091. else
  9092. tBody = tr_trolls[1].parentNode;
  9093. var pos = getPosition();
  9094. for (i = 0; i < IDs.length; i++) {
  9095. var idTroll = IDs[i];
  9096. infos = infosTrolls[idTroll];
  9097. if (infos.done) continue; // déjà vu
  9098. if (infos.bIgnore) continue; // trop vieux
  9099. if (idTroll == numTroll) continue; // pas nous-même
  9100. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9101. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9102. // trouver où insérer ce Troll
  9103. var next = undefined;
  9104. for(var j=0 ; j<tr_trolls.length ; j++) {
  9105. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9106. if (thisDist > distance) {
  9107. next = tr_trolls[j]
  9108. break;
  9109. }
  9110. }
  9111. var tr;
  9112. if (next !== undefined) {
  9113. tr = insertTr(next,'mh_tdpage')
  9114. } else {
  9115. tr = appendTr(tBody,'mh_tdpage');
  9116. }
  9117. var td = appendTd(tr); // distance
  9118. appendText(td, distance);
  9119. td = appendTd(tr); // actions
  9120. td = appendTd(tr); // ID
  9121. appendText(td, idTroll);
  9122. td = appendTd(tr); // Nom
  9123. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9124. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9125. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9126. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9127. td = appendTd(tr); // Niveau
  9128. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9129. td.align = 'center';
  9130. td = appendTd(tr); // Race
  9131. if (infos.race) appendText(td, infos.race);
  9132. // PV et PA ajoutés par addTdInfosTroll
  9133. td = appendTd(tr); // Guilde
  9134. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9135. td = appendTd(tr); // X
  9136. td.align = 'center';
  9137. if (infos.x !== undefined) appendText(td, infos.x);
  9138. td = appendTd(tr); // Y
  9139. td.align = 'center';
  9140. if (infos.y !== undefined) appendText(td, infos.y);
  9141. td = appendTd(tr); // N
  9142. td.align = 'center';
  9143. if (infos.n !== undefined) appendText(td, infos.n);
  9144. addTdInfosTroll(infos, tr.childNodes[6]);
  9145. }
  9146. } catch(e) {
  9147. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  9148. }
  9149. }
  9150.  
  9151.  
  9152. /* Mode Tétalanvert! ---------------------------------------------------------*/
  9153.  
  9154. function calculeDistance(maPos,posArr) {
  9155. return Math.max(
  9156. Math.abs(maPos[0]-posArr[0]),
  9157. Math.abs(maPos[1]-posArr[1]),
  9158. Math.abs(maPos[2]-posArr[2])
  9159. );
  9160. }
  9161.  
  9162. function inversionCoord() {
  9163. var maPos = getPosition();
  9164. var listeOffsets = {
  9165. 'monstres':checkBoxLevels.checked?4:3,
  9166. 'trolls':6,
  9167. };
  9168. for(var type in listeOffsets) {
  9169. var trList = this['tr_'+type];
  9170. var offset = listeOffsets[type];
  9171. for(var i=trList.length-1 ; i>0 ; i--) {
  9172. var oldX = parseInt(trList[i].cells[offset].textContent);
  9173. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  9174. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  9175. trList[i].cells[offset].innerHTML = oldY;
  9176. trList[i].cells[offset+1].innerHTML = oldX;
  9177. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  9178. }
  9179. }
  9180. }
  9181.  
  9182.  
  9183. /* Partie principale */
  9184. function do_vue() {
  9185. for(var type in typesAFetcher) {
  9186. fetchData(type);
  9187. }
  9188.  
  9189. // roule' 11/03/2016
  9190. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  9191. // je fais une recopie :(
  9192. tr_monstres = this['tr_monstres'];
  9193. tr_trolls = this['tr_trolls'];
  9194. tr_tresors = this['tr_tresors'];
  9195. tr_champignons = this['tr_champignons'];
  9196. tr_lieux = this['tr_lieux'];
  9197.  
  9198. nbMonstres = this['nbMonstres'];
  9199. nbTrolls = this['nbTrolls'];
  9200. nbTresors = this['nbTresors'];
  9201. nbChampignons = this['nbChampignons'];
  9202. nbLieux = this['nbLieux'];
  9203.  
  9204. try {
  9205. start_script(31);
  9206. initialiseInfos();
  9207. savePosition();
  9208.  
  9209. // Fonctionnalité "Têtalenvert" cachée, en test :
  9210. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  9211. inversionCoord();
  9212. }
  9213. ajoutDesFiltres();
  9214. set2DViewSystem();
  9215. //putBoutonTroogle();
  9216. putBoutonPXMP();
  9217. synchroniseFiltres();
  9218. toggleLevelColumn();
  9219.  
  9220. refreshDiplo();
  9221. //400 ms
  9222. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  9223. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  9224. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  9225. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  9226. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  9227. var noTresorsEngages =
  9228. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  9229. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  9230. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  9231. filtreMonstres();
  9232. if(noIntangibles) {
  9233. filtreTrolls();
  9234. }
  9235. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  9236. filtreTresors();
  9237. }
  9238. if(noTrou) {
  9239. filtreLieux();
  9240. }
  9241.  
  9242. initPopupVue();
  9243. initPXTroll();
  9244.  
  9245. if(getTalent("Projectile Magique")!=0) {
  9246. computeProjo();
  9247. }
  9248. if(getTalent("Charger")!=0) {
  9249. computeCharge();
  9250. }
  9251. if(getTalent("Télékinésie")!=0) {
  9252. computeTelek();
  9253. }
  9254. if(getTalent("Lancer de Potions")!=0) {
  9255. computeLdP();
  9256. }
  9257. putScriptExterne();
  9258. displayScriptTime();
  9259. } catch(e) {
  9260. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  9261. window.console.error(traceStack(e, 'vue'));
  9262. }
  9263. }
  9264.  
  9265.  
  9266.  
  9267. /*******************************************************************************
  9268. * This file is part of Mountyzilla. *
  9269. * *
  9270. * Mountyzilla is free software; you can redistribute it and/or modify *
  9271. * it under the terms of the GNU General Public License as published by *
  9272. * the Free Software Foundation; either version 2 of the License, or *
  9273. * (at your option) any later version. *
  9274. * *
  9275. * Mountyzilla is distributed in the hope that it will be useful, *
  9276. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9277. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9278. * GNU General Public License for more details. *
  9279. * *
  9280. * You should have received a copy of the GNU General Public License *
  9281. * along with Mountyzilla; if not, write to the Free Software *
  9282. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9283. *******************************************************************************/
  9284.  
  9285. // x~x profil2
  9286.  
  9287. /*---------------------------- Variables globales ----------------------------*/
  9288.  
  9289. var
  9290. // Anatrolliseur
  9291. urlAnatrolliseur,
  9292. // Infobulles talents
  9293. hauteur = 50, bulleStyle = null,
  9294. // Caracteristiques
  9295. // Infos troll
  9296. race, niv, idtroll, datecrea,
  9297. idguilde, nomguilde,
  9298. // Etats du troll
  9299. fatigue, bmfatigue,
  9300.  
  9301. // Experience, Pi, ...
  9302. pxdistribuables, pxperso,
  9303. piutilisable, pitotal,
  9304. nbmeurtres, nbmorts,
  9305. // utilisee pour les moyennes MM/jour, kill/jour, etc
  9306. NBjours,
  9307. // calcul des DLA suivantes
  9308. DLA, DLAsuiv, HeureServeur,
  9309. // details duree du tour (calcul pvdispo) :
  9310. dtb, pdm, bmt, adb, dpt,
  9311. //posale
  9312. posX, posY, posN,
  9313. // caracs physiques
  9314. vue, vuebp, vuebm, vuetotale,
  9315. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  9316. reg, regbp, regbm, regmoy,
  9317. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  9318. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  9319. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  9320. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  9321. rm, rmbp, rmbm, rmtotale,
  9322. mm, mmbp, mmbm, mmtotale,
  9323.  
  9324. // Variables speciales Kastars
  9325. pvActuelKastar, minParPV, overDLA,
  9326. // id pour edition manuelle de lastDLA :
  9327. inJour, inMois, inAn, inHr, inMin, inSec,
  9328. // id pour auto-refresh lastDLA :
  9329. lastDLAZone, maxAMZone, cumulZone,
  9330. lastDLA, DLAaccel;
  9331.  
  9332.  
  9333. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9334.  
  9335. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  9336. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  9337. function getUniqueValueBySelector(selector, defaultValue){
  9338. var valNode = document.querySelector(selector);
  9339. if(valNode!=null){
  9340. if(valNode.hasChildNodes()) {
  9341. return valNode.childNodes[0].nodeValue;
  9342. }else{
  9343. return defaultValue;
  9344. }
  9345. } else{
  9346. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  9347. return defaultValue;
  9348. }
  9349. }
  9350. function getUniqueStringValueBySelector(selector){
  9351. return getUniqueValueBySelector(selector,"");
  9352. }
  9353. function getUniqueIntValueBySelector(selector){
  9354. var ret = getUniqueValueBySelector(selector,0);
  9355. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9356. ret = 0;
  9357. }
  9358. return parseInt(ret);
  9359. }
  9360. function getUniqueFloatValueBySelector(selector){
  9361. var ret = getUniqueValueBySelector(selector,0.0);
  9362. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9363. ret = 0.0;
  9364. }
  9365. return parseFloat(ret);
  9366. }
  9367.  
  9368.  
  9369. function resiste(Ddeg,bm) {
  9370. // version naive mais compréhensible ^^
  9371. // DEBUG: à revoir
  9372. if(!bm) {
  9373. return 2*Math.floor(Ddeg/2);
  9374. }
  9375. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  9376. }
  9377.  
  9378. function retourAZero(fatig) {
  9379. var fat = fatig, raz = 0;
  9380. while(fat>0) {
  9381. raz++;
  9382. fat = Math.floor(fat/1.25);
  9383. }
  9384. return raz;
  9385. }
  9386.  
  9387. function decumulPumPrem(bonus) {
  9388. switch(bonus) {
  9389. case 20: return 33;
  9390. case 33: return 41;
  9391. case 41: return 46;
  9392. case 46: return 49;
  9393. case 49: return 51;
  9394. default: return 20;
  9395. }
  9396. }
  9397.  
  9398. function coefDecumul(i) {
  9399. switch(i) {
  9400. case 2: return 0.67;
  9401. case 3: return 0.4;
  9402. case 4: return 0.25;
  9403. case 5: return 0.15;
  9404. default: return 0.1;
  9405. }
  9406. }
  9407.  
  9408. function dureeHM(dmin) {
  9409. var ret = "";
  9410. dmin = Math.floor(dmin);
  9411. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  9412. var mins = dmin%60;
  9413. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  9414. return (ret) ? ret : "-";
  9415. }
  9416.  
  9417. // extraction d'une durée
  9418. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  9419. // c'est protégé (rend 0 si l'élément est absent)
  9420. // Roule' 24/12/2016
  9421. function extractionDuree(selecteur) {
  9422. var s = getUniqueStringValueBySelector(selecteur);
  9423. if (!s) return 0;
  9424. var tabN = getNumbers(s);
  9425. if (tabN.length < 2) return 0;
  9426. return tabN[0] * 60 + tabN[1];
  9427. }
  9428.  
  9429. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  9430.  
  9431. function extractionDonnees() {
  9432. // Variables temporaires
  9433. var Nbrs = {};
  9434.  
  9435. // *********************
  9436. // Cadre "Description"
  9437. // *********************
  9438. race = getUniqueStringValueBySelector('#descr #race');
  9439. debugMZ("Race : " + race);
  9440. idtroll = getUniqueStringValueBySelector('#descr #id');
  9441. debugMZ("Id troll : " + idtroll);
  9442. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  9443. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  9444. datecrea = new Date(StringToDate(strDateCrea));
  9445. debugMZ("Date creation : " + datecrea);
  9446. // Guilde
  9447. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  9448. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  9449. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  9450.  
  9451. // *******************
  9452. // Cadre "Experience"
  9453. // *******************
  9454. // Niveau de troll
  9455. niv = getUniqueIntValueBySelector('#exp #niv');
  9456. nivTroll = niv;
  9457. debugMZ("Niveau : " + niv);
  9458. // PX
  9459. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  9460. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  9461. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  9462. // PI
  9463. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  9464. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  9465. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  9466. // Meutres/Morts
  9467. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  9468. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  9469. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  9470.  
  9471. // *********************
  9472. // Cadre "Tour de Jeu"
  9473. // *********************
  9474. // DLA
  9475. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  9476. DLA = new Date(StringToDate(Nbrs["dla"]));
  9477. debugMZ("DLA: " + DLA);
  9478. // DLA suivante
  9479. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  9480. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  9481. debugMZ("DLAsuiv: " + DLAsuiv);
  9482. // Duree normale de mon Tour
  9483. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  9484. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  9485. dtb = extractionDuree("#dla #tour");
  9486. debugMZ("Duree normale de mon Tour : " + dtb);
  9487. // Bonus/Malus sur la duree
  9488. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  9489. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  9490. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  9491. debugMZ("Bonus/Malus sur la duree : " + bmt);
  9492. // Augmentation due aux blessures
  9493. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  9494. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  9495. adb = extractionDuree("#dla #blessure");
  9496. debugMZ("Augmentation due aux blessures : " + adb);
  9497. // Poids de l'equipement
  9498. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  9499. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  9500. pdm = extractionDuree("#dla #poids");
  9501. debugMZ("Poids de l'equipement : " + pdm);
  9502. // Duree de mon prochain Tour
  9503. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  9504. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  9505. dpt = extractionDuree("#dla #duree>b");
  9506. debugMZ('Duree de mon prochain Tour : ' + dpt);
  9507.  
  9508. // ****************
  9509. // Cadre "Etats"
  9510. // ****************
  9511. // Position du troll :
  9512. posX = getUniqueIntValueBySelector('#pos #x');
  9513. posY = getUniqueIntValueBySelector('#pos #y');
  9514. posN = getUniqueIntValueBySelector('#pos #n');
  9515. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  9516. // PV actuel
  9517. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  9518. pvActuelKastar = pvcourant;
  9519. debugMZ("PV actuel : " + pvcourant)
  9520. // Fatigue
  9521. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  9522. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  9523. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  9524.  
  9525. // **************************
  9526. // Cadre "Caracteristiques"
  9527. // **************************
  9528. // Attaque
  9529. att = getUniqueIntValueBySelector('#carac #att');
  9530. attbp = getUniqueIntValueBySelector('#carac #att_p');
  9531. attbm = getUniqueIntValueBySelector('#carac #att_m');
  9532. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  9533. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  9534. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  9535. attmoy = 3.5*att + attbp + attbm;
  9536. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9537. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  9538. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  9539. // Esquive
  9540. esq = getUniqueIntValueBySelector('#carac #esq');
  9541. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  9542. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  9543. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  9544. esqmoy = 3.5*esq + esqbp+esqbm;
  9545. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  9546. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  9547. // Degat
  9548. deg = getUniqueIntValueBySelector('#carac #deg');
  9549. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  9550. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  9551. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  9552. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  9553. degmoy = 2*deg + degbp+degbm;
  9554. degmoycrit = 3*deg + degbp+degbm;
  9555. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9556. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  9557. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  9558. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  9559. // PV
  9560. pvbase = getUniqueIntValueBySelector('#carac #pv');
  9561. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  9562. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  9563. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  9564. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  9565. // Regeneration
  9566. reg = getUniqueIntValueBySelector('#carac #reg');
  9567. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  9568. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  9569. regmoy = 2 * reg + regbp + regbm; // D3
  9570. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  9571. // Armure
  9572. arm = getUniqueIntValueBySelector('#carac #arm');
  9573. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  9574. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  9575. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  9576. armmoy = 2*arm + armbp+armbm;
  9577. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  9578. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  9579. // TODO : D d'armure non active
  9580. // Vue
  9581. vue = getUniqueIntValueBySelector('#carac #vue');
  9582. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  9583. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  9584. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  9585. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  9586. // RM
  9587. rm = getUniqueIntValueBySelector('#carac #rm');
  9588. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  9589. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  9590. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  9591. rmTroll = rmtotale;
  9592. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  9593. // MM
  9594. mm = getUniqueIntValueBySelector('#carac #mm');
  9595. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  9596. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  9597. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  9598. mmTroll = mmtotale;
  9599. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  9600.  
  9601. // Heure Serveur
  9602. try {
  9603. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  9604. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  9605. HeureServeur = new Date(StringToDate(heureServeurSTR));
  9606. } catch (e) {
  9607. window.console.warn(
  9608. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  9609. );
  9610. HeureServeur = new Date();
  9611. }
  9612. debugMZ("HeureServeur: " + HeureServeur);
  9613.  
  9614. // ***INIT GLOBALE*** NBjours
  9615. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  9616.  
  9617. // Calcul debut lien anatroliseur avec les caracteristiques connues
  9618. var amelio_dtb = function(dtb) {
  9619. if(dtb>555) {
  9620. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  9621. }
  9622. return 10+Math.ceil((555-dtb)/2.5);
  9623. },
  9624. amelio_pv = Math.floor(pvbase/10)-3,
  9625. amelio_vue = vue-3,
  9626. amelio_att = att-3,
  9627. amelio_esq = esq-3,
  9628. amelio_deg = deg-3,
  9629. amelio_reg = reg-1,
  9630. amelio_arm = arm-1;
  9631. if(race==="Darkling"){amelio_reg--; }
  9632. if(race==="Durakuir"){amelio_pv-- ; }
  9633. if(race==="Kastar") {amelio_deg--; }
  9634. if(race==="Skrim") {amelio_att--; }
  9635. if(race==="Tomawak") {amelio_vue--; }
  9636.  
  9637. urlAnatrolliseur = URL_AnatrolDispas
  9638. +"outils_anatrolliseur.php?anatrolliseur=v8"
  9639. +"|r="+race.toLowerCase()
  9640. +"|dla="+amelio_dtb(dtb)
  9641. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  9642. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  9643. +"|att="+amelio_att+","+attbp+","+attbm
  9644. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  9645. +"|deg="+amelio_deg+","+degbp+","+degbm
  9646. +"|reg="+amelio_reg+","+regbp+","+regbm
  9647. +"|arm="+amelio_arm+","+armbp+","+armbm
  9648. +"|mm="+mmtotale
  9649. +"|rm="+rmtotale+"|";
  9650. }
  9651.  
  9652. function saveProfil() {
  9653. MY_setValue(idtroll+'.caracs.attaque',att);
  9654. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  9655. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  9656. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  9657. if(atttourD||atttourP||atttourM) {
  9658. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9659. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  9660. }
  9661. MY_setValue(idtroll+'.caracs.esquive',esq);
  9662. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  9663. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  9664. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  9665. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  9666. MY_setValue(idtroll+'.caracs.degats',deg);
  9667. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  9668. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  9669. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  9670. if(degtourP||degtourM){
  9671. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9672. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  9673. }
  9674. MY_setValue(idtroll+'.caracs.regeneration',reg);
  9675. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  9676. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  9677. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  9678. MY_setValue(idtroll+'.caracs.vue',vue);
  9679. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  9680. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  9681. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  9682. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  9683. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  9684. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  9685. MY_setValue(idtroll+'.caracs.rm',rm);
  9686. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  9687. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  9688. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  9689. MY_setValue(idtroll+'.caracs.mm',mm);
  9690. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  9691. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  9692. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  9693. MY_setValue(idtroll+'.caracs.armure',arm);
  9694. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  9695. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  9696. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  9697. MY_setValue(idtroll+'.position.X',posX);
  9698. MY_setValue(idtroll+'.position.Y',posY);
  9699. MY_setValue(idtroll+'.position.N',posN);
  9700. MY_setValue(idtroll+'.race',race);
  9701. MY_setValue(idtroll+'.niveau',niv);
  9702. MY_setValue(idtroll+'.idguilde',idguilde);
  9703. MY_setValue(idtroll+'.nomguilde',nomguilde);
  9704. }
  9705.  
  9706.  
  9707. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  9708.  
  9709. function setInfosCaracteristiques() {
  9710. // Modification de l'entete
  9711. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  9712. thTotal.innerHTML+='|<i>Moyenne</i>';
  9713. thTotal.title="Moyenne (Moyenne ce tour)";
  9714.  
  9715. // Ajout des informations calculees
  9716. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  9717. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  9718. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  9719.  
  9720. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  9721. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  9722. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  9723.  
  9724. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  9725. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  9726. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  9727.  
  9728. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  9729. var tdRegTotal = trRegeneration.children[5];
  9730. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  9731. // Temps recupere par reg (propale R')
  9732. var regmoyTemp = Math.max(0, regmoy);
  9733. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  9734. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  9735. if (sec != 0) {
  9736. regTitle += " " + sec + " sec";
  9737. }
  9738. trRegeneration.title = regTitle;
  9739.  
  9740. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  9741. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  9742. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  9743.  
  9744. var trRM=document.querySelector("table#caracs #rm").parentElement;
  9745. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  9746. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  9747.  
  9748.  
  9749. var trMM=document.querySelector("table#caracs #mm").parentElement;
  9750. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  9751. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  9752.  
  9753. var tdRefl=document.querySelector("#refl");
  9754. // TODO : prendre en compte bonus/malus D esq du tour ?
  9755. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  9756. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  9757. }
  9758.  
  9759. function setLienAnatrolliseur(){
  9760. var pTableAmelio = document.querySelector("#carac>div>p");
  9761. pTableAmelio.innerHTML+=" - ";
  9762. var aElt = document.createElement("a");
  9763. aElt.setAttribute("href",urlAnatrolliseur);
  9764. aElt.setAttribute("target","_blank");
  9765. aElt.className="AllLinks";
  9766. aElt.innerHTML="Anatrolliser";
  9767. pTableAmelio.appendChild(aElt);
  9768. }
  9769. function setInfoDescription() {
  9770. var txtDateCrea = (NBjours!=1) ?
  9771. " ("+NBjours+" jours dans le hall)" :
  9772. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  9773. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  9774. }
  9775.  
  9776. function setInfosEtatLieux() {
  9777. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  9778. '?search=position&orderBy=distance&posx='+
  9779. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  9780. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  9781. appendBr(tdPosition);
  9782. var aElt = document.createElement("a");
  9783. aElt.setAttribute("href",urlBricol);
  9784. aElt.setAttribute("target","_blank");
  9785. aElt.className="AllLinks";
  9786. aElt.innerHTML="Lieux à proximité";
  9787. tdPosition.appendChild(aElt);
  9788. }
  9789.  
  9790. function setInfosEtatPV() { // pour AM et Sacro
  9791. var
  9792. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  9793. sec = Math.floor(15000/pvtotal)%60,
  9794. lifebar = document.querySelector("#pos .barre-vie");
  9795. if(sec!=0) { txt += " "+sec+" sec"; }
  9796. if(lifebar) { lifebar.title = txt; }
  9797. if(pvcourant<=0) { return; }
  9798. // Difference PV p/r a equilibre de temps (propale R')
  9799. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  9800. // ***INIT GLOBALE*** pvdispo
  9801. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  9802. var span = document.createElement("span");
  9803. span.title = txt;
  9804. span.style.fontStyle = "italic";
  9805. if(bmt+pdm>=0) {
  9806. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  9807. } else if(pvdispo>0) {
  9808. txt = "Vous pouvez encore perdre "+
  9809. Math.min(pvdispo,pvcourant)+
  9810. " PV sans malus de temps.";
  9811. } else if(pvdispo<0) {
  9812. txt = "Il vous manque "
  9813. +(-pvdispo)
  9814. +" PV pour ne plus avoir de malus de temps.";
  9815. } else {
  9816. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  9817. }
  9818. appendText(span,txt);
  9819. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  9820. }
  9821.  
  9822. // Complete le cadre "Experience"
  9823. function setInfosExp() {
  9824. var tdNiv = document.querySelector("#exp #niv");
  9825.  
  9826. // Calcul niveau monstre/troll min pour gain PX
  9827. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  9828. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  9829.  
  9830. // Calcul PX restant
  9831. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  9832. if (pxRestant >= 0) {
  9833. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  9834. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  9835. }
  9836.  
  9837. // Calul pi/jour
  9838. var
  9839. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  9840. tdPi = document.querySelector("#exp #pi").parentElement;
  9841. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  9842. tdPi.title = tdPiTotal.title;
  9843.  
  9844. // Rapports meurtres,morts
  9845. var tdKill = document.querySelector("#exp #kill");
  9846. tdKill.setAttribute("colspan", 1);
  9847. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  9848.  
  9849. var tdMort = document.querySelector("#exp #mort");
  9850. tdMort.setAttribute("colspan", 1);
  9851. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  9852.  
  9853. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  9854. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  9855. }
  9856.  
  9857.  
  9858. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  9859.  
  9860. function minParPVsac(fat,bm) {
  9861. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  9862. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  9863. var out = [];
  9864. out[0] = (fat>4) ?
  9865. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  9866. 30;
  9867. if(bm && bm>0) {
  9868. var totalfat=fat+bm;
  9869. out[1] = (totalfat>4) ?
  9870. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  9871. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  9872. }
  9873. return out;
  9874. }
  9875.  
  9876. function toInt(str) {
  9877. str = parseInt(str);
  9878. return (str) ? str : 0;
  9879. }
  9880.  
  9881. function saveLastDLA() {
  9882. // pour les calculs d'AM max
  9883. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  9884. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  9885. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  9886. lastDLA = new Date( StringToDate(str) );
  9887. MY_setValue(numTroll+'.DLA.ancienne',str);
  9888. lastDLAZone.innerHTML = '';
  9889. var b = document.createElement('b');
  9890. b.addEventListener('click',inputMode,false);
  9891. appendText(b,str);
  9892. lastDLAZone.appendChild(b);
  9893. refreshAccel();
  9894. }
  9895.  
  9896. function inputMode() {
  9897. // Edition manuelle lastDLA
  9898. var date;
  9899. if(lastDLA)
  9900. date = new Date( lastDLA );
  9901. else
  9902. date = new Date( DLAaccel );
  9903. lastDLAZone.innerHTML = '';
  9904. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  9905. appendText(lastDLAZone,'/');
  9906. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  9907. appendText(lastDLAZone,'/');
  9908. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  9909. appendText(lastDLAZone,' - ');
  9910. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  9911. appendText(lastDLAZone,':');
  9912. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  9913. appendText(lastDLAZone,':');
  9914. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  9915. appendText(lastDLAZone,' - ');
  9916. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  9917. }
  9918.  
  9919. function setAccel() {
  9920. var
  9921. BMfrais=false,
  9922. fat=fatigue, listeBmFat=[],
  9923. tr, th, insertPt;
  9924.  
  9925. // Creation ligne speciale pour AM dans le cadre "Etat"
  9926. tr = document.createElement('tr');
  9927. th = document.createElement('th');
  9928. appendText(th,'Fatigue et AM',true);
  9929. tr.appendChild(th);
  9930. insertPt = document.createElement('td');
  9931. tr.appendChild(insertPt);
  9932. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  9933.  
  9934. // Est-on en over-DLA ?
  9935. // ***INIT GLOBALE*** overDLA
  9936. overDLA = (HeureServeur>DLA.getTime()+3e5);
  9937. if(overDLA) {
  9938. fat=Math.floor(fatigue/1.25);
  9939. }
  9940.  
  9941. // Gestion des BM de fatigue
  9942. if(bmfatigue>0) {
  9943. // On tente de recuperer les BM de fatigue de la page des BM
  9944. if(MY_getValue(numTroll+'.bm.fatigue')) {
  9945. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  9946. BMmemoire.pop();
  9947. var tour = 0;
  9948. for(var i=0 ; i<BMmemoire.length ; i++) {
  9949. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  9950. while(tour<=parseInt(nbrs[0])) {
  9951. listeBmFat[tour]=parseInt(nbrs[1]);
  9952. tour++;
  9953. }
  9954. }
  9955. }
  9956. if(listeBmFat[0]==bmfatigue) {
  9957. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  9958. BMfrais = true;
  9959. MY_removeValue(numTroll+".bm.fatigue");
  9960. }
  9961. } else {
  9962. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  9963. BMfrais = true;
  9964. }
  9965. if(!BMfrais && bmfatigue>0) {
  9966. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  9967. if(bmfatigue==15) {
  9968. listeBmFat = [15,15,15];
  9969. } else {
  9970. listeBmFat = [30,30,15];
  9971. }
  9972. }
  9973. if(overDLA) {
  9974. // Si on est en over-DLA, on decale les bm d'un tour
  9975. listeBmFat.shift();
  9976. }
  9977. // Tableau des fatigues et accel futures
  9978. var
  9979. minppv = minParPVsac(fat,listeBmFat[0]),
  9980. table, tbody,
  9981. ligneTour, ligneFat, ligneMin,
  9982. col;
  9983. // ***INIT GLOBALE*** minParPV
  9984. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  9985. if(fat>0 || listeBmFat[0]>0) {
  9986. table = document.createElement('table');
  9987. table.className = 'mh_tdborder';
  9988. table.border = 0;
  9989. table.cellSpacing = 1;
  9990. table.cellPadding = 1;
  9991. table.style.textAlign = "center";
  9992. tbody = document.createElement('tbody');
  9993. table.appendChild(tbody);
  9994. insertPt.appendChild(table);
  9995. ligneTour = appendTr(tbody,'mh_tdtitre');
  9996. ligneTour.style.fontWeight = "bold";
  9997. var td = appendTdText(ligneTour,'Tour :',true);
  9998. td.align = 'left';
  9999. ligneFat = appendTr(tbody,'mh_tdpage');
  10000. td = appendTdText(ligneFat,'Fatigue :',true);
  10001. td.className = 'mh_tdtitre';
  10002. td.align = 'left';
  10003. ligneMin = appendTr(tbody,'mh_tdpage');
  10004. td = appendTdText(ligneMin,'1 PV =',true);
  10005. td.className = 'mh_tdtitre';
  10006. td.align = 'left';
  10007. col=0;
  10008. while(col<9 && (fat>0 || listeBmFat[col])) {
  10009. if(col==0) {
  10010. if(overDLA) {
  10011. var i = document.createElement('i');
  10012. appendText(i,'A activer');
  10013. ligneTour.appendChild(i);
  10014. } else {
  10015. appendTdText(ligneTour,'En cours');
  10016. }
  10017. } else {
  10018. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10019. }
  10020. if(listeBmFat[col]) {
  10021. if(BMfrais || (!overDLA && col==0)) {
  10022. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10023. appendTdText(ligneMin,minppv[1]+'\'');
  10024. } else {
  10025. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10026. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10027. }
  10028. } else {
  10029. appendTdText(ligneFat,fat);
  10030. appendTdText(ligneMin,minppv[0]+'\'');
  10031. }
  10032. col++;
  10033. fat = Math.floor(fat / 1.25);
  10034. minppv = minParPVsac(fat,listeBmFat[col]);
  10035. }
  10036. if(fat>1 || (fat==1 && !overDLA)) {
  10037. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10038. appendTdText(ligneFat,'-');
  10039. appendTdText(ligneMin,'-');
  10040. }
  10041. col = (overDLA) ?
  10042. Math.max(retourAZero(fatigue)-1,col) :
  10043. Math.max(retourAZero(fatigue),col);
  10044. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10045. appendTdText(ligneFat,'0');
  10046. appendTdText(ligneMin,'30\'');
  10047. if(!BMfrais && bmfatigue) {
  10048. // si les BM n'ont pas ete rafraichis, on signale:
  10049. appendText(
  10050. insertPt,
  10051. '/!\\ Visitez la page des Bonus/Malus '+
  10052. 'pour mettre à jour votre fatigue. /!\\',
  10053. true
  10054. );
  10055. appendBr(insertPt);
  10056. }
  10057. appendBr(insertPt);
  10058. }
  10059. if(pvcourant<=0) {
  10060. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10061. return;
  10062. }
  10063. if(fatigue>30) {
  10064. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10065. return;
  10066. }
  10067. // Setup lastDLAZone
  10068. if(overDLA) {
  10069. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10070. DLAaccel = new Date( DLAsuiv );
  10071. lastDLA = new Date( DLA );
  10072. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10073. // ***INIT GLOBALE*** pvActuelKastar
  10074. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10075. appendText(
  10076. insertPt,
  10077. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10078. true
  10079. );
  10080. appendBr(insertPt);
  10081. } else {
  10082. DLAaccel = new Date( DLA );
  10083. pvActuelKastar = pvcourant;
  10084. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10085. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10086. } else {
  10087. lastDLA = false;
  10088. }
  10089. }
  10090. appendText(insertPt,'Dernière DLA enregistrée : ');
  10091. lastDLAZone = document.createElement('span');
  10092. lastDLAZone.style.cursor = 'pointer';
  10093. var b = document.createElement('b');
  10094. b.onclick = inputMode;
  10095. lastDLAZone.appendChild(b);
  10096. insertPt.appendChild(lastDLAZone);
  10097. if(lastDLA) {
  10098. appendText(b,DateToString(lastDLA));
  10099. } else {
  10100. appendText(b,'aucune');
  10101. }
  10102. appendBr(insertPt);
  10103. // Setup maxAMZone et cumulZone
  10104. appendText(insertPt,'Accélération maximale possible : ');
  10105. maxAMZone = document.createElement('b');
  10106. insertPt.appendChild(maxAMZone);
  10107. appendBr(insertPt);
  10108. cumulZone = document.createElement('span');
  10109. insertPt.appendChild(cumulZone);
  10110. refreshAccel();
  10111. }
  10112.  
  10113. function refreshAccel() {
  10114. var pvs, pvsmax;
  10115. // Acceleration pour cumul instantane
  10116. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10117. if(lastDLA) {
  10118. pvsmax = Math.min(
  10119. pvActuelKastar-1,
  10120. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10121. );
  10122. maxAMZone.innerHTML = pvsmax+" PV";
  10123. } else {
  10124. pvsmax = pvActuelKastar-1;
  10125. maxAMZone.innerHTML = "inconnue";
  10126. }
  10127. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10128. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10129. cumulZone.innerHTML = '';
  10130. if(pvs<=pvsmax) {
  10131. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10132. appendText(cumulZone,pvs+' PV', true);
  10133. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10134. if(pvs!=1) {
  10135. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10136. -(pvs-1)*60*minParPV;
  10137. appendText(
  10138. cumulZone,
  10139. ' ('+(pvs-1)+' PV dans '+
  10140. Math.floor(gainSec/60)+'min'+
  10141. addZero(gainSec%60)+'s)'
  10142. );
  10143. }
  10144. } else {
  10145. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10146. appendText(
  10147. cumulZone,
  10148. 'Après votre accélération maximale, il vous faudra encore attendre '+
  10149. dureeHM(avantDLA/6e4)+
  10150. ' avant de réactiver.'
  10151. );
  10152. }
  10153. }
  10154.  
  10155.  
  10156. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  10157.  
  10158. function traitementTalents() {
  10159. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  10160. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  10161. removeAllTalents();
  10162. var totalComp = injecteInfosBulles(trCompetence,'competences');
  10163. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  10164. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  10165. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  10166. }
  10167.  
  10168. function injecteInfosBulles(liste,fonction) {
  10169. var totalpc = 0;
  10170. // on parse la liste des talents du type 'fonction'
  10171. for(var i=0 ; i<liste.length ; i++) {
  10172. var
  10173. trTalent=liste[i],
  10174. node=trTalent.cells[1].querySelector('a'),
  10175. nomTalent=epure(trim(node.textContent)),
  10176. indiceTDniveaux=7,
  10177. indiceTDSousCompetence=2,
  10178. sousCompetences=undefined;
  10179. if(fonction=="competences"){
  10180. // un TD en plus pour des information complementaire liees a la comp
  10181. indiceTDniveaux++;
  10182. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  10183. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  10184. for (var j=0; j < sousCompetences.length; j++) {
  10185. sousCompetences[j] = sousCompetences[j].epure().trim();
  10186. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  10187. }
  10188. }
  10189. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  10190. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  10191. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  10192. totalpc += niveauxMaitrisesTalentArray[1];
  10193.  
  10194. // stockage des niveaux inferieurs du talent si presents
  10195. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  10196. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  10197. totalpc+=niveauxMaitrisesTalentArray[j+1];
  10198. }
  10199. }
  10200. return totalpc;
  10201. }
  10202.  
  10203. function setInfos(node,nom,fonction,niveau) {
  10204. node.nom = nom;
  10205. node.fonction = fonction;
  10206. node.niveau = niveau;
  10207. node.onmouseover = setBulle;
  10208. node.onmouseout = cacherBulle;
  10209. }
  10210.  
  10211. var arrayModifAnatroll = {
  10212. 'Glue':'Glu',
  10213. 'PuM':'PuiM',
  10214. 'HE':'Hurlement',
  10215. //'Insultes':'Insu',
  10216. 'Pistage':'Pist',
  10217. 'PuC':'Planter'
  10218. }
  10219.  
  10220. function setTalent(nom,pc,niveau,sousCompetences) {
  10221. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  10222. // (et pas les % dont osf) ne serait pas plus rentable
  10223. var nomEnBase = arrayTalents[epure(nom)];
  10224. if(!nomEnBase) { return; }
  10225. if(!niveau) { niveau = 1; }
  10226. switch(nomEnBase) {
  10227. case 'Insultes':
  10228. urlAnatrolliseur += 'Insu'+niveau+'|';
  10229. case 'IdT':
  10230. nomEnBase += niveau;
  10231. break;
  10232. case 'Golemo':
  10233. case 'Piege':
  10234. for (var i=0 ; i < sousCompetences.length ; i++) {
  10235. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  10236. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  10237. }
  10238. break;
  10239. case 'AP':
  10240. case 'Baroufle':
  10241. case 'CdB':
  10242. case 'CdM':
  10243. case 'Parer':
  10244. case 'Retraite':
  10245. case 'RB':
  10246. case 'SInterposer':
  10247. nomEnBase += niveau;
  10248. default:
  10249. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  10250. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  10251. }
  10252. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  10253. }
  10254.  
  10255. function creerBulleVide() {
  10256. var table = document.createElement('table');
  10257. table.id = 'bulle';
  10258. table.className = 'mh_tdborder';
  10259. table.width = 300;
  10260. table.border = 0;
  10261. table.cellPadding = 5;
  10262. table.cellSpacing = 1;
  10263. table.style =
  10264. 'position:absolute;'
  10265. +'visibility:hidden;'
  10266. +'z-index:800;'
  10267. +'height:auto;';
  10268. var tr = appendTr(table,'mh_tdtitre');
  10269. appendTdText(tr,'Titre');
  10270. tr = appendTr(table,'mh_tdpage');
  10271. appendTdText(tr,'Contenu');
  10272. var aList = document.getElementsByTagName('a');
  10273. aList[aList.length-1].parentNode.appendChild(table);
  10274. }
  10275.  
  10276. function cacherBulle() {
  10277. if(bulleStyle)
  10278. bulleStyle.visibility = 'hidden';
  10279. }
  10280.  
  10281. function setBulle(evt) {
  10282. var nom = this.nom;
  10283. var fonction = this.fonction;
  10284. var niveau = parseInt(this.niveau);
  10285. var str='';
  10286. if(fonction=='competences'){
  10287. str=competences(nom,niveau);
  10288. } else if(fonction=='sortileges') {
  10289. str=sortileges(nom,true);
  10290. }
  10291. if(str=='') return;
  10292. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  10293. var xfenetre, yfenetre, xpage, ypage, element = null;
  10294. var offset = 15;
  10295. var bulleWidth = 300;
  10296. if(!hauteur) hauteur = 50;
  10297. element = document.getElementById('bulle');
  10298. xfenetre = evt.clientX;
  10299. yfenetre = evt.clientY;
  10300. xpage = xfenetre;
  10301. ypage = yfenetre;
  10302. if(evt.pageX) xpage = evt.pageX;
  10303. if(evt.pageY) ypage = evt.pageY;
  10304. if(element) {
  10305. bulleStyle = element.style;
  10306. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  10307. element.childNodes[1].firstChild.innerHTML = str;
  10308. }
  10309. if(bulleStyle) {
  10310. if(xfenetre>bulleWidth+offset)
  10311. xpage -= bulleWidth+offset;
  10312. else
  10313. xpage += offset;
  10314. if(yfenetre>hauteur+offset)
  10315. ypage -= hauteur + offset;
  10316. bulleStyle.width = bulleWidth;
  10317. bulleStyle.left = xpage + 'px';
  10318. bulleStyle.top = ypage + 'px';
  10319. bulleStyle.visibility = 'visible';
  10320. }
  10321. }
  10322.  
  10323.  
  10324. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  10325.  
  10326. function competences(comp,niveau) {
  10327. var texte = '';
  10328. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  10329. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  10330. if(minParPV>1) texte += 's';
  10331. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  10332. }
  10333. else if(comp.indexOf('Attaque Precise')!=-1) {
  10334. var pc, lastmax=0, espatt=0;
  10335. var notMaxedOut = false;
  10336. for(var i=niveau ; i>0 ; i--) {
  10337. pc = getTalent(comp,i);
  10338. if(lastmax!=0 && pc<=lastmax) continue;
  10339. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  10340. attbp+attbm;
  10341. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10342. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  10343. ' => <b>'+jetatt+'</b><br/>';
  10344. espatt += (pc-lastmax)*jetatt;
  10345. lastmax = pc;
  10346. if(i<niveau) notMaxedOut = true;
  10347. }
  10348. if(notMaxedOut) {
  10349. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  10350. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  10351. }
  10352. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  10353. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10354. }
  10355. else if(comp.indexOf('Balayage')!=-1)
  10356. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  10357. +' => <b>'+attmoy+'</b><br/>'
  10358. +'Effet : <b>Met à terre l\'adversaire</b>';
  10359. else if(comp.indexOf('Bidouille')!=-1)
  10360. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  10361. +'de votre inventaire avec le texte de votre choix.';
  10362. else if(comp.indexOf('Baroufle')!=-1){
  10363. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  10364. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  10365. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  10366. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  10367. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  10368. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  10369. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  10370. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  10371. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  10372. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  10373. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  10374. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  10375. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  10376. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  10377. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  10378. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  10379. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  10380. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  10381. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  10382. '</tbody></table>';
  10383. }
  10384. else if(comp.indexOf('Botte Secrete')!=-1){
  10385. texte = 'Attaque : <b>'
  10386. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10387. +' => <b>'
  10388. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  10389. +'</b><br/>Dégâts : <b>'
  10390. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  10391. +' => <b>'
  10392. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  10393. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  10394. +'</b>';
  10395. }
  10396. else if(comp.indexOf('Camouflage')!=-1) {
  10397. var camou = getTalent('Camouflage');
  10398. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  10399. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  10400. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  10401. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  10402. }
  10403. else if(comp.indexOf('Charger')!=-1) {
  10404. if(pvcourant<=0)
  10405. return '<i>On ne peut charger personne quand on est mort !</i>';
  10406. var portee = Math.min(
  10407. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  10408. vuetotale);
  10409. if(portee<1)
  10410. return '<b>Impossible de charger</b>';
  10411. else {
  10412. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10413. +' => <b>'+attmoy+'</b><br/>'
  10414. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10415. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  10416. +'<br/>Portée : <b>'+portee+'</b> case';
  10417. if(portee>1) texte += 's';
  10418. }
  10419. }
  10420. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  10421. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  10422. if(vuetotale>1) texte += 's';
  10423. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10424. if(vuetotale>2) texte += 's';
  10425. }
  10426. else if(comp.indexOf('Piege')!=-1) {
  10427. if(comp.indexOf('Glue')!=-1)
  10428. texte = 'Et si vous colliez vos adversaires au sol ?';
  10429. if(comp.indexOf('Feu')!=-1) {
  10430. if(texte){
  10431. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  10432. }
  10433. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  10434. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  10435. }
  10436. }
  10437. else if(comp.indexOf('Contre-Attaquer')!=-1){
  10438. texte = 'Attaque : <b>'
  10439. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10440. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10441. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10442. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10443. }
  10444. else if(comp.indexOf('Coup de Butoir')!=-1) {
  10445. var pc, lastmax=0, espdeg=0;
  10446. var notMaxedOut = false;
  10447. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10448. +' => <b>'+attmoy+'</b>';
  10449. for(var i=niveau ; i>0 ; i--) {
  10450. pc = getTalent(comp,i);
  10451. if(lastmax!=0 && pc<=lastmax) continue;
  10452. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  10453. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10454. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  10455. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  10456. espdeg += (pc-lastmax)*jetdeg;
  10457. lastmax = pc;
  10458. if(i<niveau) notMaxedOut = true;
  10459. }
  10460. if(notMaxedOut) {
  10461. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  10462. Math.floor(10*espdeg/lastmax)/10+'/'+
  10463. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  10464. }
  10465. }
  10466. else if(comp.indexOf('Course')!=-1)
  10467. texte = 'Déplacement gratuit : <b>'
  10468. +Math.floor(getTalent('Course')/2)
  10469. +' %</b> de chance';
  10470. else if(comp.indexOf('Deplacement Eclair')!=-1)
  10471. texte = 'Permet d\'économiser <b>1</b> PA '
  10472. +'par rapport au déplacement classique';
  10473. else if(comp.indexOf('Dressage')!=-1)
  10474. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  10475. +'ou un gnu sauvage.';
  10476. else if(comp.indexOf('Ecriture Magique')!=-1)
  10477. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  10478. +'la formule nécessite de réunir les composants de cette formule, '
  10479. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  10480. +'un champignon adéquat pour confectionner l\'encre.';
  10481. else if(comp.indexOf('Frenesie')!=-1) {
  10482. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10483. +' => <b>'+attmoy+'</b><br/>'
  10484. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10485. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10486. }
  10487. else if(comp.indexOf('Golem')!=-1)
  10488. texte = 'Animez votre golem en assemblant divers matériaux '
  10489. +'autour d\'un cerveau minéral.'
  10490. else if(comp.indexOf('Grattage')!=-1) {
  10491. texte = 'Permet de confectionner un Parchemin Vierge '
  10492. +'à partir de composants et de Gigots de Gob\'.';
  10493. }
  10494. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  10495. texte = 'Fait fuir un monstre si tout se passe bien.'
  10496. +'<br/>Lui donne de gros bonus sinon...';
  10497. else if(comp.indexOf('Identification des Champignons')!=-1) {
  10498. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10499. if(vuetotale>2) texte += 's';
  10500. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  10501. if(vuetotale>4) texte += 's';
  10502. }
  10503. else if(comp.indexOf('Insultes')!=-1)
  10504. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  10505. else if(comp.indexOf('interposer')!=-1)
  10506. texte = 'Jet de réflexe : <b>'
  10507. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  10508. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  10509. else if(comp.indexOf('Lancer de Potions') != -1)
  10510. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  10511. else if(comp.indexOf('Marquage')!=-1)
  10512. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  10513. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  10514. +'se trouver dans la même caverne que le monstre pour le marquer.';
  10515. else if(comp.indexOf('Melange Magique')!=-1)
  10516. texte = 'Cette Compétence permet de combiner deux Potions pour '
  10517. +'en réaliser une nouvelle dont l\'effet est la somme '
  10518. +'des effets des potions initiales.';
  10519. else if(comp.indexOf('Miner')!=-1)
  10520. texte = 'Portée horizontale (officieuse) : <b>'
  10521. +2*vuetotale+'</b> cases<br/>'
  10522. +'Portée verticale (officieuse) : <b>'
  10523. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10524. else if(comp.indexOf('Necromancie')!=-1)
  10525. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  10526. +'de faire "revivre" ce monstre.';
  10527. else if(comp.indexOf('Painthure de Guerre')!=-1)
  10528. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  10529. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  10530. +'pour s\'inspirer, et laissez parler votre créativité.'
  10531. else if(comp.indexOf('Parer')!=-1)
  10532. texte = 'Jet de parade : <b>'
  10533. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  10534. +' => <b>'
  10535. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10536. +'</b><hr><i>Equivalent esquive : <b>'
  10537. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  10538. +' => <b>'
  10539. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  10540. +'</b></i>';
  10541. else if(comp.indexOf('Pistage')!=-1)
  10542. texte = 'Portée horizontale : <b>'
  10543. +2*vuetotale+'</b> cases<br/>'
  10544. +'Portée verticale : <b>'
  10545. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10546. else if(comp.indexOf('Planter un Champignon')!=-1)
  10547. texte = 'Planter un Champignon est une compétence qui vous permet de '
  10548. +'créer des colonies d\'une variété donnée de champignon à partir de '
  10549. +'quelques exemplaires préalablement enterrés.';
  10550. else if(comp.indexOf('Regeneration Accrue')!=-1)
  10551. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  10552. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  10553. else if(comp.indexOf('Reparation')!=-1)
  10554. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  10555. +'et réparez vous-même votre matériel !';
  10556. else if(comp.indexOf('Retraite')!=-1)
  10557. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  10558. +'préférable de préparer un repli stratégique pour déconcerter '
  10559. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  10560. +'Quelle intelligence démoniaque.';
  10561. else if(comp.indexOf('Rotobaffe')!=-1) {
  10562. var Datt = att, vattbm = attbp+attbm;
  10563. var Ddeg = deg, vdegbm = degbp+degbm;
  10564. for(var i=1 ; i<niveau+2 ; i++) {
  10565. texte += '<b>Attaque n°'+i+' :</b><br/>'
  10566. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  10567. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  10568. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  10569. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  10570. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  10571. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  10572. if(i<niveau+1) texte += '<hr>';
  10573. }
  10574. }
  10575. else if(comp.indexOf('Shamaner')!=-1)
  10576. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  10577. +'des monstres en utilisant des champignons (de 1 à 3).';
  10578. else if(comp.indexOf('Tailler')!=-1){
  10579. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  10580. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  10581. }
  10582. return texte;
  10583. }
  10584.  
  10585. function decumul_buff(nom,str,buff) {
  10586. // Decumul des sorts de buff
  10587. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  10588. var dec = buff, total = buff, i=1;
  10589. while(i<6) {
  10590. i++;
  10591. dec = Math.floor(coefDecumul(i)*buff);
  10592. if(dec<=1 || i==6) break;
  10593. total += dec;
  10594. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  10595. +str+' +'+dec+' (+'+total+')</i>';
  10596. }
  10597. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  10598. return ret;
  10599. }
  10600.  
  10601.  
  10602. function sortileges(sort,mainCall,pcA,pcD) {
  10603. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  10604. var texte = '';
  10605. if (mainCall) {
  10606. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  10607. pcA = (atttourP+atttourM);
  10608. pcD = (degtourP+degtourM);
  10609. }
  10610. if (sort.indexOf('Analyse Anatomique') != -1) {
  10611. texte = 'Portée horizontale : <b>'
  10612. + Math.floor(vuetotale / 2) + '</b> case';
  10613. if (vuetotale > 3){ texte += 's'; }
  10614. texte += '<br/>Portée verticale : <b>'
  10615. + Math.floor((vuetotale+1)/4)+'</b> case';
  10616. if (vuetotale > 7){ texte += 's'; }
  10617. }
  10618. else if (sort.indexOf('Armure Etheree') != -1){
  10619. texte = decumul_buff('AE', 'Armure magique', reg);
  10620. }
  10621. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  10622. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  10623. }
  10624. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  10625. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  10626. }
  10627. else if (sort.indexOf('Augmentation des Degats') != -1){
  10628. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  10629. }
  10630. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  10631. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  10632. }
  10633. else if(sort.indexOf('Bulle Magique')!=-1){
  10634. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  10635. }
  10636. else if(sort.indexOf('Explosion')!=-1){
  10637. texte = 'Dégâts : <b>'
  10638. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  10639. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  10640. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  10641. }
  10642. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  10643. if(pvcourant<=0)
  10644. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  10645. texte = 'Portée horizontale : <b>'
  10646. +Math.min(1,vuetotale)+'</b> case<br/>'
  10647. +'Dégâts physiques : <b>-'
  10648. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  10649. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  10650. +'Dégâts magiques : <b>-'
  10651. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  10652. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  10653. }
  10654. else if(sort.indexOf('Flash Aveuglant')!=-1){
  10655. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  10656. }
  10657. else if(sort.indexOf('Glue')!=-1) {
  10658. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  10659. if(vuetotale>2) texte += 's';
  10660. }
  10661. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  10662. /* Frappe */
  10663. var modD = 0;
  10664. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10665. if(pcA!=0){
  10666. modD = parseInt(att*pcA/100);
  10667. texte += '<i>'+aff(modD)+'D6</i> ';
  10668. }
  10669. texte += aff(attbm)
  10670. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  10671. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  10672. if(pcD!=0) {
  10673. modD = parseInt(Math.floor(deg/2)*pcD/100);
  10674. texte += '<i>'+aff(modD)+'D3</i> ';
  10675. }else
  10676. modD = 0;
  10677. texte += aff(degbm)+' => <b>'
  10678. +(2*(Math.floor(deg/2)+modD)+degbm)
  10679. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  10680. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  10681. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  10682. +')</b>';
  10683. if(!mainCall) return texte;
  10684. /* Venins */
  10685. function addVenin(type,effet,duree) {
  10686. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  10687. +' pendant <b>'+duree+'</b> tour';
  10688. if(duree>1) ret += 's';
  10689. var dred = Math.max(Math.floor(duree/2),1);
  10690. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  10691. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  10692. }
  10693. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  10694. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  10695. effet = Math.floor(1.5*effet);
  10696. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  10697. }
  10698. else if(sort.indexOf('Hypnotisme')!=-1)
  10699. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  10700. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  10701. else if(sort.indexOf('Identification des tresors')!=-1)
  10702. texte = 'Permet de connaitre les caractéristiques et effets précis '
  10703. +'d\'un trésor.';
  10704. else if(sort.indexOf('Invisibilite')!=-1)
  10705. texte = 'Un troll invisible est indétectable même quand on se trouve '
  10706. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  10707. +'fait disparaître l\'invisibilité.';
  10708. else if(sort.indexOf('Levitation')!=-1)
  10709. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  10710. +'Comme les pièges ou les trous par exemple...';
  10711. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  10712. var eps = 1,
  10713. pc = 20;
  10714. var str = 'PréM';
  10715. var newSort;
  10716. var sortAtt = [
  10717. 'Projectile Magique',
  10718. 'Rafale Psychique',
  10719. 'Siphon des Ames',
  10720. 'Vampirisme',
  10721. 'Griffe du Sorcier'
  10722. ];
  10723. if(sort.indexOf('Puissance')!=-1) {
  10724. eps = -1; str='PuM';
  10725. }
  10726. for(var i=1 ; i<4 ; i++) {
  10727. if(texte) { texte += '<hr>'; }
  10728. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  10729. newSort = false;
  10730. for(var j=0 ; j<sortAtt.length ; j++) {
  10731. if(getTalent(sortAtt[j])) {
  10732. if(newSort) { texte += '<br/><br/>'; }
  10733. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  10734. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  10735. newSort = true;
  10736. }
  10737. }
  10738. pc = decumulPumPrem(pc);
  10739. }
  10740. }
  10741. else if(sort.indexOf('Projectile Magique')!=-1) {
  10742. var modD = 0;
  10743. var portee = getPortee__Profil(vuetotale);
  10744. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  10745. if(pcA!=0) {
  10746. modD = parseInt(vue*pcA/100);
  10747. texte += '<i>'+aff(modD)+'D6</i> ';
  10748. }
  10749. texte += aff(attbm)
  10750. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  10751. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  10752. if(pcD!=0) {
  10753. modD = parseInt(Math.floor(vue/2)+pcD);
  10754. texte += '<i>'+aff(modD)+'D3</i> ';
  10755. }else
  10756. modD = 0;
  10757. texte += aff(degbm)
  10758. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  10759. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  10760. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  10761. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  10762. if(!mainCall) return texte;
  10763. texte += '<br/>Portée : <b>'+portee+'</b> case';
  10764. if(portee>1) texte += 's';
  10765. }
  10766. else if(sort.indexOf('Projection')!=-1) {
  10767. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  10768. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  10769. +'Si le jet de résistance de la victime est réussi:<br/>'
  10770. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  10771. }
  10772. else if(sort.indexOf('Rafale Psychique')!=-1) {
  10773. var modD = 0;
  10774. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  10775. if(pcD!=0) {
  10776. modD = parseInt(deg*pcD/100);
  10777. texte += '<i>'+aff(modD)+'D3</i> ';
  10778. }
  10779. texte += aff(degbm)
  10780. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  10781. if(!mainCall) return texte;
  10782. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  10783. }
  10784. else if(sort.indexOf('Sacrifice')!=-1) {
  10785. if(pvcourant<=0)
  10786. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  10787.  
  10788. function perteSacro(sac) {
  10789. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  10790. }
  10791.  
  10792. var sac = Math.floor((pvcourant-1)/2);
  10793. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10794. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  10795. /* Sacros max et optimal sans malus (propale R') */
  10796. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10797. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  10798. if(sac>0)
  10799. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  10800. else
  10801. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  10802. /*if(sac>3) {
  10803. sac = 5*Math.floor((sac+1)/5)-1;
  10804. texte += '<br/>Soin optimal sans malus de temps : <b>'
  10805. +sac+'</b> PV'+perteSacro(sac);
  10806. }*/
  10807. }
  10808. else if(sort.indexOf('Siphon')!=-1) {
  10809. var modD = 0;
  10810. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10811. if(pcA!=0) {
  10812. modD = parseInt(att*pcA/100);
  10813. texte += '<i>'+aff(modD)+'D6</i> ';
  10814. }
  10815. texte += aff(attbm)
  10816. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  10817. +'Dégâts : <b>'+reg+'</b> D3 ';
  10818. if(pcD!=0) {
  10819. modD = parseInt(reg*pcD/100);
  10820. texte += '<i>'+aff(modD)+'D3</i> ';
  10821. }else
  10822. modD = 0;
  10823. texte += aff(degbm)
  10824. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  10825. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  10826. if(!mainCall) return texte;
  10827. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  10828. }
  10829. else if(sort.indexOf('Telekinesie')!=-1) {
  10830. texte = 'Portée horizontale :';
  10831. var vt = Math.floor(vuetotale/2)+2;
  10832. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  10833. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  10834. for(var i=0 ; i<5 ; i++) {
  10835. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  10836. if(vt>1) texte += 's';
  10837. vt=Math.max(0,vt-1);
  10838. }
  10839. }
  10840. else if(sort.indexOf('Teleportation')!=-1) {
  10841. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  10842. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  10843. var pmh = (20+vue+portee);
  10844. var pmv = 3+Math.floor(portee/3);
  10845. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  10846. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  10847. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  10848. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  10849. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  10850. }
  10851. else if(sort.indexOf('Vampirisme')!=-1) {
  10852. var modD = 0;
  10853. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  10854. if(pcA!=0) {
  10855. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  10856. texte += '<i>'+aff(modD)+'D6</i> ';
  10857. }
  10858. texte += aff(attbm)
  10859. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  10860. +'Dégâts : <b>'+deg+'</b> D3 ';
  10861. if(pcD!=0) {
  10862. modD = parseInt(deg*pcD/100);
  10863. texte += '<i>'+aff(modD)+'D3</i> ';
  10864. }else
  10865. modD = 0;
  10866. texte += aff(degbm)
  10867. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  10868. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  10869. }
  10870. else if(sort.indexOf('Vision Accrue')!=-1)
  10871. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  10872. else if(sort.indexOf('Vision lointaine')!=-1)
  10873. texte = 'En ciblant une zone située n\'importe où dans le '
  10874. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  10875. else if(sort.indexOf('Voir le Cache')!=-1)
  10876. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  10877. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  10878. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  10879. +getPortee__Profil(vuetotale)+'</b> cases';
  10880. else if(sort.indexOf('Vue Troublee')!=-1)
  10881. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10882. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  10883. return texte;
  10884. }
  10885.  
  10886.  
  10887. /*---------------------------------- Main ------------------------------------*/
  10888.  
  10889. function do_profil2()
  10890. {
  10891. try {
  10892. start_script(31);
  10893.  
  10894. extractionDonnees();
  10895. setInfosCaracteristiques();
  10896. setInfoDescription();
  10897. setInfosEtatLieux();
  10898. setInfosEtatPV();
  10899. setInfosExp();
  10900.  
  10901. creerBulleVide();
  10902. traitementTalents();
  10903. setLienAnatrolliseur();
  10904.  
  10905. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  10906. if(race=='Kastar'){ setAccel(); }
  10907. saveProfil();
  10908. displayScriptTime();
  10909. } catch(e) {
  10910. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10911. window.console.error(traceStack(e, 'profil2'));
  10912. }
  10913. }
  10914.  
  10915. /*******************************************************************************
  10916. * This file is part of Mountyzilla. *
  10917. * *
  10918. * Mountyzilla is free software; you can redistribute it and/or modify *
  10919. * it under the terms of the GNU General Public License as published by *
  10920. * the Free Software Foundation; either version 2 of the License, or *
  10921. * (at your option) any later version. *
  10922. * *
  10923. * Mountyzilla is distributed in the hope that it will be useful, *
  10924. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10925. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10926. * GNU General Public License for more details. *
  10927. * *
  10928. * You should have received a copy of the GNU General Public License *
  10929. * along with Mountyzilla; if not, write to the Free Software *
  10930. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10931. *******************************************************************************/
  10932.  
  10933. // x~x script_principal
  10934.  
  10935. function isPage(url) {
  10936. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  10937. }
  10938.  
  10939. // x~x md5.js
  10940. /*
  10941. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  10942. * Digest Algorithm, as defined in RFC 1321.
  10943. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  10944. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  10945. * Distributed under the BSD License
  10946. * See http://pajhome.org.uk/crypt/md5 for more info.
  10947. */
  10948.  
  10949. /*
  10950. * Configurable variables. You may need to tweak these to be compatible with
  10951. * the server-side, but the defaults work in most cases.
  10952. */
  10953. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  10954. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  10955. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  10956.  
  10957. /*
  10958. * These are the functions you'll usually want to call
  10959. * They take string arguments and return either hex or base-64 encoded strings
  10960. */
  10961. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  10962. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  10963. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  10964. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  10965. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  10966. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  10967.  
  10968. /*
  10969. * Perform a simple self-test to see if the VM is working
  10970. */
  10971. function md5_vm_test()
  10972. {
  10973. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  10974. }
  10975.  
  10976. /*
  10977. * Calculate the MD5 of an array of little-endian words, and a bit length
  10978. */
  10979. function core_md5(x, len)
  10980. {
  10981. /* append padding */
  10982. x[len >> 5] |= 0x80 << ((len) % 32);
  10983. x[(((len + 64) >>> 9) << 4) + 14] = len;
  10984.  
  10985. var a = 1732584193;
  10986. var b = -271733879;
  10987. var c = -1732584194;
  10988. var d = 271733878;
  10989.  
  10990. for(var i = 0; i < x.length; i += 16)
  10991. {
  10992. var olda = a;
  10993. var oldb = b;
  10994. var oldc = c;
  10995. var oldd = d;
  10996.  
  10997. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  10998. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  10999. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11000. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11001. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11002. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11003. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11004. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11005. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11006. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11007. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11008. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11009. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11010. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11011. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11012. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11013.  
  11014. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11015. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11016. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11017. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11018. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11019. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11020. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11021. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11022. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11023. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11024. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11025. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11026. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11027. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11028. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11029. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11030.  
  11031. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11032. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11033. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11034. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11035. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11036. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11037. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11038. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11039. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11040. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11041. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11042. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11043. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11044. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11045. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11046. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11047.  
  11048. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11049. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11050. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11051. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11052. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11053. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11054. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11055. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11056. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11057. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11058. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11059. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11060. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11061. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11062. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11063. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11064.  
  11065. a = safe_add(a, olda);
  11066. b = safe_add(b, oldb);
  11067. c = safe_add(c, oldc);
  11068. d = safe_add(d, oldd);
  11069. }
  11070. return Array(a, b, c, d);
  11071.  
  11072. }
  11073.  
  11074. /*
  11075. * These functions implement the four basic operations the algorithm uses.
  11076. */
  11077. function md5_cmn(q, a, b, x, s, t)
  11078. {
  11079. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11080. }
  11081. function md5_ff(a, b, c, d, x, s, t)
  11082. {
  11083. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11084. }
  11085. function md5_gg(a, b, c, d, x, s, t)
  11086. {
  11087. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11088. }
  11089. function md5_hh(a, b, c, d, x, s, t)
  11090. {
  11091. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11092. }
  11093. function md5_ii(a, b, c, d, x, s, t)
  11094. {
  11095. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11096. }
  11097.  
  11098. /*
  11099. * Calculate the HMAC-MD5, of a key and some data
  11100. */
  11101. function core_hmac_md5(key, data)
  11102. {
  11103. var bkey = str2binl(key);
  11104. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11105.  
  11106. var ipad = Array(16), opad = Array(16);
  11107. for(var i = 0; i < 16; i++)
  11108. {
  11109. ipad[i] = bkey[i] ^ 0x36363636;
  11110. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11111. }
  11112.  
  11113. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11114. return core_md5(opad.concat(hash), 512 + 128);
  11115. }
  11116.  
  11117. /*
  11118. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11119. * to work around bugs in some JS interpreters.
  11120. */
  11121. function safe_add(x, y)
  11122. {
  11123. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11124. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11125. return (msw << 16) | (lsw & 0xFFFF);
  11126. }
  11127.  
  11128. /*
  11129. * Bitwise rotate a 32-bit number to the left.
  11130. */
  11131. function bit_rol(num, cnt)
  11132. {
  11133. return (num << cnt) | (num >>> (32 - cnt));
  11134. }
  11135.  
  11136. /*
  11137. * Convert a string to an array of little-endian words
  11138. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11139. */
  11140. function str2binl(str)
  11141. {
  11142. var bin = Array();
  11143. var mask = (1 << chrsz) - 1;
  11144. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11145. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11146. return bin;
  11147. }
  11148.  
  11149. /*
  11150. * Convert an array of little-endian words to a string
  11151. */
  11152. function binl2str(bin)
  11153. {
  11154. var str = "";
  11155. var mask = (1 << chrsz) - 1;
  11156. for(var i = 0; i < bin.length * 32; i += chrsz)
  11157. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11158. return str;
  11159. }
  11160.  
  11161. /*
  11162. * Convert an array of little-endian words to a hex string.
  11163. */
  11164. function binl2hex(binarray)
  11165. {
  11166. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11167. var str = "";
  11168. for(var i = 0; i < binarray.length * 4; i++)
  11169. {
  11170. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11171. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11172. }
  11173. return str;
  11174. }
  11175.  
  11176. /*
  11177. * Convert an array of little-endian words to a base-64 string
  11178. */
  11179. function binl2b64(binarray)
  11180. {
  11181. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11182. var str = "";
  11183. for(var i = 0; i < binarray.length * 4; i += 3)
  11184. {
  11185. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11186. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11187. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11188. for(var j = 0; j < 4; j++)
  11189. {
  11190. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11191. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11192. }
  11193. }
  11194. return str;
  11195. }
  11196.  
  11197. ///////////////////////////////////////////
  11198. // debug cartes capitan Roule 07/12/2016
  11199. ///////////////////////////////////
  11200. // essais : objet
  11201. // .mode : description
  11202. // .essais : tableau d'objets essai
  11203. // .mode : description
  11204. // .essais : tableau de cartes
  11205. // .noCarte : id de la carte
  11206. // .essais : tableau d'essais, [x, y, n, nb]
  11207. function AfficheEssais(essais, sMode) {
  11208. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11209. if (!eBigDiv) {
  11210. var insertPoint = document.getElementById('footer1');
  11211. eBigDiv = document.createElement('table');
  11212. eBigDiv.id = 'ListeEssaiCapitan';
  11213. insertBefore(insertPoint, document.createElement('p'));
  11214. insertTitle(insertPoint,'Capitan : Liste des essais');
  11215. insertBefore(insertPoint, eBigDiv);
  11216. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11217. }
  11218. if (!essais) {
  11219. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11220. return;
  11221. }
  11222. var carte;
  11223. for (carte in essais) {
  11224. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11225. }
  11226. if (carte === undefined) {
  11227. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11228. }
  11229. }
  11230.  
  11231. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11232. var tr = appendTr(eTable);
  11233. var td = appendTd(tr);
  11234. appendText(td, sMode, bBold);
  11235. td = appendTd(tr);
  11236. appendText(td, sCarte, bBold);
  11237. td = appendTd(tr);
  11238. appendText(td, sText, bBold);
  11239. }
  11240.  
  11241. function getEssaiV1_0() {
  11242. try {
  11243. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11244. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11245. var tabK, nK;
  11246. prefs.getChildList('', nK, tabK);
  11247. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11248. //window.console.log('getEssaiV1_0, ' + nK);
  11249. return;
  11250. //return r;
  11251. } catch (e) {
  11252. window.console.log(traceStack(e, 'getEssaiV1_0'));
  11253. }
  11254. }
  11255.  
  11256. function getEssaiV1_1() {
  11257. var locSto = window.localStorage;
  11258. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11259. var r = [];
  11260. for (var i = 0; i < locSto.length; i++) {
  11261. var k = locSto.key(i);
  11262. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11263. var t = k.split(/\./);
  11264. if (t[0] !== 'capitan') continue;
  11265. if (t[2] !== 'essai') continue;
  11266. var carte = 'carte n°' + t[1];
  11267. if (r[carte]) r[carte]++;
  11268. else r[carte] = 1;
  11269. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11270. }
  11271. return r;
  11272. }
  11273.  
  11274. function showEssaiCartes() {
  11275. window.console.log('début showEssai Tout_MZ');
  11276. var essais = getEssaiV1_0();
  11277. AfficheEssais(essais, 'V1.0');
  11278. essais = getEssaiV1_1();
  11279. AfficheEssais(essais, 'V1.1');
  11280. window.console.log('fin showEssai Tout_MZ');
  11281. }
  11282.  
  11283. /*--------------------------------- Dispatch ---------------------------------*/
  11284.  
  11285. //chargerScriptDev("libs");
  11286. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  11287.  
  11288. try {
  11289. // Détection de la page à traiter
  11290. if(isPage("Messagerie/ViewMessageBot")) {
  11291. do_cdmbot();
  11292. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  11293. do_cdmcomp();
  11294. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  11295. do_diplo();
  11296. } else if(isPage("MH_Play/Play_equipement")) {
  11297. do_equip();
  11298. } else if(isPage("MH_Play/Play_menu")) {
  11299. do_menu();
  11300. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  11301. do_option();
  11302. //showEssaiCartes();
  11303. } else if(isPage("View/PJView")) {
  11304. do_pjview();
  11305. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  11306. do_profil();
  11307. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  11308. do_tancompo();
  11309. } else if(isPage("MH_Play/Play_vue")) {
  11310. do_vue();
  11311. } else if(isPage("MH_Play/Play_news")) {
  11312. do_news();
  11313. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  11314. do_move();
  11315. } else if(isPage("MH_Missions/Mission_Etape")) {
  11316. do_mission();
  11317. } else if(isPage("View/MonsterView")) {
  11318. do_infomonstre();
  11319. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  11320. do_attaque();
  11321. } else if(isPage("MH_Follower/FO_Ordres")) {
  11322. do_ordresgowap();
  11323. } else if(isPage("MH_Follower/FO_Equipement")) {
  11324. do_equipgowap();
  11325. } else if(isPage("MH_Play/Play_mouche")) {
  11326. do_mouches();
  11327. } else if(isPage("MH_Play/Play_BM")) {
  11328. do_malus();
  11329. } else if(isPage("MH_Play/Play_evenement")) {
  11330. do_myevent();
  11331. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  11332. do_enchant();
  11333. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  11334. do_pre_enchant();
  11335. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  11336. do_actions();
  11337. } 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')) {
  11338. do_mission_liste();
  11339. } else if(isPage('MH_Play/Play_action')) {
  11340. do_actions();
  11341. } else if(isPage('MH_Play/Play_profil2')) {
  11342. do_profil2();
  11343. }
  11344. } catch(e) {
  11345. if (e.stack) {
  11346. var sStack = e.stack;
  11347. // enlever les infos confidentielles
  11348. sStack = sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  11349. } else {var sStack = '';}
  11350. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  11351. }