Tout_MZ

Client MountyZilla

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

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @version 1.2.13.6
  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. // V1.2.13.6 08/01/2017
  106. // Réécriture analyse des étapes de mission sur monstre de niveau...
  107.  
  108. /**********************************************************
  109. À faire / propositions d'évolutions
  110.  
  111. breizhou13 20/12/2016
  112. envoyer les données à l'IT (Bricol'Trolls) aussi
  113. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  114. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  115. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  116. Roule'
  117. Réactiver les jubilaires
  118. [Prioritaire] trajets Gowaps sans avoir besoin de URL_MZscriptCarte (voir comment c'est fait dans Trajet_des_gowap_MkII.user.js)
  119. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  120. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  121. - voir l'intérêt de refaire fonctionner
  122. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  123. **********************************************************/
  124.  
  125. /**********************************************************
  126. **** Début de zone à déplacer dans une bibli commune ******
  127. **********************************************************/
  128.  
  129. // URL de base serveur MZ
  130. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  131. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  132. //var URL_MZ = 'http://192.99.225.92/mz';
  133.  
  134. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  135. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  136.  
  137. // URLs externes redirection (pas de souci CORS)
  138. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  139. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  140. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  141. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  142. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  143. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  144. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  145. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  146. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  147.  
  148. // URLs de test HTTPS
  149. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  150. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  151.  
  152. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  153. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  154. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  155.  
  156. // x~x Libs
  157.  
  158. /* ancien TODO
  159. * - revoir la gestion des CdM --> nott armure magique
  160. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  161. * - vérfier la gestion des enchants
  162. */
  163.  
  164. // Roule 04/09/2016 switch extern URLs to https if available
  165. var isHTTPS = false;
  166. if (window.location.protocol.indexOf('https') === 0) {
  167. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  168. URL_bricol = URL_bricol_https;
  169. isHTTPS = true;
  170. }
  171.  
  172. // Roule 23/12/2016 mode dev
  173. var isDEV = false;
  174. if (MY_getValue('MZ_dev')) {
  175. URL_MZ = URL_MZ.replace(/$/, 'dev');
  176. isDEV = true;
  177. }
  178.  
  179. // Images (pas de souci CORS)
  180. var URL_MZimg = URL_MZ + '/img/';
  181. // URLs externes ajax (CORS OK)
  182. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  183. var URL_pageDispatcher = URL_MZ + '/cdmdispatcher.php';
  184.  
  185. // liens externes détuits
  186. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  187. var MHicons = '/mountyhall/Images/Icones/';
  188. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  189. var MY_DEBUG = false;
  190.  
  191. /* remplacement fonction MZ */
  192. function MY_getValue(key) {
  193. return window.localStorage[key];
  194. }
  195.  
  196. function MY_removeValue(key) {
  197. window.localStorage.removeItem(key);
  198. }
  199.  
  200. function MY_setValue(key, val) {
  201. window.localStorage[key] = val;
  202. }
  203.  
  204. /*---------------- mise à jour de variables globales utiles ------------------*/
  205. // utilisé pour accès bdd (un peu partout) :
  206. var numTroll = MY_getValue('NUM_TROLL');
  207. // utilisé dans vue pour PX :
  208. var nivTroll = MY_getValue('NIV_TROLL');
  209. // utilisés dans actions et vue (calculs SR) :
  210. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  211. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  212. var currentURL = window.location.href;
  213.  
  214. /*-[functions]------------ Fonctions durée de script -------------------------*/
  215. var date_debut = null;
  216.  
  217. function start_script(nbJours_exp) {
  218. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  219. if(date_debut) return;
  220. date_debut = new Date();
  221. // Créé la variable expdate si demandé
  222. if(nbJours_exp) {
  223. expdate = new Date();
  224. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  225. }
  226. }
  227.  
  228. function displayScriptTime() {
  229. var footerNode = document.getElementById('footer2');
  230. if(!footerNode) return;
  231. try{
  232. var node = document.evaluate(
  233. ".//text()[contains(.,'Page générée en')]/../br",
  234. footerNode,null,9,null).singleNodeValue;
  235. }
  236. catch(e){return;}
  237. insertText(node,
  238. ' - [Script exécuté en '
  239. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  240. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  241. }
  242.  
  243. function traceStack(e, sModule) {
  244. var version = '';
  245. if (GM_info && GM_info.script && GM_info.script.version)
  246. version = ' ' + GM_info.script.version;
  247. sRet = '[MZ' + version + ']'
  248. if (sModule) sRet += ' {' + sModule + '}';
  249. if (e.message) sRet += ' ' + e.message;
  250. if (e.stack) {
  251. var sStack = e.stack;
  252. // enlever les infos confidentielles
  253. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  254. }
  255. return sRet;
  256. }
  257.  
  258. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  259.  
  260. function debugMZ(str){
  261. if(MY_DEBUG){
  262. window.console.debug('[MY_DEBUG] '+str);
  263. if(typeof str === "object"){
  264. window.console.debug(str);
  265. }
  266. }
  267. }
  268.  
  269. function FF_XMLHttpRequest(MY_XHR_Ob) {
  270. var request = new XMLHttpRequest();
  271. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  272. for(var head in MY_XHR_Ob.headers) {
  273. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  274. }
  275. request.onreadystatechange = function() {
  276. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  277. if(request.readyState!=4) { return; }
  278. if(request.error) {
  279. if(MY_XHR_Ob.onerror) {
  280. MY_XHR_Ob.onerror(request);
  281. }
  282. }
  283. else if(MY_XHR_Ob.onload) {
  284. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  285. MY_XHR_Ob.onload(request);
  286. }
  287. };
  288. request.send(MY_XHR_Ob.data);
  289. }
  290.  
  291.  
  292. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  293.  
  294. function avertissement(txt,duree) {
  295. if(!duree) duree = 15000;
  296. var div = document.createElement('div');
  297. // On numérote les avertissements pour destruction sélective
  298. var num = document.getElementsByName('avertissement').length;
  299. div.num = num;
  300. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  301. div.setAttribute('name','avertissement');
  302. div.className = 'mh_textbox';
  303. div.style.position = 'fixed';
  304. div.style.top = (10+15*num)+'px';
  305. div.style.left = (10+5*num)+'px';
  306. div.style.border = '5px solid red';
  307. div.style.zIndex = 2+num;
  308. div.style.cursor = 'pointer';
  309. div.style.fontSize = 'large';
  310. div.innerHTML = txt;
  311. div.onclick=function(){ tueAvertissement(this.num) };
  312.  
  313. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  314. var divcroix = document.createElement('div');
  315. divcroix.style.position = 'absolute';
  316. divcroix.style.top = 0;
  317. divcroix.style.right = 0;
  318. divcroix.style.color = 'black';
  319. divcroix.style.fontSize = 'inherit';
  320. divcroix.style.cursor = 'pointer'
  321. divcroix.style.zIndex = 2+num;
  322. divcroix.innerHTML = "X";
  323. div.appendChild(divcroix);
  324.  
  325. document.body.appendChild(div);
  326. // Destruction automatique de l'avertissement après "un certain temps"
  327. window.setTimeout(function(){ tueAvertissement(num) },duree);
  328. }
  329.  
  330. function tueAvertissement(num) {
  331. var divs = document.getElementsByName('avertissement');
  332. if(divs.length==0) { return; }
  333. for(var i=0 ; i<divs.length ; i++) {
  334. if(divs[i].num==num) {
  335. divs[i].parentNode.removeChild(divs[i]);
  336. return;
  337. }
  338. }
  339. }
  340.  
  341.  
  342. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  343.  
  344. function insertBefore(next,el) {
  345. next.parentNode.insertBefore(el,next);
  346. }
  347.  
  348. function appendTr(tbody,clas) {
  349. var tr = document.createElement('tr');
  350. if(clas) tr.className = clas;
  351. tbody.appendChild(tr);
  352. return tr;
  353. }
  354.  
  355. function insertTr(next,clas) {
  356. var tr = document.createElement('tr');
  357. if(clas) tr.className = clas;
  358. insertBefore(next,tr);
  359. return tr;
  360. }
  361.  
  362. function appendTd(tr) {
  363. var td = document.createElement('td');
  364. if(tr) tr.appendChild(td);
  365. return td;
  366. }
  367.  
  368. function insertTd(next) {
  369. var td = document.createElement('td');
  370. insertBefore(next,td);
  371. return td;
  372. }
  373.  
  374. function appendTdCenter(tr,colspan) {
  375. var td = appendTd(tr);
  376. td.align = 'center'; // WARNING - Obsolete
  377. if(colspan) td.colSpan = colspan;
  378. return td;
  379. }
  380.  
  381. function insertTdElement(next,el) {
  382. var td = insertTd(next);
  383. if(el) td.appendChild(el);
  384. return td;
  385. }
  386.  
  387. function appendA(paren,href,cssClass,text) {
  388. var a = document.createElement('a');
  389. if (href) a.href = href;
  390. if (cssClass) a.className = cssClass;
  391. if (text) a.appendChild(document.createTextNode(text));
  392. paren.appendChild(a);
  393. }
  394.  
  395. function appendText(paren,text,bold) {
  396. if(bold) {
  397. var b = document.createElement('b');
  398. b.appendChild(document.createTextNode(text));
  399. paren.appendChild(b);
  400. }
  401. else
  402. paren.appendChild(document.createTextNode(text));
  403. }
  404.  
  405. function insertText(next,text,bold) {
  406. if(bold) {
  407. var b = document.createElement('b');
  408. appendText(b,text);
  409. insertBefore(next,b);
  410. }
  411. else
  412. insertBefore(next,document.createTextNode(text));
  413. }
  414.  
  415. function appendTdText(tr,text,bold) {
  416. var td = appendTd(tr);
  417. appendText(td,text,bold);
  418. return td;
  419. }
  420.  
  421. function insertTdText(next,text,bold) {
  422. var td = insertTd(next);
  423. appendText(td,text,bold);
  424. return td;
  425. }
  426.  
  427. function appendBr(paren) {
  428. paren.appendChild(document.createElement('br'));
  429. }
  430.  
  431. function insertBr(next) {
  432. insertBefore(next,document.createElement('br'));
  433. }
  434.  
  435. function appendLI(ul,text) {
  436. // uniquement utilisé dans les options (crédits)
  437. var li = document.createElement('li');
  438. appendText(li,text);
  439. ul.appendChild(li);
  440. return li;
  441. }
  442.  
  443. function appendTextbox(paren,type,nam,size,maxlength,value) {
  444. var input = document.createElement('input');
  445. input.className = 'TextboxV2';
  446. input.type = type;
  447. input.name = nam;
  448. input.id = nam;
  449. input.size = size;
  450. input.maxLength = maxlength;
  451. if(value) input.value = value;
  452. paren.appendChild(input);
  453. return input;
  454. }
  455.  
  456. function appendCheckBox(paren,nam,checked,onClick) {
  457. var input = document.createElement('input');
  458. input.type = 'checkbox';
  459. input.name = nam;
  460. input.id = nam;
  461. if(checked) input.checked = true;
  462. if(onClick) input.onclick = onClick;
  463. paren.appendChild(input);
  464. return input;
  465. }
  466.  
  467. function appendNobr(paren,id,delgg,text) {
  468. var nobr = document.createElement('nobr');
  469. appendCheckBox(nobr,id,null,delgg);
  470. appendText(nobr,text);
  471. paren.appendChild(nobr);
  472. appendText(paren,' ');
  473. return nobr;
  474. }
  475.  
  476. function appendCheckBoxSpan(paren,id,onClick,text) {
  477. var span = document.createElement('span');
  478. span.style.whiteSpace = 'nowrap';
  479. appendCheckBox(span,id,false,onClick);
  480. appendText(span,text);
  481. paren.appendChild(span);
  482. appendText(paren,' ');
  483. return span;
  484. }
  485.  
  486. function appendOption(select,value,text) {
  487. var option = document.createElement('option');
  488. option.value = value;
  489. appendText(option,text);
  490. select.appendChild(option);
  491. return option;
  492. }
  493.  
  494. function appendHidden(form,nam,value) {
  495. var input = document.createElement('input');
  496. input.type = 'hidden';
  497. input.name = nam;
  498. input.id = nam;
  499. input.value = value;
  500. form.appendChild(input);
  501. }
  502.  
  503. function appendButton(paren,value,onClick) {
  504. var input = document.createElement('input');
  505. input.type = 'button';
  506. input.className = 'mh_form_submit';
  507. input.value = value;
  508. input.onmouseover = function(){this.style.cursor='pointer';};
  509. if(onClick) input.onclick = onClick;
  510. paren.appendChild(input);
  511. return input;
  512. }
  513.  
  514. function insertButton(next,value,onClick) {
  515. var input = document.createElement('input');
  516. input.type = 'button';
  517. input.className = 'mh_form_submit';
  518. input.value = value;
  519. input.onmouseover = function(){this.style.cursor='pointer';};
  520. input.onclick = onClick;
  521. insertBefore(next,input);
  522. return input;
  523. }
  524.  
  525. function appendSubmit(paren,value,onClick) {
  526. var input = document.createElement('input');
  527. input.type = 'submit';
  528. input.className = 'mh_form_submit';
  529. input.value = value;
  530. input.onmouseover = function(){this.style.cursor='pointer';};
  531. if(onClick) input.onclick = onClick;
  532. paren.appendChild(input);
  533. return input;
  534. }
  535.  
  536. function createImage(url,title) {
  537. var img = document.createElement('img');
  538. img.src = url;
  539. img.title = title;
  540. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  541. return img;
  542. }
  543.  
  544. function createAltImage(url,alt,title) {
  545. var img = document.createElement('img');
  546. img.src = url;
  547. img.alt = alt;
  548. img.title = title;
  549. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  550. return img;
  551. }
  552.  
  553. function createImageSpan(url,alt,title,text,bold) {
  554. var span = document.createElement('span');
  555. span.title = title;
  556. var img = document.createElement('img');
  557. img.src = url;
  558. img.alt = alt;
  559. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  560. span.appendChild(img);
  561. appendText(span,text,bold);
  562. return span;
  563. }
  564.  
  565. function createCase(titre,table,width) {
  566. if(!width) width=120;
  567. var tr = appendTr(table,'mh_tdpage');
  568. var td = appendTdText(tr,titre,true);
  569. td.className = 'mh_tdtitre';
  570. td.width = width;
  571. td = appendTdText(tr,'');
  572. td.className = 'mh_tdpage';
  573. return td;
  574. }
  575.  
  576. function getMyID(e) {
  577. var parent = e.parentNode;
  578. for(var i=0 ; i<parent.childNodes.length ; i++) {
  579. if(e==parent.childNodes[i])
  580. return i;
  581. }
  582. return -1;
  583. }
  584.  
  585. function insertAfter(elt,newElt) {
  586. var id = getMyID(elt);
  587. if(id==-1) return;
  588. if(id<elt.parentNode.childNodes.length-1)
  589. insertBefore(elt.nextSibling,newElt);
  590. else
  591. elt.parentNode.appendChild(newElt);
  592. }
  593.  
  594.  
  595. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  596.  
  597. function aff(nb) {
  598. return (nb>=0) ? '+'+nb : nb;
  599. }
  600.  
  601. function getNumber(str) {
  602. var nbr = str.match(/\d+/);
  603. return nbr ? Number(nbr[0]) : Number.NaN;
  604. }
  605.  
  606. function getNumbers(str) {
  607. var nbrs = str.match(/-?\d+/g);
  608. if (!nbrs) return [];
  609. for(var i=0 ; i<nbrs.length ; i++)
  610. nbrs[i] = Number(nbrs[i]);
  611. return nbrs;
  612. }
  613.  
  614. function trim(str) {
  615. return str.replace(/(^\s*)|(\s*$)/g,'');
  616. }
  617.  
  618. String.prototype.trim = function() {
  619. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  620. }
  621.  
  622. function epure(texte) {
  623. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  624. .replace(/[ç]/g,'c')
  625. .replace(/[éêèë]/g,'e')
  626. .replace(/[ïî]/g,'i')
  627. .replace(/[ôöõ]/g,'o')
  628. .replace(/[ùûü]/g,'u');
  629. }
  630.  
  631. String.prototype.epure = function () {
  632. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  633. .replace(/[ç]/g,'c')
  634. .replace(/[éêèë]/g,'e')
  635. .replace(/[ïî]/g,'i')
  636. .replace(/[ôöõ]/g,'o')
  637. .replace(/[ùûü]/g,'u');
  638. }
  639.  
  640. function bbcode(texte) {
  641. return texte.replace(/&/g,'&amp;')
  642. .replace(/"/g,'&quot;')
  643. .replace(/</g,'&lt;')
  644. .replace(/>/g,'&gt;')
  645. .replace(/'/g,'&#146;')
  646. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  647. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  648. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  649. }
  650.  
  651.  
  652. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  653.  
  654. function addZero(i) {
  655. return (i<10) ? '0'+i : i;
  656. }
  657.  
  658. function DateToString(date) {
  659. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  660. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  661. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  662. }
  663.  
  664. function StringToDate(str) {
  665. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  666. }
  667.  
  668. // fonctionne aussi avec datetime
  669. function SQLDateToFrench(str) {
  670. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  671. }
  672.  
  673. // ... et ajoute un "à" du plus bel effet
  674. function SQLDateToFrenchTime(str) {
  675. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  676. }
  677.  
  678. // SQLDate vers objet date Javascript
  679. function SQLDateToObject(str) {
  680. var t = str.split(/[- :]/);
  681. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  682. }
  683.  
  684. var mz_ie = (window.attachEvent)? true:false;
  685. if ("function" !== typeof addEvent) {
  686. if (mz_ie) {
  687. function addEvent(obj, typ, fn, sens) {
  688. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  689. obj["e"+typ+fn]( window.event );
  690. }
  691. obj.attachEvent("on"+typ, obj[typ+fn] );
  692. }
  693. }
  694. else {
  695. function addEvent(obj, typ, fn, sens) {
  696. obj.addEventListener(typ, fn, sens);
  697. }
  698. }
  699. }
  700.  
  701. // mise en commun du dessin des cartes (récupéré de Trajet_des_gowaps de feldspath et Vapulabehemot)
  702. function declare_css_carte_hall() {
  703. if(haut.getElementById("css_gow")) return;
  704. 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; }";
  705.  
  706. var node = document.createElement("style");
  707. node.type = "text/css";
  708. node.id = "css_gow";
  709. node.appendChild(document.createTextNode(css));
  710. document.getElementsByTagName("head")[0].appendChild(node);
  711. }
  712.  
  713. function ini_canvas_carte_hall() {
  714. var trajet = document.createElement("div");
  715. trajet.id = "carte_trajet";
  716.  
  717. var dessin = creer_canvas("trou");
  718. var dessin = document.createElement("canvas");
  719. dessin.id = ref;
  720. dessin.className = "mh_tdpage";
  721. trajet.appendChild(dessin);
  722. trajet.appendChild(creer_canvas("trajet"));
  723. trajet.appendChild(creer_canvas("danger"));
  724.  
  725. var dessin = creer_canvas("surligne");
  726. addEvent(dessin, "click", action_trajet, true);
  727. addEvent(dessin, "mousedown", start_v, true);
  728. addEvent(dessin, "mousemove", afficher_position, true);
  729. addEvent(dessin, "mouseout", function() { cacher_bulle(true) }, true);
  730. addEvent(dessin, "mouseover", function() { cacher_bulle(false) }, true);
  731. trajet.appendChild(dessin);
  732.  
  733. trajet.appendChild(creer_glissiere("gow", zoom));
  734.  
  735. var parp = document.getElementsByTagName('p');
  736. parp[parp.length-1].insertBefore(trajet,parp[parp.length-1].firstChild);
  737. }
  738.  
  739. /**********************
  740. * glissière en mode objet
  741. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  742. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  743. *
  744. * Usage:
  745. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  746. * ref : utilisé pour diversifier les IDs HTML
  747. * labelHTML : le label qui apparaît davant la glissière (peut contenir des balises HTML)
  748. * target : peut être de 3 types
  749. * - élément HTML : l'élément HTML à zoomer
  750. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  751. * - function : callback quand le curseur bouge
  752. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  753. * dans le mode dynamique, la callback est appelée sur mouseMove
  754. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  755. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  756. * autres méthodes
  757. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  758. **********************/
  759.  
  760. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  761. try {
  762. var mouseDown = false;
  763. var div_gliss = document.createElement("div"); // la DIV mère
  764. div_gliss.id = "MZ_gliss_"+ref;
  765. var div_label = document.createElement("div"); // le label
  766. div_label.innerHTML = labelHTML;
  767. div_gliss.appendChild(div_label);
  768. div_gliss.className = "choix_zoom";
  769. var dessin = document.createElement("canvas"); // le dessin lui-même
  770. dessin.id = "MZ_gliss_dessin_"+ref;
  771. dessin.width = 104;
  772. dessin.height = 12;
  773. div_gliss.appendChild(dessin);
  774. var pourcent = document.createElement("span"); // le pourcentage
  775. pourcent.id = "MZ_gliss_pourcent_"+ref;
  776. var pourcent_text = document.createTextNode('');
  777. pourcent.appendChild(pourcent_text);
  778. div_gliss.appendChild(pourcent);
  779.  
  780. var bulle_pourcent = document.createElement("div"); // la bulle
  781. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  782. bulle_pourcent.style.display = 'block';
  783. bulle_pourcent.style.visibility = 'hidden';
  784. bulle_pourcent.style.position = 'absolute';
  785. bulle_pourcent.style.zIndex = 3500;
  786. bulle_pourcent.style.border = '1px solid #a1927f';
  787. var bulle_pourcent_text = document.createTextNode('');
  788. bulle_pourcent.appendChild(bulle_pourcent_text);
  789. document.body.appendChild(bulle_pourcent);
  790.  
  791. this.getElt = function() {return div_gliss;};
  792.  
  793. ////////////////////////////////////
  794. // dessine et redessine le curseur
  795. ////////////////////////////////////
  796. var dessine_glissiere = function(val) {
  797. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  798. var ctx = dessin.getContext('2d');
  799. ctx.clearRect(0, 0,104, 12);
  800. ctx.fillStyle = "rgb(0,0,0)";
  801. ctx.fillRect(0,0,2,12);
  802. ctx.fillRect(102,0,2,12);
  803. ctx.fillRect(0,5,104,2);
  804.  
  805. ctx.fillStyle = "rgb(80,80,80)";
  806. ctx.fillRect(pos_0_100,0,5,12);
  807. ctx.fillStyle = "rgb(200,200,200)";
  808. ctx.fillRect(pos_0_100+1,1,3,10);
  809. pourcent_text.nodeValue = val+'%';
  810. };
  811.  
  812. ////////////////////////////////////
  813. // action qur mousedown et mousemove
  814. // stocker la nouvelle valeur
  815. // redessiner
  816. // afficher la nouvelle valeur
  817. // action selon ce qui a été demandé
  818. ////////////////////////////////////
  819. var doCallback_glissiere = function (evt) {
  820. try {
  821. if (evt.type === 'mousedown') mouseDown = true;
  822. if (evt.offsetX) {
  823. var xsouris = evt.offsetX;
  824. var xpos = evt.clientX;
  825. var ypos = evt.clientY + document.body.scrollTop;
  826. }
  827. else {
  828. var xsouris = evt.layerX;
  829. var xpos = evt.pageX;
  830. var ypos = evt.pageY;
  831. }
  832. var val = Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin));
  833. // afficher la nouvelle valeur dans la bulle
  834. bulle_pourcent_text.nodeValue = val + '%';
  835. bulle_pourcent.style.top = (ypos+3)+'px';
  836. bulle_pourcent.style.left = (xpos+16)+'px';
  837. if (evt.buttons === undefined) {
  838. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  839. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  840. } else {
  841. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  842. }
  843. // stocker la nouvelle valeur
  844. MY_setValue("MZ_glissiere_" + ref, val);
  845. // redessiner la glissière avec le curseur où il faut
  846. dessine_glissiere(val);
  847. // action selon ce qui a été demandé
  848. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  849. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  850. if (typeof paramTarget === 'object') {
  851. var elt = paramTarget;
  852. } else if (typeof paramTarget === 'string') {
  853. var elt = document.getElementById(paramTarget);
  854. } else if (typeof paramTarget === 'function') {
  855. paramTarget(val);
  856. return;
  857. }
  858. // à faire : zoom de l'elt
  859. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  860. };
  861.  
  862. ////////////////////////////////////
  863. // event mousedown et mousemove : redessiner et callback
  864. ////////////////////////////////////
  865. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  866. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  867. ////////////////////////////////////
  868. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  869. ////////////////////////////////////
  870. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  871. ////////////////////////////////////
  872. // event mouseout & mouseover : afficher/cacher la bulle
  873. ////////////////////////////////////
  874. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  875. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  876.  
  877. ////////////////////////////////////
  878. // dessiner la première fois
  879. ////////////////////////////////////
  880. var val_init = MY_getValue("MZ_glissiere_" + ref);
  881. if (val_init === undefined) val_init = valDef;
  882. dessine_glissiere(val_init);
  883. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  884. }
  885.  
  886.  
  887. /**********************************************************
  888. **** Fin de zone à déplacer dans une bibli commune ********
  889. **********************************************************/
  890.  
  891. /* DEBUG: NETTOYAGE TAGS */
  892. if(MY_getValue(numTroll+'.TAGSURL')) {
  893. MY_removeValue(numTroll+'.TAGSURL');
  894. }
  895.  
  896. // Alerte si mode dev
  897. if (isDEV) {
  898. var divpopup = document.createElement('div');
  899. divpopup.id = 'divDEV';
  900. divpopup.style =
  901. 'position: fixed;'+
  902. 'border: 15px solid red;'+
  903. 'top: 10px;right: 10px;'+
  904. 'background-color: white;'+
  905. 'color: black;'+
  906. 'font-size: large;'+
  907. 'padding: 5px'+
  908. 'z-index: 200;';
  909. appendText(divpopup, '[MZ] Mode DEV');
  910. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  911. document.body.appendChild(divpopup);
  912. }
  913.  
  914. /*---------- regroupement des getPortee() ------------------------------------*/
  915. // issu des script profil et profil2
  916. function getPortee__Profil(param) {
  917. param = Math.max(0,Number(param));
  918. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  919. // ça devrait être floor, +10.25, -2.5
  920. }
  921.  
  922. // issu du script vue
  923. function getPortee__Vue(param) {
  924. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  925. }
  926.  
  927.  
  928. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  929.  
  930. function getPXKill(niv) {
  931. return Math.max(0,10+3*niv-2*nivTroll);
  932. }
  933.  
  934. function getPXDeath(niv) {
  935. return Math.max(0,10+3*nivTroll-2*niv);
  936. }
  937.  
  938. function analysePX(niv) {
  939. niv = niv+'';
  940. var i = niv.indexOf('+');
  941. if(i!=-1) // si niv = 'XX+' ??
  942. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  943. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  944. if(i!=-1) {
  945. var max = getPXKill(niv.slice(i+2));
  946. if(max==0)
  947. return ' --> <b>0</b> PX';
  948. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  949. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  950. }
  951. i = niv.indexOf('='); // ???
  952. if(i!=-1) {
  953. var max = getPXKill(niv.slice(i+1));
  954. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  955. }
  956. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  957. }
  958.  
  959. function analysePXTroll(niv) {
  960. var str = analysePX(niv);
  961. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  962. return str;
  963. }
  964.  
  965.  
  966. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  967. // Refonte totale du code de Zorya
  968.  
  969. // Elements à implémenter en dur dans MZ2.0
  970. var numQualite = {
  971. 'Très Mauvaise':1,
  972. 'Mauvaise':2,
  973. 'Moyenne':3,
  974. 'Bonne':4,
  975. 'Très Bonne':5
  976. };
  977.  
  978. var qualiteNum = [
  979. '_dummy_',
  980. 'Très Mauvaise',
  981. 'Mauvaise',
  982. 'Moyenne',
  983. 'Bonne',
  984. 'Très Bonne'
  985. ];
  986.  
  987. var nival = {
  988. 'Abishaii Bleu':19,
  989. 'Abishaii Noir':10,
  990. 'Abishaii Rouge':23,
  991. 'Abishaii Vert':15,
  992. 'Ame-en-peine':8,
  993. 'Amibe Geante':9,
  994. 'Anaconda des Catacombes':8,
  995. 'Ankheg':10,
  996. 'Anoploure Purpurin':36,
  997. 'Araignee Geante':2,
  998. 'Ashashin':35,
  999. 'Balrog':50,
  1000. 'Banshee':16,
  1001. 'Barghest':36,
  1002. 'Basilisk':11,
  1003. 'Behemoth':34,
  1004. 'Behir':14,
  1005. 'Beholder':50,
  1006. 'Boggart':3,
  1007. 'Bondin':9,
  1008. "Bouj'Dla Placide":37,
  1009. "Bouj'Dla":19,
  1010. 'Bulette':19,
  1011. 'Caillouteux':1,
  1012. 'Capitan':35,
  1013. 'Carnosaure':25,
  1014. 'Champi-Glouton':3,
  1015. 'Chauve-Souris Geante':4,
  1016. 'Cheval a Dents de Sabre':23,
  1017. 'Chevalier du Chaos':20,
  1018. 'Chimere':13,
  1019. 'Chonchon':24,
  1020. 'Coccicruelle':22,
  1021. 'Cockatrice':5,
  1022. 'Crasc Medius':17,
  1023. 'Crasc Maexus':25,
  1024. 'Crasc':10,
  1025. 'Croquemitaine':6,
  1026. 'Cube Gelatineux':32,
  1027. 'Daemonite':27,
  1028. 'Diablotin':5,
  1029. 'Dindon du Chaos':1,
  1030. 'Djinn':29,
  1031. 'Ectoplasme':18,
  1032. 'Effrit':27,
  1033. "Elementaire d'Air":23,
  1034. "Elementaire d'Eau":17,
  1035. 'Elementaire de Feu':21,
  1036. 'Elementaire de Terre':21,
  1037. 'Elementaire du Chaos':26,
  1038. 'Erinyes':7,
  1039. 'Esprit-Follet':16,
  1040. 'Essaim Craterien':30,
  1041. 'Essaim Sanguinaire':25,
  1042. 'Ettin':8,
  1043. 'Familier':1,
  1044. 'Fantome':24,
  1045. 'Feu Follet':20,
  1046. 'Flagelleur Mental':33,
  1047. 'Foudroyeur':38,
  1048. 'Fumeux':22,
  1049. 'Fungus Geant':9,
  1050. 'Fungus Violet':4,
  1051. 'Furgolin':10,
  1052. 'Gargouille':3,
  1053. 'Geant de Pierre':13,
  1054. 'Geant des Gouffres':22,
  1055. "Geck'oo Majestueux":40,
  1056. "Geck'oo":15,
  1057. 'Glouton':20,
  1058. 'Gnoll':5,
  1059. 'Gnu Domestique':1,
  1060. 'Gnu Sauvage':1,
  1061. 'Goblin':4,
  1062. 'Goblours':4,
  1063. "Golem d'Argile":15,
  1064. 'Golem de cuir':1,
  1065. 'Golem de Chair':8,
  1066. 'Golem de Fer':31,
  1067. 'Golem de mithril':1,
  1068. 'Golem de metal':1,
  1069. 'Golem de papier':1,
  1070. 'Golem de Pierre':23,
  1071. 'Gorgone':11,
  1072. 'Goule':4,
  1073. 'Gowap Apprivoise':1,
  1074. 'Gowap Sauvage':1,
  1075. 'Gremlins':3,
  1076. 'Gritche':39,
  1077. 'Grouilleux':4,
  1078. 'Grylle':31,
  1079. 'Harpie':4,
  1080. 'Hellrot':18,
  1081. 'Homme-Lezard':4,
  1082. 'Hurleur':8,
  1083. 'Hydre':50,
  1084. 'Incube':13,
  1085. 'Kobold':2,
  1086. 'Labeilleux':26,
  1087. 'Lezard Geant':5,
  1088. 'Liche':50,
  1089. 'Limace Geante':10,
  1090. 'Loup-Garou':8,
  1091. 'Lutin':4,
  1092. 'Mante Fulcreuse':30,
  1093. 'Manticore':9,
  1094. 'Marilith':33,
  1095. 'Meduse':6,
  1096. 'Megacephale':38,
  1097. 'Mille-Pattes Geant':14,
  1098. 'Mimique':6,
  1099. 'Minotaure':7,
  1100. 'Molosse Satanique':8,
  1101. 'Momie':4,
  1102. 'Monstre Rouilleur':3,
  1103. "Mouch'oo Domestique":14,
  1104. "Mouch'oo Majestueux Sauvage":33,
  1105. "Mouch'oo Sauvage":14,
  1106. 'Na-Haniym-Heee':0,
  1107. 'Necrochore':37,
  1108. 'Necromant':39,
  1109. 'Necrophage':8,
  1110. 'Naga':10,
  1111. 'Nuee de Vermine':13,
  1112. "Nuage d'Insectes":7,
  1113. 'Ogre':7,
  1114. 'Ombre de Roches':13,
  1115. 'Ombre':2,
  1116. 'Orque':3,
  1117. 'Ours-Garou':18,
  1118. 'Palefroi Infernal':29,
  1119. 'Phoenix':32,
  1120. 'Pititabeille':0,
  1121. 'Plante Carnivore':4,
  1122. 'Pseudo-Dragon':5,
  1123. 'Rat Geant':2,
  1124. 'Rat-Garou':3,
  1125. 'Rocketeux':5,
  1126. 'Sagouin':3,
  1127. 'Scarabee Geant':4,
  1128. 'Scorpion Geant':10,
  1129. 'Shai':28,
  1130. 'Sirene':8,
  1131. 'Slaad':5,
  1132. 'Sorciere':17,
  1133. 'Spectre':14,
  1134. 'Sphinx':30,
  1135. 'Squelette':1,
  1136. 'Strige':2,
  1137. 'Succube':13,
  1138. 'Tertre Errant':20,
  1139. 'Thri-kreen':10,
  1140. 'Tigre-Garou':12,
  1141. 'Titan':26,
  1142. 'Trancheur':35,
  1143. 'Tubercule Tueur':14,
  1144. 'Tutoki':4,
  1145. 'Vampire':29,
  1146. 'Ver Carnivore Geant':12,
  1147. 'Ver Carnivore':11,
  1148. 'Veskan Du Chaos':14,
  1149. 'Vouivre':33,
  1150. 'Worg':5,
  1151. 'Xorn':14,
  1152. 'Yeti':8,
  1153. 'Yuan-ti':15,
  1154. 'Zombie':2
  1155. }
  1156.  
  1157. var tabEM = {
  1158. //Monstre: [Compo exact, Sort, Position, Localisation]
  1159. // AA
  1160. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1161. // AE
  1162. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1163. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1164. // AdA
  1165. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1166. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1167. // AdE
  1168. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1169. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1170. // AdD
  1171. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1172. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1173. // BAM
  1174. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1175. // BuM
  1176. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1177. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1178. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1179. // Explo
  1180. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1181. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1182. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1183. // FP
  1184. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1185. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1186. // FA
  1187. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1188. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1189. // Glue
  1190. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1191. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1192. // GdS
  1193. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1194. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1195. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1196. // Invi
  1197. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1198. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1199. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1200. // Lévitation
  1201. // ???
  1202. // PréM :
  1203. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1204. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1205. // Proj
  1206. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1207. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1208. // PuM :
  1209. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1210. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1211. // Sacro
  1212. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1213. // Télék
  1214. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1215. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1216. // TP
  1217. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1218. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1219. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1220. // VA
  1221. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1222. // VL
  1223. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1224. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1225. // VlC
  1226. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1227. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1228. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1229. // VT
  1230. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1231. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1232. // Variables
  1233. 'Rat':["d'un"],
  1234. 'Rat Géant':["d'un"],
  1235. 'Dindon':["d'un"],
  1236. 'Goblin':["d'un"],
  1237. 'Limace':["d'une"],
  1238. 'Limace Géante':["d'une"],
  1239. 'Ver':["d'un"],
  1240. 'Ver Carnivore':["d'un"],
  1241. 'Ver Carnivore Géant':["d'un"],
  1242. 'Fungus':["d'un"],
  1243. 'Vouivre':["d'une"],
  1244. 'Gnu':["d'un"],
  1245. 'Scarabée':["d'un"]
  1246. };
  1247.  
  1248. var mundiChampi = {
  1249. 'Préscientus Reguis':'du Phoenix',
  1250. 'Amanite Trolloïde':'de la Mouche',
  1251. 'Girolle Sanglante':'du Dindon',
  1252. 'Horreur Des Prés':'du Gobelin',
  1253. 'Bolet Péteur':'du Démon',
  1254. 'Pied Jaune':'de la Limace',
  1255. 'Agaric Sous-Terrain':'du Rat',
  1256. 'Suinte Cadavre':"de l'Hydre",
  1257. 'Cèpe Lumineux':'du Ver',
  1258. 'Fungus Rampant':'du Fungus',
  1259. 'Nez Noir':'de la Vouivre',
  1260. 'Pleurote Pleureuse':'du Gnu',
  1261. 'Phytomassus Xilénique':'du Scarabée'
  1262. };
  1263.  
  1264. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1265. appendText(node,' ');
  1266. var urlImg = URL_MZimg
  1267. +'Competences/melangeMagique.png';
  1268. var text = ' [-'+(niv+effetQ)+' %]';
  1269. var str = '';
  1270. switch(mob[0]) {
  1271. case 'A':
  1272. case 'E':
  1273. case 'I':
  1274. case 'O':
  1275. case 'U':
  1276. str = "Compo d'";
  1277. break;
  1278. default:
  1279. str = 'Compo de ';
  1280. }
  1281. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1282. var span = createImageSpan(urlImg,'MM:',title,text);
  1283. node.appendChild(span);
  1284. }
  1285. function addInfoEM(node,mob,compo,qualite,localisation) {
  1286. if(!tabEM[mob]) return;
  1287. var title = 'Composant variable', texte = 'Variable';
  1288. var bold = false;
  1289. if(tabEM[mob].length>1) {
  1290. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1291. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1292. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1293. if(pc<-20) return;
  1294. if(pc>=0) bold = true;
  1295. texte = aff(pc)+'%';
  1296. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1297. }
  1298. var urlImg = URL_MZimg
  1299. +'Competences/ecritureMagique.png';
  1300. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1301. node.appendChild(span);
  1302. }
  1303.  
  1304. function insererInfosEM(tbody) {
  1305. // lancé par equip, equipgowap
  1306. var trCompos = document.evaluate(
  1307. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1308. tbody,null,7,null);
  1309. var strCompos = '';
  1310. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1311. var node = trCompos.snapshotItem(i).childNodes[7];
  1312. var str = node.firstChild.textContent;
  1313. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1314. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1315. // Si non-EM on stoppe le traitement
  1316. if(!tabEM[mob]) continue;
  1317. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1318. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1319. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1320. addInfoEM(node,mob,compo,qualite,localisation);
  1321. }
  1322. }
  1323.  
  1324. function getQualite(qualite) {
  1325. var nb = numQualite[qualite];
  1326. return nb ? nb-1 : -1;
  1327. }
  1328.  
  1329. function getEM(nom) {
  1330. if(nom.indexOf('[')!=-1)
  1331. nom = trim(nom.substring(0,nom.indexOf('[')));
  1332. if(tabEM[nom]) return nom;
  1333. return '';
  1334. }
  1335.  
  1336. // DEBUG ex-fonction composantEM
  1337. function compoMobEM(mob) {
  1338. if(!tabEM[mob]) return '';
  1339. if(tabEM[mob].length==1)
  1340. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1341. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1342. +") pour l'écriture de "+tabEM[mob][1];
  1343. }
  1344.  
  1345. // DEBUG ex-fonction compoEM
  1346. function titreCompoEM(mob,compo,localisation,qualite) {
  1347. if(!tabEM[mob]) return '';
  1348. if(tabEM[mob].length==1) return 'Composant variable';
  1349. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1350. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1351. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1352. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1353. return '';
  1354. }
  1355.  
  1356. // DEBUG - rétrocompatibilité
  1357. function compoEM(mob) {
  1358. // appelé dans libs, vue
  1359. return compoMobEM(mob);
  1360. }
  1361. function composantEM(mob,compo,localisation,qualite) {
  1362. // appelé dans libs, tancompo
  1363. return titreCompoEM(mob,compo,localisation,qualite);
  1364. }
  1365. //
  1366.  
  1367.  
  1368. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1369.  
  1370. arrayTalents = {
  1371. /* Compétences */
  1372. 'Acceleration du Metabolisme':'AM',
  1373. 'Attaque Precise':'AP',
  1374. 'Balayage':'Balayage',
  1375. //'Balluchonnage':'Ballu',
  1376. 'Baroufle':'Baroufle',
  1377. 'Bidouille':'Bidouille',
  1378. 'Botte Secrete':'BS',
  1379. 'Camouflage':'Camou',
  1380. 'Charger':'Charger',
  1381. 'Connaissance des Monstres':'CdM',
  1382. 'Construire un Piege':'Piege',
  1383. 'Piege a Feu':'PiegeFeu',
  1384. 'Piege a Glue':'PiegeGlue',
  1385. 'Contre-Attaquer':'CA',
  1386. 'Coup de Butoir':'CdB',
  1387. 'Course':'Course',
  1388. 'Deplacement Eclair':'DE',
  1389. 'Dressage':'Dressage',
  1390. 'Ecriture Magique':'EM',
  1391. 'Frenesie':'Frenesie',
  1392. 'Golemologie':'Golemo',
  1393. 'Golem de cuir':'GolemCuir',
  1394. 'Golem de metal':'GolemMetal',
  1395. 'Golem de mithril':'GolemMithril',
  1396. 'Golem de papier':'GolemPapier',
  1397. 'Grattage':'Grattage',
  1398. 'Hurlement Effrayant':'HE',
  1399. 'Identification des Champignons':'IdC',
  1400. 'Insultes':'Insultes',
  1401. 'Lancer de Potions':'LdP',
  1402. 'Marquage':'Marquage',
  1403. 'Melange Magique':'Melange',
  1404. 'Miner':'Miner',
  1405. 'Necromancie':'Necro',
  1406. 'Painthure de Guerre':'PG',
  1407. 'Parer':'Parer',
  1408. 'Pistage':'Pistage',
  1409. 'Planter un Champignon':'PuC',
  1410. 'Regeneration Accrue':'RA',
  1411. 'Reparation':'Reparation',
  1412. 'Retraite':'Retraite',
  1413. 'Rotobaffe':'RB',
  1414. 'Shamaner':'Shamaner',
  1415. "S'interposer":'SInterposer',
  1416. 'Tailler':'Tailler',
  1417. //'Vol':'Vol',
  1418. /* Sortilèges */
  1419. 'Analyse Anatomique':'AA',
  1420. 'Armure Etheree':'AE',
  1421. 'Augmentation de l´Attaque':'AdA',
  1422. 'Augmentation de l´Esquive':'AdE',
  1423. 'Augmentation des Degats':'AdD',
  1424. 'Bulle Anti-Magie':'BAM',
  1425. 'Bulle Magique':'BuM',
  1426. 'Explosion':'Explo',
  1427. 'Faiblesse Passagere':'FP',
  1428. 'Flash Aveuglant':'FA',
  1429. 'Glue':'Glue',
  1430. 'Griffe du Sorcier':'GdS',
  1431. 'Hypnotisme':'Hypno',
  1432. 'Identification des tresors':'IdT',
  1433. 'Invisibilite':'Invi',
  1434. 'Levitation':'Levitation',
  1435. 'Precision Magique':'PreM',
  1436. 'Projectile Magique':'Projo',
  1437. 'Projection':'Proj',
  1438. 'Puissance Magique':'PuM',
  1439. 'Rafale Psychique':'Rafale',
  1440. 'Sacrifice':'Sacro',
  1441. 'Siphon des Ames':'Siphon',
  1442. 'Telekinesie':'Telek',
  1443. 'Teleportation':'TP',
  1444. 'Vampirisme':'Vampi',
  1445. 'Vision Accrue':'VA',
  1446. 'Vision lointaine':'VL',
  1447. 'Voir le Cache':'VlC',
  1448. 'Vue Troublee':'VT'
  1449. //'':''
  1450. }
  1451.  
  1452. // DEBUG - Pour rétrocompatibilité
  1453. function getSortComp(nom,niveau) {
  1454. return getTalent(nom,niveau);
  1455. }
  1456. //
  1457.  
  1458. function getTalent(nom,niveau) {
  1459. var nomEnBase = arrayTalents[epure(nom)];
  1460. if(!nomEnBase) return 0;
  1461. if(!niveau) var niveau = '';
  1462. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1463. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1464. return 0;
  1465. }
  1466.  
  1467. function removeAllTalents() {
  1468. for(var talent in arrayTalents) {
  1469. var nomEnBase = arrayTalents[talent];
  1470. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1471. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1472. continue;
  1473. }
  1474. var niveau = 1;
  1475. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1476. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1477. niveau++;
  1478. }
  1479. }
  1480. }
  1481.  
  1482. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1483. var att = MY_getValue(numTroll+'.caracs.attaque');
  1484. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1485. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1486. var mm = MY_getValue(numTroll+'.caracs.mm');
  1487. var deg = MY_getValue(numTroll+'.caracs.degats');
  1488. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1489. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1490. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1491. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1492. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1493. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1494. return false;
  1495. return true;
  1496. }
  1497.  
  1498.  
  1499. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1500.  
  1501. function getPVsRestants(pv,bless,vue) {
  1502. bless = Number(bless.match(/\d+/)[0]);
  1503. if(bless==0) return null;
  1504. var pvminmax = pv.match(/\d+/g);
  1505. if(bless==95) {
  1506. var pvb = 1;
  1507. var pvh = Math.floor( pvminmax[1]/20 );
  1508. }
  1509. else if(bless==5) {
  1510. var pvb = Math.floor( pvminmax[0]*19/20 );
  1511. var pvh = pvminmax[1];
  1512. }
  1513. else {
  1514. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1515. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1516. }
  1517. return vue ? ' ('+pvb+'-'+pvh+')' :
  1518. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1519. }
  1520.  
  1521. function insertButtonCdm(nextName,onClick,texte) {
  1522. if(texte==null) texte = 'Participer au bestiaire';
  1523. var nextNode = document.getElementsByName(nextName)[0];
  1524.  
  1525. var espace = document.createTextNode('\t');
  1526. insertBefore(nextNode,espace);
  1527.  
  1528. var button = document.createElement('input');
  1529. button.type = 'button';
  1530. button.className = 'mh_form_submit';
  1531. button.value = texte;
  1532. button.onmouseover = function(){this.style.cursor='pointer';};
  1533. if(onClick) button.onclick = onClick;
  1534. insertBefore(espace,button);
  1535. return button;
  1536. }
  1537.  
  1538. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1539. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1540. 'Capacité spéciale','Résistance Magique','Autres'];
  1541.  
  1542. function createImageTactique(url,id,nom) {
  1543. var img = document.createElement('img');
  1544. img.src = url;
  1545. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1546. img.id = id;
  1547. img.nom = nom;
  1548. img.onmouseover = showPopupTactique;
  1549. img.onmouseout = hidePopup;
  1550. return img;
  1551. }
  1552.  
  1553. function createCDMTable(id,nom,donneesMonstre) {
  1554. try {
  1555. var urlImg = URL_MZimg;
  1556. var table = document.createElement('table');
  1557. var profilActif = isProfilActif();
  1558. table.className = 'mh_tdborder';
  1559. table.border = 0;
  1560. table.cellSpacing = 1;
  1561. table.cellPadding = 4;
  1562. var thead = document.createElement('thead');
  1563. var tr = appendTr(thead,'mh_tdtitre');
  1564. var td = appendTdText(tr,
  1565. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1566. true
  1567. );
  1568. td.colSpan = 2;
  1569. table.appendChild(thead);
  1570. var tbody = document.createElement('tbody');
  1571. table.appendChild(tbody);
  1572. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1573. createCase(listeTitres[i],tbody,80);
  1574. }
  1575. var TypeMonstre = getEM(nom);
  1576. var infosCompo='';
  1577. if(TypeMonstre!='') {
  1578. infosCompo = compoEM(TypeMonstre);
  1579. }
  1580. var nodes = tbody.childNodes;
  1581. nodes[0].childNodes[1].innerHTML =
  1582. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1583. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1584. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1585. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1586. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1587. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1588. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1589. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1590. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1591. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1592. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1593. td = createCase(listeTitres[10],tbody);
  1594. td.innerHTML = bbcode(donneesMonstre[10]);
  1595. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1596. td.appendChild(document.createTextNode(" "));
  1597. if(donneesMonstre[16] == "De zone")
  1598. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1599. else if(donneesMonstre[16] == "Automatique")
  1600. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1601. else if(donneesMonstre[16] == "Au toucher")
  1602. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1603. }
  1604. }
  1605. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1606. {
  1607. td = createCase(listeTitres[11],tbody);
  1608. td.innerHTML = bbcode(donneesMonstre[9]);
  1609. // seuil de résistance du monstre
  1610. var lb = td.getElementsByTagName('b');
  1611. if(lb.length == 1) {
  1612. var mrm = lb[0].firstChild.nodeValue * 1;
  1613. var v = (mrm / mmTroll);
  1614. lb[0].firstChild.nodeValue += " ("
  1615. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1616. }
  1617. }
  1618. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1619. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1620. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1621. {
  1622. td = createCase(listeTitres[12],tbody);
  1623. if(donneesMonstre[12]==1)
  1624. {
  1625. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1626. }
  1627. if(donneesMonstre[13]==1)
  1628. {
  1629. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1630. }
  1631. else if(donneesMonstre[13]==0)
  1632. {
  1633. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1634. }
  1635. if(donneesMonstre[14]==1)
  1636. {
  1637. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1638. }
  1639. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1640. {
  1641. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1642. }
  1643. else if(donneesMonstre[14]>6)
  1644. {
  1645. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1646. }
  1647. if(donneesMonstre[15]=="Lente")
  1648. {
  1649. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1650. }
  1651. else if(donneesMonstre[15]=="Normale")
  1652. {
  1653. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1654. }
  1655. else if(donneesMonstre[15]=="Rapide")
  1656. {
  1657. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1658. }
  1659. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1660. {
  1661. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1662. }
  1663. if(infosCompo.length>0)
  1664. {
  1665. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1666. }
  1667. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1668. {
  1669. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1670. }
  1671. }
  1672. // pourcentage de blessure
  1673. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1674. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1675. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1676. if(pvs)
  1677. lb[0].firstChild.nodeValue += pvs;
  1678. }
  1679. return table;
  1680. }
  1681. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  1682. }
  1683.  
  1684.  
  1685. /*-[functions]------------ Gestion des enchantements -------------------------*/
  1686.  
  1687. var listeMonstreEnchantement = null,
  1688. listeEquipementEnchantement = null,
  1689. listeInfoEnchantement = null;
  1690.  
  1691. function computeCompoEnchantement()
  1692. {
  1693. listeMonstreEnchantement = new Array();
  1694. listeInfoEnchantement = new Array();
  1695. listeEquipementEnchantement = new Array();
  1696. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  1697. for(var i=0;i<liste.length;i++)
  1698. {
  1699. var idEquipement = liste[i]*1;
  1700. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  1701. continue;
  1702. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  1703. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  1704. var texteGlobal='';
  1705. for(var j=0;j<3;j++)
  1706. {
  1707. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  1708. listeMonstreEnchantement[infoComposant[2]] = 1;
  1709. var array = new Array();
  1710. array[0]=infoComposant[0].replace("Ril","Œil");
  1711. array[1]=infoComposant[1];
  1712. array[2]=infoComposant[2];
  1713. array[3]=getQualite(infoComposant[3]);
  1714. var texte = infoComposant[4].replace("Ril","Œil");
  1715. for(var k=5;k<infoComposant.length;k++)
  1716. {
  1717. texte += ";"+infoComposant[k].replace("Ril","Œil");
  1718. }
  1719. texteGlobal+=texte+'\n';
  1720. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1721. array[4]=texte;
  1722. listeInfoEnchantement.push(array);
  1723. }
  1724. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  1725. listeEquipementEnchantement[idEquipement] = texteGlobal;
  1726. }
  1727. }
  1728.  
  1729. function isEnchant(nom) {
  1730. var monstreEnchant = '';
  1731. for(j in listeInfoEnchantement) {
  1732. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1733. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1734. monstreEnchant=monstre;
  1735. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  1736. }
  1737. }
  1738. return trim(monstreEnchant);
  1739. }
  1740.  
  1741. function getInfoEnchantementFromMonstre(nom)
  1742. {
  1743. try
  1744. {
  1745. if(!listeMonstreEnchantement)
  1746. {
  1747. computeCompoEnchantement();
  1748. }
  1749. var infosEnchant = '';
  1750. for(j in listeInfoEnchantement) {
  1751. monstre = listeInfoEnchantement[j][2].toLowerCase();
  1752. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  1753. if(infosEnchant=='')
  1754. infosEnchant=listeInfoEnchantement[j][4];
  1755. else
  1756. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  1757. }
  1758. }
  1759. return trim(infosEnchant);
  1760. }
  1761. catch(e)
  1762. {
  1763. window.alert(e);
  1764. }
  1765. }
  1766.  
  1767. function composantEnchant(Monstre,composant,localisation,qualite) {
  1768. var compo='';
  1769. for(var i=0; i<listeInfoEnchantement.length; i++) {
  1770. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  1771. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  1772. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  1773. listeInfoEnchantement[i][3]<=qualite
  1774. ) {
  1775. return listeInfoEnchantement[i][4];
  1776. }
  1777. }
  1778. return compo;
  1779. }
  1780.  
  1781. function insertEnchantInfos(tbody) {
  1782. try
  1783. {
  1784. if(!listeMonstreEnchantement)
  1785. computeCompoEnchantement();
  1786. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  1787. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1788. if(nodes.snapshotLength == 0)
  1789. return false;
  1790. var urlImg = URL_MZimg + 'enchant.png';
  1791. for(var i = 0; i < nodes.snapshotLength; i++) {
  1792. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  1793. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  1794. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  1795. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  1796. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  1797. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  1798. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  1799. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  1800. if(isEnchant(nomMonstre).length>0)
  1801. {
  1802. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  1803. if(infos.length>0)
  1804. {
  1805. if(link.parentNode == link.nextSibling.parentNode)
  1806. {
  1807. var tmp = link.nextSibling;
  1808. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  1809. }
  1810. else
  1811. {
  1812. link.parentNode.appendChild(createImage(urlImg,infos));
  1813. }
  1814. }
  1815. }
  1816. }
  1817. }
  1818. catch(e)
  1819. {
  1820. window.alert(e);
  1821. }
  1822. }
  1823.  
  1824. function computeEnchantementEquipement(fontionTexte,formateTexte)
  1825. {
  1826. try
  1827. {
  1828. if(!listeMonstreEnchantement)
  1829. computeCompoEnchantement();
  1830. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  1831. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  1832. if(nodes.snapshotLength == 0)
  1833. return false;
  1834. var urlImg = URL_MZimg + 'enchant.png';
  1835. for(var i = 0; i < nodes.snapshotLength; i++)
  1836. {
  1837. var link = nodes.snapshotItem(i);
  1838. var idEquipement = link.getAttribute('href');
  1839. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  1840. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  1841. var nomEquipement = trim(link.firstChild.nodeValue);
  1842. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  1843. if(!enchanteur || enchanteur == '')
  1844. continue;
  1845. var infos = listeEquipementEnchantement[idEquipement];
  1846. infos=formateTexte(infos);
  1847. if(infos.length>0)
  1848. {
  1849. if(link.parentNode == link.nextSibling.parentNode)
  1850. {
  1851. var tmp = link.nextSibling;
  1852. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  1853. }
  1854. else
  1855. {
  1856. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  1857. }
  1858. }
  1859. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  1860. }
  1861. }
  1862. catch(e)
  1863. {
  1864. window.alert(e);
  1865. }
  1866. }
  1867.  
  1868. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  1869.  
  1870.  
  1871. // Les % de toucher
  1872. var c = new Array();
  1873.  
  1874. // coefficients binomiaux
  1875. function cnp(n,k)
  1876. {
  1877. if(c[n] != null && c[n][k] != null)
  1878. return c[n][k];
  1879. if(c[n] == null)
  1880. c[n] = new Array();
  1881. if(k==0)
  1882. {
  1883. c[n][k] = 1;
  1884. return 1;
  1885. }
  1886. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  1887. c[n][k] = result;
  1888. // Roule debug
  1889. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  1890. return result;
  1891. }
  1892.  
  1893. // by Dab, à comparer
  1894. function binom(n,p) {
  1895. if(p<0 || p>n) return 0;
  1896. if(c[n])
  1897. if(c[n][p]) return c[n][p];
  1898. else {
  1899. c[n]=[1];
  1900. c[n][n]=1;
  1901. if(p==0 || p==n) return 1;
  1902. }
  1903. if(2*p>n)
  1904. c[n][p]=binom(n,n-p);
  1905. else
  1906. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  1907. return c[n][p];
  1908. }
  1909.  
  1910. var coeff = new Array();
  1911.  
  1912. function coef(n,p)
  1913. {
  1914. if(n==0 && p==0)
  1915. return 1;
  1916. if(p>n*3.5)
  1917. p = 7*n-p
  1918. // roule désactive cache
  1919. if(coeff[n] != null && coeff[n][p] !=null)
  1920. return coeff[n][p];
  1921. if(coeff[n] == null)
  1922. coeff[n] = new Array();
  1923. var kmax = Math.floor((p-n)/6);
  1924. var x=0;
  1925. for(var k=0;k<=kmax;k++)
  1926. {
  1927. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  1928. }
  1929. coeff[n][p] = x;
  1930. // Roule debug
  1931. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  1932. return x;
  1933. }
  1934.  
  1935. function chanceEsquiveParfaite(a,d,ba,bd)
  1936. {
  1937. var win = 0;
  1938. var los = 0;
  1939. if(ba==null)
  1940. ba=0;
  1941. if(bd==null)
  1942. bd=0;
  1943. /* if(6*a+ba<2*(d+bd))
  1944. return 100;
  1945. if(a+ba>2*(6*d+bd))
  1946. return 0;*/
  1947. for(var ds=d;ds<=6*d;ds++)
  1948. {
  1949. var cd = coef(d,ds);
  1950. for(var as=a;as<=6*a;as++)
  1951. {
  1952. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  1953. win += cd * coef(a,as);
  1954. else
  1955. los += cd * coef(a,as);
  1956. }
  1957. }
  1958. // roule debug
  1959. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  1960. return Math.round(100*win/(win+los));
  1961. }
  1962.  
  1963. function chanceTouche(a,d,ba,bd)
  1964. {
  1965. var win = 0;
  1966. var los = 0;
  1967. if(ba==null)
  1968. ba=0;
  1969. if(bd==null)
  1970. bd=0;
  1971. if(a+ba>6*d+bd)
  1972. return 100;
  1973. if(6*a+ba<d+bd)
  1974. return 0;
  1975. for(var ds=d;ds<=6*d;ds++)
  1976. {
  1977. var cd = coef(d,ds);
  1978. for(var as=a;as<=6*a;as++)
  1979. {
  1980. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  1981. win += cd * coef(a,as);
  1982. else
  1983. los += cd * coef(a,as);
  1984. }
  1985. }
  1986. return Math.round(100*win/(win+los));
  1987. }
  1988.  
  1989. function chanceCritique(a,d,ba,bd)
  1990. {
  1991. var win = 0;
  1992. var los = 0;
  1993. if(ba==null)
  1994. ba=0;
  1995. if(bd==null)
  1996. bd=0;
  1997. if(a+ba>2*(6*d+bd))
  1998. return 100;
  1999. if(6*a+ba<2*(d+bd))
  2000. return 0;
  2001. for(var ds=d;ds<=6*d;ds++)
  2002. {
  2003. var cd = coef(d,ds);
  2004. for(var as=a;as<=6*a;as++)
  2005. {
  2006. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2007. win += cd * coef(a,as);
  2008. else
  2009. los += cd * coef(a,as);
  2010. }
  2011. }
  2012. return Math.round(100*win/(win+los));
  2013. }
  2014.  
  2015. /***********************************************
  2016. Analyse tactique
  2017. ***********************************************/
  2018.  
  2019. function getTexteAnalyse(modificateur,chiffre)
  2020. {
  2021. if(chiffre==0)
  2022. return chiffre;
  2023. return modificateur+chiffre;
  2024. }
  2025.  
  2026. function getAnalyseTactique(id,nom)
  2027. {
  2028. var donneesMonstre = listeCDM[id];
  2029. var needAutres=false;
  2030. var i;
  2031. if(donneesMonstre == null)
  2032. return;
  2033. var array = analyseTactique(donneesMonstre,nom);
  2034. if(array==null)
  2035. return "";
  2036. 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>";
  2037. for(i=0;i<array.length;i++)
  2038. {
  2039. if(array[i][1]==100 && i>0)
  2040. {
  2041. needAutres=true;
  2042. break;
  2043. }
  2044. if(i==1 && array[i][4]>0)
  2045. 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>";
  2046. else if(i==0)
  2047. 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>";
  2048. else
  2049. 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>";
  2050. }
  2051. if(needAutres)
  2052. {
  2053. if(i==array.length-1)
  2054. 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>";
  2055. else if(i==1)
  2056. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2057. else
  2058. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2059. }
  2060. return str+"</table>";
  2061. }
  2062.  
  2063. function analyseTactique(donneesMonstre,nom) {
  2064. try
  2065. {
  2066. var listeAttaques = [];
  2067. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2068. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2069. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2070. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2071. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2072. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2073. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2074. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2075. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2076. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2077. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2078. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2079. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2080. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2081. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2082. var modificateurEsquive = '';
  2083. var modificateurArmure = '';
  2084. var modificateurMagie = '';
  2085. var modificateurEsquiveM = '';
  2086. var modificateurArmureM = '';
  2087. var pasDeSR=false;
  2088. var esqM,attM,armM,degM;
  2089. 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)
  2090. return null;
  2091. var td = document.createElement('td')
  2092. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2093. var esqM = 0;
  2094. try
  2095. {
  2096. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2097. }
  2098. catch(e)
  2099. {
  2100. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2101. modificateurEsquive = '<';
  2102. modificateurArmure = '<';
  2103. modificateurMagie = '<';
  2104. }
  2105. td.innerHTML = bbcode(donneesMonstre[3]);
  2106. var attM = 0;
  2107. try
  2108. {
  2109. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2110. }
  2111. catch(e)
  2112. {
  2113. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2114. modificateurEsquiveM = '>';
  2115. modificateurArmureM = '>';
  2116. }
  2117. td.innerHTML = bbcode(donneesMonstre[5]);
  2118. var degM = 0;
  2119. try
  2120. {
  2121. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2122. }
  2123. catch(e)
  2124. {
  2125. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2126. modificateurArmureM = '>';
  2127. }
  2128. td.innerHTML = bbcode(donneesMonstre[7]);
  2129. var armM = 0;
  2130. try
  2131. {
  2132. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2133. }
  2134. catch(e)
  2135. {
  2136. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2137. modificateurArmure = '<';
  2138. }
  2139. var coeffSeuil = 0.95;
  2140. try
  2141. {
  2142. td.innerHTML = bbcode(donneesMonstre[9]);
  2143. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2144. var v = (rm / mm);
  2145. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2146. coeffSeuil = (200-seuil)/200;
  2147. }
  2148. catch(e)
  2149. {
  2150. modificateurMagie = '<';
  2151. pasDeSR = true;
  2152. }
  2153. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2154. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2155. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2156. // roule debug
  2157. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2158. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2159. 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);
  2160. //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);
  2161. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2162. if(getSortComp("Vampirisme")>0)
  2163. {
  2164. var pour = getSortComp("Vampirisme");
  2165. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2166. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2167. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2168. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2169. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2170. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2171. }
  2172. if(getSortComp("Botte Secrète")>0)
  2173. {
  2174. var pour = getSortComp("Botte Secrète");
  2175. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2176. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2177. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2178. 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;
  2179. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2180. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2181. }
  2182. if(getSortComp("Rafale Psychique")>0)
  2183. {
  2184. var pour = getSortComp("Rafale Psychique");
  2185. chanceDEsquiveParfaite = 0;
  2186. chanceDeTouche = Math.round(100*pour/100);
  2187. chanceDeCritique = Math.round(0*pour/100);
  2188. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2189. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2190. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2191. }
  2192. if(getSortComp("Explosion")>0)
  2193. {
  2194. var pour = getSortComp("Explosion");
  2195. chanceDEsquiveParfaite = 0;
  2196. chanceDeTouche = Math.round(100*pour/100);
  2197. chanceDeCritique = Math.round(0*pour/100);
  2198. 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;
  2199. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2200. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2201. }
  2202. if(getSortComp("Projectile Magique")>0)
  2203. {
  2204. var pour = getSortComp("Projectile Magique");
  2205. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2206. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2207. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2208. 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;
  2209. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2210. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2211. }
  2212. if(getSortComp("Frénésie")>0)
  2213. {
  2214. var pour = getSortComp("Frénésie");
  2215. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2216. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2217. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2218. 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;
  2219. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2220. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2221. }
  2222. if(getSortComp("Charger")>0)
  2223. {
  2224. var pour = getSortComp("Charger");
  2225. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2226. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2227. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2228. 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;
  2229. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2230. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2231. }
  2232. if(getSortComp("Griffe du Sorcier")>0)
  2233. {
  2234. var pour = getSortComp("Griffe du Sorcier");
  2235. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2236. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2237. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2238. 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;
  2239. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2240. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2241. }
  2242. if(getSortComp("Attaque Précise",1)>0)
  2243. {
  2244. var niveau = 5;
  2245. var oldPour = 0;
  2246. var chanceDEsquiveParfaite = 0;
  2247. var chanceDeTouche = 0;
  2248. var chanceDeCritique = 0;
  2249. degats = 0;
  2250. while(niveau>0)
  2251. {
  2252. var pour = getSortComp("Attaque Précise",niveau);
  2253. if(pour>oldPour)
  2254. {
  2255. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2256. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2257. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2258. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2259. chanceDeTouche += chanceDeToucheNiveau;
  2260. chanceDeCritique += chanceDeCritiqueNiveau;
  2261. 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);
  2262. oldPour = pour;
  2263. }
  2264. niveau--;
  2265. }
  2266. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2267. 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));
  2268. }
  2269. if(getSortComp("Coup de Butoir",1)>0)
  2270. {
  2271. var niveau = 5;
  2272. var oldPour =0;
  2273. var chanceDEsquiveParfaite = 0;
  2274. var chanceDeTouche=0;
  2275. var chanceDeCritique=0;
  2276. degats=0;
  2277. while(niveau>0)
  2278. {
  2279. var pour = getSortComp("Coup de Butoir",niveau);
  2280. if(pour>oldPour)
  2281. {
  2282. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2283. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2284. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2285. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2286. chanceDeTouche += chanceDeToucheNiveau;
  2287. chanceDeCritique += chanceDeCritiqueNiveau;
  2288. 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);
  2289. oldPour = pour;
  2290. }
  2291. niveau--;
  2292. }
  2293. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2294. 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));
  2295. }
  2296. 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;});
  2297. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2298. {
  2299. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2300. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2301. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2302. }
  2303. else
  2304. {
  2305. chanceDEsquiveParfaite = 0;
  2306. chanceDeTouche = 100;
  2307. chanceDeCritique = 0;
  2308. }
  2309. 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;
  2310.  
  2311. 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));
  2312. return listeAttaques;
  2313. }
  2314. catch(e) { window.alert(e);}
  2315. }
  2316.  
  2317. // x~~x marque pour s'y retrouver sous l'éditeur
  2318.  
  2319. /*
  2320. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2321. * published under GNU License v2.
  2322. *
  2323. * Patch :
  2324. * gestion des missions terminées
  2325. */
  2326. // x~x mission_liste
  2327.  
  2328. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2329. try {
  2330. var titresMimis = document.evaluate(
  2331. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2332. document, null, 7, null
  2333. );
  2334. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2335. } catch(e) {
  2336. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2337. return;
  2338. }
  2339. var enCours = {};
  2340. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2341. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2342. enCours[num] = true;
  2343. }
  2344. for(var numMimi in obMissions) {
  2345. if(!enCours[numMimi]) {
  2346. delete obMissions[numMimi];
  2347. }
  2348. }
  2349. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2350. }
  2351.  
  2352. function do_mission_liste() {
  2353. checkLesMimis();
  2354. }
  2355.  
  2356. /*******************************************************************************
  2357. * This file is part of Mountyzilla. *
  2358. * *
  2359. * Mountyzilla is free software; you can redistribute it and/or modify *
  2360. * it under the terms of the GNU General Public License as published by *
  2361. * the Free Software Foundation; either version 2 of the License, or *
  2362. * (at your option) any later version. *
  2363. * *
  2364. * Mountyzilla is distributed in the hope that it will be useful, *
  2365. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2366. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2367. * GNU General Public License for more details. *
  2368. * *
  2369. * You should have received a copy of the GNU General Public License *
  2370. * along with Mountyzilla; if not, write to the Free Software *
  2371. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2372. *******************************************************************************/
  2373.  
  2374. // x~x actions
  2375.  
  2376. /* TODO
  2377. * getLvl pour Explo, Rotobaffe et cie
  2378. */
  2379.  
  2380.  
  2381.  
  2382. /* Page de combat */
  2383.  
  2384. function getLevel() {
  2385. var divList = document.getElementsByTagName('div');
  2386. if(divList.length <= 2)
  2387. return;
  2388. // On essaie de voir si cette action était une attaque
  2389. var pList = document.getElementsByTagName('p');
  2390. var nomM = '';
  2391. // Modification pour Frénésie by TetDure
  2392. var numAtt = 0;
  2393. for (var i = 0; i < pList.length; i++) {
  2394. if(pList[i].firstChild) {
  2395. nomM = pList[i].firstChild.nodeValue;
  2396. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2397. numAtt++;
  2398. }
  2399. }
  2400. if(nomM == '')
  2401. return;
  2402. // Si c'est une attaque normale, un seul PX
  2403. var comPX = 1;
  2404. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2405. comPX++;
  2406.  
  2407. // Extraction des infos du monstre attaqué
  2408. var idM;
  2409. var male;
  2410. if(nomM.slice(20, 21) == 'e') {
  2411. male = false;
  2412. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2413. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2414. }
  2415. else {
  2416. male = true;
  2417. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2418. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2419. }
  2420. if(idM == '')
  2421. return;
  2422. var bList = document.getElementsByTagName('b');
  2423. var niveau = '';
  2424. for (var i = 0; i < bList.length; i++) {
  2425. var b = bList[i];
  2426. if(b.childNodes[0].nodeValue != "TUÉ")
  2427. continue;
  2428. var nbPX = "";
  2429. for (i++; i < bList.length; i++) {
  2430. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2431. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2432. return;
  2433. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2434. nbPX = bList[i].childNodes[0].nodeValue;
  2435. break;
  2436. }
  2437. }
  2438. if(nbPX == '')
  2439. return;
  2440. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2441. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2442. if(!nbPX)
  2443. nbPX = 0;
  2444. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2445. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2446. if(comPX > nbPX) {
  2447. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2448. niveau = "";
  2449. } else if(Math.floor(niveau) == niveau) {
  2450. chaine += niveau + ".";
  2451. } else {
  2452. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2453. niveau = "";
  2454. }
  2455. insertBr(b.nextSibling.nextSibling.nextSibling);
  2456. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2457. }
  2458.  
  2459. if(niveau != '') {
  2460. var button = insertButtonCdm('as_Action');
  2461. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2462. + escape(nomM) + "&niveau=" + escape(niveau)
  2463. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2464. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2465. }
  2466. }
  2467.  
  2468.  
  2469. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2470.  
  2471. function insertInfoMagie(node, intitule, magie) {
  2472. if(node.nextSibling) {
  2473. node = node.nextSibling;
  2474. insertBr(node);
  2475. insertText(node, intitule);
  2476. insertText(node, magie, true);
  2477. } else {
  2478. node = node.parentNode;
  2479. appendBr(node);
  2480. appendText(node, intitule);
  2481. appendText(node, magie, true);
  2482. }
  2483. }
  2484.  
  2485. function getMM(sr) {
  2486. if(rmTroll<=0) {
  2487. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2488. }
  2489. sr = Number(sr.match(/\d+/)[0]);
  2490. if(sr==10) {
  2491. return '\u2265 '+5*rmTroll;
  2492. }
  2493. if(sr<=50) {
  2494. return Math.round(50*rmTroll/sr);
  2495. }
  2496. if(sr<90) {
  2497. return Math.round((100-sr)*rmTroll/50);
  2498. }
  2499. return '\u2264 '+Math.round(rmTroll/5);
  2500. }
  2501.  
  2502. function traiteMM() {
  2503. var node = document.evaluate(
  2504. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2505. document, null, 9, null).singleNodeValue;
  2506. if(node) {
  2507. var mm = getMM(node.nodeValue);
  2508. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2509. } else {
  2510. var node = document.evaluate(
  2511. "//p/text()[contains(., 'Seuil de Résistance')]",
  2512. document, null, 9, null).singleNodeValue;
  2513. if(!node) {
  2514. return;
  2515. }
  2516. var mm = getMM(node.nodeValue);
  2517. node = node.nextSibling.nextSibling;
  2518. }
  2519. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2520. }
  2521.  
  2522. function getRM(sr) {
  2523. if(mmTroll<=0) {
  2524. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2525. }
  2526. sr = Number(sr.match(/\d+/)[0]);
  2527. if(sr==10) {
  2528. return '\u2264 '+Math.round(mmTroll/5);
  2529. }
  2530. if(sr<=50) {
  2531. return Math.round(sr*mmTroll/50);
  2532. }
  2533. if(sr<90) {
  2534. return Math.round(50*mmTroll/(100-sr));
  2535. }
  2536. return '\u2265 '+5*mmTroll;
  2537. }
  2538.  
  2539. function traiteRM() {
  2540. var nodes = document.evaluate(
  2541. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2542. document, null, 7, null);
  2543. if(nodes.snapshotLength==0) {
  2544. return;
  2545. }
  2546. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2547. var node = nodes.snapshotItem(i);
  2548. var rm = getRM(node.nodeValue);
  2549. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2550. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2551. }
  2552. }
  2553.  
  2554.  
  2555. /* Fonction stats IdT par Raistlin */
  2556. /*function getIdt() {
  2557. if(MY_getValue("SEND_IDT") == "non")
  2558. return false;
  2559. var regExpBeginning = /^\s+/;
  2560. var regExpEnd = /\s+$/;
  2561.  
  2562. var nomIdt = document.evaluate(
  2563. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2564. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2565. if(!nomIdt)
  2566. return false;
  2567.  
  2568. var caracIdt;
  2569. if(nomIdt.indexOf("Malédiction !") != -1) {
  2570. caracIdt = "";
  2571. nomIdt = "Mission maudite";
  2572. } else {
  2573. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2574. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2575. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2576. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2577. }
  2578. FF_XMLHttpRequest({
  2579. method: 'GET',
  2580. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2581. headers : {
  2582. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2583. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2584. }
  2585. });
  2586. return true;
  2587. }*/
  2588.  
  2589.  
  2590. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2591.  
  2592. function confirmeDecalage() {
  2593. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2594. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2595. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2596. var newDLA = new Date( oldDLA );
  2597. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2598. return window.confirm(
  2599. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2600. +'\nConfirmez-vous ce décalage ?'
  2601. );
  2602. }
  2603.  
  2604. function newsubmitDLA(evt) {
  2605. evt.stopPropagation();
  2606. evt.preventDefault();
  2607. if(confirmeDecalage()) {
  2608. this.submit();
  2609. }
  2610. }
  2611.  
  2612. function changeActionDecalage() {
  2613. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2614. return;
  2615. }
  2616. try {
  2617. // On récupère le contenu du script JS MH de calcul du décalage
  2618. var scriptTxt = document.evaluate(
  2619. ".//script[ not(@src) ]",
  2620. document, null, 9, null
  2621. ).singleNodeValue.textContent;
  2622. // On en extrait la DLA courante
  2623. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2624. scriptTxt = scriptTxt.split('\n')[0];
  2625. var nbs = scriptTxt.match(/\d+/g);
  2626. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2627. } catch(e) {
  2628. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2629. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  2630. return;
  2631. }
  2632. var form = document.getElementsByName('ActionForm')[0];
  2633. if(form) {
  2634. form.addEventListener('submit', newsubmitDLA, true);
  2635. } else {
  2636. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2637. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2638. }
  2639. }
  2640.  
  2641. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2642.  
  2643. function prochainMundi() {
  2644. try {
  2645. var node = document.evaluate(
  2646. "//div[@class='dateAction']/b",
  2647. document, null, 9, null
  2648. ).singleNodeValue;
  2649. } catch(e) {
  2650. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  2651. return;
  2652. }
  2653. if(!node) { return; }
  2654.  
  2655. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2656. var jour = longueurMois+1-getNumber(node.textContent);
  2657. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2658. var txt = '[Prochain Mundidey ';
  2659. if(jour>1) {
  2660. txt += 'dans '+jour+' jours]';
  2661. } else {
  2662. txt += 'demain]';
  2663. }
  2664. insertText(node.parentNode.nextSibling,txt,true);
  2665. }
  2666.  
  2667.  
  2668. /* Fonction principale */
  2669.  
  2670. function dispatch() {
  2671. if(isPage('MH_Play/Play_action')) {
  2672. prochainMundi();
  2673. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2674. var oldDLA;
  2675. changeActionDecalage();
  2676. } else if(isPage('MH_Play/Actions')) {
  2677. if(document.evaluate(
  2678. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  2679. document, null, 2, null
  2680. ).stringValue) {
  2681. traiteMM();
  2682. } else if(document.evaluate(
  2683. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  2684. document, null, 2, null
  2685. ).stringValue) {
  2686. //getIdt();
  2687. traiteRM();
  2688. } /*else {
  2689. // Est censé se lancer sur quoi *précisément* ?
  2690. traiteRM();
  2691. getLevel();
  2692. }*/
  2693. } else {
  2694. /* Traitement des messages du bot */
  2695. var messageTitle = document.evaluate(
  2696. "//form/table/tbody/tr[1]/td[1]/"
  2697. +"descendant::text()[contains(.,'[MountyHall]')]",
  2698. document, null, 2, null
  2699. ).stringValue;
  2700. if(messageTitle.indexOf('Attaquant') != -1 &&
  2701. messageTitle.indexOf('sur') != -1) {
  2702. getLevel();
  2703. traiteRM();
  2704. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  2705. messageTitle.indexOf('Défenseur') != -1) {
  2706. traiteMM();
  2707. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  2708. // à replacer avec Attaque après révision getLvl :
  2709. messageTitle.indexOf('Explosion') != -1 ||
  2710. messageTitle.indexOf('Insulte') != -1) {
  2711. traiteRM();
  2712. }
  2713. }
  2714. }
  2715.  
  2716. function do_actions() {
  2717. start_script(31);
  2718. dispatch();
  2719. displayScriptTime();
  2720. }
  2721.  
  2722. /*********************************************************************************
  2723. * This file is part of Mountyzilla. *
  2724. * *
  2725. * Mountyzilla is free software; you can redistribute it and/or modify *
  2726. * it under the terms of the GNU General Public License as published by *
  2727. * the Free Software Foundation; either version 2 of the License, or *
  2728. * (at your option) any later version. *
  2729. * *
  2730. * Mountyzilla is distributed in the hope that it will be useful, *
  2731. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2732. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2733. * GNU General Public License for more details. *
  2734. * *
  2735. * You should have received a copy of the GNU General Public License *
  2736. * along with Mountyzilla; if not, write to the Free Software *
  2737. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2738. *********************************************************************************/
  2739.  
  2740. // x~x pre-enchant
  2741.  
  2742. /* 2013-08-19 : correction auto syntaxe alert */
  2743.  
  2744. var combobox=null;
  2745.  
  2746. function changeObject()
  2747. {
  2748. if(!combobox)
  2749. return ;
  2750. var id = combobox.options[combobox.selectedIndex].value;
  2751. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  2752. if(!id || id=="")
  2753. {
  2754. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2755. return;
  2756. }
  2757. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  2758. }
  2759.  
  2760. function treatePreEnchantement() {
  2761. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2762. if(!input || input.getAttribute("type")=="hidden")
  2763. {
  2764. return false;
  2765. }
  2766. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  2767. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2768. if(!combobox)
  2769. {
  2770. return true;
  2771. }
  2772. combobox.addEventListener('change', changeObject, true);
  2773. return true;
  2774. }
  2775.  
  2776. function treateEnchantement() {
  2777. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2778. if(!input || input.getAttribute("type")!="hidden")
  2779. {
  2780. return false;
  2781. }
  2782. var idEquipement = input.getAttribute("value");
  2783. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  2784. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  2785. if(enchanteur && enchanteur != null)
  2786. return true;
  2787. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  2788. if(!input || input.getAttribute("type")!="hidden")
  2789. {
  2790. return false;
  2791. }
  2792. var idEnchanteur = input.getAttribute("value");
  2793. var nodes = document.evaluate(
  2794. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2795. if (nodes.snapshotLength != 3)
  2796. return;
  2797. for(var i=0;i<3;i++)
  2798. {
  2799. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2800. texte = texte.replace(" d'une "," d'un ");
  2801. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2802. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2803. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2804. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2805. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2806. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2807. }
  2808. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2809. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2810. var liste = MY_getValue(numTroll+".enchantement.liste");
  2811. if(!liste || liste=="")
  2812. {
  2813. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2814. }
  2815. else
  2816. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2817. }
  2818.  
  2819. function do_pre_enchant() {
  2820. start_script(60);
  2821. if(!treatePreEnchantement())
  2822. treateEnchantement();
  2823. displayScriptTime();
  2824. }
  2825.  
  2826. /*********************************************************************************
  2827. * This file is part of Mountyzilla. *
  2828. * *
  2829. * Mountyzilla is free software; you can redistribute it and/or modify *
  2830. * it under the terms of the GNU General Public License as published by *
  2831. * the Free Software Foundation; either version 2 of the License, or *
  2832. * (at your option) any later version. *
  2833. * *
  2834. * Mountyzilla is distributed in the hope that it will be useful, *
  2835. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2836. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2837. * GNU General Public License for more details. *
  2838. * *
  2839. * You should have received a copy of the GNU General Public License *
  2840. * along with Mountyzilla; if not, write to the Free Software *
  2841. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2842. *********************************************************************************/
  2843.  
  2844. // x~x enchant
  2845.  
  2846. /* 2013-08-19 : correction auto syntaxe alert */
  2847.  
  2848. function treateEnchantement() {
  2849. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  2850. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  2851. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  2852. return;
  2853. var tab = infoEquipement.split(";");
  2854. if(tab.length<2)
  2855. return;
  2856. var idEquipement = tab[0];
  2857. var nomEquipement = tab[1];
  2858. for(var i=2;i<tab.length;i++)
  2859. nomEquipement += ";"+tab[i];
  2860. var nodes = document.evaluate(
  2861. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  2862. if (nodes.snapshotLength != 3)
  2863. return;
  2864. for(var i=0;i<3;i++)
  2865. {
  2866. var texte = trim(nodes.snapshotItem(i).nodeValue);
  2867. texte = texte.replace(" d'une "," d'un ");
  2868. var compo = texte.substring(0,texte.indexOf(" d'un "));
  2869. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  2870. monstre = monstre.replace(/ Géante?/,"");
  2871. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  2872. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  2873. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  2874. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  2875. }
  2876. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  2877. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  2878. var liste = MY_getValue(numTroll+".enchantement.liste");
  2879. if(!liste || liste=="")
  2880. {
  2881. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  2882. }
  2883. else
  2884. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  2885. }
  2886.  
  2887. function do_enchant() {
  2888. start_script(60);
  2889.  
  2890. treateEnchantement();
  2891. MY_removeValue(numTroll+".enchantement.lastEquipement");
  2892. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  2893. displayScriptTime();
  2894. }
  2895.  
  2896. /*********************************************************************************
  2897. * This file is part of Mountyzilla. *
  2898. * *
  2899. * Mountyzilla is free software; you can redistribute it and/or modify *
  2900. * it under the terms of the GNU General Public License as published by *
  2901. * the Free Software Foundation; either version 2 of the License, or *
  2902. * (at your option) any later version. *
  2903. * *
  2904. * Mountyzilla is distributed in the hope that it will be useful, *
  2905. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2906. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2907. * GNU General Public License for more details. *
  2908. * *
  2909. * You should have received a copy of the GNU General Public License *
  2910. * along with Mountyzilla; if not, write to the Free Software *
  2911. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2912. *********************************************************************************/
  2913.  
  2914. // x~x myevent
  2915.  
  2916. // Script désactivé en attendant la màj vers le nouveau système de missions.
  2917. function do_myevent() {
  2918. }
  2919.  
  2920. /*********************************************************************************
  2921. * This file is part of Mountyzilla. *
  2922. * *
  2923. * Mountyzilla is free software; you can redistribute it and/or modify *
  2924. * it under the terms of the GNU General Public License as published by *
  2925. * the Free Software Foundation; either version 2 of the License, or *
  2926. * (at your option) any later version. *
  2927. * *
  2928. * Mountyzilla is distributed in the hope that it will be useful, *
  2929. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2930. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2931. * GNU General Public License for more details. *
  2932. * *
  2933. * You should have received a copy of the GNU General Public License *
  2934. * along with Mountyzilla; if not, write to the Free Software *
  2935. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2936. *********************************************************************************/
  2937.  
  2938. // x~x malus
  2939.  
  2940. /* v1.4 - 2014-01-06
  2941. * - Gestion des sorts double composante
  2942. * v1.4.1 - 2014-01-22
  2943. * - Correction décumul
  2944. * TODO
  2945. * - Identifier la position de "PV" dans l'ordre MH
  2946. */
  2947.  
  2948. var listeBM;
  2949.  
  2950.  
  2951. /* [functions] Utilitaires */
  2952.  
  2953. function decumul(bmt,nbr) {
  2954. var bmr;
  2955. if(!nbr || nbr<2) bmr = bmt;
  2956. else if(nbr==2) bmr = parseInt(0.67*bmt);
  2957. else if(nbr==3) bmr = parseInt(0.40*bmt);
  2958. else if(nbr==4) bmr = parseInt(0.25*bmt);
  2959. else if(nbr==5) bmr = parseInt(0.15*bmt);
  2960. else bmr = parseInt(0.1*bmt);
  2961. if(bmt<0) return Math.min(-1,bmr);
  2962. return Math.max(1,bmr);
  2963. }
  2964.  
  2965. function triecaracs(a,b) { // version Yoyor, mod by Dab
  2966. // Roule 23/11/2016 ajout PV
  2967. switch( a ) {
  2968. case 'ATT':
  2969. return -1;
  2970. case 'ESQ':
  2971. if(b=='ATT') return 1;
  2972. return -1;
  2973. case 'DEG':
  2974. switch( b ) {
  2975. case 'ATT':
  2976. case 'ESQ':
  2977. return 1;
  2978. default:
  2979. return -1;
  2980. }
  2981. case 'REG':
  2982. switch( b ) {
  2983. case 'ATT':
  2984. case 'ESQ':
  2985. case 'DEG':
  2986. return 1;
  2987. default:
  2988. return -1;
  2989. }
  2990. case 'Vue':
  2991. switch( b ) {
  2992. case 'ATT':
  2993. case 'ESQ':
  2994. case 'DEG':
  2995. case 'REG':
  2996. return 1;
  2997. default:
  2998. return -1;
  2999. }
  3000. case 'TOUR':
  3001. switch( b ) {
  3002. case 'ATT':
  3003. case 'ESQ':
  3004. case 'DEG':
  3005. case 'REG':
  3006. case 'Vue':
  3007. return 1;
  3008. default:
  3009. return -1;
  3010. }
  3011. case 'PV':
  3012. switch( b ) {
  3013. case 'ATT':
  3014. case 'ESQ':
  3015. case 'DEG':
  3016. case 'REG':
  3017. case 'Vue':
  3018. case 'TOUR':
  3019. return 1;
  3020. default:
  3021. return -1;
  3022. }
  3023. case 'Armure':
  3024. switch( b ) {
  3025. case 'ATT':
  3026. case 'ESQ':
  3027. case 'DEG':
  3028. case 'REG':
  3029. case 'Vue':
  3030. case 'TOUR':
  3031. case 'PV':
  3032. return 1;
  3033. default:
  3034. return -1;
  3035. }
  3036. case 'RM':
  3037. switch( b ) {
  3038. case 'ATT':
  3039. case 'ESQ':
  3040. case 'DEG':
  3041. case 'REG':
  3042. case 'Vue':
  3043. case 'TOUR':
  3044. case 'PV':
  3045. case 'Armure':
  3046. return 1;
  3047. default:
  3048. return -1;
  3049. }
  3050. case 'MM':
  3051. switch( b ) {
  3052. case 'ATT':
  3053. case 'ESQ':
  3054. case 'DEG':
  3055. case 'REG':
  3056. case 'Vue':
  3057. case 'TOUR':
  3058. case 'PV':
  3059. case 'Armure':
  3060. case 'RM':
  3061. return 1;
  3062. default:
  3063. return -1;
  3064. }
  3065. case 'Concentration':
  3066. switch( b ) {
  3067. case 'ATT':
  3068. case 'ESQ':
  3069. case 'DEG':
  3070. case 'REG':
  3071. case 'Vue':
  3072. case 'TOUR':
  3073. case 'PV':
  3074. case 'Armure':
  3075. case 'RM':
  3076. case 'MM':
  3077. return 1;
  3078. default:
  3079. return -1;
  3080. }
  3081. case 'Fatigue':
  3082. switch( b ) {
  3083. case 'ATT':
  3084. case 'ESQ':
  3085. case 'DEG':
  3086. case 'REG':
  3087. case 'Vue':
  3088. case 'TOUR':
  3089. case 'PV':
  3090. case 'Armure':
  3091. case 'RM':
  3092. case 'MM':
  3093. case 'Concentration':
  3094. return 1;
  3095. default:
  3096. return -1;
  3097. }
  3098. case "Dés d'attaque":
  3099. switch( b ) {
  3100. case 'ATT':
  3101. case 'ESQ':
  3102. case 'DEG':
  3103. case 'REG':
  3104. case 'Vue':
  3105. case 'TOUR':
  3106. case 'PV':
  3107. case 'Armure':
  3108. case 'RM':
  3109. case 'MM':
  3110. case 'Concentration':
  3111. case 'Fatigue':
  3112. return 1;
  3113. default:
  3114. return -1;
  3115. }
  3116. case 'Dés de dégâts':
  3117. switch( b ) {
  3118. case 'ATT':
  3119. case 'ESQ':
  3120. case 'DEG':
  3121. case 'REG':
  3122. case 'Vue':
  3123. case 'TOUR':
  3124. case 'PV':
  3125. case 'Armure':
  3126. case 'RM':
  3127. case 'MM':
  3128. case 'Concentration':
  3129. case 'Fatigue':
  3130. case "Dés d'attaque":
  3131. return 1;
  3132. default:
  3133. return -1;
  3134. }
  3135. default :
  3136. switch( b ) {
  3137. case 'ATT':
  3138. case 'ESQ':
  3139. case 'DEG':
  3140. case 'REG':
  3141. case 'Vue':
  3142. case 'TOUR':
  3143. case 'PV':
  3144. case 'Armure':
  3145. case 'RM':
  3146. case 'MM':
  3147. case 'Concentration':
  3148. case 'Fatigue':
  3149. case "Dés d'attaque":
  3150. case 'Dés de dégâts':
  3151. return 1;
  3152. default:
  3153. return -1;
  3154. }
  3155. }
  3156. }
  3157.  
  3158.  
  3159. /* [functions] Fonctions hide / display */
  3160.  
  3161. function toggleDetailsBM() {
  3162. if(MY_getValue('BMDETAIL')!='false') {
  3163. MY_setValue('BMDETAIL','false');
  3164. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3165. for(var i=0 ; i<trlist.length ; i++)
  3166. trlist[i].style.display = 'none';
  3167. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3168. for(var i=0 ; i<trlist.length ; i++)
  3169. trlist[i].style = '';
  3170. }
  3171. else {
  3172. MY_setValue('BMDETAIL','true');
  3173. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3174. for(var i=0 ; i<trlist.length ; i++)
  3175. trlist[i].style.display = 'none';
  3176. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3177. for(var i=0 ; i<trlist.length ; i++)
  3178. trlist[i].style = '';
  3179. }
  3180. }
  3181.  
  3182. function toggleBMList() {
  3183. if(MY_getValue('BMHIDELIST')=='true') {
  3184. MY_setValue('BMHIDELIST','false');
  3185. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3186. listeBM.snapshotItem(i).style = '';
  3187. document.getElementsByTagName('thead')[0].style = '';
  3188. document.getElementById('trhelp').style = '';
  3189. }
  3190. else {
  3191. MY_setValue('BMHIDELIST','true');
  3192. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3193. listeBM.snapshotItem(i).style.display = 'none';
  3194. document.getElementsByTagName('thead')[0].style.display = 'none';
  3195. document.getElementById('trhelp').style.display = 'none';
  3196. }
  3197. }
  3198.  
  3199. function setDisplayBM() {
  3200. if(!listeBM) return;
  3201. var titre = document.getElementById('titre2');
  3202. if(titre) {
  3203. titre.style.cursor = 'pointer';
  3204. titre.onclick = toggleBMList;
  3205. }
  3206. var tfoot = document.getElementsByTagName('tfoot')[0];
  3207. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3208. tfoot, null, 9, null).singleNodeValue;
  3209. tr.id = 'trhelp';
  3210. if(MY_getValue('BMHIDELIST')=='true') {
  3211. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3212. listeBM.snapshotItem(i).style.display = 'none';
  3213. document.getElementsByTagName('thead')[0].style.display = 'none';
  3214. tr.style.display = 'none';
  3215. }
  3216. }
  3217.  
  3218.  
  3219. /* [functions] Fonction principale */
  3220.  
  3221. function traiteMalus() {
  3222. var mainTab = document.getElementsByTagName('table')[0];
  3223. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3224. if(listeBM.snapshotLength==0) return;
  3225. /* Suppression des BM de fatigue stockés */
  3226. if(MY_getValue(numTroll+'.bm.fatigue'))
  3227. MY_removeValue(numTroll+'.bm.fatigue');
  3228. /* Extraction des données */
  3229. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3230. var nb = 0;
  3231. while(nb<listeBM.snapshotLength) {
  3232. tr = listeBM.snapshotItem(nb); nb++;
  3233. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3234. var phymag = tr.childNodes[9].textContent;
  3235. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3236. var type = tr.childNodes[3].textContent, nom;
  3237. // si c'est un type à décumul
  3238. /*
  3239. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3240. switch(type) {
  3241. case 'Potion':
  3242. case 'Parchemin':
  3243. case 'Sortilège':
  3244. case 'Capacité Spéciale':
  3245. nom = tr.childNodes[1].textContent+phymag;
  3246. break;
  3247. default:
  3248. nom = 'pasdedecumul';
  3249. }
  3250. */
  3251. nom = tr.childNodes[1].textContent+phymag;
  3252. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3253. nom = 'pasdedecumul';
  3254. uniListe[nb] = {
  3255. 'duree':duree,
  3256. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3257. 'caracs':{}
  3258. }
  3259. for(var i=0 ; i<effetsT.length ; i++) {
  3260. if(effetsT[i].indexOf(':')==-1) continue;
  3261. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3262. // nom = 'pasdedecumul' si pas de décumul
  3263. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3264. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3265. uniListe[nb]['type'] = phymag;
  3266. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3267. uniListe[nb]['caracs'][carac] = bm;
  3268. listeDurees[duree] = true;
  3269. }
  3270. } // fin boucle sur les lignes de bonus/malus
  3271. /* Gestion des décumuls et cumuls des durées */
  3272. var toursGeres = [];
  3273. for(var d in listeDurees) toursGeres.push(d);
  3274. toursGeres.sort( function (a,b){return b-a;} );
  3275. // pour sauvegarder les bm de fatigue
  3276. var strfat = '';
  3277. // Pour affichage & adpatation à footable.js (statique)
  3278. var thead = document.getElementsByTagName('thead')[0];
  3279. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3280. thead, null, 7, null).snapshotLength;
  3281. var tfoot = document.getElementsByTagName('tfoot')[0];
  3282. for(var i=0 ; i<toursGeres.length ; i++) {
  3283. var tour = toursGeres[i];
  3284. var effetsCeTour = {}; decumulsCeTour = {};
  3285. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3286. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3287. continue;
  3288. var nom = uniListe[nb]['nom'];
  3289. if(nom!='pasdedecumul') {
  3290. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3291. decumulsCeTour[nom]++;
  3292. }
  3293. for(var carac in uniListe[nb]['caracs']) {
  3294. var bm = uniListe[nb]['caracs'][carac];
  3295. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3296. var type = uniListe[nb]['type'];
  3297. if(!effetsCeTour[carac])
  3298. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3299. if(nom=='pasdedecumul')
  3300. effetsCeTour[carac][type] += bm;
  3301. else
  3302. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  3303. } else {
  3304. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3305. var thisBm;
  3306. if(nom=='pasdedecumul' || carac=='Fatigue')
  3307. thisBm = bm;
  3308. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3309. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3310. else
  3311. thisBm = decumul(bm,decumulsCeTour[nom]);
  3312. effetsCeTour[carac] += thisBm;
  3313. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3314. }
  3315. } // fin boucle sur les caractéristiques
  3316. } // fin boucle sur les bonus/malus
  3317. /* Création du bilan du tour */
  3318. var texteD = '', texteS = '';
  3319. var caracGerees = [];
  3320. for(var k in effetsCeTour) caracGerees.push(k);
  3321. caracGerees.sort( triecaracs );
  3322. for(var j=0 ; j<caracGerees.length ; j++) {
  3323. var carac = caracGerees[j], str = '';
  3324. switch( carac ) {
  3325. case 'ATT':
  3326. case 'DEG':
  3327. case 'Armure':
  3328. var phy = effetsCeTour[carac]['Physique'];
  3329. var mag = effetsCeTour[carac]['Magie'];
  3330. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3331. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3332. break;
  3333. case 'TOUR':
  3334. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3335. break;
  3336. case 'Fatigue':
  3337. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3338. case 'PV':
  3339. case 'ESQ':
  3340. case 'REG':
  3341. case 'Vue':
  3342. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3343. break;
  3344. default:
  3345. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3346. }
  3347. if(str) {
  3348. texteD += str;
  3349. texteS += str;
  3350. }
  3351. } // fin boucle sur les caractéristiques
  3352. /* Affichage */
  3353. // Si rien à afficher on passe
  3354. if(!texteD) continue;
  3355. // Si BMM+BMP=0
  3356. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3357. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3358. if(MY_getValue('BMDETAIL')=='false')
  3359. tr.style.display = 'none';
  3360. var td = appendTdText(tr,texteD.substring(3));
  3361. td.colSpan = 5-nbHidden;
  3362. var txttour = toursGeres[i]+' Tour';
  3363. if(toursGeres[i]>1) txttour += 's';
  3364. appendTdText(tr,txttour);
  3365. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3366. if(MY_getValue('BMDETAIL')!='false')
  3367. tr.style.display = 'none';
  3368. td = appendTdText(tr,texteS);
  3369. td.colSpan = 5-nbHidden;
  3370. appendTdText(tr,txttour);
  3371. } // fin boucle sur les tours générés
  3372. /* mise en place toggleDetails */
  3373. tfoot.style.cursor = 'pointer';
  3374. tfoot.onclick = toggleDetailsBM;
  3375. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3376. if(strfat)
  3377. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3378. }
  3379.  
  3380. function do_malus() {
  3381. try {
  3382. start_script();
  3383. traiteMalus();
  3384. setDisplayBM();
  3385. displayScriptTime();
  3386. }
  3387. catch(e) {window.alert(e)};
  3388. }
  3389.  
  3390. /*******************************************************************************
  3391. * This file is part of Mountyzilla. *
  3392. * *
  3393. * Mountyzilla is free software; you can redistribute it and/or modify *
  3394. * it under the terms of the GNU General Public License as published by *
  3395. * the Free Software Foundation; either version 2 of the License, or *
  3396. * (at your option) any later version. *
  3397. * *
  3398. * Mountyzilla is distributed in the hope that it will be useful, *
  3399. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3400. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3401. * GNU General Public License for more details. *
  3402. * *
  3403. * You should have received a copy of the GNU General Public License *
  3404. * along with Mountyzilla; if not, write to the Free Software *
  3405. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3406. *******************************************************************************/
  3407.  
  3408. // x~x mouches
  3409.  
  3410. var mainTab, tr_mouches;
  3411.  
  3412. function initialiseMouches() {
  3413. // Lanceur global
  3414. try {
  3415. mainTab = document.getElementById('mouches');
  3416. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3417. } catch(e) {
  3418. avertissement('Erreur MZ:<br />Consulter la console.');
  3419. window.console.error(traceStack(e, 'mouches'));
  3420. return;
  3421. }
  3422. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3423. setDisplayMouches();
  3424. traiteMouches();
  3425. }
  3426.  
  3427. function setDisplayMouches() {
  3428. // Initialise l'affichage / l'effacement du détail des mouches
  3429. var titre = document.getElementById('titre2');
  3430. if(titre) {
  3431. titre.style.cursor = 'pointer';
  3432. titre.onclick = toggleMouches;
  3433. }
  3434. var tfoot = document.getElementsByTagName('tfoot')[0];
  3435. if(tfoot) {
  3436. tfoot.style.cursor = 'pointer';
  3437. tfoot.onclick = toggleMouches;
  3438. }
  3439. if(MY_getValue('HIDEMOUCHES')=='true') {
  3440. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3441. tr_mouches.snapshotItem(i).style.display = 'none';
  3442. }
  3443. document.getElementsByTagName('thead')[0].style.display = 'none';
  3444. }
  3445. }
  3446.  
  3447. function toggleMouches() {
  3448. // Handler pour afficher / masquer les détasil
  3449. if(MY_getValue('HIDEMOUCHES')=='true') {
  3450. MY_setValue('HIDEMOUCHES','false');
  3451. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3452. tr_mouches.snapshotItem(i).style.display = '';
  3453. }
  3454. document.getElementsByTagName('thead')[0].style.display = '';
  3455. } else {
  3456. MY_setValue('HIDEMOUCHES','true');
  3457. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3458. tr_mouches.snapshotItem(i).style.display = 'none';
  3459. }
  3460. document.getElementsByTagName('thead')[0].style.display = 'none';
  3461. }
  3462. }
  3463.  
  3464. function traiteMouches() {
  3465. // Traitement complet: présence et effets des mouches
  3466. var listeTypes = {}, effetsActifs = {};
  3467. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3468. var tr = tr_mouches.snapshotItem(i);
  3469. // La mouche est-elle présente?
  3470. var etat = document.evaluate(
  3471. './img',
  3472. tr.cells[6], null, 9, null
  3473. ).singleNodeValue.alt;
  3474. if(etat!='La Mouche est là') { continue; }
  3475. // Extraction du type de mouche
  3476. var type = trim(tr.cells[3].textContent);
  3477. if(!listeTypes[type]) {
  3478. listeTypes[type] = 1;
  3479. } else {
  3480. listeTypes[type]++;
  3481. }
  3482. // La mouche a-t-elle un effet?
  3483. var effet = trim(tr.cells[2].textContent);
  3484. if(etat!='La Mouche est là' || !effet) { continue; }
  3485. // Si oui, extraction des effets (multiples pour pogées)
  3486. var caracs = effet.split(' | ');
  3487. for(var j=0 ; j<caracs.length ; j++) {
  3488. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3489. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3490. if(effetsActifs[carac]===void(0)) {
  3491. effetsActifs[carac] = valeur;
  3492. } else {
  3493. effetsActifs[carac] += valeur;
  3494. }
  3495. }
  3496. }
  3497. // Extraction Effet total et affichage des différences à la normale
  3498. var tfoot = document.getElementsByTagName('tfoot')[0];
  3499. if(!tfoot) { return; }
  3500. var nodeTotal = document.evaluate(
  3501. ".//b[contains(./text(),'Effet total')]",
  3502. tfoot, null, 9, null
  3503. ).singleNodeValue.nextSibling;
  3504. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3505. var texte = ' ';
  3506. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3507. if(texte.length>1) { texte += ' | '; }
  3508. var carac = trim(
  3509. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3510. );
  3511. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3512. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3513. texte += effetsTheoriques[i];
  3514. } else {
  3515. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3516. if(carac=='TOUR') { texte += ' min'; }
  3517. texte += '</b>';
  3518. }
  3519. }
  3520. var span = document.createElement('span');
  3521. span.innerHTML = texte;
  3522. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3523. // Affichage des différences du nombre de mouches de chaque type
  3524. var mouchesParType = document.evaluate(
  3525. "./tr/td/ul/li/text()",
  3526. tfoot, null, 7, null
  3527. );
  3528. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3529. var node = mouchesParType.snapshotItem(i);
  3530. var mots = node.nodeValue.split(' ');
  3531. var type = mots.pop();
  3532. if(!listeTypes[type]) {
  3533. node.nodeValue += ' (0 présente)';
  3534. } else if(mots[0]!=listeTypes[type]) {
  3535. if(listeTypes[type]==1) {
  3536. node.nodeValue += ' (1 présente)';
  3537. } else {
  3538. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3539. }
  3540. }
  3541. }
  3542. }
  3543.  
  3544. function do_mouches() {
  3545. start_script();
  3546. initialiseMouches();
  3547. displayScriptTime();
  3548. }
  3549.  
  3550. /*********************************************************************************
  3551. * This file is part of Mountyzilla. *
  3552. * *
  3553. * Mountyzilla is free software; you can redistribute it and/or modify *
  3554. * it under the terms of the GNU General Public License as published by *
  3555. * the Free Software Foundation; either version 2 of the License, or *
  3556. * (at your option) any later version. *
  3557. * *
  3558. * Mountyzilla is distributed in the hope that it will be useful, *
  3559. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3560. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3561. * GNU General Public License for more details. *
  3562. * *
  3563. * You should have received a copy of the GNU General Public License *
  3564. * along with Mountyzilla; if not, write to the Free Software *
  3565. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3566. *********************************************************************************/
  3567.  
  3568. // x~x equipgowap
  3569.  
  3570. var popup;
  3571.  
  3572. function initPopupEquipgowap() {
  3573. popup = document.createElement('div');
  3574. popup.setAttribute('id', 'popup');
  3575. popup.setAttribute('class', 'mh_textbox');
  3576. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3577. 'display: inline; z-index: 3; max-width: 400px;');
  3578. document.body.appendChild(popup);
  3579. }
  3580.  
  3581. function showPopupEquipgowap(evt) {
  3582. var texte = this.getAttribute("texteinfo");
  3583. popup.innerHTML = texte;
  3584. popup.style.left = evt.pageX + 15 + 'px';
  3585. popup.style.top = evt.pageY + 'px';
  3586. popup.style.visibility = "visible";
  3587. }
  3588.  
  3589. function hidePopup() {
  3590. popup.style.visibility = "hidden";
  3591. }
  3592.  
  3593. function createPopupImage(url, text)
  3594. {
  3595. var img = document.createElement('img');
  3596. img.setAttribute('src',url);
  3597. img.setAttribute('align','ABSMIDDLE');
  3598. img.setAttribute("texteinfo",text);
  3599. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3600. img.addEventListener("mouseout", hidePopup,true);
  3601. return img;
  3602. }
  3603.  
  3604. function formateTexte(texte)
  3605. {
  3606. texte = texte.replace(/\n/g,"<br/>");
  3607. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3608. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3609. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3610. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3611. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3612. return texte;
  3613. }
  3614.  
  3615.  
  3616. function treateGowaps() {
  3617. //On récupère les gowaps possédants des composants
  3618. var tbodys = document.evaluate(
  3619. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3620. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3621. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3622. var tbody = tbodys.snapshotItem(j);
  3623. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3624. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3625. if(MY_getValue("NOINFOEM") != "true")
  3626. insertEMInfos(tbody);
  3627. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3628. insertEnchantInfos(tbody);
  3629. }
  3630. }
  3631.  
  3632. function treateChampi() {
  3633. if(MY_getValue("NOINFOEM") == "true")
  3634. return false;
  3635. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3636. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3637. if (nodes.snapshotLength == 0)
  3638. return false;
  3639.  
  3640. for (var i = 0; i < nodes.snapshotLength; i++) {
  3641. var node = nodes.snapshotItem(i);
  3642. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3643. if(texte.indexOf("*")!=-1)
  3644. texte = texte.substring(0,texte.lastIndexOf(" "));
  3645. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3646. if(moisChampi[nomChampi])
  3647. {
  3648. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3649. }
  3650. }
  3651. }
  3652.  
  3653. function do_equipgowap() {
  3654. start_script();
  3655.  
  3656. treateGowaps();
  3657. treateChampi();
  3658. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3659. {
  3660. initPopupEquipgowap();
  3661. computeEnchantementEquipement(createPopupImage,formateTexte);
  3662. }
  3663.  
  3664. displayScriptTime();
  3665. }
  3666.  
  3667. /*********************************************************************************
  3668. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3669. *********************************************************************************/
  3670.  
  3671. // x~x ordresgowap
  3672.  
  3673. /* v0.2 by Dab - 2013-08-31
  3674. * - correction acquisition posale initiale
  3675. * - correction tare et affichage mire
  3676. */
  3677.  
  3678. function setCarteGogo() {
  3679. try {
  3680. //var pars = document.getElementsByTagName('p');
  3681. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3682. var eTitle = document.getElementById('titre2');
  3683. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  3684. var serv_img_trou = URL_MZimg + "carte_trou.png";
  3685. var serv_img_cible = URL_MZimg + "rep.png";
  3686.  
  3687. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  3688. //var lignes = pars[0].getElementsByTagName('tr');
  3689. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  3690. var nbpt = 0;
  3691. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  3692. for(var i=0 ; i<lignes.length ; i++) {
  3693. if(lignes[i].className == 'mh_tdpage_fo') {
  3694. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  3695. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  3696. if(point) {
  3697. nbpt++;
  3698. trajet += point[1]+','+point[2]+','+point[3]+',';
  3699. }
  3700. }
  3701. }
  3702. }
  3703. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  3704. 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'/>";
  3705. var base = [-229,-5];
  3706. if (nbpt>0) {
  3707. base = [-684,-5];
  3708. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  3709. }
  3710. 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;'/>";
  3711.  
  3712. 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>';
  3713.  
  3714. var nvspan = document.createElement('div');
  3715. nvspan.align = 'center';
  3716. nvspan.id = 'mz_mapdiv';
  3717. nvspan.valign = 'top';
  3718. nvspan.innerHTML = nvdiv;
  3719. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  3720. var footer = document.getElementById('footer1');
  3721. footer.parentNode.insertBefore(nvspan,footer);
  3722. }
  3723.  
  3724. function testeGlissiere() {
  3725. try {
  3726. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  3727. var footer = document.getElementById('footer1');
  3728. footer.parentNode.insertBefore(gliss.getElt(), footer);
  3729. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  3730. }
  3731.  
  3732. function do_ordresgowap() {
  3733. setCarteGogo(); // Via script des trouillots
  3734. if (isDEV) {
  3735. testeGlissiere();
  3736. }
  3737. }
  3738.  
  3739. /*********************************************************************************
  3740. * This file is part of Mountyzilla. *
  3741. * *
  3742. * Mountyzilla is free software; you can redistribute it and/or modify *
  3743. * it under the terms of the GNU General Public License as published by *
  3744. * the Free Software Foundation; either version 2 of the License, or *
  3745. * (at your option) any later version. *
  3746. * *
  3747. * Mountyzilla is distributed in the hope that it will be useful, *
  3748. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3749. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3750. * GNU General Public License for more details. *
  3751. * *
  3752. * You should have received a copy of the GNU General Public License *
  3753. * along with Mountyzilla; if not, write to the Free Software *
  3754. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3755. *********************************************************************************/
  3756.  
  3757. // x~x attaque
  3758.  
  3759. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3760.  
  3761. function do_attaque() {
  3762. }
  3763.  
  3764. /*******************************************************************************
  3765. * This file is part of Mountyzilla. *
  3766. * *
  3767. * Mountyzilla is free software; you can redistribute it and/or modify *
  3768. * it under the terms of the GNU General Public License as published by *
  3769. * the Free Software Foundation; either version 2 of the License, or *
  3770. * (at your option) any later version. *
  3771. * *
  3772. * Mountyzilla is distributed in the hope that it will be useful, *
  3773. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3774. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3775. * GNU General Public License for more details. *
  3776. * *
  3777. * You should have received a copy of the GNU General Public License *
  3778. * along with Mountyzilla; if not, write to the Free Software *
  3779. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3780. *******************************************************************************/
  3781.  
  3782. // x~x infomonstre
  3783.  
  3784. // DEBUG
  3785. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  3786. // À corriger, évidemment.
  3787. var listeCDM = {};
  3788. var nomMonstre='';
  3789. var idMonstre=-1;
  3790. var tbody;
  3791. var popup;
  3792.  
  3793. function traiteMonstre() {
  3794. try {
  3795. var nodeTitre = document.evaluate(
  3796. "//div[@class='titre2' and contains(text(),'(')]",
  3797. document, null, 9, null
  3798. ).singleNodeValue;
  3799. var texte = nodeTitre.firstChild.nodeValue;
  3800. } catch(e) {
  3801. window.console.log(traceStack(e, 'traiteMonstre'));
  3802. return;
  3803. }
  3804. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  3805. if(nomMonstre.indexOf(']')!=-1) {
  3806. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  3807. }
  3808. idMonstre = texte.match(/\d+/)[0];
  3809. FF_XMLHttpRequest({
  3810. method: 'GET',
  3811. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  3812. +MY_getValue('CDMID')
  3813. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  3814. headers : {
  3815. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3816. 'Accept': 'application/atom+xml,application/xml,text/xml'
  3817. },
  3818. onload: function(responseDetails) {
  3819. try {
  3820. var texte = responseDetails.responseText;
  3821. var lines = texte.split("\n");
  3822. if(lines.length>=1) {
  3823. var infos = lines[0].split(";");
  3824. if(infos.length<4) { return; }
  3825. var idMonstre = infos[0];
  3826. infos=infos.slice(3);
  3827. listeCDM[idMonstre]=infos;
  3828. computeMissionInfomonstre();
  3829. }
  3830. } catch(e) {
  3831. window.alert(e);
  3832. }
  3833. }
  3834. });
  3835. }
  3836.  
  3837. function initPopupInfomonstre() {
  3838. // Initialise le popup tactique (calculs att/deg)
  3839. popup = document.createElement('div');
  3840. popup.id = 'popup';
  3841. popup.className = 'mh_textbox';
  3842. popup.style =
  3843. 'position: absolute;'+
  3844. 'border: 1px solid #000000;'+
  3845. 'visibility: hidden;'+
  3846. 'display: inline;'+
  3847. 'z-index: 3;'+
  3848. 'max-width: 400px;';
  3849. document.body.appendChild(popup);
  3850. }
  3851.  
  3852. function showPopupTactique(evt) {
  3853. try {
  3854. var id = this.id;
  3855. var nom = this.nom;
  3856. var texte = getAnalyseTactique(id,nom);
  3857. if(texte=='') { return; }
  3858. popup.innerHTML = texte;
  3859. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  3860. if(isPage("View/MonsterView")) {
  3861. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  3862. } else {
  3863. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  3864. }
  3865. popup.style.top = evt.pageY+15+'px';
  3866. popup.style.visibility = 'visible';
  3867. } catch(e) {
  3868. window.alert(e);
  3869. }
  3870. }
  3871.  
  3872. // roule 16/03/2016, existe déjà ailleurs
  3873. // function hidePopup() {
  3874. // popup.style.visibility = 'hidden';
  3875. // }
  3876.  
  3877. function toggleTableau() {
  3878. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  3879. }
  3880.  
  3881. function computeMissionInfomonstre() {
  3882. // C'est quoi ce titre de fonction ? (O_o)
  3883. try {
  3884. var nodeInsert = document.evaluate(
  3885. "//div[@class = 'titre3']",
  3886. document, null, 9, null
  3887. ).singleNodeValue;
  3888. } catch(e) {
  3889. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  3890. return;
  3891. }
  3892. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  3893. table.align = 'center';
  3894. tbody = table.childNodes[1];
  3895. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  3896. table.firstChild.firstChild.onmouseover = function() {
  3897. this.style.cursor = 'pointer';
  3898. this.className = 'mh_tdpage';
  3899. };
  3900. table.firstChild.firstChild.onmouseout = function() {
  3901. this.className = 'mh_tdtitre';
  3902. };
  3903. tbody.style.display = 'none';
  3904. table.style.width = '350px';
  3905. insertBefore(nodeInsert,table);
  3906. }
  3907.  
  3908. function do_infomonstre() {
  3909. start_script();
  3910. try {
  3911. initPopupInfomonstre();
  3912. traiteMonstre();
  3913. } catch(e) {
  3914. window.alert('Erreur infoMonstre:\n'+e);
  3915. }
  3916. displayScriptTime();
  3917. }
  3918.  
  3919. /*******************************************************************************
  3920. * This file is part of Mountyzilla. *
  3921. * *
  3922. * Mountyzilla is free software; you can redistribute it and/or modify *
  3923. * it under the terms of the GNU General Public License as published by *
  3924. * the Free Software Foundation; either version 2 of the License, or *
  3925. * (at your option) any later version. *
  3926. * *
  3927. * Mountyzilla is distributed in the hope that it will be useful, *
  3928. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3929. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3930. * GNU General Public License for more details. *
  3931. * *
  3932. * You should have received a copy of the GNU General Public License *
  3933. * along with Mountyzilla; if not, write to the Free Software *
  3934. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3935. *******************************************************************************/
  3936.  
  3937. // x~x mission
  3938.  
  3939. /* TODO
  3940. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  3941. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  3942. *
  3943. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  3944. */
  3945.  
  3946. function saveMission(num,obEtape) {
  3947. var obMissions = {};
  3948. if(MY_getValue(numTroll+'.MISSIONS')) {
  3949. try {
  3950. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  3951. } catch(e) {
  3952. window.console.error(traceStack(e, 'Mission parsage'));
  3953. return;
  3954. }
  3955. }
  3956. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  3957. if(obEtape) {
  3958. obMissions[num] = obEtape;
  3959. } else if(obMissions[num]) {
  3960. delete obMissions[num];
  3961. }
  3962. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  3963. }
  3964.  
  3965. function addtroogle(tdLibelle, sRestrict) {
  3966. var img = document.createElement('img');
  3967. img.src = URL_MZimg + 'troogle.ico';
  3968. img.alt = 'Troogle logo';
  3969. var a = document.createElement('a');
  3970. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  3971. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  3972. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  3973. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  3974. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  3975. a.href = url;
  3976. a.title = 'Chercher sur Troogle';
  3977. a.target = 'troogle';
  3978. a.appendChild(img);
  3979. tdLibelle.appendChild(a);
  3980. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  3981. }
  3982.  
  3983. function traiteMission() {
  3984. try {
  3985. var titreMission = document.getElementsByClassName('titre2')[0];
  3986. var numMission = titreMission.textContent.match(/\d+/)[0];
  3987. var missionForm = document.getElementsByName('ActionForm')[0];
  3988. var tdLibelle = document.evaluate(
  3989. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  3990. missionForm, null, 9, null).singleNodeValue;
  3991. } catch(e) {
  3992. window.console.error(traceStack(e, 'récupération mission'));
  3993. return;
  3994. }
  3995. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  3996. try {
  3997. if(!tdLibelle) {
  3998. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  3999. debugMZ('traiteMission, la mission semble terminée');
  4000. saveMission(numMission,false);
  4001. return;
  4002. }
  4003.  
  4004. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4005. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4006. // debug Roule'
  4007. if (MY_DEBUG) {
  4008. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4009. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4010. }
  4011. if(libelle.indexOf('niveau égal à')!=-1) {
  4012. var nbKills = 1, niveau, mod;
  4013. // exemples :
  4014. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4015. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4016. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4017. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4018. if (tdLibelle.childNodes.length == 1) {
  4019. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4020. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4021. if (m) {
  4022. niveau = Number(m[1]);
  4023. mod = 'plus'
  4024. } else {
  4025. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4026. if (m) {
  4027. niveau = Number(m[1]);
  4028. mod = Number(m[2]);
  4029. } else {
  4030. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4031. return;
  4032. }
  4033. }
  4034. } else {
  4035. // ancienne méthode (multi childnode)
  4036. // à supprimer un jour peut-être
  4037. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4038. // Étape de kill multiple de niveau donné
  4039. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4040. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4041. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4042. niveau = Number(mod[0]);
  4043. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4044. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4045. } else {
  4046. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4047. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4048. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4049. mod = mod ? Number(mod[0]) : 'plus';
  4050. }
  4051. } else {
  4052. // Étape de kill unique de niveau donné
  4053. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4054. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4055. mod = mod ? Number(mod[0]) : 'plus';
  4056. }
  4057. }
  4058. // debug Roule'
  4059. if (MY_DEBUG) {
  4060. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4061. }
  4062. saveMission(numMission,{
  4063. type: 'Niveau',
  4064. niveau: niveau,
  4065. mod: mod,
  4066. mundidey: siMundidey,
  4067. libelle: libelle
  4068. });
  4069. if (mod == 'plus')
  4070. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4071. else
  4072. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4073. } else if(libelle.indexOf('de la race')!=-1) {
  4074. var nbKills = 1, race;
  4075. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4076. // Étape de kill multiple de race donnée
  4077. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4078. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4079. } else {
  4080. // Étape de kill unique de race donnée
  4081. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4082. }
  4083. race = race.replace(/\"/g,'');
  4084. saveMission(numMission,{
  4085. type: 'Race',
  4086. race: race,
  4087. mundidey: siMundidey,
  4088. libelle: libelle
  4089. });
  4090. addtroogle(tdLibelle, '@monstre ' + race);
  4091. } else if(libelle.indexOf('de la famille')!=-1) {
  4092. var nbKills = 1, famille;
  4093. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4094. // Étape de kill multiple de famille donnée
  4095. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4096. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4097. } else {
  4098. // Étape de kill unique de famille donnée
  4099. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4100. }
  4101. famille = famille.replace(/\"/g,'');
  4102. saveMission(numMission,{
  4103. type: 'Famille',
  4104. famille: famille,
  4105. mundidey: siMundidey,
  4106. libelle: libelle
  4107. });
  4108. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4109. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4110. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4111. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4112. debugMZ('traiteMission étape capacité spéciale');
  4113. saveMission(numMission,{
  4114. type: 'Pouvoir',
  4115. pouvoir: pouvoir,
  4116. libelle: libelle
  4117. });
  4118. } else {
  4119. debugMZ('traiteMission étape pas pour troogle');
  4120. saveMission(numMission,false);
  4121. }
  4122. } catch(e) {
  4123. window.console.error(traceStack(e, 'récupération étape mission'));
  4124. return;
  4125. }
  4126. }
  4127.  
  4128. function do_mission() {
  4129. start_script(60);
  4130.  
  4131. traiteMission();
  4132.  
  4133. displayScriptTime();
  4134. }
  4135.  
  4136. /*******************************************************************************
  4137. * This file is part of Mountyzilla. *
  4138. * *
  4139. * Mountyzilla is free software; you can redistribute it and/or modify *
  4140. * it under the terms of the GNU General Public License as published by *
  4141. * the Free Software Foundation; either version 2 of the License, or *
  4142. * (at your option) any later version. *
  4143. * *
  4144. * Mountyzilla is distributed in the hope that it will be useful, *
  4145. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4146. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4147. * GNU General Public License for more details. *
  4148. * *
  4149. * You should have received a copy of the GNU General Public License *
  4150. * along with Mountyzilla; if not, write to the Free Software *
  4151. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4152. *******************************************************************************/
  4153.  
  4154. // x~x move
  4155.  
  4156. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4157.  
  4158. var petitsTrous = {
  4159. '-52;57': true,
  4160. '55;70': true,
  4161. '64;70': true,
  4162. '12;-15': true,
  4163. '30;-52': true,
  4164. '48;-39': true
  4165. };
  4166.  
  4167. var grosTrous = {
  4168. '-35;65': true,
  4169. '-13;73': true,
  4170. '-64;9': true,
  4171. '-35;15': true,
  4172. '5;32': true,
  4173. '10;64': true,
  4174. '21;36': true,
  4175. '46;52': true,
  4176. '74;32': true,
  4177. '-71;-7': true,
  4178. '-67;-37': true,
  4179. '-60;-32': true,
  4180. '-51;-22': true,
  4181. '-36;-51': true,
  4182. '5;-49': true
  4183. };
  4184.  
  4185. var centreCarmine_X = 56.5;
  4186. var centreCarmine_Y = 23.5;
  4187. var rayonCarmine = 8.7;
  4188.  
  4189. function isTrou(x,y,n) {
  4190. if(petitsTrous[x+';'+y]) {
  4191. return n<0 && n>-60;
  4192. }
  4193. if(grosTrous[x+';'+y]
  4194. || grosTrous[x-1+';'+y]
  4195. || grosTrous[x+';'+y+1]
  4196. || grosTrous[x-1+';'+y+1]) {
  4197. return n<0 && n>-70;
  4198. }
  4199. if(Math.sqrt(
  4200. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4201. )<=rayonCarmine) {
  4202. return n<0 && n>-100;
  4203. }
  4204. return false;
  4205. }
  4206.  
  4207. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4208.  
  4209. function validateDestination() {
  4210. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4211. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4212. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4213. var form = document.getElementsByName('ActionForm')[0];
  4214. if(form) {
  4215. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4216. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4217. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4218. }
  4219. }
  4220. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4221. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4222. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4223. }
  4224. }
  4225. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4226. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4227. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4228. }
  4229. }
  4230. if(isTrou(x,y,n)) {
  4231. return window.confirm(
  4232. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4233. +'Vous allez tomber dans un trou de météorite.\n'
  4234. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4235. );
  4236. }
  4237. }
  4238. return true;
  4239. }
  4240.  
  4241. function newsubmitDE(event) {
  4242. event.stopPropagation();
  4243. event.preventDefault();
  4244. if(validateDestination()) {
  4245. this.submit();
  4246. }
  4247. }
  4248.  
  4249. function changeValidation() {
  4250. var form = document.getElementsByName('ActionForm')[0];
  4251. if(form) {
  4252. form.addEventListener('submit', newsubmitDE, true);
  4253. }
  4254. }
  4255.  
  4256.  
  4257. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4258.  
  4259. function validateTPDestination() {
  4260. try {
  4261. var text = document.getElementsByTagName('B')[0];
  4262. var a = text.firstChild.nodeValue.split('|');
  4263. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4264. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4265. var pos_n = a[2].substring(5, a[2].length) * 1;
  4266.  
  4267. var nbtrous = 0;
  4268. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4269. for(var x=0 ; x<=2 ; x++) {
  4270. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4271. for(var y=0 ; y<=2 ; y++) {
  4272. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4273. for(var n = 0 ; n <= 1 ; n++) {
  4274. if(isTrou(
  4275. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4276. )) {
  4277. nbtrous++;
  4278. }
  4279. }
  4280. }
  4281. }
  4282. }
  4283. }
  4284. }
  4285. if(nbtrous>0 && nbtrous<72) {
  4286. return window.confirm(
  4287. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4288. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4289. +'% de risque de tomber dans un trou de météorite.\n'
  4290. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4291. );
  4292. }
  4293. else if(nbtrous>=72) {
  4294. return window.confirm(
  4295. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4296. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4297. +'% de risque de tomber dans un trou de météorite !\n'
  4298. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4299. );
  4300. }
  4301. return true;
  4302. }
  4303. catch(e) {
  4304. window.alert(e)
  4305. }
  4306. }
  4307.  
  4308. function newsubmitTP(event) {
  4309. event.stopPropagation();
  4310. event.preventDefault();
  4311. if(validateTPDestination()) {
  4312. this.submit();
  4313. }
  4314. }
  4315.  
  4316. function changeButtonValidate() {
  4317. var form = document.getElementsByName('Formulaire')[0];
  4318. if(form) {
  4319. if(!form.getAttribute('onsubmit')) {
  4320. form.setAttribute('onsubmit','return true;');
  4321. }
  4322. form.addEventListener('submit', newsubmitTP, true);
  4323. }
  4324. }
  4325.  
  4326.  
  4327. /*-[functions]---------------- Partie Principale -----------------------------*/
  4328.  
  4329. function do_move() {
  4330. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4331. changeValidation();
  4332. }
  4333. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4334. changeButtonValidate();
  4335. }
  4336. }
  4337.  
  4338. /*******************************************************************************
  4339. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4340. * Mountyzilla is free software; provided under the GNU General Public License *
  4341. *******************************************************************************/
  4342.  
  4343. // x~x news
  4344.  
  4345. // Nombre de news à afficher & nb max de caractères par news:
  4346. const nbItems = 5;
  4347. const maxCarDescription = 300;
  4348.  
  4349. /*-[functions]------------------- Utilitaires --------------------------------*/
  4350.  
  4351. // Ne semble avoir strictement aucun effet:
  4352. String.prototype.epureDescription = function() {
  4353. return this.replace(/\\(.)/g,"$1");
  4354. }
  4355.  
  4356. function appendTitledTable(node,titre,description) {
  4357. // Crée les tables contenant les infos (avec titre)
  4358. var table = document.createElement('table');
  4359. table.border = 0;
  4360. table.className = 'mh_tdborder';
  4361. table.cellSpacing = 1;
  4362. table.cellPadding = 1;
  4363. table.style.maxWidth = '98%';
  4364. table.style.marginLeft = 'auto';
  4365. table.style.marginRight = 'auto';
  4366. var tbody = document.createElement('tbody');
  4367. table.appendChild(tbody);
  4368. var tr = appendTr(tbody,'mh_tdtitre');
  4369. var td = appendTdCenter(tr,2);
  4370. var span = document.createElement('span');
  4371. appendText(span,titre,true);
  4372. if(description) {
  4373. span.title = description;
  4374. }
  4375. td.appendChild(span);
  4376. node.appendChild(table);
  4377. return tbody;
  4378. }
  4379.  
  4380. function testCertif(paramURL, callbackOnError) {
  4381. try {
  4382. FF_XMLHttpRequest({
  4383. method: 'GET',
  4384. url: paramURL,
  4385. onload: function(responseDetails) {
  4386. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4387. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4388. }
  4389. });
  4390. } catch(e) {
  4391. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4392. callbackOnError();
  4393. }
  4394. }
  4395.  
  4396. function createOrGetGrandCadre() {
  4397. var grandCadre = document.getElementById('grandCadre');
  4398. if (grandCadre) return grandCadre;
  4399. try {
  4400. var rappels = document.evaluate(
  4401. "//p[contains(a/text(),'messagerie')]",
  4402. document, null, 9, null).singleNodeValue;
  4403. }
  4404. catch(e) {
  4405. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4406. grandCadre = document.createElement('div');
  4407. return grandCadre;
  4408. }
  4409. grandCadre = document.createElement('div');
  4410. grandCadre.id = 'grandCadre';
  4411. var sousCadre = document.createElement('div');
  4412. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4413. sousCadre.style.textAlign = 'center';
  4414. sousCadre.style.fontSize = 'xx-large';
  4415. grandCadre.appendChild(sousCadre);
  4416.  
  4417. grandCadre.style.border = 'solid 5px red';
  4418. grandCadre.style.width = 'auto';
  4419. insertBefore(rappels,grandCadre);
  4420. return grandCadre;
  4421. }
  4422.  
  4423. function showHttpsErrorCadre1() {
  4424. var grandCadre = createOrGetGrandCadre();
  4425. var sousCadre = document.createElement('div');
  4426. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4427. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4428. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4429. + URL_CertifRaistlin1
  4430. + '" target="raistlin">clique ici</a>'
  4431. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4432. + ' « Confirmer l\'exception de sécurité »'
  4433. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4434. sousCadre.style.width = 'auto';
  4435. sousCadre.style.fontSize = 'large';
  4436. sousCadre.style.border = 'solid 1px black';
  4437. sousCadre.style.backgroundColor = 'red';
  4438. grandCadre.appendChild(sousCadre);
  4439. }
  4440.  
  4441. function showHttpsErrorCadre2() {
  4442. var grandCadre = createOrGetGrandCadre();
  4443. var sousCadre = document.createElement('div');
  4444. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  4445. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  4446. + '<a style="color:blue;font-size: inherits;" href="'
  4447. + URL_CertifRaistlin2
  4448. + '" target="raistlin">clique ici</a>'
  4449. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4450. + ' « Confirmer l\'exception de sécurité »'
  4451. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  4452. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4453. sousCadre.style.width = 'auto';
  4454. sousCadre.style.fontSize = 'large';
  4455. sousCadre.style.border = 'solid 1px black';
  4456. sousCadre.style.backgroundColor = 'red';
  4457. grandCadre.appendChild(sousCadre);
  4458. }
  4459.  
  4460. function showHttpsErrorContenuMixte() {
  4461. var grandCadre = createOrGetGrandCadre();
  4462. var sousCadre = document.createElement('div');
  4463. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  4464. + '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)'
  4465. + '<ul>'
  4466. + '<li>Interface Bricol\'Troll</li>'
  4467. + '<li>Nouveautés de Mountyzilla</li>'
  4468. + '</ul>'
  4469. + '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 />'
  4470. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  4471. sousCadre.style.width = 'auto';
  4472. sousCadre.style.fontSize = 'large';
  4473. sousCadre.style.border = 'solid 1px black';
  4474. grandCadre.appendChild(sousCadre);
  4475. }
  4476.  
  4477. /*-[functions]------------------- Jubilaires ---------------------------------*/
  4478.  
  4479. function traiterJubilaires() {
  4480. // à faire
  4481. }
  4482.  
  4483. function traiterJubilaires_a_supprimer() { // ancienne méthode
  4484. try {
  4485. FF_XMLHttpRequest({
  4486. method: 'GET',
  4487. url: URL_anniv,
  4488. headers: {
  4489. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4490. 'Accept': 'application/xml,text/xml',
  4491. },
  4492. onload: function(responseDetails) {
  4493. if ((responseDetails.status == 0) && isHTTPS) {
  4494. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  4495. showHttpsErrorContenuMixte();
  4496. return;
  4497. }
  4498. var listeTrolls = responseDetails.responseText.split('\n');
  4499. if(!listeTrolls || listeTrolls.length==0) {
  4500. return;
  4501. }
  4502. afficherJubilaires(listeTrolls);
  4503. },
  4504. });
  4505. }
  4506. catch(e) {
  4507. if (isHTTPS) {
  4508. window.console.log(traceStack(e, 'appel jubilaires'));
  4509. showHttpsErrorContenuMixte();
  4510. } else {
  4511. window.alert('Erreur Jubilaires:\n'+e);
  4512. }
  4513. }
  4514. }
  4515.  
  4516. function afficherJubilaires(listeTrolls) {
  4517. try {
  4518. var rappels = document.evaluate(
  4519. "//p[contains(a/text(),'messagerie')]",
  4520. document, null, 9, null).singleNodeValue;
  4521. }
  4522. catch(e) {
  4523. return;
  4524. }
  4525. var p = document.createElement('p');
  4526. var tbody = appendTitledTable(p,
  4527. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  4528. 'Envoyez leur un message ou un cadeau !'
  4529. );
  4530. tr = appendTr(tbody,'mh_tdpage');
  4531. td = appendTdCenter(tr);
  4532. var small = document.createElement('small');
  4533. td.appendChild(small);
  4534. var first = true;
  4535. for(var i=0 ; i<listeTrolls.length ; i++) {
  4536. var infos = listeTrolls[i].split(';');
  4537. if(infos.length!=3 || infos[2]==='0') {
  4538. continue;
  4539. }
  4540. if(first) {
  4541. first = false;
  4542. }
  4543. else {
  4544. appendText(small,', ');
  4545. }
  4546. var a = document.createElement('a');
  4547. a.href = 'javascript:EPV('+infos[0]+')';
  4548. appendText(a,infos[1]);
  4549. small.appendChild(a);
  4550. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  4551. }
  4552. insertBefore(rappels,p);
  4553. }
  4554.  
  4555.  
  4556. /*-[functions]--------------------- News MZ ----------------------------------*/
  4557.  
  4558. function traiterNouvelles() {
  4559. var news = new Array;
  4560. 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 ;).']);
  4561. news.push(['24/12/2016', 'Retour de la carte montrant les déplacements des Gowaps']);
  4562. news.push(['24/12/2016', 'Le lien avec Bricol\'Troll est maintenant disponible en https']);
  4563. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  4564. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  4565. afficherNouvelles(news);
  4566. }
  4567.  
  4568. function afficherNouvelles(items) {
  4569. var footer = document.getElementById('footer1');
  4570. if(!footer) {
  4571. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  4572. return;
  4573. }
  4574. var p = document.createElement('p');
  4575. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  4576. for(var i=0 ; i<items.length ; i++) {
  4577. var tr = appendTr(tbody,'mh_tdpage');
  4578. var td = appendTdCenter(tr);
  4579. td.style.verticalAlign = 'top'; // semble sans effet
  4580. appendText(td,items[i][0],true);
  4581. td = appendTd(tr);
  4582. td.innerHTML = items[i][1];
  4583. }
  4584. insertBefore(footer,p);
  4585. }
  4586.  
  4587.  
  4588. /*---------------------------------- Main ------------------------------------*/
  4589.  
  4590. function do_news() {
  4591. start_script();
  4592.  
  4593. traiterJubilaires();
  4594. traiterNouvelles();
  4595.  
  4596. if (isHTTPS) {
  4597. // test si les certificats raistlin ont été acceptés
  4598. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  4599. var infoit = MY_getValue(numTroll+'.INFOSIT');
  4600. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  4601. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  4602. }
  4603. }
  4604.  
  4605. displayScriptTime();
  4606. }
  4607.  
  4608. /*********************************************************************************
  4609. * This file is part of Mountyzilla. *
  4610. * *
  4611. * Mountyzilla is free software; you can redistribute it and/or modify *
  4612. * it under the terms of the GNU General Public License as published by *
  4613. * the Free Software Foundation; either version 2 of the License, or *
  4614. * (at your option) any later version. *
  4615. * *
  4616. * Mountyzilla is distributed in the hope that it will be useful, *
  4617. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4618. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4619. * GNU General Public License for more details. *
  4620. * *
  4621. * You should have received a copy of the GNU General Public License *
  4622. * along with Mountyzilla; if not, write to the Free Software *
  4623. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4624. *********************************************************************************/
  4625.  
  4626. // x~x tabcompo
  4627.  
  4628. var popup;
  4629.  
  4630. function initPopupTabcompo() {
  4631. popup = document.createElement('div');
  4632. popup.setAttribute('id', 'popup');
  4633. popup.setAttribute('class', 'mh_textbox');
  4634. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  4635. + 'display: inline; z-index: 3; max-width: 400px;');
  4636. document.body.appendChild(popup);
  4637. }
  4638.  
  4639. function showPopup(evt) {
  4640. var texte = this.getAttribute("texteinfo");
  4641. popup.innerHTML = texte;
  4642. popup.style.left = evt.pageX + 15 + 'px';
  4643. popup.style.top = evt.pageY + 'px';
  4644. popup.style.visibility = "visible";
  4645. }
  4646.  
  4647. // roule 16/03/2016, existe déjà ailleurs
  4648. // function hidePopup() {
  4649. // popup.style.visibility = 'hidden';
  4650. // }
  4651.  
  4652. function createPopupImage(url, text)
  4653. {
  4654. var img = document.createElement('img');
  4655. img.setAttribute('src',url);
  4656. img.setAttribute('align','ABSMIDDLE');
  4657. img.setAttribute("texteinfo",text);
  4658. img.addEventListener("mouseover", showPopup,true);
  4659. img.addEventListener("mouseout", hidePopup,true);
  4660. return img;
  4661. }
  4662.  
  4663. function formateTexte(texte)
  4664. {
  4665. texte = texte.replace(/\n/g,"<br/>");
  4666. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4667. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4668. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4669. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4670. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4671. return texte;
  4672. }
  4673.  
  4674. function arrondi(x) {
  4675. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  4676. }
  4677.  
  4678. function traiteMinerai() {
  4679. if (currentURL.indexOf("as_type=Divers")==-1) return;
  4680. try {
  4681. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  4682. +" and contains(./tr/th/text(),'Minerai')]",
  4683. document, null, 9, null).singleNodeValue;
  4684. node = node.nextSibling.nextSibling;
  4685. }
  4686. catch(e) {return;}
  4687. var trlist = document.evaluate('./tr', node, null, 7, null);
  4688. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  4689. var node = trlist.snapshotItem(i);
  4690. var nature = node.childNodes[5].textContent;
  4691. var caracs = node.childNodes[7].textContent;
  4692. var taille = caracs.match(/\d+/)[0];
  4693. var coef = 1;
  4694. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  4695. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  4696. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  4697. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  4698. if (nature.indexOf('Mithril')!=-1) {
  4699. coef = 0.2*coef;
  4700. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  4701. }
  4702. else {
  4703. coef = 0.75*coef+1.25;
  4704. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  4705. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  4706. }
  4707. }
  4708. }
  4709.  
  4710. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  4711. function treateComposants() {
  4712. if (currentURL.indexOf("as_type=Compo")==-1) return;
  4713. //On récupère les composants
  4714. var nodes = document.evaluate(
  4715. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4716. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4717. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  4718. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4719. if (nodes.snapshotLength == 0) {
  4720. //window.console.log('[MZ] treateComposants DOWN');
  4721. return;
  4722. }
  4723. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  4724.  
  4725. var texte = "";
  4726. for (var i = 0; i < nodes.snapshotLength; i++) {
  4727. var n1 = nodes.snapshotItem(i).childNodes[1];
  4728. var n3 = nodes.snapshotItem(i).childNodes[3];
  4729. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4730. var prix = n3.childNodes[0].nodeValue;
  4731. if (!prix)
  4732. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4733. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4734. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4735. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4736. + prix.replace(/\n/g, '') + "\n";
  4737. }
  4738.  
  4739. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4740. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4741. var id_taniere = c.snapshotItem(0).nodeValue;
  4742. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  4743.  
  4744. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4745. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  4746. if (form)
  4747. {
  4748. if(document.getElementsByTagName('form').length>0)
  4749. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4750. else
  4751. {
  4752. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4753. insertBefore(thisP, form);
  4754. }
  4755. }
  4756. }
  4757.  
  4758. function treateAllComposants() {
  4759. if(currentURL.indexOf("as_type=Compo")==-1) return;
  4760. //On récupère les composants
  4761. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  4762. document, null, 0, null ).numberValue;
  4763. var c = (categ == 0 ? 3 : 4);
  4764. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  4765. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  4766. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  4767. + "td["+c+"]/text()[1] = '\240-\240' "
  4768. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  4769. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  4770. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  4771. + "and td[1]/img/@alt = 'Identifié']",
  4772. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4773. if (nodes.snapshotLength == 0) {
  4774. // window.alert('treateAllComposants DOWN');
  4775. return;
  4776. }
  4777.  
  4778. var texte = "";
  4779. for (var i = 0; i < nodes.snapshotLength; i++) {
  4780. var n1 = nodes.snapshotItem(i).childNodes[1];
  4781. var n3 = nodes.snapshotItem(i).childNodes[3];
  4782. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  4783. var prix = n3.childNodes[0].nodeValue;
  4784. if (!prix)
  4785. {
  4786. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  4787. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  4788. }
  4789. else
  4790. {
  4791. prix= prix.replace(/[\240 ]/g, "");
  4792. if(prix=="-")
  4793. prix=null;
  4794. }
  4795. if(prix)
  4796. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4797. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4798. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  4799. + prix.replace(/\n/g, '') + "\n";
  4800. else
  4801. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  4802. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  4803. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  4804. }
  4805.  
  4806. var c = document.evaluate("//div[@class = 'titre2']/text()",
  4807. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4808. var id_taniere = c.snapshotItem(0).nodeValue;
  4809. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  4810.  
  4811. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  4812. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  4813. if (form)
  4814. {
  4815. if(document.getElementsByTagName('form').length>0)
  4816. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  4817. else
  4818. {
  4819. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  4820. insertBefore(thisP, form);
  4821. }
  4822. }
  4823. }
  4824.  
  4825. function treateEM()
  4826. {
  4827. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  4828. if(currentURL.indexOf("as_type=Compo")==-1)
  4829. return false;
  4830. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  4831. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  4832. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4833. if (nodes.snapshotLength == 0)
  4834. return false;
  4835. for (var i = 0; i < nodes.snapshotLength; i++) {
  4836. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  4837. var link = desc[2].firstChild ;
  4838. var nomCompoTotal = desc[2].textContent ;
  4839. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4840. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4841. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  4842. var locqual = desc[3].textContent ;
  4843. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  4844. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  4845. if(isEM(nomMonstre).length>0)
  4846. {
  4847. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  4848. if(infos.length>0)
  4849. {
  4850. var shortDescr = "Variable";
  4851. var bold = 0;
  4852. if(infos != "Composant variable")
  4853. {
  4854. shortDescr = infos.substring(0,infos.indexOf(" "));
  4855. if(parseInt(shortDescr)>=0)
  4856. bold=1;
  4857. }
  4858. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  4859. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  4860. }
  4861. }
  4862. }
  4863. }
  4864.  
  4865. function treateChampi() {
  4866. if (currentURL.indexOf('as_type=Champi')==-1)
  4867. return false;
  4868. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  4869. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4870. if (nodes.snapshotLength == 0)
  4871. return false;
  4872.  
  4873. for (var i = 0; i < nodes.snapshotLength; i++) {
  4874. var node = nodes.snapshotItem(i);
  4875. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  4876. if (moisChampi[nomChampi])
  4877. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  4878. }
  4879. }
  4880.  
  4881. function treateEnchant()
  4882. {
  4883. if(currentURL.indexOf("as_type=Compo")==-1)
  4884. return false;
  4885. try
  4886. {
  4887. if(!listeMonstreEnchantement)
  4888. computeCompoEnchantement();
  4889. var nodes = document.evaluate(
  4890. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  4891. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  4892. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4893. if (nodes.snapshotLength == 0)
  4894. return false;
  4895. var urlImg = URL_MZimg + "enchant.png";
  4896. for (var i = 0; i < nodes.snapshotLength; i++) {
  4897. var link = nodes.snapshotItem(i);
  4898. var nomCompoTotal = link.firstChild.nodeValue;
  4899. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  4900. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  4901. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  4902. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  4903. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  4904. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  4905. if(isEnchant(nomMonstre).length>0)
  4906. {
  4907. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  4908. if(infos.length>0)
  4909. {
  4910. link.parentNode.appendChild(createImage(urlImg,infos));
  4911. }
  4912. }
  4913. }
  4914. }
  4915. catch(e)
  4916. {
  4917. window.alert(e);
  4918. }
  4919. }
  4920.  
  4921. function treateEquipEnchant()
  4922. {
  4923. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  4924. return false;
  4925. initPopupTabcompo();
  4926. computeEnchantementEquipement(createPopupImage,formateTexte);
  4927. }
  4928.  
  4929. function do_tancompo() {
  4930. start_script();
  4931.  
  4932. treateAllComposants();
  4933. treateComposants();
  4934. traiteMinerai();
  4935. if (MY_getValue('NOINFOEM')!='true') {
  4936. treateChampi();
  4937. treateEM();
  4938. }
  4939. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  4940. treateEnchant();
  4941. treateEquipEnchant();
  4942. }
  4943.  
  4944. displayScriptTime();
  4945. }
  4946.  
  4947. /*******************************************************************************
  4948. * This file is part of Mountyzilla. *
  4949. * *
  4950. * Mountyzilla is free software; you can redistribute it and/or modify *
  4951. * it under the terms of the GNU General Public License as published by *
  4952. * the Free Software Foundation; either version 2 of the License, or *
  4953. * (at your option) any later version. *
  4954. * *
  4955. * Mountyzilla is distributed in the hope that it will be useful, *
  4956. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4957. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4958. * GNU General Public License for more details. *
  4959. * *
  4960. * You should have received a copy of the GNU General Public License *
  4961. * along with Mountyzilla; if not, write to the Free Software *
  4962. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4963. *******************************************************************************/
  4964.  
  4965. // x~x pjview
  4966.  
  4967. /* TODO
  4968. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  4969. */
  4970.  
  4971. // Bulle d'infos
  4972. var DivInfo;
  4973. // Booléen stockant l'état de freezing de la bulle
  4974. var freezed = false;
  4975.  
  4976. // liste du matos
  4977. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  4978. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  4979. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  4980. var mh_caracs = {
  4981. 'anneau de protection':
  4982. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  4983. "armure d'anneaux":
  4984. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  4985. 'armure de bois':
  4986. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  4987. 'armure de cuir':
  4988. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  4989. 'armure de peaux':
  4990. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  4991. 'armure de pierre':
  4992. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  4993. 'armure de plates':
  4994. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  4995. 'baton lesté':
  4996. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4997. 'bâtons de parade':
  4998. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  4999. 'bottes':
  5000. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5001. 'bouclier à pointes':
  5002. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5003. 'boulet et chaîne':
  5004. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5005. 'cagoule':
  5006. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5007. 'casque à cornes':
  5008. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5009. 'casque à pointes':
  5010. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5011. 'casque en cuir':
  5012. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5013. 'casque en métal':
  5014. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5015. 'chaîne cloutée':
  5016. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5017. 'chapeau pointu':
  5018. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5019. 'collier de dents':
  5020. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5021. 'collier de pierre':
  5022. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5023. 'collier à pointes':
  5024. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5025. 'cotte de mailles':
  5026. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5027. 'couronne de cristal':
  5028. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5029. "couronne d'obsidienne":
  5030. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5031. "coutelas d'obsidienne":
  5032. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5033. 'coutelas en os':
  5034. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5035. 'crochet':
  5036. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5037. 'cuir bouilli':
  5038. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5039. "cuirasse d'ossements":
  5040. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5041. "cuirasse d'écailles":
  5042. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5043. 'culotte en cuir':
  5044. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5045. 'dague':
  5046. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5047. 'epée courte':
  5048. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5049. 'epée longue':
  5050. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5051. 'espadon':
  5052. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5053. 'fouet':
  5054. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5055. 'fourrures':
  5056. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5057. 'gantelet':
  5058. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5059. 'gorgeron en cuir':
  5060. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5061. 'gorgeron en métal':
  5062. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5063. 'gourdin':
  5064. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5065. 'gourdin clouté':
  5066. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5067. 'grimoire':
  5068. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5069. "gros'porte":
  5070. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5071. 'grosse racine':
  5072. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5073. 'grosse stalagmite':
  5074. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5075. 'hache de bataille':
  5076. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5077. 'hache de guerre en os':
  5078. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5079. 'hache de guerre en pierre':
  5080. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5081. "hache à deux mains d'obsidienne":
  5082. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5083. 'hallebarde':
  5084. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5085. "haubert d'écailles":
  5086. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5087. 'haubert de mailles':
  5088. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5089. 'heaume':
  5090. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5091. 'jambières en cuir':
  5092. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5093. 'jambières en fourrure':
  5094. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5095. 'jambières en maille':
  5096. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5097. 'jambières en métal':
  5098. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5099. 'jambières en os':
  5100. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5101. "lame d'obsidienne":
  5102. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5103. 'lame en os':
  5104. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5105. 'lame en pierre':
  5106. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5107. 'lorgnons':
  5108. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5109. 'machette':
  5110. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5111. "masse d'arme":
  5112. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5113. 'pagne de mailles':
  5114. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5115. 'pagne en cuir':
  5116. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5117. 'robe de mage':
  5118. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5119. 'rondache en bois':
  5120. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5121. 'rondache en métal':
  5122. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5123. 'sandales':
  5124. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5125. 'souliers dorés':
  5126. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5127. "talisman d'obsidienne":
  5128. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5129. 'talisman de pierre':
  5130. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5131. 'targe':
  5132. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5133. 'torche':
  5134. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5135. 'torque de pierre':
  5136. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5137. 'tunique':
  5138. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5139. "tunique d'écailles":
  5140. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5141. 'turban':
  5142. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5143. }
  5144.  
  5145. // liste des templates
  5146. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5147. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5148. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5149. var mh_templates = {
  5150. 'de Feu':
  5151. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5152. 'de Résistance':
  5153. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5154. "de l'Aigle":
  5155. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5156. 'de la Salamandre':
  5157. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5158. 'des Cyclopes':
  5159. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5160. 'des Enragés':
  5161. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5162. 'des Tortues':
  5163. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5164. 'des Vampires':
  5165. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5166. 'du Glacier':
  5167. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5168. 'du Rat':
  5169. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5170. 'du Roc':
  5171. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5172. 'du Temps':
  5173. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5174. 'du Vent':
  5175. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5176. 'en Mithril':
  5177. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5178. 'des Anciens':
  5179. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5180. 'des Champions':
  5181. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5182. 'des Duellistes':
  5183. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5184. 'de la Terre':
  5185. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5186. "de l'Orage":
  5187. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5188. "de l'Ours":
  5189. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5190. 'des Béhémoths':
  5191. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5192. 'des Mages':
  5193. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5194. 'du Pic':
  5195. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5196. 'du Sable':
  5197. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5198. 'acéré':
  5199. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5200. 'acérée':
  5201. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5202. 'équilibré':
  5203. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5204. 'équilibrée':
  5205. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5206. 'léger':
  5207. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5208. 'légère':
  5209. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5210. 'renforcé':
  5211. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5212. 'renforcée':
  5213. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5214. 'robuste':
  5215. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5216. }
  5217.  
  5218. function clone(arr) {
  5219. // Clonage rapide
  5220. return arr.slice(0);
  5221. }
  5222.  
  5223. function addArray(arr1,arr2) {
  5224. // Somme matricielle
  5225. var res = clone(arr1);
  5226. for(i=res.length-1 ; i>=0 ; i--) {
  5227. res[i] += arr2[i];
  5228. }
  5229. return res;
  5230. }
  5231.  
  5232. function getTemplates(nomItem) {
  5233. // Déstructure le nom de l'item en array [nom, template1, ...]
  5234. var tempFound = true;
  5235. var str = nomItem.trim();
  5236. var arr = [];
  5237. while(tempFound) {
  5238. tempFound = false;
  5239. for(var temp in mh_templates) {
  5240. // on teste la fin du nom contre chaque template
  5241. if(str.slice(-temp.length)!=temp) { continue; }
  5242. tempFound = true;
  5243. str = str.slice(0,-temp.length-1);
  5244. arr.unshift(temp);
  5245. if(str.slice(-3)==' et') {
  5246. str = str.slice(0,-3);
  5247. }
  5248. }
  5249. }
  5250. arr.unshift(str);
  5251. return arr;
  5252. }
  5253.  
  5254. function addMithril(arrayCaracs,typeItem) {
  5255. // Ajoute l'effet du Mithril sur les caracs
  5256. if(typeItem=='arme') {
  5257. if(arrayCaracs[0]<0) {
  5258. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5259. }
  5260. }
  5261. else {
  5262. if(arrayCaracs[4]<0) {
  5263. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5264. }
  5265. }
  5266. arrayCaracs[15] /= 2;
  5267. arrayCaracs[16] /= 2;
  5268. return arrayCaracs;
  5269. }
  5270.  
  5271. function addRenfort(arrayCaracs,template) {
  5272. // Ajoute l'effet des pseudo-templates sur les caracs
  5273. // S'applique APRÈS le mithril
  5274. // WARNING - Cette formule n'a rien d'officiel, gare !
  5275. var coef = 0;
  5276. if(/^lég[e,è]re?$/.test(template)) {
  5277. coef = -1;
  5278. }
  5279. else if(/^renforcée?$/.test(template)
  5280. || template==='robuste') {
  5281. coef = 1;
  5282. }
  5283. if(coef) {
  5284. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5285. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5286. }
  5287. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5288. return arrayCaracs;
  5289. }
  5290.  
  5291. function getCaracs(item) {
  5292. // Calcule les caractéristiques de l'item
  5293. var templates = getTemplates(item);
  5294. if(!mh_caracs[templates[0]]) {
  5295. // Si l'item est inconnu
  5296. return [];
  5297. }
  5298. var caracs = clone(mh_caracs[templates[0]]);
  5299. var typeItem = caracs[0];
  5300. caracs.shift();
  5301. templates.shift();
  5302. if(templates[templates.length-1]=='en Mithril') {
  5303. caracs = addMithril(caracs,typeItem);
  5304. templates.pop();
  5305. }
  5306. if(/^acérée?$/.test(templates[0])
  5307. || /^équilibrée?$/.test(templates[0])
  5308. || /^lég[e,è]re?$/.test(templates[0])
  5309. || /^renforcée?$/.test(templates[0])
  5310. || templates[0]=='robuste') {
  5311. caracs = addRenfort(caracs,templates[0]);
  5312. templates.shift();
  5313. }
  5314. for(var i=templates.length-1 ; i>=0 ; i--) {
  5315. caracs = addArray(caracs,mh_templates[templates[i]]);
  5316. }
  5317. return caracs;
  5318. }
  5319.  
  5320. function getLine(tab) {
  5321. // Préparation de la ligne à afficher lors d'un mouseover
  5322. var str = '';
  5323. if(tab[0]!=0 || tab[1]!=0) {
  5324. str += '<b>Att : </b>'+aff(tab[0]);
  5325. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5326. str += ' | ';
  5327. }
  5328. if(tab[4]!=0) {
  5329. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5330. }
  5331. if(tab[2]!=0 || tab[3]!=0) {
  5332. str += '<b>Deg : </b>'+aff(tab[2]);
  5333. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5334. str += ' | ';
  5335. }
  5336. if(tab[8]!=0) {
  5337. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5338. }
  5339. if(tab[7]!=0) {
  5340. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5341. }
  5342. if(tab[5]!=0 || tab[6]!=0) {
  5343. str += '<b>Arm : </b>'+aff(tab[5]);
  5344. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5345. str += ' | ';
  5346. }
  5347. if(tab[9]!=0 || tab[10]!=0) {
  5348. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5349. if(tab[9]!=tab[10]) {
  5350. str += '/'+aff(tab[10])+'%';
  5351. }
  5352. str += ' | ';
  5353. }
  5354. if(tab[11]!=0 || tab[12]!=0) {
  5355. str += '<b>MM : </b>'+aff(tab[11])+'%';
  5356. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  5357. str += ' | ';
  5358. }
  5359. if(tab[13]!=0) {
  5360. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5361. }
  5362. if(tab[14]!=0) {
  5363. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5364. }
  5365. str += '<b>Poids : </b>'+tab[15]+' min';
  5366. if(tab[15]!=tab[16]) {
  5367. str += ' / '+tab[16]+' min';
  5368. }
  5369. return str;
  5370. }
  5371.  
  5372. function toolTipInit() {
  5373. DivInfo = document.createElement('div');
  5374. DivInfo.id = 'infosVue';
  5375. DivInfo.className = 'mh_textbox';
  5376. DivInfo.style =
  5377. 'position: absolute;'
  5378. +'border: 1px solid #000000;'
  5379. +'visibility:hidden;'
  5380. +'display:inline;'
  5381. +'z-index:99;';
  5382. document.body.appendChild(DivInfo);
  5383. document.onmousemove = getXY;
  5384. document.onclick = changeFreezeStatus;
  5385. }
  5386.  
  5387. function getXY(evt) {
  5388. if(!freezed && DivInfo.style.visibility=='visible') {
  5389. DivInfo.style.left = evt.pageX+'px';
  5390. DivInfo.style.top = evt.pageY+10+'px';
  5391. }
  5392. }
  5393.  
  5394. function changeFreezeStatus() {
  5395. if(DivInfo.style.visibility=='visible') {
  5396. freezed = !freezed;
  5397. if(!freezed) { hideInfos(); }
  5398. }
  5399. }
  5400.  
  5401. function showInfos() {
  5402. if(freezed) { return; }
  5403. var currentInfos = this.infos;
  5404. DivInfo.innerHTML = currentInfos;
  5405. DivInfo.style.visibility = 'visible';
  5406. }
  5407.  
  5408. function hideInfos() {
  5409. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  5410. }
  5411.  
  5412. function treateEquipement() {
  5413. // Extrait les données du matos et réinjecte les infos déduites
  5414. if(MY_getValue('INFOCARAC')=='false') { return; }
  5415. var faireLigne = false;
  5416. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  5417. var nodes = document.evaluate(
  5418. "//td/b[text()='Equipement Utilisé']/../../"
  5419. +"td[2]/img[contains(@src,bullet)]",
  5420. document, null, 7, null);
  5421. if(nodes.snapshotLength>0) {
  5422. // Si CSS de base
  5423. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5424. var node = nodes.snapshotItem(i);
  5425. var next = node.nextSibling;
  5426. var nnext = next.nextSibling;
  5427. var nom = next.nodeValue.toLowerCase();
  5428. if(nnext.childNodes.length==1) {
  5429. nom += nnext.firstChild.nodeValue;
  5430. }
  5431. nom = nom.trim();
  5432. // gestion winpostrophe
  5433. var c = String.fromCharCode(180);
  5434. while(nom.indexOf(c)!=-1) {
  5435. nom = nom.replace(c,"'");
  5436. }
  5437. var arr = getCaracs(nom);
  5438. if(arr.length>0) {
  5439. faireLigne = true;
  5440. caracs = addArray(caracs,arr);
  5441. var span = document.createElement('span');
  5442. span.appendChild(next);
  5443. span.appendChild(nnext);
  5444. span.infos = getLine(arr);
  5445. span.onmouseover = showInfos;
  5446. span.onmouseout = hideInfos;
  5447. insertBefore(node.nextSibling,span);
  5448. }
  5449. }
  5450. if(faireLigne) {
  5451. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  5452. document, null, 9, null).singleNodeValue;
  5453. node.infos = getLine(caracs);
  5454. node.onmouseover = showInfos;
  5455. node.onmouseout = hideInfos;
  5456. }
  5457. }
  5458. else {
  5459. // Si CSS avancée
  5460. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  5461. document, null, 7, null);
  5462. if(nodes.snapshotLength>0) {
  5463. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5464. var node = nodes.snapshotItem(i);
  5465. var nom = node.firstChild.nodeValue.toLowerCase();
  5466. if(node.childNodes.length>1) {
  5467. nom += node.childNodes[1].firstChild.nodeValue;
  5468. }
  5469. nom = nom.trim();
  5470. // gestion winpostrophe
  5471. var c = String.fromCharCode(180);
  5472. while(nom.indexOf(c)!=-1) {
  5473. nom = nom.replace(c,"'");
  5474. }
  5475. var arr = getCaracs(nom);
  5476. if(arr.length!=0) {
  5477. caracs = addArray(caracs,arr);
  5478. node.infos = getLine(arr);
  5479. node.onmouseover = showInfos;
  5480. node.onmouseout = hideInfos;
  5481. }
  5482. }
  5483. var nodes = document.evaluate("//dt[@class='equipement']",
  5484. document, null, 7, null);
  5485. var node = nodes.snapshotItem(0);
  5486. node.infos = getLine(caracs);
  5487. node.onmouseover = showInfos;
  5488. node.onmouseout = hideInfos;
  5489. }
  5490. }
  5491. }
  5492.  
  5493. function do_pjview() {
  5494. treateEquipement();
  5495. toolTipInit();
  5496. }
  5497.  
  5498. /*******************************************************************************
  5499. * This file is part of Mountyzilla. *
  5500. * *
  5501. * Mountyzilla is free software; you can redistribute it and/or modify *
  5502. * it under the terms of the GNU General Public License as published by *
  5503. * the Free Software Foundation; either version 2 of the License, or *
  5504. * (at your option) any later version. *
  5505. * *
  5506. * Mountyzilla is distributed in the hope that it will be useful, *
  5507. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5508. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5509. * GNU General Public License for more details. *
  5510. * *
  5511. * You should have received a copy of the GNU General Public License *
  5512. * along with Mountyzilla; if not, write to the Free Software *
  5513. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5514. *******************************************************************************/
  5515.  
  5516. // x~x option
  5517.  
  5518. /* TODO
  5519. * Passer le HTML injecté aux conventions HTML5
  5520. */
  5521.  
  5522.  
  5523. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  5524.  
  5525. function saveITData() {
  5526. var IT = document.getElementById('itSelect').value;
  5527. if(IT=='bricol') {
  5528. var system = document.getElementById('urlbricol').value;
  5529. var login = document.getElementById('loginbricol').value;
  5530. var pass = document.getElementById('passbricol').value;
  5531. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  5532. if(system && login) {
  5533. if (pass) {
  5534. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  5535. MY_setValue(numTroll+'.INFOSIT', v);
  5536. //window.console.log('v=' + v);
  5537. } else {
  5538. // vérif que rien n'a changé
  5539. var str = MY_getValue(numTroll+'.INFOSIT');
  5540. if(str) {
  5541. var arr = str.split('$');
  5542. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  5543. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  5544. }
  5545. }
  5546. }
  5547. }
  5548. }
  5549. else {
  5550. MY_removeValue(numTroll+'.INFOSIT');
  5551. }
  5552. }
  5553.  
  5554. function saveLinks() {
  5555. var numLinks = document.getElementById('linksBody').childNodes.length;
  5556. var data=[ [] ];
  5557. /* Récupération et tri des liens */
  5558. for(var i=1 ; i<=numLinks ; i++) {
  5559. MY_removeValue('URL'+i);
  5560. MY_removeValue('URL'+i+'.nom');
  5561. MY_removeValue('URL'+i+'.ico');
  5562. var url = document.getElementById('url'+i).value;
  5563. var nom = document.getElementById('nom'+i).value;
  5564. var ico = document.getElementById('ico'+i).value;
  5565. if(url && (nom || ico) ) {
  5566. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5567. }
  5568. }
  5569. /* Sauvegarde */
  5570. for(var i=1 ; i<data.length ; i++) {
  5571. MY_setValue('URL'+i,data[i][0]);
  5572. MY_setValue('URL'+i+'.nom',data[i][1]);
  5573. MY_setValue('URL'+i+'.ico',data[i][2]);
  5574. }
  5575. }
  5576.  
  5577. function saveAll() {
  5578. var urlIco = document.getElementById('icoMenuIco').value;
  5579. if(urlIco) {
  5580. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5581. }
  5582. else {
  5583. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5584. document.getElementById('icoMenuIco').value = '';
  5585. }
  5586. saveLinks();
  5587. refreshLinks();
  5588. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5589. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5590. if(maxcdm) {
  5591. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5592. }
  5593. else {
  5594. MY_removeValue(numTroll+'.MAXCDM');
  5595. document.getElementById('maxcdm').value = '';
  5596. }
  5597.  
  5598. MY_setValue('NOINFOEM',
  5599. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5600. // Pourquoi Tilk stockait-il tout en str ?
  5601. // -> parce que les booléens c'est foireux (vérifié)
  5602. MY_setValue(numTroll+'.USECSS',
  5603. document.getElementById('usecss').checked ? 'true':'false');
  5604. MY_setValue('INFOCARAC',
  5605. document.getElementById('infocarac').checked ? 'true' : 'false');
  5606. //MY_setValue(numTroll+'.SEND_IDT',
  5607. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  5608. // Fonctionnalité désactivée
  5609.  
  5610. MY_setValue(numTroll+'.AUTOCDM',
  5611. document.getElementById('autoCdM').checked ? 'true' : 'false');
  5612. MY_setValue('VUECARAC',
  5613. document.getElementById('vueCarac').checked ? 'true' : 'false');
  5614. MY_setValue('CONFIRMEDECALAGE',
  5615. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  5616.  
  5617. saveITData();
  5618. var bouton = document.getElementById('saveAll');
  5619. bouton.value = (bouton.value=='Sauvegardé !') ?
  5620. 'Re-sauvegardé !' : 'Sauvegardé !';
  5621. }
  5622.  
  5623.  
  5624. /*-[functions]----------------- EventListeners -------------------------------*/
  5625.  
  5626. function onChangeIT() {
  5627. var IT = document.getElementById('itSelect').value;
  5628. var itBody = document.getElementById('itBody');
  5629. itBody.innerHTML = '';
  5630. if(IT=='bricol') {
  5631. var tr = appendTr(itBody,'mh_tdpage')
  5632. var td = appendTd(tr);
  5633. var str = MY_getValue(numTroll+'.INFOSIT');
  5634. //window.console.log('onChangeIT str=' + str);
  5635. if(str) {
  5636. var arr = str.split('$');
  5637. var system = arr[1];
  5638. var login = arr[2];
  5639. var affhv = arr[4];
  5640. }
  5641. appendText(td,'Nom du système : ');
  5642. appendTextbox(td,'text','urlbricol',20,50,system);
  5643. td = appendTd(tr);
  5644. appendText(td,'Login du compte : ');
  5645. appendTextbox(td,'text','loginbricol',20,50,login);
  5646. td = appendTd(tr);
  5647. appendText(td,'Mot de passe du compte : ');
  5648. appendTextbox(td,'password','passbricol',20,50);
  5649. td = appendTd(tr);
  5650. appendText(td,'Affichage des Trõlls hors vue : ');
  5651. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  5652. appendCheckBox(td,'affhvbricol', (affhv>0));
  5653. }
  5654. }
  5655.  
  5656. function refreshLinks() {
  5657. document.getElementById('linksBody').innerHTML = '';
  5658. var anotherURL = MY_getValue('URL1');
  5659. if(!anotherURL) { addLinkField(); }
  5660. var i=1;
  5661. while(anotherURL && i<99) {
  5662. addLinkField(i,anotherURL,
  5663. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  5664. i++;
  5665. anotherURL = MY_getValue('URL'+i);
  5666. }
  5667. }
  5668.  
  5669. function addLinkField(i,url,nom,ico) {
  5670. var linksBody = document.getElementById('linksBody');
  5671. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  5672. var tr = appendTr(linksBody);
  5673. var td = appendTdCenter(tr);
  5674. appendText(td,'Lien '+i+' : ');
  5675. appendTextbox(td,'text','url'+i,40,150,url);
  5676. td = appendTdCenter(tr);
  5677. appendText(td,'Nom : ');
  5678. appendTextbox(td,'text','nom'+i,20,150,nom);
  5679. td = appendTdCenter(tr);
  5680. appendText(td,'Icône : ');
  5681. appendTextbox(td,'text','ico'+i,40,150,ico);
  5682. }
  5683.  
  5684. function removeLinkField() {
  5685. var linksBody = document.getElementById('linksBody');
  5686. var i = linksBody.childNodes.length;
  5687. MY_removeValue('URL'+i);
  5688. MY_removeValue('URL'+i+'.nom');
  5689. MY_removeValue('URL'+i+'.ico');
  5690. linksBody.removeChild(linksBody.lastChild);
  5691. if(linksBody.childNodes.length==0) { addLinkField(); }
  5692. }
  5693.  
  5694. function resetMainIco() {
  5695. document.getElementById('icoMenuIco').value=
  5696. URL_MZimg + 'mz_logo_small.png';
  5697. }
  5698.  
  5699.  
  5700. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  5701.  
  5702. function insertTitle(next,txt) {
  5703. var div = document.createElement('div');
  5704. div.className = 'titre2';
  5705. appendText(div,txt);
  5706. insertBefore(next,div);
  5707. return div;
  5708. }
  5709.  
  5710. function insertMainTable(next) {
  5711. var table = document.createElement('table');
  5712. table.width = '98%';
  5713. table.border = 0;
  5714. table.align = 'center';
  5715. table.cellPadding = 2;
  5716. table.cellSpacing = 1;
  5717. table.className = 'mh_tdborder';
  5718. var tbody = document.createElement('tbody');
  5719. table.appendChild(tbody);
  5720. insertBefore(next,table);
  5721. return tbody;
  5722. }
  5723.  
  5724. function appendSubTable(node) {
  5725. var table = document.createElement('table');
  5726. table.width = '100%';
  5727. var tbody = document.createElement('tbody');
  5728. table.appendChild(tbody);
  5729. node.appendChild(table);
  5730. return tbody;
  5731. }
  5732.  
  5733. function insertOptionTable(insertPt) {
  5734. var mainBody = insertMainTable(insertPt);
  5735. /* Liens dans le Menu */
  5736. var tr = appendTr(mainBody,'mh_tdtitre');
  5737. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  5738. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5739. appendText(td,'Icône du Menu: ');
  5740. var url = MY_getValue(numTroll+'.ICOMENU');
  5741. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  5742. url = URL_MZimg + 'mz_logo_small.png';
  5743. }
  5744. appendTextbox(td,'text','icoMenuIco',50,200,url);
  5745. appendButton(td,'Réinitialiser',resetMainIco);
  5746. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5747. var tbody = appendSubTable(td);
  5748. tbody.id = 'linksBody';
  5749. refreshLinks();
  5750. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  5751. appendButton(td,'Ajouter',addLinkField);
  5752. appendButton(td,'Supprimer',removeLinkField);
  5753. /* Options de la Vue : vue externe, nb de CdM, etc */
  5754. tr = appendTr(mainBody,'mh_tdtitre');
  5755. appendTdText(tr,'Options de la Vue :',true);
  5756. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5757. tbody = appendSubTable(td);
  5758. tr = appendTr(tbody);
  5759. td = appendTdText(tr,'Vue externe : ');
  5760. var select = document.createElement('select');
  5761. select.id = 'vueext';
  5762. td.appendChild(select);
  5763. var listeVues2D = [
  5764. 'Bricol\' Vue',
  5765. 'Vue du CCM',
  5766. 'Vue Gloumfs 2D',
  5767. 'Vue Gloumfs 3D',
  5768. 'Grouky Vue!'
  5769. ];
  5770. for(var i=0 ; i<listeVues2D.length ; i++) {
  5771. appendOption(select,listeVues2D[i],listeVues2D[i]);
  5772. }
  5773. if(MY_getValue('VUEEXT')) {
  5774. select.value = MY_getValue('VUEEXT');
  5775. }
  5776. td = appendTd(tr);
  5777. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  5778. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  5779. tr = appendTr(tbody);
  5780. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  5781. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  5782. td = appendTd(tr);
  5783. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  5784. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  5785. /* Interface Tactique */
  5786. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5787. appendText(td,'Interface Tactique : ',true);
  5788. select = document.createElement('select');
  5789. select.id = 'itSelect';
  5790. appendOption(select,'none','Aucune');
  5791. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  5792. // seule interface supportée !
  5793. td.appendChild(select);
  5794. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5795. tbody = appendSubTable(td);
  5796. tbody.id = 'itBody';
  5797. select.onchange = onChangeIT;
  5798. var str = MY_getValue(numTroll+'.INFOSIT');
  5799. if(str) {
  5800. select.value = str.slice(0,str.indexOf('$'));
  5801. onChangeIT();
  5802. }
  5803. /* Options diverses */
  5804. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  5805. appendText(td,'Options diverses :',true);
  5806. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5807. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  5808. appendText(td,
  5809. ' Afficher les caractéristiques des équipements des autres Trõlls');
  5810. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5811. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  5812. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  5813. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5814. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  5815. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  5816. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5817. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  5818. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  5819. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  5820. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  5821. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  5822. /* Bouton SaveAll */
  5823. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  5824. input = appendButton(td,'Sauvegarder',saveAll);
  5825. input.id = 'saveAll';
  5826. }
  5827.  
  5828. function insertCreditsTable(insertPt) {
  5829. var tbody = insertMainTable(insertPt);
  5830. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  5831. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  5832. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  5833.  
  5834. var ul = document.createElement('ul');
  5835. td.appendChild(ul);
  5836. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  5837. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  5838. appendLI(ul,'Reivax (4234) pour les infos bulles');
  5839. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  5840. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  5841. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  5842. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  5843. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  5844. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  5845. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  5846. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  5847. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  5848. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  5849. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  5850. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  5851. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  5852. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  5853. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  5854. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  5855. }
  5856.  
  5857.  
  5858. /* [functions] Obsolètes */
  5859. function deleteEnchantement()
  5860. {
  5861. try
  5862. {
  5863. var idEquipement = this.getAttribute('name');
  5864. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  5865. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  5866. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  5867. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  5868. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  5869. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5870. var string = "";
  5871. for(var i=0;i<listeEquipement.length;i++)
  5872. {
  5873. if(listeEquipement[i]!=idEquipement)
  5874. if(string=="")
  5875. string = listeEquipement[i];
  5876. else
  5877. string += ";"+listeEquipement[i];
  5878. }
  5879. if(string=="")
  5880. {
  5881. MY_removeValue(numTroll+".enchantement.liste");
  5882. var table = this.parentNode.parentNode.parentNode.parentNode;
  5883. var parent = table.parentNode;
  5884. for(var i=0;i<parent.childNodes.length;i++)
  5885. {
  5886. if(parent.childNodes[i]==table)
  5887. {
  5888. parent.removeChild(parent.childNodes[i-1]);
  5889. parent.removeChild(parent.childNodes[i-1]);
  5890. parent.removeChild(parent.childNodes[i-1]);
  5891. break;
  5892. }
  5893. }
  5894. }
  5895. else
  5896. {
  5897. MY_getValue(numTroll+".enchantement.liste",string);
  5898. this.parentNode.parentNode.parentNode
  5899. .removeChild(this.parentNode.parentNode);
  5900. }
  5901. }
  5902. catch(e)
  5903. {
  5904. window.alert(e);
  5905. }
  5906. }
  5907. /* [functions] fin Obsolètes */
  5908.  
  5909. /*-[functions]---------------- Partie principale -----------------------------*/
  5910.  
  5911. function do_option() {
  5912. start_script(712);
  5913.  
  5914. // Pour cryptage des mdp IT
  5915. //appendNewScript(URL_tilk_js + 'md5.js'); // source intégré dans tout_MZ
  5916.  
  5917. var insertPoint = document.getElementById('footer1');
  5918. insertBefore(insertPoint,document.createElement('p'));
  5919. var ti = insertTitle(insertPoint,'Mountyzilla : Options');
  5920. ti.title = 'Version ' + GM_info.script.version;
  5921. insertOptionTable(insertPoint);
  5922. /* insertion enchantements ici
  5923. if(...)
  5924. insertEnchantementTable();
  5925. */
  5926. insertBefore(insertPoint,document.createElement('p'));
  5927. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  5928. ti.onclick = function (e) {
  5929. var evt = e || window.event;
  5930. if (evt.shiftKey) {
  5931. var oldDev = MY_getValue('MZ_dev');
  5932. if (oldDev) {
  5933. MY_removeValue('MZ_dev');
  5934. } else {
  5935. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  5936. MY_setValue('MZ_dev', 1);
  5937. }
  5938. document.location.href = document.location.href;
  5939. }
  5940. }
  5941. insertCreditsTable(insertPoint);
  5942. insertBefore(insertPoint,document.createElement('p'));
  5943.  
  5944. /* [zone] Obsolète ?? */
  5945. if(MY_getValue(numTroll+".enchantement.liste")
  5946. && MY_getValue(numTroll+".enchantement.liste")!="" )
  5947. {
  5948. insertTitle(insertPoint, 'Les Enchantements en cours');
  5949. table = document.createElement('table');
  5950. table.setAttribute('width', '98%');
  5951. table.setAttribute('border', '0');
  5952. table.setAttribute('align', 'center');
  5953. table.setAttribute('cellpadding', '2');
  5954. table.setAttribute('cellspacing', '1');
  5955. table.setAttribute('class', 'mh_tdborder');
  5956.  
  5957. tbody = document.createElement('tbody');
  5958. table.appendChild(tbody);
  5959. tr = appendTr(tbody, 'mh_tdtitre');
  5960. appendTdText(tr, 'Equipement',1);
  5961. appendTdText(tr, 'Composants',1);
  5962. appendTdText(tr, 'Enchanteur',1);
  5963. appendTdText(tr, 'Action',1);
  5964. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  5965. for(var i=0;i<listeEquipement.length;i++)
  5966. {
  5967. try
  5968. {
  5969. var idEquipement = listeEquipement[i];
  5970. var nomEquipement = MY_getValue(numTroll+".enchantement."
  5971. +idEquipement+".objet");
  5972. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  5973. +idEquipement+".enchanteur").split(";");
  5974. var ul = document.createElement('UL');
  5975. for(var j=0;j<3;j++)
  5976. {
  5977. var infoComposant = MY_getValue(numTroll+".enchantement."
  5978. +idEquipement+".composant."+j).split(";");
  5979. var texte = infoComposant[4].replace("Ril ","Œil ");
  5980. for(var k=5;k<infoComposant.length;k++)
  5981. {
  5982. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  5983. }
  5984. li = appendLI(ul,texte);
  5985. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  5986. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  5987. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  5988. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  5989. string+= '<input type="hidden" name="q" value="min" />';
  5990. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  5991. 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>';
  5992.  
  5993. string+= '</form>';
  5994. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  5995. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  5996. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  5997. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  5998. li.innerHTML += string;
  5999. }
  6000. tr = appendTr(tbody, 'mh_tdpage');
  6001. td = appendTdText(tr, nomEquipement);
  6002. td.setAttribute('valign', 'center');
  6003. td = document.createElement('td');
  6004. td.appendChild(ul);
  6005. tr.appendChild(td);
  6006. td.setAttribute('valign', 'center');
  6007. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6008. td.setAttribute('valign', 'center');
  6009. td = document.createElement('td');
  6010. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6011. input.setAttribute('name', idEquipement);
  6012. tr.appendChild(td);
  6013. td.setAttribute('valign', 'center');
  6014. }
  6015. catch(e)
  6016. {
  6017. }
  6018. }
  6019. insertBefore(insertPoint, table);
  6020. insertBefore(insertPoint, document.createElement('p'));
  6021. }
  6022. /* [zone] fin Obsolète ?? */
  6023.  
  6024.  
  6025. displayScriptTime();
  6026. }
  6027.  
  6028. /*******************************************************************************
  6029. * This file is part of Mountyzilla. *
  6030. * *
  6031. * Mountyzilla is free software; you can redistribute it and/or modify *
  6032. * it under the terms of the GNU General Public License as published by *
  6033. * the Free Software Foundation; either version 2 of the License, or *
  6034. * (at your option) any later version. *
  6035. * *
  6036. * Mountyzilla is distributed in the hope that it will be useful, *
  6037. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6038. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6039. * GNU General Public License for more details. *
  6040. * *
  6041. * You should have received a copy of the GNU General Public License *
  6042. * along with Mountyzilla; if not, write to the Free Software *
  6043. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6044. *******************************************************************************/
  6045.  
  6046. // x~x equip
  6047.  
  6048. /**
  6049. * 2014-02-08 - v2.0a (from scratch)
  6050. * 2014-02-18 - v2.0a0
  6051. * - ajout calcul Carats / UM des minerais + totaux
  6052. * 2014-03-06 - v2.0a1
  6053. * - retour Infos EM des Champis
  6054. * TODO
  6055. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6056. */
  6057.  
  6058. function traiteChampis() {
  6059. try{
  6060. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6061. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6062. }
  6063. catch(e){return;}
  6064. if(trlist.length<=0) return;
  6065. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6066. var node = trlist.snapshotItem(i).childNodes[7];
  6067. var str = node.textContent.trim();
  6068. var type = str.slice(0,str.lastIndexOf(' '));
  6069. var mundi = mundiChampi[type];
  6070. if(!mundi) continue;
  6071. var urlImg = URL_MZimg
  6072. +'Competences/ecritureMagique.png';
  6073. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6074. appendText(node,' ');
  6075. node.appendChild(img);
  6076. }
  6077. }
  6078.  
  6079. function traiteCompos() {
  6080. try {
  6081. var tr = document.getElementById('mh_objet_hidden_Composant');
  6082. var tbody = document.evaluate("./td/table/tbody",
  6083. tr, null, 9, null).singleNodeValue;
  6084. }
  6085. catch(e) {return;}
  6086. insererInfosEM(tbody);
  6087. }
  6088.  
  6089. function traiteMinerai() {
  6090. try{
  6091. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6092. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6093. }
  6094. catch(e){return;}
  6095. if(trlist.length<=0) return;
  6096. var totaux = {};
  6097. var str;
  6098. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6099. var node = trlist.snapshotItem(i);
  6100. var nature = node.childNodes[7].textContent,
  6101. caracs = node.childNodes[9].textContent;
  6102. var taille = Number(caracs.match(/\d+/)[0]);
  6103. var coef = 1;
  6104. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6105. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6106. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6107. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6108. if(nature.indexOf('Mithril')!=-1) {
  6109. coef = 0.2*coef;
  6110. str = ' | UM: ';
  6111. }
  6112. else {
  6113. coef = 0.75*coef+1.25;
  6114. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6115. str = ' | Carats: ';
  6116. }
  6117. var carats = Math.round(taille*coef)
  6118. appendText(node.childNodes[9], str+carats );
  6119. if(!totaux[nature]) {
  6120. totaux[nature] = [taille,carats];
  6121. }
  6122. else {
  6123. totaux[nature][0] += taille;
  6124. totaux[nature][1] += carats;
  6125. }
  6126. }
  6127. str = 'Total : ';
  6128. for(var nature in totaux) {
  6129. if(str.length>8) str += ', ';
  6130. if(nature.indexOf('Mithril')!=-1) {
  6131. str += nature+totaux[nature][1]+' UM';
  6132. }
  6133. else {
  6134. str += nature+totaux[nature][0]+'U/'
  6135. +totaux[nature][1]+'c';
  6136. }
  6137. }
  6138. /*var node = document.getElementById('mh_plus_Minerai');
  6139. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6140. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6141. if(!titre) return;*/
  6142. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6143. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6144. td.colSpan = 7;
  6145. }
  6146.  
  6147. function do_equip() {
  6148. start_script();
  6149.  
  6150. traiteChampis();
  6151. traiteCompos();
  6152. traiteMinerai();
  6153.  
  6154. displayScriptTime();
  6155. }
  6156.  
  6157. /*******************************************************************************
  6158. * This file is part of Mountyzilla. *
  6159. * *
  6160. * Mountyzilla is free software; you can redistribute it and/or modify *
  6161. * it under the terms of the GNU General Public License as published by *
  6162. * the Free Software Foundation; either version 2 of the License, or *
  6163. * (at your option) any later version. *
  6164. * *
  6165. * Mountyzilla is distributed in the hope that it will be useful, *
  6166. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6167. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6168. * GNU General Public License for more details. *
  6169. * *
  6170. * You should have received a copy of the GNU General Public License *
  6171. * along with Mountyzilla; if not, write to the Free Software *
  6172. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6173. *******************************************************************************/
  6174.  
  6175. // x~x diplo
  6176.  
  6177. /*
  6178. TODO:
  6179. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6180. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6181. V Étape 3: Ajout de la diplo perso
  6182. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6183. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6184. Options Globales:
  6185. Actuelles:
  6186. numTroll.USECSS,
  6187. numTroll.NODIPLO
  6188. NOMYTH
  6189. Nouvelles:
  6190. TODO numTroll.USECSS
  6191. numTroll.diplo.off (remplace NODIPLO)
  6192. numTroll.diplo.guilde
  6193. numTroll.diplo.perso
  6194. Structure de diplo.guilde:
  6195. isOn: 'true' ou 'false'
  6196. isDetailOn: 'true' ou 'false'
  6197. guilde
  6198. > id
  6199. > couleur
  6200. AllAmis,AllEnnemis: couleur
  6201. Amis0,...,Ennemis5
  6202. > Troll: idTroll1;...;
  6203. > Guilde: idGuilde1;...;
  6204. > titre
  6205. > couleur
  6206. Structure de diplo.perso:
  6207. isOn: 'true' ou 'false'
  6208. mythiques: couleur
  6209. Troll,Guilde,Monstre:
  6210. > id
  6211. > couleur
  6212. > description
  6213. */
  6214.  
  6215. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6216.  
  6217. function couleurAleatoire() {
  6218. var alph = '0123456789ABCDEF'.split('');
  6219. var clr = '#';
  6220. for (var i=0; i<6; i++) {
  6221. clr+=alph[ Math.floor(16*Math.random()) ];
  6222. }
  6223. return clr;
  6224. }
  6225.  
  6226. function isCouleur(str) {
  6227. return /^#[0-9A-F]{6}$/i.test(str);
  6228. }
  6229.  
  6230. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6231.  
  6232. function appendChoixCouleur(node,id) {
  6233. var span = document.createElement('span');
  6234. span.id = 'span'+id;
  6235. if(isDetailOn) {
  6236. span.style.display = 'none';
  6237. }
  6238. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6239. if(diploGuilde[id]) {
  6240. couleur = diploGuilde[id];
  6241. }
  6242. appendText(span,' - Couleur HTML: ');
  6243. var input = appendTextbox(span,'text',id,7,7,couleur);
  6244. input.onkeyup = previewCouleur;
  6245. input.onchange = previewCouleur;
  6246. input.onkeyup();
  6247. node.appendChild(span);
  6248. }
  6249.  
  6250. function insertChoixCouleur(node,id) {
  6251. var span = document.createElement('span');
  6252. span.id = 'span'+id;
  6253. // La couleur détaillée passera à une valeur aléatoire
  6254. // si toggle vers isDetailOn
  6255. var couleur = couleurAleatoire();
  6256. if(!isDetailOn) {
  6257. span.style.display = 'none';
  6258. } else if(diploGuilde[id]) {
  6259. couleur = diploGuilde[id].couleur;
  6260. }
  6261. appendText(span,' - Couleur HTML: ');
  6262. var input = appendTextbox(span,'text',id,7,7,couleur);
  6263. input.onkeyup = previewCouleur;
  6264. input.onchange = previewCouleur;
  6265. input.onkeyup();
  6266. insertBefore(node,span);
  6267. }
  6268.  
  6269. function setChoixCouleurs() {
  6270. try {
  6271. var form = document.getElementsByName('ActionForm')[0];
  6272. var nodesAE = document.evaluate(
  6273. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6274. form, null, 7, null
  6275. );
  6276. var nodes = document.evaluate(
  6277. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6278. form, null, 7, null
  6279. );
  6280. } catch(e) {
  6281. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6282. return false;
  6283. };
  6284. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6285. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6286. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6287. for(var i=0 ; i<5 ; i++) {
  6288. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6289. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6290. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6291. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6292. }
  6293. return true;
  6294. }
  6295.  
  6296. function fetchDiploGuilde() {
  6297. try {
  6298. for(var AE in {Amis:0,Ennemis:0}) {
  6299. for(var i=0 ; i<5 ; i++) {
  6300. /* Récup des A/E de rang i */
  6301. var td = document.getElementById('td'+AE+i);
  6302. var ligne = td.getElementsByTagName('table')[0].rows;
  6303. var titre = trim(td.firstChild.textContent);
  6304. // On laisse la gestion des couleurs à setChoixCouleurs:
  6305. var couleur = document.getElementById(AE+i).value;
  6306. diploGuilde[AE+i] = {
  6307. Troll:'',
  6308. Guilde:'',
  6309. titre: titre,
  6310. couleur: couleur
  6311. };
  6312. for(var j=1 ; j<ligne.length ; j++) {
  6313. var str = trim(ligne[j].cells[0].textContent);
  6314. var idx = str.lastIndexOf('(');
  6315. var num = str.slice(idx+1,-1);
  6316. var type = trim(ligne[j].cells[1].textContent);
  6317. diploGuilde[AE+i][type] += num+';';
  6318. }
  6319. }
  6320. }
  6321. } catch(e) {
  6322. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6323. return false;
  6324. }
  6325. return true;
  6326. }
  6327.  
  6328.  
  6329. /*-[functions]--------------------- Handlers ---------------------------------*/
  6330.  
  6331. function toggleDetails() {
  6332. isDetailOn = !isDetailOn;
  6333. for(var AE in {Amis:0,Ennemis:0}) {
  6334. document.getElementById('spanAll'+AE).style.display =
  6335. (isDetailOn?'none':'');
  6336. for(var i=0 ; i<5 ; i++) {
  6337. document.getElementById('span'+AE+i).style.display =
  6338. (isDetailOn?'':'none');
  6339. }
  6340. }
  6341. }
  6342.  
  6343. function toggleMythiques() {
  6344. isMythiquesOn = !isMythiquesOn;
  6345. document.getElementById('spanMythiques').style.display =
  6346. (isMythiquesOn?'':'none');
  6347. }
  6348.  
  6349. function previewCouleur() {
  6350. var value = this.value;
  6351. if(isCouleur(value)) {
  6352. this.style.backgroundColor = value;
  6353. this.title = '';
  6354. } else {
  6355. this.style.backgroundColor = '';
  6356. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  6357. }
  6358. }
  6359.  
  6360. function appendMenuType(node,duType) {
  6361. var select = document.createElement('select');
  6362. select.className = 'SelectboxV2';
  6363. var type = ['Guilde','Troll','Monstre'];
  6364. for(var i=0 ; i<3 ; i++) {
  6365. appendOption(select,type[i],type[i]);
  6366. if(type[i]==duType) { select.selectedIndex=i; }
  6367. }
  6368. node.appendChild(select);
  6369. }
  6370.  
  6371. function ajouteChamp(type,num,couleur,descr) {
  6372. var champs = document.getElementById('diploPerso');
  6373. var nb = champs.rows.length;
  6374. var tr = champs.insertRow(-1);
  6375. var td = appendTd(tr);
  6376. appendMenuType(td,type);
  6377. td = appendTd(tr);
  6378. appendText(td,' n°');
  6379. appendTextbox(td,'text','num'+nb,6,15,num);
  6380. td = appendTd(tr);
  6381. appendText(td,' couleur HTML:');
  6382. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  6383. input.onkeyup = previewCouleur;
  6384. input.onchange = previewCouleur;
  6385. input.onkeyup();
  6386. td = appendTd(tr);
  6387. appendText(td,' Description:');
  6388. appendTextbox(td,'text','descr'+nb,30,150,descr);
  6389. td = appendTd(tr);
  6390. var span = document.createElement('span');
  6391. appendText(span,'[ok!]',true);
  6392. span.style.visibility = 'hidden';
  6393. td.appendChild(span);
  6394. td = appendTd(tr);
  6395. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  6396. }
  6397.  
  6398. function retireCeChamp() {
  6399. var thisTr = this.parentNode.parentNode;
  6400. thisTr.parentNode.removeChild(thisTr);
  6401. var champs = document.getElementById('diploPerso');
  6402. if(champs.rows.length==0) { ajouteChamp(); }
  6403. }
  6404.  
  6405. function valideChamp(champ) {
  6406. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  6407. isCouleur(champ.cells[2].childNodes[1].value);
  6408. if(isValide) {
  6409. champ.cells[4].firstChild.style.visibility = 'visible';
  6410. } else {
  6411. champ.cells[4].firstChild.style.visibility = 'hidden';
  6412. }
  6413. return isValide;
  6414. }
  6415.  
  6416. function sauvegarderTout() {
  6417. /* Diplo de guilde */
  6418. diploGuilde.isOn =
  6419. document.getElementById('isGuildeOn').checked?'true':'false';
  6420. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  6421. var numGuilde = Number(document.getElementById('numGuilde').value);
  6422. var couleur = document.getElementById('couleurGuilde').value;
  6423. if(numGuilde) {
  6424. diploGuilde.guilde = {
  6425. id: numGuilde,
  6426. couleur: couleur
  6427. };
  6428. } else {
  6429. delete diploGuilde.guilde;
  6430. }
  6431. for(var AE in {Amis:0,Ennemis:0}) {
  6432. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  6433. for(var i=0 ; i<5 ; i++) {
  6434. if(isDetailOn) {
  6435. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  6436. } else {
  6437. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  6438. }
  6439. }
  6440. }
  6441. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  6442. /* Diplo personnelle (ex-fonction saveChamps) */
  6443. var champs = document.getElementById('diploPerso');
  6444. diploPerso = {
  6445. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  6446. Guilde: {},
  6447. Troll: {},
  6448. Monstre: {}
  6449. };
  6450. if(isMythiquesOn &&
  6451. isCouleur(document.getElementById('couleurMythiques').value)) {
  6452. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  6453. }
  6454. for(var i=0 ; i<champs.rows.length ; i++) {
  6455. if(valideChamp(champs.rows[i])) {
  6456. var type = champs.rows[i].cells[0].firstChild.value;
  6457. var num = champs.rows[i].cells[1].childNodes[1].value;
  6458. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  6459. var descr = champs.rows[i].cells[3].childNodes[1].value;
  6460. diploPerso[type][num] = {
  6461. couleur: couleur
  6462. };
  6463. if(descr) {
  6464. diploPerso[type][num].titre = descr;
  6465. }
  6466. }
  6467. }
  6468. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  6469.  
  6470. avertissement('Données sauvegardées');
  6471. }
  6472.  
  6473.  
  6474. /*-[functions]------------- Modifications de la page -------------------------*/
  6475.  
  6476. function creeTablePrincipale() {
  6477. var insertPt = document.getElementById('insertPt');
  6478. /* Titre + bouton de Sauvegarde */
  6479. var tr = insertTr(insertPt,'mh_tdtitre');
  6480. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  6481. appendButton(td,'Sauvegarder',sauvegarderTout);
  6482. /* Options fixes */
  6483. tr = insertTr(insertPt,'mh_tdpage');
  6484. td = appendTdText(tr,'Diplomatie de guilde:',true);
  6485. appendBr(td);
  6486. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  6487. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  6488. appendBr(td);
  6489. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  6490. appendText(td,'Utiliser des couleurs détaillées (10)');
  6491. /* Diplo personnelle */
  6492. tr = insertTr(insertPt,'mh_tdpage');
  6493. td = appendTdText(tr,'Diplomatie personnelle:',true);
  6494. appendBr(td);
  6495. // Diplo Mythiques
  6496. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  6497. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  6498. var span = document.createElement('span');
  6499. span.id = 'spanMythiques';
  6500. if(!isMythiquesOn) {
  6501. span.style.display = 'none';
  6502. }
  6503. var couleur = '#FFAAAA';
  6504. if(diploPerso.mythiques) {
  6505. couleur = diploPerso.mythiques;
  6506. }
  6507. appendText(span,' - couleur HTML:');
  6508. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  6509. input.onkeyup = previewCouleur;
  6510. input.onchange = previewCouleur;
  6511. input.onkeyup();
  6512. td.appendChild(span);
  6513. appendBr(td);
  6514. // Diplo éditable
  6515. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  6516. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  6517. appendBr(td);
  6518. var table = document.createElement('table');
  6519. table.id = 'diploPerso'
  6520. td.appendChild(table);
  6521. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  6522. for(var num in diploPerso[type]) {
  6523. ajouteChamp(
  6524. type,
  6525. num,
  6526. diploPerso[type][num].couleur,
  6527. diploPerso[type][num].titre
  6528. );
  6529. }
  6530. }
  6531. if(table.rows.length==0) {
  6532. ajouteChamp();
  6533. }
  6534. appendButton(td,'Ajouter',ajouteChamp)
  6535. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  6536. appendText(td,' ');
  6537. appendButton(td,
  6538. 'Exemples de couleur',
  6539. function() {
  6540. var fenetre = window.open(
  6541. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  6542. 'Divers',
  6543. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  6544. 'status=0,menubar=0,resizable=1,scrollbars=1'
  6545. );
  6546. fenetre.focus();
  6547. }
  6548. );
  6549. /* Couleur de Guilde */
  6550. tr = insertTr(insertPt,'mh_tdtitre');
  6551. td = appendTdText(tr,'GUILDE',true);
  6552. appendText(td,' - n°');
  6553. appendTextbox(td,'text','numGuilde',5,10,
  6554. diploGuilde.guilde && diploGuilde.guilde.id ?
  6555. diploGuilde.guilde.id : ''
  6556. );
  6557. appendText(td,' - Couleur HTML: ');
  6558. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  6559. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  6560. diploGuilde.guilde.couleur : '#BBBBFF'
  6561. );
  6562. input.onkeyup = previewCouleur;
  6563. input.onchange = previewCouleur;
  6564. input.onkeyup();
  6565. }
  6566.  
  6567.  
  6568. /*-[functions]----------------------- Main -----------------------------------*/
  6569.  
  6570. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6571. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6572. var isDetailOn = diploGuilde.isDetailOn=='true';
  6573. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6574. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6575. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6576.  
  6577. function do_diplo() {
  6578. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6579. creeTablePrincipale();
  6580. }
  6581. }
  6582.  
  6583. /*******************************************************************************
  6584. * This file is part of Mountyzilla. *
  6585. * *
  6586. * Mountyzilla is free software; you can redistribute it and/or modify *
  6587. * it under the terms of the GNU General Public License as published by *
  6588. * the Free Software Foundation; either version 2 of the License, or *
  6589. * (at your option) any later version. *
  6590. * *
  6591. * Mountyzilla is distributed in the hope that it will be useful, *
  6592. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6593. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6594. * GNU General Public License for more details. *
  6595. * *
  6596. * You should have received a copy of the GNU General Public License *
  6597. * along with Mountyzilla; if not, write to the Free Software *
  6598. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6599. *******************************************************************************/
  6600.  
  6601. // x~x cdmcomp
  6602.  
  6603. var cdm = '';
  6604.  
  6605. function getNonNegInts(str) {
  6606. var nbrs = str.match(/\d+/g);
  6607. for(var i=0 ; i<nbrs.length ; i++) {
  6608. nbrs[i] = Number(nbrs[i]);
  6609. }
  6610. return nbrs;
  6611. }
  6612.  
  6613. function traiteCdMcomp() {
  6614. try {
  6615. var msgEffet = document.getElementById('msgEffet');
  6616. } catch(e) {
  6617. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  6618. return;
  6619. }
  6620.  
  6621. // Teste si ce message du bot est un message de CdM
  6622. if(!document.evaluate(
  6623. "./p/b/text()[contains(.,'fait partie')]",
  6624. msgEffet, null, 9, null
  6625. ).singleNodeValue) {
  6626. return;
  6627. }
  6628. // Début de récupération de la CdM
  6629. cdm = document.evaluate(
  6630. "./p/b/text()[contains(.,'fait partie')]",
  6631. msgEffet, null, 9, null
  6632. ).singleNodeValue.nodeValue+'\n';
  6633. var tbody = document.evaluate(
  6634. "descendant::table/tbody",
  6635. msgEffet, null, 9, null
  6636. ).singleNodeValue;
  6637. var nomStat = document.evaluate(
  6638. "./tr/td[1]/b/text()",
  6639. tbody, null, 7, null
  6640. );
  6641. var valStat = document.evaluate(
  6642. "./tr/td[2]/descendant::text()",
  6643. tbody, null, 7, null
  6644. );
  6645. var i=0;
  6646. while(i<nomStat.snapshotLength) {
  6647. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  6648. cdm += 'Armure : ';
  6649. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  6650. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  6651. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  6652. armp = [0,armp[0]];
  6653. }
  6654. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  6655. armm = [0,armm[0]];
  6656. }
  6657. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  6658. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  6659. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  6660. } else {
  6661. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6662. }
  6663. cdm += ')\n';
  6664. i++;
  6665. } else {
  6666. cdm += nomStat.snapshotItem(i).nodeValue+
  6667. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  6668. }
  6669. i++;
  6670. }
  6671. // Envoi auto ou insertion bouton envoi (suivant option)
  6672. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  6673. sendInfoCDM();
  6674. var p = document.createElement('p');
  6675. p.style.color = 'green';
  6676. appendText(p,'CdM envoyée vers la base MountyZilla !');
  6677. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  6678. } else {
  6679. insertButtonCdm('as_Action', sendInfoCDM);
  6680. }
  6681.  
  6682. // Insertion de l'estimation des PV restants
  6683. var pv = valStat.snapshotItem(1).nodeValue;
  6684. if(pv.indexOf("entre")==-1) {
  6685. return;
  6686. }
  6687. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  6688. if(pv) {
  6689. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  6690. appendTdText(tr, pv[0], true);
  6691. appendTdText(tr, pv[1], true);
  6692. }
  6693. }
  6694.  
  6695. function sendInfoCDM() {
  6696. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  6697. var buttonCDM = this;
  6698. var texte = '';
  6699. FF_XMLHttpRequest({
  6700. method: 'GET',
  6701. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6702. headers : {
  6703. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6704. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6705. },
  6706. onload: function(responseDetails) {
  6707. texte = responseDetails.responseText;
  6708. buttonCDM.value = texte;
  6709. buttonCDM.disabled = true;
  6710. }
  6711. });
  6712. }
  6713.  
  6714. function do_cdmcomp() {
  6715. start_script(31);
  6716. traiteCdMcomp();
  6717. displayScriptTime();
  6718. }
  6719.  
  6720. /*********************************************************************************
  6721. * This file is part of Mountyzilla. *
  6722. * *
  6723. * Mountyzilla is free software; you can redistribute it and/or modify *
  6724. * it under the terms of the GNU General Public License as published by *
  6725. * the Free Software Foundation; either version 2 of the License, or *
  6726. * (at your option) any later version. *
  6727. * *
  6728. * Mountyzilla is distributed in the hope that it will be useful, *
  6729. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6730. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6731. * GNU General Public License for more details. *
  6732. * *
  6733. * You should have received a copy of the GNU General Public License *
  6734. * along with Mountyzilla; if not, write to the Free Software *
  6735. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6736. *********************************************************************************/
  6737.  
  6738. // x~x cmdbot
  6739.  
  6740. /* v0.2 by Dab - 2013-08-20
  6741. * - patch dégueu pour gérer la décomposition P/M de l'armure
  6742. */
  6743.  
  6744. var buttonCDM;
  6745.  
  6746. /*******************************************************************************************
  6747. CDM :
  6748. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  6749.  
  6750. Il ne vous est pas possible d'améliorer cette compétence.
  6751.  
  6752. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  6753. Niveau : Inimaginable (entre 49 et 51)
  6754. Points de Vie : Surtrollesque (entre 450 et 470)
  6755. Blessure (Approximatif) : 0 %
  6756. Dés d'Attaque : Impressionnant (entre 30 et 32)
  6757. Dés d'Esquive : Impressionnant (entre 28 et 30)
  6758. Dés de Dégat : Très Fort (entre 18 et 20)
  6759. Dés de Régénération : Excellent (égal à 13)
  6760. Armure Physique : Moyen (entre 10 et 12)
  6761. Armure Magique : Faible (inférieur à 6)
  6762. Vue : Moyen (entre 9 et 11)
  6763. Maitrise Magique : Inimaginable (supérieur à 6000)
  6764. Résistance Magique : Inimaginable (supérieur à 6000)
  6765. Nombre d'attaques : 1
  6766. Vitesse de Déplacement : Normale
  6767. Voir le Caché : Oui
  6768. Attaque à distance : Non
  6769. Attaque magique : Oui
  6770. Vole : Non
  6771. Sang froid : Inexistant
  6772. DLA : Milieu
  6773. Durée Tour : Remarquable (entre 9 et 11)
  6774. Chargement : Vide
  6775. Bonus Malus : Aucun
  6776.  
  6777. Vous avez également gagné 1 PX pour la réussite.
  6778. *******************************************************************************************
  6779. BOT :
  6780. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  6781.  
  6782. Le Monstre ciblé fait partie des : Mort-Vivant
  6783.  
  6784. Niveau : Incroyable (entre 36 et 38)
  6785. *******************************************************************************************/
  6786.  
  6787. function getNNInt(str) {
  6788. var nbrs = str.match(/\d+/g);
  6789. for (var i=0 ; i<nbrs.length ; i++)
  6790. nbrs[i] = parseInt(nbrs[i]);
  6791. return nbrs;
  6792. }
  6793.  
  6794. function sendCDM() {
  6795. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6796. document, null, 9, null).singleNodeValue;
  6797. cdm = td.innerHTML;
  6798. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  6799. "$3$4 ($1 - N°$2)<br>");
  6800. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  6801. 'Blessure : XX % (approximativement)');
  6802. // Supprime la décomposition P/M de l'Armure
  6803. var bgn = cdm.indexOf('Armure Physique');
  6804. if (bgn!=-1) {
  6805. var end = cdm.indexOf('Vue')-2;
  6806. var lines = cdm.substring(bgn,end).split('<br>');
  6807. var armp = getNNInt(lines[0]);
  6808. var armm = getNNInt(lines[1]);
  6809. if (lines[0].indexOf('(inf')!=-1)
  6810. armp = [0,armp[0]];
  6811. if (lines[1].indexOf('(inf')!=-1)
  6812. armm = [0,armm[0]];
  6813. var insrt = 'Armure : ';
  6814. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  6815. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  6816. else
  6817. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  6818. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  6819. }
  6820. cdm = cdm.replace(/<br>/g,'\n');
  6821. FF_XMLHttpRequest({
  6822. method: 'GET',
  6823. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  6824. headers : {
  6825. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6826. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6827. },
  6828. onload: function(responseDetails) {
  6829. buttonCDM.value=responseDetails.responseText;
  6830. buttonCDM.disabled = true;
  6831. }
  6832. });
  6833. }
  6834.  
  6835. function traiteCdMmsg() {
  6836. // Teste si ce message du bot est un message de CdM
  6837. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  6838. document, null, 9, null).singleNodeValue;
  6839. if (!td) return false;
  6840. cdm = td.innerHTML;
  6841. // Insertion de l'estimation des PV restants
  6842. var des = cdm.indexOf('Dés');
  6843. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  6844. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  6845. if(pv)
  6846. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  6847.  
  6848. // Insertion bouton envoi + espace
  6849. buttonCDM = insertButtonCdm('bClose',sendCDM);
  6850. }
  6851.  
  6852. /*function traitePouvoir() {
  6853. // Teste si ce message du bot est un message de CdM
  6854. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  6855. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  6856. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  6857. if (!td)
  6858. return false;
  6859. var infos = td.innerHTML;
  6860. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  6861. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  6862. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  6863. var date = /alors : ([^<]+)\./.exec(infos)[1];
  6864. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  6865. var effetPouvoir="";
  6866. var full=false;
  6867. if(infos.indexOf("REDUIT")!=-1) {
  6868. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  6869. }
  6870. else {
  6871. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  6872. full=true;
  6873. }
  6874. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  6875. // On insère le bouton et un espace
  6876. //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));
  6877. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  6878. if(!MY_getValue('AUTOSENDPOUV'))
  6879. {
  6880. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  6881. button.setAttribute("onClick", "window.open('" + url
  6882. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  6883. + "this.value='Merci de votre participation'; this.disabled = true;");
  6884. }
  6885. else
  6886. {
  6887. FF_XMLHttpRequest({
  6888. method: 'GET',
  6889. url: url,
  6890. headers : {
  6891. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  6892. 'Accept': 'application/atom+xml,application/xml,text/xml'
  6893. }});
  6894. }
  6895. }*/
  6896.  
  6897. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  6898. traiteCdMmsg();
  6899. }
  6900. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  6901.  
  6902. /*******************************************************************************
  6903. * This file is part of Mountyzilla. *
  6904. * *
  6905. * Mountyzilla is free software; you can redistribute it and/or modify *
  6906. * it under the terms of the GNU General Public License as published by *
  6907. * the Free Software Foundation; either version 2 of the License, or *
  6908. * (at your option) any later version. *
  6909. * *
  6910. * Mountyzilla is distributed in the hope that it will be useful, *
  6911. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6912. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6913. * GNU General Public License for more details. *
  6914. * *
  6915. * You should have received a copy of the GNU General Public License *
  6916. * along with Mountyzilla; if not, write to the Free Software *
  6917. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6918. *******************************************************************************/
  6919.  
  6920. // x~x menu
  6921. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  6922.  
  6923. var menuRac, mainIco;
  6924.  
  6925. // met à jour les carac sauvegardées (position, DLA, etc.)
  6926. function updateData() {
  6927. var inputs = document.getElementsByTagName('input');
  6928. var divs = document.getElementsByTagName('div');
  6929. numTroll = inputs[0].value;
  6930. MY_setValue('NUM_TROLL', numTroll);
  6931. MY_setValue('NIV_TROLL',inputs[1].value);
  6932. if(!MY_getValue(numTroll+'.caracs.rm')) {
  6933. MY_setValue(numTroll+'.caracs.rm',0);
  6934. // assure l'init des 4 var de libs
  6935. }
  6936. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  6937. var DLA = new Date(
  6938. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  6939. );
  6940. if(MY_getValue(numTroll+'.DLA.encours')) {
  6941. var DLAstockee = new Date(
  6942. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  6943. );
  6944. if(DLA>DLAstockee) {
  6945. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  6946. // Pose un pb en cas de décalage de DLA
  6947. }
  6948. }
  6949. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  6950. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  6951. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  6952. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  6953. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  6954. }
  6955.  
  6956. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  6957. function initRaccourcis() {
  6958. var anotherURL = MY_getValue('URL1');
  6959. if(!anotherURL) { return; }
  6960. /* Création de l'icône faisant apparaître le menu */
  6961. mainIco = document.createElement('img');
  6962. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  6963. if(!urlIco) {
  6964. urlIco =
  6965. URL_MZimg + 'mz_logo_small.png';
  6966. }
  6967. mainIco.src = urlIco;
  6968. mainIco.alt = 'MZ';
  6969. mainIco.style = 'position:fixed; top:0px; left:0px';
  6970. mainIco.onmouseover = afficheMenu;
  6971. document.body.appendChild(mainIco);
  6972. /* Création du menu des Raccourcis */
  6973. menuRac = document.createElement('div');
  6974. menuRac.className = 'mh_textbox';
  6975. menuRac.style =
  6976. 'position:fixed; top:10px; left:10px;'+
  6977. 'max-width:190px;'+
  6978. 'border-radius: 4px; padding: 4px;'+
  6979. 'z-index: 500;'+
  6980. 'visibility: hidden;';
  6981. document.body.appendChild(menuRac);
  6982. document.addEventListener('mousemove',cacheMenu,false);
  6983. var i=1;
  6984. while(anotherURL) {
  6985. var a = document.createElement('a');
  6986. var url = MY_getValue('URL'+i);
  6987. var nom = MY_getValue('URL'+i+'.nom');
  6988. var ico = MY_getValue('URL'+i+'.ico');
  6989. a.href = url;
  6990. a.target = '_blank';
  6991. if(ico) {
  6992. var txt = nom ? nom : '';
  6993. var img = createImage(ico,txt);
  6994. a.appendChild(img);
  6995. }
  6996. else {
  6997. appendText(a,'['+nom+']');
  6998. }
  6999. menuRac.appendChild(a);
  7000. appendBr(menuRac);
  7001. i++;
  7002. anotherURL = MY_getValue('URL'+i);
  7003. }
  7004. }
  7005.  
  7006. function afficheMenu() {
  7007. menuRac.style.visibility = 'visible';
  7008. }
  7009.  
  7010. function cacheMenu(e) {
  7011. if(menuRac.style.visibility=='hidden') { return; }
  7012. // Position souris
  7013. var ptX = e.clientX;
  7014. var ptY = e.clientY;
  7015. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7016. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7017. var menuRect = menuRac.getBoundingClientRect();
  7018. var icoRect = mainIco.getBoundingClientRect();
  7019. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7020. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7021. menuRac.style.visibility = 'hidden';
  7022. }
  7023. }
  7024.  
  7025. // ajout de l'icône, branchée sur un refresh
  7026. function initUpdateCoordGauche() {
  7027. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7028. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7029. var img = document.createElement('img');
  7030. img.src = URL_MZimg + 'recycl.png'
  7031. img.onclick = function(evt) {
  7032. document.location.href = document.location.href;
  7033. };
  7034. img.title = 'Mise à jour de la localisation';
  7035. img.style.cursor = 'pointer';
  7036. img.style.position = 'absolute';
  7037. img.style.bottom = 0;
  7038. img.style.left = 0;
  7039. div.appendChild(img);
  7040. }
  7041.  
  7042. function do_menu() {
  7043. // met à jour les carac sauvegardées (position, DLA, etc.)
  7044. updateData();
  7045. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7046. initRaccourcis();
  7047. // Ajout bouton de mise à jour coordonnées
  7048. initUpdateCoordGauche();
  7049. }
  7050.  
  7051. /*******************************************************************************
  7052. * This file is part of Mountyzilla. *
  7053. * *
  7054. * Mountyzilla is free software; you can redistribute it and/or modify *
  7055. * it under the terms of the GNU General Public License as published by *
  7056. * the Free Software Foundation; either version 2 of the License, or *
  7057. * (at your option) any later version. *
  7058. * *
  7059. * Mountyzilla is distributed in the hope that it will be useful, *
  7060. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7061. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7062. * GNU General Public License for more details. *
  7063. * *
  7064. * You should have received a copy of the GNU General Public License *
  7065. * along with Mountyzilla; if not, write to the Free Software *
  7066. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7067. *******************************************************************************/
  7068.  
  7069. // x~x vue
  7070.  
  7071. /* TODO
  7072. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7073. * prévoir fix ("delete infos")
  7074. */
  7075.  
  7076. /*--------------------------- Variables Globales -----------------------------*/
  7077.  
  7078. // Infos remplies par des scripts extérieurs
  7079. var listeCDM = [], listeLevels = [];
  7080.  
  7081. // Position actuelle
  7082. var currentPosition=[0,0,0];
  7083.  
  7084. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7085. var porteeVue=[0,0,0,0];
  7086.  
  7087. // Fenêtres déplaçables
  7088. var winCurr = null;
  7089. var offsetX, offsetY;
  7090. document.onmousemove = drag;
  7091.  
  7092. // Diplomatie
  7093. var Diplo = {
  7094. Guilde: {},
  7095. Troll: {},
  7096. Monstre: {}
  7097. // .mythiques: uniquement si option activée
  7098. };
  7099. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7100.  
  7101. // Infos tactiques
  7102. var popup;
  7103.  
  7104. // Gère l'affichage en cascade des popups de CdM
  7105. var nbCDM = 0;
  7106.  
  7107. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7108.  
  7109. // Utilisé pour supprimer les monstres "engagés"
  7110. var listeEngages = {};
  7111. var isEngagesComputed = false;
  7112. var cursorOnLink = false; // DEBUG: wtf ?
  7113.  
  7114. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7115. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7116.  
  7117. // Checkboxes de filtrage
  7118. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7119. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7120. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  7121. comboBoxNiveauMin, comboBoxNiveauMax;
  7122.  
  7123. /* Acquisition & Stockage des données de DB */
  7124. const typesAFetcher = {
  7125. 'monstres':1,
  7126. 'trolls':1,
  7127. 'tresors':1,
  7128. 'champignons':1,
  7129. 'lieux':1
  7130. }
  7131. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7132. tr_champignons = {}, tr_lieux = {};
  7133. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7134. nbChampignons = 0, nbLieux = 0;
  7135.  
  7136. function fetchData(type) {
  7137. try {
  7138. var node = document.getElementById('mh_vue_hidden_'+type);
  7139. // this = MZ.global = sandBox de travail de MZ
  7140. // On définit donc des variables MZ-globales
  7141. this['tr_'+type] = node.getElementsByTagName('tr');
  7142. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7143. } catch(e) {
  7144. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7145. }
  7146. }
  7147.  
  7148.  
  7149. /*---------------------------------- DEBUG -----------------------------------*/
  7150. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7151. var x_monstres = tr_monstres;
  7152. var x_trolls = tr_trolls;
  7153. var x_tresors = tr_tresors;
  7154. var x_champis = tr_champignons;
  7155. var x_lieux = tr_lieux;
  7156. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7157.  
  7158.  
  7159. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7160.  
  7161. function positionToString(arr) {
  7162. return arr.join(';');
  7163. }
  7164.  
  7165. function savePosition() {
  7166. // Stocke la position (à jour) de la vue pour les autres scripts
  7167. // DEBUG: Lesquels et pourquoi?
  7168. var pos = getPosition();
  7169. MY_setValue(numTroll+'.position.X',pos[0]);
  7170. MY_setValue(numTroll+'.position.Y',pos[1]);
  7171. MY_setValue(numTroll+'.position.N',pos[2]);
  7172. }
  7173.  
  7174.  
  7175. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7176. /* INFOS :
  7177. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7178. * sont identifiables via leur Name
  7179. * les tables-listings sont identifiables via l'ID du tr conteneur
  7180. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7181. */
  7182.  
  7183. /* [functions] Récup données Utilisateur */
  7184. function getPosition() {
  7185. // Pour rétrocompatibilité
  7186. return currentPosition;
  7187. }
  7188.  
  7189. function getPorteVue() {
  7190. // Pour rétrocompatibilité
  7191. return porteeVue;
  7192. }
  7193.  
  7194. function getVue() {
  7195. // Retourne [vueHpure, vueVpure]
  7196. var vues = getPorteVue();
  7197. return [ vues[0], vues[1] ];
  7198. }
  7199.  
  7200. // Roule 11/03/2016
  7201. /* [functions] Récup données monstres, trolls, etc. */
  7202. function getXxxDistance(xxx, i) {
  7203. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7204. }
  7205. function getXxxPosition(xxx, i) {
  7206. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7207. var l = tds.length;
  7208. return [
  7209. parseInt(tds[l-3].textContent),
  7210. parseInt(tds[l-2].textContent),
  7211. parseInt(tds[l-1].textContent)
  7212. ];
  7213. }
  7214.  
  7215.  
  7216. /* [functions] Récup données monstres */
  7217. function getMonstreDistance(i) {
  7218. return parseInt(tr_monstres[i].cells[0].textContent);
  7219. }
  7220.  
  7221. function getMonstreID(i) {
  7222. return tr_monstres[i].cells[2].firstChild.nodeValue;
  7223. }
  7224.  
  7225. function getMonstreIDByTR(tr) {
  7226. return tr.cells[2].firstChild.nodeValue;
  7227. }
  7228.  
  7229. function getMonstreLevelNode(i) {
  7230. return tr_monstres[i].cells[3];
  7231. }
  7232.  
  7233. function getMonstreLevel(i) {
  7234. if(!isCDMsRetrieved) return -1;
  7235. var donneesMonstre = listeCDM[getMonstreID(i)];
  7236. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  7237. }
  7238.  
  7239. function getMonstreNomNode(i) {
  7240. try {
  7241. var td = document.evaluate(
  7242. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  7243. tr_monstres[i], null, 9, null
  7244. ).singleNodeValue;
  7245. return td;
  7246. } catch(e) {
  7247. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  7248. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  7249. }
  7250. }
  7251.  
  7252. function getMonstreNom(i) {
  7253. return getMonstreNomByTR(tr_monstres[i]);
  7254. }
  7255.  
  7256. function getMonstreNomByTR(tr) {
  7257. try {
  7258. var nom = document.evaluate(
  7259. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  7260. tr, null, 2, null
  7261. ).stringValue;
  7262. return nom;
  7263. } catch(e) {
  7264. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  7265. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  7266. }
  7267. }
  7268.  
  7269. function getMonstrePosition(i) {
  7270. var tds = tr_monstres[i].childNodes;
  7271. var l = tds.length;
  7272. return [
  7273. parseInt(tds[l-3].textContent),
  7274. parseInt(tds[l-2].textContent),
  7275. parseInt(tds[l-1].textContent)
  7276. ];
  7277. }
  7278.  
  7279. function appendMonstres(txt) {
  7280. for(var i=1; i<=nbMonstres ; i++)
  7281. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  7282. return txt;
  7283. }
  7284.  
  7285. function getMonstres() {
  7286. var vue = getVue();
  7287. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7288. }
  7289.  
  7290. function bddMonstres(start,stop) {
  7291. if(!start) { var start = 1; }
  7292. if(!stop) { var stop = nbMonstres; }
  7293. stop = Math.min(nbMonstres,stop);
  7294. var txt='';
  7295. for(var i=start ; i<=stop ; i++) {
  7296. txt += getMonstreID(i)+';'+
  7297. getMonstreNom(i)+';'+
  7298. positionToString(getMonstrePosition(i))+'\n';
  7299. }
  7300. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  7301. }
  7302.  
  7303. /* [functions] Récup données Trolls */
  7304. function getTrollDistance(i) {
  7305. return parseInt(tr_trolls[i].cells[0].textContent);
  7306. }
  7307.  
  7308. function getTrollID(i) {
  7309. return parseInt(tr_trolls[i].cells[2].textContent);
  7310. }
  7311.  
  7312. function getTrollNomNode(i) {
  7313. var isEnvoiOn =
  7314. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  7315. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  7316. }
  7317.  
  7318. function getTrollNivNode(i) {
  7319. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  7320. return tr_trolls[i].cells[4];
  7321. }
  7322.  
  7323. function getTrollGuilde(i) {
  7324. return trim(tr_trolls[i].cells[6].textContent);
  7325. }
  7326.  
  7327. function getTrollGuildeID(i) {
  7328. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  7329. var href;
  7330. try {
  7331. 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"
  7332. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  7333. } catch(e) { // debug pb remonté par Marsak
  7334. window.console.error(traceStack(e, 'getTrollGuildeID')
  7335. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  7336. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  7337. return -1;
  7338. }
  7339. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  7340. }
  7341. return -1;
  7342. }
  7343.  
  7344. function getTrollPosition(i) {
  7345. var tds = tr_trolls[i].childNodes;
  7346. var l = tds.length;
  7347. return [
  7348. parseInt(tds[l-3].textContent),
  7349. parseInt(tds[l-2].textContent),
  7350. parseInt(tds[l-1].textContent)
  7351. ];
  7352. }
  7353.  
  7354. function bddTrolls() {
  7355. var txt='#DEBUT TROLLS\n'+
  7356. numTroll+';'+positionToString(getPosition())+'\n';
  7357. for(var i=1 ; i<=nbTrolls ; i++) {
  7358. txt += getTrollID(i)+';'+
  7359. positionToString(getTrollPosition(i))+'\n';
  7360. }
  7361. return txt+'#FIN TROLLS';
  7362. }
  7363.  
  7364. /* [functions] Récup données Trésors */
  7365. function getTresorDistance(i) {
  7366. return tr_tresors[i].cells[0].firstChild.nodeValue;
  7367. }
  7368.  
  7369. function getTresorID(i) {
  7370. return trim(tr_tresors[i].cells[2].textContent);
  7371. }
  7372.  
  7373. function getTresorNom(i) {
  7374. // Utilisation de textContent pour régler le "bug de Pollux"
  7375. return trim(tr_tresors[i].cells[3].textContent);
  7376. }
  7377.  
  7378. function getTresorPosition(i) {
  7379. var tds = tr_tresors[i].childNodes;
  7380. var l = tds.length;
  7381. return [
  7382. parseInt(tds[l-3].textContent),
  7383. parseInt(tds[l-2].textContent),
  7384. parseInt(tds[l-1].textContent),
  7385. ];
  7386. }
  7387.  
  7388. function bddTresors(dmin,start,stop) {
  7389. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  7390. if(!dmin) { var dmin = 0; }
  7391. if(!start) { var start = 1; }
  7392. if(!stop) { var stop = nbTresors; }
  7393. stop = Math.min(nbTresors,stop);
  7394. var txt='';
  7395. for(var i=start ; i<=stop ; i++) {
  7396. if(getTresorDistance(i)>=dmin) {
  7397. txt += getTresorID(i)+';'+
  7398. getTresorNom(i)+';'+
  7399. positionToString(getTresorPosition(i))+'\n';
  7400. }
  7401. }
  7402. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  7403. }
  7404.  
  7405. /* [functions] Récup données Champignons */
  7406. // DEBUG: Pas de colonne "Référence" sur serveur de test
  7407. function getChampignonNom(i) {
  7408. return trim(tr_champignons[i].cells[2].textContent);
  7409. }
  7410.  
  7411. function getChampignonPosition(i) {
  7412. var tds = tr_champignons[i].childNodes;
  7413. var l = tds.length;
  7414. return [
  7415. parseInt(tds[l-3].textContent),
  7416. parseInt(tds[l-2].textContent),
  7417. parseInt(tds[l-1].textContent)
  7418. ];
  7419. }
  7420.  
  7421. function bddChampignons() {
  7422. var txt='';
  7423. for(var i=1 ; i<=nbChampignons ; i++) {
  7424. txt += ';'+ // Les champis n'ont pas de Référence
  7425. getChampignonNom(i)+';'+
  7426. positionToString(getChampignonPosition(i))+'\n';
  7427. }
  7428. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  7429. }
  7430.  
  7431. /* [functions] Récup données Lieux */
  7432. function getLieuDistance(i) {
  7433. return parseInt(tr_lieux[i].cells[0].textContent);
  7434. }
  7435.  
  7436. function getLieuID(i) {
  7437. return parseInt(tr_lieux[i].cells[2].textContent);
  7438. }
  7439.  
  7440. function getLieuNom(i) {
  7441. // Conversion ASCII pour éviter les bugs des Vues externes
  7442. return trim(tr_lieux[i].cells[3].textContent);
  7443. }
  7444.  
  7445. function getLieuPosition(i) {
  7446. var tds = tr_lieux[i].childNodes;
  7447. var l = tds.length;
  7448. return [
  7449. parseInt(tds[l-3].textContent),
  7450. parseInt(tds[l-2].textContent),
  7451. parseInt(tds[l-1].textContent)
  7452. ];
  7453. }
  7454.  
  7455. function appendLieux(txt) {
  7456. for(var i = 1; i < nbLieux+1; i++) {
  7457. var tds = x_lieux[i].childNodes;
  7458. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  7459. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  7460. }
  7461. return txt;
  7462. }
  7463.  
  7464. function getLieux() {
  7465. var vue = getVue();
  7466. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7467. }
  7468.  
  7469. function bddLieux(start,stop) {
  7470. if(!start) { var start = 1; }
  7471. if(!stop) { var stop = nbLieux; }
  7472. stop = Math.min(nbLieux,stop);
  7473. var txt='';
  7474. for(var i=start ; i<=stop ; i++) {
  7475. txt += getLieuID(i)+';'+
  7476. epure(getLieuNom(i))+';'+
  7477. positionToString(getLieuPosition(i))+'\n';
  7478. }
  7479. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  7480. }
  7481.  
  7482.  
  7483. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  7484.  
  7485. function saveCheckBox(chkbo, pref) {
  7486. // Enregistre et retourne l'état d'une CheckBox
  7487. var etat = chkbo.checked;
  7488. MY_setValue(pref, etat ? 'true' : 'false' );
  7489. return etat;
  7490. }
  7491.  
  7492. function recallCheckBox(chkbox, pref) {
  7493. // Restitue l'état d'une CheckBox
  7494. chkbox.checked = (MY_getValue(pref)=='true');
  7495. }
  7496.  
  7497. function saveComboBox(cbb, pref) {
  7498. // Enregistre et retourne l'état d'une ComboBox
  7499. var etat = cbb.selectedIndex;
  7500. MY_setValue(pref, etat);
  7501. return etat;
  7502. }
  7503.  
  7504. function recallComboBox(cbb, pref) {
  7505. // Restitue l'état d'une ComboBox
  7506. var nb = MY_getValue(pref);
  7507. if(nb) cbb.value = nb;
  7508. return nb;
  7509. }
  7510.  
  7511. function synchroniseFiltres() {
  7512. // Récupération de toutes les options de la vue
  7513. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  7514. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  7515. if(numBool) {
  7516. debutFiltrage('Monstres');
  7517. }
  7518. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  7519. recallCheckBox(checkBoxMythiques,'NOMYTH');
  7520. recallCheckBox(checkBoxEngages,'NOENGAGE');
  7521. recallCheckBox(checkBoxLevels,'NOLEVEL');
  7522. recallCheckBox(checkBoxIntangibles,'NOINT');
  7523. recallCheckBox(checkBoxGG,'NOGG');
  7524. recallCheckBox(checkBoxCompos,'NOCOMP');
  7525. recallCheckBox(checkBoxBidouilles,'NOBID');
  7526. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  7527. recallCheckBox(checkBoxTrou,'NOTROU');
  7528. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  7529. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  7530. if(MY_getValue('NOINFOEM')!='true')
  7531. recallCheckBox(checkBoxEM,'NOEM');
  7532. }
  7533.  
  7534.  
  7535. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  7536.  
  7537. /* [functions] Menu Vue 2D */
  7538. var vue2Ddata = {
  7539. 'Bricol\' Vue': {
  7540. url: URL_bricol_mountyhall + 'vue_form.php',
  7541. paramid: 'vue',
  7542. func: getVueScript,
  7543. extra_params: {
  7544. 'mode': 'vue_SP_Vue2',
  7545. 'screen_width': window.screen.width
  7546. }
  7547. },
  7548. 'Vue du CCM': {
  7549. url: URL_vue_CCM,
  7550. paramid: 'vue',
  7551. func: getVueScript,
  7552. extra_params: {
  7553. 'id': numTroll+';'+positionToString(getPosition())
  7554. }
  7555. },
  7556. 'Vue Gloumfs 2D': {
  7557. url: URL_vue_Gloumfs2D,
  7558. paramid: 'vue_mountyzilla',
  7559. func: getVueScript,
  7560. extra_params: {}
  7561. },
  7562. 'Vue Gloumfs 3D': {
  7563. url: URL_vue_Gloumfs3D,
  7564. paramid: 'vue_mountyzilla',
  7565. func: getVueScript,
  7566. extra_params: {}
  7567. },
  7568. 'Grouky Vue!': {
  7569. url: URL_vue_Grouky,
  7570. paramid: 'vue',
  7571. func: getVueScript,
  7572. extra_params: {
  7573. 'type_vue': 'V5b1'
  7574. }
  7575. },
  7576. /*'DEBUG': {
  7577. url: 'http://weblocal/testeur.php',
  7578. paramid: 'vue',
  7579. func: getVueScript,
  7580. extra_params: {}
  7581. }*/
  7582. };
  7583.  
  7584. function getVueScript() {
  7585. try {
  7586. var txt = bddTrolls()+
  7587. bddMonstres()+
  7588. bddChampignons()+
  7589. bddTresors()+
  7590. bddLieux()+
  7591. '#DEBUT ORIGINE\n'+
  7592. getPorteVue()[2]+';'+positionToString(getPosition())+
  7593. '\n#FIN ORIGINE\n';
  7594. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  7595. return txt;
  7596. } catch(e) {
  7597. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7598. window.console.error(traceStack(e, 'getVueScript'))
  7599. }
  7600. }
  7601.  
  7602. function refresh2DViewButton() {
  7603. // = EventListener menu+bouton vue 2D
  7604. var vueext = document.getElementById('selectVue2D').value;
  7605. MY_setValue('VUEEXT',vueext);
  7606. var form = document.getElementById('viewForm');
  7607. form.innerHTML = '';
  7608. form.method = 'post';
  7609. form.action = vue2Ddata[vueext].url;
  7610. form.target = '_blank';
  7611. appendHidden(form, vue2Ddata[vueext].paramid, '');
  7612. for(var key in vue2Ddata[vueext].extra_params) {
  7613. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  7614. }
  7615. appendSubmit(form, 'Voir',
  7616. function() {
  7617. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  7618. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  7619. vue2Ddata[vueext].func();
  7620. }
  7621. );
  7622. }
  7623.  
  7624. function set2DViewSystem() {
  7625. // Initialise le système de vue 2D
  7626. // Recherche du point d'insertion
  7627. try {
  7628. var center = document.evaluate(
  7629. "//h2[@id='titre2']/following-sibling::center",
  7630. document, null, 9, null
  7631. ).singleNodeValue;
  7632. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  7633. if (!center) center = document.evaluate(
  7634. "//h2[@id='titre2']/following-sibling::div",
  7635. document, null, 9, null
  7636. ).singleNodeValue;
  7637. } catch(e) {
  7638. avertissement("Erreur d'initialisation du système de vue 2D");
  7639. window.console.error(traceStack(e, 'set2DViewSystem'));
  7640. return;
  7641. }
  7642. // Récupération de la dernière vue utilisée
  7643. var vueext = MY_getValue('VUEEXT');
  7644. if(!vueext || !vue2Ddata[vueext]) {
  7645. // sinon, la vue Bricol'Trolls est employée par défaut
  7646. vueext = 'Bricol\' Vue';
  7647. }
  7648. try {
  7649. // Création du sélecteur de vue externe
  7650. selectVue2D = document.createElement('select');
  7651. selectVue2D.id = 'selectVue2D';
  7652. selectVue2D.className = 'SelectboxV2';
  7653. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  7654. for(var view in vue2Ddata) {
  7655. appendOption(selectVue2D, view, view);
  7656. }
  7657. selectVue2D.value = vueext;
  7658. selectVue2D.onchange = refresh2DViewButton;
  7659. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  7660. var form = document.createElement('form');
  7661. form.id = 'viewForm';
  7662. // Insertion du système de vue
  7663. var table = document.createElement('table');
  7664. var tr = appendTr(table);
  7665. var td = appendTd(tr);
  7666. td.appendChild(selectVue2D);
  7667. td = appendTd(tr);
  7668. td.style.fontSize = '0px'; // gère le bug de l'extra character
  7669. td.appendChild(form);
  7670. center.insertBefore(table,center.firstChild);
  7671. insertBr(center.childNodes[1]);
  7672. // Appelle le handler pour initialiser le bouton de submit
  7673. refresh2DViewButton();
  7674. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  7675. } catch(e) {
  7676. avertissement("Erreur de traitement du système de vue 2D");
  7677. window.console.error(traceStack(e, 'set2DViewSystem'));
  7678. }
  7679. }
  7680.  
  7681. /* [functions] Tableau d'Infos */
  7682. function initialiseInfos() {
  7683. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  7684. var
  7685. infoTab = document.getElementsByName('LimitViewForm')[0].
  7686. getElementsByTagName('table')[0],
  7687. tbody = infoTab.tBodies[0],
  7688. thead = infoTab.createTHead(),
  7689. tr = appendTr(thead,'mh_tdtitre'),
  7690. td = appendTdText(tr,'INFORMATIONS',true),
  7691. span = document.createElement('span');
  7692. // Récupération de la position du joueur
  7693. try {
  7694. var strPos = document.evaluate(
  7695. ".//li/b/text()[contains(.,'X = ')]",
  7696. infoTab, null, 9, null
  7697. ).singleNodeValue.nodeValue;
  7698. // ***INIT GLOBALE*** currentPosition
  7699. currentPosition = getNumbers(strPos);
  7700. debugMZ("retrievePosition(): "+currentPosition);
  7701. } catch(e) {
  7702. // Si on ne trouve pas le "X ="
  7703. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  7704. }
  7705. // Récupération des portées (max et limitée) de la vue
  7706. try {
  7707. var
  7708. nodes = document.evaluate(
  7709. ".//li/b/text()[contains(.,'horizontalement') "+
  7710. "or contains(.,'verticalement')]",
  7711. infoTab, null, 7, null
  7712. ),
  7713. array = [];
  7714. for(var i=0 ; i<4 ; i++) {
  7715. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  7716. }
  7717. // ***INIT GLOBALE*** porteeVue
  7718. porteeVue = array;
  7719. } catch(e) {
  7720. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  7721. }
  7722.  
  7723. infoTab.id = 'infoTab'; // Pour scripts externes
  7724. tbody.id = 'corpsInfoTab';
  7725. tbody.rows[0].cells[0].colSpan = 2;
  7726. td.colSpan = 3;
  7727. td.onmouseover = function() {
  7728. this.style.cursor = 'pointer';
  7729. this.className = 'mh_tdpage';
  7730. };
  7731. td.onmouseout = function() {
  7732. this.className = 'mh_tdtitre';
  7733. };
  7734. td.onclick = function() {
  7735. toggleTableauInfos(false);
  7736. };
  7737. span.id = 'msgInfoTab';
  7738. span.style.display = 'none';
  7739. appendText(
  7740. span,
  7741. ' => Position : X = '+currentPosition[0]+
  7742. ', Y = '+currentPosition[1]+
  7743. ', N = '+currentPosition[2]+
  7744. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  7745. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  7746. true
  7747. );
  7748. td.appendChild(span);
  7749. tr = appendTr(tbody,'mh_tdpage');
  7750. td = appendTdText(tr,'EFFACER : ',true);
  7751. td.align = 'center';
  7752. td.className = 'mh_tdtitre';
  7753. td.width = 100;
  7754. td = appendTdCenter(tr,2);
  7755. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  7756. checkBoxGG = appendCheckBoxSpan(
  7757. td,'delgg',filtreTresors," Les GG'"
  7758. ).firstChild;
  7759. checkBoxCompos = appendCheckBoxSpan(
  7760. td,'delcomp',filtreTresors,' Les Compos'
  7761. ).firstChild;
  7762. checkBoxBidouilles = appendCheckBoxSpan(
  7763. td,'delbid',filtreTresors,' Les Bidouilles'
  7764. ).firstChild;
  7765. checkBoxIntangibles = appendCheckBoxSpan(
  7766. td,'delint',filtreTrolls,' Les Intangibles'
  7767. ).firstChild;
  7768. checkBoxGowaps = appendCheckBoxSpan(
  7769. td,'delgowap',filtreMonstres,' Les Gowaps'
  7770. ).firstChild;
  7771. checkBoxEngages = appendCheckBoxSpan(
  7772. td,'delengage',filtreMonstres,' Les Engagés'
  7773. ).firstChild;
  7774. checkBoxLevels = appendCheckBoxSpan(
  7775. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  7776. ).firstChild;
  7777. checkBoxDiplo = appendCheckBoxSpan(
  7778. td,'delDiplo',refreshDiplo,' La Diplomatie'
  7779. ).firstChild;
  7780. checkBoxTrou = appendCheckBoxSpan(
  7781. td,'deltrou',filtreLieux,' Les Trous'
  7782. ).firstChild;
  7783. checkBoxMythiques = appendCheckBoxSpan(
  7784. td,'delmyth',filtreMonstres,' Les Mythiques'
  7785. ).firstChild;
  7786. if(MY_getValue('NOINFOEM')!='true') {
  7787. checkBoxEM = appendCheckBoxSpan(
  7788. td,'delem',filtreMonstres,' Les Composants EM'
  7789. ).firstChild;
  7790. }
  7791. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  7792. td,'deltres',filtreTresors,' Les Trésors non libres'
  7793. ).firstChild;
  7794. checkBoxTactique = appendCheckBoxSpan(
  7795. td,'deltactique',updateTactique,' Les Infos tactiques'
  7796. ).firstChild;
  7797. if(MY_getValue('INFOPLIE')) {
  7798. toggleTableauInfos(true);
  7799. }
  7800. }
  7801.  
  7802. function toggleTableauInfos(firstRun) {
  7803. var
  7804. msg = document.getElementById('msgInfoTab'),
  7805. corps = document.getElementById('corpsInfoTab'),
  7806. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7807. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  7808. if(!firstRun) {
  7809. infoplie = !infoplie;
  7810. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  7811. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  7812. }
  7813. if(infoplie) {
  7814. msg.style.display = '';
  7815. corps.style.display = 'none';
  7816. } else {
  7817. msg.style.display = 'none';
  7818. corps.style.display = '';
  7819. }
  7820. }
  7821.  
  7822. /* [functions] Filtres */
  7823. function prepareFiltrage(ref,width) {
  7824. // = Initialise le filtre 'ref'
  7825. try {
  7826. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  7827. } catch(e) {
  7828. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  7829. return false;
  7830. }
  7831. if(width) { tdTitre.width = width; }
  7832. // Ajout du tr de Filtrage (masqué)
  7833. var tbody = tdTitre.parentNode.parentNode;
  7834. var tr = appendTr(tbody,'mh_tdpage');
  7835. tr.style.display = 'none';
  7836. tr.id = 'trFiltre'+ref;
  7837. var td = appendTd(tr);
  7838. td.colSpan = 5;
  7839. // Ajout du bouton de gestion de Filtrage
  7840. var tdBtn = insertTd(tdTitre.nextSibling);
  7841. tdBtn.id = 'tdInsert'+ref;
  7842. var btn = appendButton(tdBtn,'Filtrer');
  7843. btn.id = 'btnFiltre'+ref;
  7844. btn.onclick = function() {
  7845. debutFiltrage(ref)
  7846. };
  7847. return td;
  7848. }
  7849.  
  7850. function debutFiltrage(ref) {
  7851. // = Handler de début de filtrage (filtre 'ref')
  7852. document.getElementById('trFiltre'+ref).style.display = '';
  7853. var btn = document.getElementById('btnFiltre'+ref);
  7854. btn.value = 'Annuler Filtre';
  7855. btn.onclick = function() {
  7856. finFiltrage(ref);
  7857. };
  7858. }
  7859.  
  7860. function finFiltrage(ref) {
  7861. // = Handler de fin de filtrage (filtre 'ref')
  7862. /* On réassigne le bouton 'Filtrer' */
  7863. document.getElementById('trFiltre'+ref).style.display = 'none';
  7864. var btn = document.getElementById('btnFiltre'+ref);
  7865. btn.value = 'Filtrer';
  7866. btn.onclick = function() {
  7867. debutFiltrage(ref);
  7868. };
  7869. /* Réinitialisation filtres */
  7870. document.getElementById('str'+ref).value = '';
  7871. switch(ref) {
  7872. case 'Monstres':
  7873. document.getElementById('nivMinMonstres').value = 0;
  7874. document.getElementById('nivMaxMonstres').value = 0;
  7875. break;
  7876. case 'Trolls':
  7877. document.getElementById('strGuildes').value = '';
  7878. }
  7879. /* Nettoyage (=lance le filtre) */
  7880. // Ici this = MZ.global = sandBox de travail de MZ
  7881. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  7882. //this['filtre'+ref]();
  7883. switch (ref) {
  7884. case 'Monstres':
  7885. filtreMonstres();
  7886. break;
  7887. case 'Trolls':
  7888. filtreTrolls();
  7889. break;
  7890. case 'Tresors':
  7891. filtreTresors();
  7892. break;
  7893. case 'Lieux':
  7894. filtreLieux();
  7895. break;
  7896. default:
  7897. window.console.log('cas incongru dans finFiltrage : ' + ref);
  7898. break;
  7899. }
  7900. }
  7901.  
  7902. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  7903. var bouton = appendButton(td,nomBouton,onClick);
  7904. appendText(td,'\u00a0');
  7905. var textbox = appendTextbox(td,'text',id,15,30);
  7906. textbox.onkeypress = function(event) {
  7907. try {
  7908. if(event.keyCode==13) {
  7909. event.preventDefault();
  7910. bouton.click();
  7911. }
  7912. }
  7913. catch(e){
  7914. window.alert(e)
  7915. }
  7916. };
  7917. }
  7918.  
  7919. function ajoutFiltreMenu(tr,id,onChange) {
  7920. var select = document.createElement('select');
  7921. select.id = id;
  7922. select.onchange = onChange;
  7923. appendOption(select,0,'Aucun');
  7924. for(var i=1 ; i<=60 ; i++) {
  7925. appendOption(select,i,i);
  7926. }
  7927. tr.appendChild(select);
  7928. return select;
  7929. }
  7930.  
  7931. function ajoutDesFiltres() {
  7932. /* Monstres */
  7933. var td = prepareFiltrage('Monstres',120);
  7934. if(td) {
  7935. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  7936. appendText(td,'\u00a0\u00a0\u00a0');
  7937. appendText(td,'Niveau Min: ');
  7938. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  7939. appendText(td,'\u00a0');
  7940. appendText(td,'Niveau Max: ');
  7941. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  7942. }
  7943. /* Trõlls */
  7944. td = prepareFiltrage('Trolls',50);
  7945. if(td) {
  7946. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  7947. appendText(td,'\u00a0\u00a0\u00a0');
  7948. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  7949. }
  7950. /* Trésors */
  7951. td = prepareFiltrage('Tresors',55);
  7952. if(td) {
  7953. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  7954. }
  7955. /* Lieux */
  7956. td = prepareFiltrage('Lieux',40);
  7957. if(td) {
  7958. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  7959. }
  7960. }
  7961.  
  7962. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  7963.  
  7964. /* [functions] Affichage de la colonne des niveaux */
  7965. function insertLevelColumn() {
  7966. // Déclenché si bascule vers affichage des niveaux des mobs
  7967. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7968. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  7969. td.width = 25;
  7970. for(var i=1 ; i<=nbMonstres ; i++) {
  7971. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  7972. td = insertTdText(getMonstreLevelNode(i), '-');
  7973. td.onclick = function() {
  7974. basculeCDM(
  7975. getMonstreNomByTR(this.parentNode),
  7976. getMonstreIDByTR(this.parentNode)
  7977. );
  7978. };
  7979. td.onmouseover = function() {
  7980. this.style.cursor = 'pointer';
  7981. this.className = 'mh_tdtitre';
  7982. };
  7983. td.onmouseout = function() {
  7984. if(this.parentNode.diploActive=='oui') {
  7985. this.className = '';
  7986. } else {
  7987. this.className = 'mh_tdpage';
  7988. }
  7989. };
  7990. td.style = 'font-weight:bold;text-align:center;';
  7991. if(isCDMsRetrieved) {
  7992. // Rappel des niveaux si mémorisés
  7993. td.innerHTML = listeLevels[i];
  7994. }
  7995. }
  7996. }
  7997.  
  7998. function toggleLevelColumn() {
  7999. // = Handler checkBox noLevel
  8000. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8001. insertLevelColumn();
  8002. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8003. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8004. for(var i=0 ; i<=nbMonstres ; i++) {
  8005. if(isCDMsRetrieved) {
  8006. // Mémorisation des niveaux pour rappel éventuel
  8007. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8008. }
  8009. // Suppression du td Niveau
  8010. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8011. }
  8012. }
  8013. }
  8014.  
  8015. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8016. function basculeCDM(nom,id) {
  8017. // = Bascule l'affichage des popups CdM
  8018. if(listeCDM[id]) {
  8019. if(!document.getElementById('popupCDM'+id)) {
  8020. afficherCDM(nom, id);
  8021. } else {
  8022. cacherPopupCDM('popupCDM'+id);
  8023. }
  8024. }
  8025. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8026. }
  8027.  
  8028. function cacherPopupCDM(titre) {
  8029. var popup = document.getElementById(titre);
  8030. popup.parentNode.removeChild(popup);
  8031. }
  8032.  
  8033. /* DEBUG: Section à mettre à jour */
  8034. var selectionFunction;
  8035.  
  8036. function startDrag(evt) {
  8037. winCurr = this.parentNode;
  8038. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8039. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8040. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8041. selectionFunction = document.body.style.MozUserSelect;
  8042. document.body.style.MozUserSelect = 'none';
  8043. winCurr.style.MozUserSelect = 'none';
  8044. return false;
  8045. }
  8046.  
  8047. function stopDrag(evt) {
  8048. winCurr.style.MozUserSelect = selectionFunction;
  8049. document.body.style.MozUserSelect = selectionFunction;
  8050. winCurr = null;
  8051. }
  8052.  
  8053. function drag(evt) {
  8054. if(winCurr==null) { return; }
  8055. evt = evt || window.event;
  8056. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8057. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8058. return false;
  8059. }
  8060. /* FIN DEBUG */
  8061.  
  8062. function afficherCDM(nom,id) {
  8063. // Crée la table de CdM du mob n° id
  8064. var donneesMonstre = listeCDM[id];
  8065. /* Début création table */
  8066. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8067. table.id = 'popupCDM'+id;
  8068. table.style =
  8069. 'position:fixed;'+
  8070. 'z-index:1;'+
  8071. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8072. 'left:'+(window.innerWidth-365)+'px;'+
  8073. 'width:300px;'+
  8074. 'height:200px;';
  8075. /* Ajout du titre avec gestion Drag & Drop */
  8076. var tr = table.firstChild;
  8077. tr.style.cursor = 'move';
  8078. tr.onmousedown = startDrag;
  8079. tr.onmouseup = stopDrag;
  8080. /* Ajout du bouton "Fermer" */
  8081. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8082. tr.onmouseover = function() {
  8083. this.style.cursor = 'pointer';
  8084. this.className = 'mh_tdpage';
  8085. };
  8086. tr.onmouseout = function() {
  8087. this.className = 'mh_tdtitre';
  8088. };
  8089. tr.idcdm = id;
  8090. tr.onclick = function() {
  8091. cacherPopupCDM('popupCDM'+this.idcdm);
  8092. this.className = 'mh_tdtitre';
  8093. };
  8094. td = appendTdText(tr,'Fermer',true);
  8095. td.colSpan = 2;
  8096. td.style = 'text-align:center;';
  8097. nbCDM++;
  8098. /* Fin création table & Affichage */
  8099. document.body.appendChild(table);
  8100. }
  8101.  
  8102. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8103. function initPopupVue() {
  8104. popup = document.createElement('div');
  8105. popup.id = 'popup';
  8106. popup.className = 'mh_textbox';
  8107. popup.style =
  8108. 'position: absolute;'+
  8109. 'border: 1px solid #000000;'+
  8110. 'visibility: hidden;'+
  8111. 'display: inline;'+
  8112. 'z-index: 3;'+
  8113. 'max-width: 400px;';
  8114. document.body.appendChild(popup);
  8115. }
  8116.  
  8117. // roule 16/03/2016 supprimé, existe déjà dans vue
  8118. // function showPopupTactique(evt) {
  8119. // var id = this.id;
  8120. // var nom = this.nom;
  8121. // var texte = getAnalyseTactique(id,nom);
  8122. // if(texte=='') { return; }
  8123. // popup.innerHTML = texte;
  8124. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  8125. // popup.style.top = (evt.pageY+15)+'px';
  8126. // popup.style.visibility = 'visible';
  8127. // }
  8128.  
  8129. // roule 16/03/2016, existe déjà ailleurs
  8130. // function hidePopup() {
  8131. // popup.style.visibility = 'hidden';
  8132. // }
  8133.  
  8134. /* [functions] Récupération / Computation des Infos Tactiques */
  8135. // TODO à revoir
  8136. function retireMarquage(nom) {
  8137. var i = nom.indexOf(']');
  8138. switch(i) {
  8139. case -1:
  8140. case nom.length-1:
  8141. return nom;
  8142. default:
  8143. return nom.slice(0,i+1);
  8144. }
  8145. }
  8146.  
  8147. function showPopupError(sHTML) {
  8148. var divpopup = document.createElement('div');
  8149. divpopup.id = 'divpopup';
  8150. divpopup.style =
  8151. 'position: fixed;'+
  8152. 'border: 3px solid #000000;'+
  8153. 'top: 300px;left: 10px;'+
  8154. 'background-color: red;'+
  8155. 'color: white;'+
  8156. 'font-size: xx-large;'+
  8157. 'z-index: 200;';
  8158. divpopup.innerHTML = sHTML;
  8159. var divcroix = document.createElement('div');
  8160. divcroix.style =
  8161. 'position: absolute;'+
  8162. 'top: 0;right: 0;'+
  8163. 'color: inherit;'+
  8164. 'font-size: inherit;'+
  8165. 'cursor: pointer;'+
  8166. 'z-index: 201;';
  8167. divcroix.innerHTML = "X";
  8168. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8169. document.body.appendChild(divpopup);
  8170. divpopup.appendChild(divcroix);
  8171. }
  8172.  
  8173. function retrieveCDMs() {
  8174. // Récupère les CdM disponibles dans la BDD
  8175. // Lancé uniquement sur toggleLevelColumn
  8176. if(checkBoxLevels.checked) { return; }
  8177. var str = '';
  8178. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8179. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8180. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8181. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  8182. for(var i=1 ; i<=cdmMax ; i++) {
  8183. var nomMonstre = retireMarquage(getMonstreNom(i));
  8184. if(nomMonstre.indexOf(']') != -1) {
  8185. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  8186. }
  8187. // *** WARNING : PROXY RATIBUS ***
  8188. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  8189. str += 'nom[]='+escape(nomMonstre)+'$'+(
  8190. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  8191. )+'&';
  8192. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  8193. FF_XMLHttpRequest({
  8194. method: 'POST',
  8195. url: URL_MZinfoMonstre,
  8196. headers : {
  8197. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8198. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8199. 'Content-type':'application/x-www-form-urlencoded'
  8200. },
  8201. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  8202. onload: function(responseDetails) {
  8203. try {
  8204. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  8205. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  8206. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  8207. '" target="raistlin">Mountyzilla - https<br />'+
  8208. 'Tu dois accepter le certificat de Raistlin<br />'+
  8209. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  8210. ' « Confirmer l\'exception de sécurité »</a>');
  8211. return;
  8212. }
  8213. var texte = responseDetails.responseText;
  8214. var lines = texte.split('\n');
  8215. if(lines.length==0) { return; }
  8216. var begin2, end2, index;
  8217. for(var j=0 ; j<lines.length ; j++) {
  8218. var infos = lines[j].split(';');
  8219. if(infos.length<4) { continue; }
  8220. var idMonstre=infos[0];
  8221. var isCDM = infos[1];
  8222. index = parseInt(infos[2]);
  8223. var level = infos[3];
  8224. infos = infos.slice(3);
  8225. if(begin2==null) { begin2 = index; }
  8226. end2 = index;
  8227. listeCDM[idMonstre] = infos;
  8228. if(isCDM==1) {
  8229. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  8230. } else {
  8231. getMonstreLevelNode(index).innerHTML = level;
  8232. }
  8233. }
  8234. computeMission(begin2,end2);
  8235. } catch(e) {
  8236. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  8237. }
  8238. }
  8239. });
  8240. str = '';
  8241. begin = i+1;
  8242. }
  8243. }
  8244. isCDMsRetrieved=true;
  8245. }
  8246.  
  8247. function computeMission(begin,end) {
  8248. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  8249. computeVLC(begin,end);
  8250. if(!begin) begin=1;
  8251. if(!end) end=nbMonstres;
  8252. var str = MY_getValue(numTroll+'.MISSIONS');
  8253. if(!str) { return; }
  8254. var urlImg = URL_MZimg+'mission.png';
  8255. var obMissions = JSON.parse(str);
  8256. for(var i=end ; i>=begin ; i--) {
  8257. var mess = '';
  8258. for(var num in obMissions) {
  8259. var mobMission = false;
  8260. switch(obMissions[num].type) {
  8261. case 'Race':
  8262. var race = epure(obMissions[num].race.toLowerCase());
  8263. var nom = epure(getMonstreNom(i).toLowerCase());
  8264. if(nom.indexOf(race)!=-1) {
  8265. mobMission = true;
  8266. }
  8267. break;
  8268. case 'Niveau':
  8269. var donneesMonstre = listeCDM[getMonstreID(i)];
  8270. if(donneesMonstre) {
  8271. var nivMob = Number(donneesMonstre[0]);
  8272. var nivMimi = Number(obMissions[num].niveau),
  8273. mod = obMissions[num].mod;
  8274. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  8275. || (isNaN(mod) && nivMob>=nivMimi)) {
  8276. mobMission = true;
  8277. }
  8278. }
  8279. break;
  8280. case 'Famille':
  8281. var donneesMonstre = listeCDM[getMonstreID(i)];
  8282. if(donneesMonstre) {
  8283. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  8284. var familleMob = epure(donneesMonstre[1].toLowerCase());
  8285. if(familleMob.indexOf(familleMimi)!=-1) {
  8286. mobMission = true;
  8287. }
  8288. }
  8289. break;
  8290. case 'Pouvoir':
  8291. var donneesMonstre = listeCDM[getMonstreID(i)];
  8292. if(donneesMonstre) {
  8293. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  8294. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  8295. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8296. mobMission = true;
  8297. }
  8298. }
  8299. }
  8300. if(mobMission) {
  8301. mess += mess ? '\n\n' : '';
  8302. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8303. }
  8304. }
  8305. if(mess) {
  8306. var td = getMonstreNomNode(i);
  8307. appendText(td,' ');
  8308. td.appendChild(createImage(urlImg,mess));
  8309. }
  8310. }
  8311. }
  8312.  
  8313. function computeVLC(begin,end) {
  8314. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8315. computeTactique(begin,end);
  8316. if(!begin) begin=1;
  8317. if(!end) end=nbMonstres;
  8318. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8319. if(!cache)
  8320. return false;
  8321. var urlImg = URL_MZimg + "oeil.png";
  8322. for(var i = end; i >= begin;i--)
  8323. {
  8324. var id = getMonstreID(i);
  8325. var donneesMonstre = listeCDM[id];
  8326. if(donneesMonstre && donneesMonstre.length>12)
  8327. {
  8328. if(donneesMonstre[12]==1)
  8329. {
  8330. var td = getMonstreNomNode(i);
  8331. td.appendChild(document.createTextNode(" "));
  8332. td.appendChild(createImage(urlImg, "Voit le caché"));
  8333. }
  8334. }
  8335. }
  8336. }
  8337.  
  8338. function computeTactique(begin, end) {
  8339. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8340. try {
  8341. if(!begin) begin = 1;
  8342. if(!end) end = nbMonstres;
  8343. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8344. if(noTactique || !isProfilActif()) return;
  8345. for(var j=end ; j>=begin ; j--) {
  8346. var id = getMonstreID(j);
  8347. var nom = getMonstreNom(j);
  8348. var donneesMonstre = listeCDM[id];
  8349. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8350. var td = getMonstreNomNode(j);
  8351. appendText(td,' ');
  8352. td.appendChild(
  8353. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  8354. );
  8355. }
  8356. }
  8357. }
  8358. catch(e) {
  8359. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8360. }
  8361. filtreMonstres();
  8362. }
  8363.  
  8364. function updateTactique() {
  8365. // = Handler checkBox noTactique
  8366. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8367. if(!isCDMsRetrieved) return;
  8368. if(noTactique) {
  8369. for(var i=nbMonstres ; i>0 ; i--) {
  8370. var tr = getMonstreNomNode(i);
  8371. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  8372. tr, null, 9, null).singleNodeValue;
  8373. if(img) {
  8374. img.parentNode.removeChild(img.previousSibling);
  8375. img.parentNode.removeChild(img);
  8376. }
  8377. }
  8378. }
  8379. else
  8380. computeTactique();
  8381. }
  8382.  
  8383. function filtreMonstres() {
  8384. // = Handler universel pour les fonctions liées aux monstres
  8385. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  8386. urlEnchantImg = URL_MZimg+'images/enchant.png';
  8387. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  8388. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  8389. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  8390. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  8391. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  8392. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  8393. // old/new : détermine s'il faut ou non nettoyer les tr
  8394. var oldNOEM = true, noEM = true;
  8395. if(MY_getValue('NOINFOEM')!='true') {
  8396. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  8397. }
  8398. // Filtrage par nom
  8399. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  8400. // Génère la liste des mobs engagés (si filtrés)
  8401. if(noEngages && !isEngagesComputed) {
  8402. for(var i=nbTrolls ; i>0 ; i--) {
  8403. var pos = getTrollPosition(i);
  8404. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  8405. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  8406. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  8407. }
  8408. isEngagesComputed = true;
  8409. }
  8410. /*** FILTRAGE ***/
  8411. /* À computer :
  8412. * - EM (nom suffit)
  8413. * - Enchant (nom suffit)
  8414. * - Mission (nécessite CdM)
  8415. * - mob VlC (nécessite CdM)
  8416. * Sans computation :
  8417. * - Gowap ? engagé ?
  8418. */
  8419. for(var i=nbMonstres ; i>0 ; i--) {
  8420. var pos = getMonstrePosition(i);
  8421. var nom = getMonstreNom(i).toLowerCase();
  8422. if(noEM!=oldNOEM) {
  8423. if(noEM) {
  8424. // Si noEM passe de false à true, on nettoie les td "Nom"
  8425. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  8426. var tr = getMonstreNomNode(i);
  8427. while(tr.childNodes.length>1) {
  8428. tr.removeChild(tr.childNodes[1]);
  8429. }
  8430. } else {
  8431. var tr = getMonstreNomNode(i);
  8432. var TypeMonstre=getEM(nom);
  8433. if(TypeMonstre!='') {
  8434. var infosCompo=compoMobEM(TypeMonstre);
  8435. if(infosCompo.length>0) {
  8436. tr.appendChild(document.createTextNode(' '));
  8437. tr.appendChild(createImage(urlImg, infosCompo));
  8438. }
  8439. }
  8440. }
  8441. }
  8442. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  8443. var texte = getInfoEnchantementFromMonstre(nom);
  8444. if(texte!='') {
  8445. var td = getMonstreNomNode(i);
  8446. td.appendChild(document.createTextNode(' '));
  8447. td.appendChild(createImage(urlEnchantImg, texte));
  8448. }
  8449. }
  8450. tr_monstres[i].style.display = (
  8451. noGowaps &&
  8452. nom.indexOf('gowap apprivoisé')!=-1 &&
  8453. getMonstreDistance(i)>1
  8454. ) || (
  8455. noEngages &&
  8456. getMonstreDistance(i)!=0 &&
  8457. listeEngages[pos[0]] &&
  8458. listeEngages[pos[0]][pos[1]] &&
  8459. listeEngages[pos[0]][pos[1]][pos[2]]
  8460. ) || (
  8461. strMonstre!='' &&
  8462. nom.indexOf(strMonstre)==-1
  8463. ) || (
  8464. nivMin>0 &&
  8465. getMonstreLevel(i)!=-1 &&
  8466. getMonstreLevel(i)<nivMin &&
  8467. getMonstreDistance(i)>1 &&
  8468. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  8469. ) || (
  8470. nivMax>0 &&
  8471. getMonstreLevel(i)>nivMax &&
  8472. getMonstreDistance(i)>1 &&
  8473. nom.toLowerCase().indexOf("kilamo")==-1
  8474. ) ? 'none' : '';
  8475. }
  8476. if(MY_getValue('NOINFOEM')!='true') {
  8477. if(noEM != oldNOEM) {
  8478. if(noEM && isCDMsRetrieved) computeMission();
  8479. }
  8480. oldNOEM = noEM;
  8481. }
  8482. needComputeEnchantement = false;
  8483. }
  8484.  
  8485.  
  8486. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  8487.  
  8488. function filtreTrolls() {
  8489. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  8490. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  8491. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  8492. for(var i=1 ; i<=nbTrolls ; i++) {
  8493. tr_trolls[i].style.display = (
  8494. noIntangibles &&
  8495. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  8496. ) || (
  8497. strTroll!='' &&
  8498. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  8499. ) || (
  8500. strGuilde!='' &&
  8501. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  8502. ) ? 'none' : '';
  8503. }
  8504. }
  8505.  
  8506. /* [functions] Bulle PX Trolls */
  8507. var bulle;
  8508.  
  8509. function initPXTroll() {
  8510. bulle = document.createElement('div');
  8511. bulle.id = 'bulle';
  8512. bulle.className = 'mh_textbox';
  8513. bulle.style =
  8514. 'position: absolute;'+
  8515. 'border: 1px solid #000000;'+
  8516. 'visibility: hidden;'+
  8517. 'display: inline;'+
  8518. 'z-index: 2;';
  8519. document.body.appendChild(bulle);
  8520.  
  8521. for(var i=nbTrolls ; i>0 ; i--) {
  8522. var td_niv = getTrollNivNode(i);
  8523. td_niv.onmouseover = showPXTroll;
  8524. td_niv.onmouseout = hidePXTroll;
  8525. }
  8526. }
  8527.  
  8528. function showPXTroll(evt) {
  8529. var lvl = this.firstChild.nodeValue;
  8530. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  8531. bulle.style.left = evt.pageX+15+'px';
  8532. bulle.style.top = evt.pageY+'px';
  8533. bulle.style.visibility = 'visible';
  8534. }
  8535.  
  8536. function hidePXTroll() {
  8537. bulle.style.visibility = 'hidden';
  8538. }
  8539.  
  8540. /* [functions] Envoi PX / MP */
  8541. function putBoutonPXMP() {
  8542. // Bouton d'initialisation du mode Envoi
  8543. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8544. var td = document.getElementById('tdInsertTrolls');
  8545. if(!td) { return; }
  8546. td.width = 100;
  8547. td = insertTd(td.nextSibling);
  8548. td.style.verticalAlign = 'top';
  8549. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8550. bouton.id = 'btnEnvoi';
  8551. }
  8552.  
  8553. function prepareEnvoi() {
  8554. // = 1er Handler du bouton d'envoi
  8555. /* Ajout de la colonne des CheckBoxes */
  8556. var td = insertTdText(getTrollNomNode(0),'');
  8557. td.width = 5;
  8558. for(var i=nbTrolls ; i>0 ; i--) {
  8559. td = insertTd(getTrollNomNode(i));
  8560. appendCheckBox(td,'envoi'+i);
  8561. }
  8562. /* Ajout du radio de choix PX ou MP */
  8563. var btnEnvoi = document.getElementById('btnEnvoi');
  8564. if(!btnEnvoi) { return; }
  8565. var tdEnvoi = btnEnvoi.parentNode;
  8566. appendText(tdEnvoi,' ');
  8567. var span = document.createElement('span');
  8568. span.style.whiteSpace = 'nowrap';
  8569. var radioElt = document.createElement('input');
  8570. radioElt.type = 'radio';
  8571. radioElt.name = 'envoiPXMP';
  8572. radioElt.id = 'radioPX';
  8573. span.appendChild(radioElt);
  8574. appendText(span,' des PX ');
  8575. radioElt = document.createElement('input');
  8576. radioElt.type = 'radio';
  8577. radioElt.name = 'envoiPXMP';
  8578. radioElt.checked = true;
  8579. span.appendChild(radioElt);
  8580. appendText(span,' un MP');
  8581. tdEnvoi.appendChild(span);
  8582. /* Insertion du bouton Annuler */
  8583. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8584. /* Modification de l'effet du bouton Envoi */
  8585. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8586. }
  8587.  
  8588. function annuleEnvoi() {
  8589. // = Handler bouton Annuler
  8590. /* Nettoyage du td du bouton Envoi */
  8591. var btnEnvoi = document.getElementById('btnEnvoi');
  8592. var tdEnvoi = btnEnvoi.parentNode;
  8593. while(tdEnvoi.firstChild) {
  8594. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8595. }
  8596. /* Retour à l'effet de base du bouton Envoi */
  8597. btnEnvoi.onclick = prepareEnvoi;
  8598. tdEnvoi.appendChild(btnEnvoi);
  8599. /* Suppression CheckBoxes */
  8600. for(var i=nbTrolls ; i>=0 ; i--) {
  8601. var td = getTrollNomNode(i);
  8602. td.parentNode.removeChild(td);
  8603. }
  8604. }
  8605.  
  8606. function effectueEnvoi() {
  8607. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  8608. var str='';
  8609. for(var i=nbTrolls ; i>0 ; i--) {
  8610. var chb = document.getElementById('envoi'+i);
  8611. if(chb.checked) {
  8612. str += (str?',':'')+getTrollID(i);
  8613. }
  8614. }
  8615. var PXchecked = document.getElementById('radioPX').checked;
  8616. if(PXchecked) {
  8617. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  8618. } else {
  8619. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  8620. }
  8621. }
  8622.  
  8623. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  8624.  
  8625. function filtreTresors() {
  8626. // += Handler checkboxes : gg, compos, bidouilles, non libres
  8627. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  8628. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  8629. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  8630. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8631. if(noEngages && !isEngagesComputed) {
  8632. for(var i=nbTrolls ; i>0 ; i--) {
  8633. var pos = getTrollPosition(i);
  8634. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  8635. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  8636. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  8637. }
  8638. isEngagesComputed = true;
  8639. }
  8640. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  8641. for(var i=nbTresors ; i>0 ; i--) {
  8642. var nom = getTresorNom(i);
  8643. var pos = getTresorPosition(i);
  8644. tr_tresors[i].style.display = (
  8645. noGG &&
  8646. nom.indexOf('Gigots de Gob')!=-1
  8647. ) || (
  8648. noCompos &&
  8649. nom.indexOf('Composant')!=-1
  8650. ) || (
  8651. noEngages &&
  8652. listeEngages[pos[2]] &&
  8653. listeEngages[pos[2]][pos[1]] &&
  8654. listeEngages[pos[2]][pos[1]][pos[0]] &&
  8655. getTresorDistance(i)>0
  8656. ) || (
  8657. strTresor!='' &&
  8658. nom.toLowerCase().indexOf(strTresor)==-1
  8659. ) || (
  8660. noBidouilles &&
  8661. nom.indexOf('Bidouille')!=-1
  8662. ) ? 'none' : '';
  8663. }
  8664. }
  8665.  
  8666.  
  8667. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  8668.  
  8669. function filtreLieux() {
  8670. // += Handler checkbox trous
  8671. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  8672. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  8673. for(var i=nbLieux ; i>0 ; i--) {
  8674. tr_lieux[i].style.display = (
  8675. strLieu &&
  8676. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  8677. ) || (
  8678. noTrou &&
  8679. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  8680. getLieuDistance(i)>1
  8681. ) ? 'none' : '';
  8682. }
  8683. }
  8684.  
  8685.  
  8686. /*-[functions]-------------------- Diplomatie --------------------------------*/
  8687.  
  8688. function refreshDiplo() {
  8689. MY_setValue(numTroll+'.diplo.off',
  8690. checkBoxDiplo.checked?'true':'false'
  8691. );
  8692. if(isDiploRaw) { computeDiplo(); }
  8693. appliqueDiplo();
  8694. }
  8695.  
  8696. function computeDiplo() {
  8697. // On extrait les données de couleur et on les stocke par id
  8698. // Ordre de préséance :
  8699. // source Guilde < source Perso
  8700. // guilde cible < troll cible
  8701. /* Diplo de Guilde */
  8702. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  8703. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  8704. if(diploGuilde && diploGuilde.isOn=='true') {
  8705. // Guilde perso
  8706. if(diploGuilde.guilde) {
  8707. Diplo.Guilde[diploGuilde.guilde.id] = {
  8708. couleur: diploGuilde.guilde.couleur,
  8709. titre: 'Ma Guilde'
  8710. };
  8711. }
  8712. // Guildes/Trolls A/E
  8713. for(var AE in {Amis:0,Ennemis:0}) {
  8714. for(var i=0 ; i<5 ; i++) {
  8715. if(diploGuilde[AE+i]) {
  8716. for(var type in {Guilde:0,Troll:0}) {
  8717. var liste = diploGuilde[AE+i][type].split(';');
  8718. for(var j=liste.length-2 ; j>=0 ; j--) {
  8719. Diplo[type][liste[j]] = {
  8720. couleur: diploGuilde[AE+i].couleur,
  8721. titre: diploGuilde[AE+i].titre
  8722. };
  8723. }
  8724. }
  8725. }
  8726. }
  8727. }
  8728. }
  8729. /* Diplo Perso */
  8730. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  8731. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  8732. if(diploPerso && diploPerso.isOn=='true') {
  8733. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  8734. for(var id in diploPerso[type]) {
  8735. Diplo[type][id] = diploPerso[type][id];
  8736. }
  8737. }
  8738. }
  8739. if(diploPerso.mythiques) {
  8740. Diplo.mythiques = diploPerso.mythiques;
  8741. }
  8742. isDiploRaw = false;
  8743. }
  8744.  
  8745. function appliqueDiplo() {
  8746. var aAppliquer = Diplo;
  8747. if(checkBoxDiplo.checked) {
  8748. // Pour retour à l'affichage basique sur désactivation de la diplo
  8749. aAppliquer = {
  8750. Guilde: {},
  8751. Troll: {},
  8752. Monstre: {}
  8753. };
  8754. }
  8755. /* On applique "aAppliquer" */
  8756. // Diplo Trõlls
  8757. for(var i=nbTrolls ; i>0 ; i--) {
  8758. var idG = getTrollGuildeID(i);
  8759. var idT = getTrollID(i);
  8760. var tr = tr_trolls[i];
  8761. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  8762. if(aAppliquer.Troll[idT]) {
  8763. tr.className = '';
  8764. var descr = aAppliquer.Troll[idT].titre;
  8765. if(descr) {
  8766. getTrollNomNode(i).title = descr
  8767. }
  8768. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  8769. } else if(aAppliquer.Guilde[idG]) {
  8770. tr.className = '';
  8771. var descr = aAppliquer.Guilde[idG].titre;
  8772. if(descr) {
  8773. getTrollNomNode(i).title = descr
  8774. }
  8775. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  8776. } else {
  8777. tr.className = 'mh_tdpage';
  8778. getTrollNomNode(i).title = '';
  8779. }
  8780. }
  8781. // Diplo Monstres
  8782. for(var i=nbMonstres ; i>0 ; i--) {
  8783. var id = getMonstreID(i);
  8784. var nom = getMonstreNom(i).toLowerCase();
  8785. if(aAppliquer.Monstre[id]) {
  8786. tr_monstres[i].className = '';
  8787. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  8788. tr_monstres[i].diploActive = 'oui';
  8789. var descr = aAppliquer.Monstre[id].titre;
  8790. if(descr) {
  8791. getMonstreNomNode(i).title = descr;
  8792. }
  8793. } else if(aAppliquer.mythiques &&
  8794. (nom.indexOf('liche')==0 ||
  8795. nom.indexOf('hydre')==0 ||
  8796. nom.indexOf('balrog')==0 ||
  8797. nom.indexOf('beholder')==0)) {
  8798. tr_monstres[i].className = '';
  8799. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  8800. tr_monstres[i].diploActive = 'oui';
  8801. getMonstreNomNode(i).title = 'Monstre Mythique';
  8802. } else {
  8803. tr_monstres[i].className = 'mh_tdpage';
  8804. tr_monstres[i].diploActive = '';
  8805. }
  8806. }
  8807. }
  8808.  
  8809.  
  8810. /*-[functions]---------------- Actions à distance ----------------------------*/
  8811.  
  8812. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  8813. var monN = parseInt(getPosition()[2]);
  8814. for(var type in keltypes) {
  8815. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  8816. for(var i=this['nb'+type] ; i>0 ; i--) {
  8817. var tr = this['tr_'+type.toLowerCase()][i];
  8818. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  8819. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  8820. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  8821. var sonN = getXxxPosition(type, i)[2];
  8822. var d = getXxxDistance(type, i);
  8823. if(sonN==monN && d>=dmin && d<=dmax) {
  8824. var iconeAction = document.evaluate(
  8825. "./descendant::img[@alt='"+alt+"']",
  8826. tr, null, 9, null
  8827. ).singleNodeValue;
  8828. if(iconeAction) {
  8829. if(iconeAction.title) {
  8830. iconeAction.title += "\n"+message;
  8831. } else {
  8832. iconeAction.title = message;
  8833. }
  8834. iconeAction.src = urlIcon;
  8835. } else {
  8836. var tdAction = tr.getElementsByTagName('td')[1];
  8837. var icon = document.createElement('img');
  8838. icon.src = urlIcon;
  8839. icon.height = 20;
  8840. icon.alt = alt;
  8841. icon.title = message;
  8842. tdAction.appendChild(icon);
  8843. }
  8844. }
  8845. }
  8846. }
  8847. }
  8848.  
  8849. function computeCharge() {
  8850. computeActionDistante(1,
  8851. getPortee__Vue(
  8852. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  8853. MY_getValue(numTroll+".caracs.regeneration")
  8854. ),
  8855. {'Monstres':1, 'Trolls':1},
  8856. 'Attaquer',
  8857. MHicons+'E_Metal09.png',
  8858. 'Cible à portée de Charge'
  8859. );
  8860. }
  8861.  
  8862. function computeProjo() {
  8863. computeActionDistante(0,
  8864. getPortee__Vue(
  8865. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8866. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8867. ),
  8868. {'Monstres':1, 'Trolls':1},
  8869. 'Attaquer',
  8870. MHicons+'S_Fire05.png',
  8871. 'Cible à portée de Projo'
  8872. );
  8873. }
  8874.  
  8875. function computeTelek() {
  8876. computeActionDistante(0,
  8877. Math.floor((
  8878. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8879. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8880. )/2),
  8881. {'Tresors':1},
  8882. 'Telek',
  8883. MHicons+'S_Magic04.png',
  8884. 'Trésor à portée de Télékinésie'
  8885. );
  8886. }
  8887.  
  8888. function computeLdP() {
  8889. computeActionDistante(0,
  8890. 2+Math.floor((
  8891. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  8892. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  8893. )/5),
  8894. {'Monstres':1, 'Trolls':1},
  8895. 'self',
  8896. MHicons+'P_Red01.png',
  8897. 'Cible à portée de Lancer de Potions'
  8898. );
  8899. }
  8900.  
  8901.  
  8902. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  8903.  
  8904. function putScriptExterne() {
  8905. var infoit = MY_getValue(numTroll+'.INFOSIT');
  8906. if(!infoit || infoit=='') return;
  8907.  
  8908. var nomit = infoit.slice(0,infoit.indexOf('$'));
  8909. if(nomit=='bricol') {
  8910. var data = infoit.split('$');
  8911. try {
  8912. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  8913. // appendNewScript(URL_bricol+data[1]
  8914. // +'/mz.php?login='+data[2]
  8915. // +'&password='+data[3]
  8916. // );
  8917. FF_XMLHttpRequest({
  8918. method: 'GET',
  8919. url: URL_bricol+data[1]
  8920. +'/mz_json.php?login='+data[2]
  8921. +'&password='+data[3],
  8922. onload: function(responseDetails) {
  8923. try {
  8924. if (responseDetails.status == 0) {
  8925. if (isHTTPS) {
  8926. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  8927. } else {
  8928. window.console.log('status=0 à l\'appel bricol\'troll');
  8929. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  8930. }
  8931. return;
  8932. }
  8933. var ratibusData;
  8934. try {
  8935. ratibusData = JSON.parse(responseDetails.responseText);
  8936. } catch(e) {}
  8937. if (ratibusData === undefined) {
  8938. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  8939. return;
  8940. }
  8941. if (ratibusData.error) {
  8942. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  8943. } else {
  8944. putInfosTrolls(ratibusData.data.trolls);
  8945. }
  8946. } catch(e) {
  8947. window.console.log(traceStack(e, 'retour bricol\'troll'));
  8948. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  8949. }
  8950. }
  8951. });
  8952. } catch(e) {
  8953. if (isHTTPS) {
  8954. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  8955. } else {
  8956. window.console.log(traceStack(e, 'appel bricol\'troll'));
  8957. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  8958. }
  8959. }
  8960. }
  8961. }
  8962.  
  8963. /* Le script mz.php de Ratibus renvoie :
  8964. + infosTrolls = new Array();
  8965. + infosTrolls[numdutroll] =
  8966. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  8967. + etc ...
  8968. + putInfosTrolls();
  8969. *
  8970. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  8971. * Roule 07/11/2016, on utilise mz_json qui envoie
  8972. {
  8973. "data": {
  8974. "trolls": {
  8975. "59424": {
  8976. "id": 59424,
  8977. "pv": xx,
  8978. "pv_max": xx,
  8979. "updated_at": "2016-10-31 07:28:40",
  8980. "dla": "2016-10-05 07:28:04",
  8981. "pa": 0
  8982. },
  8983. }
  8984. }
  8985. }
  8986. */
  8987.  
  8988. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  8989. function corrigeBricolTrolls(infosTrolls) {
  8990. for(var i in infosTrolls) {
  8991. var pv = infosTrolls[i][0];
  8992. var pvmax = infosTrolls[i][1];
  8993. var pvmem = MY_getValue(i+'.caracs.pv.max');
  8994. if(pvmem && pvmem>pvmax) {
  8995. infosTrolls[i][1] = pvmem;
  8996. pvmax = pvmem;
  8997. }
  8998. if(pv>pvmax) {
  8999. var newpvmax = 5*Math.ceil(pv/5);
  9000. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9001. infosTrolls[i][1] = newpvmax;
  9002. }
  9003. }
  9004. }
  9005.  
  9006. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9007. function addTdInfosTroll(infos, nextTD) {
  9008. /* cadre barre PV */
  9009. var tab = document.createElement('div');
  9010. /* ancienne méthode par img, à supprimer
  9011. tab.width = 100;
  9012. tab.style.width = 100;
  9013. tab.height = 10;
  9014. tab.style.background = '#FFFFFF';
  9015. tab.style.border = 1;
  9016. */
  9017. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9018. /* barre PV */
  9019. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9020. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9021. .vieContainer {
  9022. background-color: #CCC;
  9023. width: 50px;
  9024. height: 6px;
  9025. border: 1px solid #000;
  9026. text-align: left;
  9027. }
  9028. */
  9029. tab.style.width = '100px';
  9030. tab.style.height = '10px';
  9031. tab.style.border = '1px solid #000';
  9032. tab.style.textAlign = 'left';
  9033. var div2 = document.createElement('div');
  9034. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9035. var dateLimite = new Date();
  9036. dateLimite.setDate(dateLimite.getDate() - 7);
  9037. if (infos.oUpdatedAt < dateLimite) {
  9038. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9039. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9040. } else if (pourcentVie > 66) {
  9041. div2.style.backgroundColor = '#77EE77';
  9042. } else if (pourcentVie > 33) {
  9043. div2.style.backgroundColor = '#EEEE77';
  9044. } else {
  9045. div2.style.backgroundColor = '#FF0000';
  9046. }
  9047. div2.style.width = pourcentVie + '%';
  9048. div2.style.height = '10px';
  9049. tab.appendChild(div2);
  9050. /* ancienne méthode par img, à supprimer
  9051. var img = document.createElement('img');
  9052. img.src = '../Images/Interface/milieu.gif';
  9053. img.height = 10;
  9054. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9055. tab.appendChild(img);
  9056. */
  9057.  
  9058. /* lien vers l'IT */
  9059. var lien = document.createElement('a');
  9060. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9061. lien.href = URL_bricol+nomit+'/index.php';
  9062. lien.target = '_blank';
  9063. lien.appendChild(tab);
  9064. insertTdElement(nextTD,lien);
  9065. /* PAs dispos */
  9066. var span = document.createElement('span');
  9067. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9068. appendText(span, infos.pa +' PA' );
  9069. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9070. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9071. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9072. span.style.backgroundColor = 'B8EEB8';
  9073. }
  9074. insertTdElement(nextTD, span);
  9075. }
  9076.  
  9077. function putInfosTrolls(infosTrolls) {
  9078. try {
  9079. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9080. // supression des infos trop vieilles (un mois)
  9081. var IDs = Object.keys(infosTrolls);
  9082. var dateLimite = new Date();
  9083. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9084. for (var i = 0; i < IDs.length; i++) {
  9085. var idTroll = IDs[i];
  9086. var infos = infosTrolls[idTroll];
  9087. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9088. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9089. }
  9090. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9091. td.width = 40;
  9092. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9093. td.width = 105;
  9094.  
  9095. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9096. //corrigeBricolTrolls(infosTrolls);
  9097.  
  9098. for(i=nbTrolls ; i>0 ; i--) {
  9099. var infos = infosTrolls[getTrollID(i)];
  9100. if(infos && (!infos.bIgnore)) {
  9101. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9102. infos.done = true;
  9103. } else {
  9104. insertTd(tr_trolls[i].childNodes[6]);
  9105. insertTd(tr_trolls[i].childNodes[6]);
  9106. }
  9107. }
  9108. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9109. var str = MY_getValue(numTroll+'.INFOSIT');
  9110. if(!str) return;
  9111. var arr = str.split('$');
  9112. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9113.  
  9114. //window.console.log('nb Troll IT : ' + IDs.length);
  9115. var tBody = tr_trolls[0].parentNode;
  9116. if (tr_trolls[1] === undefined)
  9117. tBody = tr_trolls[0].parentNode;
  9118. else
  9119. tBody = tr_trolls[1].parentNode;
  9120. var pos = getPosition();
  9121. for (i = 0; i < IDs.length; i++) {
  9122. var idTroll = IDs[i];
  9123. infos = infosTrolls[idTroll];
  9124. if (infos.done) continue; // déjà vu
  9125. if (infos.bIgnore) continue; // trop vieux
  9126. if (idTroll == numTroll) continue; // pas nous-même
  9127. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9128. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9129. // trouver où insérer ce Troll
  9130. var next = undefined;
  9131. for(var j=0 ; j<tr_trolls.length ; j++) {
  9132. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9133. if (thisDist > distance) {
  9134. next = tr_trolls[j]
  9135. break;
  9136. }
  9137. }
  9138. var tr;
  9139. if (next !== undefined) {
  9140. tr = insertTr(next,'mh_tdpage')
  9141. } else {
  9142. tr = appendTr(tBody,'mh_tdpage');
  9143. }
  9144. var td = appendTd(tr); // distance
  9145. appendText(td, distance);
  9146. td = appendTd(tr); // actions
  9147. td = appendTd(tr); // ID
  9148. appendText(td, idTroll);
  9149. td = appendTd(tr); // Nom
  9150. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9151. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9152. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9153. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9154. td = appendTd(tr); // Niveau
  9155. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9156. td.align = 'center';
  9157. td = appendTd(tr); // Race
  9158. if (infos.race) appendText(td, infos.race);
  9159. // PV et PA ajoutés par addTdInfosTroll
  9160. td = appendTd(tr); // Guilde
  9161. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9162. td = appendTd(tr); // X
  9163. td.align = 'center';
  9164. if (infos.x !== undefined) appendText(td, infos.x);
  9165. td = appendTd(tr); // Y
  9166. td.align = 'center';
  9167. if (infos.y !== undefined) appendText(td, infos.y);
  9168. td = appendTd(tr); // N
  9169. td.align = 'center';
  9170. if (infos.n !== undefined) appendText(td, infos.n);
  9171. addTdInfosTroll(infos, tr.childNodes[6]);
  9172. }
  9173. } catch(e) {
  9174. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  9175. }
  9176. }
  9177.  
  9178.  
  9179. /* Mode Tétalanvert! ---------------------------------------------------------*/
  9180.  
  9181. function calculeDistance(maPos,posArr) {
  9182. return Math.max(
  9183. Math.abs(maPos[0]-posArr[0]),
  9184. Math.abs(maPos[1]-posArr[1]),
  9185. Math.abs(maPos[2]-posArr[2])
  9186. );
  9187. }
  9188.  
  9189. function inversionCoord() {
  9190. var maPos = getPosition();
  9191. var listeOffsets = {
  9192. 'monstres':checkBoxLevels.checked?4:3,
  9193. 'trolls':6,
  9194. };
  9195. for(var type in listeOffsets) {
  9196. var trList = this['tr_'+type];
  9197. var offset = listeOffsets[type];
  9198. for(var i=trList.length-1 ; i>0 ; i--) {
  9199. var oldX = parseInt(trList[i].cells[offset].textContent);
  9200. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  9201. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  9202. trList[i].cells[offset].innerHTML = oldY;
  9203. trList[i].cells[offset+1].innerHTML = oldX;
  9204. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  9205. }
  9206. }
  9207. }
  9208.  
  9209.  
  9210. /* Partie principale */
  9211. function do_vue() {
  9212. for(var type in typesAFetcher) {
  9213. fetchData(type);
  9214. }
  9215.  
  9216. // roule' 11/03/2016
  9217. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  9218. // je fais une recopie :(
  9219. tr_monstres = this['tr_monstres'];
  9220. tr_trolls = this['tr_trolls'];
  9221. tr_tresors = this['tr_tresors'];
  9222. tr_champignons = this['tr_champignons'];
  9223. tr_lieux = this['tr_lieux'];
  9224.  
  9225. nbMonstres = this['nbMonstres'];
  9226. nbTrolls = this['nbTrolls'];
  9227. nbTresors = this['nbTresors'];
  9228. nbChampignons = this['nbChampignons'];
  9229. nbLieux = this['nbLieux'];
  9230.  
  9231. try {
  9232. start_script(31);
  9233. initialiseInfos();
  9234. savePosition();
  9235.  
  9236. // Fonctionnalité "Têtalenvert" cachée, en test :
  9237. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  9238. inversionCoord();
  9239. }
  9240. ajoutDesFiltres();
  9241. set2DViewSystem();
  9242. //putBoutonTroogle();
  9243. putBoutonPXMP();
  9244. synchroniseFiltres();
  9245. toggleLevelColumn();
  9246.  
  9247. refreshDiplo();
  9248. //400 ms
  9249. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  9250. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  9251. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  9252. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  9253. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  9254. var noTresorsEngages =
  9255. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  9256. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  9257. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  9258. filtreMonstres();
  9259. if(noIntangibles) {
  9260. filtreTrolls();
  9261. }
  9262. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  9263. filtreTresors();
  9264. }
  9265. if(noTrou) {
  9266. filtreLieux();
  9267. }
  9268.  
  9269. initPopupVue();
  9270. initPXTroll();
  9271.  
  9272. if(getTalent("Projectile Magique")!=0) {
  9273. computeProjo();
  9274. }
  9275. if(getTalent("Charger")!=0) {
  9276. computeCharge();
  9277. }
  9278. if(getTalent("Télékinésie")!=0) {
  9279. computeTelek();
  9280. }
  9281. if(getTalent("Lancer de Potions")!=0) {
  9282. computeLdP();
  9283. }
  9284. putScriptExterne();
  9285. displayScriptTime();
  9286. } catch(e) {
  9287. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  9288. window.console.error(traceStack(e, 'vue'));
  9289. }
  9290. }
  9291.  
  9292.  
  9293.  
  9294. /*******************************************************************************
  9295. * This file is part of Mountyzilla. *
  9296. * *
  9297. * Mountyzilla is free software; you can redistribute it and/or modify *
  9298. * it under the terms of the GNU General Public License as published by *
  9299. * the Free Software Foundation; either version 2 of the License, or *
  9300. * (at your option) any later version. *
  9301. * *
  9302. * Mountyzilla is distributed in the hope that it will be useful, *
  9303. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9304. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9305. * GNU General Public License for more details. *
  9306. * *
  9307. * You should have received a copy of the GNU General Public License *
  9308. * along with Mountyzilla; if not, write to the Free Software *
  9309. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9310. *******************************************************************************/
  9311.  
  9312. // x~x profil2
  9313.  
  9314. /*---------------------------- Variables globales ----------------------------*/
  9315.  
  9316. var
  9317. // Anatrolliseur
  9318. urlAnatrolliseur,
  9319. // Infobulles talents
  9320. hauteur = 50, bulleStyle = null,
  9321. // Caracteristiques
  9322. // Infos troll
  9323. race, niv, idtroll, datecrea,
  9324. idguilde, nomguilde,
  9325. // Etats du troll
  9326. fatigue, bmfatigue,
  9327.  
  9328. // Experience, Pi, ...
  9329. pxdistribuables, pxperso,
  9330. piutilisable, pitotal,
  9331. nbmeurtres, nbmorts,
  9332. // utilisee pour les moyennes MM/jour, kill/jour, etc
  9333. NBjours,
  9334. // calcul des DLA suivantes
  9335. DLA, DLAsuiv, HeureServeur,
  9336. // details duree du tour (calcul pvdispo) :
  9337. dtb, pdm, bmt, adb, dpt,
  9338. //posale
  9339. posX, posY, posN,
  9340. // caracs physiques
  9341. vue, vuebp, vuebm, vuetotale,
  9342. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  9343. reg, regbp, regbm, regmoy,
  9344. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  9345. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  9346. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  9347. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  9348. rm, rmbp, rmbm, rmtotale,
  9349. mm, mmbp, mmbm, mmtotale,
  9350.  
  9351. // Variables speciales Kastars
  9352. pvActuelKastar, minParPV, overDLA,
  9353. // id pour edition manuelle de lastDLA :
  9354. inJour, inMois, inAn, inHr, inMin, inSec,
  9355. // id pour auto-refresh lastDLA :
  9356. lastDLAZone, maxAMZone, cumulZone,
  9357. lastDLA, DLAaccel;
  9358.  
  9359.  
  9360. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9361.  
  9362. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  9363. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  9364. function getUniqueValueBySelector(selector, defaultValue){
  9365. var valNode = document.querySelector(selector);
  9366. if(valNode!=null){
  9367. if(valNode.hasChildNodes()) {
  9368. return valNode.childNodes[0].nodeValue;
  9369. }else{
  9370. return defaultValue;
  9371. }
  9372. } else{
  9373. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  9374. return defaultValue;
  9375. }
  9376. }
  9377. function getUniqueStringValueBySelector(selector){
  9378. return getUniqueValueBySelector(selector,"");
  9379. }
  9380. function getUniqueIntValueBySelector(selector){
  9381. var ret = getUniqueValueBySelector(selector,0);
  9382. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9383. ret = 0;
  9384. }
  9385. return parseInt(ret);
  9386. }
  9387. function getUniqueFloatValueBySelector(selector){
  9388. var ret = getUniqueValueBySelector(selector,0.0);
  9389. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9390. ret = 0.0;
  9391. }
  9392. return parseFloat(ret);
  9393. }
  9394.  
  9395.  
  9396. function resiste(Ddeg,bm) {
  9397. // version naive mais compréhensible ^^
  9398. // DEBUG: à revoir
  9399. if(!bm) {
  9400. return 2*Math.floor(Ddeg/2);
  9401. }
  9402. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  9403. }
  9404.  
  9405. function retourAZero(fatig) {
  9406. var fat = fatig, raz = 0;
  9407. while(fat>0) {
  9408. raz++;
  9409. fat = Math.floor(fat/1.25);
  9410. }
  9411. return raz;
  9412. }
  9413.  
  9414. function decumulPumPrem(bonus) {
  9415. switch(bonus) {
  9416. case 20: return 33;
  9417. case 33: return 41;
  9418. case 41: return 46;
  9419. case 46: return 49;
  9420. case 49: return 51;
  9421. default: return 20;
  9422. }
  9423. }
  9424.  
  9425. function coefDecumul(i) {
  9426. switch(i) {
  9427. case 2: return 0.67;
  9428. case 3: return 0.4;
  9429. case 4: return 0.25;
  9430. case 5: return 0.15;
  9431. default: return 0.1;
  9432. }
  9433. }
  9434.  
  9435. function dureeHM(dmin) {
  9436. var ret = "";
  9437. dmin = Math.floor(dmin);
  9438. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  9439. var mins = dmin%60;
  9440. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  9441. return (ret) ? ret : "-";
  9442. }
  9443.  
  9444. // extraction d'une durée
  9445. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  9446. // c'est protégé (rend 0 si l'élément est absent)
  9447. // Roule' 24/12/2016
  9448. function extractionDuree(selecteur) {
  9449. var s = getUniqueStringValueBySelector(selecteur);
  9450. if (!s) return 0;
  9451. var tabN = getNumbers(s);
  9452. if (tabN.length < 2) return 0;
  9453. return tabN[0] * 60 + tabN[1];
  9454. }
  9455.  
  9456. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  9457.  
  9458. function extractionDonnees() {
  9459. // Variables temporaires
  9460. var Nbrs = {};
  9461.  
  9462. // *********************
  9463. // Cadre "Description"
  9464. // *********************
  9465. race = getUniqueStringValueBySelector('#descr #race');
  9466. debugMZ("Race : " + race);
  9467. idtroll = getUniqueStringValueBySelector('#descr #id');
  9468. debugMZ("Id troll : " + idtroll);
  9469. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  9470. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  9471. datecrea = new Date(StringToDate(strDateCrea));
  9472. debugMZ("Date creation : " + datecrea);
  9473. // Guilde
  9474. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  9475. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  9476. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  9477.  
  9478. // *******************
  9479. // Cadre "Experience"
  9480. // *******************
  9481. // Niveau de troll
  9482. niv = getUniqueIntValueBySelector('#exp #niv');
  9483. nivTroll = niv;
  9484. debugMZ("Niveau : " + niv);
  9485. // PX
  9486. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  9487. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  9488. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  9489. // PI
  9490. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  9491. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  9492. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  9493. // Meutres/Morts
  9494. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  9495. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  9496. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  9497.  
  9498. // *********************
  9499. // Cadre "Tour de Jeu"
  9500. // *********************
  9501. // DLA
  9502. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  9503. DLA = new Date(StringToDate(Nbrs["dla"]));
  9504. debugMZ("DLA: " + DLA);
  9505. // DLA suivante
  9506. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  9507. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  9508. debugMZ("DLAsuiv: " + DLAsuiv);
  9509. // Duree normale de mon Tour
  9510. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  9511. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  9512. dtb = extractionDuree("#dla #tour");
  9513. debugMZ("Duree normale de mon Tour : " + dtb);
  9514. // Bonus/Malus sur la duree
  9515. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  9516. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  9517. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  9518. debugMZ("Bonus/Malus sur la duree : " + bmt);
  9519. // Augmentation due aux blessures
  9520. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  9521. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  9522. adb = extractionDuree("#dla #blessure");
  9523. debugMZ("Augmentation due aux blessures : " + adb);
  9524. // Poids de l'equipement
  9525. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  9526. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  9527. pdm = extractionDuree("#dla #poids");
  9528. debugMZ("Poids de l'equipement : " + pdm);
  9529. // Duree de mon prochain Tour
  9530. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  9531. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  9532. dpt = extractionDuree("#dla #duree>b");
  9533. debugMZ('Duree de mon prochain Tour : ' + dpt);
  9534.  
  9535. // ****************
  9536. // Cadre "Etats"
  9537. // ****************
  9538. // Position du troll :
  9539. posX = getUniqueIntValueBySelector('#pos #x');
  9540. posY = getUniqueIntValueBySelector('#pos #y');
  9541. posN = getUniqueIntValueBySelector('#pos #n');
  9542. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  9543. // PV actuel
  9544. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  9545. pvActuelKastar = pvcourant;
  9546. debugMZ("PV actuel : " + pvcourant)
  9547. // Fatigue
  9548. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  9549. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  9550. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  9551.  
  9552. // **************************
  9553. // Cadre "Caracteristiques"
  9554. // **************************
  9555. // Attaque
  9556. att = getUniqueIntValueBySelector('#carac #att');
  9557. attbp = getUniqueIntValueBySelector('#carac #att_p');
  9558. attbm = getUniqueIntValueBySelector('#carac #att_m');
  9559. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  9560. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  9561. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  9562. attmoy = 3.5*att + attbp + attbm;
  9563. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9564. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  9565. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  9566. // Esquive
  9567. esq = getUniqueIntValueBySelector('#carac #esq');
  9568. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  9569. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  9570. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  9571. esqmoy = 3.5*esq + esqbp+esqbm;
  9572. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  9573. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  9574. // Degat
  9575. deg = getUniqueIntValueBySelector('#carac #deg');
  9576. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  9577. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  9578. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  9579. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  9580. degmoy = 2*deg + degbp+degbm;
  9581. degmoycrit = 3*deg + degbp+degbm;
  9582. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9583. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  9584. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  9585. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  9586. // PV
  9587. pvbase = getUniqueIntValueBySelector('#carac #pv');
  9588. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  9589. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  9590. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  9591. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  9592. // Regeneration
  9593. reg = getUniqueIntValueBySelector('#carac #reg');
  9594. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  9595. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  9596. regmoy = 2 * reg + regbp + regbm; // D3
  9597. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  9598. // Armure
  9599. arm = getUniqueIntValueBySelector('#carac #arm');
  9600. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  9601. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  9602. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  9603. armmoy = 2*arm + armbp+armbm;
  9604. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  9605. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  9606. // TODO : D d'armure non active
  9607. // Vue
  9608. vue = getUniqueIntValueBySelector('#carac #vue');
  9609. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  9610. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  9611. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  9612. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  9613. // RM
  9614. rm = getUniqueIntValueBySelector('#carac #rm');
  9615. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  9616. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  9617. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  9618. rmTroll = rmtotale;
  9619. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  9620. // MM
  9621. mm = getUniqueIntValueBySelector('#carac #mm');
  9622. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  9623. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  9624. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  9625. mmTroll = mmtotale;
  9626. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  9627.  
  9628. // Heure Serveur
  9629. try {
  9630. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  9631. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  9632. HeureServeur = new Date(StringToDate(heureServeurSTR));
  9633. } catch (e) {
  9634. window.console.warn(
  9635. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  9636. );
  9637. HeureServeur = new Date();
  9638. }
  9639. debugMZ("HeureServeur: " + HeureServeur);
  9640.  
  9641. // ***INIT GLOBALE*** NBjours
  9642. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  9643.  
  9644. // Calcul debut lien anatroliseur avec les caracteristiques connues
  9645. var amelio_dtb = function(dtb) {
  9646. if(dtb>555) {
  9647. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  9648. }
  9649. return 10+Math.ceil((555-dtb)/2.5);
  9650. },
  9651. amelio_pv = Math.floor(pvbase/10)-3,
  9652. amelio_vue = vue-3,
  9653. amelio_att = att-3,
  9654. amelio_esq = esq-3,
  9655. amelio_deg = deg-3,
  9656. amelio_reg = reg-1,
  9657. amelio_arm = arm-1;
  9658. if(race==="Darkling"){amelio_reg--; }
  9659. if(race==="Durakuir"){amelio_pv-- ; }
  9660. if(race==="Kastar") {amelio_deg--; }
  9661. if(race==="Skrim") {amelio_att--; }
  9662. if(race==="Tomawak") {amelio_vue--; }
  9663.  
  9664. urlAnatrolliseur = URL_AnatrolDispas
  9665. +"outils_anatrolliseur.php?anatrolliseur=v8"
  9666. +"|r="+race.toLowerCase()
  9667. +"|dla="+amelio_dtb(dtb)
  9668. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  9669. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  9670. +"|att="+amelio_att+","+attbp+","+attbm
  9671. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  9672. +"|deg="+amelio_deg+","+degbp+","+degbm
  9673. +"|reg="+amelio_reg+","+regbp+","+regbm
  9674. +"|arm="+amelio_arm+","+armbp+","+armbm
  9675. +"|mm="+mmtotale
  9676. +"|rm="+rmtotale+"|";
  9677. }
  9678.  
  9679. function saveProfil() {
  9680. MY_setValue(idtroll+'.caracs.attaque',att);
  9681. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  9682. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  9683. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  9684. if(atttourD||atttourP||atttourM) {
  9685. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9686. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  9687. }
  9688. MY_setValue(idtroll+'.caracs.esquive',esq);
  9689. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  9690. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  9691. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  9692. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  9693. MY_setValue(idtroll+'.caracs.degats',deg);
  9694. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  9695. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  9696. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  9697. if(degtourP||degtourM){
  9698. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9699. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  9700. }
  9701. MY_setValue(idtroll+'.caracs.regeneration',reg);
  9702. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  9703. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  9704. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  9705. MY_setValue(idtroll+'.caracs.vue',vue);
  9706. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  9707. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  9708. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  9709. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  9710. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  9711. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  9712. MY_setValue(idtroll+'.caracs.rm',rm);
  9713. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  9714. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  9715. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  9716. MY_setValue(idtroll+'.caracs.mm',mm);
  9717. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  9718. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  9719. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  9720. MY_setValue(idtroll+'.caracs.armure',arm);
  9721. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  9722. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  9723. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  9724. MY_setValue(idtroll+'.position.X',posX);
  9725. MY_setValue(idtroll+'.position.Y',posY);
  9726. MY_setValue(idtroll+'.position.N',posN);
  9727. MY_setValue(idtroll+'.race',race);
  9728. MY_setValue(idtroll+'.niveau',niv);
  9729. MY_setValue(idtroll+'.idguilde',idguilde);
  9730. MY_setValue(idtroll+'.nomguilde',nomguilde);
  9731. }
  9732.  
  9733.  
  9734. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  9735.  
  9736. function setInfosCaracteristiques() {
  9737. // Modification de l'entete
  9738. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  9739. thTotal.innerHTML+='|<i>Moyenne</i>';
  9740. thTotal.title="Moyenne (Moyenne ce tour)";
  9741.  
  9742. // Ajout des informations calculees
  9743. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  9744. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  9745. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  9746.  
  9747. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  9748. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  9749. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  9750.  
  9751. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  9752. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  9753. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  9754.  
  9755. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  9756. var tdRegTotal = trRegeneration.children[5];
  9757. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  9758. // Temps recupere par reg (propale R')
  9759. var regmoyTemp = Math.max(0, regmoy);
  9760. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  9761. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  9762. if (sec != 0) {
  9763. regTitle += " " + sec + " sec";
  9764. }
  9765. trRegeneration.title = regTitle;
  9766.  
  9767. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  9768. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  9769. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  9770.  
  9771. var trRM=document.querySelector("table#caracs #rm").parentElement;
  9772. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  9773. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  9774.  
  9775.  
  9776. var trMM=document.querySelector("table#caracs #mm").parentElement;
  9777. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  9778. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  9779.  
  9780. var tdRefl=document.querySelector("#refl");
  9781. // TODO : prendre en compte bonus/malus D esq du tour ?
  9782. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  9783. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  9784. }
  9785.  
  9786. function setLienAnatrolliseur(){
  9787. var pTableAmelio = document.querySelector("#carac>div>p");
  9788. pTableAmelio.innerHTML+=" - ";
  9789. var aElt = document.createElement("a");
  9790. aElt.setAttribute("href",urlAnatrolliseur);
  9791. aElt.setAttribute("target","_blank");
  9792. aElt.className="AllLinks";
  9793. aElt.innerHTML="Anatrolliser";
  9794. pTableAmelio.appendChild(aElt);
  9795. }
  9796. function setInfoDescription() {
  9797. var txtDateCrea = (NBjours!=1) ?
  9798. " ("+NBjours+" jours dans le hall)" :
  9799. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  9800. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  9801. }
  9802.  
  9803. function setInfosEtatLieux() {
  9804. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  9805. '?search=position&orderBy=distance&posx='+
  9806. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  9807. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  9808. appendBr(tdPosition);
  9809. var aElt = document.createElement("a");
  9810. aElt.setAttribute("href",urlBricol);
  9811. aElt.setAttribute("target","_blank");
  9812. aElt.className="AllLinks";
  9813. aElt.innerHTML="Lieux à proximité";
  9814. tdPosition.appendChild(aElt);
  9815. }
  9816.  
  9817. function setInfosEtatPV() { // pour AM et Sacro
  9818. var
  9819. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  9820. sec = Math.floor(15000/pvtotal)%60,
  9821. lifebar = document.querySelector("#pos .barre-vie");
  9822. if(sec!=0) { txt += " "+sec+" sec"; }
  9823. if(lifebar) { lifebar.title = txt; }
  9824. if(pvcourant<=0) { return; }
  9825. // Difference PV p/r a equilibre de temps (propale R')
  9826. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  9827. // ***INIT GLOBALE*** pvdispo
  9828. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  9829. var span = document.createElement("span");
  9830. span.title = txt;
  9831. span.style.fontStyle = "italic";
  9832. if(bmt+pdm>=0) {
  9833. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  9834. } else if(pvdispo>0) {
  9835. txt = "Vous pouvez encore perdre "+
  9836. Math.min(pvdispo,pvcourant)+
  9837. " PV sans malus de temps.";
  9838. } else if(pvdispo<0) {
  9839. txt = "Il vous manque "
  9840. +(-pvdispo)
  9841. +" PV pour ne plus avoir de malus de temps.";
  9842. } else {
  9843. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  9844. }
  9845. appendText(span,txt);
  9846. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  9847. }
  9848.  
  9849. // Complete le cadre "Experience"
  9850. function setInfosExp() {
  9851. var tdNiv = document.querySelector("#exp #niv");
  9852.  
  9853. // Calcul niveau monstre/troll min pour gain PX
  9854. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  9855. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  9856.  
  9857. // Calcul PX restant
  9858. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  9859. if (pxRestant >= 0) {
  9860. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  9861. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  9862. }
  9863.  
  9864. // Calul pi/jour
  9865. var
  9866. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  9867. tdPi = document.querySelector("#exp #pi").parentElement;
  9868. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  9869. tdPi.title = tdPiTotal.title;
  9870.  
  9871. // Rapports meurtres,morts
  9872. var tdKill = document.querySelector("#exp #kill");
  9873. tdKill.setAttribute("colspan", 1);
  9874. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  9875.  
  9876. var tdMort = document.querySelector("#exp #mort");
  9877. tdMort.setAttribute("colspan", 1);
  9878. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  9879.  
  9880. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  9881. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  9882. }
  9883.  
  9884.  
  9885. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  9886.  
  9887. function minParPVsac(fat,bm) {
  9888. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  9889. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  9890. var out = [];
  9891. out[0] = (fat>4) ?
  9892. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  9893. 30;
  9894. if(bm && bm>0) {
  9895. var totalfat=fat+bm;
  9896. out[1] = (totalfat>4) ?
  9897. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  9898. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  9899. }
  9900. return out;
  9901. }
  9902.  
  9903. function toInt(str) {
  9904. str = parseInt(str);
  9905. return (str) ? str : 0;
  9906. }
  9907.  
  9908. function saveLastDLA() {
  9909. // pour les calculs d'AM max
  9910. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  9911. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  9912. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  9913. lastDLA = new Date( StringToDate(str) );
  9914. MY_setValue(numTroll+'.DLA.ancienne',str);
  9915. lastDLAZone.innerHTML = '';
  9916. var b = document.createElement('b');
  9917. b.addEventListener('click',inputMode,false);
  9918. appendText(b,str);
  9919. lastDLAZone.appendChild(b);
  9920. refreshAccel();
  9921. }
  9922.  
  9923. function inputMode() {
  9924. // Edition manuelle lastDLA
  9925. var date;
  9926. if(lastDLA)
  9927. date = new Date( lastDLA );
  9928. else
  9929. date = new Date( DLAaccel );
  9930. lastDLAZone.innerHTML = '';
  9931. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  9932. appendText(lastDLAZone,'/');
  9933. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  9934. appendText(lastDLAZone,'/');
  9935. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  9936. appendText(lastDLAZone,' - ');
  9937. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  9938. appendText(lastDLAZone,':');
  9939. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  9940. appendText(lastDLAZone,':');
  9941. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  9942. appendText(lastDLAZone,' - ');
  9943. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  9944. }
  9945.  
  9946. function setAccel() {
  9947. var
  9948. BMfrais=false,
  9949. fat=fatigue, listeBmFat=[],
  9950. tr, th, insertPt;
  9951.  
  9952. // Creation ligne speciale pour AM dans le cadre "Etat"
  9953. tr = document.createElement('tr');
  9954. th = document.createElement('th');
  9955. appendText(th,'Fatigue et AM',true);
  9956. tr.appendChild(th);
  9957. insertPt = document.createElement('td');
  9958. tr.appendChild(insertPt);
  9959. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  9960.  
  9961. // Est-on en over-DLA ?
  9962. // ***INIT GLOBALE*** overDLA
  9963. overDLA = (HeureServeur>DLA.getTime()+3e5);
  9964. if(overDLA) {
  9965. fat=Math.floor(fatigue/1.25);
  9966. }
  9967.  
  9968. // Gestion des BM de fatigue
  9969. if(bmfatigue>0) {
  9970. // On tente de recuperer les BM de fatigue de la page des BM
  9971. if(MY_getValue(numTroll+'.bm.fatigue')) {
  9972. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  9973. BMmemoire.pop();
  9974. var tour = 0;
  9975. for(var i=0 ; i<BMmemoire.length ; i++) {
  9976. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  9977. while(tour<=parseInt(nbrs[0])) {
  9978. listeBmFat[tour]=parseInt(nbrs[1]);
  9979. tour++;
  9980. }
  9981. }
  9982. }
  9983. if(listeBmFat[0]==bmfatigue) {
  9984. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  9985. BMfrais = true;
  9986. MY_removeValue(numTroll+".bm.fatigue");
  9987. }
  9988. } else {
  9989. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  9990. BMfrais = true;
  9991. }
  9992. if(!BMfrais && bmfatigue>0) {
  9993. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  9994. if(bmfatigue==15) {
  9995. listeBmFat = [15,15,15];
  9996. } else {
  9997. listeBmFat = [30,30,15];
  9998. }
  9999. }
  10000. if(overDLA) {
  10001. // Si on est en over-DLA, on decale les bm d'un tour
  10002. listeBmFat.shift();
  10003. }
  10004. // Tableau des fatigues et accel futures
  10005. var
  10006. minppv = minParPVsac(fat,listeBmFat[0]),
  10007. table, tbody,
  10008. ligneTour, ligneFat, ligneMin,
  10009. col;
  10010. // ***INIT GLOBALE*** minParPV
  10011. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10012. if(fat>0 || listeBmFat[0]>0) {
  10013. table = document.createElement('table');
  10014. table.className = 'mh_tdborder';
  10015. table.border = 0;
  10016. table.cellSpacing = 1;
  10017. table.cellPadding = 1;
  10018. table.style.textAlign = "center";
  10019. tbody = document.createElement('tbody');
  10020. table.appendChild(tbody);
  10021. insertPt.appendChild(table);
  10022. ligneTour = appendTr(tbody,'mh_tdtitre');
  10023. ligneTour.style.fontWeight = "bold";
  10024. var td = appendTdText(ligneTour,'Tour :',true);
  10025. td.align = 'left';
  10026. ligneFat = appendTr(tbody,'mh_tdpage');
  10027. td = appendTdText(ligneFat,'Fatigue :',true);
  10028. td.className = 'mh_tdtitre';
  10029. td.align = 'left';
  10030. ligneMin = appendTr(tbody,'mh_tdpage');
  10031. td = appendTdText(ligneMin,'1 PV =',true);
  10032. td.className = 'mh_tdtitre';
  10033. td.align = 'left';
  10034. col=0;
  10035. while(col<9 && (fat>0 || listeBmFat[col])) {
  10036. if(col==0) {
  10037. if(overDLA) {
  10038. var i = document.createElement('i');
  10039. appendText(i,'A activer');
  10040. ligneTour.appendChild(i);
  10041. } else {
  10042. appendTdText(ligneTour,'En cours');
  10043. }
  10044. } else {
  10045. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10046. }
  10047. if(listeBmFat[col]) {
  10048. if(BMfrais || (!overDLA && col==0)) {
  10049. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10050. appendTdText(ligneMin,minppv[1]+'\'');
  10051. } else {
  10052. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10053. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10054. }
  10055. } else {
  10056. appendTdText(ligneFat,fat);
  10057. appendTdText(ligneMin,minppv[0]+'\'');
  10058. }
  10059. col++;
  10060. fat = Math.floor(fat / 1.25);
  10061. minppv = minParPVsac(fat,listeBmFat[col]);
  10062. }
  10063. if(fat>1 || (fat==1 && !overDLA)) {
  10064. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10065. appendTdText(ligneFat,'-');
  10066. appendTdText(ligneMin,'-');
  10067. }
  10068. col = (overDLA) ?
  10069. Math.max(retourAZero(fatigue)-1,col) :
  10070. Math.max(retourAZero(fatigue),col);
  10071. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10072. appendTdText(ligneFat,'0');
  10073. appendTdText(ligneMin,'30\'');
  10074. if(!BMfrais && bmfatigue) {
  10075. // si les BM n'ont pas ete rafraichis, on signale:
  10076. appendText(
  10077. insertPt,
  10078. '/!\\ Visitez la page des Bonus/Malus '+
  10079. 'pour mettre à jour votre fatigue. /!\\',
  10080. true
  10081. );
  10082. appendBr(insertPt);
  10083. }
  10084. appendBr(insertPt);
  10085. }
  10086. if(pvcourant<=0) {
  10087. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10088. return;
  10089. }
  10090. if(fatigue>30) {
  10091. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10092. return;
  10093. }
  10094. // Setup lastDLAZone
  10095. if(overDLA) {
  10096. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10097. DLAaccel = new Date( DLAsuiv );
  10098. lastDLA = new Date( DLA );
  10099. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10100. // ***INIT GLOBALE*** pvActuelKastar
  10101. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10102. appendText(
  10103. insertPt,
  10104. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10105. true
  10106. );
  10107. appendBr(insertPt);
  10108. } else {
  10109. DLAaccel = new Date( DLA );
  10110. pvActuelKastar = pvcourant;
  10111. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10112. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10113. } else {
  10114. lastDLA = false;
  10115. }
  10116. }
  10117. appendText(insertPt,'Dernière DLA enregistrée : ');
  10118. lastDLAZone = document.createElement('span');
  10119. lastDLAZone.style.cursor = 'pointer';
  10120. var b = document.createElement('b');
  10121. b.onclick = inputMode;
  10122. lastDLAZone.appendChild(b);
  10123. insertPt.appendChild(lastDLAZone);
  10124. if(lastDLA) {
  10125. appendText(b,DateToString(lastDLA));
  10126. } else {
  10127. appendText(b,'aucune');
  10128. }
  10129. appendBr(insertPt);
  10130. // Setup maxAMZone et cumulZone
  10131. appendText(insertPt,'Accélération maximale possible : ');
  10132. maxAMZone = document.createElement('b');
  10133. insertPt.appendChild(maxAMZone);
  10134. appendBr(insertPt);
  10135. cumulZone = document.createElement('span');
  10136. insertPt.appendChild(cumulZone);
  10137. refreshAccel();
  10138. }
  10139.  
  10140. function refreshAccel() {
  10141. var pvs, pvsmax;
  10142. // Acceleration pour cumul instantane
  10143. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10144. if(lastDLA) {
  10145. pvsmax = Math.min(
  10146. pvActuelKastar-1,
  10147. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10148. );
  10149. maxAMZone.innerHTML = pvsmax+" PV";
  10150. } else {
  10151. pvsmax = pvActuelKastar-1;
  10152. maxAMZone.innerHTML = "inconnue";
  10153. }
  10154. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10155. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10156. cumulZone.innerHTML = '';
  10157. if(pvs<=pvsmax) {
  10158. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10159. appendText(cumulZone,pvs+' PV', true);
  10160. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10161. if(pvs!=1) {
  10162. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10163. -(pvs-1)*60*minParPV;
  10164. appendText(
  10165. cumulZone,
  10166. ' ('+(pvs-1)+' PV dans '+
  10167. Math.floor(gainSec/60)+'min'+
  10168. addZero(gainSec%60)+'s)'
  10169. );
  10170. }
  10171. } else {
  10172. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10173. appendText(
  10174. cumulZone,
  10175. 'Après votre accélération maximale, il vous faudra encore attendre '+
  10176. dureeHM(avantDLA/6e4)+
  10177. ' avant de réactiver.'
  10178. );
  10179. }
  10180. }
  10181.  
  10182.  
  10183. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  10184.  
  10185. function traitementTalents() {
  10186. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  10187. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  10188. removeAllTalents();
  10189. var totalComp = injecteInfosBulles(trCompetence,'competences');
  10190. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  10191. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  10192. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  10193. }
  10194.  
  10195. function injecteInfosBulles(liste,fonction) {
  10196. var totalpc = 0;
  10197. // on parse la liste des talents du type 'fonction'
  10198. for(var i=0 ; i<liste.length ; i++) {
  10199. var
  10200. trTalent=liste[i],
  10201. node=trTalent.cells[1].querySelector('a'),
  10202. nomTalent=epure(trim(node.textContent)),
  10203. indiceTDniveaux=7,
  10204. indiceTDSousCompetence=2,
  10205. sousCompetences=undefined;
  10206. if(fonction=="competences"){
  10207. // un TD en plus pour des information complementaire liees a la comp
  10208. indiceTDniveaux++;
  10209. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  10210. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  10211. for (var j=0; j < sousCompetences.length; j++) {
  10212. sousCompetences[j] = sousCompetences[j].epure().trim();
  10213. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  10214. }
  10215. }
  10216. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  10217. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  10218. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  10219. totalpc += niveauxMaitrisesTalentArray[1];
  10220.  
  10221. // stockage des niveaux inferieurs du talent si presents
  10222. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  10223. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  10224. totalpc+=niveauxMaitrisesTalentArray[j+1];
  10225. }
  10226. }
  10227. return totalpc;
  10228. }
  10229.  
  10230. function setInfos(node,nom,fonction,niveau) {
  10231. node.nom = nom;
  10232. node.fonction = fonction;
  10233. node.niveau = niveau;
  10234. node.onmouseover = setBulle;
  10235. node.onmouseout = cacherBulle;
  10236. }
  10237.  
  10238. var arrayModifAnatroll = {
  10239. 'Glue':'Glu',
  10240. 'PuM':'PuiM',
  10241. 'HE':'Hurlement',
  10242. //'Insultes':'Insu',
  10243. 'Pistage':'Pist',
  10244. 'PuC':'Planter'
  10245. }
  10246.  
  10247. function setTalent(nom,pc,niveau,sousCompetences) {
  10248. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  10249. // (et pas les % dont osf) ne serait pas plus rentable
  10250. var nomEnBase = arrayTalents[epure(nom)];
  10251. if(!nomEnBase) { return; }
  10252. if(!niveau) { niveau = 1; }
  10253. switch(nomEnBase) {
  10254. case 'Insultes':
  10255. urlAnatrolliseur += 'Insu'+niveau+'|';
  10256. case 'IdT':
  10257. nomEnBase += niveau;
  10258. break;
  10259. case 'Golemo':
  10260. case 'Piege':
  10261. for (var i=0 ; i < sousCompetences.length ; i++) {
  10262. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  10263. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  10264. }
  10265. break;
  10266. case 'AP':
  10267. case 'Baroufle':
  10268. case 'CdB':
  10269. case 'CdM':
  10270. case 'Parer':
  10271. case 'Retraite':
  10272. case 'RB':
  10273. case 'SInterposer':
  10274. nomEnBase += niveau;
  10275. default:
  10276. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  10277. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  10278. }
  10279. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  10280. }
  10281.  
  10282. function creerBulleVide() {
  10283. var table = document.createElement('table');
  10284. table.id = 'bulle';
  10285. table.className = 'mh_tdborder';
  10286. table.width = 300;
  10287. table.border = 0;
  10288. table.cellPadding = 5;
  10289. table.cellSpacing = 1;
  10290. table.style =
  10291. 'position:absolute;'
  10292. +'visibility:hidden;'
  10293. +'z-index:800;'
  10294. +'height:auto;';
  10295. var tr = appendTr(table,'mh_tdtitre');
  10296. appendTdText(tr,'Titre');
  10297. tr = appendTr(table,'mh_tdpage');
  10298. appendTdText(tr,'Contenu');
  10299. var aList = document.getElementsByTagName('a');
  10300. aList[aList.length-1].parentNode.appendChild(table);
  10301. }
  10302.  
  10303. function cacherBulle() {
  10304. if(bulleStyle)
  10305. bulleStyle.visibility = 'hidden';
  10306. }
  10307.  
  10308. function setBulle(evt) {
  10309. var nom = this.nom;
  10310. var fonction = this.fonction;
  10311. var niveau = parseInt(this.niveau);
  10312. var str='';
  10313. if(fonction=='competences'){
  10314. str=competences(nom,niveau);
  10315. } else if(fonction=='sortileges') {
  10316. str=sortileges(nom,true);
  10317. }
  10318. if(str=='') return;
  10319. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  10320. var xfenetre, yfenetre, xpage, ypage, element = null;
  10321. var offset = 15;
  10322. var bulleWidth = 300;
  10323. if(!hauteur) hauteur = 50;
  10324. element = document.getElementById('bulle');
  10325. xfenetre = evt.clientX;
  10326. yfenetre = evt.clientY;
  10327. xpage = xfenetre;
  10328. ypage = yfenetre;
  10329. if(evt.pageX) xpage = evt.pageX;
  10330. if(evt.pageY) ypage = evt.pageY;
  10331. if(element) {
  10332. bulleStyle = element.style;
  10333. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  10334. element.childNodes[1].firstChild.innerHTML = str;
  10335. }
  10336. if(bulleStyle) {
  10337. if(xfenetre>bulleWidth+offset)
  10338. xpage -= bulleWidth+offset;
  10339. else
  10340. xpage += offset;
  10341. if(yfenetre>hauteur+offset)
  10342. ypage -= hauteur + offset;
  10343. bulleStyle.width = bulleWidth;
  10344. bulleStyle.left = xpage + 'px';
  10345. bulleStyle.top = ypage + 'px';
  10346. bulleStyle.visibility = 'visible';
  10347. }
  10348. }
  10349.  
  10350.  
  10351. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  10352.  
  10353. function competences(comp,niveau) {
  10354. var texte = '';
  10355. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  10356. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  10357. if(minParPV>1) texte += 's';
  10358. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  10359. }
  10360. else if(comp.indexOf('Attaque Precise')!=-1) {
  10361. var pc, lastmax=0, espatt=0;
  10362. var notMaxedOut = false;
  10363. for(var i=niveau ; i>0 ; i--) {
  10364. pc = getTalent(comp,i);
  10365. if(lastmax!=0 && pc<=lastmax) continue;
  10366. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  10367. attbp+attbm;
  10368. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10369. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  10370. ' => <b>'+jetatt+'</b><br/>';
  10371. espatt += (pc-lastmax)*jetatt;
  10372. lastmax = pc;
  10373. if(i<niveau) notMaxedOut = true;
  10374. }
  10375. if(notMaxedOut) {
  10376. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  10377. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  10378. }
  10379. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  10380. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10381. }
  10382. else if(comp.indexOf('Balayage')!=-1)
  10383. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  10384. +' => <b>'+attmoy+'</b><br/>'
  10385. +'Effet : <b>Met à terre l\'adversaire</b>';
  10386. else if(comp.indexOf('Bidouille')!=-1)
  10387. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  10388. +'de votre inventaire avec le texte de votre choix.';
  10389. else if(comp.indexOf('Baroufle')!=-1){
  10390. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  10391. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  10392. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  10393. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  10394. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  10395. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  10396. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  10397. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  10398. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  10399. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  10400. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  10401. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  10402. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  10403. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  10404. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  10405. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  10406. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  10407. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  10408. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  10409. '</tbody></table>';
  10410. }
  10411. else if(comp.indexOf('Botte Secrete')!=-1){
  10412. texte = 'Attaque : <b>'
  10413. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10414. +' => <b>'
  10415. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  10416. +'</b><br/>Dégâts : <b>'
  10417. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  10418. +' => <b>'
  10419. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  10420. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  10421. +'</b>';
  10422. }
  10423. else if(comp.indexOf('Camouflage')!=-1) {
  10424. var camou = getTalent('Camouflage');
  10425. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  10426. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  10427. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  10428. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  10429. }
  10430. else if(comp.indexOf('Charger')!=-1) {
  10431. if(pvcourant<=0)
  10432. return '<i>On ne peut charger personne quand on est mort !</i>';
  10433. var portee = Math.min(
  10434. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  10435. vuetotale);
  10436. if(portee<1)
  10437. return '<b>Impossible de charger</b>';
  10438. else {
  10439. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10440. +' => <b>'+attmoy+'</b><br/>'
  10441. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10442. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  10443. +'<br/>Portée : <b>'+portee+'</b> case';
  10444. if(portee>1) texte += 's';
  10445. }
  10446. }
  10447. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  10448. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  10449. if(vuetotale>1) texte += 's';
  10450. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10451. if(vuetotale>2) texte += 's';
  10452. }
  10453. else if(comp.indexOf('Piege')!=-1) {
  10454. if(comp.indexOf('Glue')!=-1)
  10455. texte = 'Et si vous colliez vos adversaires au sol ?';
  10456. if(comp.indexOf('Feu')!=-1) {
  10457. if(texte){
  10458. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  10459. }
  10460. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  10461. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  10462. }
  10463. }
  10464. else if(comp.indexOf('Contre-Attaquer')!=-1){
  10465. texte = 'Attaque : <b>'
  10466. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10467. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10468. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10469. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10470. }
  10471. else if(comp.indexOf('Coup de Butoir')!=-1) {
  10472. var pc, lastmax=0, espdeg=0;
  10473. var notMaxedOut = false;
  10474. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10475. +' => <b>'+attmoy+'</b>';
  10476. for(var i=niveau ; i>0 ; i--) {
  10477. pc = getTalent(comp,i);
  10478. if(lastmax!=0 && pc<=lastmax) continue;
  10479. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  10480. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10481. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  10482. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  10483. espdeg += (pc-lastmax)*jetdeg;
  10484. lastmax = pc;
  10485. if(i<niveau) notMaxedOut = true;
  10486. }
  10487. if(notMaxedOut) {
  10488. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  10489. Math.floor(10*espdeg/lastmax)/10+'/'+
  10490. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  10491. }
  10492. }
  10493. else if(comp.indexOf('Course')!=-1)
  10494. texte = 'Déplacement gratuit : <b>'
  10495. +Math.floor(getTalent('Course')/2)
  10496. +' %</b> de chance';
  10497. else if(comp.indexOf('Deplacement Eclair')!=-1)
  10498. texte = 'Permet d\'économiser <b>1</b> PA '
  10499. +'par rapport au déplacement classique';
  10500. else if(comp.indexOf('Dressage')!=-1)
  10501. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  10502. +'ou un gnu sauvage.';
  10503. else if(comp.indexOf('Ecriture Magique')!=-1)
  10504. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  10505. +'la formule nécessite de réunir les composants de cette formule, '
  10506. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  10507. +'un champignon adéquat pour confectionner l\'encre.';
  10508. else if(comp.indexOf('Frenesie')!=-1) {
  10509. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10510. +' => <b>'+attmoy+'</b><br/>'
  10511. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10512. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10513. }
  10514. else if(comp.indexOf('Golem')!=-1)
  10515. texte = 'Animez votre golem en assemblant divers matériaux '
  10516. +'autour d\'un cerveau minéral.'
  10517. else if(comp.indexOf('Grattage')!=-1) {
  10518. texte = 'Permet de confectionner un Parchemin Vierge '
  10519. +'à partir de composants et de Gigots de Gob\'.';
  10520. }
  10521. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  10522. texte = 'Fait fuir un monstre si tout se passe bien.'
  10523. +'<br/>Lui donne de gros bonus sinon...';
  10524. else if(comp.indexOf('Identification des Champignons')!=-1) {
  10525. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10526. if(vuetotale>2) texte += 's';
  10527. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  10528. if(vuetotale>4) texte += 's';
  10529. }
  10530. else if(comp.indexOf('Insultes')!=-1)
  10531. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  10532. else if(comp.indexOf('interposer')!=-1)
  10533. texte = 'Jet de réflexe : <b>'
  10534. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  10535. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  10536. else if(comp.indexOf('Lancer de Potions') != -1)
  10537. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  10538. else if(comp.indexOf('Marquage')!=-1)
  10539. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  10540. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  10541. +'se trouver dans la même caverne que le monstre pour le marquer.';
  10542. else if(comp.indexOf('Melange Magique')!=-1)
  10543. texte = 'Cette Compétence permet de combiner deux Potions pour '
  10544. +'en réaliser une nouvelle dont l\'effet est la somme '
  10545. +'des effets des potions initiales.';
  10546. else if(comp.indexOf('Miner')!=-1)
  10547. texte = 'Portée horizontale (officieuse) : <b>'
  10548. +2*vuetotale+'</b> cases<br/>'
  10549. +'Portée verticale (officieuse) : <b>'
  10550. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10551. else if(comp.indexOf('Necromancie')!=-1)
  10552. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  10553. +'de faire "revivre" ce monstre.';
  10554. else if(comp.indexOf('Painthure de Guerre')!=-1)
  10555. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  10556. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  10557. +'pour s\'inspirer, et laissez parler votre créativité.'
  10558. else if(comp.indexOf('Parer')!=-1)
  10559. texte = 'Jet de parade : <b>'
  10560. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  10561. +' => <b>'
  10562. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10563. +'</b><hr><i>Equivalent esquive : <b>'
  10564. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  10565. +' => <b>'
  10566. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  10567. +'</b></i>';
  10568. else if(comp.indexOf('Pistage')!=-1)
  10569. texte = 'Portée horizontale : <b>'
  10570. +2*vuetotale+'</b> cases<br/>'
  10571. +'Portée verticale : <b>'
  10572. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10573. else if(comp.indexOf('Planter un Champignon')!=-1)
  10574. texte = 'Planter un Champignon est une compétence qui vous permet de '
  10575. +'créer des colonies d\'une variété donnée de champignon à partir de '
  10576. +'quelques exemplaires préalablement enterrés.';
  10577. else if(comp.indexOf('Regeneration Accrue')!=-1)
  10578. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  10579. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  10580. else if(comp.indexOf('Reparation')!=-1)
  10581. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  10582. +'et réparez vous-même votre matériel !';
  10583. else if(comp.indexOf('Retraite')!=-1)
  10584. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  10585. +'préférable de préparer un repli stratégique pour déconcerter '
  10586. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  10587. +'Quelle intelligence démoniaque.';
  10588. else if(comp.indexOf('Rotobaffe')!=-1) {
  10589. var Datt = att, vattbm = attbp+attbm;
  10590. var Ddeg = deg, vdegbm = degbp+degbm;
  10591. for(var i=1 ; i<niveau+2 ; i++) {
  10592. texte += '<b>Attaque n°'+i+' :</b><br/>'
  10593. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  10594. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  10595. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  10596. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  10597. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  10598. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  10599. if(i<niveau+1) texte += '<hr>';
  10600. }
  10601. }
  10602. else if(comp.indexOf('Shamaner')!=-1)
  10603. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  10604. +'des monstres en utilisant des champignons (de 1 à 3).';
  10605. else if(comp.indexOf('Tailler')!=-1){
  10606. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  10607. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  10608. }
  10609. return texte;
  10610. }
  10611.  
  10612. function decumul_buff(nom,str,buff) {
  10613. // Decumul des sorts de buff
  10614. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  10615. var dec = buff, total = buff, i=1;
  10616. while(i<6) {
  10617. i++;
  10618. dec = Math.floor(coefDecumul(i)*buff);
  10619. if(dec<=1 || i==6) break;
  10620. total += dec;
  10621. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  10622. +str+' +'+dec+' (+'+total+')</i>';
  10623. }
  10624. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  10625. return ret;
  10626. }
  10627.  
  10628.  
  10629. function sortileges(sort,mainCall,pcA,pcD) {
  10630. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  10631. var texte = '';
  10632. if (mainCall) {
  10633. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  10634. pcA = (atttourP+atttourM);
  10635. pcD = (degtourP+degtourM);
  10636. }
  10637. if (sort.indexOf('Analyse Anatomique') != -1) {
  10638. texte = 'Portée horizontale : <b>'
  10639. + Math.floor(vuetotale / 2) + '</b> case';
  10640. if (vuetotale > 3){ texte += 's'; }
  10641. texte += '<br/>Portée verticale : <b>'
  10642. + Math.floor((vuetotale+1)/4)+'</b> case';
  10643. if (vuetotale > 7){ texte += 's'; }
  10644. }
  10645. else if (sort.indexOf('Armure Etheree') != -1){
  10646. texte = decumul_buff('AE', 'Armure magique', reg);
  10647. }
  10648. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  10649. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  10650. }
  10651. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  10652. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  10653. }
  10654. else if (sort.indexOf('Augmentation des Degats') != -1){
  10655. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  10656. }
  10657. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  10658. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  10659. }
  10660. else if(sort.indexOf('Bulle Magique')!=-1){
  10661. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  10662. }
  10663. else if(sort.indexOf('Explosion')!=-1){
  10664. texte = 'Dégâts : <b>'
  10665. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  10666. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  10667. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  10668. }
  10669. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  10670. if(pvcourant<=0)
  10671. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  10672. texte = 'Portée horizontale : <b>'
  10673. +Math.min(1,vuetotale)+'</b> case<br/>'
  10674. +'Dégâts physiques : <b>-'
  10675. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  10676. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  10677. +'Dégâts magiques : <b>-'
  10678. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  10679. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  10680. }
  10681. else if(sort.indexOf('Flash Aveuglant')!=-1){
  10682. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  10683. }
  10684. else if(sort.indexOf('Glue')!=-1) {
  10685. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  10686. if(vuetotale>2) texte += 's';
  10687. }
  10688. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  10689. /* Frappe */
  10690. var modD = 0;
  10691. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10692. if(pcA!=0){
  10693. modD = parseInt(att*pcA/100);
  10694. texte += '<i>'+aff(modD)+'D6</i> ';
  10695. }
  10696. texte += aff(attbm)
  10697. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  10698. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  10699. if(pcD!=0) {
  10700. modD = parseInt(Math.floor(deg/2)*pcD/100);
  10701. texte += '<i>'+aff(modD)+'D3</i> ';
  10702. }else
  10703. modD = 0;
  10704. texte += aff(degbm)+' => <b>'
  10705. +(2*(Math.floor(deg/2)+modD)+degbm)
  10706. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  10707. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  10708. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  10709. +')</b>';
  10710. if(!mainCall) return texte;
  10711. /* Venins */
  10712. function addVenin(type,effet,duree) {
  10713. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  10714. +' pendant <b>'+duree+'</b> tour';
  10715. if(duree>1) ret += 's';
  10716. var dred = Math.max(Math.floor(duree/2),1);
  10717. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  10718. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  10719. }
  10720. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  10721. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  10722. effet = Math.floor(1.5*effet);
  10723. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  10724. }
  10725. else if(sort.indexOf('Hypnotisme')!=-1)
  10726. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  10727. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  10728. else if(sort.indexOf('Identification des tresors')!=-1)
  10729. texte = 'Permet de connaitre les caractéristiques et effets précis '
  10730. +'d\'un trésor.';
  10731. else if(sort.indexOf('Invisibilite')!=-1)
  10732. texte = 'Un troll invisible est indétectable même quand on se trouve '
  10733. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  10734. +'fait disparaître l\'invisibilité.';
  10735. else if(sort.indexOf('Levitation')!=-1)
  10736. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  10737. +'Comme les pièges ou les trous par exemple...';
  10738. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  10739. var eps = 1,
  10740. pc = 20;
  10741. var str = 'PréM';
  10742. var newSort;
  10743. var sortAtt = [
  10744. 'Projectile Magique',
  10745. 'Rafale Psychique',
  10746. 'Siphon des Ames',
  10747. 'Vampirisme',
  10748. 'Griffe du Sorcier'
  10749. ];
  10750. if(sort.indexOf('Puissance')!=-1) {
  10751. eps = -1; str='PuM';
  10752. }
  10753. for(var i=1 ; i<4 ; i++) {
  10754. if(texte) { texte += '<hr>'; }
  10755. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  10756. newSort = false;
  10757. for(var j=0 ; j<sortAtt.length ; j++) {
  10758. if(getTalent(sortAtt[j])) {
  10759. if(newSort) { texte += '<br/><br/>'; }
  10760. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  10761. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  10762. newSort = true;
  10763. }
  10764. }
  10765. pc = decumulPumPrem(pc);
  10766. }
  10767. }
  10768. else if(sort.indexOf('Projectile Magique')!=-1) {
  10769. var modD = 0;
  10770. var portee = getPortee__Profil(vuetotale);
  10771. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  10772. if(pcA!=0) {
  10773. modD = parseInt(vue*pcA/100);
  10774. texte += '<i>'+aff(modD)+'D6</i> ';
  10775. }
  10776. texte += aff(attbm)
  10777. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  10778. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  10779. if(pcD!=0) {
  10780. modD = parseInt(Math.floor(vue/2)+pcD);
  10781. texte += '<i>'+aff(modD)+'D3</i> ';
  10782. }else
  10783. modD = 0;
  10784. texte += aff(degbm)
  10785. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  10786. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  10787. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  10788. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  10789. if(!mainCall) return texte;
  10790. texte += '<br/>Portée : <b>'+portee+'</b> case';
  10791. if(portee>1) texte += 's';
  10792. }
  10793. else if(sort.indexOf('Projection')!=-1) {
  10794. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  10795. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  10796. +'Si le jet de résistance de la victime est réussi:<br/>'
  10797. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  10798. }
  10799. else if(sort.indexOf('Rafale Psychique')!=-1) {
  10800. var modD = 0;
  10801. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  10802. if(pcD!=0) {
  10803. modD = parseInt(deg*pcD/100);
  10804. texte += '<i>'+aff(modD)+'D3</i> ';
  10805. }
  10806. texte += aff(degbm)
  10807. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  10808. if(!mainCall) return texte;
  10809. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  10810. }
  10811. else if(sort.indexOf('Sacrifice')!=-1) {
  10812. if(pvcourant<=0)
  10813. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  10814.  
  10815. function perteSacro(sac) {
  10816. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  10817. }
  10818.  
  10819. var sac = Math.floor((pvcourant-1)/2);
  10820. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10821. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  10822. /* Sacros max et optimal sans malus (propale R') */
  10823. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10824. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  10825. if(sac>0)
  10826. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  10827. else
  10828. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  10829. /*if(sac>3) {
  10830. sac = 5*Math.floor((sac+1)/5)-1;
  10831. texte += '<br/>Soin optimal sans malus de temps : <b>'
  10832. +sac+'</b> PV'+perteSacro(sac);
  10833. }*/
  10834. }
  10835. else if(sort.indexOf('Siphon')!=-1) {
  10836. var modD = 0;
  10837. texte = 'Attaque : <b>'+att+'</b> D6 ';
  10838. if(pcA!=0) {
  10839. modD = parseInt(att*pcA/100);
  10840. texte += '<i>'+aff(modD)+'D6</i> ';
  10841. }
  10842. texte += aff(attbm)
  10843. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  10844. +'Dégâts : <b>'+reg+'</b> D3 ';
  10845. if(pcD!=0) {
  10846. modD = parseInt(reg*pcD/100);
  10847. texte += '<i>'+aff(modD)+'D3</i> ';
  10848. }else
  10849. modD = 0;
  10850. texte += aff(degbm)
  10851. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  10852. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  10853. if(!mainCall) return texte;
  10854. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  10855. }
  10856. else if(sort.indexOf('Telekinesie')!=-1) {
  10857. texte = 'Portée horizontale :';
  10858. var vt = Math.floor(vuetotale/2)+2;
  10859. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  10860. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  10861. for(var i=0 ; i<5 ; i++) {
  10862. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  10863. if(vt>1) texte += 's';
  10864. vt=Math.max(0,vt-1);
  10865. }
  10866. }
  10867. else if(sort.indexOf('Teleportation')!=-1) {
  10868. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  10869. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  10870. var pmh = (20+vue+portee);
  10871. var pmv = 3+Math.floor(portee/3);
  10872. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  10873. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  10874. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  10875. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  10876. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  10877. }
  10878. else if(sort.indexOf('Vampirisme')!=-1) {
  10879. var modD = 0;
  10880. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  10881. if(pcA!=0) {
  10882. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  10883. texte += '<i>'+aff(modD)+'D6</i> ';
  10884. }
  10885. texte += aff(attbm)
  10886. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  10887. +'Dégâts : <b>'+deg+'</b> D3 ';
  10888. if(pcD!=0) {
  10889. modD = parseInt(deg*pcD/100);
  10890. texte += '<i>'+aff(modD)+'D3</i> ';
  10891. }else
  10892. modD = 0;
  10893. texte += aff(degbm)
  10894. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  10895. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  10896. }
  10897. else if(sort.indexOf('Vision Accrue')!=-1)
  10898. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  10899. else if(sort.indexOf('Vision lointaine')!=-1)
  10900. texte = 'En ciblant une zone située n\'importe où dans le '
  10901. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  10902. else if(sort.indexOf('Voir le Cache')!=-1)
  10903. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  10904. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  10905. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  10906. +getPortee__Profil(vuetotale)+'</b> cases';
  10907. else if(sort.indexOf('Vue Troublee')!=-1)
  10908. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  10909. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  10910. return texte;
  10911. }
  10912.  
  10913.  
  10914. /*---------------------------------- Main ------------------------------------*/
  10915.  
  10916. function do_profil2()
  10917. {
  10918. try {
  10919. start_script(31);
  10920.  
  10921. extractionDonnees();
  10922. setInfosCaracteristiques();
  10923. setInfoDescription();
  10924. setInfosEtatLieux();
  10925. setInfosEtatPV();
  10926. setInfosExp();
  10927.  
  10928. creerBulleVide();
  10929. traitementTalents();
  10930. setLienAnatrolliseur();
  10931.  
  10932. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  10933. if(race=='Kastar'){ setAccel(); }
  10934. saveProfil();
  10935. displayScriptTime();
  10936. } catch(e) {
  10937. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10938. window.console.error(traceStack(e, 'profil2'));
  10939. }
  10940. }
  10941.  
  10942. /*******************************************************************************
  10943. * This file is part of Mountyzilla. *
  10944. * *
  10945. * Mountyzilla is free software; you can redistribute it and/or modify *
  10946. * it under the terms of the GNU General Public License as published by *
  10947. * the Free Software Foundation; either version 2 of the License, or *
  10948. * (at your option) any later version. *
  10949. * *
  10950. * Mountyzilla is distributed in the hope that it will be useful, *
  10951. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10952. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10953. * GNU General Public License for more details. *
  10954. * *
  10955. * You should have received a copy of the GNU General Public License *
  10956. * along with Mountyzilla; if not, write to the Free Software *
  10957. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10958. *******************************************************************************/
  10959.  
  10960. // x~x script_principal
  10961.  
  10962. function isPage(url) {
  10963. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  10964. }
  10965.  
  10966. // x~x md5.js
  10967. /*
  10968. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  10969. * Digest Algorithm, as defined in RFC 1321.
  10970. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  10971. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  10972. * Distributed under the BSD License
  10973. * See http://pajhome.org.uk/crypt/md5 for more info.
  10974. */
  10975.  
  10976. /*
  10977. * Configurable variables. You may need to tweak these to be compatible with
  10978. * the server-side, but the defaults work in most cases.
  10979. */
  10980. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  10981. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  10982. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  10983.  
  10984. /*
  10985. * These are the functions you'll usually want to call
  10986. * They take string arguments and return either hex or base-64 encoded strings
  10987. */
  10988. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  10989. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  10990. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  10991. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  10992. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  10993. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  10994.  
  10995. /*
  10996. * Perform a simple self-test to see if the VM is working
  10997. */
  10998. function md5_vm_test()
  10999. {
  11000. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11001. }
  11002.  
  11003. /*
  11004. * Calculate the MD5 of an array of little-endian words, and a bit length
  11005. */
  11006. function core_md5(x, len)
  11007. {
  11008. /* append padding */
  11009. x[len >> 5] |= 0x80 << ((len) % 32);
  11010. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11011.  
  11012. var a = 1732584193;
  11013. var b = -271733879;
  11014. var c = -1732584194;
  11015. var d = 271733878;
  11016.  
  11017. for(var i = 0; i < x.length; i += 16)
  11018. {
  11019. var olda = a;
  11020. var oldb = b;
  11021. var oldc = c;
  11022. var oldd = d;
  11023.  
  11024. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11025. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11026. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11027. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11028. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11029. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11030. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11031. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11032. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11033. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11034. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11035. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11036. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11037. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11038. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11039. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11040.  
  11041. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11042. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11043. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11044. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11045. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11046. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11047. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11048. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11049. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11050. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11051. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11052. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11053. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11054. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11055. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11056. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11057.  
  11058. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11059. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11060. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11061. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11062. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11063. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11064. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11065. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11066. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11067. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11068. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11069. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11070. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11071. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11072. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11073. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11074.  
  11075. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11076. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11077. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11078. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11079. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11080. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11081. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11082. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11083. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11084. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11085. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11086. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11087. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11088. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11089. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11090. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11091.  
  11092. a = safe_add(a, olda);
  11093. b = safe_add(b, oldb);
  11094. c = safe_add(c, oldc);
  11095. d = safe_add(d, oldd);
  11096. }
  11097. return Array(a, b, c, d);
  11098.  
  11099. }
  11100.  
  11101. /*
  11102. * These functions implement the four basic operations the algorithm uses.
  11103. */
  11104. function md5_cmn(q, a, b, x, s, t)
  11105. {
  11106. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11107. }
  11108. function md5_ff(a, b, c, d, x, s, t)
  11109. {
  11110. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11111. }
  11112. function md5_gg(a, b, c, d, x, s, t)
  11113. {
  11114. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11115. }
  11116. function md5_hh(a, b, c, d, x, s, t)
  11117. {
  11118. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11119. }
  11120. function md5_ii(a, b, c, d, x, s, t)
  11121. {
  11122. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11123. }
  11124.  
  11125. /*
  11126. * Calculate the HMAC-MD5, of a key and some data
  11127. */
  11128. function core_hmac_md5(key, data)
  11129. {
  11130. var bkey = str2binl(key);
  11131. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11132.  
  11133. var ipad = Array(16), opad = Array(16);
  11134. for(var i = 0; i < 16; i++)
  11135. {
  11136. ipad[i] = bkey[i] ^ 0x36363636;
  11137. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11138. }
  11139.  
  11140. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11141. return core_md5(opad.concat(hash), 512 + 128);
  11142. }
  11143.  
  11144. /*
  11145. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11146. * to work around bugs in some JS interpreters.
  11147. */
  11148. function safe_add(x, y)
  11149. {
  11150. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11151. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11152. return (msw << 16) | (lsw & 0xFFFF);
  11153. }
  11154.  
  11155. /*
  11156. * Bitwise rotate a 32-bit number to the left.
  11157. */
  11158. function bit_rol(num, cnt)
  11159. {
  11160. return (num << cnt) | (num >>> (32 - cnt));
  11161. }
  11162.  
  11163. /*
  11164. * Convert a string to an array of little-endian words
  11165. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11166. */
  11167. function str2binl(str)
  11168. {
  11169. var bin = Array();
  11170. var mask = (1 << chrsz) - 1;
  11171. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11172. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11173. return bin;
  11174. }
  11175.  
  11176. /*
  11177. * Convert an array of little-endian words to a string
  11178. */
  11179. function binl2str(bin)
  11180. {
  11181. var str = "";
  11182. var mask = (1 << chrsz) - 1;
  11183. for(var i = 0; i < bin.length * 32; i += chrsz)
  11184. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11185. return str;
  11186. }
  11187.  
  11188. /*
  11189. * Convert an array of little-endian words to a hex string.
  11190. */
  11191. function binl2hex(binarray)
  11192. {
  11193. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11194. var str = "";
  11195. for(var i = 0; i < binarray.length * 4; i++)
  11196. {
  11197. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11198. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11199. }
  11200. return str;
  11201. }
  11202.  
  11203. /*
  11204. * Convert an array of little-endian words to a base-64 string
  11205. */
  11206. function binl2b64(binarray)
  11207. {
  11208. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11209. var str = "";
  11210. for(var i = 0; i < binarray.length * 4; i += 3)
  11211. {
  11212. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11213. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11214. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11215. for(var j = 0; j < 4; j++)
  11216. {
  11217. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11218. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11219. }
  11220. }
  11221. return str;
  11222. }
  11223.  
  11224. ///////////////////////////////////////////
  11225. // debug cartes capitan Roule 07/12/2016
  11226. ///////////////////////////////////
  11227. // essais : objet
  11228. // .mode : description
  11229. // .essais : tableau d'objets essai
  11230. // .mode : description
  11231. // .essais : tableau de cartes
  11232. // .noCarte : id de la carte
  11233. // .essais : tableau d'essais, [x, y, n, nb]
  11234. function AfficheEssais(essais, sMode) {
  11235. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11236. if (!eBigDiv) {
  11237. var insertPoint = document.getElementById('footer1');
  11238. eBigDiv = document.createElement('table');
  11239. eBigDiv.id = 'ListeEssaiCapitan';
  11240. insertBefore(insertPoint, document.createElement('p'));
  11241. insertTitle(insertPoint,'Capitan : Liste des essais');
  11242. insertBefore(insertPoint, eBigDiv);
  11243. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11244. }
  11245. if (!essais) {
  11246. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11247. return;
  11248. }
  11249. var carte;
  11250. for (carte in essais) {
  11251. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11252. }
  11253. if (carte === undefined) {
  11254. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11255. }
  11256. }
  11257.  
  11258. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11259. var tr = appendTr(eTable);
  11260. var td = appendTd(tr);
  11261. appendText(td, sMode, bBold);
  11262. td = appendTd(tr);
  11263. appendText(td, sCarte, bBold);
  11264. td = appendTd(tr);
  11265. appendText(td, sText, bBold);
  11266. }
  11267.  
  11268. function getEssaiV1_0() {
  11269. try {
  11270. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11271. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11272. var tabK, nK;
  11273. prefs.getChildList('', nK, tabK);
  11274. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11275. //window.console.log('getEssaiV1_0, ' + nK);
  11276. return;
  11277. //return r;
  11278. } catch (e) {
  11279. window.console.log(traceStack(e, 'getEssaiV1_0'));
  11280. }
  11281. }
  11282.  
  11283. function getEssaiV1_1() {
  11284. var locSto = window.localStorage;
  11285. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11286. var r = [];
  11287. for (var i = 0; i < locSto.length; i++) {
  11288. var k = locSto.key(i);
  11289. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11290. var t = k.split(/\./);
  11291. if (t[0] !== 'capitan') continue;
  11292. if (t[2] !== 'essai') continue;
  11293. var carte = 'carte n°' + t[1];
  11294. if (r[carte]) r[carte]++;
  11295. else r[carte] = 1;
  11296. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11297. }
  11298. return r;
  11299. }
  11300.  
  11301. function showEssaiCartes() {
  11302. window.console.log('début showEssai Tout_MZ');
  11303. var essais = getEssaiV1_0();
  11304. AfficheEssais(essais, 'V1.0');
  11305. essais = getEssaiV1_1();
  11306. AfficheEssais(essais, 'V1.1');
  11307. window.console.log('fin showEssai Tout_MZ');
  11308. }
  11309.  
  11310. /*--------------------------------- Dispatch ---------------------------------*/
  11311.  
  11312. //chargerScriptDev("libs");
  11313. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  11314.  
  11315. try {
  11316. // Détection de la page à traiter
  11317. if(isPage("Messagerie/ViewMessageBot")) {
  11318. do_cdmbot();
  11319. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  11320. do_cdmcomp();
  11321. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  11322. do_diplo();
  11323. } else if(isPage("MH_Play/Play_equipement")) {
  11324. do_equip();
  11325. } else if(isPage("MH_Play/Play_menu")) {
  11326. do_menu();
  11327. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  11328. do_option();
  11329. //showEssaiCartes();
  11330. } else if(isPage("View/PJView")) {
  11331. do_pjview();
  11332. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  11333. do_profil();
  11334. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  11335. do_tancompo();
  11336. } else if(isPage("MH_Play/Play_vue")) {
  11337. do_vue();
  11338. } else if(isPage("MH_Play/Play_news")) {
  11339. do_news();
  11340. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  11341. do_move();
  11342. } else if(isPage("MH_Missions/Mission_Etape")) {
  11343. do_mission();
  11344. } else if(isPage("View/MonsterView")) {
  11345. do_infomonstre();
  11346. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  11347. do_attaque();
  11348. } else if(isPage("MH_Follower/FO_Ordres")) {
  11349. do_ordresgowap();
  11350. } else if(isPage("MH_Follower/FO_Equipement")) {
  11351. do_equipgowap();
  11352. } else if(isPage("MH_Play/Play_mouche")) {
  11353. do_mouches();
  11354. } else if(isPage("MH_Play/Play_BM")) {
  11355. do_malus();
  11356. } else if(isPage("MH_Play/Play_evenement")) {
  11357. do_myevent();
  11358. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  11359. do_enchant();
  11360. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  11361. do_pre_enchant();
  11362. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  11363. do_actions();
  11364. } 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')) {
  11365. do_mission_liste();
  11366. } else if(isPage('MH_Play/Play_action')) {
  11367. do_actions();
  11368. } else if(isPage('MH_Play/Play_profil2')) {
  11369. do_profil2();
  11370. }
  11371. } catch(e) {
  11372. if (e.stack) {
  11373. var sStack = e.stack;
  11374. // enlever les infos confidentielles
  11375. sStack = sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  11376. } else {var sStack = '';}
  11377. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  11378. }