Tout_MZ

Client MountyZilla

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

  1. // ==UserScript==
  2. // @name Tout_MZ
  3. // @namespace MH
  4. // @description Client MountyZilla
  5. // @include */mountyhall/*
  6. // @exclude *trolls.ratibus.net*
  7. // @exclude *it.mh.raistlin.fr*
  8. // @version 1.2.14
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // vérif UTF-8 éê
  13.  
  14. /*******************************************************************************
  15. * This file is part of Mountyzilla. *
  16. * *
  17. * Mountyzilla is free software; you can redistribute it and/or modify *
  18. * it under the terms of the GNU General Public License as published by *
  19. * the Free Software Foundation; either version 2 of the License, or *
  20. * (at your option) any later version. *
  21. * *
  22. * Mountyzilla is distributed in the hope that it will be useful, *
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  25. * GNU General Public License for more details. *
  26. * *
  27. * You should have received a copy of the GNU General Public License *
  28. * along with Mountyzilla; if not, write to the Free Software *
  29. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  30. *******************************************************************************/
  31.  
  32. // V1.1 : regroupement en un gros paquet sale
  33. // V1.2 : toujours un gros paquet sale, passage sous Greasemonkey
  34. // V1.2.1 :
  35. // include des URLs MH alternatives
  36. // regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose
  37. // Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte
  38. // V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues
  39. // V1.2.3 :
  40. // suppression ancien profil
  41. // nettoyage doublon sur getPortee
  42. // adaptation portee TP basée sur les PI
  43. // repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)
  44. // V1.2.4 14/10/2016
  45. // utilisation du relai raistlin pour l'envoi des CdM
  46. // V1.2.5 17/10/2016
  47. // correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence
  48. // remise en route de la gestion des options avec intégration md5 dans ce script
  49. // V1.2.6 19/10/2016
  50. // affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https
  51. // stockage idguilde et nomguilde
  52. // V1.2.7 07/11/2016
  53. // remise en route de l'interface avec l'IT bricol'Troll
  54. // V1.2.8 10/11/2016
  55. // gestion des messages d'erreur de l'interface avec l'IT bricol'Troll
  56. // déplacement des images sur l'infra raistlin + meilleure gestion HTTPS
  57. // V1.2.9 16/11/2016
  58. // adaptation Firefox 50 (comportement différent sur échec Ajax https)
  59. // V1.2.10 07/12/2016
  60. // correction décumul des bonus/malus
  61. // affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll
  62. // V1.2.10.1 08/12/2016
  63. // option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage
  64. // V1.2.10.2 09/12/2016
  65. // positionnement des Trõlls camou/invi à la bonne position par rapport à la distance
  66. // V1.2.10.3 09/12/2016
  67. // Adaptation à une modification du HTML MH (voir set2DViewSystem)
  68. // V1.2.10.4 12/12/2016
  69. // Correction bug à la récupération d'une erreur interface Bricoll'Troll
  70. // V1.2.11 13/12/2016
  71. // Passage sur BdD Raistlin \o/
  72. // V1.2.11.1 17/12/2016
  73. // Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un
  74. // V1.2.11.2 18/12/2016
  75. // Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil
  76. // V1.2.11.3 19/12/2016
  77. // Correction de la récupération des PI totaux (du coup la portée de TP était NaN)
  78. // Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours
  79. // V1.2.11.4 19/12/2016
  80. // Changement des couleurs de la barre de vie Interface Bricol'Troll
  81. // V1.2.11.5 à 7 20 & 21/12/2016
  82. // Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)
  83. // V1.2.12 24/12/2016
  84. // Nettoyage des URL
  85. // Mode dev (Shift+Click sur le mot "Crédits" dans Options/Pack Graphique) qui se branche sur le site de dev
  86. // Interface bricoll'Troll en https
  87. // Remise en marche des cartes des trajets des gowaps
  88. // V1.2.12.1 27/12/2016
  89. // Correction mode IP
  90. // Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)
  91. // V1.2.12.2 30/12/2016
  92. // retour en mode normal (http si jeu en http)
  93. // V1.2.13 01/01/2017
  94. // homogénéisation des messages d'erreur
  95. // Ajout du lien Troogle sur les étapes de mission monstre
  96. // V1.2.13.1 06/01/2017
  97. // Suppression oldSchoolProfile qui n'existe plus
  98. // Ajout du "refresh" du cadre de gauche
  99. // V1.2.13.2 07/01/2017
  100. // Correction missions, recherche troogle (familles et types de monstres)
  101. // V1.2.13.3 07/01/2017
  102. // Correction erreur sur un commentaire qui bloquait la compilation javascript
  103. // V1.2.13.4 07/01/2017
  104. // Plus de traces en mode debug pour l'analyse des étapes de mission
  105. // V1.2.13.5 07/01/2017
  106. // Correction bug qui se manisfestait sous LINUX
  107. // V1.2.13.6 08/01/2017
  108. // Réécriture analyse des étapes de mission sur monstre de niveau...
  109. // V1.2.13.7 10/01/2017
  110. // Exclusion Bricoll'troll dans l'entête GM
  111. // V1.2.14 20/01/2017
  112. // Ajout de l'export des données Trõlligion
  113.  
  114. /**********************************************************
  115. À faire / propositions d'évolutions
  116.  
  117. breizhou13 20/12/2016
  118. envoyer les données à l'IT (Bricol'Trolls) aussi
  119. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  120. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  121. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  122. Roule'
  123. Réactiver les jubilaires
  124. [Prioritaire] trajets Gowaps sans avoir besoin de URL_MZscriptCarte (voir comment c'est fait dans Trajet_des_gowap_MkII.user.js)
  125. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  126. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  127. - voir l'intérêt de refaire fonctionner
  128. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  129. **********************************************************/
  130.  
  131. /**********************************************************
  132. **** Début de zone à déplacer dans une bibli commune ******
  133. **********************************************************/
  134.  
  135. // URL de base serveur MZ
  136. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  137. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  138. //var URL_MZ = 'http://192.99.225.92/mz';
  139.  
  140. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  141. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  142.  
  143. // URLs externes redirection (pas de souci CORS)
  144. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  145. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  146. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  147. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  148. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  149. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  150. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  151. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  152. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  153.  
  154. // URLs de test HTTPS
  155. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  156. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  157.  
  158. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  159. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  160. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  161.  
  162. // x~x Libs
  163.  
  164. /* ancien TODO
  165. * - revoir la gestion des CdM --> nott armure magique
  166. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  167. * - vérfier la gestion des enchants
  168. */
  169.  
  170. // Roule 04/09/2016 switch extern URLs to https if available
  171. var isHTTPS = false;
  172. if (window.location.protocol.indexOf('https') === 0) {
  173. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  174. URL_bricol = URL_bricol_https;
  175. isHTTPS = true;
  176. }
  177.  
  178. // Roule 23/12/2016 mode dev
  179. var isDEV = false;
  180. if (MY_getValue('MZ_dev')) {
  181. URL_MZ = URL_MZ.replace(/$/, 'dev');
  182. isDEV = true;
  183. }
  184.  
  185. // Images (pas de souci CORS)
  186. var URL_MZimg = URL_MZ + '/img/';
  187. // URLs externes ajax (CORS OK)
  188. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  189. var URL_pageDispatcher = URL_MZ + '/cdmdispatcher.php';
  190.  
  191. // liens externes détuits
  192. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  193. var MHicons = '/mountyhall/Images/Icones/';
  194. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  195. var MY_DEBUG = false;
  196.  
  197. /* remplacement fonction MZ */
  198. function MY_getValue(key) {
  199. return window.localStorage[key];
  200. }
  201.  
  202. function MY_removeValue(key) {
  203. window.localStorage.removeItem(key);
  204. }
  205.  
  206. function MY_setValue(key, val) {
  207. window.localStorage[key] = val;
  208. }
  209.  
  210. /*---------------- mise à jour de variables globales utiles ------------------*/
  211. // utilisé pour accès bdd (un peu partout) :
  212. var numTroll = MY_getValue('NUM_TROLL');
  213. // utilisé dans vue pour PX :
  214. var nivTroll = MY_getValue('NIV_TROLL');
  215. // utilisés dans actions et vue (calculs SR) :
  216. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  217. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  218. var currentURL = window.location.href;
  219.  
  220. /*-[functions]------------ Fonctions durée de script -------------------------*/
  221. var date_debut = null;
  222.  
  223. function start_script(nbJours_exp) {
  224. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  225. if(date_debut) return;
  226. date_debut = new Date();
  227. // Créé la variable expdate si demandé
  228. if(nbJours_exp) {
  229. expdate = new Date();
  230. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  231. }
  232. }
  233.  
  234. function displayScriptTime() {
  235. var footerNode = document.getElementById('footer2');
  236. if(!footerNode) return;
  237. try{
  238. var node = document.evaluate(
  239. ".//text()[contains(.,'Page générée en')]/../br",
  240. footerNode,null,9,null).singleNodeValue;
  241. }
  242. catch(e){return;}
  243. insertText(node,
  244. ' - [Script exécuté en '
  245. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  246. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  247. }
  248.  
  249. function traceStack(e, sModule) {
  250. var version = '';
  251. if (GM_info && GM_info.script && GM_info.script.version)
  252. version = ' ' + GM_info.script.version;
  253. sRet = '[MZ' + version + ']'
  254. if (sModule) sRet += ' {' + sModule + '}';
  255. if (e.message) sRet += ' ' + e.message;
  256. if (e.stack) {
  257. var sStack = e.stack;
  258. // enlever les infos confidentielles
  259. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  260. }
  261. return sRet;
  262. }
  263.  
  264. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  265.  
  266. function debugMZ(str){
  267. if(MY_DEBUG){
  268. window.console.debug('[MY_DEBUG] '+str);
  269. if(typeof str === "object"){
  270. window.console.debug(str);
  271. }
  272. }
  273. }
  274.  
  275. function FF_XMLHttpRequest(MY_XHR_Ob) {
  276. var request = new XMLHttpRequest();
  277. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  278. for(var head in MY_XHR_Ob.headers) {
  279. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  280. }
  281. request.onreadystatechange = function() {
  282. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  283. if(request.readyState!=4) { return; }
  284. if(request.error) {
  285. if(MY_XHR_Ob.onerror) {
  286. MY_XHR_Ob.onerror(request);
  287. }
  288. }
  289. else if(MY_XHR_Ob.onload) {
  290. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  291. MY_XHR_Ob.onload(request);
  292. }
  293. };
  294. request.send(MY_XHR_Ob.data);
  295. }
  296.  
  297.  
  298. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  299.  
  300. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  301. function copyTextToClipboard(text) {
  302. var textArea = document.createElement("textarea");
  303.  
  304. //
  305. // *** This styling is an extra step which is likely not required. ***
  306. //
  307. // Why is it here? To ensure:
  308. // 1. the element is able to have focus and selection.
  309. // 2. if element was to flash render it has minimal visual impact.
  310. // 3. less flakyness with selection and copying which **might** occur if
  311. // the textarea element is not visible.
  312. //
  313. // The likelihood is the element won't even render, not even a flash,
  314. // so some of these are just precautions. However in IE the element
  315. // is visible whilst the popup box asking the user for permission for
  316. // the web page to copy to the clipboard.
  317. //
  318.  
  319. // Place in top-left corner of screen regardless of scroll position.
  320. textArea.style.position = 'fixed';
  321. textArea.style.top = 0;
  322. textArea.style.left = 0;
  323.  
  324. // Ensure it has a small width and height. Setting to 1px / 1em
  325. // doesn't work as this gives a negative w/h on some browsers.
  326. textArea.style.width = '2em';
  327. textArea.style.height = '2em';
  328.  
  329. // We don't need padding, reducing the size if it does flash render.
  330. textArea.style.padding = 0;
  331.  
  332. // Clean up any borders.
  333. textArea.style.border = 'none';
  334. textArea.style.outline = 'none';
  335. textArea.style.boxShadow = 'none';
  336.  
  337. // Avoid flash of white box if rendered for any reason.
  338. textArea.style.background = 'transparent';
  339.  
  340. textArea.value = text;
  341.  
  342. document.body.appendChild(textArea);
  343.  
  344. textArea.select();
  345.  
  346. var successful = document.execCommand('copy');
  347.  
  348. document.body.removeChild(textArea);
  349. return successful;
  350. }
  351.  
  352. function avertissement(txt,duree) {
  353. if(!duree) duree = 15000;
  354. var div = document.createElement('div');
  355. // On numérote les avertissements pour destruction sélective
  356. var num = document.getElementsByName('avertissement').length;
  357. div.num = num;
  358. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  359. div.setAttribute('name','avertissement');
  360. div.className = 'mh_textbox';
  361. div.style.position = 'fixed';
  362. div.style.top = (10+15*num)+'px';
  363. div.style.left = (10+5*num)+'px';
  364. div.style.border = '5px solid red';
  365. div.style.zIndex = 2+num;
  366. div.style.cursor = 'pointer';
  367. div.style.fontSize = 'large';
  368. div.innerHTML = txt;
  369. div.onclick=function(){ tueAvertissement(this.num) };
  370.  
  371. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  372. var divcroix = document.createElement('div');
  373. divcroix.style.position = 'absolute';
  374. divcroix.style.top = 0;
  375. divcroix.style.right = 0;
  376. divcroix.style.color = 'black';
  377. divcroix.style.fontSize = 'inherit';
  378. divcroix.style.cursor = 'pointer'
  379. divcroix.style.zIndex = 2+num;
  380. divcroix.innerHTML = "X";
  381. div.appendChild(divcroix);
  382.  
  383. document.body.appendChild(div);
  384. // Destruction automatique de l'avertissement après "un certain temps"
  385. window.setTimeout(function(){ tueAvertissement(num) },duree);
  386. }
  387.  
  388. function tueAvertissement(num) {
  389. var divs = document.getElementsByName('avertissement');
  390. if(divs.length==0) { return; }
  391. for(var i=0 ; i<divs.length ; i++) {
  392. if(divs[i].num==num) {
  393. divs[i].parentNode.removeChild(divs[i]);
  394. return;
  395. }
  396. }
  397. }
  398.  
  399.  
  400. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  401.  
  402. function insertBefore(next,el) {
  403. next.parentNode.insertBefore(el,next);
  404. }
  405.  
  406. function appendTr(tbody,clas) {
  407. var tr = document.createElement('tr');
  408. if(clas) tr.className = clas;
  409. tbody.appendChild(tr);
  410. return tr;
  411. }
  412.  
  413. function insertTr(next,clas) {
  414. var tr = document.createElement('tr');
  415. if(clas) tr.className = clas;
  416. insertBefore(next,tr);
  417. return tr;
  418. }
  419.  
  420. function appendTd(tr) {
  421. var td = document.createElement('td');
  422. if(tr) tr.appendChild(td);
  423. return td;
  424. }
  425.  
  426. function insertTd(next) {
  427. var td = document.createElement('td');
  428. insertBefore(next,td);
  429. return td;
  430. }
  431.  
  432. function appendTdCenter(tr,colspan) {
  433. var td = appendTd(tr);
  434. td.align = 'center'; // WARNING - Obsolete
  435. if(colspan) td.colSpan = colspan;
  436. return td;
  437. }
  438.  
  439. function insertTdElement(next,el) {
  440. var td = insertTd(next);
  441. if(el) td.appendChild(el);
  442. return td;
  443. }
  444.  
  445. function appendA(paren,href,cssClass,text) {
  446. var a = document.createElement('a');
  447. if (href) a.href = href;
  448. if (cssClass) a.className = cssClass;
  449. if (text) a.appendChild(document.createTextNode(text));
  450. paren.appendChild(a);
  451. }
  452.  
  453. function appendText(paren,text,bold) {
  454. if(bold) {
  455. var b = document.createElement('b');
  456. b.appendChild(document.createTextNode(text));
  457. paren.appendChild(b);
  458. }
  459. else
  460. paren.appendChild(document.createTextNode(text));
  461. }
  462.  
  463. function insertText(next,text,bold) {
  464. if(bold) {
  465. var b = document.createElement('b');
  466. appendText(b,text);
  467. insertBefore(next,b);
  468. }
  469. else
  470. insertBefore(next,document.createTextNode(text));
  471. }
  472.  
  473. function appendTdText(tr,text,bold) {
  474. var td = appendTd(tr);
  475. appendText(td,text,bold);
  476. return td;
  477. }
  478.  
  479. function insertTdText(next,text,bold) {
  480. var td = insertTd(next);
  481. appendText(td,text,bold);
  482. return td;
  483. }
  484.  
  485. function appendBr(paren) {
  486. paren.appendChild(document.createElement('br'));
  487. }
  488.  
  489. function insertBr(next) {
  490. insertBefore(next,document.createElement('br'));
  491. }
  492.  
  493. function appendLI(ul,text) {
  494. // uniquement utilisé dans les options (crédits)
  495. var li = document.createElement('li');
  496. appendText(li,text);
  497. ul.appendChild(li);
  498. return li;
  499. }
  500.  
  501. function appendTextbox(paren,type,nam,size,maxlength,value) {
  502. var input = document.createElement('input');
  503. input.className = 'TextboxV2';
  504. input.type = type;
  505. input.name = nam;
  506. input.id = nam;
  507. input.size = size;
  508. input.maxLength = maxlength;
  509. if(value) input.value = value;
  510. paren.appendChild(input);
  511. return input;
  512. }
  513.  
  514. function appendCheckBox(paren,nam,checked,onClick) {
  515. var input = document.createElement('input');
  516. input.type = 'checkbox';
  517. input.name = nam;
  518. input.id = nam;
  519. if(checked) input.checked = true;
  520. if(onClick) input.onclick = onClick;
  521. paren.appendChild(input);
  522. return input;
  523. }
  524.  
  525. function appendNobr(paren,id,delgg,text) {
  526. var nobr = document.createElement('nobr');
  527. appendCheckBox(nobr,id,null,delgg);
  528. appendText(nobr,text);
  529. paren.appendChild(nobr);
  530. appendText(paren,' ');
  531. return nobr;
  532. }
  533.  
  534. function appendCheckBoxSpan(paren,id,onClick,text) {
  535. var span = document.createElement('span');
  536. span.style.whiteSpace = 'nowrap';
  537. appendCheckBox(span,id,false,onClick);
  538. appendText(span,text);
  539. paren.appendChild(span);
  540. appendText(paren,' ');
  541. return span;
  542. }
  543.  
  544. function appendOption(select,value,text) {
  545. var option = document.createElement('option');
  546. option.value = value;
  547. appendText(option,text);
  548. select.appendChild(option);
  549. return option;
  550. }
  551.  
  552. function appendHidden(form,nam,value) {
  553. var input = document.createElement('input');
  554. input.type = 'hidden';
  555. input.name = nam;
  556. input.id = nam;
  557. input.value = value;
  558. form.appendChild(input);
  559. }
  560.  
  561. function appendButton(paren,value,onClick) {
  562. var input = document.createElement('input');
  563. input.type = 'button';
  564. input.className = 'mh_form_submit';
  565. input.value = value;
  566. input.onmouseover = function(){this.style.cursor='pointer';};
  567. if(onClick) input.onclick = onClick;
  568. paren.appendChild(input);
  569. return input;
  570. }
  571.  
  572. function insertButton(next,value,onClick) {
  573. var input = document.createElement('input');
  574. input.type = 'button';
  575. input.className = 'mh_form_submit';
  576. input.value = value;
  577. input.onmouseover = function(){this.style.cursor='pointer';};
  578. input.onclick = onClick;
  579. insertBefore(next,input);
  580. return input;
  581. }
  582.  
  583. function appendSubmit(paren,value,onClick) {
  584. var input = document.createElement('input');
  585. input.type = 'submit';
  586. input.className = 'mh_form_submit';
  587. input.value = value;
  588. input.onmouseover = function(){this.style.cursor='pointer';};
  589. if(onClick) input.onclick = onClick;
  590. paren.appendChild(input);
  591. return input;
  592. }
  593.  
  594. function createImage(url,title) {
  595. var img = document.createElement('img');
  596. img.src = url;
  597. img.title = title;
  598. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  599. return img;
  600. }
  601.  
  602. function createAltImage(url,alt,title) {
  603. var img = document.createElement('img');
  604. img.src = url;
  605. img.alt = alt;
  606. if (title) img.title = title;
  607. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  608. return img;
  609. }
  610.  
  611. function createImageSpan(url,alt,title,text,bold) {
  612. var span = document.createElement('span');
  613. span.title = title;
  614. var img = document.createElement('img');
  615. img.src = url;
  616. img.alt = alt;
  617. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  618. span.appendChild(img);
  619. appendText(span,text,bold);
  620. return span;
  621. }
  622.  
  623. function createCase(titre,table,width) {
  624. if(!width) width=120;
  625. var tr = appendTr(table,'mh_tdpage');
  626. var td = appendTdText(tr,titre,true);
  627. td.className = 'mh_tdtitre';
  628. td.width = width;
  629. td = appendTdText(tr,'');
  630. td.className = 'mh_tdpage';
  631. return td;
  632. }
  633.  
  634. function getMyID(e) {
  635. var parent = e.parentNode;
  636. for(var i=0 ; i<parent.childNodes.length ; i++) {
  637. if(e==parent.childNodes[i])
  638. return i;
  639. }
  640. return -1;
  641. }
  642.  
  643. function insertAfter(elt,newElt) {
  644. var id = getMyID(elt);
  645. if(id==-1) return;
  646. if(id<elt.parentNode.childNodes.length-1)
  647. insertBefore(elt.nextSibling,newElt);
  648. else
  649. elt.parentNode.appendChild(newElt);
  650. }
  651.  
  652.  
  653. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  654.  
  655. function aff(nb) {
  656. return (nb>=0) ? '+'+nb : nb;
  657. }
  658.  
  659. function getNumber(str) {
  660. var nbr = str.match(/\d+/);
  661. return nbr ? Number(nbr[0]) : Number.NaN;
  662. }
  663.  
  664. function getNumbers(str) {
  665. var nbrs = str.match(/-?\d+/g);
  666. if (!nbrs) return [];
  667. for(var i=0 ; i<nbrs.length ; i++)
  668. nbrs[i] = Number(nbrs[i]);
  669. return nbrs;
  670. }
  671.  
  672. function trim(str) {
  673. return str.replace(/(^\s*)|(\s*$)/g,'');
  674. }
  675.  
  676. String.prototype.trim = function() {
  677. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  678. }
  679.  
  680. function epure(texte) {
  681. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  682. .replace(/[ç]/g,'c')
  683. .replace(/[éêèë]/g,'e')
  684. .replace(/[ïî]/g,'i')
  685. .replace(/[ôöõ]/g,'o')
  686. .replace(/[ùûü]/g,'u');
  687. }
  688.  
  689. String.prototype.epure = function () {
  690. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  691. .replace(/[ç]/g,'c')
  692. .replace(/[éêèë]/g,'e')
  693. .replace(/[ïî]/g,'i')
  694. .replace(/[ôöõ]/g,'o')
  695. .replace(/[ùûü]/g,'u');
  696. }
  697.  
  698. function bbcode(texte) {
  699. return texte.replace(/&/g,'&amp;')
  700. .replace(/"/g,'&quot;')
  701. .replace(/</g,'&lt;')
  702. .replace(/>/g,'&gt;')
  703. .replace(/'/g,'&#146;')
  704. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  705. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  706. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  707. }
  708.  
  709.  
  710. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  711.  
  712. function addZero(i) {
  713. return (i<10) ? '0'+i : i;
  714. }
  715.  
  716. function DateToString(date) {
  717. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  718. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  719. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  720. }
  721.  
  722. function StringToDate(str) {
  723. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  724. }
  725.  
  726. // fonctionne aussi avec datetime
  727. function SQLDateToFrench(str) {
  728. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  729. }
  730.  
  731. // ... et ajoute un "à" du plus bel effet
  732. function SQLDateToFrenchTime(str) {
  733. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  734. }
  735.  
  736. // SQLDate vers objet date Javascript
  737. function SQLDateToObject(str) {
  738. var t = str.split(/[- :]/);
  739. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  740. }
  741.  
  742. var mz_ie = (window.attachEvent)? true:false;
  743. if ("function" !== typeof addEvent) {
  744. if (mz_ie) {
  745. function addEvent(obj, typ, fn, sens) {
  746. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  747. obj["e"+typ+fn]( window.event );
  748. }
  749. obj.attachEvent("on"+typ, obj[typ+fn] );
  750. }
  751. }
  752. else {
  753. function addEvent(obj, typ, fn, sens) {
  754. obj.addEventListener(typ, fn, sens);
  755. }
  756. }
  757. }
  758.  
  759. // mise en commun du dessin des cartes (récupéré de Trajet_des_gowaps de feldspath et Vapulabehemot)
  760. function declare_css_carte_hall() {
  761. if(haut.getElementById("css_gow")) return;
  762. 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; }";
  763.  
  764. var node = document.createElement("style");
  765. node.type = "text/css";
  766. node.id = "css_gow";
  767. node.appendChild(document.createTextNode(css));
  768. document.getElementsByTagName("head")[0].appendChild(node);
  769. }
  770.  
  771. function ini_canvas_carte_hall() {
  772. var trajet = document.createElement("div");
  773. trajet.id = "carte_trajet";
  774.  
  775. var dessin = creer_canvas("trou");
  776. var dessin = document.createElement("canvas");
  777. dessin.id = ref;
  778. dessin.className = "mh_tdpage";
  779. trajet.appendChild(dessin);
  780. trajet.appendChild(creer_canvas("trajet"));
  781. trajet.appendChild(creer_canvas("danger"));
  782.  
  783. var dessin = creer_canvas("surligne");
  784. addEvent(dessin, "click", action_trajet, true);
  785. addEvent(dessin, "mousedown", start_v, true);
  786. addEvent(dessin, "mousemove", afficher_position, true);
  787. addEvent(dessin, "mouseout", function() { cacher_bulle(true) }, true);
  788. addEvent(dessin, "mouseover", function() { cacher_bulle(false) }, true);
  789. trajet.appendChild(dessin);
  790.  
  791. trajet.appendChild(creer_glissiere("gow", zoom));
  792.  
  793. var parp = document.getElementsByTagName('p');
  794. parp[parp.length-1].insertBefore(trajet,parp[parp.length-1].firstChild);
  795. }
  796.  
  797. /**********************
  798. * glissière en mode objet
  799. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  800. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  801. *
  802. * Usage:
  803. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  804. * ref : utilisé pour diversifier les IDs HTML
  805. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  806. * target : peut être de 3 types
  807. * - élément HTML : l'élément HTML à zoomer
  808. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  809. * - function : callback quand le curseur bouge
  810. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  811. * dans le mode dynamique, la callback est appelée sur mouseMove
  812. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  813. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  814. * autres méthodes
  815. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  816. **********************/
  817.  
  818. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  819. try {
  820. var mouseDown = false;
  821. var div_gliss = document.createElement("div"); // la DIV mère
  822. div_gliss.id = "MZ_gliss_"+ref;
  823. var div_label = document.createElement("span"); // le label
  824. div_label.innerHTML = labelHTML;
  825. div_gliss.appendChild(div_label);
  826. div_gliss.className = "choix_zoom";
  827. var dessin = document.createElement("canvas"); // le dessin lui-même
  828. dessin.id = "MZ_gliss_dessin_"+ref;
  829. dessin.style.cursor = "pointer";
  830. dessin.width = 104;
  831. dessin.height = 12;
  832. dessin.style.marginLeft = '2px';
  833. dessin.style.marginRight = '2px';
  834. div_gliss.appendChild(dessin);
  835. var pourcent = document.createElement("span"); // le pourcentage
  836. pourcent.id = "MZ_gliss_pourcent_"+ref;
  837. var pourcent_text = document.createTextNode('');
  838. var previousVal;
  839. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  840.  
  841. // alignement vertical
  842. dessin.style.verticalAlign = 'middle';
  843. div_label.style.verticalAlign = 'middle';
  844. pourcent.style.verticalAlign = 'middle';
  845.  
  846. pourcent.appendChild(pourcent_text);
  847. div_gliss.appendChild(pourcent);
  848.  
  849. var bulle_pourcent = document.createElement("div"); // la bulle
  850. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  851. bulle_pourcent.style.display = 'block';
  852. bulle_pourcent.style.visibility = 'hidden';
  853. bulle_pourcent.style.position = 'absolute';
  854. bulle_pourcent.style.zIndex = 3500;
  855. bulle_pourcent.style.border = '1px solid #a1927f';
  856. var bulle_pourcent_text = document.createTextNode('');
  857. bulle_pourcent.appendChild(bulle_pourcent_text);
  858. document.body.appendChild(bulle_pourcent);
  859.  
  860. this.getElt = function() {return div_gliss;};
  861.  
  862. ////////////////////////////////////
  863. // dessine et redessine le curseur
  864. ////////////////////////////////////
  865. var dessine_glissiere = function(val) {
  866. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  867. var ctx = dessin.getContext('2d');
  868. ctx.clearRect(0, 0,104, 12);
  869. ctx.fillStyle = "rgb(0,0,0)";
  870. ctx.fillRect(0,0,2,12);
  871. ctx.fillRect(102,0,2,12);
  872. ctx.fillRect(0,5,104,2);
  873.  
  874. ctx.fillStyle = "rgb(80,80,80)";
  875. ctx.fillRect(pos_0_100,0,5,12);
  876. ctx.fillStyle = "rgb(200,200,200)";
  877. ctx.fillRect(pos_0_100+1,1,3,10);
  878. pourcent_text.nodeValue = val+'%';
  879. previousVal = parseInt(val);
  880. };
  881.  
  882. ////////////////////////////////////
  883. // action sur mousedown et mousemove
  884. // stocker la nouvelle valeur
  885. // redessiner
  886. // afficher la nouvelle valeur
  887. // action selon ce qui a été demandé
  888. ////////////////////////////////////
  889. var doCallback_glissiere = function (evt) {
  890. try {
  891. if (evt.type === 'mousedown') mouseDown = true;
  892. if (evt.offsetX) {
  893. var xsouris = evt.offsetX;
  894. var xpos = evt.clientX;
  895. var ypos = evt.clientY + document.body.scrollTop;
  896. }
  897. else {
  898. var xsouris = evt.layerX;
  899. var xpos = evt.pageX;
  900. var ypos = evt.pageY;
  901. }
  902. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  903. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  904. // afficher la nouvelle valeur dans la bulle
  905. bulle_pourcent_text.nodeValue = val + '%';
  906. bulle_pourcent.style.top = (ypos+3)+'px';
  907. bulle_pourcent.style.left = (xpos+16)+'px';
  908. if (evt.buttons === undefined) {
  909. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  910. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  911. } else {
  912. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  913. }
  914. // stocker la nouvelle valeur
  915. MY_setValue("MZ_glissiere_" + ref, val);
  916. // redessiner la glissière avec le curseur où il faut
  917. dessine_glissiere(val);
  918. // action selon ce qui a été demandé
  919. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  920. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  921. if (typeof paramTarget === 'object') {
  922. var elt = paramTarget;
  923. } else if (typeof paramTarget === 'string') {
  924. var elt = document.getElementById(paramTarget);
  925. } else if (typeof paramTarget === 'function') {
  926. paramTarget(val);
  927. return;
  928. }
  929. if (elt.setZoom != undefined) elt.setZoom(val);
  930. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  931. };
  932.  
  933. ////////////////////////////////////
  934. // event mousedown et mousemove : redessiner et callback
  935. ////////////////////////////////////
  936. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  937. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  938. ////////////////////////////////////
  939. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  940. ////////////////////////////////////
  941. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  942. ////////////////////////////////////
  943. // event mouseout & mouseover : afficher/cacher la bulle
  944. ////////////////////////////////////
  945. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  946. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  947.  
  948. ////////////////////////////////////
  949. // dessiner la première fois
  950. ////////////////////////////////////
  951. var val_init = MY_getValue("MZ_glissiere_" + ref);
  952. if (val_init === undefined) val_init = valDef;
  953. dessine_glissiere(val_init);
  954. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  955. }
  956.  
  957. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  958. // reçoit 2 objets avec des propriétés x et y
  959. // rend un objet avec x et y (rend undefined si le trajet est direct)
  960. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  961. var deltaX = locArrivee.x - locDepart.x;
  962. if (deltaX == 0) return; // pas de point intermédiaire
  963. var deltaY = locArrivee.y - locDepart.y;
  964. if (deltaY == 0) return; // pas de point intermédiaire
  965. var absDeltaX = Math.abs(deltaX);
  966. var absDeltaY = Math.abs(deltaY);
  967. if (absDeltaX > absDeltaY) {
  968. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  969. } else if (absDeltaY > absDeltaX) {
  970. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  971. } else {
  972. return; // égalité, pas de point intermédiaire
  973. }
  974. }
  975.  
  976. /**********************
  977. * carte en mode objet
  978. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  979. *
  980. * Usage:
  981. * carte = new carte_MZ(ref, tabDepl);
  982. * ref : utilisé pour diversifier les IDs HTML
  983. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  984. * autres méthodes
  985. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  986. **********************/
  987.  
  988. function carte_MZ(ref, tabDepl) {
  989. try {
  990. var div_carte = document.createElement("div"); // la DIV mère
  991. div_carte.id = "MZ_carte_"+ref;
  992. div_carte.className = "carte_MZ";
  993. var dessin = document.createElement("canvas"); // le dessin lui-même
  994. dessin.id = "MZ_carte_dessin_"+ref;
  995. //dessin.style.backgroundColor = 'rgb(255,255,204)';
  996. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  997. div_carte.appendChild(dessin);
  998.  
  999. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1000. , [-66.5, -37.5, 2, 1.5, -69]
  1001. , [-63.5, 8.5, 2, 1.5, -69]
  1002. , [-59.5, -32.5, 2, 1.5, -69]
  1003. , [-52, 57, 0.25, 0.8, -59]
  1004. , [-50.5, -22.5, 2, 1.5, -69]
  1005. , [-35.5, -51.5, 2, 1.5, -69]
  1006. , [-34.5, 14.5, 2, 1.5, -69]
  1007. , [-34.5, 64.5, 2, 1.5, -69]
  1008. , [-11.5, 72.5, 2, 1.5, -69]
  1009. , [5.5, -49.5, 2, 1.5, -69]
  1010. , [5.5, 31.5, 2, 1.5, -69]
  1011. , [10.5, 63.5, 2, 1.5, -69]
  1012. , [12, -15, 0.25, 0.8, -59]
  1013. , [21.5, 35.5, 2, 1.5, -69]
  1014. , [30, -52, 0.25, 0.8, -59]
  1015. , [46.5, 51.5, 2, 1.5, -69]
  1016. , [48, -39, 0.25, 0.8, -59]
  1017. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1018. , [56.5, 23.5, 75, 8.7, -99]
  1019. , [64, 70, 0.25, 0.8, -59]
  1020. , [74.5, 31.5, 2, 1.5, -69]];
  1021.  
  1022. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1023. var couleur_cible = 'rgba(0,0,0,0.5)';
  1024. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1025. var couleur_trou = 'rgb(200,0,0)';
  1026.  
  1027. var coord_x = function(val) {
  1028. return decalh+coeff*(val+100);
  1029. };
  1030. var coord_y = function(val) {
  1031. return decalv+coeff*(100-val);
  1032. };
  1033.  
  1034. var ctx = dessin.getContext('2d');
  1035. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1036. if (coeff) coeff /= 50;
  1037. else coeff = 2;
  1038. var decalv=30, decalh=30;
  1039.  
  1040. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1041. //var res = false
  1042. var x0 = pos0.x;
  1043. var y0 = pos0.x;
  1044. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1045. var px = Math.sign(pos1.x - pos0.x);
  1046. var py = Math.sign(pos1.y - pos0.y);
  1047. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1048. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1049.  
  1050. for(var k in position_trous_MZ) {
  1051. a = parseFloat(px*px+py*py);
  1052. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1053. c = parseFloat((x0-position_trous_MZ[k][0])*(x0-position_trous_MZ[k][0])+(y0-position_trous_MZ[k][1])*(y0-position_trous_MZ[k][1])-position_trous_MZ[k][2]);
  1054. delta = b*b-a*c
  1055. if(delta >= 0) {
  1056. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1057. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1058. if(t0 <= tmax && t1 >= 0) {
  1059. // Roule' 10/10/2016 J'ai déplacé le flag res=true à l'intérieur de la boucle for ci-dessous car il y avait de fausses détections
  1060. //res = true;
  1061. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1062. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1063. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1064. // Roule : pas utile pour nous
  1065. //res = true;
  1066. //chute.push([x0+l*px, y0+l*py]);
  1067. return true;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. //return res;
  1073. return false;
  1074. };
  1075.  
  1076. var dessine_carte = function () {
  1077. dessin.width = 200*coeff+2*decalh;
  1078. dessin.height = 200*coeff+2*decalv;
  1079.  
  1080. //repere
  1081. ctx.beginPath();
  1082. ctx.moveTo(coord_x(0), coord_y(100));
  1083. ctx.lineTo(coord_x(0), coord_y(-100));
  1084. ctx.moveTo(coord_x(-100), coord_y(0));
  1085. ctx.lineTo(coord_x(100), coord_y(0));
  1086. ctx.stroke();
  1087. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1088.  
  1089. //trous
  1090. ctx.fillStyle = couleur_trou;
  1091. for(var i in position_trous_MZ) {
  1092. ctx.beginPath();
  1093. ctx.arc(coord_x(position_trous_MZ[i][0]), coord_y(position_trous_MZ[i][1]), coeff*position_trous_MZ[i][3], 0, Math.PI*2, true);
  1094. ctx.fill();
  1095. }
  1096. // trajets
  1097. ctx.lineCap = "round";
  1098. ctx.lineJoin = "round";
  1099. for (var iSuivant in tabDepl) {
  1100. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1101. var tabDeplOneSuivant = tabDepl[iSuivant];
  1102. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1103. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1104. // La "cible" au départ
  1105. ctx.beginPath();
  1106. ctx.lineWidth = 1;
  1107. ctx.strokeStyle = couleur_cible;
  1108. ctx.fillStyle = couleur_cible;
  1109. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1110. ctx.moveTo(x0 + coeff * 4, y0);
  1111. ctx.lineTo(x0 - coeff * 4, y0);
  1112. ctx.moveTo(x0, y0 + coeff * 4);
  1113. ctx.lineTo(x0, y0 - coeff * 4);
  1114. ctx.stroke();
  1115. // les segments
  1116. var nb_pts = tabDeplOneSuivant.length;
  1117. var pointPrecedent = tabDeplOneSuivant[0];
  1118. for (var i=1; i<nb_pts; i++) {
  1119. ctx.beginPath();
  1120. ctx.lineWidth = coeff;
  1121. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1122. ctx.strokeStyle = couleur_depl_normal;
  1123. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1124. if (pointIntermediaire === undefined) {
  1125. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1126. ctx.strokeStyle = couleur_depl_collision_trou;
  1127. else
  1128. ctx.strokeStyle = couleur_depl_normal;
  1129. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1130. } else {
  1131. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1132. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1133. ctx.strokeStyle = couleur_depl_collision_trou;
  1134. else
  1135. ctx.strokeStyle = couleur_depl_normal;
  1136. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1137. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1138. }
  1139. pointPrecedent = tabDeplOneSuivant[i];
  1140. ctx.stroke();
  1141. }
  1142. // Les points à chaque étape
  1143. ctx.fillStyle = couleur_depl_normal;
  1144. for (var i=1; i<nb_pts; i++) {
  1145. ctx.beginPath();
  1146. var x = coord_x(tabDeplOneSuivant[i].x);
  1147. var y = coord_y(tabDeplOneSuivant[i].y);
  1148. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1149. ctx.fill();
  1150. }
  1151. }
  1152. }
  1153.  
  1154. this.setZoom = function (val) {
  1155. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1156. coeff = val / 50;
  1157. dessine_carte();
  1158. }
  1159.  
  1160. // glissiere
  1161. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1162. var eGliss = gliss.getElt();
  1163. eGliss.style.position = 'absolute';
  1164. eGliss.style.top = (coeff * 2) + 'px';
  1165. eGliss.style.left = decalh + 'px';
  1166. dessin.style.position = 'relative';
  1167. div_carte.style.position = 'relative';
  1168. eGliss.style.zIndex = 9000;
  1169. div_carte.appendChild(eGliss);
  1170.  
  1171. // affichage au survol de la souris
  1172. var bulle = document.createElement('div');
  1173. bulle.style.visibility = 'hidden';
  1174. bulle.style.position = 'absolute';
  1175. bulle.style.zIndex = 3100;
  1176. bulle.style.width = '400px';
  1177. bulle.style.border = 'solid 1px #a1927f';
  1178. appendText(bulle, 'ici');
  1179. div_carte.appendChild(bulle);
  1180. var affichePosition = function(evt) {
  1181. if (evt.offsetX) {
  1182. var xsouris = evt.offsetX;
  1183. var ysouris = evt.offsetY;
  1184. var xpos = evt.clientX;
  1185. var ypos = evt.clientY + document.body.scrollTop;
  1186. }
  1187. else {
  1188. var xsouris = evt.layerX;
  1189. var ysouris = evt.layerY;
  1190. var xpos = evt.pageX;
  1191. var ypos = evt.pageY;
  1192. }
  1193. bulle.firstChild.nodeValue = xsouris;
  1194. bulle.style.top = ysouris + 'px';
  1195. bulle.style.left = xsouris + 'px';
  1196. }
  1197. addEvent(dessin, "mousemove", affichePosition, true);
  1198. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1199. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1200.  
  1201. // dessin initial
  1202. dessine_carte();
  1203.  
  1204. this.getElt = function() {return div_carte;};
  1205.  
  1206. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1207. }
  1208.  
  1209.  
  1210. /**********************************************************
  1211. **** Fin de zone à déplacer dans une bibli commune ********
  1212. **********************************************************/
  1213.  
  1214. /* DEBUG: NETTOYAGE TAGS */
  1215. if(MY_getValue(numTroll+'.TAGSURL')) {
  1216. MY_removeValue(numTroll+'.TAGSURL');
  1217. }
  1218.  
  1219. // Alerte si mode dev
  1220. if (isDEV) {
  1221. var divpopup = document.createElement('div');
  1222. divpopup.id = 'divDEV';
  1223. divpopup.style =
  1224. 'position: fixed;'+
  1225. 'border: 15px solid red;'+
  1226. 'top: 10px;right: 10px;'+
  1227. 'background-color: white;'+
  1228. 'color: black;'+
  1229. 'font-size: large;'+
  1230. 'padding: 5px'+
  1231. 'z-index: 200;';
  1232. appendText(divpopup, '[MZ] Mode DEV');
  1233. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1234. document.body.appendChild(divpopup);
  1235. }
  1236.  
  1237. /*---------- regroupement des getPortee() ------------------------------------*/
  1238. // issu des script profil et profil2
  1239. function getPortee__Profil(param) {
  1240. param = Math.max(0,Number(param));
  1241. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1242. // ça devrait être floor, +10.25, -2.5
  1243. }
  1244.  
  1245. // issu du script vue
  1246. function getPortee__Vue(param) {
  1247. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1248. }
  1249.  
  1250.  
  1251. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1252.  
  1253. function getPXKill(niv) {
  1254. return Math.max(0,10+3*niv-2*nivTroll);
  1255. }
  1256.  
  1257. function getPXDeath(niv) {
  1258. return Math.max(0,10+3*nivTroll-2*niv);
  1259. }
  1260.  
  1261. function analysePX(niv) {
  1262. niv = niv+'';
  1263. var i = niv.indexOf('+');
  1264. if(i!=-1) // si niv = 'XX+' ??
  1265. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1266. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1267. if(i!=-1) {
  1268. var max = getPXKill(niv.slice(i+2));
  1269. if(max==0)
  1270. return ' --> <b>0</b> PX';
  1271. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1272. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1273. }
  1274. i = niv.indexOf('='); // ???
  1275. if(i!=-1) {
  1276. var max = getPXKill(niv.slice(i+1));
  1277. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1278. }
  1279. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1280. }
  1281.  
  1282. function analysePXTroll(niv) {
  1283. var str = analysePX(niv);
  1284. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1285. return str;
  1286. }
  1287.  
  1288.  
  1289. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1290. // Refonte totale du code de Zorya
  1291.  
  1292. // Elements à implémenter en dur dans MZ2.0
  1293. var numQualite = {
  1294. 'Très Mauvaise':1,
  1295. 'Mauvaise':2,
  1296. 'Moyenne':3,
  1297. 'Bonne':4,
  1298. 'Très Bonne':5
  1299. };
  1300.  
  1301. var qualiteNum = [
  1302. '_dummy_',
  1303. 'Très Mauvaise',
  1304. 'Mauvaise',
  1305. 'Moyenne',
  1306. 'Bonne',
  1307. 'Très Bonne'
  1308. ];
  1309.  
  1310. var nival = {
  1311. 'Abishaii Bleu':19,
  1312. 'Abishaii Noir':10,
  1313. 'Abishaii Rouge':23,
  1314. 'Abishaii Vert':15,
  1315. 'Ame-en-peine':8,
  1316. 'Amibe Geante':9,
  1317. 'Anaconda des Catacombes':8,
  1318. 'Ankheg':10,
  1319. 'Anoploure Purpurin':36,
  1320. 'Araignee Geante':2,
  1321. 'Ashashin':35,
  1322. 'Balrog':50,
  1323. 'Banshee':16,
  1324. 'Barghest':36,
  1325. 'Basilisk':11,
  1326. 'Behemoth':34,
  1327. 'Behir':14,
  1328. 'Beholder':50,
  1329. 'Boggart':3,
  1330. 'Bondin':9,
  1331. "Bouj'Dla Placide":37,
  1332. "Bouj'Dla":19,
  1333. 'Bulette':19,
  1334. 'Caillouteux':1,
  1335. 'Capitan':35,
  1336. 'Carnosaure':25,
  1337. 'Champi-Glouton':3,
  1338. 'Chauve-Souris Geante':4,
  1339. 'Cheval a Dents de Sabre':23,
  1340. 'Chevalier du Chaos':20,
  1341. 'Chimere':13,
  1342. 'Chonchon':24,
  1343. 'Coccicruelle':22,
  1344. 'Cockatrice':5,
  1345. 'Crasc Medius':17,
  1346. 'Crasc Maexus':25,
  1347. 'Crasc':10,
  1348. 'Croquemitaine':6,
  1349. 'Cube Gelatineux':32,
  1350. 'Daemonite':27,
  1351. 'Diablotin':5,
  1352. 'Dindon du Chaos':1,
  1353. 'Djinn':29,
  1354. 'Ectoplasme':18,
  1355. 'Effrit':27,
  1356. "Elementaire d'Air":23,
  1357. "Elementaire d'Eau":17,
  1358. 'Elementaire de Feu':21,
  1359. 'Elementaire de Terre':21,
  1360. 'Elementaire du Chaos':26,
  1361. 'Erinyes':7,
  1362. 'Esprit-Follet':16,
  1363. 'Essaim Craterien':30,
  1364. 'Essaim Sanguinaire':25,
  1365. 'Ettin':8,
  1366. 'Familier':1,
  1367. 'Fantome':24,
  1368. 'Feu Follet':20,
  1369. 'Flagelleur Mental':33,
  1370. 'Foudroyeur':38,
  1371. 'Fumeux':22,
  1372. 'Fungus Geant':9,
  1373. 'Fungus Violet':4,
  1374. 'Furgolin':10,
  1375. 'Gargouille':3,
  1376. 'Geant de Pierre':13,
  1377. 'Geant des Gouffres':22,
  1378. "Geck'oo Majestueux":40,
  1379. "Geck'oo":15,
  1380. 'Glouton':20,
  1381. 'Gnoll':5,
  1382. 'Gnu Domestique':1,
  1383. 'Gnu Sauvage':1,
  1384. 'Goblin':4,
  1385. 'Goblours':4,
  1386. "Golem d'Argile":15,
  1387. 'Golem de cuir':1,
  1388. 'Golem de Chair':8,
  1389. 'Golem de Fer':31,
  1390. 'Golem de mithril':1,
  1391. 'Golem de metal':1,
  1392. 'Golem de papier':1,
  1393. 'Golem de Pierre':23,
  1394. 'Gorgone':11,
  1395. 'Goule':4,
  1396. 'Gowap Apprivoise':1,
  1397. 'Gowap Sauvage':1,
  1398. 'Gremlins':3,
  1399. 'Gritche':39,
  1400. 'Grouilleux':4,
  1401. 'Grylle':31,
  1402. 'Harpie':4,
  1403. 'Hellrot':18,
  1404. 'Homme-Lezard':4,
  1405. 'Hurleur':8,
  1406. 'Hydre':50,
  1407. 'Incube':13,
  1408. 'Kobold':2,
  1409. 'Labeilleux':26,
  1410. 'Lezard Geant':5,
  1411. 'Liche':50,
  1412. 'Limace Geante':10,
  1413. 'Loup-Garou':8,
  1414. 'Lutin':4,
  1415. 'Mante Fulcreuse':30,
  1416. 'Manticore':9,
  1417. 'Marilith':33,
  1418. 'Meduse':6,
  1419. 'Megacephale':38,
  1420. 'Mille-Pattes Geant':14,
  1421. 'Mimique':6,
  1422. 'Minotaure':7,
  1423. 'Molosse Satanique':8,
  1424. 'Momie':4,
  1425. 'Monstre Rouilleur':3,
  1426. "Mouch'oo Domestique":14,
  1427. "Mouch'oo Majestueux Sauvage":33,
  1428. "Mouch'oo Sauvage":14,
  1429. 'Na-Haniym-Heee':0,
  1430. 'Necrochore':37,
  1431. 'Necromant':39,
  1432. 'Necrophage':8,
  1433. 'Naga':10,
  1434. 'Nuee de Vermine':13,
  1435. "Nuage d'Insectes":7,
  1436. 'Ogre':7,
  1437. 'Ombre de Roches':13,
  1438. 'Ombre':2,
  1439. 'Orque':3,
  1440. 'Ours-Garou':18,
  1441. 'Palefroi Infernal':29,
  1442. 'Phoenix':32,
  1443. 'Pititabeille':0,
  1444. 'Plante Carnivore':4,
  1445. 'Pseudo-Dragon':5,
  1446. 'Rat Geant':2,
  1447. 'Rat-Garou':3,
  1448. 'Rocketeux':5,
  1449. 'Sagouin':3,
  1450. 'Scarabee Geant':4,
  1451. 'Scorpion Geant':10,
  1452. 'Shai':28,
  1453. 'Sirene':8,
  1454. 'Slaad':5,
  1455. 'Sorciere':17,
  1456. 'Spectre':14,
  1457. 'Sphinx':30,
  1458. 'Squelette':1,
  1459. 'Strige':2,
  1460. 'Succube':13,
  1461. 'Tertre Errant':20,
  1462. 'Thri-kreen':10,
  1463. 'Tigre-Garou':12,
  1464. 'Titan':26,
  1465. 'Trancheur':35,
  1466. 'Tubercule Tueur':14,
  1467. 'Tutoki':4,
  1468. 'Vampire':29,
  1469. 'Ver Carnivore Geant':12,
  1470. 'Ver Carnivore':11,
  1471. 'Veskan Du Chaos':14,
  1472. 'Vouivre':33,
  1473. 'Worg':5,
  1474. 'Xorn':14,
  1475. 'Yeti':8,
  1476. 'Yuan-ti':15,
  1477. 'Zombie':2
  1478. }
  1479.  
  1480. var tabEM = {
  1481. //Monstre: [Compo exact, Sort, Position, Localisation]
  1482. // AA
  1483. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1484. // AE
  1485. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1486. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1487. // AdA
  1488. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1489. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1490. // AdE
  1491. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1492. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1493. // AdD
  1494. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1495. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1496. // BAM
  1497. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1498. // BuM
  1499. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1500. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1501. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1502. // Explo
  1503. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1504. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1505. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1506. // FP
  1507. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1508. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1509. // FA
  1510. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1511. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1512. // Glue
  1513. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1514. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1515. // GdS
  1516. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1517. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1518. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1519. // Invi
  1520. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1521. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1522. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1523. // Lévitation
  1524. // ???
  1525. // PréM :
  1526. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1527. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1528. // Proj
  1529. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1530. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1531. // PuM :
  1532. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1533. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1534. // Sacro
  1535. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1536. // Télék
  1537. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1538. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1539. // TP
  1540. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1541. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1542. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1543. // VA
  1544. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1545. // VL
  1546. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1547. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1548. // VlC
  1549. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1550. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1551. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1552. // VT
  1553. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1554. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1555. // Variables
  1556. 'Rat':["d'un"],
  1557. 'Rat Géant':["d'un"],
  1558. 'Dindon':["d'un"],
  1559. 'Goblin':["d'un"],
  1560. 'Limace':["d'une"],
  1561. 'Limace Géante':["d'une"],
  1562. 'Ver':["d'un"],
  1563. 'Ver Carnivore':["d'un"],
  1564. 'Ver Carnivore Géant':["d'un"],
  1565. 'Fungus':["d'un"],
  1566. 'Vouivre':["d'une"],
  1567. 'Gnu':["d'un"],
  1568. 'Scarabée':["d'un"]
  1569. };
  1570.  
  1571. var mundiChampi = {
  1572. 'Préscientus Reguis':'du Phoenix',
  1573. 'Amanite Trolloïde':'de la Mouche',
  1574. 'Girolle Sanglante':'du Dindon',
  1575. 'Horreur Des Prés':'du Gobelin',
  1576. 'Bolet Péteur':'du Démon',
  1577. 'Pied Jaune':'de la Limace',
  1578. 'Agaric Sous-Terrain':'du Rat',
  1579. 'Suinte Cadavre':"de l'Hydre",
  1580. 'Cèpe Lumineux':'du Ver',
  1581. 'Fungus Rampant':'du Fungus',
  1582. 'Nez Noir':'de la Vouivre',
  1583. 'Pleurote Pleureuse':'du Gnu',
  1584. 'Phytomassus Xilénique':'du Scarabée'
  1585. };
  1586.  
  1587. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1588. appendText(node,' ');
  1589. var urlImg = URL_MZimg
  1590. +'Competences/melangeMagique.png';
  1591. var text = ' [-'+(niv+effetQ)+' %]';
  1592. var str = '';
  1593. switch(mob[0]) {
  1594. case 'A':
  1595. case 'E':
  1596. case 'I':
  1597. case 'O':
  1598. case 'U':
  1599. str = "Compo d'";
  1600. break;
  1601. default:
  1602. str = 'Compo de ';
  1603. }
  1604. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1605. var span = createImageSpan(urlImg,'MM:',title,text);
  1606. node.appendChild(span);
  1607. }
  1608. function addInfoEM(node,mob,compo,qualite,localisation) {
  1609. if(!tabEM[mob]) return;
  1610. var title = 'Composant variable', texte = 'Variable';
  1611. var bold = false;
  1612. if(tabEM[mob].length>1) {
  1613. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1614. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1615. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1616. if(pc<-20) return;
  1617. if(pc>=0) bold = true;
  1618. texte = aff(pc)+'%';
  1619. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1620. }
  1621. var urlImg = URL_MZimg
  1622. +'Competences/ecritureMagique.png';
  1623. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1624. node.appendChild(span);
  1625. }
  1626.  
  1627. function insererInfosEM(tbody) {
  1628. // lancé par equip, equipgowap
  1629. var trCompos = document.evaluate(
  1630. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1631. tbody,null,7,null);
  1632. var strCompos = '';
  1633. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1634. var node = trCompos.snapshotItem(i).childNodes[7];
  1635. var str = node.firstChild.textContent;
  1636. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1637. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1638. // Si non-EM on stoppe le traitement
  1639. if(!tabEM[mob]) continue;
  1640. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1641. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1642. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1643. addInfoEM(node,mob,compo,qualite,localisation);
  1644. }
  1645. }
  1646.  
  1647. function getQualite(qualite) {
  1648. var nb = numQualite[qualite];
  1649. return nb ? nb-1 : -1;
  1650. }
  1651.  
  1652. function getEM(nom) {
  1653. if(nom.indexOf('[')!=-1)
  1654. nom = trim(nom.substring(0,nom.indexOf('[')));
  1655. if(tabEM[nom]) return nom;
  1656. return '';
  1657. }
  1658.  
  1659. // DEBUG ex-fonction composantEM
  1660. function compoMobEM(mob) {
  1661. if(!tabEM[mob]) return '';
  1662. if(tabEM[mob].length==1)
  1663. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1664. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1665. +") pour l'écriture de "+tabEM[mob][1];
  1666. }
  1667.  
  1668. // DEBUG ex-fonction compoEM
  1669. function titreCompoEM(mob,compo,localisation,qualite) {
  1670. if(!tabEM[mob]) return '';
  1671. if(tabEM[mob].length==1) return 'Composant variable';
  1672. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1673. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1674. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1675. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1676. return '';
  1677. }
  1678.  
  1679. // DEBUG - rétrocompatibilité
  1680. function compoEM(mob) {
  1681. // appelé dans libs, vue
  1682. return compoMobEM(mob);
  1683. }
  1684. function composantEM(mob,compo,localisation,qualite) {
  1685. // appelé dans libs, tancompo
  1686. return titreCompoEM(mob,compo,localisation,qualite);
  1687. }
  1688. //
  1689.  
  1690.  
  1691. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1692.  
  1693. arrayTalents = {
  1694. /* Compétences */
  1695. 'Acceleration du Metabolisme':'AM',
  1696. 'Attaque Precise':'AP',
  1697. 'Balayage':'Balayage',
  1698. //'Balluchonnage':'Ballu',
  1699. 'Baroufle':'Baroufle',
  1700. 'Bidouille':'Bidouille',
  1701. 'Botte Secrete':'BS',
  1702. 'Camouflage':'Camou',
  1703. 'Charger':'Charger',
  1704. 'Connaissance des Monstres':'CdM',
  1705. 'Construire un Piege':'Piege',
  1706. 'Piege a Feu':'PiegeFeu',
  1707. 'Piege a Glue':'PiegeGlue',
  1708. 'Contre-Attaquer':'CA',
  1709. 'Coup de Butoir':'CdB',
  1710. 'Course':'Course',
  1711. 'Deplacement Eclair':'DE',
  1712. 'Dressage':'Dressage',
  1713. 'Ecriture Magique':'EM',
  1714. 'Frenesie':'Frenesie',
  1715. 'Golemologie':'Golemo',
  1716. 'Golem de cuir':'GolemCuir',
  1717. 'Golem de metal':'GolemMetal',
  1718. 'Golem de mithril':'GolemMithril',
  1719. 'Golem de papier':'GolemPapier',
  1720. 'Grattage':'Grattage',
  1721. 'Hurlement Effrayant':'HE',
  1722. 'Identification des Champignons':'IdC',
  1723. 'Insultes':'Insultes',
  1724. 'Lancer de Potions':'LdP',
  1725. 'Marquage':'Marquage',
  1726. 'Melange Magique':'Melange',
  1727. 'Miner':'Miner',
  1728. 'Necromancie':'Necro',
  1729. 'Painthure de Guerre':'PG',
  1730. 'Parer':'Parer',
  1731. 'Pistage':'Pistage',
  1732. 'Planter un Champignon':'PuC',
  1733. 'Regeneration Accrue':'RA',
  1734. 'Reparation':'Reparation',
  1735. 'Retraite':'Retraite',
  1736. 'Rotobaffe':'RB',
  1737. 'Shamaner':'Shamaner',
  1738. "S'interposer":'SInterposer',
  1739. 'Tailler':'Tailler',
  1740. //'Vol':'Vol',
  1741. /* Sortilèges */
  1742. 'Analyse Anatomique':'AA',
  1743. 'Armure Etheree':'AE',
  1744. 'Augmentation de l´Attaque':'AdA',
  1745. 'Augmentation de l´Esquive':'AdE',
  1746. 'Augmentation des Degats':'AdD',
  1747. 'Bulle Anti-Magie':'BAM',
  1748. 'Bulle Magique':'BuM',
  1749. 'Explosion':'Explo',
  1750. 'Faiblesse Passagere':'FP',
  1751. 'Flash Aveuglant':'FA',
  1752. 'Glue':'Glue',
  1753. 'Griffe du Sorcier':'GdS',
  1754. 'Hypnotisme':'Hypno',
  1755. 'Identification des tresors':'IdT',
  1756. 'Invisibilite':'Invi',
  1757. 'Levitation':'Levitation',
  1758. 'Precision Magique':'PreM',
  1759. 'Projectile Magique':'Projo',
  1760. 'Projection':'Proj',
  1761. 'Puissance Magique':'PuM',
  1762. 'Rafale Psychique':'Rafale',
  1763. 'Sacrifice':'Sacro',
  1764. 'Siphon des Ames':'Siphon',
  1765. 'Telekinesie':'Telek',
  1766. 'Teleportation':'TP',
  1767. 'Vampirisme':'Vampi',
  1768. 'Vision Accrue':'VA',
  1769. 'Vision lointaine':'VL',
  1770. 'Voir le Cache':'VlC',
  1771. 'Vue Troublee':'VT'
  1772. //'':''
  1773. }
  1774.  
  1775. // DEBUG - Pour rétrocompatibilité
  1776. function getSortComp(nom,niveau) {
  1777. return getTalent(nom,niveau);
  1778. }
  1779. //
  1780.  
  1781. function getTalent(nom,niveau) {
  1782. var nomEnBase = arrayTalents[epure(nom)];
  1783. if(!nomEnBase) return 0;
  1784. if(!niveau) var niveau = '';
  1785. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1786. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1787. return 0;
  1788. }
  1789.  
  1790. function removeAllTalents() {
  1791. for(var talent in arrayTalents) {
  1792. var nomEnBase = arrayTalents[talent];
  1793. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1794. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1795. continue;
  1796. }
  1797. var niveau = 1;
  1798. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1799. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1800. niveau++;
  1801. }
  1802. }
  1803. }
  1804.  
  1805. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1806. var att = MY_getValue(numTroll+'.caracs.attaque');
  1807. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1808. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1809. var mm = MY_getValue(numTroll+'.caracs.mm');
  1810. var deg = MY_getValue(numTroll+'.caracs.degats');
  1811. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1812. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1813. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1814. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1815. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1816. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1817. return false;
  1818. return true;
  1819. }
  1820.  
  1821.  
  1822. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1823.  
  1824. function getPVsRestants(pv,bless,vue) {
  1825. bless = Number(bless.match(/\d+/)[0]);
  1826. if(bless==0) return null;
  1827. var pvminmax = pv.match(/\d+/g);
  1828. if(bless==95) {
  1829. var pvb = 1;
  1830. var pvh = Math.floor( pvminmax[1]/20 );
  1831. }
  1832. else if(bless==5) {
  1833. var pvb = Math.floor( pvminmax[0]*19/20 );
  1834. var pvh = pvminmax[1];
  1835. }
  1836. else {
  1837. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1838. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1839. }
  1840. return vue ? ' ('+pvb+'-'+pvh+')' :
  1841. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1842. }
  1843.  
  1844. function insertButtonCdm(nextName,onClick,texte) {
  1845. if(texte==null) texte = 'Participer au bestiaire';
  1846. var nextNode = document.getElementsByName(nextName)[0];
  1847.  
  1848. var espace = document.createTextNode('\t');
  1849. insertBefore(nextNode,espace);
  1850.  
  1851. var button = document.createElement('input');
  1852. button.type = 'button';
  1853. button.className = 'mh_form_submit';
  1854. button.value = texte;
  1855. button.onmouseover = function(){this.style.cursor='pointer';};
  1856. if(onClick) button.onclick = onClick;
  1857. insertBefore(espace,button);
  1858. return button;
  1859. }
  1860.  
  1861. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1862. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1863. 'Capacité spéciale','Résistance Magique','Autres'];
  1864.  
  1865. function createImageTactique(url,id,nom) {
  1866. var img = document.createElement('img');
  1867. img.src = url;
  1868. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1869. img.id = id;
  1870. img.nom = nom;
  1871. img.onmouseover = showPopupTactique;
  1872. img.onmouseout = hidePopup;
  1873. return img;
  1874. }
  1875.  
  1876. function createCDMTable(id,nom,donneesMonstre) {
  1877. try {
  1878. var urlImg = URL_MZimg;
  1879. var table = document.createElement('table');
  1880. var profilActif = isProfilActif();
  1881. table.className = 'mh_tdborder';
  1882. table.border = 0;
  1883. table.cellSpacing = 1;
  1884. table.cellPadding = 4;
  1885. var thead = document.createElement('thead');
  1886. var tr = appendTr(thead,'mh_tdtitre');
  1887. var td = appendTdText(tr,
  1888. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1889. true
  1890. );
  1891. td.colSpan = 2;
  1892. table.appendChild(thead);
  1893. var tbody = document.createElement('tbody');
  1894. table.appendChild(tbody);
  1895. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1896. createCase(listeTitres[i],tbody,80);
  1897. }
  1898. var TypeMonstre = getEM(nom);
  1899. var infosCompo='';
  1900. if(TypeMonstre!='') {
  1901. infosCompo = compoEM(TypeMonstre);
  1902. }
  1903. var nodes = tbody.childNodes;
  1904. nodes[0].childNodes[1].innerHTML =
  1905. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1906. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1907. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1908. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1909. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1910. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1911. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1912. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1913. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1914. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1915. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1916. td = createCase(listeTitres[10],tbody);
  1917. td.innerHTML = bbcode(donneesMonstre[10]);
  1918. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  1919. td.appendChild(document.createTextNode(" "));
  1920. if(donneesMonstre[16] == "De zone")
  1921. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  1922. else if(donneesMonstre[16] == "Automatique")
  1923. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  1924. else if(donneesMonstre[16] == "Au toucher")
  1925. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  1926. }
  1927. }
  1928. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  1929. {
  1930. td = createCase(listeTitres[11],tbody);
  1931. td.innerHTML = bbcode(donneesMonstre[9]);
  1932. // seuil de résistance du monstre
  1933. var lb = td.getElementsByTagName('b');
  1934. if(lb.length == 1) {
  1935. var mrm = lb[0].firstChild.nodeValue * 1;
  1936. var v = (mrm / mmTroll);
  1937. lb[0].firstChild.nodeValue += " ("
  1938. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  1939. }
  1940. }
  1941. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  1942. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  1943. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  1944. {
  1945. td = createCase(listeTitres[12],tbody);
  1946. if(donneesMonstre[12]==1)
  1947. {
  1948. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  1949. }
  1950. if(donneesMonstre[13]==1)
  1951. {
  1952. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  1953. }
  1954. else if(donneesMonstre[13]==0)
  1955. {
  1956. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  1957. }
  1958. if(donneesMonstre[14]==1)
  1959. {
  1960. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  1961. }
  1962. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  1963. {
  1964. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  1965. }
  1966. else if(donneesMonstre[14]>6)
  1967. {
  1968. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  1969. }
  1970. if(donneesMonstre[15]=="Lente")
  1971. {
  1972. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  1973. }
  1974. else if(donneesMonstre[15]=="Normale")
  1975. {
  1976. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  1977. }
  1978. else if(donneesMonstre[15]=="Rapide")
  1979. {
  1980. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  1981. }
  1982. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  1983. {
  1984. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  1985. }
  1986. if(infosCompo.length>0)
  1987. {
  1988. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  1989. }
  1990. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  1991. {
  1992. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  1993. }
  1994. }
  1995. // pourcentage de blessure
  1996. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  1997. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  1998. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  1999. if(pvs)
  2000. lb[0].firstChild.nodeValue += pvs;
  2001. }
  2002. return table;
  2003. }
  2004. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2005. }
  2006.  
  2007.  
  2008. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2009.  
  2010. var listeMonstreEnchantement = null,
  2011. listeEquipementEnchantement = null,
  2012. listeInfoEnchantement = null;
  2013.  
  2014. function computeCompoEnchantement()
  2015. {
  2016. listeMonstreEnchantement = new Array();
  2017. listeInfoEnchantement = new Array();
  2018. listeEquipementEnchantement = new Array();
  2019. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2020. for(var i=0;i<liste.length;i++)
  2021. {
  2022. var idEquipement = liste[i]*1;
  2023. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2024. continue;
  2025. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2026. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2027. var texteGlobal='';
  2028. for(var j=0;j<3;j++)
  2029. {
  2030. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  2031. listeMonstreEnchantement[infoComposant[2]] = 1;
  2032. var array = new Array();
  2033. array[0]=infoComposant[0].replace("Ril","Œil");
  2034. array[1]=infoComposant[1];
  2035. array[2]=infoComposant[2];
  2036. array[3]=getQualite(infoComposant[3]);
  2037. var texte = infoComposant[4].replace("Ril","Œil");
  2038. for(var k=5;k<infoComposant.length;k++)
  2039. {
  2040. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2041. }
  2042. texteGlobal+=texte+'\n';
  2043. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2044. array[4]=texte;
  2045. listeInfoEnchantement.push(array);
  2046. }
  2047. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2048. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2049. }
  2050. }
  2051.  
  2052. function isEnchant(nom) {
  2053. var monstreEnchant = '';
  2054. for(j in listeInfoEnchantement) {
  2055. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2056. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2057. monstreEnchant=monstre;
  2058. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2059. }
  2060. }
  2061. return trim(monstreEnchant);
  2062. }
  2063.  
  2064. function getInfoEnchantementFromMonstre(nom)
  2065. {
  2066. try
  2067. {
  2068. if(!listeMonstreEnchantement)
  2069. {
  2070. computeCompoEnchantement();
  2071. }
  2072. var infosEnchant = '';
  2073. for(j in listeInfoEnchantement) {
  2074. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2075. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2076. if(infosEnchant=='')
  2077. infosEnchant=listeInfoEnchantement[j][4];
  2078. else
  2079. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2080. }
  2081. }
  2082. return trim(infosEnchant);
  2083. }
  2084. catch(e)
  2085. {
  2086. window.alert(e);
  2087. }
  2088. }
  2089.  
  2090. function composantEnchant(Monstre,composant,localisation,qualite) {
  2091. var compo='';
  2092. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2093. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2094. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2095. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2096. listeInfoEnchantement[i][3]<=qualite
  2097. ) {
  2098. return listeInfoEnchantement[i][4];
  2099. }
  2100. }
  2101. return compo;
  2102. }
  2103.  
  2104. function insertEnchantInfos(tbody) {
  2105. try
  2106. {
  2107. if(!listeMonstreEnchantement)
  2108. computeCompoEnchantement();
  2109. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2110. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2111. if(nodes.snapshotLength == 0)
  2112. return false;
  2113. var urlImg = URL_MZimg + 'enchant.png';
  2114. for(var i = 0; i < nodes.snapshotLength; i++) {
  2115. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2116. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2117. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2118. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2119. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2120. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2121. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2122. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2123. if(isEnchant(nomMonstre).length>0)
  2124. {
  2125. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2126. if(infos.length>0)
  2127. {
  2128. if(link.parentNode == link.nextSibling.parentNode)
  2129. {
  2130. var tmp = link.nextSibling;
  2131. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2132. }
  2133. else
  2134. {
  2135. link.parentNode.appendChild(createImage(urlImg,infos));
  2136. }
  2137. }
  2138. }
  2139. }
  2140. }
  2141. catch(e)
  2142. {
  2143. window.alert(e);
  2144. }
  2145. }
  2146.  
  2147. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2148. {
  2149. try
  2150. {
  2151. if(!listeMonstreEnchantement)
  2152. computeCompoEnchantement();
  2153. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2154. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2155. if(nodes.snapshotLength == 0)
  2156. return false;
  2157. var urlImg = URL_MZimg + 'enchant.png';
  2158. for(var i = 0; i < nodes.snapshotLength; i++)
  2159. {
  2160. var link = nodes.snapshotItem(i);
  2161. var idEquipement = link.getAttribute('href');
  2162. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2163. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2164. var nomEquipement = trim(link.firstChild.nodeValue);
  2165. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2166. if(!enchanteur || enchanteur == '')
  2167. continue;
  2168. var infos = listeEquipementEnchantement[idEquipement];
  2169. infos=formateTexte(infos);
  2170. if(infos.length>0)
  2171. {
  2172. if(link.parentNode == link.nextSibling.parentNode)
  2173. {
  2174. var tmp = link.nextSibling;
  2175. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2176. }
  2177. else
  2178. {
  2179. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2180. }
  2181. }
  2182. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2183. }
  2184. }
  2185. catch(e)
  2186. {
  2187. window.alert(e);
  2188. }
  2189. }
  2190.  
  2191. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2192.  
  2193.  
  2194. // Les % de toucher
  2195. var c = new Array();
  2196.  
  2197. // coefficients binomiaux
  2198. function cnp(n,k)
  2199. {
  2200. if(c[n] != null && c[n][k] != null)
  2201. return c[n][k];
  2202. if(c[n] == null)
  2203. c[n] = new Array();
  2204. if(k==0)
  2205. {
  2206. c[n][k] = 1;
  2207. return 1;
  2208. }
  2209. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2210. c[n][k] = result;
  2211. // Roule debug
  2212. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2213. return result;
  2214. }
  2215.  
  2216. // by Dab, à comparer
  2217. function binom(n,p) {
  2218. if(p<0 || p>n) return 0;
  2219. if(c[n])
  2220. if(c[n][p]) return c[n][p];
  2221. else {
  2222. c[n]=[1];
  2223. c[n][n]=1;
  2224. if(p==0 || p==n) return 1;
  2225. }
  2226. if(2*p>n)
  2227. c[n][p]=binom(n,n-p);
  2228. else
  2229. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2230. return c[n][p];
  2231. }
  2232.  
  2233. var coeff = new Array();
  2234.  
  2235. function coef(n,p)
  2236. {
  2237. if(n==0 && p==0)
  2238. return 1;
  2239. if(p>n*3.5)
  2240. p = 7*n-p
  2241. // roule désactive cache
  2242. if(coeff[n] != null && coeff[n][p] !=null)
  2243. return coeff[n][p];
  2244. if(coeff[n] == null)
  2245. coeff[n] = new Array();
  2246. var kmax = Math.floor((p-n)/6);
  2247. var x=0;
  2248. for(var k=0;k<=kmax;k++)
  2249. {
  2250. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2251. }
  2252. coeff[n][p] = x;
  2253. // Roule debug
  2254. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2255. return x;
  2256. }
  2257.  
  2258. function chanceEsquiveParfaite(a,d,ba,bd)
  2259. {
  2260. var win = 0;
  2261. var los = 0;
  2262. if(ba==null)
  2263. ba=0;
  2264. if(bd==null)
  2265. bd=0;
  2266. /* if(6*a+ba<2*(d+bd))
  2267. return 100;
  2268. if(a+ba>2*(6*d+bd))
  2269. return 0;*/
  2270. for(var ds=d;ds<=6*d;ds++)
  2271. {
  2272. var cd = coef(d,ds);
  2273. for(var as=a;as<=6*a;as++)
  2274. {
  2275. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2276. win += cd * coef(a,as);
  2277. else
  2278. los += cd * coef(a,as);
  2279. }
  2280. }
  2281. // roule debug
  2282. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2283. return Math.round(100*win/(win+los));
  2284. }
  2285.  
  2286. function chanceTouche(a,d,ba,bd)
  2287. {
  2288. var win = 0;
  2289. var los = 0;
  2290. if(ba==null)
  2291. ba=0;
  2292. if(bd==null)
  2293. bd=0;
  2294. if(a+ba>6*d+bd)
  2295. return 100;
  2296. if(6*a+ba<d+bd)
  2297. return 0;
  2298. for(var ds=d;ds<=6*d;ds++)
  2299. {
  2300. var cd = coef(d,ds);
  2301. for(var as=a;as<=6*a;as++)
  2302. {
  2303. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2304. win += cd * coef(a,as);
  2305. else
  2306. los += cd * coef(a,as);
  2307. }
  2308. }
  2309. return Math.round(100*win/(win+los));
  2310. }
  2311.  
  2312. function chanceCritique(a,d,ba,bd)
  2313. {
  2314. var win = 0;
  2315. var los = 0;
  2316. if(ba==null)
  2317. ba=0;
  2318. if(bd==null)
  2319. bd=0;
  2320. if(a+ba>2*(6*d+bd))
  2321. return 100;
  2322. if(6*a+ba<2*(d+bd))
  2323. return 0;
  2324. for(var ds=d;ds<=6*d;ds++)
  2325. {
  2326. var cd = coef(d,ds);
  2327. for(var as=a;as<=6*a;as++)
  2328. {
  2329. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2330. win += cd * coef(a,as);
  2331. else
  2332. los += cd * coef(a,as);
  2333. }
  2334. }
  2335. return Math.round(100*win/(win+los));
  2336. }
  2337.  
  2338. /***********************************************
  2339. Analyse tactique
  2340. ***********************************************/
  2341.  
  2342. function getTexteAnalyse(modificateur,chiffre)
  2343. {
  2344. if(chiffre==0)
  2345. return chiffre;
  2346. return modificateur+chiffre;
  2347. }
  2348.  
  2349. function getAnalyseTactique(id,nom)
  2350. {
  2351. var donneesMonstre = listeCDM[id];
  2352. var needAutres=false;
  2353. var i;
  2354. if(donneesMonstre == null)
  2355. return;
  2356. var array = analyseTactique(donneesMonstre,nom);
  2357. if(array==null)
  2358. return "";
  2359. 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>";
  2360. for(i=0;i<array.length;i++)
  2361. {
  2362. if(array[i][1]==100 && i>0)
  2363. {
  2364. needAutres=true;
  2365. break;
  2366. }
  2367. if(i==1 && array[i][4]>0)
  2368. 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>";
  2369. else if(i==0)
  2370. 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>";
  2371. else
  2372. 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>";
  2373. }
  2374. if(needAutres)
  2375. {
  2376. if(i==array.length-1)
  2377. 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>";
  2378. else if(i==1)
  2379. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2380. else
  2381. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2382. }
  2383. return str+"</table>";
  2384. }
  2385.  
  2386. function analyseTactique(donneesMonstre,nom) {
  2387. try
  2388. {
  2389. var listeAttaques = [];
  2390. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2391. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2392. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2393. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2394. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2395. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2396. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2397. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2398. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2399. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2400. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2401. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2402. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2403. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2404. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2405. var modificateurEsquive = '';
  2406. var modificateurArmure = '';
  2407. var modificateurMagie = '';
  2408. var modificateurEsquiveM = '';
  2409. var modificateurArmureM = '';
  2410. var pasDeSR=false;
  2411. var esqM,attM,armM,degM;
  2412. 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)
  2413. return null;
  2414. var td = document.createElement('td')
  2415. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2416. var esqM = 0;
  2417. try
  2418. {
  2419. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2420. }
  2421. catch(e)
  2422. {
  2423. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2424. modificateurEsquive = '<';
  2425. modificateurArmure = '<';
  2426. modificateurMagie = '<';
  2427. }
  2428. td.innerHTML = bbcode(donneesMonstre[3]);
  2429. var attM = 0;
  2430. try
  2431. {
  2432. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2433. }
  2434. catch(e)
  2435. {
  2436. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2437. modificateurEsquiveM = '>';
  2438. modificateurArmureM = '>';
  2439. }
  2440. td.innerHTML = bbcode(donneesMonstre[5]);
  2441. var degM = 0;
  2442. try
  2443. {
  2444. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2445. }
  2446. catch(e)
  2447. {
  2448. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2449. modificateurArmureM = '>';
  2450. }
  2451. td.innerHTML = bbcode(donneesMonstre[7]);
  2452. var armM = 0;
  2453. try
  2454. {
  2455. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2456. }
  2457. catch(e)
  2458. {
  2459. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2460. modificateurArmure = '<';
  2461. }
  2462. var coeffSeuil = 0.95;
  2463. try
  2464. {
  2465. td.innerHTML = bbcode(donneesMonstre[9]);
  2466. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2467. var v = (rm / mm);
  2468. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2469. coeffSeuil = (200-seuil)/200;
  2470. }
  2471. catch(e)
  2472. {
  2473. modificateurMagie = '<';
  2474. pasDeSR = true;
  2475. }
  2476. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2477. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2478. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2479. // roule debug
  2480. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2481. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2482. 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);
  2483. //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);
  2484. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2485. if(getSortComp("Vampirisme")>0)
  2486. {
  2487. var pour = getSortComp("Vampirisme");
  2488. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2489. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2490. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2491. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2492. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2493. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2494. }
  2495. if(getSortComp("Botte Secrète")>0)
  2496. {
  2497. var pour = getSortComp("Botte Secrète");
  2498. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2499. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2500. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2501. 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;
  2502. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2503. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2504. }
  2505. if(getSortComp("Rafale Psychique")>0)
  2506. {
  2507. var pour = getSortComp("Rafale Psychique");
  2508. chanceDEsquiveParfaite = 0;
  2509. chanceDeTouche = Math.round(100*pour/100);
  2510. chanceDeCritique = Math.round(0*pour/100);
  2511. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2512. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2513. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2514. }
  2515. if(getSortComp("Explosion")>0)
  2516. {
  2517. var pour = getSortComp("Explosion");
  2518. chanceDEsquiveParfaite = 0;
  2519. chanceDeTouche = Math.round(100*pour/100);
  2520. chanceDeCritique = Math.round(0*pour/100);
  2521. 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;
  2522. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2523. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2524. }
  2525. if(getSortComp("Projectile Magique")>0)
  2526. {
  2527. var pour = getSortComp("Projectile Magique");
  2528. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2529. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2530. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2531. 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;
  2532. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2533. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2534. }
  2535. if(getSortComp("Frénésie")>0)
  2536. {
  2537. var pour = getSortComp("Frénésie");
  2538. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2539. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2540. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2541. 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;
  2542. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2543. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2544. }
  2545. if(getSortComp("Charger")>0)
  2546. {
  2547. var pour = getSortComp("Charger");
  2548. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2549. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2550. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2551. 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;
  2552. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2553. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2554. }
  2555. if(getSortComp("Griffe du Sorcier")>0)
  2556. {
  2557. var pour = getSortComp("Griffe du Sorcier");
  2558. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2559. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2560. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2561. 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;
  2562. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2563. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2564. }
  2565. if(getSortComp("Attaque Précise",1)>0)
  2566. {
  2567. var niveau = 5;
  2568. var oldPour = 0;
  2569. var chanceDEsquiveParfaite = 0;
  2570. var chanceDeTouche = 0;
  2571. var chanceDeCritique = 0;
  2572. degats = 0;
  2573. while(niveau>0)
  2574. {
  2575. var pour = getSortComp("Attaque Précise",niveau);
  2576. if(pour>oldPour)
  2577. {
  2578. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2579. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2580. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2581. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2582. chanceDeTouche += chanceDeToucheNiveau;
  2583. chanceDeCritique += chanceDeCritiqueNiveau;
  2584. 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);
  2585. oldPour = pour;
  2586. }
  2587. niveau--;
  2588. }
  2589. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2590. 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));
  2591. }
  2592. if(getSortComp("Coup de Butoir",1)>0)
  2593. {
  2594. var niveau = 5;
  2595. var oldPour =0;
  2596. var chanceDEsquiveParfaite = 0;
  2597. var chanceDeTouche=0;
  2598. var chanceDeCritique=0;
  2599. degats=0;
  2600. while(niveau>0)
  2601. {
  2602. var pour = getSortComp("Coup de Butoir",niveau);
  2603. if(pour>oldPour)
  2604. {
  2605. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2606. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2607. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2608. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2609. chanceDeTouche += chanceDeToucheNiveau;
  2610. chanceDeCritique += chanceDeCritiqueNiveau;
  2611. 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);
  2612. oldPour = pour;
  2613. }
  2614. niveau--;
  2615. }
  2616. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2617. 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));
  2618. }
  2619. 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;});
  2620. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2621. {
  2622. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2623. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2624. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2625. }
  2626. else
  2627. {
  2628. chanceDEsquiveParfaite = 0;
  2629. chanceDeTouche = 100;
  2630. chanceDeCritique = 0;
  2631. }
  2632. 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;
  2633.  
  2634. 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));
  2635. return listeAttaques;
  2636. }
  2637. catch(e) { window.alert(e);}
  2638. }
  2639.  
  2640. // x~~x marque pour s'y retrouver sous l'éditeur
  2641.  
  2642. /*
  2643. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2644. * published under GNU License v2.
  2645. *
  2646. * Patch :
  2647. * gestion des missions terminées
  2648. */
  2649. // x~x mission_liste
  2650.  
  2651. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2652. try {
  2653. var titresMimis = document.evaluate(
  2654. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2655. document, null, 7, null
  2656. );
  2657. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2658. } catch(e) {
  2659. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2660. return;
  2661. }
  2662. var enCours = {};
  2663. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2664. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2665. enCours[num] = true;
  2666. }
  2667. for(var numMimi in obMissions) {
  2668. if(!enCours[numMimi]) {
  2669. delete obMissions[numMimi];
  2670. }
  2671. }
  2672. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2673. }
  2674.  
  2675. function do_mission_liste() {
  2676. checkLesMimis();
  2677. }
  2678.  
  2679. /*******************************************************************************
  2680. * This file is part of Mountyzilla. *
  2681. * *
  2682. * Mountyzilla is free software; you can redistribute it and/or modify *
  2683. * it under the terms of the GNU General Public License as published by *
  2684. * the Free Software Foundation; either version 2 of the License, or *
  2685. * (at your option) any later version. *
  2686. * *
  2687. * Mountyzilla is distributed in the hope that it will be useful, *
  2688. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2689. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2690. * GNU General Public License for more details. *
  2691. * *
  2692. * You should have received a copy of the GNU General Public License *
  2693. * along with Mountyzilla; if not, write to the Free Software *
  2694. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2695. *******************************************************************************/
  2696.  
  2697. // x~x actions
  2698.  
  2699. /* TODO
  2700. * getLvl pour Explo, Rotobaffe et cie
  2701. */
  2702.  
  2703.  
  2704.  
  2705. /* Page de combat */
  2706.  
  2707. function getLevel() {
  2708. var divList = document.getElementsByTagName('div');
  2709. if(divList.length <= 2)
  2710. return;
  2711. // On essaie de voir si cette action était une attaque
  2712. var pList = document.getElementsByTagName('p');
  2713. var nomM = '';
  2714. // Modification pour Frénésie by TetDure
  2715. var numAtt = 0;
  2716. for (var i = 0; i < pList.length; i++) {
  2717. if(pList[i].firstChild) {
  2718. nomM = pList[i].firstChild.nodeValue;
  2719. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2720. numAtt++;
  2721. }
  2722. }
  2723. if(nomM == '')
  2724. return;
  2725. // Si c'est une attaque normale, un seul PX
  2726. var comPX = 1;
  2727. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2728. comPX++;
  2729.  
  2730. // Extraction des infos du monstre attaqué
  2731. var idM;
  2732. var male;
  2733. if(nomM.slice(20, 21) == 'e') {
  2734. male = false;
  2735. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2736. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2737. }
  2738. else {
  2739. male = true;
  2740. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2741. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2742. }
  2743. if(idM == '')
  2744. return;
  2745. var bList = document.getElementsByTagName('b');
  2746. var niveau = '';
  2747. for (var i = 0; i < bList.length; i++) {
  2748. var b = bList[i];
  2749. if(b.childNodes[0].nodeValue != "TUÉ")
  2750. continue;
  2751. var nbPX = "";
  2752. for (i++; i < bList.length; i++) {
  2753. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2754. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2755. return;
  2756. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2757. nbPX = bList[i].childNodes[0].nodeValue;
  2758. break;
  2759. }
  2760. }
  2761. if(nbPX == '')
  2762. return;
  2763. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2764. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2765. if(!nbPX)
  2766. nbPX = 0;
  2767. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2768. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2769. if(comPX > nbPX) {
  2770. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2771. niveau = "";
  2772. } else if(Math.floor(niveau) == niveau) {
  2773. chaine += niveau + ".";
  2774. } else {
  2775. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2776. niveau = "";
  2777. }
  2778. insertBr(b.nextSibling.nextSibling.nextSibling);
  2779. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2780. }
  2781.  
  2782. if(niveau != '') {
  2783. var button = insertButtonCdm('as_Action');
  2784. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2785. + escape(nomM) + "&niveau=" + escape(niveau)
  2786. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2787. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2788. }
  2789. }
  2790.  
  2791.  
  2792. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2793.  
  2794. function insertInfoMagie(node, intitule, magie) {
  2795. if(node.nextSibling) {
  2796. node = node.nextSibling;
  2797. insertBr(node);
  2798. insertText(node, intitule);
  2799. insertText(node, magie, true);
  2800. } else {
  2801. node = node.parentNode;
  2802. appendBr(node);
  2803. appendText(node, intitule);
  2804. appendText(node, magie, true);
  2805. }
  2806. }
  2807.  
  2808. function getMM(sr) {
  2809. if(rmTroll<=0) {
  2810. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2811. }
  2812. sr = Number(sr.match(/\d+/)[0]);
  2813. if(sr==10) {
  2814. return '\u2265 '+5*rmTroll;
  2815. }
  2816. if(sr<=50) {
  2817. return Math.round(50*rmTroll/sr);
  2818. }
  2819. if(sr<90) {
  2820. return Math.round((100-sr)*rmTroll/50);
  2821. }
  2822. return '\u2264 '+Math.round(rmTroll/5);
  2823. }
  2824.  
  2825. function traiteMM() {
  2826. var node = document.evaluate(
  2827. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2828. document, null, 9, null).singleNodeValue;
  2829. if(node) {
  2830. var mm = getMM(node.nodeValue);
  2831. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2832. } else {
  2833. var node = document.evaluate(
  2834. "//p/text()[contains(., 'Seuil de Résistance')]",
  2835. document, null, 9, null).singleNodeValue;
  2836. if(!node) {
  2837. return;
  2838. }
  2839. var mm = getMM(node.nodeValue);
  2840. node = node.nextSibling.nextSibling;
  2841. }
  2842. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2843. }
  2844.  
  2845. function getRM(sr) {
  2846. if(mmTroll<=0) {
  2847. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2848. }
  2849. sr = Number(sr.match(/\d+/)[0]);
  2850. if(sr==10) {
  2851. return '\u2264 '+Math.round(mmTroll/5);
  2852. }
  2853. if(sr<=50) {
  2854. return Math.round(sr*mmTroll/50);
  2855. }
  2856. if(sr<90) {
  2857. return Math.round(50*mmTroll/(100-sr));
  2858. }
  2859. return '\u2265 '+5*mmTroll;
  2860. }
  2861.  
  2862. function traiteRM() {
  2863. var nodes = document.evaluate(
  2864. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2865. document, null, 7, null);
  2866. if(nodes.snapshotLength==0) {
  2867. return;
  2868. }
  2869. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2870. var node = nodes.snapshotItem(i);
  2871. var rm = getRM(node.nodeValue);
  2872. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2873. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2874. }
  2875. }
  2876.  
  2877.  
  2878. /* Fonction stats IdT par Raistlin */
  2879. /*function getIdt() {
  2880. if(MY_getValue("SEND_IDT") == "non")
  2881. return false;
  2882. var regExpBeginning = /^\s+/;
  2883. var regExpEnd = /\s+$/;
  2884.  
  2885. var nomIdt = document.evaluate(
  2886. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2887. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2888. if(!nomIdt)
  2889. return false;
  2890.  
  2891. var caracIdt;
  2892. if(nomIdt.indexOf("Malédiction !") != -1) {
  2893. caracIdt = "";
  2894. nomIdt = "Mission maudite";
  2895. } else {
  2896. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2897. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2898. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2899. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2900. }
  2901. FF_XMLHttpRequest({
  2902. method: 'GET',
  2903. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  2904. headers : {
  2905. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  2906. 'Accept': 'application/atom+xml,application/xml,text/xml',
  2907. }
  2908. });
  2909. return true;
  2910. }*/
  2911.  
  2912.  
  2913. /*-[functions]------------------- Décalage DLA -------------------------------*/
  2914.  
  2915. function confirmeDecalage() {
  2916. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  2917. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  2918. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  2919. var newDLA = new Date( oldDLA );
  2920. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  2921. return window.confirm(
  2922. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  2923. +'\nConfirmez-vous ce décalage ?'
  2924. );
  2925. }
  2926.  
  2927. function newsubmitDLA(evt) {
  2928. evt.stopPropagation();
  2929. evt.preventDefault();
  2930. if(confirmeDecalage()) {
  2931. this.submit();
  2932. }
  2933. }
  2934.  
  2935. function changeActionDecalage() {
  2936. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  2937. return;
  2938. }
  2939. try {
  2940. // On récupère le contenu du script JS MH de calcul du décalage
  2941. var scriptTxt = document.evaluate(
  2942. ".//script[ not(@src) ]",
  2943. document, null, 9, null
  2944. ).singleNodeValue.textContent;
  2945. // On en extrait la DLA courante
  2946. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  2947. scriptTxt = scriptTxt.split('\n')[0];
  2948. var nbs = scriptTxt.match(/\d+/g);
  2949. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  2950. } catch(e) {
  2951. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2952. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  2953. return;
  2954. }
  2955. var form = document.getElementsByName('ActionForm')[0];
  2956. if(form) {
  2957. form.addEventListener('submit', newsubmitDLA, true);
  2958. } else {
  2959. avertissement('Erreur de parsage : confirmation de décalage impossible');
  2960. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  2961. }
  2962. }
  2963.  
  2964. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  2965.  
  2966. function prochainMundi() {
  2967. try {
  2968. var node = document.evaluate(
  2969. "//div[@class='dateAction']/b",
  2970. document, null, 9, null
  2971. ).singleNodeValue;
  2972. } catch(e) {
  2973. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  2974. return;
  2975. }
  2976. if(!node) { return; }
  2977.  
  2978. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  2979. var jour = longueurMois+1-getNumber(node.textContent);
  2980. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  2981. var txt = '[Prochain Mundidey ';
  2982. if(jour>1) {
  2983. txt += 'dans '+jour+' jours]';
  2984. } else {
  2985. txt += 'demain]';
  2986. }
  2987. insertText(node.parentNode.nextSibling,txt,true);
  2988. }
  2989.  
  2990.  
  2991. /* Fonction principale */
  2992.  
  2993. function dispatch() {
  2994. if(isPage('MH_Play/Play_action')) {
  2995. prochainMundi();
  2996. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  2997. var oldDLA;
  2998. changeActionDecalage();
  2999. } else if(isPage('MH_Play/Actions')) {
  3000. if(document.evaluate(
  3001. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3002. document, null, 2, null
  3003. ).stringValue) {
  3004. traiteMM();
  3005. } else if(document.evaluate(
  3006. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3007. document, null, 2, null
  3008. ).stringValue) {
  3009. //getIdt();
  3010. traiteRM();
  3011. } /*else {
  3012. // Est censé se lancer sur quoi *précisément* ?
  3013. traiteRM();
  3014. getLevel();
  3015. }*/
  3016. } else {
  3017. /* Traitement des messages du bot */
  3018. var messageTitle = document.evaluate(
  3019. "//form/table/tbody/tr[1]/td[1]/"
  3020. +"descendant::text()[contains(.,'[MountyHall]')]",
  3021. document, null, 2, null
  3022. ).stringValue;
  3023. if(messageTitle.indexOf('Attaquant') != -1 &&
  3024. messageTitle.indexOf('sur') != -1) {
  3025. getLevel();
  3026. traiteRM();
  3027. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3028. messageTitle.indexOf('Défenseur') != -1) {
  3029. traiteMM();
  3030. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3031. // à replacer avec Attaque après révision getLvl :
  3032. messageTitle.indexOf('Explosion') != -1 ||
  3033. messageTitle.indexOf('Insulte') != -1) {
  3034. traiteRM();
  3035. }
  3036. }
  3037. }
  3038.  
  3039. function do_actions() {
  3040. start_script(31);
  3041. dispatch();
  3042. displayScriptTime();
  3043. }
  3044.  
  3045. /*********************************************************************************
  3046. * This file is part of Mountyzilla. *
  3047. * *
  3048. * Mountyzilla is free software; you can redistribute it and/or modify *
  3049. * it under the terms of the GNU General Public License as published by *
  3050. * the Free Software Foundation; either version 2 of the License, or *
  3051. * (at your option) any later version. *
  3052. * *
  3053. * Mountyzilla is distributed in the hope that it will be useful, *
  3054. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3055. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3056. * GNU General Public License for more details. *
  3057. * *
  3058. * You should have received a copy of the GNU General Public License *
  3059. * along with Mountyzilla; if not, write to the Free Software *
  3060. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3061. *********************************************************************************/
  3062.  
  3063. // x~x pre-enchant
  3064.  
  3065. /* 2013-08-19 : correction auto syntaxe alert */
  3066.  
  3067. var combobox=null;
  3068.  
  3069. function changeObject()
  3070. {
  3071. if(!combobox)
  3072. return ;
  3073. var id = combobox.options[combobox.selectedIndex].value;
  3074. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3075. if(!id || id=="")
  3076. {
  3077. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3078. return;
  3079. }
  3080. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3081. }
  3082.  
  3083. function treatePreEnchantement() {
  3084. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3085. if(!input || input.getAttribute("type")=="hidden")
  3086. {
  3087. return false;
  3088. }
  3089. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3090. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3091. if(!combobox)
  3092. {
  3093. return true;
  3094. }
  3095. combobox.addEventListener('change', changeObject, true);
  3096. return true;
  3097. }
  3098.  
  3099. function treateEnchantement() {
  3100. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3101. if(!input || input.getAttribute("type")!="hidden")
  3102. {
  3103. return false;
  3104. }
  3105. var idEquipement = input.getAttribute("value");
  3106. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3107. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3108. if(enchanteur && enchanteur != null)
  3109. return true;
  3110. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3111. if(!input || input.getAttribute("type")!="hidden")
  3112. {
  3113. return false;
  3114. }
  3115. var idEnchanteur = input.getAttribute("value");
  3116. var nodes = document.evaluate(
  3117. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3118. if (nodes.snapshotLength != 3)
  3119. return;
  3120. for(var i=0;i<3;i++)
  3121. {
  3122. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3123. texte = texte.replace(" d'une "," d'un ");
  3124. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3125. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3126. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3127. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3128. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3129. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3130. }
  3131. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3132. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3133. var liste = MY_getValue(numTroll+".enchantement.liste");
  3134. if(!liste || liste=="")
  3135. {
  3136. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3137. }
  3138. else
  3139. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3140. }
  3141.  
  3142. function do_pre_enchant() {
  3143. start_script(60);
  3144. if(!treatePreEnchantement())
  3145. treateEnchantement();
  3146. displayScriptTime();
  3147. }
  3148.  
  3149. /*********************************************************************************
  3150. * This file is part of Mountyzilla. *
  3151. * *
  3152. * Mountyzilla is free software; you can redistribute it and/or modify *
  3153. * it under the terms of the GNU General Public License as published by *
  3154. * the Free Software Foundation; either version 2 of the License, or *
  3155. * (at your option) any later version. *
  3156. * *
  3157. * Mountyzilla is distributed in the hope that it will be useful, *
  3158. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3159. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3160. * GNU General Public License for more details. *
  3161. * *
  3162. * You should have received a copy of the GNU General Public License *
  3163. * along with Mountyzilla; if not, write to the Free Software *
  3164. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3165. *********************************************************************************/
  3166.  
  3167. // x~x enchant
  3168.  
  3169. /* 2013-08-19 : correction auto syntaxe alert */
  3170.  
  3171. function treateEnchantement() {
  3172. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3173. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3174. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3175. return;
  3176. var tab = infoEquipement.split(";");
  3177. if(tab.length<2)
  3178. return;
  3179. var idEquipement = tab[0];
  3180. var nomEquipement = tab[1];
  3181. for(var i=2;i<tab.length;i++)
  3182. nomEquipement += ";"+tab[i];
  3183. var nodes = document.evaluate(
  3184. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3185. if (nodes.snapshotLength != 3)
  3186. return;
  3187. for(var i=0;i<3;i++)
  3188. {
  3189. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3190. texte = texte.replace(" d'une "," d'un ");
  3191. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3192. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3193. monstre = monstre.replace(/ Géante?/,"");
  3194. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3195. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3196. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3197. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3198. }
  3199. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3200. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3201. var liste = MY_getValue(numTroll+".enchantement.liste");
  3202. if(!liste || liste=="")
  3203. {
  3204. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3205. }
  3206. else
  3207. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3208. }
  3209.  
  3210. function do_enchant() {
  3211. start_script(60);
  3212.  
  3213. treateEnchantement();
  3214. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3215. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3216. displayScriptTime();
  3217. }
  3218.  
  3219. /*********************************************************************************
  3220. * This file is part of Mountyzilla. *
  3221. * *
  3222. * Mountyzilla is free software; you can redistribute it and/or modify *
  3223. * it under the terms of the GNU General Public License as published by *
  3224. * the Free Software Foundation; either version 2 of the License, or *
  3225. * (at your option) any later version. *
  3226. * *
  3227. * Mountyzilla is distributed in the hope that it will be useful, *
  3228. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3229. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3230. * GNU General Public License for more details. *
  3231. * *
  3232. * You should have received a copy of the GNU General Public License *
  3233. * along with Mountyzilla; if not, write to the Free Software *
  3234. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3235. *********************************************************************************/
  3236.  
  3237. // x~x myevent
  3238.  
  3239. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3240. function do_myevent() {
  3241. }
  3242.  
  3243. /*********************************************************************************
  3244. * This file is part of Mountyzilla. *
  3245. * *
  3246. * Mountyzilla is free software; you can redistribute it and/or modify *
  3247. * it under the terms of the GNU General Public License as published by *
  3248. * the Free Software Foundation; either version 2 of the License, or *
  3249. * (at your option) any later version. *
  3250. * *
  3251. * Mountyzilla is distributed in the hope that it will be useful, *
  3252. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3253. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3254. * GNU General Public License for more details. *
  3255. * *
  3256. * You should have received a copy of the GNU General Public License *
  3257. * along with Mountyzilla; if not, write to the Free Software *
  3258. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3259. *********************************************************************************/
  3260.  
  3261. // x~x malus
  3262.  
  3263. /* v1.4 - 2014-01-06
  3264. * - Gestion des sorts double composante
  3265. * v1.4.1 - 2014-01-22
  3266. * - Correction décumul
  3267. * TODO
  3268. * - Identifier la position de "PV" dans l'ordre MH
  3269. */
  3270.  
  3271. var listeBM;
  3272.  
  3273.  
  3274. /* [functions] Utilitaires */
  3275.  
  3276. function decumul(bmt,nbr) {
  3277. var bmr;
  3278. if(!nbr || nbr<2) bmr = bmt;
  3279. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3280. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3281. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3282. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3283. else bmr = parseInt(0.1*bmt);
  3284. if(bmt<0) return Math.min(-1,bmr);
  3285. return Math.max(1,bmr);
  3286. }
  3287.  
  3288. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3289. // Roule 23/11/2016 ajout PV
  3290. switch( a ) {
  3291. case 'ATT':
  3292. return -1;
  3293. case 'ESQ':
  3294. if(b=='ATT') return 1;
  3295. return -1;
  3296. case 'DEG':
  3297. switch( b ) {
  3298. case 'ATT':
  3299. case 'ESQ':
  3300. return 1;
  3301. default:
  3302. return -1;
  3303. }
  3304. case 'REG':
  3305. switch( b ) {
  3306. case 'ATT':
  3307. case 'ESQ':
  3308. case 'DEG':
  3309. return 1;
  3310. default:
  3311. return -1;
  3312. }
  3313. case 'Vue':
  3314. switch( b ) {
  3315. case 'ATT':
  3316. case 'ESQ':
  3317. case 'DEG':
  3318. case 'REG':
  3319. return 1;
  3320. default:
  3321. return -1;
  3322. }
  3323. case 'TOUR':
  3324. switch( b ) {
  3325. case 'ATT':
  3326. case 'ESQ':
  3327. case 'DEG':
  3328. case 'REG':
  3329. case 'Vue':
  3330. return 1;
  3331. default:
  3332. return -1;
  3333. }
  3334. case 'PV':
  3335. switch( b ) {
  3336. case 'ATT':
  3337. case 'ESQ':
  3338. case 'DEG':
  3339. case 'REG':
  3340. case 'Vue':
  3341. case 'TOUR':
  3342. return 1;
  3343. default:
  3344. return -1;
  3345. }
  3346. case 'Armure':
  3347. switch( b ) {
  3348. case 'ATT':
  3349. case 'ESQ':
  3350. case 'DEG':
  3351. case 'REG':
  3352. case 'Vue':
  3353. case 'TOUR':
  3354. case 'PV':
  3355. return 1;
  3356. default:
  3357. return -1;
  3358. }
  3359. case 'RM':
  3360. switch( b ) {
  3361. case 'ATT':
  3362. case 'ESQ':
  3363. case 'DEG':
  3364. case 'REG':
  3365. case 'Vue':
  3366. case 'TOUR':
  3367. case 'PV':
  3368. case 'Armure':
  3369. return 1;
  3370. default:
  3371. return -1;
  3372. }
  3373. case 'MM':
  3374. switch( b ) {
  3375. case 'ATT':
  3376. case 'ESQ':
  3377. case 'DEG':
  3378. case 'REG':
  3379. case 'Vue':
  3380. case 'TOUR':
  3381. case 'PV':
  3382. case 'Armure':
  3383. case 'RM':
  3384. return 1;
  3385. default:
  3386. return -1;
  3387. }
  3388. case 'Concentration':
  3389. switch( b ) {
  3390. case 'ATT':
  3391. case 'ESQ':
  3392. case 'DEG':
  3393. case 'REG':
  3394. case 'Vue':
  3395. case 'TOUR':
  3396. case 'PV':
  3397. case 'Armure':
  3398. case 'RM':
  3399. case 'MM':
  3400. return 1;
  3401. default:
  3402. return -1;
  3403. }
  3404. case 'Fatigue':
  3405. switch( b ) {
  3406. case 'ATT':
  3407. case 'ESQ':
  3408. case 'DEG':
  3409. case 'REG':
  3410. case 'Vue':
  3411. case 'TOUR':
  3412. case 'PV':
  3413. case 'Armure':
  3414. case 'RM':
  3415. case 'MM':
  3416. case 'Concentration':
  3417. return 1;
  3418. default:
  3419. return -1;
  3420. }
  3421. case "Dés d'attaque":
  3422. switch( b ) {
  3423. case 'ATT':
  3424. case 'ESQ':
  3425. case 'DEG':
  3426. case 'REG':
  3427. case 'Vue':
  3428. case 'TOUR':
  3429. case 'PV':
  3430. case 'Armure':
  3431. case 'RM':
  3432. case 'MM':
  3433. case 'Concentration':
  3434. case 'Fatigue':
  3435. return 1;
  3436. default:
  3437. return -1;
  3438. }
  3439. case 'Dés de dégâts':
  3440. switch( b ) {
  3441. case 'ATT':
  3442. case 'ESQ':
  3443. case 'DEG':
  3444. case 'REG':
  3445. case 'Vue':
  3446. case 'TOUR':
  3447. case 'PV':
  3448. case 'Armure':
  3449. case 'RM':
  3450. case 'MM':
  3451. case 'Concentration':
  3452. case 'Fatigue':
  3453. case "Dés d'attaque":
  3454. return 1;
  3455. default:
  3456. return -1;
  3457. }
  3458. default :
  3459. switch( b ) {
  3460. case 'ATT':
  3461. case 'ESQ':
  3462. case 'DEG':
  3463. case 'REG':
  3464. case 'Vue':
  3465. case 'TOUR':
  3466. case 'PV':
  3467. case 'Armure':
  3468. case 'RM':
  3469. case 'MM':
  3470. case 'Concentration':
  3471. case 'Fatigue':
  3472. case "Dés d'attaque":
  3473. case 'Dés de dégâts':
  3474. return 1;
  3475. default:
  3476. return -1;
  3477. }
  3478. }
  3479. }
  3480.  
  3481.  
  3482. /* [functions] Fonctions hide / display */
  3483.  
  3484. function toggleDetailsBM() {
  3485. if(MY_getValue('BMDETAIL')!='false') {
  3486. MY_setValue('BMDETAIL','false');
  3487. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3488. for(var i=0 ; i<trlist.length ; i++)
  3489. trlist[i].style.display = 'none';
  3490. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3491. for(var i=0 ; i<trlist.length ; i++)
  3492. trlist[i].style = '';
  3493. }
  3494. else {
  3495. MY_setValue('BMDETAIL','true');
  3496. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3497. for(var i=0 ; i<trlist.length ; i++)
  3498. trlist[i].style.display = 'none';
  3499. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3500. for(var i=0 ; i<trlist.length ; i++)
  3501. trlist[i].style = '';
  3502. }
  3503. }
  3504.  
  3505. function toggleBMList() {
  3506. if(MY_getValue('BMHIDELIST')=='true') {
  3507. MY_setValue('BMHIDELIST','false');
  3508. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3509. listeBM.snapshotItem(i).style = '';
  3510. document.getElementsByTagName('thead')[0].style = '';
  3511. document.getElementById('trhelp').style = '';
  3512. }
  3513. else {
  3514. MY_setValue('BMHIDELIST','true');
  3515. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3516. listeBM.snapshotItem(i).style.display = 'none';
  3517. document.getElementsByTagName('thead')[0].style.display = 'none';
  3518. document.getElementById('trhelp').style.display = 'none';
  3519. }
  3520. }
  3521.  
  3522. function setDisplayBM() {
  3523. if(!listeBM) return;
  3524. var titre = document.getElementById('titre2');
  3525. if(titre) {
  3526. titre.style.cursor = 'pointer';
  3527. titre.onclick = toggleBMList;
  3528. }
  3529. var tfoot = document.getElementsByTagName('tfoot')[0];
  3530. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3531. tfoot, null, 9, null).singleNodeValue;
  3532. tr.id = 'trhelp';
  3533. if(MY_getValue('BMHIDELIST')=='true') {
  3534. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3535. listeBM.snapshotItem(i).style.display = 'none';
  3536. document.getElementsByTagName('thead')[0].style.display = 'none';
  3537. tr.style.display = 'none';
  3538. }
  3539. }
  3540.  
  3541.  
  3542. /* [functions] Fonction principale */
  3543.  
  3544. function traiteMalus() {
  3545. var mainTab = document.getElementsByTagName('table')[0];
  3546. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3547. if(listeBM.snapshotLength==0) return;
  3548. /* Suppression des BM de fatigue stockés */
  3549. if(MY_getValue(numTroll+'.bm.fatigue'))
  3550. MY_removeValue(numTroll+'.bm.fatigue');
  3551. /* Extraction des données */
  3552. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3553. var nb = 0;
  3554. while(nb<listeBM.snapshotLength) {
  3555. tr = listeBM.snapshotItem(nb); nb++;
  3556. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3557. var phymag = tr.childNodes[9].textContent;
  3558. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3559. var type = tr.childNodes[3].textContent, nom;
  3560. // si c'est un type à décumul
  3561. /*
  3562. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3563. switch(type) {
  3564. case 'Potion':
  3565. case 'Parchemin':
  3566. case 'Sortilège':
  3567. case 'Capacité Spéciale':
  3568. nom = tr.childNodes[1].textContent+phymag;
  3569. break;
  3570. default:
  3571. nom = 'pasdedecumul';
  3572. }
  3573. */
  3574. nom = tr.childNodes[1].textContent+phymag;
  3575. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3576. nom = 'pasdedecumul';
  3577. uniListe[nb] = {
  3578. 'duree':duree,
  3579. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3580. 'caracs':{}
  3581. }
  3582. for(var i=0 ; i<effetsT.length ; i++) {
  3583. if(effetsT[i].indexOf(':')==-1) continue;
  3584. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3585. // nom = 'pasdedecumul' si pas de décumul
  3586. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3587. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3588. uniListe[nb]['type'] = phymag;
  3589. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3590. uniListe[nb]['caracs'][carac] = bm;
  3591. listeDurees[duree] = true;
  3592. }
  3593. } // fin boucle sur les lignes de bonus/malus
  3594. /* Gestion des décumuls et cumuls des durées */
  3595. var toursGeres = [];
  3596. for(var d in listeDurees) toursGeres.push(d);
  3597. toursGeres.sort( function (a,b){return b-a;} );
  3598. // pour sauvegarder les bm de fatigue
  3599. var strfat = '';
  3600. // Pour affichage & adpatation à footable.js (statique)
  3601. var thead = document.getElementsByTagName('thead')[0];
  3602. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3603. thead, null, 7, null).snapshotLength;
  3604. var tfoot = document.getElementsByTagName('tfoot')[0];
  3605. for(var i=0 ; i<toursGeres.length ; i++) {
  3606. var tour = toursGeres[i];
  3607. var effetsCeTour = {}; decumulsCeTour = {};
  3608. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3609. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3610. continue;
  3611. var nom = uniListe[nb]['nom'];
  3612. if(nom!='pasdedecumul') {
  3613. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3614. decumulsCeTour[nom]++;
  3615. }
  3616. for(var carac in uniListe[nb]['caracs']) {
  3617. var bm = uniListe[nb]['caracs'][carac];
  3618. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3619. var type = uniListe[nb]['type'];
  3620. if(!effetsCeTour[carac])
  3621. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3622. if(nom=='pasdedecumul')
  3623. effetsCeTour[carac][type] += bm;
  3624. else
  3625. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  3626. } else {
  3627. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3628. var thisBm;
  3629. if(nom=='pasdedecumul' || carac=='Fatigue')
  3630. thisBm = bm;
  3631. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3632. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3633. else
  3634. thisBm = decumul(bm,decumulsCeTour[nom]);
  3635. effetsCeTour[carac] += thisBm;
  3636. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3637. }
  3638. } // fin boucle sur les caractéristiques
  3639. } // fin boucle sur les bonus/malus
  3640. /* Création du bilan du tour */
  3641. var texteD = '', texteS = '';
  3642. var caracGerees = [];
  3643. for(var k in effetsCeTour) caracGerees.push(k);
  3644. caracGerees.sort( triecaracs );
  3645. for(var j=0 ; j<caracGerees.length ; j++) {
  3646. var carac = caracGerees[j], str = '';
  3647. switch( carac ) {
  3648. case 'ATT':
  3649. case 'DEG':
  3650. case 'Armure':
  3651. var phy = effetsCeTour[carac]['Physique'];
  3652. var mag = effetsCeTour[carac]['Magie'];
  3653. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3654. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3655. break;
  3656. case 'TOUR':
  3657. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3658. break;
  3659. case 'Fatigue':
  3660. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3661. case 'PV':
  3662. case 'ESQ':
  3663. case 'REG':
  3664. case 'Vue':
  3665. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3666. break;
  3667. default:
  3668. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3669. }
  3670. if(str) {
  3671. texteD += str;
  3672. texteS += str;
  3673. }
  3674. } // fin boucle sur les caractéristiques
  3675. /* Affichage */
  3676. // Si rien à afficher on passe
  3677. if(!texteD) continue;
  3678. // Si BMM+BMP=0
  3679. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3680. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3681. if(MY_getValue('BMDETAIL')=='false')
  3682. tr.style.display = 'none';
  3683. var td = appendTdText(tr,texteD.substring(3));
  3684. td.colSpan = 5-nbHidden;
  3685. var txttour = toursGeres[i]+' Tour';
  3686. if(toursGeres[i]>1) txttour += 's';
  3687. appendTdText(tr,txttour);
  3688. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3689. if(MY_getValue('BMDETAIL')!='false')
  3690. tr.style.display = 'none';
  3691. td = appendTdText(tr,texteS);
  3692. td.colSpan = 5-nbHidden;
  3693. appendTdText(tr,txttour);
  3694. } // fin boucle sur les tours générés
  3695. /* mise en place toggleDetails */
  3696. tfoot.style.cursor = 'pointer';
  3697. tfoot.onclick = toggleDetailsBM;
  3698. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3699. if(strfat)
  3700. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3701. }
  3702.  
  3703. function do_malus() {
  3704. try {
  3705. start_script();
  3706. traiteMalus();
  3707. setDisplayBM();
  3708. displayScriptTime();
  3709. }
  3710. catch(e) {window.alert(e)};
  3711. }
  3712.  
  3713. /*******************************************************************************
  3714. * This file is part of Mountyzilla. *
  3715. * *
  3716. * Mountyzilla is free software; you can redistribute it and/or modify *
  3717. * it under the terms of the GNU General Public License as published by *
  3718. * the Free Software Foundation; either version 2 of the License, or *
  3719. * (at your option) any later version. *
  3720. * *
  3721. * Mountyzilla is distributed in the hope that it will be useful, *
  3722. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3723. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3724. * GNU General Public License for more details. *
  3725. * *
  3726. * You should have received a copy of the GNU General Public License *
  3727. * along with Mountyzilla; if not, write to the Free Software *
  3728. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3729. *******************************************************************************/
  3730.  
  3731. // x~x mouches
  3732.  
  3733. var mainTab, tr_mouches;
  3734.  
  3735. function initialiseMouches() {
  3736. // Lanceur global
  3737. try {
  3738. mainTab = document.getElementById('mouches');
  3739. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3740. } catch(e) {
  3741. avertissement('Erreur MZ:<br />Consulter la console.');
  3742. window.console.error(traceStack(e, 'mouches'));
  3743. return;
  3744. }
  3745. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3746. setDisplayMouches();
  3747. traiteMouches();
  3748. }
  3749.  
  3750. function setDisplayMouches() {
  3751. // Initialise l'affichage / l'effacement du détail des mouches
  3752. var titre = document.getElementById('titre2');
  3753. if(titre) {
  3754. titre.style.cursor = 'pointer';
  3755. titre.onclick = toggleMouches;
  3756. }
  3757. var tfoot = document.getElementsByTagName('tfoot')[0];
  3758. if(tfoot) {
  3759. tfoot.style.cursor = 'pointer';
  3760. tfoot.onclick = toggleMouches;
  3761. }
  3762. if(MY_getValue('HIDEMOUCHES')=='true') {
  3763. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3764. tr_mouches.snapshotItem(i).style.display = 'none';
  3765. }
  3766. document.getElementsByTagName('thead')[0].style.display = 'none';
  3767. }
  3768. }
  3769.  
  3770. function toggleMouches() {
  3771. // Handler pour afficher / masquer les détasil
  3772. if(MY_getValue('HIDEMOUCHES')=='true') {
  3773. MY_setValue('HIDEMOUCHES','false');
  3774. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3775. tr_mouches.snapshotItem(i).style.display = '';
  3776. }
  3777. document.getElementsByTagName('thead')[0].style.display = '';
  3778. } else {
  3779. MY_setValue('HIDEMOUCHES','true');
  3780. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3781. tr_mouches.snapshotItem(i).style.display = 'none';
  3782. }
  3783. document.getElementsByTagName('thead')[0].style.display = 'none';
  3784. }
  3785. }
  3786.  
  3787. function traiteMouches() {
  3788. // Traitement complet: présence et effets des mouches
  3789. var listeTypes = {}, effetsActifs = {};
  3790. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3791. var tr = tr_mouches.snapshotItem(i);
  3792. // La mouche est-elle présente?
  3793. var etat = document.evaluate(
  3794. './img',
  3795. tr.cells[6], null, 9, null
  3796. ).singleNodeValue.alt;
  3797. if(etat!='La Mouche est là') { continue; }
  3798. // Extraction du type de mouche
  3799. var type = trim(tr.cells[3].textContent);
  3800. if(!listeTypes[type]) {
  3801. listeTypes[type] = 1;
  3802. } else {
  3803. listeTypes[type]++;
  3804. }
  3805. // La mouche a-t-elle un effet?
  3806. var effet = trim(tr.cells[2].textContent);
  3807. if(etat!='La Mouche est là' || !effet) { continue; }
  3808. // Si oui, extraction des effets (multiples pour pogées)
  3809. var caracs = effet.split(' | ');
  3810. for(var j=0 ; j<caracs.length ; j++) {
  3811. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3812. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3813. if(effetsActifs[carac]===void(0)) {
  3814. effetsActifs[carac] = valeur;
  3815. } else {
  3816. effetsActifs[carac] += valeur;
  3817. }
  3818. }
  3819. }
  3820. // Extraction Effet total et affichage des différences à la normale
  3821. var tfoot = document.getElementsByTagName('tfoot')[0];
  3822. if(!tfoot) { return; }
  3823. var nodeTotal = document.evaluate(
  3824. ".//b[contains(./text(),'Effet total')]",
  3825. tfoot, null, 9, null
  3826. ).singleNodeValue.nextSibling;
  3827. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3828. var texte = ' ';
  3829. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3830. if(texte.length>1) { texte += ' | '; }
  3831. var carac = trim(
  3832. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3833. );
  3834. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3835. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3836. texte += effetsTheoriques[i];
  3837. } else {
  3838. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3839. if(carac=='TOUR') { texte += ' min'; }
  3840. texte += '</b>';
  3841. }
  3842. }
  3843. var span = document.createElement('span');
  3844. span.innerHTML = texte;
  3845. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3846. // Affichage des différences du nombre de mouches de chaque type
  3847. var mouchesParType = document.evaluate(
  3848. "./tr/td/ul/li/text()",
  3849. tfoot, null, 7, null
  3850. );
  3851. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3852. var node = mouchesParType.snapshotItem(i);
  3853. var mots = node.nodeValue.split(' ');
  3854. var type = mots.pop();
  3855. if(!listeTypes[type]) {
  3856. node.nodeValue += ' (0 présente)';
  3857. } else if(mots[0]!=listeTypes[type]) {
  3858. if(listeTypes[type]==1) {
  3859. node.nodeValue += ' (1 présente)';
  3860. } else {
  3861. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3862. }
  3863. }
  3864. }
  3865. }
  3866.  
  3867. function do_mouches() {
  3868. start_script();
  3869. initialiseMouches();
  3870. displayScriptTime();
  3871. }
  3872.  
  3873. /*********************************************************************************
  3874. * This file is part of Mountyzilla. *
  3875. * *
  3876. * Mountyzilla is free software; you can redistribute it and/or modify *
  3877. * it under the terms of the GNU General Public License as published by *
  3878. * the Free Software Foundation; either version 2 of the License, or *
  3879. * (at your option) any later version. *
  3880. * *
  3881. * Mountyzilla is distributed in the hope that it will be useful, *
  3882. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3883. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3884. * GNU General Public License for more details. *
  3885. * *
  3886. * You should have received a copy of the GNU General Public License *
  3887. * along with Mountyzilla; if not, write to the Free Software *
  3888. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3889. *********************************************************************************/
  3890.  
  3891. // x~x equipgowap
  3892.  
  3893. var popup;
  3894.  
  3895. function initPopupEquipgowap() {
  3896. popup = document.createElement('div');
  3897. popup.setAttribute('id', 'popup');
  3898. popup.setAttribute('class', 'mh_textbox');
  3899. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3900. 'display: inline; z-index: 3; max-width: 400px;');
  3901. document.body.appendChild(popup);
  3902. }
  3903.  
  3904. function showPopupEquipgowap(evt) {
  3905. var texte = this.getAttribute("texteinfo");
  3906. popup.innerHTML = texte;
  3907. popup.style.left = evt.pageX + 15 + 'px';
  3908. popup.style.top = evt.pageY + 'px';
  3909. popup.style.visibility = "visible";
  3910. }
  3911.  
  3912. function hidePopup() {
  3913. popup.style.visibility = "hidden";
  3914. }
  3915.  
  3916. function createPopupImage(url, text)
  3917. {
  3918. var img = document.createElement('img');
  3919. img.setAttribute('src',url);
  3920. img.setAttribute('align','ABSMIDDLE');
  3921. img.setAttribute("texteinfo",text);
  3922. img.addEventListener("mouseover", showPopupEquipgowap,true);
  3923. img.addEventListener("mouseout", hidePopup,true);
  3924. return img;
  3925. }
  3926.  
  3927. function formateTexte(texte)
  3928. {
  3929. texte = texte.replace(/\n/g,"<br/>");
  3930. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  3931. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  3932. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  3933. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  3934. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  3935. return texte;
  3936. }
  3937.  
  3938.  
  3939. function treateGowaps() {
  3940. //On récupère les gowaps possédants des composants
  3941. var tbodys = document.evaluate(
  3942. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  3943. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3944. for (var j = 0; j < tbodys.snapshotLength; j++) {
  3945. var tbody = tbodys.snapshotItem(j);
  3946. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  3947. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  3948. if(MY_getValue("NOINFOEM") != "true")
  3949. insertEMInfos(tbody);
  3950. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3951. insertEnchantInfos(tbody);
  3952. }
  3953. }
  3954.  
  3955. function treateChampi() {
  3956. if(MY_getValue("NOINFOEM") == "true")
  3957. return false;
  3958. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  3959. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3960. if (nodes.snapshotLength == 0)
  3961. return false;
  3962.  
  3963. for (var i = 0; i < nodes.snapshotLength; i++) {
  3964. var node = nodes.snapshotItem(i);
  3965. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  3966. if(texte.indexOf("*")!=-1)
  3967. texte = texte.substring(0,texte.lastIndexOf(" "));
  3968. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  3969. if(moisChampi[nomChampi])
  3970. {
  3971. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  3972. }
  3973. }
  3974. }
  3975.  
  3976. function do_equipgowap() {
  3977. start_script();
  3978.  
  3979. treateGowaps();
  3980. treateChampi();
  3981. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  3982. {
  3983. initPopupEquipgowap();
  3984. computeEnchantementEquipement(createPopupImage,formateTexte);
  3985. }
  3986.  
  3987. displayScriptTime();
  3988. }
  3989.  
  3990. /*********************************************************************************
  3991. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  3992. *********************************************************************************/
  3993.  
  3994. // x~x ordresgowap
  3995.  
  3996. // version Roule' janvier 2017
  3997. function setCarteUnGogoHTML5() {
  3998. // fabriquer la liste des positions successives
  3999. var listeDepl = []; // ce sera un tableau d'objets
  4000. // position courrante
  4001. var eTitle = document.getElementById('titre2');
  4002. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4003. listeDepl.push({x: parseInt(tabPos[0]), y: parseInt(tabPos[1]), n: parseInt(tabPos[2])}); // ParseInt obligatoire, javascript language de m*rd*
  4004. // déplacements
  4005. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4006. for(var i=0 ; i<lignes.length ; i++) {
  4007. if(lignes[i].className == 'mh_tdpage_fo') {
  4008. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4009. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4010. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4011. }
  4012. }
  4013. // générer la carte
  4014. var carte = new carte_MZ('cartegogo', [listeDepl]); // Le 2e arg est un tableau de tableaux d'objets
  4015. // positionner la carte
  4016. var footer = document.getElementById('footer1');
  4017. var eCarte = carte.getElt();
  4018. eCarte.style.textAlign = 'left';
  4019. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4020. else document.body.appendChild(eCarte);
  4021. }
  4022.  
  4023. /* v0.2 by Dab - 2013-08-31
  4024. * - correction acquisition posale initiale
  4025. * - correction tare et affichage mire
  4026. */
  4027.  
  4028. function setCarteGogo() {
  4029. try {
  4030. //var pars = document.getElementsByTagName('p');
  4031. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4032. var eTitle = document.getElementById('titre2');
  4033. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4034. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4035. var serv_img_cible = URL_MZimg + "rep.png";
  4036.  
  4037. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4038. //var lignes = pars[0].getElementsByTagName('tr');
  4039. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4040. var nbpt = 0;
  4041. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4042. for(var i=0 ; i<lignes.length ; i++) {
  4043. if(lignes[i].className == 'mh_tdpage_fo') {
  4044. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4045. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4046. if(point) {
  4047. nbpt++;
  4048. trajet += point[1]+','+point[2]+','+point[3]+',';
  4049. }
  4050. }
  4051. }
  4052. }
  4053. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4054. 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'/>";
  4055. var base = [-229,-5];
  4056. if (nbpt>0) {
  4057. base = [-684,-5];
  4058. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4059. }
  4060. 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;'/>";
  4061.  
  4062. 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>';
  4063.  
  4064. var nvspan = document.createElement('div');
  4065. nvspan.align = 'center';
  4066. nvspan.id = 'mz_mapdiv';
  4067. nvspan.valign = 'top';
  4068. nvspan.innerHTML = nvdiv;
  4069. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4070. var footer = document.getElementById('footer1');
  4071. footer.parentNode.insertBefore(nvspan,footer);
  4072. }
  4073.  
  4074. function testeGlissiere() {
  4075. try {
  4076. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4077. var footer = document.getElementById('footer1');
  4078. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4079. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4080. }
  4081.  
  4082. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4083. if (x0 !== undefined) {
  4084. // ouais, récursif une fois
  4085. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4086. if (PtInterm === undefined)
  4087. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4088. else
  4089. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4090. return;
  4091. }
  4092. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4093. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4094. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4095. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4096. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4097. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4098. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4099. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4100. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4101. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4102. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4103. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4104. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4105. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4106. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4107. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4108. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4109. }
  4110.  
  4111. function do_ordresgowap() {
  4112. if (isDEV) {
  4113. setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4114. //testeGlissiere();
  4115. //MZ_testsUnitairesCalculIntermediaire();
  4116. } else {
  4117. }
  4118. setCarteGogo(); // Via script des trouillots
  4119. }
  4120.  
  4121. /*********************************************************************************
  4122. * This file is part of Mountyzilla. *
  4123. * *
  4124. * Mountyzilla is free software; you can redistribute it and/or modify *
  4125. * it under the terms of the GNU General Public License as published by *
  4126. * the Free Software Foundation; either version 2 of the License, or *
  4127. * (at your option) any later version. *
  4128. * *
  4129. * Mountyzilla is distributed in the hope that it will be useful, *
  4130. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4131. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4132. * GNU General Public License for more details. *
  4133. * *
  4134. * You should have received a copy of the GNU General Public License *
  4135. * along with Mountyzilla; if not, write to the Free Software *
  4136. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4137. *********************************************************************************/
  4138.  
  4139. // x~x attaque
  4140.  
  4141. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4142.  
  4143. function do_attaque() {
  4144. }
  4145.  
  4146. /*******************************************************************************
  4147. * This file is part of Mountyzilla. *
  4148. * *
  4149. * Mountyzilla is free software; you can redistribute it and/or modify *
  4150. * it under the terms of the GNU General Public License as published by *
  4151. * the Free Software Foundation; either version 2 of the License, or *
  4152. * (at your option) any later version. *
  4153. * *
  4154. * Mountyzilla is distributed in the hope that it will be useful, *
  4155. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4156. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4157. * GNU General Public License for more details. *
  4158. * *
  4159. * You should have received a copy of the GNU General Public License *
  4160. * along with Mountyzilla; if not, write to the Free Software *
  4161. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4162. *******************************************************************************/
  4163.  
  4164. // x~x infomonstre
  4165.  
  4166. // DEBUG
  4167. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4168. // À corriger, évidemment.
  4169. var listeCDM = {};
  4170. var nomMonstre='';
  4171. var idMonstre=-1;
  4172. var tbody;
  4173. var popup;
  4174.  
  4175. function traiteMonstre() {
  4176. try {
  4177. var nodeTitre = document.evaluate(
  4178. "//div[@class='titre2' and contains(text(),'(')]",
  4179. document, null, 9, null
  4180. ).singleNodeValue;
  4181. var texte = nodeTitre.firstChild.nodeValue;
  4182. } catch(e) {
  4183. window.console.log(traceStack(e, 'traiteMonstre'));
  4184. return;
  4185. }
  4186. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4187. if(nomMonstre.indexOf(']')!=-1) {
  4188. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4189. }
  4190. idMonstre = texte.match(/\d+/)[0];
  4191. FF_XMLHttpRequest({
  4192. method: 'GET',
  4193. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4194. +MY_getValue('CDMID')
  4195. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4196. headers : {
  4197. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4198. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4199. },
  4200. onload: function(responseDetails) {
  4201. try {
  4202. var texte = responseDetails.responseText;
  4203. var lines = texte.split("\n");
  4204. if(lines.length>=1) {
  4205. var infos = lines[0].split(";");
  4206. if(infos.length<4) { return; }
  4207. var idMonstre = infos[0];
  4208. infos=infos.slice(3);
  4209. listeCDM[idMonstre]=infos;
  4210. computeMissionInfomonstre();
  4211. }
  4212. } catch(e) {
  4213. window.alert(e);
  4214. }
  4215. }
  4216. });
  4217. }
  4218.  
  4219. function initPopupInfomonstre() {
  4220. // Initialise le popup tactique (calculs att/deg)
  4221. popup = document.createElement('div');
  4222. popup.id = 'popup';
  4223. popup.className = 'mh_textbox';
  4224. popup.style =
  4225. 'position: absolute;'+
  4226. 'border: 1px solid #000000;'+
  4227. 'visibility: hidden;'+
  4228. 'display: inline;'+
  4229. 'z-index: 3;'+
  4230. 'max-width: 400px;';
  4231. document.body.appendChild(popup);
  4232. }
  4233.  
  4234. function showPopupTactique(evt) {
  4235. try {
  4236. var id = this.id;
  4237. var nom = this.nom;
  4238. var texte = getAnalyseTactique(id,nom);
  4239. if(texte=='') { return; }
  4240. popup.innerHTML = texte;
  4241. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4242. if(isPage("View/MonsterView")) {
  4243. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4244. } else {
  4245. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4246. }
  4247. popup.style.top = evt.pageY+15+'px';
  4248. popup.style.visibility = 'visible';
  4249. } catch(e) {
  4250. window.alert(e);
  4251. }
  4252. }
  4253.  
  4254. // roule 16/03/2016, existe déjà ailleurs
  4255. // function hidePopup() {
  4256. // popup.style.visibility = 'hidden';
  4257. // }
  4258.  
  4259. function toggleTableau() {
  4260. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4261. }
  4262.  
  4263. function computeMissionInfomonstre() {
  4264. // C'est quoi ce titre de fonction ? (O_o)
  4265. try {
  4266. var nodeInsert = document.evaluate(
  4267. "//div[@class = 'titre3']",
  4268. document, null, 9, null
  4269. ).singleNodeValue;
  4270. } catch(e) {
  4271. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4272. return;
  4273. }
  4274. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4275. table.align = 'center';
  4276. tbody = table.childNodes[1];
  4277. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4278. table.firstChild.firstChild.onmouseover = function() {
  4279. this.style.cursor = 'pointer';
  4280. this.className = 'mh_tdpage';
  4281. };
  4282. table.firstChild.firstChild.onmouseout = function() {
  4283. this.className = 'mh_tdtitre';
  4284. };
  4285. tbody.style.display = 'none';
  4286. table.style.width = '350px';
  4287. insertBefore(nodeInsert,table);
  4288. }
  4289.  
  4290. function do_infomonstre() {
  4291. start_script();
  4292. try {
  4293. initPopupInfomonstre();
  4294. traiteMonstre();
  4295. } catch(e) {
  4296. window.alert('Erreur infoMonstre:\n'+e);
  4297. }
  4298. displayScriptTime();
  4299. }
  4300.  
  4301. /*******************************************************************************
  4302. * This file is part of Mountyzilla. *
  4303. * *
  4304. * Mountyzilla is free software; you can redistribute it and/or modify *
  4305. * it under the terms of the GNU General Public License as published by *
  4306. * the Free Software Foundation; either version 2 of the License, or *
  4307. * (at your option) any later version. *
  4308. * *
  4309. * Mountyzilla is distributed in the hope that it will be useful, *
  4310. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4311. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4312. * GNU General Public License for more details. *
  4313. * *
  4314. * You should have received a copy of the GNU General Public License *
  4315. * along with Mountyzilla; if not, write to the Free Software *
  4316. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4317. *******************************************************************************/
  4318.  
  4319. // x~x mission
  4320.  
  4321. /* TODO
  4322. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4323. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4324. *
  4325. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4326. */
  4327.  
  4328. function saveMission(num,obEtape) {
  4329. var obMissions = {};
  4330. if(MY_getValue(numTroll+'.MISSIONS')) {
  4331. try {
  4332. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4333. } catch(e) {
  4334. window.console.error(traceStack(e, 'Mission parsage'));
  4335. return;
  4336. }
  4337. }
  4338. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4339. if(obEtape) {
  4340. obMissions[num] = obEtape;
  4341. } else if(obMissions[num]) {
  4342. delete obMissions[num];
  4343. }
  4344. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4345. }
  4346.  
  4347. function addtroogle(tdLibelle, sRestrict) {
  4348. var img = document.createElement('img');
  4349. img.src = URL_MZimg + 'troogle.ico';
  4350. img.alt = 'Troogle logo';
  4351. var a = document.createElement('a');
  4352. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4353. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4354. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4355. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4356. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4357. a.href = url;
  4358. a.title = 'Chercher sur Troogle';
  4359. a.target = 'troogle';
  4360. a.appendChild(img);
  4361. tdLibelle.appendChild(a);
  4362. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4363. }
  4364.  
  4365. function traiteMission() {
  4366. try {
  4367. var titreMission = document.getElementsByClassName('titre2')[0];
  4368. var numMission = titreMission.textContent.match(/\d+/)[0];
  4369. var missionForm = document.getElementsByName('ActionForm')[0];
  4370. var tdLibelle = document.evaluate(
  4371. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4372. missionForm, null, 9, null).singleNodeValue;
  4373. } catch(e) {
  4374. window.console.error(traceStack(e, 'récupération mission'));
  4375. return;
  4376. }
  4377. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4378. try {
  4379. if(!tdLibelle) {
  4380. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4381. debugMZ('traiteMission, la mission semble terminée');
  4382. saveMission(numMission,false);
  4383. return;
  4384. }
  4385.  
  4386. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4387. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4388. // debug Roule'
  4389. if (MY_DEBUG) {
  4390. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4391. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4392. }
  4393. if(libelle.indexOf('niveau égal à')!=-1) {
  4394. var nbKills = 1, niveau, mod;
  4395. // exemples :
  4396. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4397. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4398. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4399. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4400. if (tdLibelle.childNodes.length == 1) {
  4401. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4402. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4403. if (m) {
  4404. niveau = Number(m[1]);
  4405. mod = 'plus'
  4406. } else {
  4407. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4408. if (m) {
  4409. niveau = Number(m[1]);
  4410. mod = Number(m[2]);
  4411. } else {
  4412. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4413. return;
  4414. }
  4415. }
  4416. } else {
  4417. // ancienne méthode (multi childnode)
  4418. // à supprimer un jour peut-être
  4419. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4420. // Étape de kill multiple de niveau donné
  4421. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4422. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4423. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4424. niveau = Number(mod[0]);
  4425. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4426. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4427. } else {
  4428. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4429. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4430. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4431. mod = mod ? Number(mod[0]) : 'plus';
  4432. }
  4433. } else {
  4434. // Étape de kill unique de niveau donné
  4435. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4436. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4437. mod = mod ? Number(mod[0]) : 'plus';
  4438. }
  4439. }
  4440. // debug Roule'
  4441. if (MY_DEBUG) {
  4442. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4443. }
  4444. saveMission(numMission,{
  4445. type: 'Niveau',
  4446. niveau: niveau,
  4447. mod: mod,
  4448. mundidey: siMundidey,
  4449. libelle: libelle
  4450. });
  4451. if (mod == 'plus')
  4452. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4453. else
  4454. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4455. } else if(libelle.indexOf('de la race')!=-1) {
  4456. var nbKills = 1, race;
  4457. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4458. // Étape de kill multiple de race donnée
  4459. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4460. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4461. } else {
  4462. // Étape de kill unique de race donnée
  4463. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4464. }
  4465. race = race.replace(/\"/g,'');
  4466. saveMission(numMission,{
  4467. type: 'Race',
  4468. race: race,
  4469. mundidey: siMundidey,
  4470. libelle: libelle
  4471. });
  4472. addtroogle(tdLibelle, '@monstre ' + race);
  4473. } else if(libelle.indexOf('de la famille')!=-1) {
  4474. var nbKills = 1, famille;
  4475. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4476. // Étape de kill multiple de famille donnée
  4477. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4478. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4479. } else {
  4480. // Étape de kill unique de famille donnée
  4481. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4482. }
  4483. famille = famille.replace(/\"/g,'');
  4484. saveMission(numMission,{
  4485. type: 'Famille',
  4486. famille: famille,
  4487. mundidey: siMundidey,
  4488. libelle: libelle
  4489. });
  4490. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4491. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4492. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4493. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4494. debugMZ('traiteMission étape capacité spéciale');
  4495. saveMission(numMission,{
  4496. type: 'Pouvoir',
  4497. pouvoir: pouvoir,
  4498. libelle: libelle
  4499. });
  4500. } else {
  4501. debugMZ('traiteMission étape pas pour troogle');
  4502. saveMission(numMission,false);
  4503. }
  4504. } catch(e) {
  4505. window.console.error(traceStack(e, 'récupération étape mission'));
  4506. return;
  4507. }
  4508. }
  4509.  
  4510. function do_mission() {
  4511. start_script(60);
  4512.  
  4513. traiteMission();
  4514.  
  4515. displayScriptTime();
  4516. }
  4517.  
  4518. /*******************************************************************************
  4519. * This file is part of Mountyzilla. *
  4520. * *
  4521. * Mountyzilla is free software; you can redistribute it and/or modify *
  4522. * it under the terms of the GNU General Public License as published by *
  4523. * the Free Software Foundation; either version 2 of the License, or *
  4524. * (at your option) any later version. *
  4525. * *
  4526. * Mountyzilla is distributed in the hope that it will be useful, *
  4527. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4528. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4529. * GNU General Public License for more details. *
  4530. * *
  4531. * You should have received a copy of the GNU General Public License *
  4532. * along with Mountyzilla; if not, write to the Free Software *
  4533. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4534. *******************************************************************************/
  4535.  
  4536. // x~x move
  4537.  
  4538. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4539.  
  4540. var petitsTrous = {
  4541. '-52;57': true,
  4542. '55;70': true,
  4543. '64;70': true,
  4544. '12;-15': true,
  4545. '30;-52': true,
  4546. '48;-39': true
  4547. };
  4548.  
  4549. var grosTrous = {
  4550. '-35;65': true,
  4551. '-13;73': true,
  4552. '-64;9': true,
  4553. '-35;15': true,
  4554. '5;32': true,
  4555. '10;64': true,
  4556. '21;36': true,
  4557. '46;52': true,
  4558. '74;32': true,
  4559. '-71;-7': true,
  4560. '-67;-37': true,
  4561. '-60;-32': true,
  4562. '-51;-22': true,
  4563. '-36;-51': true,
  4564. '5;-49': true
  4565. };
  4566.  
  4567. var centreCarmine_X = 56.5;
  4568. var centreCarmine_Y = 23.5;
  4569. var rayonCarmine = 8.7;
  4570.  
  4571. function isTrou(x,y,n) {
  4572. if(petitsTrous[x+';'+y]) {
  4573. return n<0 && n>-60;
  4574. }
  4575. if(grosTrous[x+';'+y]
  4576. || grosTrous[x-1+';'+y]
  4577. || grosTrous[x+';'+y+1]
  4578. || grosTrous[x-1+';'+y+1]) {
  4579. return n<0 && n>-70;
  4580. }
  4581. if(Math.sqrt(
  4582. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4583. )<=rayonCarmine) {
  4584. return n<0 && n>-100;
  4585. }
  4586. return false;
  4587. }
  4588.  
  4589. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4590.  
  4591. function validateDestination() {
  4592. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4593. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4594. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4595. var form = document.getElementsByName('ActionForm')[0];
  4596. if(form) {
  4597. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4598. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4599. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4600. }
  4601. }
  4602. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4603. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4604. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4605. }
  4606. }
  4607. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4608. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4609. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4610. }
  4611. }
  4612. if(isTrou(x,y,n)) {
  4613. return window.confirm(
  4614. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4615. +'Vous allez tomber dans un trou de météorite.\n'
  4616. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4617. );
  4618. }
  4619. }
  4620. return true;
  4621. }
  4622.  
  4623. function newsubmitDE(event) {
  4624. event.stopPropagation();
  4625. event.preventDefault();
  4626. if(validateDestination()) {
  4627. this.submit();
  4628. }
  4629. }
  4630.  
  4631. function changeValidation() {
  4632. var form = document.getElementsByName('ActionForm')[0];
  4633. if(form) {
  4634. form.addEventListener('submit', newsubmitDE, true);
  4635. }
  4636. }
  4637.  
  4638.  
  4639. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4640.  
  4641. function validateTPDestination() {
  4642. try {
  4643. var text = document.getElementsByTagName('B')[0];
  4644. var a = text.firstChild.nodeValue.split('|');
  4645. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4646. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4647. var pos_n = a[2].substring(5, a[2].length) * 1;
  4648.  
  4649. var nbtrous = 0;
  4650. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4651. for(var x=0 ; x<=2 ; x++) {
  4652. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4653. for(var y=0 ; y<=2 ; y++) {
  4654. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4655. for(var n = 0 ; n <= 1 ; n++) {
  4656. if(isTrou(
  4657. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4658. )) {
  4659. nbtrous++;
  4660. }
  4661. }
  4662. }
  4663. }
  4664. }
  4665. }
  4666. }
  4667. if(nbtrous>0 && nbtrous<72) {
  4668. return window.confirm(
  4669. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4670. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4671. +'% de risque de tomber dans un trou de météorite.\n'
  4672. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4673. );
  4674. }
  4675. else if(nbtrous>=72) {
  4676. return window.confirm(
  4677. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4678. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4679. +'% de risque de tomber dans un trou de météorite !\n'
  4680. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4681. );
  4682. }
  4683. return true;
  4684. }
  4685. catch(e) {
  4686. window.alert(e)
  4687. }
  4688. }
  4689.  
  4690. function newsubmitTP(event) {
  4691. event.stopPropagation();
  4692. event.preventDefault();
  4693. if(validateTPDestination()) {
  4694. this.submit();
  4695. }
  4696. }
  4697.  
  4698. function changeButtonValidate() {
  4699. var form = document.getElementsByName('Formulaire')[0];
  4700. if(form) {
  4701. if(!form.getAttribute('onsubmit')) {
  4702. form.setAttribute('onsubmit','return true;');
  4703. }
  4704. form.addEventListener('submit', newsubmitTP, true);
  4705. }
  4706. }
  4707.  
  4708.  
  4709. /*-[functions]---------------- Partie Principale -----------------------------*/
  4710.  
  4711. function do_move() {
  4712. if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4713. changeValidation();
  4714. }
  4715. else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4716. changeButtonValidate();
  4717. }
  4718. }
  4719.  
  4720. /*******************************************************************************
  4721. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4722. * Mountyzilla is free software; provided under the GNU General Public License *
  4723. *******************************************************************************/
  4724.  
  4725. // x~x news
  4726.  
  4727. // Nombre de news à afficher & nb max de caractères par news:
  4728. const nbItems = 5;
  4729. const maxCarDescription = 300;
  4730.  
  4731. /*-[functions]------------------- Utilitaires --------------------------------*/
  4732.  
  4733. // Ne semble avoir strictement aucun effet:
  4734. String.prototype.epureDescription = function() {
  4735. return this.replace(/\\(.)/g,"$1");
  4736. }
  4737.  
  4738. function appendTitledTable(node,titre,description) {
  4739. // Crée les tables contenant les infos (avec titre)
  4740. var table = document.createElement('table');
  4741. table.border = 0;
  4742. table.className = 'mh_tdborder';
  4743. table.cellSpacing = 1;
  4744. table.cellPadding = 1;
  4745. table.style.maxWidth = '98%';
  4746. table.style.marginLeft = 'auto';
  4747. table.style.marginRight = 'auto';
  4748. var tbody = document.createElement('tbody');
  4749. table.appendChild(tbody);
  4750. var tr = appendTr(tbody,'mh_tdtitre');
  4751. var td = appendTdCenter(tr,2);
  4752. var span = document.createElement('span');
  4753. appendText(span,titre,true);
  4754. if(description) {
  4755. span.title = description;
  4756. }
  4757. td.appendChild(span);
  4758. node.appendChild(table);
  4759. return tbody;
  4760. }
  4761.  
  4762. function testCertif(paramURL, callbackOnError) {
  4763. try {
  4764. FF_XMLHttpRequest({
  4765. method: 'GET',
  4766. url: paramURL,
  4767. onload: function(responseDetails) {
  4768. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4769. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4770. }
  4771. });
  4772. } catch(e) {
  4773. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4774. callbackOnError();
  4775. }
  4776. }
  4777.  
  4778. function createOrGetGrandCadre() {
  4779. var grandCadre = document.getElementById('grandCadre');
  4780. if (grandCadre) return grandCadre;
  4781. try {
  4782. var rappels = document.evaluate(
  4783. "//p[contains(a/text(),'messagerie')]",
  4784. document, null, 9, null).singleNodeValue;
  4785. }
  4786. catch(e) {
  4787. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4788. grandCadre = document.createElement('div');
  4789. return grandCadre;
  4790. }
  4791. grandCadre = document.createElement('div');
  4792. grandCadre.id = 'grandCadre';
  4793. var sousCadre = document.createElement('div');
  4794. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4795. sousCadre.style.textAlign = 'center';
  4796. sousCadre.style.fontSize = 'xx-large';
  4797. grandCadre.appendChild(sousCadre);
  4798.  
  4799. grandCadre.style.border = 'solid 5px red';
  4800. grandCadre.style.width = 'auto';
  4801. insertBefore(rappels,grandCadre);
  4802. return grandCadre;
  4803. }
  4804.  
  4805. function showHttpsErrorCadre1() {
  4806. var grandCadre = createOrGetGrandCadre();
  4807. var sousCadre = document.createElement('div');
  4808. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4809. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4810. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4811. + URL_CertifRaistlin1
  4812. + '" target="raistlin">clique ici</a>'
  4813. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4814. + ' « Confirmer l\'exception de sécurité »'
  4815. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4816. sousCadre.style.width = 'auto';
  4817. sousCadre.style.fontSize = 'large';
  4818. sousCadre.style.border = 'solid 1px black';
  4819. sousCadre.style.backgroundColor = 'red';
  4820. grandCadre.appendChild(sousCadre);
  4821. }
  4822.  
  4823. function showHttpsErrorCadre2() {
  4824. var grandCadre = createOrGetGrandCadre();
  4825. var sousCadre = document.createElement('div');
  4826. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  4827. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  4828. + '<a style="color:blue;font-size: inherits;" href="'
  4829. + URL_CertifRaistlin2
  4830. + '" target="raistlin">clique ici</a>'
  4831. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4832. + ' « Confirmer l\'exception de sécurité »'
  4833. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  4834. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4835. sousCadre.style.width = 'auto';
  4836. sousCadre.style.fontSize = 'large';
  4837. sousCadre.style.border = 'solid 1px black';
  4838. sousCadre.style.backgroundColor = 'red';
  4839. grandCadre.appendChild(sousCadre);
  4840. }
  4841.  
  4842. function showHttpsErrorContenuMixte() {
  4843. var grandCadre = createOrGetGrandCadre();
  4844. var sousCadre = document.createElement('div');
  4845. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  4846. + '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)'
  4847. + '<ul>'
  4848. + '<li>Interface Bricol\'Troll</li>'
  4849. + '<li>Nouveautés de Mountyzilla</li>'
  4850. + '</ul>'
  4851. + '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 />'
  4852. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  4853. sousCadre.style.width = 'auto';
  4854. sousCadre.style.fontSize = 'large';
  4855. sousCadre.style.border = 'solid 1px black';
  4856. grandCadre.appendChild(sousCadre);
  4857. }
  4858.  
  4859. /*-[functions]------------------- Jubilaires ---------------------------------*/
  4860.  
  4861. function traiterJubilaires() {
  4862. // à faire
  4863. }
  4864.  
  4865. function traiterJubilaires_a_supprimer() { // ancienne méthode
  4866. try {
  4867. FF_XMLHttpRequest({
  4868. method: 'GET',
  4869. url: URL_anniv,
  4870. headers: {
  4871. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  4872. 'Accept': 'application/xml,text/xml',
  4873. },
  4874. onload: function(responseDetails) {
  4875. if ((responseDetails.status == 0) && isHTTPS) {
  4876. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  4877. showHttpsErrorContenuMixte();
  4878. return;
  4879. }
  4880. var listeTrolls = responseDetails.responseText.split('\n');
  4881. if(!listeTrolls || listeTrolls.length==0) {
  4882. return;
  4883. }
  4884. afficherJubilaires(listeTrolls);
  4885. },
  4886. });
  4887. }
  4888. catch(e) {
  4889. if (isHTTPS) {
  4890. window.console.log(traceStack(e, 'appel jubilaires'));
  4891. showHttpsErrorContenuMixte();
  4892. } else {
  4893. window.alert('Erreur Jubilaires:\n'+e);
  4894. }
  4895. }
  4896. }
  4897.  
  4898. function afficherJubilaires(listeTrolls) {
  4899. try {
  4900. var rappels = document.evaluate(
  4901. "//p[contains(a/text(),'messagerie')]",
  4902. document, null, 9, null).singleNodeValue;
  4903. }
  4904. catch(e) {
  4905. return;
  4906. }
  4907. var p = document.createElement('p');
  4908. var tbody = appendTitledTable(p,
  4909. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  4910. 'Envoyez leur un message ou un cadeau !'
  4911. );
  4912. tr = appendTr(tbody,'mh_tdpage');
  4913. td = appendTdCenter(tr);
  4914. var small = document.createElement('small');
  4915. td.appendChild(small);
  4916. var first = true;
  4917. for(var i=0 ; i<listeTrolls.length ; i++) {
  4918. var infos = listeTrolls[i].split(';');
  4919. if(infos.length!=3 || infos[2]==='0') {
  4920. continue;
  4921. }
  4922. if(first) {
  4923. first = false;
  4924. }
  4925. else {
  4926. appendText(small,', ');
  4927. }
  4928. var a = document.createElement('a');
  4929. a.href = 'javascript:EPV('+infos[0]+')';
  4930. appendText(a,infos[1]);
  4931. small.appendChild(a);
  4932. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  4933. }
  4934. insertBefore(rappels,p);
  4935. }
  4936.  
  4937.  
  4938. /*-[functions]--------------------- News MZ ----------------------------------*/
  4939.  
  4940. function traiterNouvelles() {
  4941. var news = new Array;
  4942. 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 ;).']);
  4943. news.push(['24/12/2016', 'Retour de la carte montrant les déplacements des Gowaps']);
  4944. news.push(['24/12/2016', 'Le lien avec Bricol\'Troll est maintenant disponible en https']);
  4945. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  4946. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  4947. news.push(['10/01/2017', '<span style="color:red">Il n\'est plus nécessaire de bloquer les mises à jour de Firefox</span>. MZ devrait fonctionner sur toutes les versions&nbsp;: anciennes, récentes, béta']);
  4948. afficherNouvelles(news);
  4949. }
  4950.  
  4951. function afficherNouvelles(items) {
  4952. var footer = document.getElementById('footer1');
  4953. if(!footer) {
  4954. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  4955. return;
  4956. }
  4957. var p = document.createElement('p');
  4958. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  4959. var div = document.createElement('div');
  4960. div.style.position = 'absolute';
  4961. div.style.right = 0;
  4962. div.style.top = 0;
  4963. div.style.paddingRight = '3px';
  4964. div.style.whiteSpace = 'nowrap';
  4965. appendText(div, '(version ' + GM_info.script.version + ')');
  4966. tbody.rows[0].cells[0].style.position = 'relative';
  4967. tbody.rows[0].cells[0].appendChild(div);
  4968. for(var i=0 ; i<items.length ; i++) {
  4969. var tr = appendTr(tbody,'mh_tdpage');
  4970. var td = appendTdCenter(tr);
  4971. td.style.verticalAlign = 'top'; // semble sans effet
  4972. appendText(td,items[i][0],true);
  4973. td = appendTd(tr);
  4974. td.innerHTML = items[i][1];
  4975. }
  4976. insertBefore(footer,p);
  4977. }
  4978.  
  4979.  
  4980. /*---------------------------------- Main ------------------------------------*/
  4981.  
  4982. function do_news() {
  4983. start_script();
  4984.  
  4985. traiterJubilaires();
  4986. traiterNouvelles();
  4987.  
  4988. if (isHTTPS) {
  4989. // test si les certificats raistlin ont été acceptés
  4990. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  4991. var infoit = MY_getValue(numTroll+'.INFOSIT');
  4992. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  4993. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  4994. }
  4995. }
  4996.  
  4997. displayScriptTime();
  4998. }
  4999.  
  5000. /*********************************************************************************
  5001. * This file is part of Mountyzilla. *
  5002. * *
  5003. * Mountyzilla is free software; you can redistribute it and/or modify *
  5004. * it under the terms of the GNU General Public License as published by *
  5005. * the Free Software Foundation; either version 2 of the License, or *
  5006. * (at your option) any later version. *
  5007. * *
  5008. * Mountyzilla is distributed in the hope that it will be useful, *
  5009. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5010. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5011. * GNU General Public License for more details. *
  5012. * *
  5013. * You should have received a copy of the GNU General Public License *
  5014. * along with Mountyzilla; if not, write to the Free Software *
  5015. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5016. *********************************************************************************/
  5017.  
  5018. // x~x tabcompo
  5019.  
  5020. var popup;
  5021.  
  5022. function initPopupTabcompo() {
  5023. popup = document.createElement('div');
  5024. popup.setAttribute('id', 'popup');
  5025. popup.setAttribute('class', 'mh_textbox');
  5026. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5027. + 'display: inline; z-index: 3; max-width: 400px;');
  5028. document.body.appendChild(popup);
  5029. }
  5030.  
  5031. function showPopup(evt) {
  5032. var texte = this.getAttribute("texteinfo");
  5033. popup.innerHTML = texte;
  5034. popup.style.left = evt.pageX + 15 + 'px';
  5035. popup.style.top = evt.pageY + 'px';
  5036. popup.style.visibility = "visible";
  5037. }
  5038.  
  5039. // roule 16/03/2016, existe déjà ailleurs
  5040. // function hidePopup() {
  5041. // popup.style.visibility = 'hidden';
  5042. // }
  5043.  
  5044. function createPopupImage(url, text)
  5045. {
  5046. var img = document.createElement('img');
  5047. img.setAttribute('src',url);
  5048. img.setAttribute('align','ABSMIDDLE');
  5049. img.setAttribute("texteinfo",text);
  5050. img.addEventListener("mouseover", showPopup,true);
  5051. img.addEventListener("mouseout", hidePopup,true);
  5052. return img;
  5053. }
  5054.  
  5055. function formateTexte(texte)
  5056. {
  5057. texte = texte.replace(/\n/g,"<br/>");
  5058. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5059. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5060. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5061. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5062. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5063. return texte;
  5064. }
  5065.  
  5066. function arrondi(x) {
  5067. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5068. }
  5069.  
  5070. function traiteMinerai() {
  5071. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5072. try {
  5073. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5074. +" and contains(./tr/th/text(),'Minerai')]",
  5075. document, null, 9, null).singleNodeValue;
  5076. node = node.nextSibling.nextSibling;
  5077. }
  5078. catch(e) {return;}
  5079. var trlist = document.evaluate('./tr', node, null, 7, null);
  5080. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5081. var node = trlist.snapshotItem(i);
  5082. var nature = node.childNodes[5].textContent;
  5083. var caracs = node.childNodes[7].textContent;
  5084. var taille = caracs.match(/\d+/)[0];
  5085. var coef = 1;
  5086. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5087. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5088. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5089. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5090. if (nature.indexOf('Mithril')!=-1) {
  5091. coef = 0.2*coef;
  5092. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5093. }
  5094. else {
  5095. coef = 0.75*coef+1.25;
  5096. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5097. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5098. }
  5099. }
  5100. }
  5101.  
  5102. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5103. function treateComposants() {
  5104. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5105. //On récupère les composants
  5106. var nodes = document.evaluate(
  5107. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5108. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5109. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5110. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5111. if (nodes.snapshotLength == 0) {
  5112. //window.console.log('[MZ] treateComposants DOWN');
  5113. return;
  5114. }
  5115. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5116.  
  5117. var texte = "";
  5118. for (var i = 0; i < nodes.snapshotLength; i++) {
  5119. var n1 = nodes.snapshotItem(i).childNodes[1];
  5120. var n3 = nodes.snapshotItem(i).childNodes[3];
  5121. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5122. var prix = n3.childNodes[0].nodeValue;
  5123. if (!prix)
  5124. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5125. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5126. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5127. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5128. + prix.replace(/\n/g, '') + "\n";
  5129. }
  5130.  
  5131. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5132. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5133. var id_taniere = c.snapshotItem(0).nodeValue;
  5134. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5135.  
  5136. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5137. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5138. if (form)
  5139. {
  5140. if(document.getElementsByTagName('form').length>0)
  5141. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5142. else
  5143. {
  5144. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5145. insertBefore(thisP, form);
  5146. }
  5147. }
  5148. }
  5149.  
  5150. function treateAllComposants() {
  5151. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5152. //On récupère les composants
  5153. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5154. document, null, 0, null ).numberValue;
  5155. var c = (categ == 0 ? 3 : 4);
  5156. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5157. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5158. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5159. + "td["+c+"]/text()[1] = '\240-\240' "
  5160. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5161. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5162. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5163. + "and td[1]/img/@alt = 'Identifié']",
  5164. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5165. if (nodes.snapshotLength == 0) {
  5166. // window.alert('treateAllComposants DOWN');
  5167. return;
  5168. }
  5169.  
  5170. var texte = "";
  5171. for (var i = 0; i < nodes.snapshotLength; i++) {
  5172. var n1 = nodes.snapshotItem(i).childNodes[1];
  5173. var n3 = nodes.snapshotItem(i).childNodes[3];
  5174. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5175. var prix = n3.childNodes[0].nodeValue;
  5176. if (!prix)
  5177. {
  5178. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5179. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5180. }
  5181. else
  5182. {
  5183. prix= prix.replace(/[\240 ]/g, "");
  5184. if(prix=="-")
  5185. prix=null;
  5186. }
  5187. if(prix)
  5188. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5189. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5190. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5191. + prix.replace(/\n/g, '') + "\n";
  5192. else
  5193. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5194. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5195. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5196. }
  5197.  
  5198. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5199. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5200. var id_taniere = c.snapshotItem(0).nodeValue;
  5201. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5202.  
  5203. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5204. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5205. if (form)
  5206. {
  5207. if(document.getElementsByTagName('form').length>0)
  5208. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5209. else
  5210. {
  5211. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5212. insertBefore(thisP, form);
  5213. }
  5214. }
  5215. }
  5216.  
  5217. function treateEM()
  5218. {
  5219. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5220. if(currentURL.indexOf("as_type=Compo")==-1)
  5221. return false;
  5222. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5223. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5224. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5225. if (nodes.snapshotLength == 0)
  5226. return false;
  5227. for (var i = 0; i < nodes.snapshotLength; i++) {
  5228. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5229. var link = desc[2].firstChild ;
  5230. var nomCompoTotal = desc[2].textContent ;
  5231. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5232. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5233. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5234. var locqual = desc[3].textContent ;
  5235. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5236. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5237. if(isEM(nomMonstre).length>0)
  5238. {
  5239. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5240. if(infos.length>0)
  5241. {
  5242. var shortDescr = "Variable";
  5243. var bold = 0;
  5244. if(infos != "Composant variable")
  5245. {
  5246. shortDescr = infos.substring(0,infos.indexOf(" "));
  5247. if(parseInt(shortDescr)>=0)
  5248. bold=1;
  5249. }
  5250. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5251. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5252. }
  5253. }
  5254. }
  5255. }
  5256.  
  5257. function treateChampi() {
  5258. if (currentURL.indexOf('as_type=Champi')==-1)
  5259. return false;
  5260. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5261. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5262. if (nodes.snapshotLength == 0)
  5263. return false;
  5264.  
  5265. for (var i = 0; i < nodes.snapshotLength; i++) {
  5266. var node = nodes.snapshotItem(i);
  5267. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5268. if (moisChampi[nomChampi])
  5269. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5270. }
  5271. }
  5272.  
  5273. function treateEnchant()
  5274. {
  5275. if(currentURL.indexOf("as_type=Compo")==-1)
  5276. return false;
  5277. try
  5278. {
  5279. if(!listeMonstreEnchantement)
  5280. computeCompoEnchantement();
  5281. var nodes = document.evaluate(
  5282. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5283. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5284. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5285. if (nodes.snapshotLength == 0)
  5286. return false;
  5287. var urlImg = URL_MZimg + "enchant.png";
  5288. for (var i = 0; i < nodes.snapshotLength; i++) {
  5289. var link = nodes.snapshotItem(i);
  5290. var nomCompoTotal = link.firstChild.nodeValue;
  5291. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5292. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5293. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5294. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5295. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5296. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5297. if(isEnchant(nomMonstre).length>0)
  5298. {
  5299. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5300. if(infos.length>0)
  5301. {
  5302. link.parentNode.appendChild(createImage(urlImg,infos));
  5303. }
  5304. }
  5305. }
  5306. }
  5307. catch(e)
  5308. {
  5309. window.alert(e);
  5310. }
  5311. }
  5312.  
  5313. function treateEquipEnchant()
  5314. {
  5315. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5316. return false;
  5317. initPopupTabcompo();
  5318. computeEnchantementEquipement(createPopupImage,formateTexte);
  5319. }
  5320.  
  5321. function do_tancompo() {
  5322. start_script();
  5323.  
  5324. treateAllComposants();
  5325. treateComposants();
  5326. traiteMinerai();
  5327. if (MY_getValue('NOINFOEM')!='true') {
  5328. treateChampi();
  5329. treateEM();
  5330. }
  5331. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5332. treateEnchant();
  5333. treateEquipEnchant();
  5334. }
  5335.  
  5336. displayScriptTime();
  5337. }
  5338.  
  5339. /*******************************************************************************
  5340. * This file is part of Mountyzilla. *
  5341. * *
  5342. * Mountyzilla is free software; you can redistribute it and/or modify *
  5343. * it under the terms of the GNU General Public License as published by *
  5344. * the Free Software Foundation; either version 2 of the License, or *
  5345. * (at your option) any later version. *
  5346. * *
  5347. * Mountyzilla is distributed in the hope that it will be useful, *
  5348. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5349. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5350. * GNU General Public License for more details. *
  5351. * *
  5352. * You should have received a copy of the GNU General Public License *
  5353. * along with Mountyzilla; if not, write to the Free Software *
  5354. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5355. *******************************************************************************/
  5356.  
  5357. // x~x pjview
  5358.  
  5359. /* TODO
  5360. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5361. */
  5362.  
  5363. // Bulle d'infos
  5364. var DivInfo;
  5365. // Booléen stockant l'état de freezing de la bulle
  5366. var freezed = false;
  5367.  
  5368. // liste du matos
  5369. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5370. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5371. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5372. var mh_caracs = {
  5373. 'anneau de protection':
  5374. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5375. "armure d'anneaux":
  5376. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5377. 'armure de bois':
  5378. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5379. 'armure de cuir':
  5380. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5381. 'armure de peaux':
  5382. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5383. 'armure de pierre':
  5384. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5385. 'armure de plates':
  5386. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5387. 'baton lesté':
  5388. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5389. 'bâtons de parade':
  5390. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5391. 'bottes':
  5392. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5393. 'bouclier à pointes':
  5394. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5395. 'boulet et chaîne':
  5396. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5397. 'cagoule':
  5398. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5399. 'casque à cornes':
  5400. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5401. 'casque à pointes':
  5402. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5403. 'casque en cuir':
  5404. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5405. 'casque en métal':
  5406. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5407. 'chaîne cloutée':
  5408. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5409. 'chapeau pointu':
  5410. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5411. 'collier de dents':
  5412. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5413. 'collier de pierre':
  5414. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5415. 'collier à pointes':
  5416. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5417. 'cotte de mailles':
  5418. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5419. 'couronne de cristal':
  5420. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5421. "couronne d'obsidienne":
  5422. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5423. "coutelas d'obsidienne":
  5424. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5425. 'coutelas en os':
  5426. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5427. 'crochet':
  5428. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5429. 'cuir bouilli':
  5430. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5431. "cuirasse d'ossements":
  5432. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5433. "cuirasse d'écailles":
  5434. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5435. 'culotte en cuir':
  5436. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5437. 'dague':
  5438. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5439. 'epée courte':
  5440. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5441. 'epée longue':
  5442. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5443. 'espadon':
  5444. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5445. 'fouet':
  5446. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5447. 'fourrures':
  5448. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5449. 'gantelet':
  5450. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5451. 'gorgeron en cuir':
  5452. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5453. 'gorgeron en métal':
  5454. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5455. 'gourdin':
  5456. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5457. 'gourdin clouté':
  5458. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5459. 'grimoire':
  5460. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5461. "gros'porte":
  5462. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5463. 'grosse racine':
  5464. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5465. 'grosse stalagmite':
  5466. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5467. 'hache de bataille':
  5468. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5469. 'hache de guerre en os':
  5470. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5471. 'hache de guerre en pierre':
  5472. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5473. "hache à deux mains d'obsidienne":
  5474. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5475. 'hallebarde':
  5476. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5477. "haubert d'écailles":
  5478. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5479. 'haubert de mailles':
  5480. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5481. 'heaume':
  5482. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5483. 'jambières en cuir':
  5484. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5485. 'jambières en fourrure':
  5486. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5487. 'jambières en maille':
  5488. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5489. 'jambières en métal':
  5490. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5491. 'jambières en os':
  5492. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5493. "lame d'obsidienne":
  5494. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5495. 'lame en os':
  5496. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5497. 'lame en pierre':
  5498. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5499. 'lorgnons':
  5500. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5501. 'machette':
  5502. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5503. "masse d'arme":
  5504. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5505. 'pagne de mailles':
  5506. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5507. 'pagne en cuir':
  5508. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5509. 'robe de mage':
  5510. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5511. 'rondache en bois':
  5512. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5513. 'rondache en métal':
  5514. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5515. 'sandales':
  5516. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5517. 'souliers dorés':
  5518. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5519. "talisman d'obsidienne":
  5520. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5521. 'talisman de pierre':
  5522. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5523. 'targe':
  5524. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5525. 'torche':
  5526. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5527. 'torque de pierre':
  5528. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5529. 'tunique':
  5530. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5531. "tunique d'écailles":
  5532. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5533. 'turban':
  5534. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5535. }
  5536.  
  5537. // liste des templates
  5538. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5539. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5540. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5541. var mh_templates = {
  5542. 'de Feu':
  5543. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5544. 'de Résistance':
  5545. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5546. "de l'Aigle":
  5547. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5548. 'de la Salamandre':
  5549. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5550. 'des Cyclopes':
  5551. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5552. 'des Enragés':
  5553. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5554. 'des Tortues':
  5555. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5556. 'des Vampires':
  5557. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5558. 'du Glacier':
  5559. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5560. 'du Rat':
  5561. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5562. 'du Roc':
  5563. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5564. 'du Temps':
  5565. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5566. 'du Vent':
  5567. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5568. 'en Mithril':
  5569. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5570. 'des Anciens':
  5571. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5572. 'des Champions':
  5573. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5574. 'des Duellistes':
  5575. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5576. 'de la Terre':
  5577. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5578. "de l'Orage":
  5579. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5580. "de l'Ours":
  5581. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5582. 'des Béhémoths':
  5583. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5584. 'des Mages':
  5585. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5586. 'du Pic':
  5587. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5588. 'du Sable':
  5589. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5590. 'acéré':
  5591. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5592. 'acérée':
  5593. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5594. 'équilibré':
  5595. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5596. 'équilibrée':
  5597. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5598. 'léger':
  5599. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5600. 'légère':
  5601. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5602. 'renforcé':
  5603. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5604. 'renforcée':
  5605. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5606. 'robuste':
  5607. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5608. }
  5609.  
  5610. function clone(arr) {
  5611. // Clonage rapide
  5612. return arr.slice(0);
  5613. }
  5614.  
  5615. function addArray(arr1,arr2) {
  5616. // Somme matricielle
  5617. var res = clone(arr1);
  5618. for(i=res.length-1 ; i>=0 ; i--) {
  5619. res[i] += arr2[i];
  5620. }
  5621. return res;
  5622. }
  5623.  
  5624. function getTemplates(nomItem) {
  5625. // Déstructure le nom de l'item en array [nom, template1, ...]
  5626. var tempFound = true;
  5627. var str = nomItem.trim();
  5628. var arr = [];
  5629. while(tempFound) {
  5630. tempFound = false;
  5631. for(var temp in mh_templates) {
  5632. // on teste la fin du nom contre chaque template
  5633. if(str.slice(-temp.length)!=temp) { continue; }
  5634. tempFound = true;
  5635. str = str.slice(0,-temp.length-1);
  5636. arr.unshift(temp);
  5637. if(str.slice(-3)==' et') {
  5638. str = str.slice(0,-3);
  5639. }
  5640. }
  5641. }
  5642. arr.unshift(str);
  5643. return arr;
  5644. }
  5645.  
  5646. function addMithril(arrayCaracs,typeItem) {
  5647. // Ajoute l'effet du Mithril sur les caracs
  5648. if(typeItem=='arme') {
  5649. if(arrayCaracs[0]<0) {
  5650. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5651. }
  5652. }
  5653. else {
  5654. if(arrayCaracs[4]<0) {
  5655. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5656. }
  5657. }
  5658. arrayCaracs[15] /= 2;
  5659. arrayCaracs[16] /= 2;
  5660. return arrayCaracs;
  5661. }
  5662.  
  5663. function addRenfort(arrayCaracs,template) {
  5664. // Ajoute l'effet des pseudo-templates sur les caracs
  5665. // S'applique APRÈS le mithril
  5666. // WARNING - Cette formule n'a rien d'officiel, gare !
  5667. var coef = 0;
  5668. if(/^lég[e,è]re?$/.test(template)) {
  5669. coef = -1;
  5670. }
  5671. else if(/^renforcée?$/.test(template)
  5672. || template==='robuste') {
  5673. coef = 1;
  5674. }
  5675. if(coef) {
  5676. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5677. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5678. }
  5679. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5680. return arrayCaracs;
  5681. }
  5682.  
  5683. function getCaracs(item) {
  5684. // Calcule les caractéristiques de l'item
  5685. var templates = getTemplates(item);
  5686. if(!mh_caracs[templates[0]]) {
  5687. // Si l'item est inconnu
  5688. return [];
  5689. }
  5690. var caracs = clone(mh_caracs[templates[0]]);
  5691. var typeItem = caracs[0];
  5692. caracs.shift();
  5693. templates.shift();
  5694. if(templates[templates.length-1]=='en Mithril') {
  5695. caracs = addMithril(caracs,typeItem);
  5696. templates.pop();
  5697. }
  5698. if(/^acérée?$/.test(templates[0])
  5699. || /^équilibrée?$/.test(templates[0])
  5700. || /^lég[e,è]re?$/.test(templates[0])
  5701. || /^renforcée?$/.test(templates[0])
  5702. || templates[0]=='robuste') {
  5703. caracs = addRenfort(caracs,templates[0]);
  5704. templates.shift();
  5705. }
  5706. for(var i=templates.length-1 ; i>=0 ; i--) {
  5707. caracs = addArray(caracs,mh_templates[templates[i]]);
  5708. }
  5709. return caracs;
  5710. }
  5711.  
  5712. function getLine(tab) {
  5713. // Préparation de la ligne à afficher lors d'un mouseover
  5714. var str = '';
  5715. if(tab[0]!=0 || tab[1]!=0) {
  5716. str += '<b>Att : </b>'+aff(tab[0]);
  5717. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5718. str += ' | ';
  5719. }
  5720. if(tab[4]!=0) {
  5721. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5722. }
  5723. if(tab[2]!=0 || tab[3]!=0) {
  5724. str += '<b>Deg : </b>'+aff(tab[2]);
  5725. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5726. str += ' | ';
  5727. }
  5728. if(tab[8]!=0) {
  5729. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5730. }
  5731. if(tab[7]!=0) {
  5732. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5733. }
  5734. if(tab[5]!=0 || tab[6]!=0) {
  5735. str += '<b>Arm : </b>'+aff(tab[5]);
  5736. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5737. str += ' | ';
  5738. }
  5739. if(tab[9]!=0 || tab[10]!=0) {
  5740. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5741. if(tab[9]!=tab[10]) {
  5742. str += '/'+aff(tab[10])+'%';
  5743. }
  5744. str += ' | ';
  5745. }
  5746. if(tab[11]!=0 || tab[12]!=0) {
  5747. str += '<b>MM : </b>'+aff(tab[11])+'%';
  5748. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  5749. str += ' | ';
  5750. }
  5751. if(tab[13]!=0) {
  5752. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5753. }
  5754. if(tab[14]!=0) {
  5755. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5756. }
  5757. str += '<b>Poids : </b>'+tab[15]+' min';
  5758. if(tab[15]!=tab[16]) {
  5759. str += ' / '+tab[16]+' min';
  5760. }
  5761. return str;
  5762. }
  5763.  
  5764. function toolTipInit() {
  5765. DivInfo = document.createElement('div');
  5766. DivInfo.id = 'infosVue';
  5767. DivInfo.className = 'mh_textbox';
  5768. DivInfo.style =
  5769. 'position: absolute;'
  5770. +'border: 1px solid #000000;'
  5771. +'visibility:hidden;'
  5772. +'display:inline;'
  5773. +'z-index:99;';
  5774. document.body.appendChild(DivInfo);
  5775. document.onmousemove = getXY;
  5776. document.onclick = changeFreezeStatus;
  5777. }
  5778.  
  5779. function getXY(evt) {
  5780. if(!freezed && DivInfo.style.visibility=='visible') {
  5781. DivInfo.style.left = evt.pageX+'px';
  5782. DivInfo.style.top = evt.pageY+10+'px';
  5783. }
  5784. }
  5785.  
  5786. function changeFreezeStatus() {
  5787. if(DivInfo.style.visibility=='visible') {
  5788. freezed = !freezed;
  5789. if(!freezed) { hideInfos(); }
  5790. }
  5791. }
  5792.  
  5793. function showInfos() {
  5794. if(freezed) { return; }
  5795. var currentInfos = this.infos;
  5796. DivInfo.innerHTML = currentInfos;
  5797. DivInfo.style.visibility = 'visible';
  5798. }
  5799.  
  5800. function hideInfos() {
  5801. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  5802. }
  5803.  
  5804. function treateEquipement() {
  5805. // Extrait les données du matos et réinjecte les infos déduites
  5806. if(MY_getValue('INFOCARAC')=='false') { return; }
  5807. var faireLigne = false;
  5808. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  5809. var nodes = document.evaluate(
  5810. "//td/b[text()='Equipement Utilisé']/../../"
  5811. +"td[2]/img[contains(@src,bullet)]",
  5812. document, null, 7, null);
  5813. if(nodes.snapshotLength>0) {
  5814. // Si CSS de base
  5815. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5816. var node = nodes.snapshotItem(i);
  5817. var next = node.nextSibling;
  5818. var nnext = next.nextSibling;
  5819. var nom = next.nodeValue.toLowerCase();
  5820. if(nnext.childNodes.length==1) {
  5821. nom += nnext.firstChild.nodeValue;
  5822. }
  5823. nom = nom.trim();
  5824. // gestion winpostrophe
  5825. var c = String.fromCharCode(180);
  5826. while(nom.indexOf(c)!=-1) {
  5827. nom = nom.replace(c,"'");
  5828. }
  5829. var arr = getCaracs(nom);
  5830. if(arr.length>0) {
  5831. faireLigne = true;
  5832. caracs = addArray(caracs,arr);
  5833. var span = document.createElement('span');
  5834. span.appendChild(next);
  5835. span.appendChild(nnext);
  5836. span.infos = getLine(arr);
  5837. span.onmouseover = showInfos;
  5838. span.onmouseout = hideInfos;
  5839. insertBefore(node.nextSibling,span);
  5840. }
  5841. }
  5842. if(faireLigne) {
  5843. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  5844. document, null, 9, null).singleNodeValue;
  5845. node.infos = getLine(caracs);
  5846. node.onmouseover = showInfos;
  5847. node.onmouseout = hideInfos;
  5848. }
  5849. }
  5850. else {
  5851. // Si CSS avancée
  5852. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  5853. document, null, 7, null);
  5854. if(nodes.snapshotLength>0) {
  5855. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  5856. var node = nodes.snapshotItem(i);
  5857. var nom = node.firstChild.nodeValue.toLowerCase();
  5858. if(node.childNodes.length>1) {
  5859. nom += node.childNodes[1].firstChild.nodeValue;
  5860. }
  5861. nom = nom.trim();
  5862. // gestion winpostrophe
  5863. var c = String.fromCharCode(180);
  5864. while(nom.indexOf(c)!=-1) {
  5865. nom = nom.replace(c,"'");
  5866. }
  5867. var arr = getCaracs(nom);
  5868. if(arr.length!=0) {
  5869. caracs = addArray(caracs,arr);
  5870. node.infos = getLine(arr);
  5871. node.onmouseover = showInfos;
  5872. node.onmouseout = hideInfos;
  5873. }
  5874. }
  5875. var nodes = document.evaluate("//dt[@class='equipement']",
  5876. document, null, 7, null);
  5877. var node = nodes.snapshotItem(0);
  5878. node.infos = getLine(caracs);
  5879. node.onmouseover = showInfos;
  5880. node.onmouseout = hideInfos;
  5881. }
  5882. }
  5883. }
  5884.  
  5885. function do_pjview() {
  5886. treateEquipement();
  5887. toolTipInit();
  5888. }
  5889.  
  5890. /*******************************************************************************
  5891. * This file is part of Mountyzilla. *
  5892. * *
  5893. * Mountyzilla is free software; you can redistribute it and/or modify *
  5894. * it under the terms of the GNU General Public License as published by *
  5895. * the Free Software Foundation; either version 2 of the License, or *
  5896. * (at your option) any later version. *
  5897. * *
  5898. * Mountyzilla is distributed in the hope that it will be useful, *
  5899. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5900. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5901. * GNU General Public License for more details. *
  5902. * *
  5903. * You should have received a copy of the GNU General Public License *
  5904. * along with Mountyzilla; if not, write to the Free Software *
  5905. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5906. *******************************************************************************/
  5907.  
  5908. // x~x option
  5909.  
  5910. /* TODO
  5911. * Passer le HTML injecté aux conventions HTML5
  5912. */
  5913.  
  5914.  
  5915. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  5916.  
  5917. function saveITData() {
  5918. var IT = document.getElementById('itSelect').value;
  5919. if(IT=='bricol') {
  5920. var system = document.getElementById('urlbricol').value;
  5921. var login = document.getElementById('loginbricol').value;
  5922. var pass = document.getElementById('passbricol').value;
  5923. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  5924. if(system && login) {
  5925. if (pass) {
  5926. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  5927. MY_setValue(numTroll+'.INFOSIT', v);
  5928. //window.console.log('v=' + v);
  5929. } else {
  5930. // vérif que rien n'a changé
  5931. var str = MY_getValue(numTroll+'.INFOSIT');
  5932. if(str) {
  5933. var arr = str.split('$');
  5934. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  5935. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  5936. }
  5937. }
  5938. }
  5939. }
  5940. }
  5941. else {
  5942. MY_removeValue(numTroll+'.INFOSIT');
  5943. }
  5944. }
  5945.  
  5946. function saveLinks() {
  5947. var numLinks = document.getElementById('linksBody').childNodes.length;
  5948. var data=[ [] ];
  5949. /* Récupération et tri des liens */
  5950. for(var i=1 ; i<=numLinks ; i++) {
  5951. MY_removeValue('URL'+i);
  5952. MY_removeValue('URL'+i+'.nom');
  5953. MY_removeValue('URL'+i+'.ico');
  5954. var url = document.getElementById('url'+i).value;
  5955. var nom = document.getElementById('nom'+i).value;
  5956. var ico = document.getElementById('ico'+i).value;
  5957. if(url && (nom || ico) ) {
  5958. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  5959. }
  5960. }
  5961. /* Sauvegarde */
  5962. for(var i=1 ; i<data.length ; i++) {
  5963. MY_setValue('URL'+i,data[i][0]);
  5964. MY_setValue('URL'+i+'.nom',data[i][1]);
  5965. MY_setValue('URL'+i+'.ico',data[i][2]);
  5966. }
  5967. }
  5968.  
  5969. function saveAll() {
  5970. var urlIco = document.getElementById('icoMenuIco').value;
  5971. if(urlIco) {
  5972. MY_setValue(numTroll+'.ICOMENU', urlIco );
  5973. }
  5974. else {
  5975. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  5976. document.getElementById('icoMenuIco').value = '';
  5977. }
  5978. saveLinks();
  5979. refreshLinks();
  5980. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  5981. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  5982. if(maxcdm) {
  5983. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  5984. }
  5985. else {
  5986. MY_removeValue(numTroll+'.MAXCDM');
  5987. document.getElementById('maxcdm').value = '';
  5988. }
  5989.  
  5990. MY_setValue('NOINFOEM',
  5991. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  5992. // Pourquoi Tilk stockait-il tout en str ?
  5993. // -> parce que les booléens c'est foireux (vérifié)
  5994. MY_setValue(numTroll+'.USECSS',
  5995. document.getElementById('usecss').checked ? 'true':'false');
  5996. MY_setValue('INFOCARAC',
  5997. document.getElementById('infocarac').checked ? 'true' : 'false');
  5998. //MY_setValue(numTroll+'.SEND_IDT',
  5999. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6000. // Fonctionnalité désactivée
  6001.  
  6002. MY_setValue(numTroll+'.AUTOCDM',
  6003. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6004. MY_setValue('VUECARAC',
  6005. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6006. MY_setValue('CONFIRMEDECALAGE',
  6007. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6008.  
  6009. saveITData();
  6010. var bouton = document.getElementById('saveAll');
  6011. bouton.value = (bouton.value=='Sauvegardé !') ?
  6012. 'Re-sauvegardé !' : 'Sauvegardé !';
  6013. }
  6014.  
  6015.  
  6016. /*-[functions]----------------- EventListeners -------------------------------*/
  6017.  
  6018. function onChangeIT() {
  6019. var IT = document.getElementById('itSelect').value;
  6020. var itBody = document.getElementById('itBody');
  6021. itBody.innerHTML = '';
  6022. if(IT=='bricol') {
  6023. var tr = appendTr(itBody,'mh_tdpage')
  6024. var td = appendTd(tr);
  6025. var str = MY_getValue(numTroll+'.INFOSIT');
  6026. //window.console.log('onChangeIT str=' + str);
  6027. if(str) {
  6028. var arr = str.split('$');
  6029. var system = arr[1];
  6030. var login = arr[2];
  6031. var affhv = arr[4];
  6032. }
  6033. appendText(td,'Nom du système : ');
  6034. appendTextbox(td,'text','urlbricol',20,50,system);
  6035. td = appendTd(tr);
  6036. appendText(td,'Login du compte : ');
  6037. appendTextbox(td,'text','loginbricol',20,50,login);
  6038. td = appendTd(tr);
  6039. appendText(td,'Mot de passe du compte : ');
  6040. appendTextbox(td,'password','passbricol',20,50);
  6041. td = appendTd(tr);
  6042. appendText(td,'Affichage des Trõlls hors vue : ');
  6043. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  6044. appendCheckBox(td,'affhvbricol', (affhv>0));
  6045. }
  6046. }
  6047.  
  6048. function refreshLinks() {
  6049. document.getElementById('linksBody').innerHTML = '';
  6050. var anotherURL = MY_getValue('URL1');
  6051. if(!anotherURL) { addLinkField(); }
  6052. var i=1;
  6053. while(anotherURL && i<99) {
  6054. addLinkField(i,anotherURL,
  6055. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6056. i++;
  6057. anotherURL = MY_getValue('URL'+i);
  6058. }
  6059. }
  6060.  
  6061. function addLinkField(i,url,nom,ico) {
  6062. var linksBody = document.getElementById('linksBody');
  6063. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6064. var tr = appendTr(linksBody);
  6065. var td = appendTdCenter(tr);
  6066. appendText(td,'Lien '+i+' : ');
  6067. appendTextbox(td,'text','url'+i,40,150,url);
  6068. td = appendTdCenter(tr);
  6069. appendText(td,'Nom : ');
  6070. appendTextbox(td,'text','nom'+i,20,150,nom);
  6071. td = appendTdCenter(tr);
  6072. appendText(td,'Icône : ');
  6073. appendTextbox(td,'text','ico'+i,40,150,ico);
  6074. }
  6075.  
  6076. function removeLinkField() {
  6077. var linksBody = document.getElementById('linksBody');
  6078. var i = linksBody.childNodes.length;
  6079. MY_removeValue('URL'+i);
  6080. MY_removeValue('URL'+i+'.nom');
  6081. MY_removeValue('URL'+i+'.ico');
  6082. linksBody.removeChild(linksBody.lastChild);
  6083. if(linksBody.childNodes.length==0) { addLinkField(); }
  6084. }
  6085.  
  6086. function resetMainIco() {
  6087. document.getElementById('icoMenuIco').value=
  6088. URL_MZimg + 'mz_logo_small.png';
  6089. }
  6090.  
  6091.  
  6092. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6093.  
  6094. function insertTitle(next,txt) {
  6095. var div = document.createElement('div');
  6096. div.className = 'titre2';
  6097. appendText(div,txt);
  6098. insertBefore(next,div);
  6099. return div;
  6100. }
  6101.  
  6102. function insertMainTable(next) {
  6103. var table = document.createElement('table');
  6104. table.width = '98%';
  6105. table.border = 0;
  6106. table.align = 'center';
  6107. table.cellPadding = 2;
  6108. table.cellSpacing = 1;
  6109. table.className = 'mh_tdborder';
  6110. var tbody = document.createElement('tbody');
  6111. table.appendChild(tbody);
  6112. insertBefore(next,table);
  6113. return tbody;
  6114. }
  6115.  
  6116. function appendSubTable(node) {
  6117. var table = document.createElement('table');
  6118. table.width = '100%';
  6119. var tbody = document.createElement('tbody');
  6120. table.appendChild(tbody);
  6121. node.appendChild(table);
  6122. return tbody;
  6123. }
  6124.  
  6125. function insertOptionTable(insertPt) {
  6126. var mainBody = insertMainTable(insertPt);
  6127. /* Liens dans le Menu */
  6128. var tr = appendTr(mainBody,'mh_tdtitre');
  6129. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6130. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6131. appendText(td,'Icône du Menu: ');
  6132. var url = MY_getValue(numTroll+'.ICOMENU');
  6133. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6134. url = URL_MZimg + 'mz_logo_small.png';
  6135. }
  6136. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6137. appendButton(td,'Réinitialiser',resetMainIco);
  6138. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6139. var tbody = appendSubTable(td);
  6140. tbody.id = 'linksBody';
  6141. refreshLinks();
  6142. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6143. appendButton(td,'Ajouter',addLinkField);
  6144. appendButton(td,'Supprimer',removeLinkField);
  6145. /* Options de la Vue : vue externe, nb de CdM, etc */
  6146. tr = appendTr(mainBody,'mh_tdtitre');
  6147. appendTdText(tr,'Options de la Vue :',true);
  6148. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6149. tbody = appendSubTable(td);
  6150. tr = appendTr(tbody);
  6151. td = appendTdText(tr,'Vue externe : ');
  6152. var select = document.createElement('select');
  6153. select.id = 'vueext';
  6154. td.appendChild(select);
  6155. var listeVues2D = [
  6156. 'Bricol\' Vue',
  6157. 'Vue du CCM',
  6158. 'Vue Gloumfs 2D',
  6159. 'Vue Gloumfs 3D',
  6160. 'Grouky Vue!'
  6161. ];
  6162. for(var i=0 ; i<listeVues2D.length ; i++) {
  6163. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6164. }
  6165. if(MY_getValue('VUEEXT')) {
  6166. select.value = MY_getValue('VUEEXT');
  6167. }
  6168. td = appendTd(tr);
  6169. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6170. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6171. tr = appendTr(tbody);
  6172. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6173. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6174. td = appendTd(tr);
  6175. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6176. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6177. /* Interface Tactique */
  6178. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6179. appendText(td,'Interface Tactique : ',true);
  6180. select = document.createElement('select');
  6181. select.id = 'itSelect';
  6182. appendOption(select,'none','Aucune');
  6183. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6184. // seule interface supportée !
  6185. td.appendChild(select);
  6186. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6187. tbody = appendSubTable(td);
  6188. tbody.id = 'itBody';
  6189. select.onchange = onChangeIT;
  6190. var str = MY_getValue(numTroll+'.INFOSIT');
  6191. if(str) {
  6192. select.value = str.slice(0,str.indexOf('$'));
  6193. onChangeIT();
  6194. }
  6195. /* Options diverses */
  6196. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6197. appendText(td,'Options diverses :',true);
  6198. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6199. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6200. appendText(td,
  6201. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6202. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6203. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6204. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6205. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6206. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6207. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6208. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6209. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6210. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6211. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6212. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6213. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6214. /* Bouton SaveAll */
  6215. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6216. input = appendButton(td,'Sauvegarder',saveAll);
  6217. input.id = 'saveAll';
  6218. }
  6219.  
  6220. function insertCreditsTable(insertPt) {
  6221. var tbody = insertMainTable(insertPt);
  6222. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6223. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6224. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6225.  
  6226. var ul = document.createElement('ul');
  6227. td.appendChild(ul);
  6228. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6229. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6230. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6231. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6232. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6233. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6234. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6235. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6236. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6237. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6238. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6239. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6240. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6241. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6242. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6243. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6244. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6245. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6246. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6247. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6248. }
  6249.  
  6250.  
  6251. /* [functions] Obsolètes */
  6252. function deleteEnchantement()
  6253. {
  6254. try
  6255. {
  6256. var idEquipement = this.getAttribute('name');
  6257. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6258. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6259. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6260. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6261. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6262. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6263. var string = "";
  6264. for(var i=0;i<listeEquipement.length;i++)
  6265. {
  6266. if(listeEquipement[i]!=idEquipement)
  6267. if(string=="")
  6268. string = listeEquipement[i];
  6269. else
  6270. string += ";"+listeEquipement[i];
  6271. }
  6272. if(string=="")
  6273. {
  6274. MY_removeValue(numTroll+".enchantement.liste");
  6275. var table = this.parentNode.parentNode.parentNode.parentNode;
  6276. var parent = table.parentNode;
  6277. for(var i=0;i<parent.childNodes.length;i++)
  6278. {
  6279. if(parent.childNodes[i]==table)
  6280. {
  6281. parent.removeChild(parent.childNodes[i-1]);
  6282. parent.removeChild(parent.childNodes[i-1]);
  6283. parent.removeChild(parent.childNodes[i-1]);
  6284. break;
  6285. }
  6286. }
  6287. }
  6288. else
  6289. {
  6290. MY_getValue(numTroll+".enchantement.liste",string);
  6291. this.parentNode.parentNode.parentNode
  6292. .removeChild(this.parentNode.parentNode);
  6293. }
  6294. }
  6295. catch(e)
  6296. {
  6297. window.alert(e);
  6298. }
  6299. }
  6300. /* [functions] fin Obsolètes */
  6301.  
  6302. /*-[functions]---------------- Partie principale -----------------------------*/
  6303.  
  6304. function do_option() {
  6305. start_script(712);
  6306.  
  6307. // Pour cryptage des mdp IT
  6308. //appendNewScript(URL_tilk_js + 'md5.js'); // source intégré dans tout_MZ
  6309.  
  6310. var insertPoint = document.getElementById('footer1');
  6311. insertBefore(insertPoint,document.createElement('p'));
  6312. var ti = insertTitle(insertPoint,'Mountyzilla : Options');
  6313. ti.title = 'Version ' + GM_info.script.version;
  6314. insertOptionTable(insertPoint);
  6315. /* insertion enchantements ici
  6316. if(...)
  6317. insertEnchantementTable();
  6318. */
  6319. insertBefore(insertPoint,document.createElement('p'));
  6320. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6321. ti.onclick = function (e) {
  6322. var evt = e || window.event;
  6323. if (evt.shiftKey) {
  6324. var oldDev = MY_getValue('MZ_dev');
  6325. if (oldDev) {
  6326. MY_removeValue('MZ_dev');
  6327. } else {
  6328. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6329. MY_setValue('MZ_dev', 1);
  6330. }
  6331. document.location.href = document.location.href;
  6332. }
  6333. }
  6334. insertCreditsTable(insertPoint);
  6335. insertBefore(insertPoint,document.createElement('p'));
  6336.  
  6337. /* [zone] Obsolète ?? */
  6338. if(MY_getValue(numTroll+".enchantement.liste")
  6339. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6340. {
  6341. insertTitle(insertPoint, 'Les Enchantements en cours');
  6342. table = document.createElement('table');
  6343. table.setAttribute('width', '98%');
  6344. table.setAttribute('border', '0');
  6345. table.setAttribute('align', 'center');
  6346. table.setAttribute('cellpadding', '2');
  6347. table.setAttribute('cellspacing', '1');
  6348. table.setAttribute('class', 'mh_tdborder');
  6349.  
  6350. tbody = document.createElement('tbody');
  6351. table.appendChild(tbody);
  6352. tr = appendTr(tbody, 'mh_tdtitre');
  6353. appendTdText(tr, 'Equipement',1);
  6354. appendTdText(tr, 'Composants',1);
  6355. appendTdText(tr, 'Enchanteur',1);
  6356. appendTdText(tr, 'Action',1);
  6357. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6358. for(var i=0;i<listeEquipement.length;i++)
  6359. {
  6360. try
  6361. {
  6362. var idEquipement = listeEquipement[i];
  6363. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6364. +idEquipement+".objet");
  6365. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6366. +idEquipement+".enchanteur").split(";");
  6367. var ul = document.createElement('UL');
  6368. for(var j=0;j<3;j++)
  6369. {
  6370. var infoComposant = MY_getValue(numTroll+".enchantement."
  6371. +idEquipement+".composant."+j).split(";");
  6372. var texte = infoComposant[4].replace("Ril ","Œil ");
  6373. for(var k=5;k<infoComposant.length;k++)
  6374. {
  6375. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6376. }
  6377. li = appendLI(ul,texte);
  6378. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6379. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6380. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6381. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6382. string+= '<input type="hidden" name="q" value="min" />';
  6383. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6384. 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>';
  6385.  
  6386. string+= '</form>';
  6387. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6388. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6389. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6390. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6391. li.innerHTML += string;
  6392. }
  6393. tr = appendTr(tbody, 'mh_tdpage');
  6394. td = appendTdText(tr, nomEquipement);
  6395. td.setAttribute('valign', 'center');
  6396. td = document.createElement('td');
  6397. td.appendChild(ul);
  6398. tr.appendChild(td);
  6399. td.setAttribute('valign', 'center');
  6400. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6401. td.setAttribute('valign', 'center');
  6402. td = document.createElement('td');
  6403. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6404. input.setAttribute('name', idEquipement);
  6405. tr.appendChild(td);
  6406. td.setAttribute('valign', 'center');
  6407. }
  6408. catch(e)
  6409. {
  6410. }
  6411. }
  6412. insertBefore(insertPoint, table);
  6413. insertBefore(insertPoint, document.createElement('p'));
  6414. }
  6415. /* [zone] fin Obsolète ?? */
  6416.  
  6417.  
  6418. displayScriptTime();
  6419. }
  6420.  
  6421. /*******************************************************************************
  6422. * This file is part of Mountyzilla. *
  6423. * *
  6424. * Mountyzilla is free software; you can redistribute it and/or modify *
  6425. * it under the terms of the GNU General Public License as published by *
  6426. * the Free Software Foundation; either version 2 of the License, or *
  6427. * (at your option) any later version. *
  6428. * *
  6429. * Mountyzilla is distributed in the hope that it will be useful, *
  6430. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6431. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6432. * GNU General Public License for more details. *
  6433. * *
  6434. * You should have received a copy of the GNU General Public License *
  6435. * along with Mountyzilla; if not, write to the Free Software *
  6436. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6437. *******************************************************************************/
  6438.  
  6439. // x~x equip
  6440.  
  6441. /**
  6442. * 2014-02-08 - v2.0a (from scratch)
  6443. * 2014-02-18 - v2.0a0
  6444. * - ajout calcul Carats / UM des minerais + totaux
  6445. * 2014-03-06 - v2.0a1
  6446. * - retour Infos EM des Champis
  6447. * TODO
  6448. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6449. */
  6450.  
  6451. function traiteChampis() {
  6452. try{
  6453. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6454. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6455. }
  6456. catch(e){return;}
  6457. if(trlist.length<=0) return;
  6458. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6459. var node = trlist.snapshotItem(i).childNodes[7];
  6460. var str = node.textContent.trim();
  6461. var type = str.slice(0,str.lastIndexOf(' '));
  6462. var mundi = mundiChampi[type];
  6463. if(!mundi) continue;
  6464. var urlImg = URL_MZimg
  6465. +'Competences/ecritureMagique.png';
  6466. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6467. appendText(node,' ');
  6468. node.appendChild(img);
  6469. }
  6470. }
  6471.  
  6472. function traiteCompos() {
  6473. try {
  6474. var tr = document.getElementById('mh_objet_hidden_Composant');
  6475. var tbody = document.evaluate("./td/table/tbody",
  6476. tr, null, 9, null).singleNodeValue;
  6477. }
  6478. catch(e) {return;}
  6479. insererInfosEM(tbody);
  6480. }
  6481.  
  6482. function traiteMinerai() {
  6483. try{
  6484. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6485. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6486. }
  6487. catch(e){return;}
  6488. if(trlist.length<=0) return;
  6489. var totaux = {};
  6490. var str;
  6491. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6492. var node = trlist.snapshotItem(i);
  6493. var nature = node.childNodes[7].textContent,
  6494. caracs = node.childNodes[9].textContent;
  6495. var taille = Number(caracs.match(/\d+/)[0]);
  6496. var coef = 1;
  6497. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6498. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6499. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6500. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6501. if(nature.indexOf('Mithril')!=-1) {
  6502. coef = 0.2*coef;
  6503. str = ' | UM: ';
  6504. }
  6505. else {
  6506. coef = 0.75*coef+1.25;
  6507. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6508. str = ' | Carats: ';
  6509. }
  6510. var carats = Math.round(taille*coef)
  6511. appendText(node.childNodes[9], str+carats );
  6512. if(!totaux[nature]) {
  6513. totaux[nature] = [taille,carats];
  6514. }
  6515. else {
  6516. totaux[nature][0] += taille;
  6517. totaux[nature][1] += carats;
  6518. }
  6519. }
  6520. str = 'Total : ';
  6521. for(var nature in totaux) {
  6522. if(str.length>8) str += ', ';
  6523. if(nature.indexOf('Mithril')!=-1) {
  6524. str += nature+totaux[nature][1]+' UM';
  6525. }
  6526. else {
  6527. str += nature+totaux[nature][0]+'U/'
  6528. +totaux[nature][1]+'c';
  6529. }
  6530. }
  6531. /*var node = document.getElementById('mh_plus_Minerai');
  6532. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6533. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6534. if(!titre) return;*/
  6535. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6536. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6537. td.colSpan = 7;
  6538. }
  6539.  
  6540. function do_equip() {
  6541. start_script();
  6542.  
  6543. traiteChampis();
  6544. traiteCompos();
  6545. traiteMinerai();
  6546.  
  6547. displayScriptTime();
  6548. }
  6549.  
  6550. /*******************************************************************************
  6551. * This file is part of Mountyzilla. *
  6552. * *
  6553. * Mountyzilla is free software; you can redistribute it and/or modify *
  6554. * it under the terms of the GNU General Public License as published by *
  6555. * the Free Software Foundation; either version 2 of the License, or *
  6556. * (at your option) any later version. *
  6557. * *
  6558. * Mountyzilla is distributed in the hope that it will be useful, *
  6559. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6560. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6561. * GNU General Public License for more details. *
  6562. * *
  6563. * You should have received a copy of the GNU General Public License *
  6564. * along with Mountyzilla; if not, write to the Free Software *
  6565. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6566. *******************************************************************************/
  6567.  
  6568. // x~x diplo
  6569.  
  6570. /*
  6571. TODO:
  6572. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6573. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6574. V Étape 3: Ajout de la diplo perso
  6575. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6576. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6577. Options Globales:
  6578. Actuelles:
  6579. numTroll.USECSS,
  6580. numTroll.NODIPLO
  6581. NOMYTH
  6582. Nouvelles:
  6583. TODO numTroll.USECSS
  6584. numTroll.diplo.off (remplace NODIPLO)
  6585. numTroll.diplo.guilde
  6586. numTroll.diplo.perso
  6587. Structure de diplo.guilde:
  6588. isOn: 'true' ou 'false'
  6589. isDetailOn: 'true' ou 'false'
  6590. guilde
  6591. > id
  6592. > couleur
  6593. AllAmis,AllEnnemis: couleur
  6594. Amis0,...,Ennemis5
  6595. > Troll: idTroll1;...;
  6596. > Guilde: idGuilde1;...;
  6597. > titre
  6598. > couleur
  6599. Structure de diplo.perso:
  6600. isOn: 'true' ou 'false'
  6601. mythiques: couleur
  6602. Troll,Guilde,Monstre:
  6603. > id
  6604. > couleur
  6605. > description
  6606. */
  6607.  
  6608. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6609.  
  6610. function couleurAleatoire() {
  6611. var alph = '0123456789ABCDEF'.split('');
  6612. var clr = '#';
  6613. for (var i=0; i<6; i++) {
  6614. clr+=alph[ Math.floor(16*Math.random()) ];
  6615. }
  6616. return clr;
  6617. }
  6618.  
  6619. function isCouleur(str) {
  6620. return /^#[0-9A-F]{6}$/i.test(str);
  6621. }
  6622.  
  6623. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6624.  
  6625. function appendChoixCouleur(node,id) {
  6626. var span = document.createElement('span');
  6627. span.id = 'span'+id;
  6628. if(isDetailOn) {
  6629. span.style.display = 'none';
  6630. }
  6631. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6632. if(diploGuilde[id]) {
  6633. couleur = diploGuilde[id];
  6634. }
  6635. appendText(span,' - Couleur HTML: ');
  6636. var input = appendTextbox(span,'text',id,7,7,couleur);
  6637. input.onkeyup = previewCouleur;
  6638. input.onchange = previewCouleur;
  6639. input.onkeyup();
  6640. node.appendChild(span);
  6641. }
  6642.  
  6643. function insertChoixCouleur(node,id) {
  6644. var span = document.createElement('span');
  6645. span.id = 'span'+id;
  6646. // La couleur détaillée passera à une valeur aléatoire
  6647. // si toggle vers isDetailOn
  6648. var couleur = couleurAleatoire();
  6649. if(!isDetailOn) {
  6650. span.style.display = 'none';
  6651. } else if(diploGuilde[id]) {
  6652. couleur = diploGuilde[id].couleur;
  6653. }
  6654. appendText(span,' - Couleur HTML: ');
  6655. var input = appendTextbox(span,'text',id,7,7,couleur);
  6656. input.onkeyup = previewCouleur;
  6657. input.onchange = previewCouleur;
  6658. input.onkeyup();
  6659. insertBefore(node,span);
  6660. }
  6661.  
  6662. function setChoixCouleurs() {
  6663. try {
  6664. var form = document.getElementsByName('ActionForm')[0];
  6665. var nodesAE = document.evaluate(
  6666. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6667. form, null, 7, null
  6668. );
  6669. var nodes = document.evaluate(
  6670. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6671. form, null, 7, null
  6672. );
  6673. } catch(e) {
  6674. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6675. return false;
  6676. };
  6677. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6678. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6679. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6680. for(var i=0 ; i<5 ; i++) {
  6681. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6682. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6683. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6684. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6685. }
  6686. return true;
  6687. }
  6688.  
  6689. function fetchDiploGuilde() {
  6690. try {
  6691. for(var AE in {Amis:0,Ennemis:0}) {
  6692. for(var i=0 ; i<5 ; i++) {
  6693. /* Récup des A/E de rang i */
  6694. var td = document.getElementById('td'+AE+i);
  6695. var ligne = td.getElementsByTagName('table')[0].rows;
  6696. var titre = trim(td.firstChild.textContent);
  6697. // On laisse la gestion des couleurs à setChoixCouleurs:
  6698. var couleur = document.getElementById(AE+i).value;
  6699. diploGuilde[AE+i] = {
  6700. Troll:'',
  6701. Guilde:'',
  6702. titre: titre,
  6703. couleur: couleur
  6704. };
  6705. for(var j=1 ; j<ligne.length ; j++) {
  6706. var str = trim(ligne[j].cells[0].textContent);
  6707. var idx = str.lastIndexOf('(');
  6708. var num = str.slice(idx+1,-1);
  6709. var type = trim(ligne[j].cells[1].textContent);
  6710. diploGuilde[AE+i][type] += num+';';
  6711. }
  6712. }
  6713. }
  6714. } catch(e) {
  6715. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6716. return false;
  6717. }
  6718. return true;
  6719. }
  6720.  
  6721.  
  6722. /*-[functions]--------------------- Handlers ---------------------------------*/
  6723.  
  6724. function toggleDetails() {
  6725. isDetailOn = !isDetailOn;
  6726. for(var AE in {Amis:0,Ennemis:0}) {
  6727. document.getElementById('spanAll'+AE).style.display =
  6728. (isDetailOn?'none':'');
  6729. for(var i=0 ; i<5 ; i++) {
  6730. document.getElementById('span'+AE+i).style.display =
  6731. (isDetailOn?'':'none');
  6732. }
  6733. }
  6734. }
  6735.  
  6736. function toggleMythiques() {
  6737. isMythiquesOn = !isMythiquesOn;
  6738. document.getElementById('spanMythiques').style.display =
  6739. (isMythiquesOn?'':'none');
  6740. }
  6741.  
  6742. function previewCouleur() {
  6743. var value = this.value;
  6744. if(isCouleur(value)) {
  6745. this.style.backgroundColor = value;
  6746. this.title = '';
  6747. } else {
  6748. this.style.backgroundColor = '';
  6749. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  6750. }
  6751. }
  6752.  
  6753. function appendMenuType(node,duType) {
  6754. var select = document.createElement('select');
  6755. select.className = 'SelectboxV2';
  6756. var type = ['Guilde','Troll','Monstre'];
  6757. for(var i=0 ; i<3 ; i++) {
  6758. appendOption(select,type[i],type[i]);
  6759. if(type[i]==duType) { select.selectedIndex=i; }
  6760. }
  6761. node.appendChild(select);
  6762. }
  6763.  
  6764. function ajouteChamp(type,num,couleur,descr) {
  6765. var champs = document.getElementById('diploPerso');
  6766. var nb = champs.rows.length;
  6767. var tr = champs.insertRow(-1);
  6768. var td = appendTd(tr);
  6769. appendMenuType(td,type);
  6770. td = appendTd(tr);
  6771. appendText(td,' n°');
  6772. appendTextbox(td,'text','num'+nb,6,15,num);
  6773. td = appendTd(tr);
  6774. appendText(td,' couleur HTML:');
  6775. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  6776. input.onkeyup = previewCouleur;
  6777. input.onchange = previewCouleur;
  6778. input.onkeyup();
  6779. td = appendTd(tr);
  6780. appendText(td,' Description:');
  6781. appendTextbox(td,'text','descr'+nb,30,150,descr);
  6782. td = appendTd(tr);
  6783. var span = document.createElement('span');
  6784. appendText(span,'[ok!]',true);
  6785. span.style.visibility = 'hidden';
  6786. td.appendChild(span);
  6787. td = appendTd(tr);
  6788. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  6789. }
  6790.  
  6791. function retireCeChamp() {
  6792. var thisTr = this.parentNode.parentNode;
  6793. thisTr.parentNode.removeChild(thisTr);
  6794. var champs = document.getElementById('diploPerso');
  6795. if(champs.rows.length==0) { ajouteChamp(); }
  6796. }
  6797.  
  6798. function valideChamp(champ) {
  6799. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  6800. isCouleur(champ.cells[2].childNodes[1].value);
  6801. if(isValide) {
  6802. champ.cells[4].firstChild.style.visibility = 'visible';
  6803. } else {
  6804. champ.cells[4].firstChild.style.visibility = 'hidden';
  6805. }
  6806. return isValide;
  6807. }
  6808.  
  6809. function sauvegarderTout() {
  6810. /* Diplo de guilde */
  6811. diploGuilde.isOn =
  6812. document.getElementById('isGuildeOn').checked?'true':'false';
  6813. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  6814. var numGuilde = Number(document.getElementById('numGuilde').value);
  6815. var couleur = document.getElementById('couleurGuilde').value;
  6816. if(numGuilde) {
  6817. diploGuilde.guilde = {
  6818. id: numGuilde,
  6819. couleur: couleur
  6820. };
  6821. } else {
  6822. delete diploGuilde.guilde;
  6823. }
  6824. for(var AE in {Amis:0,Ennemis:0}) {
  6825. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  6826. for(var i=0 ; i<5 ; i++) {
  6827. if(isDetailOn) {
  6828. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  6829. } else {
  6830. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  6831. }
  6832. }
  6833. }
  6834. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  6835. /* Diplo personnelle (ex-fonction saveChamps) */
  6836. var champs = document.getElementById('diploPerso');
  6837. diploPerso = {
  6838. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  6839. Guilde: {},
  6840. Troll: {},
  6841. Monstre: {}
  6842. };
  6843. if(isMythiquesOn &&
  6844. isCouleur(document.getElementById('couleurMythiques').value)) {
  6845. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  6846. }
  6847. for(var i=0 ; i<champs.rows.length ; i++) {
  6848. if(valideChamp(champs.rows[i])) {
  6849. var type = champs.rows[i].cells[0].firstChild.value;
  6850. var num = champs.rows[i].cells[1].childNodes[1].value;
  6851. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  6852. var descr = champs.rows[i].cells[3].childNodes[1].value;
  6853. diploPerso[type][num] = {
  6854. couleur: couleur
  6855. };
  6856. if(descr) {
  6857. diploPerso[type][num].titre = descr;
  6858. }
  6859. }
  6860. }
  6861. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  6862.  
  6863. avertissement('Données sauvegardées');
  6864. }
  6865.  
  6866.  
  6867. /*-[functions]------------- Modifications de la page -------------------------*/
  6868.  
  6869. function creeTablePrincipale() {
  6870. var insertPt = document.getElementById('insertPt');
  6871. /* Titre + bouton de Sauvegarde */
  6872. var tr = insertTr(insertPt,'mh_tdtitre');
  6873. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  6874. appendButton(td,'Sauvegarder',sauvegarderTout);
  6875. /* Options fixes */
  6876. tr = insertTr(insertPt,'mh_tdpage');
  6877. td = appendTdText(tr,'Diplomatie de guilde:',true);
  6878. appendBr(td);
  6879. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  6880. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  6881. appendBr(td);
  6882. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  6883. appendText(td,'Utiliser des couleurs détaillées (10)');
  6884. /* Diplo personnelle */
  6885. tr = insertTr(insertPt,'mh_tdpage');
  6886. td = appendTdText(tr,'Diplomatie personnelle:',true);
  6887. appendBr(td);
  6888. // Diplo Mythiques
  6889. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  6890. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  6891. var span = document.createElement('span');
  6892. span.id = 'spanMythiques';
  6893. if(!isMythiquesOn) {
  6894. span.style.display = 'none';
  6895. }
  6896. var couleur = '#FFAAAA';
  6897. if(diploPerso.mythiques) {
  6898. couleur = diploPerso.mythiques;
  6899. }
  6900. appendText(span,' - couleur HTML:');
  6901. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  6902. input.onkeyup = previewCouleur;
  6903. input.onchange = previewCouleur;
  6904. input.onkeyup();
  6905. td.appendChild(span);
  6906. appendBr(td);
  6907. // Diplo éditable
  6908. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  6909. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  6910. appendBr(td);
  6911. var table = document.createElement('table');
  6912. table.id = 'diploPerso'
  6913. td.appendChild(table);
  6914. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  6915. for(var num in diploPerso[type]) {
  6916. ajouteChamp(
  6917. type,
  6918. num,
  6919. diploPerso[type][num].couleur,
  6920. diploPerso[type][num].titre
  6921. );
  6922. }
  6923. }
  6924. if(table.rows.length==0) {
  6925. ajouteChamp();
  6926. }
  6927. appendButton(td,'Ajouter',ajouteChamp)
  6928. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  6929. appendText(td,' ');
  6930. appendButton(td,
  6931. 'Exemples de couleur',
  6932. function() {
  6933. var fenetre = window.open(
  6934. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  6935. 'Divers',
  6936. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  6937. 'status=0,menubar=0,resizable=1,scrollbars=1'
  6938. );
  6939. fenetre.focus();
  6940. }
  6941. );
  6942. /* Couleur de Guilde */
  6943. tr = insertTr(insertPt,'mh_tdtitre');
  6944. td = appendTdText(tr,'GUILDE',true);
  6945. appendText(td,' - n°');
  6946. appendTextbox(td,'text','numGuilde',5,10,
  6947. diploGuilde.guilde && diploGuilde.guilde.id ?
  6948. diploGuilde.guilde.id : ''
  6949. );
  6950. appendText(td,' - Couleur HTML: ');
  6951. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  6952. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  6953. diploGuilde.guilde.couleur : '#BBBBFF'
  6954. );
  6955. input.onkeyup = previewCouleur;
  6956. input.onchange = previewCouleur;
  6957. input.onkeyup();
  6958. }
  6959.  
  6960.  
  6961. /*-[functions]----------------------- Main -----------------------------------*/
  6962.  
  6963. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  6964. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  6965. var isDetailOn = diploGuilde.isDetailOn=='true';
  6966. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  6967. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  6968. var isMythiquesOn = diploPerso.mythiques!=undefined;
  6969.  
  6970. function do_diplo() {
  6971. if(setChoixCouleurs() && fetchDiploGuilde()) {
  6972. creeTablePrincipale();
  6973. }
  6974. }
  6975.  
  6976. /*******************************************************************************
  6977. * This file is part of Mountyzilla. *
  6978. * *
  6979. * Mountyzilla is free software; you can redistribute it and/or modify *
  6980. * it under the terms of the GNU General Public License as published by *
  6981. * the Free Software Foundation; either version 2 of the License, or *
  6982. * (at your option) any later version. *
  6983. * *
  6984. * Mountyzilla is distributed in the hope that it will be useful, *
  6985. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6986. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6987. * GNU General Public License for more details. *
  6988. * *
  6989. * You should have received a copy of the GNU General Public License *
  6990. * along with Mountyzilla; if not, write to the Free Software *
  6991. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6992. *******************************************************************************/
  6993.  
  6994. // x~x cdmcomp
  6995.  
  6996. var cdm = '';
  6997.  
  6998. function getNonNegInts(str) {
  6999. var nbrs = str.match(/\d+/g);
  7000. for(var i=0 ; i<nbrs.length ; i++) {
  7001. nbrs[i] = Number(nbrs[i]);
  7002. }
  7003. return nbrs;
  7004. }
  7005.  
  7006. function traiteCdMcomp() {
  7007. try {
  7008. var msgEffet = document.getElementById('msgEffet');
  7009. } catch(e) {
  7010. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  7011. return;
  7012. }
  7013.  
  7014. // Teste si ce message du bot est un message de CdM
  7015. if(!document.evaluate(
  7016. "./p/b/text()[contains(.,'fait partie')]",
  7017. msgEffet, null, 9, null
  7018. ).singleNodeValue) {
  7019. return;
  7020. }
  7021. // Début de récupération de la CdM
  7022. cdm = document.evaluate(
  7023. "./p/b/text()[contains(.,'fait partie')]",
  7024. msgEffet, null, 9, null
  7025. ).singleNodeValue.nodeValue+'\n';
  7026. var tbody = document.evaluate(
  7027. "descendant::table/tbody",
  7028. msgEffet, null, 9, null
  7029. ).singleNodeValue;
  7030. var nomStat = document.evaluate(
  7031. "./tr/td[1]/b/text()",
  7032. tbody, null, 7, null
  7033. );
  7034. var valStat = document.evaluate(
  7035. "./tr/td[2]/descendant::text()",
  7036. tbody, null, 7, null
  7037. );
  7038. var i=0;
  7039. while(i<nomStat.snapshotLength) {
  7040. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7041. cdm += 'Armure : ';
  7042. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7043. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7044. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7045. armp = [0,armp[0]];
  7046. }
  7047. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7048. armm = [0,armm[0]];
  7049. }
  7050. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7051. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7052. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7053. } else {
  7054. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7055. }
  7056. cdm += ')\n';
  7057. i++;
  7058. } else {
  7059. cdm += nomStat.snapshotItem(i).nodeValue+
  7060. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7061. }
  7062. i++;
  7063. }
  7064. // Envoi auto ou insertion bouton envoi (suivant option)
  7065. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7066. sendInfoCDM();
  7067. var p = document.createElement('p');
  7068. p.style.color = 'green';
  7069. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7070. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7071. } else {
  7072. insertButtonCdm('as_Action', sendInfoCDM);
  7073. }
  7074.  
  7075. // Insertion de l'estimation des PV restants
  7076. var pv = valStat.snapshotItem(1).nodeValue;
  7077. if(pv.indexOf("entre")==-1) {
  7078. return;
  7079. }
  7080. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  7081. if(pv) {
  7082. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  7083. appendTdText(tr, pv[0], true);
  7084. appendTdText(tr, pv[1], true);
  7085. }
  7086. }
  7087.  
  7088. function sendInfoCDM() {
  7089. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7090. var buttonCDM = this;
  7091. var texte = '';
  7092. FF_XMLHttpRequest({
  7093. method: 'GET',
  7094. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  7095. headers : {
  7096. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7097. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7098. },
  7099. onload: function(responseDetails) {
  7100. texte = responseDetails.responseText;
  7101. buttonCDM.value = texte;
  7102. buttonCDM.disabled = true;
  7103. }
  7104. });
  7105. }
  7106.  
  7107. function do_cdmcomp() {
  7108. start_script(31);
  7109. traiteCdMcomp();
  7110. displayScriptTime();
  7111. }
  7112.  
  7113. /*********************************************************************************
  7114. * This file is part of Mountyzilla. *
  7115. * *
  7116. * Mountyzilla is free software; you can redistribute it and/or modify *
  7117. * it under the terms of the GNU General Public License as published by *
  7118. * the Free Software Foundation; either version 2 of the License, or *
  7119. * (at your option) any later version. *
  7120. * *
  7121. * Mountyzilla is distributed in the hope that it will be useful, *
  7122. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7123. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7124. * GNU General Public License for more details. *
  7125. * *
  7126. * You should have received a copy of the GNU General Public License *
  7127. * along with Mountyzilla; if not, write to the Free Software *
  7128. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7129. *********************************************************************************/
  7130.  
  7131. // x~x cmdbot
  7132.  
  7133. /* v0.2 by Dab - 2013-08-20
  7134. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7135. */
  7136.  
  7137. var buttonCDM;
  7138.  
  7139. /*******************************************************************************************
  7140. CDM :
  7141. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7142.  
  7143. Il ne vous est pas possible d'améliorer cette compétence.
  7144.  
  7145. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7146. Niveau : Inimaginable (entre 49 et 51)
  7147. Points de Vie : Surtrollesque (entre 450 et 470)
  7148. Blessure (Approximatif) : 0 %
  7149. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7150. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7151. Dés de Dégat : Très Fort (entre 18 et 20)
  7152. Dés de Régénération : Excellent (égal à 13)
  7153. Armure Physique : Moyen (entre 10 et 12)
  7154. Armure Magique : Faible (inférieur à 6)
  7155. Vue : Moyen (entre 9 et 11)
  7156. Maitrise Magique : Inimaginable (supérieur à 6000)
  7157. Résistance Magique : Inimaginable (supérieur à 6000)
  7158. Nombre d'attaques : 1
  7159. Vitesse de Déplacement : Normale
  7160. Voir le Caché : Oui
  7161. Attaque à distance : Non
  7162. Attaque magique : Oui
  7163. Vole : Non
  7164. Sang froid : Inexistant
  7165. DLA : Milieu
  7166. Durée Tour : Remarquable (entre 9 et 11)
  7167. Chargement : Vide
  7168. Bonus Malus : Aucun
  7169.  
  7170. Vous avez également gagné 1 PX pour la réussite.
  7171. *******************************************************************************************
  7172. BOT :
  7173. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7174.  
  7175. Le Monstre ciblé fait partie des : Mort-Vivant
  7176.  
  7177. Niveau : Incroyable (entre 36 et 38)
  7178. *******************************************************************************************/
  7179.  
  7180. function getNNInt(str) {
  7181. var nbrs = str.match(/\d+/g);
  7182. for (var i=0 ; i<nbrs.length ; i++)
  7183. nbrs[i] = parseInt(nbrs[i]);
  7184. return nbrs;
  7185. }
  7186.  
  7187. function sendCDM() {
  7188. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7189. document, null, 9, null).singleNodeValue;
  7190. cdm = td.innerHTML;
  7191. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7192. "$3$4 ($1 - N°$2)<br>");
  7193. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7194. 'Blessure : XX % (approximativement)');
  7195. // Supprime la décomposition P/M de l'Armure
  7196. var bgn = cdm.indexOf('Armure Physique');
  7197. if (bgn!=-1) {
  7198. var end = cdm.indexOf('Vue')-2;
  7199. var lines = cdm.substring(bgn,end).split('<br>');
  7200. var armp = getNNInt(lines[0]);
  7201. var armm = getNNInt(lines[1]);
  7202. if (lines[0].indexOf('(inf')!=-1)
  7203. armp = [0,armp[0]];
  7204. if (lines[1].indexOf('(inf')!=-1)
  7205. armm = [0,armm[0]];
  7206. var insrt = 'Armure : ';
  7207. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7208. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7209. else
  7210. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7211. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7212. }
  7213. cdm = cdm.replace(/<br>/g,'\n');
  7214. FF_XMLHttpRequest({
  7215. method: 'GET',
  7216. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  7217. headers : {
  7218. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7219. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7220. },
  7221. onload: function(responseDetails) {
  7222. buttonCDM.value=responseDetails.responseText;
  7223. buttonCDM.disabled = true;
  7224. }
  7225. });
  7226. }
  7227.  
  7228. function traiteCdMmsg() {
  7229. // Teste si ce message du bot est un message de CdM
  7230. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7231. document, null, 9, null).singleNodeValue;
  7232. if (!td) return false;
  7233. cdm = td.innerHTML;
  7234. // Insertion de l'estimation des PV restants
  7235. var des = cdm.indexOf('Dés');
  7236. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7237. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7238. if(pv)
  7239. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7240.  
  7241. // Insertion bouton envoi + espace
  7242. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7243. }
  7244.  
  7245. /*function traitePouvoir() {
  7246. // Teste si ce message du bot est un message de CdM
  7247. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7248. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7249. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7250. if (!td)
  7251. return false;
  7252. var infos = td.innerHTML;
  7253. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7254. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7255. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7256. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7257. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7258. var effetPouvoir="";
  7259. var full=false;
  7260. if(infos.indexOf("REDUIT")!=-1) {
  7261. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7262. }
  7263. else {
  7264. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7265. full=true;
  7266. }
  7267. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7268. // On insère le bouton et un espace
  7269. //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));
  7270. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7271. if(!MY_getValue('AUTOSENDPOUV'))
  7272. {
  7273. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7274. button.setAttribute("onClick", "window.open('" + url
  7275. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7276. + "this.value='Merci de votre participation'; this.disabled = true;");
  7277. }
  7278. else
  7279. {
  7280. FF_XMLHttpRequest({
  7281. method: 'GET',
  7282. url: url,
  7283. headers : {
  7284. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7285. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7286. }});
  7287. }
  7288. }*/
  7289.  
  7290. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7291. traiteCdMmsg();
  7292. }
  7293. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7294.  
  7295. /*******************************************************************************
  7296. * This file is part of Mountyzilla. *
  7297. * *
  7298. * Mountyzilla is free software; you can redistribute it and/or modify *
  7299. * it under the terms of the GNU General Public License as published by *
  7300. * the Free Software Foundation; either version 2 of the License, or *
  7301. * (at your option) any later version. *
  7302. * *
  7303. * Mountyzilla is distributed in the hope that it will be useful, *
  7304. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7305. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7306. * GNU General Public License for more details. *
  7307. * *
  7308. * You should have received a copy of the GNU General Public License *
  7309. * along with Mountyzilla; if not, write to the Free Software *
  7310. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7311. *******************************************************************************/
  7312.  
  7313. // x~x menu
  7314. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7315.  
  7316. var menuRac, mainIco;
  7317.  
  7318. // met à jour les carac sauvegardées (position, DLA, etc.)
  7319. function updateData() {
  7320. var inputs = document.getElementsByTagName('input');
  7321. var divs = document.getElementsByTagName('div');
  7322. numTroll = inputs[0].value;
  7323. MY_setValue('NUM_TROLL', numTroll);
  7324. MY_setValue('NIV_TROLL',inputs[1].value);
  7325. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7326. MY_setValue(numTroll+'.caracs.rm',0);
  7327. // assure l'init des 4 var de libs
  7328. }
  7329. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7330. var DLA = new Date(
  7331. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  7332. );
  7333. if(MY_getValue(numTroll+'.DLA.encours')) {
  7334. var DLAstockee = new Date(
  7335. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  7336. );
  7337. if(DLA>DLAstockee) {
  7338. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  7339. // Pose un pb en cas de décalage de DLA
  7340. }
  7341. }
  7342. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  7343. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  7344. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  7345. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  7346. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  7347. }
  7348.  
  7349. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7350. function initRaccourcis() {
  7351. var anotherURL = MY_getValue('URL1');
  7352. if(!anotherURL) { return; }
  7353. /* Création de l'icône faisant apparaître le menu */
  7354. mainIco = document.createElement('img');
  7355. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  7356. if(!urlIco) {
  7357. urlIco =
  7358. URL_MZimg + 'mz_logo_small.png';
  7359. }
  7360. mainIco.src = urlIco;
  7361. mainIco.alt = 'MZ';
  7362. mainIco.style = 'position:fixed; top:0px; left:0px';
  7363. mainIco.onmouseover = afficheMenu;
  7364. document.body.appendChild(mainIco);
  7365. /* Création du menu des Raccourcis */
  7366. menuRac = document.createElement('div');
  7367. menuRac.className = 'mh_textbox';
  7368. menuRac.style =
  7369. 'position:fixed; top:10px; left:10px;'+
  7370. 'max-width:190px;'+
  7371. 'border-radius: 4px; padding: 4px;'+
  7372. 'z-index: 500;'+
  7373. 'visibility: hidden;';
  7374. document.body.appendChild(menuRac);
  7375. document.addEventListener('mousemove',cacheMenu,false);
  7376. var i=1;
  7377. while(anotherURL) {
  7378. var a = document.createElement('a');
  7379. var url = MY_getValue('URL'+i);
  7380. var nom = MY_getValue('URL'+i+'.nom');
  7381. var ico = MY_getValue('URL'+i+'.ico');
  7382. a.href = url;
  7383. a.target = '_blank';
  7384. if(ico) {
  7385. var txt = nom ? nom : '';
  7386. var img = createImage(ico,txt);
  7387. a.appendChild(img);
  7388. }
  7389. else {
  7390. appendText(a,'['+nom+']');
  7391. }
  7392. menuRac.appendChild(a);
  7393. appendBr(menuRac);
  7394. i++;
  7395. anotherURL = MY_getValue('URL'+i);
  7396. }
  7397. }
  7398.  
  7399. function afficheMenu() {
  7400. menuRac.style.visibility = 'visible';
  7401. }
  7402.  
  7403. function cacheMenu(e) {
  7404. if(menuRac.style.visibility=='hidden') { return; }
  7405. // Position souris
  7406. var ptX = e.clientX;
  7407. var ptY = e.clientY;
  7408. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7409. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7410. var menuRect = menuRac.getBoundingClientRect();
  7411. var icoRect = mainIco.getBoundingClientRect();
  7412. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7413. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7414. menuRac.style.visibility = 'hidden';
  7415. }
  7416. }
  7417.  
  7418. // ajout de l'icône, branchée sur un refresh
  7419. function initUpdateCoordGauche() {
  7420. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7421. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7422. var img = document.createElement('img');
  7423. img.src = URL_MZimg + 'recycl.png'
  7424. img.onclick = function(evt) {
  7425. document.location.href = document.location.href;
  7426. };
  7427. img.title = 'Mise à jour de la localisation';
  7428. img.style.cursor = 'pointer';
  7429. img.style.position = 'absolute';
  7430. img.style.bottom = 0;
  7431. img.style.left = 0;
  7432. div.appendChild(img);
  7433. }
  7434.  
  7435. function do_menu() {
  7436. // met à jour les carac sauvegardées (position, DLA, etc.)
  7437. updateData();
  7438. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7439. initRaccourcis();
  7440. // Ajout bouton de mise à jour coordonnées
  7441. initUpdateCoordGauche();
  7442. }
  7443.  
  7444. /*******************************************************************************
  7445. * This file is part of Mountyzilla. *
  7446. * *
  7447. * Mountyzilla is free software; you can redistribute it and/or modify *
  7448. * it under the terms of the GNU General Public License as published by *
  7449. * the Free Software Foundation; either version 2 of the License, or *
  7450. * (at your option) any later version. *
  7451. * *
  7452. * Mountyzilla is distributed in the hope that it will be useful, *
  7453. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7454. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7455. * GNU General Public License for more details. *
  7456. * *
  7457. * You should have received a copy of the GNU General Public License *
  7458. * along with Mountyzilla; if not, write to the Free Software *
  7459. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7460. *******************************************************************************/
  7461.  
  7462. // x~x vue
  7463.  
  7464. /* TODO
  7465. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7466. * prévoir fix ("delete infos")
  7467. */
  7468.  
  7469. /*--------------------------- Variables Globales -----------------------------*/
  7470.  
  7471. // Infos remplies par des scripts extérieurs
  7472. var listeCDM = [], listeLevels = [];
  7473.  
  7474. // Position actuelle
  7475. var currentPosition=[0,0,0];
  7476.  
  7477. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7478. var porteeVue=[0,0,0,0];
  7479.  
  7480. // Fenêtres déplaçables
  7481. var winCurr = null;
  7482. var offsetX, offsetY;
  7483. document.onmousemove = drag;
  7484.  
  7485. // Diplomatie
  7486. var Diplo = {
  7487. Guilde: {},
  7488. Troll: {},
  7489. Monstre: {}
  7490. // .mythiques: uniquement si option activée
  7491. };
  7492. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7493.  
  7494. // Infos tactiques
  7495. var popup;
  7496.  
  7497. // Gère l'affichage en cascade des popups de CdM
  7498. var nbCDM = 0;
  7499.  
  7500. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7501.  
  7502. // Utilisé pour supprimer les monstres "engagés"
  7503. var listeEngages = {};
  7504. var isEngagesComputed = false;
  7505. var cursorOnLink = false; // DEBUG: wtf ?
  7506.  
  7507. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7508. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7509.  
  7510. // Checkboxes de filtrage
  7511. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7512. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7513. checkBoxTactique, checkBoxLevels, checkBoxGowaps, checkBoxEngages,
  7514. comboBoxNiveauMin, comboBoxNiveauMax;
  7515.  
  7516. /* Acquisition & Stockage des données de DB */
  7517. const typesAFetcher = {
  7518. 'monstres':1,
  7519. 'trolls':1,
  7520. 'tresors':1,
  7521. 'champignons':1,
  7522. 'lieux':1
  7523. }
  7524. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7525. tr_champignons = {}, tr_lieux = {};
  7526. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7527. nbChampignons = 0, nbLieux = 0;
  7528.  
  7529. function fetchData(type) {
  7530. try {
  7531. var node = document.getElementById('mh_vue_hidden_'+type);
  7532. // this = MZ.global = sandBox de travail de MZ
  7533. // On définit donc des variables MZ-globales
  7534. this['tr_'+type] = node.getElementsByTagName('tr');
  7535. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7536. } catch(e) {
  7537. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7538. }
  7539. }
  7540.  
  7541.  
  7542. /*---------------------------------- DEBUG -----------------------------------*/
  7543. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7544. var x_monstres = tr_monstres;
  7545. var x_trolls = tr_trolls;
  7546. var x_tresors = tr_tresors;
  7547. var x_champis = tr_champignons;
  7548. var x_lieux = tr_lieux;
  7549. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7550.  
  7551.  
  7552. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7553.  
  7554. function positionToString(arr) {
  7555. return arr.join(';');
  7556. }
  7557.  
  7558. function savePosition() {
  7559. // Stocke la position (à jour) de la vue pour les autres scripts
  7560. // DEBUG: Lesquels et pourquoi?
  7561. var pos = getPosition();
  7562. MY_setValue(numTroll+'.position.X',pos[0]);
  7563. MY_setValue(numTroll+'.position.Y',pos[1]);
  7564. MY_setValue(numTroll+'.position.N',pos[2]);
  7565. }
  7566.  
  7567.  
  7568. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7569. /* INFOS :
  7570. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7571. * sont identifiables via leur Name
  7572. * les tables-listings sont identifiables via l'ID du tr conteneur
  7573. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7574. */
  7575.  
  7576. /* [functions] Récup données Utilisateur */
  7577. function getPosition() {
  7578. // Pour rétrocompatibilité
  7579. return currentPosition;
  7580. }
  7581.  
  7582. function getPorteVue() {
  7583. // Pour rétrocompatibilité
  7584. return porteeVue;
  7585. }
  7586.  
  7587. function getVue() {
  7588. // Retourne [vueHpure, vueVpure]
  7589. var vues = getPorteVue();
  7590. return [ vues[0], vues[1] ];
  7591. }
  7592.  
  7593. // Roule 11/03/2016
  7594. /* [functions] Récup données monstres, trolls, etc. */
  7595. function getXxxDistance(xxx, i) {
  7596. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7597. }
  7598. function getXxxPosition(xxx, i) {
  7599. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7600. var l = tds.length;
  7601. return [
  7602. parseInt(tds[l-3].textContent),
  7603. parseInt(tds[l-2].textContent),
  7604. parseInt(tds[l-1].textContent)
  7605. ];
  7606. }
  7607.  
  7608.  
  7609. /* [functions] Récup données monstres */
  7610. function getMonstreDistance(i) {
  7611. return parseInt(tr_monstres[i].cells[0].textContent);
  7612. }
  7613.  
  7614. function getMonstreID(i) {
  7615. return tr_monstres[i].cells[2].firstChild.nodeValue;
  7616. }
  7617.  
  7618. function getMonstreIDByTR(tr) {
  7619. return tr.cells[2].firstChild.nodeValue;
  7620. }
  7621.  
  7622. function getMonstreLevelNode(i) {
  7623. return tr_monstres[i].cells[3];
  7624. }
  7625.  
  7626. function getMonstreLevel(i) {
  7627. if(!isCDMsRetrieved) return -1;
  7628. var donneesMonstre = listeCDM[getMonstreID(i)];
  7629. return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  7630. }
  7631.  
  7632. function getMonstreNomNode(i) {
  7633. try {
  7634. var td = document.evaluate(
  7635. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  7636. tr_monstres[i], null, 9, null
  7637. ).singleNodeValue;
  7638. return td;
  7639. } catch(e) {
  7640. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  7641. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  7642. }
  7643. }
  7644.  
  7645. function getMonstreNom(i) {
  7646. return getMonstreNomByTR(tr_monstres[i]);
  7647. }
  7648.  
  7649. function getMonstreNomByTR(tr) {
  7650. try {
  7651. var nom = document.evaluate(
  7652. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  7653. tr, null, 2, null
  7654. ).stringValue;
  7655. return nom;
  7656. } catch(e) {
  7657. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  7658. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  7659. }
  7660. }
  7661.  
  7662. function getMonstrePosition(i) {
  7663. var tds = tr_monstres[i].childNodes;
  7664. var l = tds.length;
  7665. return [
  7666. parseInt(tds[l-3].textContent),
  7667. parseInt(tds[l-2].textContent),
  7668. parseInt(tds[l-1].textContent)
  7669. ];
  7670. }
  7671.  
  7672. function appendMonstres(txt) {
  7673. for(var i=1; i<=nbMonstres ; i++)
  7674. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  7675. return txt;
  7676. }
  7677.  
  7678. function getMonstres() {
  7679. var vue = getVue();
  7680. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7681. }
  7682.  
  7683. function bddMonstres(start,stop) {
  7684. if(!start) { var start = 1; }
  7685. if(!stop) { var stop = nbMonstres; }
  7686. stop = Math.min(nbMonstres,stop);
  7687. var txt='';
  7688. for(var i=start ; i<=stop ; i++) {
  7689. txt += getMonstreID(i)+';'+
  7690. getMonstreNom(i)+';'+
  7691. positionToString(getMonstrePosition(i))+'\n';
  7692. }
  7693. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  7694. }
  7695.  
  7696. /* [functions] Récup données Trolls */
  7697. function getTrollDistance(i) {
  7698. return parseInt(tr_trolls[i].cells[0].textContent);
  7699. }
  7700.  
  7701. function getTrollID(i) {
  7702. return parseInt(tr_trolls[i].cells[2].textContent);
  7703. }
  7704.  
  7705. function getTrollNomNode(i) {
  7706. var isEnvoiOn =
  7707. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  7708. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  7709. }
  7710.  
  7711. function getTrollNivNode(i) {
  7712. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  7713. return tr_trolls[i].cells[4];
  7714. }
  7715.  
  7716. function getTrollGuilde(i) {
  7717. return trim(tr_trolls[i].cells[6].textContent);
  7718. }
  7719.  
  7720. function getTrollGuildeID(i) {
  7721. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  7722. var href;
  7723. try {
  7724. 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"
  7725. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  7726. } catch(e) { // debug pb remonté par Marsak
  7727. window.console.error(traceStack(e, 'getTrollGuildeID')
  7728. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  7729. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  7730. return -1;
  7731. }
  7732. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  7733. }
  7734. return -1;
  7735. }
  7736.  
  7737. function getTrollPosition(i) {
  7738. var tds = tr_trolls[i].childNodes;
  7739. var l = tds.length;
  7740. return [
  7741. parseInt(tds[l-3].textContent),
  7742. parseInt(tds[l-2].textContent),
  7743. parseInt(tds[l-1].textContent)
  7744. ];
  7745. }
  7746.  
  7747. function bddTrolls() {
  7748. var txt='#DEBUT TROLLS\n'+
  7749. numTroll+';'+positionToString(getPosition())+'\n';
  7750. for(var i=1 ; i<=nbTrolls ; i++) {
  7751. txt += getTrollID(i)+';'+
  7752. positionToString(getTrollPosition(i))+'\n';
  7753. }
  7754. return txt+'#FIN TROLLS';
  7755. }
  7756.  
  7757. /* [functions] Récup données Trésors */
  7758. function getTresorDistance(i) {
  7759. return tr_tresors[i].cells[0].firstChild.nodeValue;
  7760. }
  7761.  
  7762. function getTresorID(i) {
  7763. return trim(tr_tresors[i].cells[2].textContent);
  7764. }
  7765.  
  7766. function getTresorNom(i) {
  7767. // Utilisation de textContent pour régler le "bug de Pollux"
  7768. return trim(tr_tresors[i].cells[3].textContent);
  7769. }
  7770.  
  7771. function getTresorPosition(i) {
  7772. var tds = tr_tresors[i].childNodes;
  7773. var l = tds.length;
  7774. return [
  7775. parseInt(tds[l-3].textContent),
  7776. parseInt(tds[l-2].textContent),
  7777. parseInt(tds[l-1].textContent),
  7778. ];
  7779. }
  7780.  
  7781. function bddTresors(dmin,start,stop) {
  7782. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  7783. if(!dmin) { var dmin = 0; }
  7784. if(!start) { var start = 1; }
  7785. if(!stop) { var stop = nbTresors; }
  7786. stop = Math.min(nbTresors,stop);
  7787. var txt='';
  7788. for(var i=start ; i<=stop ; i++) {
  7789. if(getTresorDistance(i)>=dmin) {
  7790. txt += getTresorID(i)+';'+
  7791. getTresorNom(i)+';'+
  7792. positionToString(getTresorPosition(i))+'\n';
  7793. }
  7794. }
  7795. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  7796. }
  7797.  
  7798. /* [functions] Récup données Champignons */
  7799. // DEBUG: Pas de colonne "Référence" sur serveur de test
  7800. function getChampignonNom(i) {
  7801. return trim(tr_champignons[i].cells[2].textContent);
  7802. }
  7803.  
  7804. function getChampignonPosition(i) {
  7805. var tds = tr_champignons[i].childNodes;
  7806. var l = tds.length;
  7807. return [
  7808. parseInt(tds[l-3].textContent),
  7809. parseInt(tds[l-2].textContent),
  7810. parseInt(tds[l-1].textContent)
  7811. ];
  7812. }
  7813.  
  7814. function bddChampignons() {
  7815. var txt='';
  7816. for(var i=1 ; i<=nbChampignons ; i++) {
  7817. txt += ';'+ // Les champis n'ont pas de Référence
  7818. getChampignonNom(i)+';'+
  7819. positionToString(getChampignonPosition(i))+'\n';
  7820. }
  7821. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  7822. }
  7823.  
  7824. /* [functions] Récup données Lieux */
  7825. function getLieuDistance(i) {
  7826. return parseInt(tr_lieux[i].cells[0].textContent);
  7827. }
  7828.  
  7829. function getLieuID(i) {
  7830. return parseInt(tr_lieux[i].cells[2].textContent);
  7831. }
  7832.  
  7833. function getLieuNom(i) {
  7834. // Conversion ASCII pour éviter les bugs des Vues externes
  7835. return trim(tr_lieux[i].cells[3].textContent);
  7836. }
  7837.  
  7838. function getLieuPosition(i) {
  7839. var tds = tr_lieux[i].childNodes;
  7840. var l = tds.length;
  7841. return [
  7842. parseInt(tds[l-3].textContent),
  7843. parseInt(tds[l-2].textContent),
  7844. parseInt(tds[l-1].textContent)
  7845. ];
  7846. }
  7847.  
  7848. function appendLieux(txt) {
  7849. for(var i = 1; i < nbLieux+1; i++) {
  7850. var tds = x_lieux[i].childNodes;
  7851. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  7852. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  7853. }
  7854. return txt;
  7855. }
  7856.  
  7857. function getLieux() {
  7858. var vue = getVue();
  7859. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7860. }
  7861.  
  7862. function bddLieux(start,stop) {
  7863. if(!start) { var start = 1; }
  7864. if(!stop) { var stop = nbLieux; }
  7865. stop = Math.min(nbLieux,stop);
  7866. var txt='';
  7867. for(var i=start ; i<=stop ; i++) {
  7868. txt += getLieuID(i)+';'+
  7869. epure(getLieuNom(i))+';'+
  7870. positionToString(getLieuPosition(i))+'\n';
  7871. }
  7872. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  7873. }
  7874.  
  7875.  
  7876. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  7877.  
  7878. function saveCheckBox(chkbo, pref) {
  7879. // Enregistre et retourne l'état d'une CheckBox
  7880. var etat = chkbo.checked;
  7881. MY_setValue(pref, etat ? 'true' : 'false' );
  7882. return etat;
  7883. }
  7884.  
  7885. function recallCheckBox(chkbox, pref) {
  7886. // Restitue l'état d'une CheckBox
  7887. chkbox.checked = (MY_getValue(pref)=='true');
  7888. }
  7889.  
  7890. function saveComboBox(cbb, pref) {
  7891. // Enregistre et retourne l'état d'une ComboBox
  7892. var etat = cbb.selectedIndex;
  7893. MY_setValue(pref, etat);
  7894. return etat;
  7895. }
  7896.  
  7897. function recallComboBox(cbb, pref) {
  7898. // Restitue l'état d'une ComboBox
  7899. var nb = MY_getValue(pref);
  7900. if(nb) cbb.value = nb;
  7901. return nb;
  7902. }
  7903.  
  7904. function synchroniseFiltres() {
  7905. // Récupération de toutes les options de la vue
  7906. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  7907. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  7908. if(numBool) {
  7909. debutFiltrage('Monstres');
  7910. }
  7911. recallCheckBox(checkBoxGowaps,'NOGOWAP');
  7912. recallCheckBox(checkBoxMythiques,'NOMYTH');
  7913. recallCheckBox(checkBoxEngages,'NOENGAGE');
  7914. recallCheckBox(checkBoxLevels,'NOLEVEL');
  7915. recallCheckBox(checkBoxIntangibles,'NOINT');
  7916. recallCheckBox(checkBoxGG,'NOGG');
  7917. recallCheckBox(checkBoxCompos,'NOCOMP');
  7918. recallCheckBox(checkBoxBidouilles,'NOBID');
  7919. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  7920. recallCheckBox(checkBoxTrou,'NOTROU');
  7921. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  7922. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  7923. if(MY_getValue('NOINFOEM')!='true')
  7924. recallCheckBox(checkBoxEM,'NOEM');
  7925. }
  7926.  
  7927.  
  7928. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  7929.  
  7930. /* [functions] Menu Vue 2D */
  7931. var vue2Ddata = {
  7932. 'Bricol\' Vue': {
  7933. url: URL_bricol_mountyhall + 'vue_form.php',
  7934. paramid: 'vue',
  7935. func: getVueScript,
  7936. extra_params: {
  7937. 'mode': 'vue_SP_Vue2',
  7938. 'screen_width': window.screen.width
  7939. }
  7940. },
  7941. 'Vue du CCM': {
  7942. url: URL_vue_CCM,
  7943. paramid: 'vue',
  7944. func: getVueScript,
  7945. extra_params: {
  7946. 'id': numTroll+';'+positionToString(getPosition())
  7947. }
  7948. },
  7949. 'Vue Gloumfs 2D': {
  7950. url: URL_vue_Gloumfs2D,
  7951. paramid: 'vue_mountyzilla',
  7952. func: getVueScript,
  7953. extra_params: {}
  7954. },
  7955. 'Vue Gloumfs 3D': {
  7956. url: URL_vue_Gloumfs3D,
  7957. paramid: 'vue_mountyzilla',
  7958. func: getVueScript,
  7959. extra_params: {}
  7960. },
  7961. 'Grouky Vue!': {
  7962. url: URL_vue_Grouky,
  7963. paramid: 'vue',
  7964. func: getVueScript,
  7965. extra_params: {
  7966. 'type_vue': 'V5b1'
  7967. }
  7968. },
  7969. /*'DEBUG': {
  7970. url: 'http://weblocal/testeur.php',
  7971. paramid: 'vue',
  7972. func: getVueScript,
  7973. extra_params: {}
  7974. }*/
  7975. };
  7976.  
  7977. function getVueScript() {
  7978. try {
  7979. var txt = bddTrolls()+
  7980. bddMonstres()+
  7981. bddChampignons()+
  7982. bddTresors()+
  7983. bddLieux()+
  7984. '#DEBUT ORIGINE\n'+
  7985. getPorteVue()[2]+';'+positionToString(getPosition())+
  7986. '\n#FIN ORIGINE\n';
  7987. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  7988. return txt;
  7989. } catch(e) {
  7990. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  7991. window.console.error(traceStack(e, 'getVueScript'))
  7992. }
  7993. }
  7994.  
  7995. function refresh2DViewButton() {
  7996. // = EventListener menu+bouton vue 2D
  7997. var vueext = document.getElementById('selectVue2D').value;
  7998. MY_setValue('VUEEXT',vueext);
  7999. var form = document.getElementById('viewForm');
  8000. form.innerHTML = '';
  8001. form.method = 'post';
  8002. form.action = vue2Ddata[vueext].url;
  8003. form.target = '_blank';
  8004. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8005. for(var key in vue2Ddata[vueext].extra_params) {
  8006. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8007. }
  8008. appendSubmit(form, 'Voir',
  8009. function() {
  8010. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8011. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8012. vue2Ddata[vueext].func();
  8013. }
  8014. );
  8015. }
  8016.  
  8017. function set2DViewSystem() {
  8018. // Initialise le système de vue 2D
  8019. // Recherche du point d'insertion
  8020. try {
  8021. var center = document.evaluate(
  8022. "//h2[@id='titre2']/following-sibling::center",
  8023. document, null, 9, null
  8024. ).singleNodeValue;
  8025. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8026. if (!center) center = document.evaluate(
  8027. "//h2[@id='titre2']/following-sibling::div",
  8028. document, null, 9, null
  8029. ).singleNodeValue;
  8030. } catch(e) {
  8031. avertissement("Erreur d'initialisation du système de vue 2D");
  8032. window.console.error(traceStack(e, 'set2DViewSystem'));
  8033. return;
  8034. }
  8035. // Récupération de la dernière vue utilisée
  8036. var vueext = MY_getValue('VUEEXT');
  8037. if(!vueext || !vue2Ddata[vueext]) {
  8038. // sinon, la vue Bricol'Trolls est employée par défaut
  8039. vueext = 'Bricol\' Vue';
  8040. }
  8041. try {
  8042. // Création du sélecteur de vue externe
  8043. selectVue2D = document.createElement('select');
  8044. selectVue2D.id = 'selectVue2D';
  8045. selectVue2D.className = 'SelectboxV2';
  8046. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  8047. for(var view in vue2Ddata) {
  8048. appendOption(selectVue2D, view, view);
  8049. }
  8050. selectVue2D.value = vueext;
  8051. selectVue2D.onchange = refresh2DViewButton;
  8052. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8053. var form = document.createElement('form');
  8054. form.id = 'viewForm';
  8055. // Insertion du système de vue
  8056. var table = document.createElement('table');
  8057. var tr = appendTr(table);
  8058. var td = appendTd(tr);
  8059. td.appendChild(selectVue2D);
  8060. td = appendTd(tr);
  8061. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8062. td.appendChild(form);
  8063. center.insertBefore(table,center.firstChild);
  8064. insertBr(center.childNodes[1]);
  8065. // Appelle le handler pour initialiser le bouton de submit
  8066. refresh2DViewButton();
  8067. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8068. } catch(e) {
  8069. avertissement("Erreur de traitement du système de vue 2D");
  8070. window.console.error(traceStack(e, 'set2DViewSystem'));
  8071. }
  8072. }
  8073.  
  8074. /* [functions] Tableau d'Infos */
  8075. function initialiseInfos() {
  8076. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8077. var
  8078. infoTab = document.getElementsByName('LimitViewForm')[0].
  8079. getElementsByTagName('table')[0],
  8080. tbody = infoTab.tBodies[0],
  8081. thead = infoTab.createTHead(),
  8082. tr = appendTr(thead,'mh_tdtitre'),
  8083. td = appendTdText(tr,'INFORMATIONS',true),
  8084. span = document.createElement('span');
  8085. // Récupération de la position du joueur
  8086. try {
  8087. var strPos = document.evaluate(
  8088. ".//li/b/text()[contains(.,'X = ')]",
  8089. infoTab, null, 9, null
  8090. ).singleNodeValue.nodeValue;
  8091. // ***INIT GLOBALE*** currentPosition
  8092. currentPosition = getNumbers(strPos);
  8093. debugMZ("retrievePosition(): "+currentPosition);
  8094. } catch(e) {
  8095. // Si on ne trouve pas le "X ="
  8096. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8097. }
  8098. // Récupération des portées (max et limitée) de la vue
  8099. try {
  8100. var
  8101. nodes = document.evaluate(
  8102. ".//li/b/text()[contains(.,'horizontalement') "+
  8103. "or contains(.,'verticalement')]",
  8104. infoTab, null, 7, null
  8105. ),
  8106. array = [];
  8107. for(var i=0 ; i<4 ; i++) {
  8108. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8109. }
  8110. // ***INIT GLOBALE*** porteeVue
  8111. porteeVue = array;
  8112. } catch(e) {
  8113. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8114. }
  8115.  
  8116. infoTab.id = 'infoTab'; // Pour scripts externes
  8117. tbody.id = 'corpsInfoTab';
  8118. tbody.rows[0].cells[0].colSpan = 2;
  8119. td.colSpan = 3;
  8120. td.onmouseover = function() {
  8121. this.style.cursor = 'pointer';
  8122. this.className = 'mh_tdpage';
  8123. };
  8124. td.onmouseout = function() {
  8125. this.className = 'mh_tdtitre';
  8126. };
  8127. td.onclick = function() {
  8128. toggleTableauInfos(false);
  8129. };
  8130. span.id = 'msgInfoTab';
  8131. span.style.display = 'none';
  8132. appendText(
  8133. span,
  8134. ' => Position : X = '+currentPosition[0]+
  8135. ', Y = '+currentPosition[1]+
  8136. ', N = '+currentPosition[2]+
  8137. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8138. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8139. true
  8140. );
  8141. td.appendChild(span);
  8142. tr = appendTr(tbody,'mh_tdpage');
  8143. td = appendTdText(tr,'EFFACER : ',true);
  8144. td.align = 'center';
  8145. td.className = 'mh_tdtitre';
  8146. td.width = 100;
  8147. td = appendTdCenter(tr,2);
  8148. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8149. checkBoxGG = appendCheckBoxSpan(
  8150. td,'delgg',filtreTresors," Les GG'"
  8151. ).firstChild;
  8152. checkBoxCompos = appendCheckBoxSpan(
  8153. td,'delcomp',filtreTresors,' Les Compos'
  8154. ).firstChild;
  8155. checkBoxBidouilles = appendCheckBoxSpan(
  8156. td,'delbid',filtreTresors,' Les Bidouilles'
  8157. ).firstChild;
  8158. checkBoxIntangibles = appendCheckBoxSpan(
  8159. td,'delint',filtreTrolls,' Les Intangibles'
  8160. ).firstChild;
  8161. checkBoxGowaps = appendCheckBoxSpan(
  8162. td,'delgowap',filtreMonstres,' Les Gowaps'
  8163. ).firstChild;
  8164. checkBoxEngages = appendCheckBoxSpan(
  8165. td,'delengage',filtreMonstres,' Les Engagés'
  8166. ).firstChild;
  8167. checkBoxLevels = appendCheckBoxSpan(
  8168. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8169. ).firstChild;
  8170. checkBoxDiplo = appendCheckBoxSpan(
  8171. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8172. ).firstChild;
  8173. checkBoxTrou = appendCheckBoxSpan(
  8174. td,'deltrou',filtreLieux,' Les Trous'
  8175. ).firstChild;
  8176. checkBoxMythiques = appendCheckBoxSpan(
  8177. td,'delmyth',filtreMonstres,' Les Mythiques'
  8178. ).firstChild;
  8179. if(MY_getValue('NOINFOEM')!='true') {
  8180. checkBoxEM = appendCheckBoxSpan(
  8181. td,'delem',filtreMonstres,' Les Composants EM'
  8182. ).firstChild;
  8183. }
  8184. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8185. td,'deltres',filtreTresors,' Les Trésors non libres'
  8186. ).firstChild;
  8187. checkBoxTactique = appendCheckBoxSpan(
  8188. td,'deltactique',updateTactique,' Les Infos tactiques'
  8189. ).firstChild;
  8190. if(MY_getValue('INFOPLIE')) {
  8191. toggleTableauInfos(true);
  8192. }
  8193. }
  8194.  
  8195. function toggleTableauInfos(firstRun) {
  8196. var
  8197. msg = document.getElementById('msgInfoTab'),
  8198. corps = document.getElementById('corpsInfoTab'),
  8199. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8200. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8201. if(!firstRun) {
  8202. infoplie = !infoplie;
  8203. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8204. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8205. }
  8206. if(infoplie) {
  8207. msg.style.display = '';
  8208. corps.style.display = 'none';
  8209. } else {
  8210. msg.style.display = 'none';
  8211. corps.style.display = '';
  8212. }
  8213. }
  8214.  
  8215. /* [functions] Filtres */
  8216. function prepareFiltrage(ref,width) {
  8217. // = Initialise le filtre 'ref'
  8218. try {
  8219. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8220. } catch(e) {
  8221. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8222. return false;
  8223. }
  8224. if(width) { tdTitre.width = width; }
  8225. // Ajout du tr de Filtrage (masqué)
  8226. var tbody = tdTitre.parentNode.parentNode;
  8227. var tr = appendTr(tbody,'mh_tdpage');
  8228. tr.style.display = 'none';
  8229. tr.id = 'trFiltre'+ref;
  8230. var td = appendTd(tr);
  8231. td.colSpan = 5;
  8232. // Ajout du bouton de gestion de Filtrage
  8233. var tdBtn = insertTd(tdTitre.nextSibling);
  8234. tdBtn.id = 'tdInsert'+ref;
  8235. var btn = appendButton(tdBtn,'Filtrer');
  8236. btn.id = 'btnFiltre'+ref;
  8237. btn.onclick = function() {
  8238. debutFiltrage(ref)
  8239. };
  8240. return td;
  8241. }
  8242.  
  8243. function debutFiltrage(ref) {
  8244. // = Handler de début de filtrage (filtre 'ref')
  8245. document.getElementById('trFiltre'+ref).style.display = '';
  8246. var btn = document.getElementById('btnFiltre'+ref);
  8247. btn.value = 'Annuler Filtre';
  8248. btn.onclick = function() {
  8249. finFiltrage(ref);
  8250. };
  8251. }
  8252.  
  8253. function finFiltrage(ref) {
  8254. // = Handler de fin de filtrage (filtre 'ref')
  8255. /* On réassigne le bouton 'Filtrer' */
  8256. document.getElementById('trFiltre'+ref).style.display = 'none';
  8257. var btn = document.getElementById('btnFiltre'+ref);
  8258. btn.value = 'Filtrer';
  8259. btn.onclick = function() {
  8260. debutFiltrage(ref);
  8261. };
  8262. /* Réinitialisation filtres */
  8263. document.getElementById('str'+ref).value = '';
  8264. switch(ref) {
  8265. case 'Monstres':
  8266. document.getElementById('nivMinMonstres').value = 0;
  8267. document.getElementById('nivMaxMonstres').value = 0;
  8268. break;
  8269. case 'Trolls':
  8270. document.getElementById('strGuildes').value = '';
  8271. }
  8272. /* Nettoyage (=lance le filtre) */
  8273. // Ici this = MZ.global = sandBox de travail de MZ
  8274. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  8275. //this['filtre'+ref]();
  8276. switch (ref) {
  8277. case 'Monstres':
  8278. filtreMonstres();
  8279. break;
  8280. case 'Trolls':
  8281. filtreTrolls();
  8282. break;
  8283. case 'Tresors':
  8284. filtreTresors();
  8285. break;
  8286. case 'Lieux':
  8287. filtreLieux();
  8288. break;
  8289. default:
  8290. window.console.log('cas incongru dans finFiltrage : ' + ref);
  8291. break;
  8292. }
  8293. }
  8294.  
  8295. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  8296. var bouton = appendButton(td,nomBouton,onClick);
  8297. appendText(td,'\u00a0');
  8298. var textbox = appendTextbox(td,'text',id,15,30);
  8299. textbox.onkeypress = function(event) {
  8300. try {
  8301. if(event.keyCode==13) {
  8302. event.preventDefault();
  8303. bouton.click();
  8304. }
  8305. }
  8306. catch(e){
  8307. window.alert(e)
  8308. }
  8309. };
  8310. }
  8311.  
  8312. function ajoutFiltreMenu(tr,id,onChange) {
  8313. var select = document.createElement('select');
  8314. select.id = id;
  8315. select.onchange = onChange;
  8316. appendOption(select,0,'Aucun');
  8317. for(var i=1 ; i<=60 ; i++) {
  8318. appendOption(select,i,i);
  8319. }
  8320. tr.appendChild(select);
  8321. return select;
  8322. }
  8323.  
  8324. function ajoutDesFiltres() {
  8325. /* Monstres */
  8326. var td = prepareFiltrage('Monstres',120);
  8327. if(td) {
  8328. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  8329. appendText(td,'\u00a0\u00a0\u00a0');
  8330. appendText(td,'Niveau Min: ');
  8331. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  8332. appendText(td,'\u00a0');
  8333. appendText(td,'Niveau Max: ');
  8334. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  8335. }
  8336. /* Trõlls */
  8337. td = prepareFiltrage('Trolls',50);
  8338. if(td) {
  8339. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  8340. appendText(td,'\u00a0\u00a0\u00a0');
  8341. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  8342. }
  8343. /* Trésors */
  8344. td = prepareFiltrage('Tresors',55);
  8345. if(td) {
  8346. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  8347. }
  8348. /* Lieux */
  8349. td = prepareFiltrage('Lieux',40);
  8350. if(td) {
  8351. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  8352. }
  8353. }
  8354.  
  8355. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  8356.  
  8357. /* [functions] Affichage de la colonne des niveaux */
  8358. function insertLevelColumn() {
  8359. // Déclenché si bascule vers affichage des niveaux des mobs
  8360. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8361. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  8362. td.width = 25;
  8363. for(var i=1 ; i<=nbMonstres ; i++) {
  8364. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8365. td = insertTdText(getMonstreLevelNode(i), '-');
  8366. td.onclick = function() {
  8367. basculeCDM(
  8368. getMonstreNomByTR(this.parentNode),
  8369. getMonstreIDByTR(this.parentNode)
  8370. );
  8371. };
  8372. td.onmouseover = function() {
  8373. this.style.cursor = 'pointer';
  8374. this.className = 'mh_tdtitre';
  8375. };
  8376. td.onmouseout = function() {
  8377. if(this.parentNode.diploActive=='oui') {
  8378. this.className = '';
  8379. } else {
  8380. this.className = 'mh_tdpage';
  8381. }
  8382. };
  8383. td.style = 'font-weight:bold;text-align:center;';
  8384. if(isCDMsRetrieved) {
  8385. // Rappel des niveaux si mémorisés
  8386. td.innerHTML = listeLevels[i];
  8387. }
  8388. }
  8389. }
  8390.  
  8391. function toggleLevelColumn() {
  8392. // = Handler checkBox noLevel
  8393. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8394. insertLevelColumn();
  8395. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8396. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8397. for(var i=0 ; i<=nbMonstres ; i++) {
  8398. if(isCDMsRetrieved) {
  8399. // Mémorisation des niveaux pour rappel éventuel
  8400. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8401. }
  8402. // Suppression du td Niveau
  8403. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8404. }
  8405. }
  8406. }
  8407.  
  8408. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8409. function basculeCDM(nom,id) {
  8410. // = Bascule l'affichage des popups CdM
  8411. if(listeCDM[id]) {
  8412. if(!document.getElementById('popupCDM'+id)) {
  8413. afficherCDM(nom, id);
  8414. } else {
  8415. cacherPopupCDM('popupCDM'+id);
  8416. }
  8417. }
  8418. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8419. }
  8420.  
  8421. function cacherPopupCDM(titre) {
  8422. var popup = document.getElementById(titre);
  8423. popup.parentNode.removeChild(popup);
  8424. }
  8425.  
  8426. /* DEBUG: Section à mettre à jour */
  8427. var selectionFunction;
  8428.  
  8429. function startDrag(evt) {
  8430. winCurr = this.parentNode;
  8431. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8432. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8433. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8434. selectionFunction = document.body.style.MozUserSelect;
  8435. document.body.style.MozUserSelect = 'none';
  8436. winCurr.style.MozUserSelect = 'none';
  8437. return false;
  8438. }
  8439.  
  8440. function stopDrag(evt) {
  8441. winCurr.style.MozUserSelect = selectionFunction;
  8442. document.body.style.MozUserSelect = selectionFunction;
  8443. winCurr = null;
  8444. }
  8445.  
  8446. function drag(evt) {
  8447. if(winCurr==null) { return; }
  8448. evt = evt || window.event;
  8449. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8450. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8451. return false;
  8452. }
  8453. /* FIN DEBUG */
  8454.  
  8455. function afficherCDM(nom,id) {
  8456. // Crée la table de CdM du mob n° id
  8457. var donneesMonstre = listeCDM[id];
  8458. /* Début création table */
  8459. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8460. table.id = 'popupCDM'+id;
  8461. table.style =
  8462. 'position:fixed;'+
  8463. 'z-index:1;'+
  8464. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8465. 'left:'+(window.innerWidth-365)+'px;'+
  8466. 'width:300px;'+
  8467. 'height:200px;';
  8468. /* Ajout du titre avec gestion Drag & Drop */
  8469. var tr = table.firstChild;
  8470. tr.style.cursor = 'move';
  8471. tr.onmousedown = startDrag;
  8472. tr.onmouseup = stopDrag;
  8473. /* Ajout du bouton "Fermer" */
  8474. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8475. tr.onmouseover = function() {
  8476. this.style.cursor = 'pointer';
  8477. this.className = 'mh_tdpage';
  8478. };
  8479. tr.onmouseout = function() {
  8480. this.className = 'mh_tdtitre';
  8481. };
  8482. tr.idcdm = id;
  8483. tr.onclick = function() {
  8484. cacherPopupCDM('popupCDM'+this.idcdm);
  8485. this.className = 'mh_tdtitre';
  8486. };
  8487. td = appendTdText(tr,'Fermer',true);
  8488. td.colSpan = 2;
  8489. td.style = 'text-align:center;';
  8490. nbCDM++;
  8491. /* Fin création table & Affichage */
  8492. document.body.appendChild(table);
  8493. }
  8494.  
  8495. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8496. function initPopupVue() {
  8497. popup = document.createElement('div');
  8498. popup.id = 'popup';
  8499. popup.className = 'mh_textbox';
  8500. popup.style =
  8501. 'position: absolute;'+
  8502. 'border: 1px solid #000000;'+
  8503. 'visibility: hidden;'+
  8504. 'display: inline;'+
  8505. 'z-index: 3;'+
  8506. 'max-width: 400px;';
  8507. document.body.appendChild(popup);
  8508. }
  8509.  
  8510. // roule 16/03/2016 supprimé, existe déjà dans vue
  8511. // function showPopupTactique(evt) {
  8512. // var id = this.id;
  8513. // var nom = this.nom;
  8514. // var texte = getAnalyseTactique(id,nom);
  8515. // if(texte=='') { return; }
  8516. // popup.innerHTML = texte;
  8517. // popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  8518. // popup.style.top = (evt.pageY+15)+'px';
  8519. // popup.style.visibility = 'visible';
  8520. // }
  8521.  
  8522. // roule 16/03/2016, existe déjà ailleurs
  8523. // function hidePopup() {
  8524. // popup.style.visibility = 'hidden';
  8525. // }
  8526.  
  8527. /* [functions] Récupération / Computation des Infos Tactiques */
  8528. // TODO à revoir
  8529. function retireMarquage(nom) {
  8530. var i = nom.indexOf(']');
  8531. switch(i) {
  8532. case -1:
  8533. case nom.length-1:
  8534. return nom;
  8535. default:
  8536. return nom.slice(0,i+1);
  8537. }
  8538. }
  8539.  
  8540. function showPopupError(sHTML) {
  8541. var divpopup = document.createElement('div');
  8542. divpopup.id = 'divpopup';
  8543. divpopup.style =
  8544. 'position: fixed;'+
  8545. 'border: 3px solid #000000;'+
  8546. 'top: 300px;left: 10px;'+
  8547. 'background-color: red;'+
  8548. 'color: white;'+
  8549. 'font-size: xx-large;'+
  8550. 'z-index: 200;';
  8551. divpopup.innerHTML = sHTML;
  8552. var divcroix = document.createElement('div');
  8553. divcroix.style =
  8554. 'position: absolute;'+
  8555. 'top: 0;right: 0;'+
  8556. 'color: inherit;'+
  8557. 'font-size: inherit;'+
  8558. 'cursor: pointer;'+
  8559. 'z-index: 201;';
  8560. divcroix.innerHTML = "X";
  8561. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8562. document.body.appendChild(divpopup);
  8563. divpopup.appendChild(divcroix);
  8564. }
  8565.  
  8566. function retrieveCDMs() {
  8567. // Récupère les CdM disponibles dans la BDD
  8568. // Lancé uniquement sur toggleLevelColumn
  8569. if(checkBoxLevels.checked) { return; }
  8570. var str = '';
  8571. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8572. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8573. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8574. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  8575. for(var i=1 ; i<=cdmMax ; i++) {
  8576. var nomMonstre = retireMarquage(getMonstreNom(i));
  8577. if(nomMonstre.indexOf(']') != -1) {
  8578. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  8579. }
  8580. // *** WARNING : PROXY RATIBUS ***
  8581. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  8582. str += 'nom[]='+escape(nomMonstre)+'$'+(
  8583. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  8584. )+'&';
  8585. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  8586. FF_XMLHttpRequest({
  8587. method: 'POST',
  8588. url: URL_MZinfoMonstre,
  8589. headers : {
  8590. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8591. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8592. 'Content-type':'application/x-www-form-urlencoded'
  8593. },
  8594. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  8595. onload: function(responseDetails) {
  8596. try {
  8597. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  8598. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  8599. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  8600. '" target="raistlin">Mountyzilla - https<br />'+
  8601. 'Tu dois accepter le certificat de Raistlin<br />'+
  8602. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  8603. ' « Confirmer l\'exception de sécurité »</a>');
  8604. return;
  8605. }
  8606. var texte = responseDetails.responseText;
  8607. var lines = texte.split('\n');
  8608. if(lines.length==0) { return; }
  8609. var begin2, end2, index;
  8610. for(var j=0 ; j<lines.length ; j++) {
  8611. var infos = lines[j].split(';');
  8612. if(infos.length<4) { continue; }
  8613. var idMonstre=infos[0];
  8614. var isCDM = infos[1];
  8615. index = parseInt(infos[2]);
  8616. var level = infos[3];
  8617. infos = infos.slice(3);
  8618. if(begin2==null) { begin2 = index; }
  8619. end2 = index;
  8620. listeCDM[idMonstre] = infos;
  8621. if(isCDM==1) {
  8622. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  8623. } else {
  8624. getMonstreLevelNode(index).innerHTML = level;
  8625. }
  8626. }
  8627. computeMission(begin2,end2);
  8628. } catch(e) {
  8629. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  8630. }
  8631. }
  8632. });
  8633. str = '';
  8634. begin = i+1;
  8635. }
  8636. }
  8637. isCDMsRetrieved=true;
  8638. }
  8639.  
  8640. function computeMission(begin,end) {
  8641. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  8642. computeVLC(begin,end);
  8643. if(!begin) begin=1;
  8644. if(!end) end=nbMonstres;
  8645. var str = MY_getValue(numTroll+'.MISSIONS');
  8646. if(!str) { return; }
  8647. var urlImg = URL_MZimg+'mission.png';
  8648. var obMissions = JSON.parse(str);
  8649. for(var i=end ; i>=begin ; i--) {
  8650. var mess = '';
  8651. for(var num in obMissions) {
  8652. var mobMission = false;
  8653. switch(obMissions[num].type) {
  8654. case 'Race':
  8655. var race = epure(obMissions[num].race.toLowerCase());
  8656. var nom = epure(getMonstreNom(i).toLowerCase());
  8657. if(nom.indexOf(race)!=-1) {
  8658. mobMission = true;
  8659. }
  8660. break;
  8661. case 'Niveau':
  8662. var donneesMonstre = listeCDM[getMonstreID(i)];
  8663. if(donneesMonstre) {
  8664. var nivMob = Number(donneesMonstre[0]);
  8665. var nivMimi = Number(obMissions[num].niveau),
  8666. mod = obMissions[num].mod;
  8667. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  8668. || (isNaN(mod) && nivMob>=nivMimi)) {
  8669. mobMission = true;
  8670. }
  8671. }
  8672. break;
  8673. case 'Famille':
  8674. var donneesMonstre = listeCDM[getMonstreID(i)];
  8675. if(donneesMonstre) {
  8676. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  8677. var familleMob = epure(donneesMonstre[1].toLowerCase());
  8678. if(familleMob.indexOf(familleMimi)!=-1) {
  8679. mobMission = true;
  8680. }
  8681. }
  8682. break;
  8683. case 'Pouvoir':
  8684. var donneesMonstre = listeCDM[getMonstreID(i)];
  8685. if(donneesMonstre) {
  8686. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  8687. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  8688. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8689. mobMission = true;
  8690. }
  8691. }
  8692. }
  8693. if(mobMission) {
  8694. mess += mess ? '\n\n' : '';
  8695. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8696. }
  8697. }
  8698. if(mess) {
  8699. var td = getMonstreNomNode(i);
  8700. appendText(td,' ');
  8701. td.appendChild(createImage(urlImg,mess));
  8702. }
  8703. }
  8704. }
  8705.  
  8706. function computeVLC(begin,end) {
  8707. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8708. computeTactique(begin,end);
  8709. if(!begin) begin=1;
  8710. if(!end) end=nbMonstres;
  8711. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8712. if(!cache)
  8713. return false;
  8714. var urlImg = URL_MZimg + "oeil.png";
  8715. for(var i = end; i >= begin;i--)
  8716. {
  8717. var id = getMonstreID(i);
  8718. var donneesMonstre = listeCDM[id];
  8719. if(donneesMonstre && donneesMonstre.length>12)
  8720. {
  8721. if(donneesMonstre[12]==1)
  8722. {
  8723. var td = getMonstreNomNode(i);
  8724. td.appendChild(document.createTextNode(" "));
  8725. td.appendChild(createImage(urlImg, "Voit le caché"));
  8726. }
  8727. }
  8728. }
  8729. }
  8730.  
  8731. function computeTactique(begin, end) {
  8732. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8733. try {
  8734. if(!begin) begin = 1;
  8735. if(!end) end = nbMonstres;
  8736. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8737. if(noTactique || !isProfilActif()) return;
  8738. for(var j=end ; j>=begin ; j--) {
  8739. var id = getMonstreID(j);
  8740. var nom = getMonstreNom(j);
  8741. var donneesMonstre = listeCDM[id];
  8742. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8743. var td = getMonstreNomNode(j);
  8744. appendText(td,' ');
  8745. td.appendChild(
  8746. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  8747. );
  8748. }
  8749. }
  8750. }
  8751. catch(e) {
  8752. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8753. }
  8754. filtreMonstres();
  8755. }
  8756.  
  8757. function updateTactique() {
  8758. // = Handler checkBox noTactique
  8759. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8760. if(!isCDMsRetrieved) return;
  8761. if(noTactique) {
  8762. for(var i=nbMonstres ; i>0 ; i--) {
  8763. var tr = getMonstreNomNode(i);
  8764. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  8765. tr, null, 9, null).singleNodeValue;
  8766. if(img) {
  8767. img.parentNode.removeChild(img.previousSibling);
  8768. img.parentNode.removeChild(img);
  8769. }
  8770. }
  8771. }
  8772. else
  8773. computeTactique();
  8774. }
  8775.  
  8776. function filtreMonstres() {
  8777. // = Handler universel pour les fonctions liées aux monstres
  8778. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  8779. urlEnchantImg = URL_MZimg+'images/enchant.png';
  8780. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  8781. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  8782. var noGowaps = saveCheckBox(checkBoxGowaps,'NOGOWAP'),
  8783. noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE'),
  8784. nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE'),
  8785. nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  8786. // old/new : détermine s'il faut ou non nettoyer les tr
  8787. var oldNOEM = true, noEM = true;
  8788. if(MY_getValue('NOINFOEM')!='true') {
  8789. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  8790. }
  8791. // Filtrage par nom
  8792. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  8793. // Génère la liste des mobs engagés (si filtrés)
  8794. if(noEngages && !isEngagesComputed) {
  8795. for(var i=nbTrolls ; i>0 ; i--) {
  8796. var pos = getTrollPosition(i);
  8797. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  8798. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  8799. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  8800. }
  8801. isEngagesComputed = true;
  8802. }
  8803. /*** FILTRAGE ***/
  8804. /* À computer :
  8805. * - EM (nom suffit)
  8806. * - Enchant (nom suffit)
  8807. * - Mission (nécessite CdM)
  8808. * - mob VlC (nécessite CdM)
  8809. * Sans computation :
  8810. * - Gowap ? engagé ?
  8811. */
  8812. for(var i=nbMonstres ; i>0 ; i--) {
  8813. var pos = getMonstrePosition(i);
  8814. var nom = getMonstreNom(i).toLowerCase();
  8815. if(noEM!=oldNOEM) {
  8816. if(noEM) {
  8817. // Si noEM passe de false à true, on nettoie les td "Nom"
  8818. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  8819. var tr = getMonstreNomNode(i);
  8820. while(tr.childNodes.length>1) {
  8821. tr.removeChild(tr.childNodes[1]);
  8822. }
  8823. } else {
  8824. var tr = getMonstreNomNode(i);
  8825. var TypeMonstre=getEM(nom);
  8826. if(TypeMonstre!='') {
  8827. var infosCompo=compoMobEM(TypeMonstre);
  8828. if(infosCompo.length>0) {
  8829. tr.appendChild(document.createTextNode(' '));
  8830. tr.appendChild(createImage(urlImg, infosCompo));
  8831. }
  8832. }
  8833. }
  8834. }
  8835. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  8836. var texte = getInfoEnchantementFromMonstre(nom);
  8837. if(texte!='') {
  8838. var td = getMonstreNomNode(i);
  8839. td.appendChild(document.createTextNode(' '));
  8840. td.appendChild(createImage(urlEnchantImg, texte));
  8841. }
  8842. }
  8843. tr_monstres[i].style.display = (
  8844. noGowaps &&
  8845. nom.indexOf('gowap apprivoisé')!=-1 &&
  8846. getMonstreDistance(i)>1
  8847. ) || (
  8848. noEngages &&
  8849. getMonstreDistance(i)!=0 &&
  8850. listeEngages[pos[0]] &&
  8851. listeEngages[pos[0]][pos[1]] &&
  8852. listeEngages[pos[0]][pos[1]][pos[2]]
  8853. ) || (
  8854. strMonstre!='' &&
  8855. nom.indexOf(strMonstre)==-1
  8856. ) || (
  8857. nivMin>0 &&
  8858. getMonstreLevel(i)!=-1 &&
  8859. getMonstreLevel(i)<nivMin &&
  8860. getMonstreDistance(i)>1 &&
  8861. nom.toLowerCase().indexOf("kilamo")==-1 // wtf ?!...
  8862. ) || (
  8863. nivMax>0 &&
  8864. getMonstreLevel(i)>nivMax &&
  8865. getMonstreDistance(i)>1 &&
  8866. nom.toLowerCase().indexOf("kilamo")==-1
  8867. ) ? 'none' : '';
  8868. }
  8869. if(MY_getValue('NOINFOEM')!='true') {
  8870. if(noEM != oldNOEM) {
  8871. if(noEM && isCDMsRetrieved) computeMission();
  8872. }
  8873. oldNOEM = noEM;
  8874. }
  8875. needComputeEnchantement = false;
  8876. }
  8877.  
  8878.  
  8879. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  8880.  
  8881. function filtreTrolls() {
  8882. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  8883. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  8884. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  8885. for(var i=1 ; i<=nbTrolls ; i++) {
  8886. tr_trolls[i].style.display = (
  8887. noIntangibles &&
  8888. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  8889. ) || (
  8890. strTroll!='' &&
  8891. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  8892. ) || (
  8893. strGuilde!='' &&
  8894. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  8895. ) ? 'none' : '';
  8896. }
  8897. }
  8898.  
  8899. /* [functions] Bulle PX Trolls */
  8900. var bulle;
  8901.  
  8902. function initPXTroll() {
  8903. bulle = document.createElement('div');
  8904. bulle.id = 'bulle';
  8905. bulle.className = 'mh_textbox';
  8906. bulle.style =
  8907. 'position: absolute;'+
  8908. 'border: 1px solid #000000;'+
  8909. 'visibility: hidden;'+
  8910. 'display: inline;'+
  8911. 'z-index: 2;';
  8912. document.body.appendChild(bulle);
  8913.  
  8914. for(var i=nbTrolls ; i>0 ; i--) {
  8915. var td_niv = getTrollNivNode(i);
  8916. td_niv.onmouseover = showPXTroll;
  8917. td_niv.onmouseout = hidePXTroll;
  8918. }
  8919. }
  8920.  
  8921. function showPXTroll(evt) {
  8922. var lvl = this.firstChild.nodeValue;
  8923. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  8924. bulle.style.left = evt.pageX+15+'px';
  8925. bulle.style.top = evt.pageY+'px';
  8926. bulle.style.visibility = 'visible';
  8927. }
  8928.  
  8929. function hidePXTroll() {
  8930. bulle.style.visibility = 'hidden';
  8931. }
  8932.  
  8933. /* [functions] Envoi PX / MP */
  8934. function putBoutonPXMP() {
  8935. // Bouton d'initialisation du mode Envoi
  8936. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  8937. var td = document.getElementById('tdInsertTrolls');
  8938. if(!td) { return; }
  8939. td.width = 100;
  8940. td = insertTd(td.nextSibling);
  8941. td.style.verticalAlign = 'top';
  8942. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  8943. bouton.id = 'btnEnvoi';
  8944. }
  8945.  
  8946. function prepareEnvoi() {
  8947. // = 1er Handler du bouton d'envoi
  8948. /* Ajout de la colonne des CheckBoxes */
  8949. var td = insertTdText(getTrollNomNode(0),'');
  8950. td.width = 5;
  8951. for(var i=nbTrolls ; i>0 ; i--) {
  8952. td = insertTd(getTrollNomNode(i));
  8953. appendCheckBox(td,'envoi'+i);
  8954. }
  8955. /* Ajout du radio de choix PX ou MP */
  8956. var btnEnvoi = document.getElementById('btnEnvoi');
  8957. if(!btnEnvoi) { return; }
  8958. var tdEnvoi = btnEnvoi.parentNode;
  8959. appendText(tdEnvoi,' ');
  8960. var span = document.createElement('span');
  8961. span.style.whiteSpace = 'nowrap';
  8962. var radioElt = document.createElement('input');
  8963. radioElt.type = 'radio';
  8964. radioElt.name = 'envoiPXMP';
  8965. radioElt.id = 'radioPX';
  8966. span.appendChild(radioElt);
  8967. appendText(span,' des PX ');
  8968. radioElt = document.createElement('input');
  8969. radioElt.type = 'radio';
  8970. radioElt.name = 'envoiPXMP';
  8971. radioElt.checked = true;
  8972. span.appendChild(radioElt);
  8973. appendText(span,' un MP');
  8974. tdEnvoi.appendChild(span);
  8975. /* Insertion du bouton Annuler */
  8976. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  8977. /* Modification de l'effet du bouton Envoi */
  8978. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  8979. }
  8980.  
  8981. function annuleEnvoi() {
  8982. // = Handler bouton Annuler
  8983. /* Nettoyage du td du bouton Envoi */
  8984. var btnEnvoi = document.getElementById('btnEnvoi');
  8985. var tdEnvoi = btnEnvoi.parentNode;
  8986. while(tdEnvoi.firstChild) {
  8987. tdEnvoi.removeChild(tdEnvoi.firstChild);
  8988. }
  8989. /* Retour à l'effet de base du bouton Envoi */
  8990. btnEnvoi.onclick = prepareEnvoi;
  8991. tdEnvoi.appendChild(btnEnvoi);
  8992. /* Suppression CheckBoxes */
  8993. for(var i=nbTrolls ; i>=0 ; i--) {
  8994. var td = getTrollNomNode(i);
  8995. td.parentNode.removeChild(td);
  8996. }
  8997. }
  8998.  
  8999. function effectueEnvoi() {
  9000. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9001. var str='';
  9002. for(var i=nbTrolls ; i>0 ; i--) {
  9003. var chb = document.getElementById('envoi'+i);
  9004. if(chb.checked) {
  9005. str += (str?',':'')+getTrollID(i);
  9006. }
  9007. }
  9008. var PXchecked = document.getElementById('radioPX').checked;
  9009. if(PXchecked) {
  9010. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9011. } else {
  9012. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9013. }
  9014. }
  9015.  
  9016. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9017.  
  9018. function filtreTresors() {
  9019. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9020. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9021. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9022. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9023. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9024. if(noEngages && !isEngagesComputed) {
  9025. for(var i=nbTrolls ; i>0 ; i--) {
  9026. var pos = getTrollPosition(i);
  9027. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9028. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9029. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9030. }
  9031. isEngagesComputed = true;
  9032. }
  9033. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9034. for(var i=nbTresors ; i>0 ; i--) {
  9035. var nom = getTresorNom(i);
  9036. var pos = getTresorPosition(i);
  9037. tr_tresors[i].style.display = (
  9038. noGG &&
  9039. nom.indexOf('Gigots de Gob')!=-1
  9040. ) || (
  9041. noCompos &&
  9042. nom.indexOf('Composant')!=-1
  9043. ) || (
  9044. noEngages &&
  9045. listeEngages[pos[2]] &&
  9046. listeEngages[pos[2]][pos[1]] &&
  9047. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9048. getTresorDistance(i)>0
  9049. ) || (
  9050. strTresor!='' &&
  9051. nom.toLowerCase().indexOf(strTresor)==-1
  9052. ) || (
  9053. noBidouilles &&
  9054. nom.indexOf('Bidouille')!=-1
  9055. ) ? 'none' : '';
  9056. }
  9057. }
  9058.  
  9059.  
  9060. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9061.  
  9062. function filtreLieux() {
  9063. // += Handler checkbox trous
  9064. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9065. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9066. for(var i=nbLieux ; i>0 ; i--) {
  9067. tr_lieux[i].style.display = (
  9068. strLieu &&
  9069. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9070. ) || (
  9071. noTrou &&
  9072. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9073. getLieuDistance(i)>1
  9074. ) ? 'none' : '';
  9075. }
  9076. }
  9077.  
  9078.  
  9079. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9080.  
  9081. function refreshDiplo() {
  9082. MY_setValue(numTroll+'.diplo.off',
  9083. checkBoxDiplo.checked?'true':'false'
  9084. );
  9085. if(isDiploRaw) { computeDiplo(); }
  9086. appliqueDiplo();
  9087. }
  9088.  
  9089. function computeDiplo() {
  9090. // On extrait les données de couleur et on les stocke par id
  9091. // Ordre de préséance :
  9092. // source Guilde < source Perso
  9093. // guilde cible < troll cible
  9094. /* Diplo de Guilde */
  9095. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9096. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9097. if(diploGuilde && diploGuilde.isOn=='true') {
  9098. // Guilde perso
  9099. if(diploGuilde.guilde) {
  9100. Diplo.Guilde[diploGuilde.guilde.id] = {
  9101. couleur: diploGuilde.guilde.couleur,
  9102. titre: 'Ma Guilde'
  9103. };
  9104. }
  9105. // Guildes/Trolls A/E
  9106. for(var AE in {Amis:0,Ennemis:0}) {
  9107. for(var i=0 ; i<5 ; i++) {
  9108. if(diploGuilde[AE+i]) {
  9109. for(var type in {Guilde:0,Troll:0}) {
  9110. var liste = diploGuilde[AE+i][type].split(';');
  9111. for(var j=liste.length-2 ; j>=0 ; j--) {
  9112. Diplo[type][liste[j]] = {
  9113. couleur: diploGuilde[AE+i].couleur,
  9114. titre: diploGuilde[AE+i].titre
  9115. };
  9116. }
  9117. }
  9118. }
  9119. }
  9120. }
  9121. }
  9122. /* Diplo Perso */
  9123. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9124. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9125. if(diploPerso && diploPerso.isOn=='true') {
  9126. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9127. for(var id in diploPerso[type]) {
  9128. Diplo[type][id] = diploPerso[type][id];
  9129. }
  9130. }
  9131. }
  9132. if(diploPerso.mythiques) {
  9133. Diplo.mythiques = diploPerso.mythiques;
  9134. }
  9135. isDiploRaw = false;
  9136. }
  9137.  
  9138. function appliqueDiplo() {
  9139. var aAppliquer = Diplo;
  9140. if(checkBoxDiplo.checked) {
  9141. // Pour retour à l'affichage basique sur désactivation de la diplo
  9142. aAppliquer = {
  9143. Guilde: {},
  9144. Troll: {},
  9145. Monstre: {}
  9146. };
  9147. }
  9148. /* On applique "aAppliquer" */
  9149. // Diplo Trõlls
  9150. for(var i=nbTrolls ; i>0 ; i--) {
  9151. var idG = getTrollGuildeID(i);
  9152. var idT = getTrollID(i);
  9153. var tr = tr_trolls[i];
  9154. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9155. if(aAppliquer.Troll[idT]) {
  9156. tr.className = '';
  9157. var descr = aAppliquer.Troll[idT].titre;
  9158. if(descr) {
  9159. getTrollNomNode(i).title = descr
  9160. }
  9161. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9162. } else if(aAppliquer.Guilde[idG]) {
  9163. tr.className = '';
  9164. var descr = aAppliquer.Guilde[idG].titre;
  9165. if(descr) {
  9166. getTrollNomNode(i).title = descr
  9167. }
  9168. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9169. } else {
  9170. tr.className = 'mh_tdpage';
  9171. getTrollNomNode(i).title = '';
  9172. }
  9173. }
  9174. // Diplo Monstres
  9175. for(var i=nbMonstres ; i>0 ; i--) {
  9176. var id = getMonstreID(i);
  9177. var nom = getMonstreNom(i).toLowerCase();
  9178. if(aAppliquer.Monstre[id]) {
  9179. tr_monstres[i].className = '';
  9180. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  9181. tr_monstres[i].diploActive = 'oui';
  9182. var descr = aAppliquer.Monstre[id].titre;
  9183. if(descr) {
  9184. getMonstreNomNode(i).title = descr;
  9185. }
  9186. } else if(aAppliquer.mythiques &&
  9187. (nom.indexOf('liche')==0 ||
  9188. nom.indexOf('hydre')==0 ||
  9189. nom.indexOf('balrog')==0 ||
  9190. nom.indexOf('beholder')==0)) {
  9191. tr_monstres[i].className = '';
  9192. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  9193. tr_monstres[i].diploActive = 'oui';
  9194. getMonstreNomNode(i).title = 'Monstre Mythique';
  9195. } else {
  9196. tr_monstres[i].className = 'mh_tdpage';
  9197. tr_monstres[i].diploActive = '';
  9198. }
  9199. }
  9200. }
  9201.  
  9202.  
  9203. /*-[functions]---------------- Actions à distance ----------------------------*/
  9204.  
  9205. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  9206. var monN = parseInt(getPosition()[2]);
  9207. for(var type in keltypes) {
  9208. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  9209. for(var i=this['nb'+type] ; i>0 ; i--) {
  9210. var tr = this['tr_'+type.toLowerCase()][i];
  9211. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  9212. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  9213. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  9214. var sonN = getXxxPosition(type, i)[2];
  9215. var d = getXxxDistance(type, i);
  9216. if(sonN==monN && d>=dmin && d<=dmax) {
  9217. var iconeAction = document.evaluate(
  9218. "./descendant::img[@alt='"+alt+"']",
  9219. tr, null, 9, null
  9220. ).singleNodeValue;
  9221. if(iconeAction) {
  9222. if(iconeAction.title) {
  9223. iconeAction.title += "\n"+message;
  9224. } else {
  9225. iconeAction.title = message;
  9226. }
  9227. iconeAction.src = urlIcon;
  9228. } else {
  9229. var tdAction = tr.getElementsByTagName('td')[1];
  9230. var icon = document.createElement('img');
  9231. icon.src = urlIcon;
  9232. icon.height = 20;
  9233. icon.alt = alt;
  9234. icon.title = message;
  9235. tdAction.appendChild(icon);
  9236. }
  9237. }
  9238. }
  9239. }
  9240. }
  9241.  
  9242. function computeCharge() {
  9243. computeActionDistante(1,
  9244. getPortee__Vue(
  9245. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  9246. MY_getValue(numTroll+".caracs.regeneration")
  9247. ),
  9248. {'Monstres':1, 'Trolls':1},
  9249. 'Attaquer',
  9250. MHicons+'E_Metal09.png',
  9251. 'Cible à portée de Charge'
  9252. );
  9253. }
  9254.  
  9255. function computeProjo() {
  9256. computeActionDistante(0,
  9257. getPortee__Vue(
  9258. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9259. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9260. ),
  9261. {'Monstres':1, 'Trolls':1},
  9262. 'Attaquer',
  9263. MHicons+'S_Fire05.png',
  9264. 'Cible à portée de Projo'
  9265. );
  9266. }
  9267.  
  9268. function computeTelek() {
  9269. computeActionDistante(0,
  9270. Math.floor((
  9271. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9272. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9273. )/2),
  9274. {'Tresors':1},
  9275. 'Telek',
  9276. MHicons+'S_Magic04.png',
  9277. 'Trésor à portée de Télékinésie'
  9278. );
  9279. }
  9280.  
  9281. function computeLdP() {
  9282. computeActionDistante(0,
  9283. 2+Math.floor((
  9284. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9285. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9286. )/5),
  9287. {'Monstres':1, 'Trolls':1},
  9288. 'self',
  9289. MHicons+'P_Red01.png',
  9290. 'Cible à portée de Lancer de Potions'
  9291. );
  9292. }
  9293.  
  9294.  
  9295. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  9296.  
  9297. function putScriptExterne() {
  9298. var infoit = MY_getValue(numTroll+'.INFOSIT');
  9299. if(!infoit || infoit=='') return;
  9300.  
  9301. var nomit = infoit.slice(0,infoit.indexOf('$'));
  9302. if(nomit=='bricol') {
  9303. var data = infoit.split('$');
  9304. try {
  9305. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  9306. // appendNewScript(URL_bricol+data[1]
  9307. // +'/mz.php?login='+data[2]
  9308. // +'&password='+data[3]
  9309. // );
  9310. FF_XMLHttpRequest({
  9311. method: 'GET',
  9312. url: URL_bricol+data[1]
  9313. +'/mz_json.php?login='+data[2]
  9314. +'&password='+data[3],
  9315. onload: function(responseDetails) {
  9316. try {
  9317. if (responseDetails.status == 0) {
  9318. if (isHTTPS) {
  9319. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  9320. } else {
  9321. window.console.log('status=0 à l\'appel bricol\'troll');
  9322. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  9323. }
  9324. return;
  9325. }
  9326. var ratibusData;
  9327. try {
  9328. ratibusData = JSON.parse(responseDetails.responseText);
  9329. } catch(e) {}
  9330. if (ratibusData === undefined) {
  9331. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  9332. return;
  9333. }
  9334. if (ratibusData.error) {
  9335. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  9336. } else {
  9337. putInfosTrolls(ratibusData.data.trolls);
  9338. }
  9339. } catch(e) {
  9340. window.console.log(traceStack(e, 'retour bricol\'troll'));
  9341. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  9342. }
  9343. }
  9344. });
  9345. } catch(e) {
  9346. if (isHTTPS) {
  9347. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  9348. } else {
  9349. window.console.log(traceStack(e, 'appel bricol\'troll'));
  9350. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  9351. }
  9352. }
  9353. }
  9354. }
  9355.  
  9356. /* Le script mz.php de Ratibus renvoie :
  9357. + infosTrolls = new Array();
  9358. + infosTrolls[numdutroll] =
  9359. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  9360. + etc ...
  9361. + putInfosTrolls();
  9362. *
  9363. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  9364. * Roule 07/11/2016, on utilise mz_json qui envoie
  9365. {
  9366. "data": {
  9367. "trolls": {
  9368. "59424": {
  9369. "id": 59424,
  9370. "pv": xx,
  9371. "pv_max": xx,
  9372. "updated_at": "2016-10-31 07:28:40",
  9373. "dla": "2016-10-05 07:28:04",
  9374. "pa": 0
  9375. },
  9376. }
  9377. }
  9378. }
  9379. */
  9380.  
  9381. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  9382. function corrigeBricolTrolls(infosTrolls) {
  9383. for(var i in infosTrolls) {
  9384. var pv = infosTrolls[i][0];
  9385. var pvmax = infosTrolls[i][1];
  9386. var pvmem = MY_getValue(i+'.caracs.pv.max');
  9387. if(pvmem && pvmem>pvmax) {
  9388. infosTrolls[i][1] = pvmem;
  9389. pvmax = pvmem;
  9390. }
  9391. if(pv>pvmax) {
  9392. var newpvmax = 5*Math.ceil(pv/5);
  9393. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9394. infosTrolls[i][1] = newpvmax;
  9395. }
  9396. }
  9397. }
  9398.  
  9399. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9400. function addTdInfosTroll(infos, nextTD) {
  9401. /* cadre barre PV */
  9402. var tab = document.createElement('div');
  9403. /* ancienne méthode par img, à supprimer
  9404. tab.width = 100;
  9405. tab.style.width = 100;
  9406. tab.height = 10;
  9407. tab.style.background = '#FFFFFF';
  9408. tab.style.border = 1;
  9409. */
  9410. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9411. /* barre PV */
  9412. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9413. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9414. .vieContainer {
  9415. background-color: #CCC;
  9416. width: 50px;
  9417. height: 6px;
  9418. border: 1px solid #000;
  9419. text-align: left;
  9420. }
  9421. */
  9422. tab.style.width = '100px';
  9423. tab.style.height = '10px';
  9424. tab.style.border = '1px solid #000';
  9425. tab.style.textAlign = 'left';
  9426. var div2 = document.createElement('div');
  9427. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9428. var dateLimite = new Date();
  9429. dateLimite.setDate(dateLimite.getDate() - 7);
  9430. if (infos.oUpdatedAt < dateLimite) {
  9431. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9432. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9433. } else if (pourcentVie > 66) {
  9434. div2.style.backgroundColor = '#77EE77';
  9435. } else if (pourcentVie > 33) {
  9436. div2.style.backgroundColor = '#EEEE77';
  9437. } else {
  9438. div2.style.backgroundColor = '#FF0000';
  9439. }
  9440. div2.style.width = pourcentVie + '%';
  9441. div2.style.height = '10px';
  9442. tab.appendChild(div2);
  9443. /* ancienne méthode par img, à supprimer
  9444. var img = document.createElement('img');
  9445. img.src = '../Images/Interface/milieu.gif';
  9446. img.height = 10;
  9447. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9448. tab.appendChild(img);
  9449. */
  9450.  
  9451. /* lien vers l'IT */
  9452. var lien = document.createElement('a');
  9453. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9454. lien.href = URL_bricol+nomit+'/index.php';
  9455. lien.target = '_blank';
  9456. lien.appendChild(tab);
  9457. insertTdElement(nextTD,lien);
  9458. /* PAs dispos */
  9459. var span = document.createElement('span');
  9460. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9461. appendText(span, infos.pa +' PA' );
  9462. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9463. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9464. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9465. span.style.backgroundColor = 'B8EEB8';
  9466. }
  9467. insertTdElement(nextTD, span);
  9468. }
  9469.  
  9470. function putInfosTrolls(infosTrolls) {
  9471. try {
  9472. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9473. // supression des infos trop vieilles (un mois)
  9474. var IDs = Object.keys(infosTrolls);
  9475. var dateLimite = new Date();
  9476. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9477. for (var i = 0; i < IDs.length; i++) {
  9478. var idTroll = IDs[i];
  9479. var infos = infosTrolls[idTroll];
  9480. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9481. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9482. }
  9483. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9484. td.width = 40;
  9485. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9486. td.width = 105;
  9487.  
  9488. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9489. //corrigeBricolTrolls(infosTrolls);
  9490.  
  9491. for(i=nbTrolls ; i>0 ; i--) {
  9492. var infos = infosTrolls[getTrollID(i)];
  9493. if(infos && (!infos.bIgnore)) {
  9494. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9495. infos.done = true;
  9496. } else {
  9497. insertTd(tr_trolls[i].childNodes[6]);
  9498. insertTd(tr_trolls[i].childNodes[6]);
  9499. }
  9500. }
  9501. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9502. var str = MY_getValue(numTroll+'.INFOSIT');
  9503. if(!str) return;
  9504. var arr = str.split('$');
  9505. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9506.  
  9507. //window.console.log('nb Troll IT : ' + IDs.length);
  9508. var tBody = tr_trolls[0].parentNode;
  9509. if (tr_trolls[1] === undefined)
  9510. tBody = tr_trolls[0].parentNode;
  9511. else
  9512. tBody = tr_trolls[1].parentNode;
  9513. var pos = getPosition();
  9514. for (i = 0; i < IDs.length; i++) {
  9515. var idTroll = IDs[i];
  9516. infos = infosTrolls[idTroll];
  9517. if (infos.done) continue; // déjà vu
  9518. if (infos.bIgnore) continue; // trop vieux
  9519. if (idTroll == numTroll) continue; // pas nous-même
  9520. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9521. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9522. // trouver où insérer ce Troll
  9523. var next = undefined;
  9524. for(var j=0 ; j<tr_trolls.length ; j++) {
  9525. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9526. if (thisDist > distance) {
  9527. next = tr_trolls[j]
  9528. break;
  9529. }
  9530. }
  9531. var tr;
  9532. if (next !== undefined) {
  9533. tr = insertTr(next,'mh_tdpage')
  9534. } else {
  9535. tr = appendTr(tBody,'mh_tdpage');
  9536. }
  9537. var td = appendTd(tr); // distance
  9538. appendText(td, distance);
  9539. td = appendTd(tr); // actions
  9540. td = appendTd(tr); // ID
  9541. appendText(td, idTroll);
  9542. td = appendTd(tr); // Nom
  9543. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9544. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9545. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9546. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9547. td = appendTd(tr); // Niveau
  9548. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9549. td.align = 'center';
  9550. td = appendTd(tr); // Race
  9551. if (infos.race) appendText(td, infos.race);
  9552. // PV et PA ajoutés par addTdInfosTroll
  9553. td = appendTd(tr); // Guilde
  9554. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9555. td = appendTd(tr); // X
  9556. td.align = 'center';
  9557. if (infos.x !== undefined) appendText(td, infos.x);
  9558. td = appendTd(tr); // Y
  9559. td.align = 'center';
  9560. if (infos.y !== undefined) appendText(td, infos.y);
  9561. td = appendTd(tr); // N
  9562. td.align = 'center';
  9563. if (infos.n !== undefined) appendText(td, infos.n);
  9564. addTdInfosTroll(infos, tr.childNodes[6]);
  9565. }
  9566. } catch(e) {
  9567. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  9568. }
  9569. }
  9570.  
  9571.  
  9572. /* Mode Tétalanvert! ---------------------------------------------------------*/
  9573.  
  9574. function calculeDistance(maPos,posArr) {
  9575. return Math.max(
  9576. Math.abs(maPos[0]-posArr[0]),
  9577. Math.abs(maPos[1]-posArr[1]),
  9578. Math.abs(maPos[2]-posArr[2])
  9579. );
  9580. }
  9581.  
  9582. function inversionCoord() {
  9583. var maPos = getPosition();
  9584. var listeOffsets = {
  9585. 'monstres':checkBoxLevels.checked?4:3,
  9586. 'trolls':6,
  9587. };
  9588. for(var type in listeOffsets) {
  9589. var trList = this['tr_'+type];
  9590. var offset = listeOffsets[type];
  9591. for(var i=trList.length-1 ; i>0 ; i--) {
  9592. var oldX = parseInt(trList[i].cells[offset].textContent);
  9593. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  9594. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  9595. trList[i].cells[offset].innerHTML = oldY;
  9596. trList[i].cells[offset+1].innerHTML = oldX;
  9597. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  9598. }
  9599. }
  9600. }
  9601.  
  9602.  
  9603. /* Partie principale */
  9604. function do_vue() {
  9605. for(var type in typesAFetcher) {
  9606. fetchData(type);
  9607. }
  9608.  
  9609. // roule' 11/03/2016
  9610. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  9611. // je fais une recopie :(
  9612. tr_monstres = this['tr_monstres'];
  9613. tr_trolls = this['tr_trolls'];
  9614. tr_tresors = this['tr_tresors'];
  9615. tr_champignons = this['tr_champignons'];
  9616. tr_lieux = this['tr_lieux'];
  9617.  
  9618. nbMonstres = this['nbMonstres'];
  9619. nbTrolls = this['nbTrolls'];
  9620. nbTresors = this['nbTresors'];
  9621. nbChampignons = this['nbChampignons'];
  9622. nbLieux = this['nbLieux'];
  9623.  
  9624. try {
  9625. start_script(31);
  9626. initialiseInfos();
  9627. savePosition();
  9628.  
  9629. // Fonctionnalité "Têtalenvert" cachée, en test :
  9630. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  9631. inversionCoord();
  9632. }
  9633. ajoutDesFiltres();
  9634. set2DViewSystem();
  9635. //putBoutonTroogle();
  9636. putBoutonPXMP();
  9637. synchroniseFiltres();
  9638. toggleLevelColumn();
  9639.  
  9640. refreshDiplo();
  9641. //400 ms
  9642. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  9643. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  9644. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  9645. var noGowaps = saveCheckBox(checkBoxGowaps, "NOGOWAP");
  9646. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  9647. var noTresorsEngages =
  9648. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  9649. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  9650. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  9651. filtreMonstres();
  9652. if(noIntangibles) {
  9653. filtreTrolls();
  9654. }
  9655. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  9656. filtreTresors();
  9657. }
  9658. if(noTrou) {
  9659. filtreLieux();
  9660. }
  9661.  
  9662. initPopupVue();
  9663. initPXTroll();
  9664.  
  9665. if(getTalent("Projectile Magique")!=0) {
  9666. computeProjo();
  9667. }
  9668. if(getTalent("Charger")!=0) {
  9669. computeCharge();
  9670. }
  9671. if(getTalent("Télékinésie")!=0) {
  9672. computeTelek();
  9673. }
  9674. if(getTalent("Lancer de Potions")!=0) {
  9675. computeLdP();
  9676. }
  9677. putScriptExterne();
  9678. displayScriptTime();
  9679. } catch(e) {
  9680. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  9681. window.console.error(traceStack(e, 'vue'));
  9682. }
  9683. }
  9684.  
  9685.  
  9686.  
  9687. /*******************************************************************************
  9688. * This file is part of Mountyzilla. *
  9689. * *
  9690. * Mountyzilla is free software; you can redistribute it and/or modify *
  9691. * it under the terms of the GNU General Public License as published by *
  9692. * the Free Software Foundation; either version 2 of the License, or *
  9693. * (at your option) any later version. *
  9694. * *
  9695. * Mountyzilla is distributed in the hope that it will be useful, *
  9696. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9697. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9698. * GNU General Public License for more details. *
  9699. * *
  9700. * You should have received a copy of the GNU General Public License *
  9701. * along with Mountyzilla; if not, write to the Free Software *
  9702. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9703. *******************************************************************************/
  9704.  
  9705. // x~x profil2
  9706.  
  9707. /*---------------------------- Variables globales ----------------------------*/
  9708.  
  9709. var
  9710. // Anatrolliseur
  9711. urlAnatrolliseur,
  9712. // Infobulles talents
  9713. hauteur = 50, bulleStyle = null,
  9714. // Caracteristiques
  9715. // Infos troll
  9716. race, niv, idtroll, datecrea,
  9717. idguilde, nomguilde,
  9718. // Etats du troll
  9719. fatigue, bmfatigue,
  9720.  
  9721. // Experience, Pi, ...
  9722. pxdistribuables, pxperso,
  9723. piutilisable, pitotal,
  9724. nbmeurtres, nbmorts,
  9725. // utilisee pour les moyennes MM/jour, kill/jour, etc
  9726. NBjours,
  9727. // calcul des DLA suivantes
  9728. DLA, DLAsuiv, HeureServeur,
  9729. // details duree du tour (calcul pvdispo) :
  9730. dtb, pdm, bmt, adb, dpt,
  9731. //posale
  9732. posX, posY, posN,
  9733. // caracs physiques
  9734. vue, vuebp, vuebm, vuetotale,
  9735. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  9736. reg, regbp, regbm, regmoy,
  9737. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  9738. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  9739. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  9740. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  9741. rm, rmbp, rmbm, rmtotale,
  9742. mm, mmbp, mmbm, mmtotale,
  9743.  
  9744. // Variables speciales Kastars
  9745. pvActuelKastar, minParPV, overDLA,
  9746. // id pour edition manuelle de lastDLA :
  9747. inJour, inMois, inAn, inHr, inMin, inSec,
  9748. // id pour auto-refresh lastDLA :
  9749. lastDLAZone, maxAMZone, cumulZone,
  9750. lastDLA, DLAaccel;
  9751.  
  9752.  
  9753. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9754.  
  9755. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  9756. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  9757. function getUniqueValueBySelector(selector, defaultValue){
  9758. var valNode = document.querySelector(selector);
  9759. if(valNode!=null){
  9760. if(valNode.hasChildNodes()) {
  9761. return valNode.childNodes[0].nodeValue;
  9762. }else{
  9763. return defaultValue;
  9764. }
  9765. } else{
  9766. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  9767. return defaultValue;
  9768. }
  9769. }
  9770. function getUniqueStringValueBySelector(selector){
  9771. return getUniqueValueBySelector(selector,"");
  9772. }
  9773. function getUniqueIntValueBySelector(selector){
  9774. var ret = getUniqueValueBySelector(selector,0);
  9775. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9776. ret = 0;
  9777. }
  9778. return parseInt(ret);
  9779. }
  9780. function getUniqueFloatValueBySelector(selector){
  9781. var ret = getUniqueValueBySelector(selector,0.0);
  9782. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  9783. ret = 0.0;
  9784. }
  9785. return parseFloat(ret);
  9786. }
  9787.  
  9788.  
  9789. function resiste(Ddeg,bm) {
  9790. // version naive mais compréhensible ^^
  9791. // DEBUG: à revoir
  9792. if(!bm) {
  9793. return 2*Math.floor(Ddeg/2);
  9794. }
  9795. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  9796. }
  9797.  
  9798. function retourAZero(fatig) {
  9799. var fat = fatig, raz = 0;
  9800. while(fat>0) {
  9801. raz++;
  9802. fat = Math.floor(fat/1.25);
  9803. }
  9804. return raz;
  9805. }
  9806.  
  9807. function decumulPumPrem(bonus) {
  9808. switch(bonus) {
  9809. case 20: return 33;
  9810. case 33: return 41;
  9811. case 41: return 46;
  9812. case 46: return 49;
  9813. case 49: return 51;
  9814. default: return 20;
  9815. }
  9816. }
  9817.  
  9818. function coefDecumul(i) {
  9819. switch(i) {
  9820. case 2: return 0.67;
  9821. case 3: return 0.4;
  9822. case 4: return 0.25;
  9823. case 5: return 0.15;
  9824. default: return 0.1;
  9825. }
  9826. }
  9827.  
  9828. function dureeHM(dmin) {
  9829. var ret = "";
  9830. dmin = Math.floor(dmin);
  9831. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  9832. var mins = dmin%60;
  9833. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  9834. return (ret) ? ret : "-";
  9835. }
  9836.  
  9837. // extraction d'une durée
  9838. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  9839. // c'est protégé (rend 0 si l'élément est absent)
  9840. // Roule' 24/12/2016
  9841. function extractionDuree(selecteur) {
  9842. var s = getUniqueStringValueBySelector(selecteur);
  9843. if (!s) return 0;
  9844. var tabN = getNumbers(s);
  9845. if (tabN.length < 2) return 0;
  9846. return tabN[0] * 60 + tabN[1];
  9847. }
  9848.  
  9849. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  9850.  
  9851. function extractionDonnees() {
  9852. // Variables temporaires
  9853. var Nbrs = {};
  9854.  
  9855. // *********************
  9856. // Cadre "Description"
  9857. // *********************
  9858. race = getUniqueStringValueBySelector('#descr #race');
  9859. debugMZ("Race : " + race);
  9860. idtroll = getUniqueStringValueBySelector('#descr #id');
  9861. debugMZ("Id troll : " + idtroll);
  9862. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  9863. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  9864. datecrea = new Date(StringToDate(strDateCrea));
  9865. debugMZ("Date creation : " + datecrea);
  9866. // Guilde
  9867. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  9868. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  9869. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  9870.  
  9871. // *******************
  9872. // Cadre "Experience"
  9873. // *******************
  9874. // Niveau de troll
  9875. niv = getUniqueIntValueBySelector('#exp #niv');
  9876. nivTroll = niv;
  9877. debugMZ("Niveau : " + niv);
  9878. // PX
  9879. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  9880. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  9881. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  9882. // PI
  9883. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  9884. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  9885. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  9886. // Meutres/Morts
  9887. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  9888. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  9889. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  9890.  
  9891. // *********************
  9892. // Cadre "Tour de Jeu"
  9893. // *********************
  9894. // DLA
  9895. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  9896. DLA = new Date(StringToDate(Nbrs["dla"]));
  9897. debugMZ("DLA: " + DLA);
  9898. // DLA suivante
  9899. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  9900. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  9901. debugMZ("DLAsuiv: " + DLAsuiv);
  9902. // Duree normale de mon Tour
  9903. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  9904. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  9905. dtb = extractionDuree("#dla #tour");
  9906. debugMZ("Duree normale de mon Tour : " + dtb);
  9907. // Bonus/Malus sur la duree
  9908. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  9909. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  9910. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  9911. debugMZ("Bonus/Malus sur la duree : " + bmt);
  9912. // Augmentation due aux blessures
  9913. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  9914. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  9915. adb = extractionDuree("#dla #blessure");
  9916. debugMZ("Augmentation due aux blessures : " + adb);
  9917. // Poids de l'equipement
  9918. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  9919. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  9920. pdm = extractionDuree("#dla #poids");
  9921. debugMZ("Poids de l'equipement : " + pdm);
  9922. // Duree de mon prochain Tour
  9923. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  9924. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  9925. dpt = extractionDuree("#dla #duree>b");
  9926. debugMZ('Duree de mon prochain Tour : ' + dpt);
  9927.  
  9928. // ****************
  9929. // Cadre "Etats"
  9930. // ****************
  9931. // Position du troll :
  9932. posX = getUniqueIntValueBySelector('#pos #x');
  9933. posY = getUniqueIntValueBySelector('#pos #y');
  9934. posN = getUniqueIntValueBySelector('#pos #n');
  9935. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  9936. // PV actuel
  9937. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  9938. pvActuelKastar = pvcourant;
  9939. debugMZ("PV actuel : " + pvcourant)
  9940. // Fatigue
  9941. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  9942. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  9943. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  9944.  
  9945. // **************************
  9946. // Cadre "Caracteristiques"
  9947. // **************************
  9948. // Attaque
  9949. att = getUniqueIntValueBySelector('#carac #att');
  9950. attbp = getUniqueIntValueBySelector('#carac #att_p');
  9951. attbm = getUniqueIntValueBySelector('#carac #att_m');
  9952. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  9953. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  9954. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  9955. attmoy = 3.5*att + attbp + attbm;
  9956. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  9957. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  9958. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  9959. // Esquive
  9960. esq = getUniqueIntValueBySelector('#carac #esq');
  9961. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  9962. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  9963. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  9964. esqmoy = 3.5*esq + esqbp+esqbm;
  9965. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  9966. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  9967. // Degat
  9968. deg = getUniqueIntValueBySelector('#carac #deg');
  9969. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  9970. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  9971. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  9972. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  9973. degmoy = 2*deg + degbp+degbm;
  9974. degmoycrit = 3*deg + degbp+degbm;
  9975. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  9976. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  9977. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  9978. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  9979. // PV
  9980. pvbase = getUniqueIntValueBySelector('#carac #pv');
  9981. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  9982. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  9983. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  9984. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  9985. // Regeneration
  9986. reg = getUniqueIntValueBySelector('#carac #reg');
  9987. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  9988. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  9989. regmoy = 2 * reg + regbp + regbm; // D3
  9990. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  9991. // Armure
  9992. arm = getUniqueIntValueBySelector('#carac #arm');
  9993. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  9994. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  9995. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  9996. armmoy = 2*arm + armbp+armbm;
  9997. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  9998. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  9999. // TODO : D d'armure non active
  10000. // Vue
  10001. vue = getUniqueIntValueBySelector('#carac #vue');
  10002. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10003. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10004. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10005. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10006. // RM
  10007. rm = getUniqueIntValueBySelector('#carac #rm');
  10008. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10009. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10010. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10011. rmTroll = rmtotale;
  10012. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10013. // MM
  10014. mm = getUniqueIntValueBySelector('#carac #mm');
  10015. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10016. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10017. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10018. mmTroll = mmtotale;
  10019. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10020.  
  10021. // Heure Serveur
  10022. try {
  10023. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10024. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10025. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10026. } catch (e) {
  10027. window.console.warn(
  10028. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10029. );
  10030. HeureServeur = new Date();
  10031. }
  10032. debugMZ("HeureServeur: " + HeureServeur);
  10033.  
  10034. // ***INIT GLOBALE*** NBjours
  10035. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10036.  
  10037. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10038. var amelio_dtb = function(dtb) {
  10039. if(dtb>555) {
  10040. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10041. }
  10042. return 10+Math.ceil((555-dtb)/2.5);
  10043. },
  10044. amelio_pv = Math.floor(pvbase/10)-3,
  10045. amelio_vue = vue-3,
  10046. amelio_att = att-3,
  10047. amelio_esq = esq-3,
  10048. amelio_deg = deg-3,
  10049. amelio_reg = reg-1,
  10050. amelio_arm = arm-1;
  10051. if(race==="Darkling"){amelio_reg--; }
  10052. if(race==="Durakuir"){amelio_pv-- ; }
  10053. if(race==="Kastar") {amelio_deg--; }
  10054. if(race==="Skrim") {amelio_att--; }
  10055. if(race==="Tomawak") {amelio_vue--; }
  10056.  
  10057. urlAnatrolliseur = URL_AnatrolDispas
  10058. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10059. +"|r="+race.toLowerCase()
  10060. +"|dla="+amelio_dtb(dtb)
  10061. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10062. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10063. +"|att="+amelio_att+","+attbp+","+attbm
  10064. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10065. +"|deg="+amelio_deg+","+degbp+","+degbm
  10066. +"|reg="+amelio_reg+","+regbp+","+regbm
  10067. +"|arm="+amelio_arm+","+armbp+","+armbm
  10068. +"|mm="+mmtotale
  10069. +"|rm="+rmtotale+"|";
  10070. }
  10071.  
  10072. function saveProfil() {
  10073. MY_setValue(idtroll+'.caracs.attaque',att);
  10074. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10075. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10076. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10077. if(atttourD||atttourP||atttourM) {
  10078. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10079. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10080. }
  10081. MY_setValue(idtroll+'.caracs.esquive',esq);
  10082. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10083. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10084. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10085. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10086. MY_setValue(idtroll+'.caracs.degats',deg);
  10087. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10088. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10089. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10090. if(degtourP||degtourM){
  10091. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10092. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10093. }
  10094. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10095. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10096. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10097. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10098. MY_setValue(idtroll+'.caracs.vue',vue);
  10099. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10100. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10101. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10102. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10103. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10104. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10105. MY_setValue(idtroll+'.caracs.rm',rm);
  10106. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10107. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10108. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10109. MY_setValue(idtroll+'.caracs.mm',mm);
  10110. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10111. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10112. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10113. MY_setValue(idtroll+'.caracs.armure',arm);
  10114. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10115. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10116. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10117. MY_setValue(idtroll+'.position.X',posX);
  10118. MY_setValue(idtroll+'.position.Y',posY);
  10119. MY_setValue(idtroll+'.position.N',posN);
  10120. MY_setValue(idtroll+'.race',race);
  10121. MY_setValue(idtroll+'.niveau',niv);
  10122. MY_setValue(idtroll+'.idguilde',idguilde);
  10123. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10124. }
  10125.  
  10126.  
  10127. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10128.  
  10129. function setInfosCaracteristiques() {
  10130. // Modification de l'entete
  10131. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10132. thTotal.innerHTML+='|<i>Moyenne</i>';
  10133. thTotal.title="Moyenne (Moyenne ce tour)";
  10134.  
  10135. // Ajout des informations calculees
  10136. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10137. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10138. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10139.  
  10140. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10141. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10142. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10143.  
  10144. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10145. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10146. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10147.  
  10148. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10149. var tdRegTotal = trRegeneration.children[5];
  10150. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10151. // Temps recupere par reg (propale R')
  10152. var regmoyTemp = Math.max(0, regmoy);
  10153. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10154. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10155. if (sec != 0) {
  10156. regTitle += " " + sec + " sec";
  10157. }
  10158. trRegeneration.title = regTitle;
  10159.  
  10160. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  10161. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  10162. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  10163.  
  10164. var trRM=document.querySelector("table#caracs #rm").parentElement;
  10165. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  10166. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  10167.  
  10168.  
  10169. var trMM=document.querySelector("table#caracs #mm").parentElement;
  10170. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  10171. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  10172.  
  10173. var tdRefl=document.querySelector("#refl");
  10174. // TODO : prendre en compte bonus/malus D esq du tour ?
  10175. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  10176. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  10177. }
  10178.  
  10179. function setLienAnatrolliseur(){
  10180. var pTableAmelio = document.querySelector("#carac>div>p");
  10181. pTableAmelio.innerHTML+=" - ";
  10182. var aElt = document.createElement("a");
  10183. aElt.setAttribute("href",urlAnatrolliseur);
  10184. aElt.setAttribute("target","_blank");
  10185. aElt.className="AllLinks";
  10186. aElt.innerHTML="Anatrolliser";
  10187. pTableAmelio.appendChild(aElt);
  10188. }
  10189. function setInfoDescription() {
  10190. var txtDateCrea = (NBjours!=1) ?
  10191. " ("+NBjours+" jours dans le hall)" :
  10192. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  10193. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  10194. }
  10195.  
  10196. function setInfosEtatLieux() {
  10197. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  10198. '?search=position&orderBy=distance&posx='+
  10199. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  10200. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  10201. appendBr(tdPosition);
  10202. var aElt = document.createElement("a");
  10203. aElt.setAttribute("href",urlBricol);
  10204. aElt.setAttribute("target","_blank");
  10205. aElt.className="AllLinks";
  10206. aElt.innerHTML="Lieux à proximité";
  10207. tdPosition.appendChild(aElt);
  10208. }
  10209.  
  10210. function setInfosEtatPV() { // pour AM et Sacro
  10211. var
  10212. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  10213. sec = Math.floor(15000/pvtotal)%60,
  10214. lifebar = document.querySelector("#pos .barre-vie");
  10215. if(sec!=0) { txt += " "+sec+" sec"; }
  10216. if(lifebar) { lifebar.title = txt; }
  10217. if(pvcourant<=0) { return; }
  10218. // Difference PV p/r a equilibre de temps (propale R')
  10219. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  10220. // ***INIT GLOBALE*** pvdispo
  10221. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10222. var span = document.createElement("span");
  10223. span.title = txt;
  10224. span.style.fontStyle = "italic";
  10225. if(bmt+pdm>=0) {
  10226. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  10227. } else if(pvdispo>0) {
  10228. txt = "Vous pouvez encore perdre "+
  10229. Math.min(pvdispo,pvcourant)+
  10230. " PV sans malus de temps.";
  10231. } else if(pvdispo<0) {
  10232. txt = "Il vous manque "
  10233. +(-pvdispo)
  10234. +" PV pour ne plus avoir de malus de temps.";
  10235. } else {
  10236. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  10237. }
  10238. appendText(span,txt);
  10239. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  10240. }
  10241.  
  10242. // Complete le cadre "Experience"
  10243. function setInfosExp() {
  10244. var tdNiv = document.querySelector("#exp #niv");
  10245.  
  10246. // Calcul niveau monstre/troll min pour gain PX
  10247. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  10248. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  10249.  
  10250. // Calcul PX restant
  10251. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  10252. if (pxRestant >= 0) {
  10253. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  10254. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  10255. }
  10256.  
  10257. // Calul pi/jour
  10258. var
  10259. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  10260. tdPi = document.querySelector("#exp #pi").parentElement;
  10261. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  10262. tdPi.title = tdPiTotal.title;
  10263.  
  10264. // Rapports meurtres,morts
  10265. var tdKill = document.querySelector("#exp #kill");
  10266. tdKill.setAttribute("colspan", 1);
  10267. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  10268.  
  10269. var tdMort = document.querySelector("#exp #mort");
  10270. tdMort.setAttribute("colspan", 1);
  10271. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  10272.  
  10273. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  10274. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  10275. }
  10276.  
  10277.  
  10278. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  10279.  
  10280. function minParPVsac(fat,bm) {
  10281. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  10282. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  10283. var out = [];
  10284. out[0] = (fat>4) ?
  10285. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  10286. 30;
  10287. if(bm && bm>0) {
  10288. var totalfat=fat+bm;
  10289. out[1] = (totalfat>4) ?
  10290. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  10291. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  10292. }
  10293. return out;
  10294. }
  10295.  
  10296. function toInt(str) {
  10297. str = parseInt(str);
  10298. return (str) ? str : 0;
  10299. }
  10300.  
  10301. function saveLastDLA() {
  10302. // pour les calculs d'AM max
  10303. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  10304. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  10305. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  10306. lastDLA = new Date( StringToDate(str) );
  10307. MY_setValue(numTroll+'.DLA.ancienne',str);
  10308. lastDLAZone.innerHTML = '';
  10309. var b = document.createElement('b');
  10310. b.addEventListener('click',inputMode,false);
  10311. appendText(b,str);
  10312. lastDLAZone.appendChild(b);
  10313. refreshAccel();
  10314. }
  10315.  
  10316. function inputMode() {
  10317. // Edition manuelle lastDLA
  10318. var date;
  10319. if(lastDLA)
  10320. date = new Date( lastDLA );
  10321. else
  10322. date = new Date( DLAaccel );
  10323. lastDLAZone.innerHTML = '';
  10324. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  10325. appendText(lastDLAZone,'/');
  10326. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  10327. appendText(lastDLAZone,'/');
  10328. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  10329. appendText(lastDLAZone,' - ');
  10330. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  10331. appendText(lastDLAZone,':');
  10332. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  10333. appendText(lastDLAZone,':');
  10334. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  10335. appendText(lastDLAZone,' - ');
  10336. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  10337. }
  10338.  
  10339. function setAccel() {
  10340. var
  10341. BMfrais=false,
  10342. fat=fatigue, listeBmFat=[],
  10343. tr, th, insertPt;
  10344.  
  10345. // Creation ligne speciale pour AM dans le cadre "Etat"
  10346. tr = document.createElement('tr');
  10347. th = document.createElement('th');
  10348. appendText(th,'Fatigue et AM',true);
  10349. tr.appendChild(th);
  10350. insertPt = document.createElement('td');
  10351. tr.appendChild(insertPt);
  10352. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  10353.  
  10354. // Est-on en over-DLA ?
  10355. // ***INIT GLOBALE*** overDLA
  10356. overDLA = (HeureServeur>DLA.getTime()+3e5);
  10357. if(overDLA) {
  10358. fat=Math.floor(fatigue/1.25);
  10359. }
  10360.  
  10361. // Gestion des BM de fatigue
  10362. if(bmfatigue>0) {
  10363. // On tente de recuperer les BM de fatigue de la page des BM
  10364. if(MY_getValue(numTroll+'.bm.fatigue')) {
  10365. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  10366. BMmemoire.pop();
  10367. var tour = 0;
  10368. for(var i=0 ; i<BMmemoire.length ; i++) {
  10369. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  10370. while(tour<=parseInt(nbrs[0])) {
  10371. listeBmFat[tour]=parseInt(nbrs[1]);
  10372. tour++;
  10373. }
  10374. }
  10375. }
  10376. if(listeBmFat[0]==bmfatigue) {
  10377. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  10378. BMfrais = true;
  10379. MY_removeValue(numTroll+".bm.fatigue");
  10380. }
  10381. } else {
  10382. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  10383. BMfrais = true;
  10384. }
  10385. if(!BMfrais && bmfatigue>0) {
  10386. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  10387. if(bmfatigue==15) {
  10388. listeBmFat = [15,15,15];
  10389. } else {
  10390. listeBmFat = [30,30,15];
  10391. }
  10392. }
  10393. if(overDLA) {
  10394. // Si on est en over-DLA, on decale les bm d'un tour
  10395. listeBmFat.shift();
  10396. }
  10397. // Tableau des fatigues et accel futures
  10398. var
  10399. minppv = minParPVsac(fat,listeBmFat[0]),
  10400. table, tbody,
  10401. ligneTour, ligneFat, ligneMin,
  10402. col;
  10403. // ***INIT GLOBALE*** minParPV
  10404. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10405. if(fat>0 || listeBmFat[0]>0) {
  10406. table = document.createElement('table');
  10407. table.className = 'mh_tdborder';
  10408. table.border = 0;
  10409. table.cellSpacing = 1;
  10410. table.cellPadding = 1;
  10411. table.style.textAlign = "center";
  10412. tbody = document.createElement('tbody');
  10413. table.appendChild(tbody);
  10414. insertPt.appendChild(table);
  10415. ligneTour = appendTr(tbody,'mh_tdtitre');
  10416. ligneTour.style.fontWeight = "bold";
  10417. var td = appendTdText(ligneTour,'Tour :',true);
  10418. td.align = 'left';
  10419. ligneFat = appendTr(tbody,'mh_tdpage');
  10420. td = appendTdText(ligneFat,'Fatigue :',true);
  10421. td.className = 'mh_tdtitre';
  10422. td.align = 'left';
  10423. ligneMin = appendTr(tbody,'mh_tdpage');
  10424. td = appendTdText(ligneMin,'1 PV =',true);
  10425. td.className = 'mh_tdtitre';
  10426. td.align = 'left';
  10427. col=0;
  10428. while(col<9 && (fat>0 || listeBmFat[col])) {
  10429. if(col==0) {
  10430. if(overDLA) {
  10431. var i = document.createElement('i');
  10432. appendText(i,'A activer');
  10433. ligneTour.appendChild(i);
  10434. } else {
  10435. appendTdText(ligneTour,'En cours');
  10436. }
  10437. } else {
  10438. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10439. }
  10440. if(listeBmFat[col]) {
  10441. if(BMfrais || (!overDLA && col==0)) {
  10442. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10443. appendTdText(ligneMin,minppv[1]+'\'');
  10444. } else {
  10445. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10446. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10447. }
  10448. } else {
  10449. appendTdText(ligneFat,fat);
  10450. appendTdText(ligneMin,minppv[0]+'\'');
  10451. }
  10452. col++;
  10453. fat = Math.floor(fat / 1.25);
  10454. minppv = minParPVsac(fat,listeBmFat[col]);
  10455. }
  10456. if(fat>1 || (fat==1 && !overDLA)) {
  10457. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10458. appendTdText(ligneFat,'-');
  10459. appendTdText(ligneMin,'-');
  10460. }
  10461. col = (overDLA) ?
  10462. Math.max(retourAZero(fatigue)-1,col) :
  10463. Math.max(retourAZero(fatigue),col);
  10464. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10465. appendTdText(ligneFat,'0');
  10466. appendTdText(ligneMin,'30\'');
  10467. if(!BMfrais && bmfatigue) {
  10468. // si les BM n'ont pas ete rafraichis, on signale:
  10469. appendText(
  10470. insertPt,
  10471. '/!\\ Visitez la page des Bonus/Malus '+
  10472. 'pour mettre à jour votre fatigue. /!\\',
  10473. true
  10474. );
  10475. appendBr(insertPt);
  10476. }
  10477. appendBr(insertPt);
  10478. }
  10479. if(pvcourant<=0) {
  10480. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10481. return;
  10482. }
  10483. if(fatigue>30) {
  10484. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10485. return;
  10486. }
  10487. // Setup lastDLAZone
  10488. if(overDLA) {
  10489. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10490. DLAaccel = new Date( DLAsuiv );
  10491. lastDLA = new Date( DLA );
  10492. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10493. // ***INIT GLOBALE*** pvActuelKastar
  10494. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10495. appendText(
  10496. insertPt,
  10497. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10498. true
  10499. );
  10500. appendBr(insertPt);
  10501. } else {
  10502. DLAaccel = new Date( DLA );
  10503. pvActuelKastar = pvcourant;
  10504. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10505. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10506. } else {
  10507. lastDLA = false;
  10508. }
  10509. }
  10510. appendText(insertPt,'Dernière DLA enregistrée : ');
  10511. lastDLAZone = document.createElement('span');
  10512. lastDLAZone.style.cursor = 'pointer';
  10513. var b = document.createElement('b');
  10514. b.onclick = inputMode;
  10515. lastDLAZone.appendChild(b);
  10516. insertPt.appendChild(lastDLAZone);
  10517. if(lastDLA) {
  10518. appendText(b,DateToString(lastDLA));
  10519. } else {
  10520. appendText(b,'aucune');
  10521. }
  10522. appendBr(insertPt);
  10523. // Setup maxAMZone et cumulZone
  10524. appendText(insertPt,'Accélération maximale possible : ');
  10525. maxAMZone = document.createElement('b');
  10526. insertPt.appendChild(maxAMZone);
  10527. appendBr(insertPt);
  10528. cumulZone = document.createElement('span');
  10529. insertPt.appendChild(cumulZone);
  10530. refreshAccel();
  10531. }
  10532.  
  10533. function refreshAccel() {
  10534. var pvs, pvsmax;
  10535. // Acceleration pour cumul instantane
  10536. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10537. if(lastDLA) {
  10538. pvsmax = Math.min(
  10539. pvActuelKastar-1,
  10540. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10541. );
  10542. maxAMZone.innerHTML = pvsmax+" PV";
  10543. } else {
  10544. pvsmax = pvActuelKastar-1;
  10545. maxAMZone.innerHTML = "inconnue";
  10546. }
  10547. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10548. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10549. cumulZone.innerHTML = '';
  10550. if(pvs<=pvsmax) {
  10551. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10552. appendText(cumulZone,pvs+' PV', true);
  10553. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10554. if(pvs!=1) {
  10555. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10556. -(pvs-1)*60*minParPV;
  10557. appendText(
  10558. cumulZone,
  10559. ' ('+(pvs-1)+' PV dans '+
  10560. Math.floor(gainSec/60)+'min'+
  10561. addZero(gainSec%60)+'s)'
  10562. );
  10563. }
  10564. } else {
  10565. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10566. appendText(
  10567. cumulZone,
  10568. 'Après votre accélération maximale, il vous faudra encore attendre '+
  10569. dureeHM(avantDLA/6e4)+
  10570. ' avant de réactiver.'
  10571. );
  10572. }
  10573. }
  10574.  
  10575.  
  10576. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  10577.  
  10578. function traitementTalents() {
  10579. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  10580. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  10581. removeAllTalents();
  10582. var totalComp = injecteInfosBulles(trCompetence,'competences');
  10583. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  10584. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  10585. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  10586. }
  10587.  
  10588. function injecteInfosBulles(liste,fonction) {
  10589. var totalpc = 0;
  10590. // on parse la liste des talents du type 'fonction'
  10591. for(var i=0 ; i<liste.length ; i++) {
  10592. var
  10593. trTalent=liste[i],
  10594. node=trTalent.cells[1].querySelector('a'),
  10595. nomTalent=epure(trim(node.textContent)),
  10596. indiceTDniveaux=7,
  10597. indiceTDSousCompetence=2,
  10598. sousCompetences=undefined;
  10599. if(fonction=="competences"){
  10600. // un TD en plus pour des information complementaire liees a la comp
  10601. indiceTDniveaux++;
  10602. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  10603. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  10604. for (var j=0; j < sousCompetences.length; j++) {
  10605. sousCompetences[j] = sousCompetences[j].epure().trim();
  10606. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  10607. }
  10608. }
  10609. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  10610. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  10611. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  10612. totalpc += niveauxMaitrisesTalentArray[1];
  10613.  
  10614. // stockage des niveaux inferieurs du talent si presents
  10615. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  10616. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  10617. totalpc+=niveauxMaitrisesTalentArray[j+1];
  10618. }
  10619. }
  10620. return totalpc;
  10621. }
  10622.  
  10623. function setInfos(node,nom,fonction,niveau) {
  10624. node.nom = nom;
  10625. node.fonction = fonction;
  10626. node.niveau = niveau;
  10627. node.onmouseover = setBulle;
  10628. node.onmouseout = cacherBulle;
  10629. }
  10630.  
  10631. var arrayModifAnatroll = {
  10632. 'Glue':'Glu',
  10633. 'PuM':'PuiM',
  10634. 'HE':'Hurlement',
  10635. //'Insultes':'Insu',
  10636. 'Pistage':'Pist',
  10637. 'PuC':'Planter'
  10638. }
  10639.  
  10640. function setTalent(nom,pc,niveau,sousCompetences) {
  10641. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  10642. // (et pas les % dont osf) ne serait pas plus rentable
  10643. var nomEnBase = arrayTalents[epure(nom)];
  10644. if(!nomEnBase) { return; }
  10645. if(!niveau) { niveau = 1; }
  10646. switch(nomEnBase) {
  10647. case 'Insultes':
  10648. urlAnatrolliseur += 'Insu'+niveau+'|';
  10649. case 'IdT':
  10650. nomEnBase += niveau;
  10651. break;
  10652. case 'Golemo':
  10653. case 'Piege':
  10654. for (var i=0 ; i < sousCompetences.length ; i++) {
  10655. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  10656. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  10657. }
  10658. break;
  10659. case 'AP':
  10660. case 'Baroufle':
  10661. case 'CdB':
  10662. case 'CdM':
  10663. case 'Parer':
  10664. case 'Retraite':
  10665. case 'RB':
  10666. case 'SInterposer':
  10667. nomEnBase += niveau;
  10668. default:
  10669. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  10670. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  10671. }
  10672. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  10673. }
  10674.  
  10675. function creerBulleVide() {
  10676. var table = document.createElement('table');
  10677. table.id = 'bulle';
  10678. table.className = 'mh_tdborder';
  10679. table.width = 300;
  10680. table.border = 0;
  10681. table.cellPadding = 5;
  10682. table.cellSpacing = 1;
  10683. table.style =
  10684. 'position:absolute;'
  10685. +'visibility:hidden;'
  10686. +'z-index:800;'
  10687. +'height:auto;';
  10688. var tr = appendTr(table,'mh_tdtitre');
  10689. appendTdText(tr,'Titre');
  10690. tr = appendTr(table,'mh_tdpage');
  10691. appendTdText(tr,'Contenu');
  10692. var aList = document.getElementsByTagName('a');
  10693. aList[aList.length-1].parentNode.appendChild(table);
  10694. }
  10695.  
  10696. function cacherBulle() {
  10697. if(bulleStyle)
  10698. bulleStyle.visibility = 'hidden';
  10699. }
  10700.  
  10701. function setBulle(evt) {
  10702. var nom = this.nom;
  10703. var fonction = this.fonction;
  10704. var niveau = parseInt(this.niveau);
  10705. var str='';
  10706. if(fonction=='competences'){
  10707. str=competences(nom,niveau);
  10708. } else if(fonction=='sortileges') {
  10709. str=sortileges(nom,true);
  10710. }
  10711. if(str=='') return;
  10712. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  10713. var xfenetre, yfenetre, xpage, ypage, element = null;
  10714. var offset = 15;
  10715. var bulleWidth = 300;
  10716. if(!hauteur) hauteur = 50;
  10717. element = document.getElementById('bulle');
  10718. xfenetre = evt.clientX;
  10719. yfenetre = evt.clientY;
  10720. xpage = xfenetre;
  10721. ypage = yfenetre;
  10722. if(evt.pageX) xpage = evt.pageX;
  10723. if(evt.pageY) ypage = evt.pageY;
  10724. if(element) {
  10725. bulleStyle = element.style;
  10726. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  10727. element.childNodes[1].firstChild.innerHTML = str;
  10728. }
  10729. if(bulleStyle) {
  10730. if(xfenetre>bulleWidth+offset)
  10731. xpage -= bulleWidth+offset;
  10732. else
  10733. xpage += offset;
  10734. if(yfenetre>hauteur+offset)
  10735. ypage -= hauteur + offset;
  10736. bulleStyle.width = bulleWidth;
  10737. bulleStyle.left = xpage + 'px';
  10738. bulleStyle.top = ypage + 'px';
  10739. bulleStyle.visibility = 'visible';
  10740. }
  10741. }
  10742.  
  10743.  
  10744. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  10745.  
  10746. function competences(comp,niveau) {
  10747. var texte = '';
  10748. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  10749. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  10750. if(minParPV>1) texte += 's';
  10751. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  10752. }
  10753. else if(comp.indexOf('Attaque Precise')!=-1) {
  10754. var pc, lastmax=0, espatt=0;
  10755. var notMaxedOut = false;
  10756. for(var i=niveau ; i>0 ; i--) {
  10757. pc = getTalent(comp,i);
  10758. if(lastmax!=0 && pc<=lastmax) continue;
  10759. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  10760. attbp+attbm;
  10761. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10762. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  10763. ' => <b>'+jetatt+'</b><br/>';
  10764. espatt += (pc-lastmax)*jetatt;
  10765. lastmax = pc;
  10766. if(i<niveau) notMaxedOut = true;
  10767. }
  10768. if(notMaxedOut) {
  10769. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  10770. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  10771. }
  10772. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  10773. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10774. }
  10775. else if(comp.indexOf('Balayage')!=-1)
  10776. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  10777. +' => <b>'+attmoy+'</b><br/>'
  10778. +'Effet : <b>Met à terre l\'adversaire</b>';
  10779. else if(comp.indexOf('Bidouille')!=-1)
  10780. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  10781. +'de votre inventaire avec le texte de votre choix.';
  10782. else if(comp.indexOf('Baroufle')!=-1){
  10783. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  10784. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  10785. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  10786. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  10787. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  10788. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  10789. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  10790. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  10791. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  10792. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  10793. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  10794. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  10795. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  10796. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  10797. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  10798. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  10799. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  10800. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  10801. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  10802. '</tbody></table>';
  10803. }
  10804. else if(comp.indexOf('Botte Secrete')!=-1){
  10805. texte = 'Attaque : <b>'
  10806. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10807. +' => <b>'
  10808. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  10809. +'</b><br/>Dégâts : <b>'
  10810. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  10811. +' => <b>'
  10812. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  10813. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  10814. +'</b>';
  10815. }
  10816. else if(comp.indexOf('Camouflage')!=-1) {
  10817. var camou = getTalent('Camouflage');
  10818. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  10819. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  10820. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  10821. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  10822. }
  10823. else if(comp.indexOf('Charger')!=-1) {
  10824. if(pvcourant<=0)
  10825. return '<i>On ne peut charger personne quand on est mort !</i>';
  10826. var portee = Math.min(
  10827. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  10828. vuetotale);
  10829. if(portee<1)
  10830. return '<b>Impossible de charger</b>';
  10831. else {
  10832. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10833. +' => <b>'+attmoy+'</b><br/>'
  10834. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10835. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  10836. +'<br/>Portée : <b>'+portee+'</b> case';
  10837. if(portee>1) texte += 's';
  10838. }
  10839. }
  10840. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  10841. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  10842. if(vuetotale>1) texte += 's';
  10843. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10844. if(vuetotale>2) texte += 's';
  10845. }
  10846. else if(comp.indexOf('Piege')!=-1) {
  10847. if(comp.indexOf('Glue')!=-1)
  10848. texte = 'Et si vous colliez vos adversaires au sol ?';
  10849. if(comp.indexOf('Feu')!=-1) {
  10850. if(texte){
  10851. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  10852. }
  10853. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  10854. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  10855. }
  10856. }
  10857. else if(comp.indexOf('Contre-Attaquer')!=-1){
  10858. texte = 'Attaque : <b>'
  10859. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  10860. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10861. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10862. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10863. }
  10864. else if(comp.indexOf('Coup de Butoir')!=-1) {
  10865. var pc, lastmax=0, espdeg=0;
  10866. var notMaxedOut = false;
  10867. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10868. +' => <b>'+attmoy+'</b>';
  10869. for(var i=niveau ; i>0 ; i--) {
  10870. pc = getTalent(comp,i);
  10871. if(lastmax!=0 && pc<=lastmax) continue;
  10872. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  10873. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  10874. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  10875. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  10876. espdeg += (pc-lastmax)*jetdeg;
  10877. lastmax = pc;
  10878. if(i<niveau) notMaxedOut = true;
  10879. }
  10880. if(notMaxedOut) {
  10881. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  10882. Math.floor(10*espdeg/lastmax)/10+'/'+
  10883. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  10884. }
  10885. }
  10886. else if(comp.indexOf('Course')!=-1)
  10887. texte = 'Déplacement gratuit : <b>'
  10888. +Math.floor(getTalent('Course')/2)
  10889. +' %</b> de chance';
  10890. else if(comp.indexOf('Deplacement Eclair')!=-1)
  10891. texte = 'Permet d\'économiser <b>1</b> PA '
  10892. +'par rapport au déplacement classique';
  10893. else if(comp.indexOf('Dressage')!=-1)
  10894. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  10895. +'ou un gnu sauvage.';
  10896. else if(comp.indexOf('Ecriture Magique')!=-1)
  10897. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  10898. +'la formule nécessite de réunir les composants de cette formule, '
  10899. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  10900. +'un champignon adéquat pour confectionner l\'encre.';
  10901. else if(comp.indexOf('Frenesie')!=-1) {
  10902. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  10903. +' => <b>'+attmoy+'</b><br/>'
  10904. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  10905. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  10906. }
  10907. else if(comp.indexOf('Golem')!=-1)
  10908. texte = 'Animez votre golem en assemblant divers matériaux '
  10909. +'autour d\'un cerveau minéral.'
  10910. else if(comp.indexOf('Grattage')!=-1) {
  10911. texte = 'Permet de confectionner un Parchemin Vierge '
  10912. +'à partir de composants et de Gigots de Gob\'.';
  10913. }
  10914. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  10915. texte = 'Fait fuir un monstre si tout se passe bien.'
  10916. +'<br/>Lui donne de gros bonus sinon...';
  10917. else if(comp.indexOf('Identification des Champignons')!=-1) {
  10918. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  10919. if(vuetotale>2) texte += 's';
  10920. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  10921. if(vuetotale>4) texte += 's';
  10922. }
  10923. else if(comp.indexOf('Insultes')!=-1)
  10924. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  10925. else if(comp.indexOf('interposer')!=-1)
  10926. texte = 'Jet de réflexe : <b>'
  10927. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  10928. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  10929. else if(comp.indexOf('Lancer de Potions') != -1)
  10930. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  10931. else if(comp.indexOf('Marquage')!=-1)
  10932. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  10933. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  10934. +'se trouver dans la même caverne que le monstre pour le marquer.';
  10935. else if(comp.indexOf('Melange Magique')!=-1)
  10936. texte = 'Cette Compétence permet de combiner deux Potions pour '
  10937. +'en réaliser une nouvelle dont l\'effet est la somme '
  10938. +'des effets des potions initiales.';
  10939. else if(comp.indexOf('Miner')!=-1)
  10940. texte = 'Portée horizontale (officieuse) : <b>'
  10941. +2*vuetotale+'</b> cases<br/>'
  10942. +'Portée verticale (officieuse) : <b>'
  10943. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10944. else if(comp.indexOf('Necromancie')!=-1)
  10945. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  10946. +'de faire "revivre" ce monstre.';
  10947. else if(comp.indexOf('Painthure de Guerre')!=-1)
  10948. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  10949. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  10950. +'pour s\'inspirer, et laissez parler votre créativité.'
  10951. else if(comp.indexOf('Parer')!=-1)
  10952. texte = 'Jet de parade : <b>'
  10953. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  10954. +' => <b>'
  10955. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  10956. +'</b><hr><i>Equivalent esquive : <b>'
  10957. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  10958. +' => <b>'
  10959. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  10960. +'</b></i>';
  10961. else if(comp.indexOf('Pistage')!=-1)
  10962. texte = 'Portée horizontale : <b>'
  10963. +2*vuetotale+'</b> cases<br/>'
  10964. +'Portée verticale : <b>'
  10965. +2*Math.ceil(vuetotale/2)+'</b> cases';
  10966. else if(comp.indexOf('Planter un Champignon')!=-1)
  10967. texte = 'Planter un Champignon est une compétence qui vous permet de '
  10968. +'créer des colonies d\'une variété donnée de champignon à partir de '
  10969. +'quelques exemplaires préalablement enterrés.';
  10970. else if(comp.indexOf('Regeneration Accrue')!=-1)
  10971. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  10972. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  10973. else if(comp.indexOf('Reparation')!=-1)
  10974. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  10975. +'et réparez vous-même votre matériel !';
  10976. else if(comp.indexOf('Retraite')!=-1)
  10977. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  10978. +'préférable de préparer un repli stratégique pour déconcerter '
  10979. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  10980. +'Quelle intelligence démoniaque.';
  10981. else if(comp.indexOf('Rotobaffe')!=-1) {
  10982. var Datt = att, vattbm = attbp+attbm;
  10983. var Ddeg = deg, vdegbm = degbp+degbm;
  10984. for(var i=1 ; i<niveau+2 ; i++) {
  10985. texte += '<b>Attaque n°'+i+' :</b><br/>'
  10986. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  10987. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  10988. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  10989. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  10990. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  10991. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  10992. if(i<niveau+1) texte += '<hr>';
  10993. }
  10994. }
  10995. else if(comp.indexOf('Shamaner')!=-1)
  10996. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  10997. +'des monstres en utilisant des champignons (de 1 à 3).';
  10998. else if(comp.indexOf('Tailler')!=-1){
  10999. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11000. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11001. }
  11002. return texte;
  11003. }
  11004.  
  11005. function decumul_buff(nom,str,buff) {
  11006. // Decumul des sorts de buff
  11007. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11008. var dec = buff, total = buff, i=1;
  11009. while(i<6) {
  11010. i++;
  11011. dec = Math.floor(coefDecumul(i)*buff);
  11012. if(dec<=1 || i==6) break;
  11013. total += dec;
  11014. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11015. +str+' +'+dec+' (+'+total+')</i>';
  11016. }
  11017. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11018. return ret;
  11019. }
  11020.  
  11021.  
  11022. function sortileges(sort,mainCall,pcA,pcD) {
  11023. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11024. var texte = '';
  11025. if (mainCall) {
  11026. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11027. pcA = (atttourP+atttourM);
  11028. pcD = (degtourP+degtourM);
  11029. }
  11030. if (sort.indexOf('Analyse Anatomique') != -1) {
  11031. texte = 'Portée horizontale : <b>'
  11032. + Math.floor(vuetotale / 2) + '</b> case';
  11033. if (vuetotale > 3){ texte += 's'; }
  11034. texte += '<br/>Portée verticale : <b>'
  11035. + Math.floor((vuetotale+1)/4)+'</b> case';
  11036. if (vuetotale > 7){ texte += 's'; }
  11037. }
  11038. else if (sort.indexOf('Armure Etheree') != -1){
  11039. texte = decumul_buff('AE', 'Armure magique', reg);
  11040. }
  11041. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11042. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11043. }
  11044. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11045. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11046. }
  11047. else if (sort.indexOf('Augmentation des Degats') != -1){
  11048. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11049. }
  11050. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11051. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11052. }
  11053. else if(sort.indexOf('Bulle Magique')!=-1){
  11054. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11055. }
  11056. else if(sort.indexOf('Explosion')!=-1){
  11057. texte = 'Dégâts : <b>'
  11058. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11059. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11060. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11061. }
  11062. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11063. if(pvcourant<=0)
  11064. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11065. texte = 'Portée horizontale : <b>'
  11066. +Math.min(1,vuetotale)+'</b> case<br/>'
  11067. +'Dégâts physiques : <b>-'
  11068. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11069. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11070. +'Dégâts magiques : <b>-'
  11071. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11072. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11073. }
  11074. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11075. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11076. }
  11077. else if(sort.indexOf('Glue')!=-1) {
  11078. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11079. if(vuetotale>2) texte += 's';
  11080. }
  11081. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11082. /* Frappe */
  11083. var modD = 0;
  11084. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11085. if(pcA!=0){
  11086. modD = parseInt(att*pcA/100);
  11087. texte += '<i>'+aff(modD)+'D6</i> ';
  11088. }
  11089. texte += aff(attbm)
  11090. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11091. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11092. if(pcD!=0) {
  11093. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11094. texte += '<i>'+aff(modD)+'D3</i> ';
  11095. }else
  11096. modD = 0;
  11097. texte += aff(degbm)+' => <b>'
  11098. +(2*(Math.floor(deg/2)+modD)+degbm)
  11099. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11100. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11101. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11102. +')</b>';
  11103. if(!mainCall) return texte;
  11104. /* Venins */
  11105. function addVenin(type,effet,duree) {
  11106. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11107. +' pendant <b>'+duree+'</b> tour';
  11108. if(duree>1) ret += 's';
  11109. var dred = Math.max(Math.floor(duree/2),1);
  11110. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11111. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11112. }
  11113. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11114. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11115. effet = Math.floor(1.5*effet);
  11116. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11117. }
  11118. else if(sort.indexOf('Hypnotisme')!=-1)
  11119. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11120. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11121. else if(sort.indexOf('Identification des tresors')!=-1)
  11122. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11123. +'d\'un trésor.';
  11124. else if(sort.indexOf('Invisibilite')!=-1)
  11125. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11126. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11127. +'fait disparaître l\'invisibilité.';
  11128. else if(sort.indexOf('Levitation')!=-1)
  11129. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11130. +'Comme les pièges ou les trous par exemple...';
  11131. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11132. var eps = 1,
  11133. pc = 20;
  11134. var str = 'PréM';
  11135. var newSort;
  11136. var sortAtt = [
  11137. 'Projectile Magique',
  11138. 'Rafale Psychique',
  11139. 'Siphon des Ames',
  11140. 'Vampirisme',
  11141. 'Griffe du Sorcier'
  11142. ];
  11143. if(sort.indexOf('Puissance')!=-1) {
  11144. eps = -1; str='PuM';
  11145. }
  11146. for(var i=1 ; i<4 ; i++) {
  11147. if(texte) { texte += '<hr>'; }
  11148. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11149. newSort = false;
  11150. for(var j=0 ; j<sortAtt.length ; j++) {
  11151. if(getTalent(sortAtt[j])) {
  11152. if(newSort) { texte += '<br/><br/>'; }
  11153. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  11154. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  11155. newSort = true;
  11156. }
  11157. }
  11158. pc = decumulPumPrem(pc);
  11159. }
  11160. }
  11161. else if(sort.indexOf('Projectile Magique')!=-1) {
  11162. var modD = 0;
  11163. var portee = getPortee__Profil(vuetotale);
  11164. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  11165. if(pcA!=0) {
  11166. modD = parseInt(vue*pcA/100);
  11167. texte += '<i>'+aff(modD)+'D6</i> ';
  11168. }
  11169. texte += aff(attbm)
  11170. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  11171. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  11172. if(pcD!=0) {
  11173. modD = parseInt(Math.floor(vue/2)+pcD);
  11174. texte += '<i>'+aff(modD)+'D3</i> ';
  11175. }else
  11176. modD = 0;
  11177. texte += aff(degbm)
  11178. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  11179. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  11180. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  11181. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  11182. if(!mainCall) return texte;
  11183. texte += '<br/>Portée : <b>'+portee+'</b> case';
  11184. if(portee>1) texte += 's';
  11185. }
  11186. else if(sort.indexOf('Projection')!=-1) {
  11187. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  11188. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  11189. +'Si le jet de résistance de la victime est réussi:<br/>'
  11190. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  11191. }
  11192. else if(sort.indexOf('Rafale Psychique')!=-1) {
  11193. var modD = 0;
  11194. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  11195. if(pcD!=0) {
  11196. modD = parseInt(deg*pcD/100);
  11197. texte += '<i>'+aff(modD)+'D3</i> ';
  11198. }
  11199. texte += aff(degbm)
  11200. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  11201. if(!mainCall) return texte;
  11202. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  11203. }
  11204. else if(sort.indexOf('Sacrifice')!=-1) {
  11205. if(pvcourant<=0)
  11206. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  11207.  
  11208. function perteSacro(sac) {
  11209. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  11210. }
  11211.  
  11212. var sac = Math.floor((pvcourant-1)/2);
  11213. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11214. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  11215. /* Sacros max et optimal sans malus (propale R') */
  11216. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11217. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  11218. if(sac>0)
  11219. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  11220. else
  11221. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  11222. /*if(sac>3) {
  11223. sac = 5*Math.floor((sac+1)/5)-1;
  11224. texte += '<br/>Soin optimal sans malus de temps : <b>'
  11225. +sac+'</b> PV'+perteSacro(sac);
  11226. }*/
  11227. }
  11228. else if(sort.indexOf('Siphon')!=-1) {
  11229. var modD = 0;
  11230. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11231. if(pcA!=0) {
  11232. modD = parseInt(att*pcA/100);
  11233. texte += '<i>'+aff(modD)+'D6</i> ';
  11234. }
  11235. texte += aff(attbm)
  11236. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  11237. +'Dégâts : <b>'+reg+'</b> D3 ';
  11238. if(pcD!=0) {
  11239. modD = parseInt(reg*pcD/100);
  11240. texte += '<i>'+aff(modD)+'D3</i> ';
  11241. }else
  11242. modD = 0;
  11243. texte += aff(degbm)
  11244. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  11245. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  11246. if(!mainCall) return texte;
  11247. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  11248. }
  11249. else if(sort.indexOf('Telekinesie')!=-1) {
  11250. texte = 'Portée horizontale :';
  11251. var vt = Math.floor(vuetotale/2)+2;
  11252. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  11253. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  11254. for(var i=0 ; i<5 ; i++) {
  11255. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  11256. if(vt>1) texte += 's';
  11257. vt=Math.max(0,vt-1);
  11258. }
  11259. }
  11260. else if(sort.indexOf('Teleportation')!=-1) {
  11261. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  11262. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  11263. var pmh = (20+vue+portee);
  11264. var pmv = 3+Math.floor(portee/3);
  11265. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  11266. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  11267. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  11268. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  11269. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  11270. }
  11271. else if(sort.indexOf('Vampirisme')!=-1) {
  11272. var modD = 0;
  11273. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  11274. if(pcA!=0) {
  11275. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  11276. texte += '<i>'+aff(modD)+'D6</i> ';
  11277. }
  11278. texte += aff(attbm)
  11279. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  11280. +'Dégâts : <b>'+deg+'</b> D3 ';
  11281. if(pcD!=0) {
  11282. modD = parseInt(deg*pcD/100);
  11283. texte += '<i>'+aff(modD)+'D3</i> ';
  11284. }else
  11285. modD = 0;
  11286. texte += aff(degbm)
  11287. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  11288. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  11289. }
  11290. else if(sort.indexOf('Vision Accrue')!=-1)
  11291. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  11292. else if(sort.indexOf('Vision lointaine')!=-1)
  11293. texte = 'En ciblant une zone située n\'importe où dans le '
  11294. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  11295. else if(sort.indexOf('Voir le Cache')!=-1)
  11296. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  11297. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  11298. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  11299. +getPortee__Profil(vuetotale)+'</b> cases';
  11300. else if(sort.indexOf('Vue Troublee')!=-1)
  11301. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11302. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  11303. return texte;
  11304. }
  11305.  
  11306.  
  11307. /*---------------------------------- Main ------------------------------------*/
  11308.  
  11309. function do_profil2()
  11310. {
  11311. try {
  11312. start_script(31);
  11313.  
  11314. extractionDonnees();
  11315. setInfosCaracteristiques();
  11316. setInfoDescription();
  11317. setInfosEtatLieux();
  11318. setInfosEtatPV();
  11319. setInfosExp();
  11320.  
  11321. creerBulleVide();
  11322. traitementTalents();
  11323. setLienAnatrolliseur();
  11324.  
  11325. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  11326. if(race=='Kastar'){ setAccel(); }
  11327. saveProfil();
  11328. displayScriptTime();
  11329. } catch(e) {
  11330. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  11331. window.console.error(traceStack(e, 'profil2'));
  11332. }
  11333. }
  11334.  
  11335. /*******************************************************************************
  11336. * This file is part of Mountyzilla. *
  11337. * *
  11338. * Mountyzilla is free software; you can redistribute it and/or modify *
  11339. * it under the terms of the GNU General Public License as published by *
  11340. * the Free Software Foundation; either version 2 of the License, or *
  11341. * (at your option) any later version. *
  11342. * *
  11343. * Mountyzilla is distributed in the hope that it will be useful, *
  11344. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11345. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11346. * GNU General Public License for more details. *
  11347. * *
  11348. * You should have received a copy of the GNU General Public License *
  11349. * along with Mountyzilla; if not, write to the Free Software *
  11350. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11351. *******************************************************************************/
  11352.  
  11353. // x~x script_principal
  11354.  
  11355. function isPage(url) {
  11356. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11357. }
  11358.  
  11359. // x~x md5.js
  11360. /*
  11361. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11362. * Digest Algorithm, as defined in RFC 1321.
  11363. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11364. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11365. * Distributed under the BSD License
  11366. * See http://pajhome.org.uk/crypt/md5 for more info.
  11367. */
  11368.  
  11369. /*
  11370. * Configurable variables. You may need to tweak these to be compatible with
  11371. * the server-side, but the defaults work in most cases.
  11372. */
  11373. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11374. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11375. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11376.  
  11377. /*
  11378. * These are the functions you'll usually want to call
  11379. * They take string arguments and return either hex or base-64 encoded strings
  11380. */
  11381. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11382. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11383. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11384. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11385. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11386. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11387.  
  11388. /*
  11389. * Perform a simple self-test to see if the VM is working
  11390. */
  11391. function md5_vm_test()
  11392. {
  11393. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11394. }
  11395.  
  11396. /*
  11397. * Calculate the MD5 of an array of little-endian words, and a bit length
  11398. */
  11399. function core_md5(x, len)
  11400. {
  11401. /* append padding */
  11402. x[len >> 5] |= 0x80 << ((len) % 32);
  11403. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11404.  
  11405. var a = 1732584193;
  11406. var b = -271733879;
  11407. var c = -1732584194;
  11408. var d = 271733878;
  11409.  
  11410. for(var i = 0; i < x.length; i += 16)
  11411. {
  11412. var olda = a;
  11413. var oldb = b;
  11414. var oldc = c;
  11415. var oldd = d;
  11416.  
  11417. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11418. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11419. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11420. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11421. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11422. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11423. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11424. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11425. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11426. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11427. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11428. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11429. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11430. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11431. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11432. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11433.  
  11434. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11435. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11436. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11437. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11438. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11439. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11440. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11441. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11442. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11443. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11444. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11445. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11446. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11447. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11448. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11449. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11450.  
  11451. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11452. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11453. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11454. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11455. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11456. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11457. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11458. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11459. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11460. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11461. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11462. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11463. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11464. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11465. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11466. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11467.  
  11468. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11469. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11470. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11471. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11472. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11473. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11474. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11475. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11476. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11477. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11478. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11479. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11480. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11481. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11482. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11483. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11484.  
  11485. a = safe_add(a, olda);
  11486. b = safe_add(b, oldb);
  11487. c = safe_add(c, oldc);
  11488. d = safe_add(d, oldd);
  11489. }
  11490. return Array(a, b, c, d);
  11491.  
  11492. }
  11493.  
  11494. /*
  11495. * These functions implement the four basic operations the algorithm uses.
  11496. */
  11497. function md5_cmn(q, a, b, x, s, t)
  11498. {
  11499. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11500. }
  11501. function md5_ff(a, b, c, d, x, s, t)
  11502. {
  11503. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11504. }
  11505. function md5_gg(a, b, c, d, x, s, t)
  11506. {
  11507. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11508. }
  11509. function md5_hh(a, b, c, d, x, s, t)
  11510. {
  11511. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11512. }
  11513. function md5_ii(a, b, c, d, x, s, t)
  11514. {
  11515. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11516. }
  11517.  
  11518. /*
  11519. * Calculate the HMAC-MD5, of a key and some data
  11520. */
  11521. function core_hmac_md5(key, data)
  11522. {
  11523. var bkey = str2binl(key);
  11524. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11525.  
  11526. var ipad = Array(16), opad = Array(16);
  11527. for(var i = 0; i < 16; i++)
  11528. {
  11529. ipad[i] = bkey[i] ^ 0x36363636;
  11530. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11531. }
  11532.  
  11533. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11534. return core_md5(opad.concat(hash), 512 + 128);
  11535. }
  11536.  
  11537. /*
  11538. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11539. * to work around bugs in some JS interpreters.
  11540. */
  11541. function safe_add(x, y)
  11542. {
  11543. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11544. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11545. return (msw << 16) | (lsw & 0xFFFF);
  11546. }
  11547.  
  11548. /*
  11549. * Bitwise rotate a 32-bit number to the left.
  11550. */
  11551. function bit_rol(num, cnt)
  11552. {
  11553. return (num << cnt) | (num >>> (32 - cnt));
  11554. }
  11555.  
  11556. /*
  11557. * Convert a string to an array of little-endian words
  11558. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11559. */
  11560. function str2binl(str)
  11561. {
  11562. var bin = Array();
  11563. var mask = (1 << chrsz) - 1;
  11564. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11565. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11566. return bin;
  11567. }
  11568.  
  11569. /*
  11570. * Convert an array of little-endian words to a string
  11571. */
  11572. function binl2str(bin)
  11573. {
  11574. var str = "";
  11575. var mask = (1 << chrsz) - 1;
  11576. for(var i = 0; i < bin.length * 32; i += chrsz)
  11577. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11578. return str;
  11579. }
  11580.  
  11581. /*
  11582. * Convert an array of little-endian words to a hex string.
  11583. */
  11584. function binl2hex(binarray)
  11585. {
  11586. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11587. var str = "";
  11588. for(var i = 0; i < binarray.length * 4; i++)
  11589. {
  11590. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11591. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11592. }
  11593. return str;
  11594. }
  11595.  
  11596. /*
  11597. * Convert an array of little-endian words to a base-64 string
  11598. */
  11599. function binl2b64(binarray)
  11600. {
  11601. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11602. var str = "";
  11603. for(var i = 0; i < binarray.length * 4; i += 3)
  11604. {
  11605. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11606. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11607. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11608. for(var j = 0; j < 4; j++)
  11609. {
  11610. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11611. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11612. }
  11613. }
  11614. return str;
  11615. }
  11616.  
  11617. ///////////////////////////////////////////
  11618. // debug cartes capitan Roule 07/12/2016
  11619. ///////////////////////////////////
  11620. // essais : objet
  11621. // .mode : description
  11622. // .essais : tableau d'objets essai
  11623. // .mode : description
  11624. // .essais : tableau de cartes
  11625. // .noCarte : id de la carte
  11626. // .essais : tableau d'essais, [x, y, n, nb]
  11627. function AfficheEssais(essais, sMode) {
  11628. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11629. if (!eBigDiv) {
  11630. var insertPoint = document.getElementById('footer1');
  11631. eBigDiv = document.createElement('table');
  11632. eBigDiv.id = 'ListeEssaiCapitan';
  11633. insertBefore(insertPoint, document.createElement('p'));
  11634. insertTitle(insertPoint,'Capitan : Liste des essais');
  11635. insertBefore(insertPoint, eBigDiv);
  11636. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11637. }
  11638. if (!essais) {
  11639. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11640. return;
  11641. }
  11642. var carte;
  11643. for (carte in essais) {
  11644. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11645. }
  11646. if (carte === undefined) {
  11647. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11648. }
  11649. }
  11650.  
  11651. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11652. var tr = appendTr(eTable);
  11653. var td = appendTd(tr);
  11654. appendText(td, sMode, bBold);
  11655. td = appendTd(tr);
  11656. appendText(td, sCarte, bBold);
  11657. td = appendTd(tr);
  11658. appendText(td, sText, bBold);
  11659. }
  11660.  
  11661. function getEssaiV1_0() {
  11662. try {
  11663. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11664. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11665. var tabK, nK;
  11666. prefs.getChildList('', nK, tabK);
  11667. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11668. //window.console.log('getEssaiV1_0, ' + nK);
  11669. return;
  11670. //return r;
  11671. } catch (e) {
  11672. window.console.log(traceStack(e, 'getEssaiV1_0'));
  11673. }
  11674. }
  11675.  
  11676. function getEssaiV1_1() {
  11677. var locSto = window.localStorage;
  11678. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11679. var r = [];
  11680. for (var i = 0; i < locSto.length; i++) {
  11681. var k = locSto.key(i);
  11682. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11683. var t = k.split(/\./);
  11684. if (t[0] !== 'capitan') continue;
  11685. if (t[2] !== 'essai') continue;
  11686. var carte = 'carte n°' + t[1];
  11687. if (r[carte]) r[carte]++;
  11688. else r[carte] = 1;
  11689. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11690. }
  11691. return r;
  11692. }
  11693.  
  11694. function showEssaiCartes() {
  11695. window.console.log('début showEssai Tout_MZ');
  11696. var essais = getEssaiV1_0();
  11697. AfficheEssais(essais, 'V1.0');
  11698. essais = getEssaiV1_1();
  11699. AfficheEssais(essais, 'V1.1');
  11700. window.console.log('fin showEssai Tout_MZ');
  11701. }
  11702.  
  11703. /*--------------------------------- Création liste trolligion ---------------------------------*/
  11704. function export_trolligion() {
  11705. var tabDl = document.getElementsByTagName('dl');
  11706. if ((!tabDl) || !tabDl[0]) {
  11707. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  11708. return;
  11709. }
  11710. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  11711. // nom : string
  11712. // rayonnement : entier
  11713. // grades : table d'objets (une occurence par grade)
  11714. // nom : string
  11715. // trolls : table d'objets (un par Trõll)
  11716. // id
  11717. // nom
  11718. // idguilde
  11719. // guilde
  11720. // race
  11721. // niveau
  11722. // ferveur
  11723. var currentDieu;
  11724. var currentGrade;
  11725. for (var iChild1 in tabDl[0].children) {
  11726. var eChild1 = tabDl[0].children[iChild1];
  11727. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  11728. case 'dd': // Trõll
  11729. var oTroll = {};
  11730. var tabFigcaption = eChild1.getElementsByTagName('figcaption');
  11731. if ((!tabFigcaption) || !tabFigcaption[0]) {
  11732. window.console.log('[MZ ' + GM_info.script.version + '] ignore dd sans figcaption ' + eChild1.innerHTML);
  11733. break;
  11734. }
  11735. for (var iChild2 in tabFigcaption[0].childNodes) { // childNodes pour obtenir les éléments texte aussi
  11736. var eChild2 = tabFigcaption[0].childNodes[iChild2];
  11737. if (eChild2.nodeType === undefined) continue; // properties
  11738. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  11739. switch (eChild2.nodeType) {
  11740. case 1: //ELEMENT_NODE:
  11741. switch (eChild2.nodeName.toLowerCase()) {
  11742. case 'a':
  11743. var m;
  11744. if (!eChild2.href) {
  11745. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  11746. break;
  11747. }
  11748. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  11749. if (m) {
  11750. oTroll.id = parseInt(m[1]);
  11751. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  11752. break;
  11753. }
  11754. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  11755. if (m) {
  11756. var idGuilde = parseInt(m[1]);
  11757. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  11758. oTroll.idguilde = parseInt(m[1]);
  11759. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  11760. }
  11761. break;
  11762. }
  11763. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  11764. break;
  11765. case 'br': // ignore
  11766. case 'style': // ignore
  11767. break;
  11768. case 'div': // barre de vie
  11769. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  11770. eChild3 = eChild2.children[0];
  11771. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  11772. var eChild4 = eChild3.children[0];
  11773. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  11774. break;
  11775. }
  11776. }
  11777. // pas de break pour bénéficier du log ci-dessous
  11778. default:
  11779. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  11780. break;
  11781. }
  11782. break;
  11783. case 3: //TEXT_NODE:
  11784. var txt = eChild2.nodeValue.trim();
  11785. if (txt === '') break;
  11786. var m = txt.match(/(.*) *\((\d+)\)/);
  11787. if (m) {
  11788. oTroll.race = m[1].trim();
  11789. oTroll.niveau = parseInt(m[2]);
  11790. } else {
  11791. oTroll.race = txt;
  11792. }
  11793. break;
  11794. default: // ne devrait pas arriver
  11795. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  11796. break;
  11797. }
  11798. }
  11799. currentGrade.trolls.push(oTroll);
  11800. break;
  11801. case 'dt':
  11802. var tabH3 = eChild1.getElementsByTagName('h3');
  11803. if (tabH3 && tabH3[0]) { // changement de dieu
  11804. currentDieu = {
  11805. nom: tabH3[0].innerText || tabH3[0].textContent
  11806. , grades: []};
  11807. var txt = eChild1.innerText || eChild1.textContent;
  11808. var m = txt.match(/yon*ement *:* *(\d+)/);
  11809. if (m) currentDieu.rayonnement = parseInt(m[1]);
  11810. currentGrade = undefined;
  11811. tabDieux.push(currentDieu);
  11812. break;
  11813. }
  11814. var tabH4 = eChild1.getElementsByTagName('h4');
  11815. if (tabH4 && tabH4[0]) { // changement de grade
  11816. var grade;
  11817. var txt = tabH4[0].innerText || tabH4[0].textContent;
  11818. tabI = tabH4[0].getElementsByTagName('i');
  11819. if (tabI && tabI[0]) {
  11820. grade = tabI[0].innerText || tabI[0].textContent;
  11821. grade = grade.replace(/"/g, '');
  11822. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  11823. if (m) grade += ' (' + m[1] + ')';
  11824. } else {
  11825. grade = txt.replace(/"/g, '');
  11826. }
  11827. currentGrade = {nom: grade, trolls: []};
  11828. currentDieu.grades.push(currentGrade);
  11829. break;
  11830. }
  11831. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  11832. break;
  11833. default:
  11834. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  11835. }
  11836. }
  11837. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  11838. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  11839. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  11840. for (var iDieu in tabDieux) {
  11841. var oDieu = tabDieux[iDieu];
  11842. for (var iGrade in oDieu.grades) {
  11843. var oGrade = oDieu.grades[iGrade];
  11844. for (var iTroll in oGrade.trolls) {
  11845. var oTroll = oGrade.trolls[iTroll];
  11846. var t = [oDieu.nom, oDieu.rayonnement
  11847. , oGrade.nom
  11848. , oTroll.id, oTroll.nom
  11849. , oTroll.idguilde, oTroll.guilde
  11850. , oTroll.race, oTroll.niveau
  11851. , oTroll.ferveur];
  11852. for (var iParam in t) if (t[iParam] === undefined) t[iParam] = ''; // protection
  11853. txt += t.join("\t") + "\n";
  11854. }
  11855. }
  11856. }
  11857. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  11858. try {
  11859. copyTextToClipboard(txt);
  11860. window.alert("Les données ont été copiées dans le presse-papier\n"
  11861. + "Collez dans Calc\n"
  11862. + "ou, au pire, dans EXCEL®");
  11863. } catch(e) {
  11864. window.alert("Échec à la copie vers le presse-papier\n" + e);
  11865. }
  11866. }
  11867.  
  11868. function do_trolligion() {
  11869. var divpopup = document.createElement('div');
  11870. divpopup.id = 'MZ_divCopier';
  11871. divpopup.style.position = 'fixed';
  11872. divpopup.style.top = '2px';
  11873. divpopup.style.left = '2px;';
  11874. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  11875. divpopup.style.cursor = 'pointer';
  11876. divpopup.style.zIndex = 200;
  11877. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  11878. divpopup.onclick = export_trolligion;
  11879. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  11880. divpopup.appendChild(img);
  11881. document.body.appendChild(divpopup);
  11882. }
  11883.  
  11884. /*--------------------------------- Dispatch ---------------------------------*/
  11885.  
  11886. //chargerScriptDev("libs");
  11887. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  11888.  
  11889. try {
  11890. // Détection de la page à traiter
  11891. if(isPage("Messagerie/ViewMessageBot")) {
  11892. do_cdmbot();
  11893. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  11894. do_cdmcomp();
  11895. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  11896. do_diplo();
  11897. } else if(isPage("MH_Play/Play_equipement")) {
  11898. do_equip();
  11899. } else if(isPage("MH_Play/Play_menu")) {
  11900. do_menu();
  11901. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  11902. do_option();
  11903. //showEssaiCartes();
  11904. } else if(isPage("View/PJView")) {
  11905. do_pjview();
  11906. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  11907. do_profil();
  11908. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  11909. do_tancompo();
  11910. } else if(isPage("MH_Play/Play_vue")) {
  11911. do_vue();
  11912. } else if(isPage("MH_Play/Play_news")) {
  11913. do_news();
  11914. } else if(isPage("MH_Play/Actions/Play_a_Move") || isPage("MH_Lieux/Lieu_Teleport")) {
  11915. do_move();
  11916. } else if(isPage("MH_Missions/Mission_Etape")) {
  11917. do_mission();
  11918. } else if(isPage("View/MonsterView")) {
  11919. do_infomonstre();
  11920. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  11921. do_attaque();
  11922. } else if(isPage("MH_Follower/FO_Ordres")) {
  11923. do_ordresgowap();
  11924. } else if(isPage("MH_Follower/FO_Equipement")) {
  11925. do_equipgowap();
  11926. } else if(isPage("MH_Play/Play_mouche")) {
  11927. do_mouches();
  11928. } else if(isPage("MH_Play/Play_BM")) {
  11929. do_malus();
  11930. } else if(isPage("MH_Play/Play_evenement")) {
  11931. do_myevent();
  11932. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  11933. do_enchant();
  11934. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  11935. do_pre_enchant();
  11936. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  11937. do_actions();
  11938. } 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')) {
  11939. do_mission_liste();
  11940. } else if(isPage('MH_Play/Play_action')) {
  11941. do_actions();
  11942. } else if(isPage('MH_Play/Play_profil2')) {
  11943. do_profil2();
  11944. } else if(isPage('View/TrolligionView.php')) {
  11945. do_trolligion();
  11946. }
  11947. } catch(e) {
  11948. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  11949. }