Tout_MZ

Client MountyZilla

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

  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.16.1
  9. // @grant GM_getValue
  10. // @grant GM_deleteValue
  11. // @grant GM_setValue
  12. // ==/UserScript==
  13.  
  14. // vérif UTF-8 ş
  15.  
  16. /*******************************************************************************
  17. * This file is part of Mountyzilla. *
  18. * *
  19. * Mountyzilla is free software; you can redistribute it and/or modify *
  20. * it under the terms of the GNU General Public License as published by *
  21. * the Free Software Foundation; either version 2 of the License, or *
  22. * (at your option) any later version. *
  23. * *
  24. * Mountyzilla is distributed in the hope that it will be useful, *
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  27. * GNU General Public License for more details. *
  28. * *
  29. * You should have received a copy of the GNU General Public License *
  30. * along with Mountyzilla; if not, write to the Free Software *
  31. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  32. *******************************************************************************/
  33.  
  34. try {
  35. const MZ_changeLog = [
  36. "V1.2.16 21/02/2017",
  37. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  38. " possibilité de masquer les Gowaps Sauvages dans la vue",
  39. " calcul des caractéristiques du siphon des âmes",
  40. "V1.2.15.2 02/02/2017",
  41. " adaptation décumul VlC (page des bonus/malus)",
  42. "V1.2.15.1 29/01/2017",
  43. " carte sur la page de description du lieu TP",
  44. "V1.2.15 25/01/2017",
  45. " mise en place des nouvelles cartes (suivants, TP)",
  46. "V1.2.14.3 25/01/2017",
  47. " résumé dans l'export des données Trõlligion",
  48. "V1.2.14.2 20/01/2017",
  49. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  50. "V1.2.14.1 20/01/2017",
  51. " réécriture filtrage des monstres par niveau dans la vue",
  52. " Changelog dans la page des news MZ",
  53. "V1.2.14 20/01/2017",
  54. " Ajout de l'export des données Trõlligion",
  55. "V1.2.13.7 10/01/2017",
  56. " Exclusion Bricoll'troll dans l'entête GM",
  57. "V1.2.13.6 08/01/2017",
  58. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  59. "V1.2.13.5 07/01/2017",
  60. " Correction bug qui se manisfestait sous LINUX",
  61. "V1.2.13.4 07/01/2017",
  62. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  63. "V1.2.13.3 07/01/2017",
  64. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  65. "V1.2.13.2 07/01/2017",
  66. " Correction missions, recherche troogle (familles et types de monstres)",
  67. "V1.2.13.1 06/01/2017",
  68. " Suppression oldSchoolProfile qui n'existe plus",
  69. " Ajout du 'refresh' du cadre de gauche",
  70. "V1.2.13 01/01/2017",
  71. " homogénéisation des messages d'erreur",
  72. " Ajout du lien Troogle sur les étapes de mission monstre",
  73. "V1.2.12.2 30/12/2016",
  74. " retour en mode normal (http si jeu en http)",
  75. "V1.2.12.1 27/12/2016",
  76. " Correction mode IP",
  77. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  78. "V1.2.12 24/12/2016",
  79. " Nettoyage des URL",
  80. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  81. " Interface bricoll'Troll en https",
  82. " Remise en marche des cartes des trajets des gowaps",
  83. "V1.2.11.5 à 7 20 & 21/12/2016",
  84. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  85. "V1.2.11.4 19/12/2016",
  86. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  87. "V1.2.11.3 19/12/2016",
  88. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  89. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  90. "V1.2.11.2 18/12/2016",
  91. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  92. "V1.2.11.1 17/12/2016",
  93. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  94. "V1.2.11 13/12/2016",
  95. " Passage sur BdD Raistlin \\o/",
  96. "V1.2.10.4 12/12/2016",
  97. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  98. "V1.2.10.3 09/12/2016",
  99. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  100. "V1.2.10.2 09/12/2016",
  101. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  102. "V1.2.10.1 08/12/2016",
  103. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  104. "V1.2.10 07/12/2016",
  105. " correction décumul des bonus/malus",
  106. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  107. "V1.2.9 16/11/2016",
  108. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  109. "V1.2.8 10/11/2016",
  110. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  111. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  112. "V1.2.7 07/11/2016",
  113. " remise en route de l'interface avec l'IT bricol'Troll",
  114. "V1.2.6 19/10/2016",
  115. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  116. " stockage idguilde et nomguilde",
  117. "V1.2.5 17/10/2016",
  118. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  119. " remise en route de la gestion des options avec intégration md5 dans ce script",
  120. "V1.2.4 14/10/2016",
  121. " utilisation du relai raistlin pour l'envoi des CdM",
  122. "V1.2.3 :",
  123. " suppression ancien profil",
  124. " nettoyage doublon sur getPortee",
  125. " adaptation portee TP basée sur les PI",
  126. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  127. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  128. "V1.2.1 :",
  129. " include des URLs MH alternatives",
  130. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  131. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  132. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  133. "V1.1 : regroupement en un gros paquet sale",
  134. ];
  135.  
  136. /**********************************************************
  137. À faire / propositions d'évolutions
  138.  
  139. breizhou13 20/12/2016
  140. envoyer les données à l'IT (Bricol'Trolls) aussi
  141. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  142. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  143. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  144. Roule'
  145. Réactiver les jubilaires
  146. [Prioritaire] trajets Gowaps sans avoir besoin de URL_MZscriptCarte (voir comment c'est fait dans Trajet_des_gowap_MkII.user.js)
  147. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  148. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  149. - voir l'intérêt de refaire fonctionner
  150. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  151. 100 (post formum 10/02/2017
  152. Il y aurait moyen de rajouter la prise en compte du Siphon des ames sur les attaques prisent en compte par la calculette sur la vue ?
  153. **********************************************************/
  154.  
  155. /**********************************************************
  156. **** Début de zone à déplacer dans une bibli commune ******
  157. **********************************************************/
  158.  
  159. // URL de base serveur MZ
  160. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  161. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  162. //var URL_MZ = 'http://192.99.225.92/mz';
  163.  
  164. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  165. // à supprimer
  166. const newCarte = true;
  167. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  168.  
  169. // URLs externes redirection (pas de souci CORS)
  170. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  171. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  172. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  173. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  174. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  175. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  176. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  177. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  178. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  179.  
  180. // URLs de test HTTPS
  181. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  182. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  183.  
  184. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  185. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  186. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  187.  
  188. // x~x Libs
  189.  
  190. /* ancien TODO
  191. * - revoir la gestion des CdM --> nott armure magique
  192. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  193. * - vérfier la gestion des enchants
  194. */
  195.  
  196. // Roule 04/09/2016 switch extern URLs to https if available
  197. var isHTTPS = false;
  198. if (window.location.protocol.indexOf('https') === 0) {
  199. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  200. URL_bricol = URL_bricol_https;
  201. isHTTPS = true;
  202. }
  203.  
  204. // Roule 23/12/2016 mode dev
  205. var isDEV = false;
  206. if (window.localStorage.getItem('MZ_dev')) {
  207. URL_MZ = URL_MZ.replace(/$/, 'dev');
  208. isDEV = true;
  209. }
  210.  
  211. // Images (pas de souci CORS)
  212. var URL_MZimg = URL_MZ + '/img/';
  213. // URLs externes ajax (CORS OK)
  214. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  215. var URL_pageDispatcher = URL_MZ + '/cdmdispatcher.php';
  216.  
  217. // liens externes détuits
  218. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  219. var MHicons = '/mountyhall/Images/Icones/';
  220. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  221. var MY_DEBUG = false;
  222.  
  223. if (GM_getValue === undefined) { // éviter le blocage si pas sous GM
  224. window.console.log('*** warning *** GM_getValue n\'est pas défini (c\'est normal en test de compilation)');
  225. var GM_getValue = function(key) {};
  226. var GM_setValue = function(key, val) {};
  227. var GM_deleteValue = function(key) {};
  228. }
  229.  
  230. /* Utilisation de la gestion de l'enregistrement des données de
  231. GreaseMonkey, avec partage entre scripts via le localStorage, par
  232. Vapulabehemot (82169) 07/02/2017 */
  233. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  234. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  235. function MY_getValue(key) {
  236. var v = window.localStorage.getItem(key);
  237. if (v === 'true') {
  238. v = 1;
  239. window.localStorage[key] = 1;
  240. } else if (v === 'false') {
  241. v = 0;
  242. window.localStorage[key] = 0;
  243. }
  244. vGM = GM_getValue(key);
  245. if ((vGM == null)
  246. || (v != null && v != vGM)){
  247. GM_setValue(key, v);
  248. } else if (v == null && vGM != null) {
  249. v = vGM;
  250. window.localStorage[key] = vGM;
  251. }
  252. return v;
  253. }
  254. function MY_removeValue(key) {
  255. GM_deleteValue(key);
  256. window.localStorage.removeItem(key);
  257. }
  258. function MY_setValue(key, val) {
  259. if (val === true)
  260. val = 1;
  261. else if (val === false)
  262. val = 0;
  263. GM_setValue(key, val);
  264. window.localStorage[key] = val;
  265. }
  266.  
  267. /*---------------- mise à jour de variables globales utiles ------------------*/
  268. // utilisé pour accès bdd (un peu partout) :
  269. var numTroll = MY_getValue('NUM_TROLL');
  270. // utilisé dans vue pour PX :
  271. var nivTroll = MY_getValue('NIV_TROLL');
  272. // utilisés dans actions et vue (calculs SR) :
  273. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  274. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  275. var currentURL = window.location.href;
  276.  
  277. /*-[functions]------------ Fonctions durée de script -------------------------*/
  278. var date_debut = null;
  279.  
  280. function start_script(nbJours_exp) {
  281. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  282. if(date_debut) return;
  283. date_debut = new Date();
  284. // Créé la variable expdate si demandé
  285. if(nbJours_exp) {
  286. expdate = new Date();
  287. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  288. }
  289. }
  290.  
  291. function displayScriptTime() {
  292. var footerNode = document.getElementById('footer2');
  293. if(!footerNode) return;
  294. try{
  295. var node = document.evaluate(
  296. ".//text()[contains(.,'Page générée en')]/../br",
  297. footerNode,null,9,null).singleNodeValue;
  298. }
  299. catch(e){return;}
  300. insertText(node,
  301. ' - [Script exécuté en '
  302. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  303. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  304. }
  305.  
  306. function traceStack(e, sModule) {
  307. var version = '';
  308. if (GM_info && GM_info.script && GM_info.script.version)
  309. version = ' ' + GM_info.script.version;
  310. sRet = '[MZ' + version + ']'
  311. if (sModule) sRet += ' {' + sModule + '}';
  312. if (e.message) sRet += ' ' + e.message;
  313. if (e.stack) {
  314. var sStack = e.stack;
  315. // enlever les infos confidentielles
  316. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  317. }
  318. return sRet;
  319. }
  320.  
  321. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  322.  
  323. function debugMZ(str){
  324. if(MY_DEBUG){
  325. window.console.debug('[MY_DEBUG] '+str);
  326. if(typeof str === "object"){
  327. window.console.debug(str);
  328. }
  329. }
  330. }
  331.  
  332. function FF_XMLHttpRequest(MY_XHR_Ob) {
  333. var request = new XMLHttpRequest();
  334. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  335. for(var head in MY_XHR_Ob.headers) {
  336. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  337. }
  338. request.onreadystatechange = function() {
  339. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  340. if(request.readyState!=4) { return; }
  341. if(request.error) {
  342. if(MY_XHR_Ob.onerror) {
  343. MY_XHR_Ob.onerror(request);
  344. }
  345. }
  346. else if(MY_XHR_Ob.onload) {
  347. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  348. MY_XHR_Ob.onload(request);
  349. }
  350. };
  351. request.send(MY_XHR_Ob.data);
  352. }
  353.  
  354.  
  355. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  356.  
  357. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  358. function copyTextToClipboard(text) {
  359. var textArea = document.createElement("textarea");
  360.  
  361. //
  362. // *** This styling is an extra step which is likely not required. ***
  363. //
  364. // Why is it here? To ensure:
  365. // 1. the element is able to have focus and selection.
  366. // 2. if element was to flash render it has minimal visual impact.
  367. // 3. less flakyness with selection and copying which **might** occur if
  368. // the textarea element is not visible.
  369. //
  370. // The likelihood is the element won't even render, not even a flash,
  371. // so some of these are just precautions. However in IE the element
  372. // is visible whilst the popup box asking the user for permission for
  373. // the web page to copy to the clipboard.
  374. //
  375.  
  376. // Place in top-left corner of screen regardless of scroll position.
  377. textArea.style.position = 'fixed';
  378. textArea.style.top = 0;
  379. textArea.style.left = 0;
  380.  
  381. // Ensure it has a small width and height. Setting to 1px / 1em
  382. // doesn't work as this gives a negative w/h on some browsers.
  383. textArea.style.width = '2em';
  384. textArea.style.height = '2em';
  385.  
  386. // We don't need padding, reducing the size if it does flash render.
  387. textArea.style.padding = 0;
  388.  
  389. // Clean up any borders.
  390. textArea.style.border = 'none';
  391. textArea.style.outline = 'none';
  392. textArea.style.boxShadow = 'none';
  393.  
  394. // Avoid flash of white box if rendered for any reason.
  395. textArea.style.background = 'transparent';
  396.  
  397. textArea.value = text;
  398.  
  399. document.body.appendChild(textArea);
  400.  
  401. textArea.select();
  402.  
  403. var successful = document.execCommand('copy');
  404.  
  405. document.body.removeChild(textArea);
  406. return successful;
  407. }
  408.  
  409. function avertissement(txt,duree) {
  410. if(!duree) duree = 15000;
  411. var div = document.createElement('div');
  412. // On numérote les avertissements pour destruction sélective
  413. var num = document.getElementsByName('avertissement').length;
  414. div.num = num;
  415. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  416. div.setAttribute('name','avertissement');
  417. div.className = 'mh_textbox';
  418. div.style.position = 'fixed';
  419. div.style.top = (10+15*num)+'px';
  420. div.style.left = (10+5*num)+'px';
  421. div.style.border = '5px solid red';
  422. div.style.zIndex = 2+num;
  423. div.style.cursor = 'pointer';
  424. div.style.fontSize = 'large';
  425. div.innerHTML = txt;
  426. div.onclick=function(){ tueAvertissement(this.num) };
  427.  
  428. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  429. var divcroix = document.createElement('div');
  430. divcroix.style.position = 'absolute';
  431. divcroix.style.top = 0;
  432. divcroix.style.right = 0;
  433. divcroix.style.color = 'black';
  434. divcroix.style.fontSize = 'inherit';
  435. divcroix.style.cursor = 'pointer'
  436. divcroix.style.zIndex = 2+num;
  437. divcroix.innerHTML = "X";
  438. div.appendChild(divcroix);
  439.  
  440. document.body.appendChild(div);
  441. // Destruction automatique de l'avertissement après "un certain temps"
  442. window.setTimeout(function(){ tueAvertissement(num) },duree);
  443. }
  444.  
  445. function tueAvertissement(num) {
  446. var divs = document.getElementsByName('avertissement');
  447. if(divs.length==0) { return; }
  448. for(var i=0 ; i<divs.length ; i++) {
  449. if(divs[i].num==num) {
  450. divs[i].parentNode.removeChild(divs[i]);
  451. return;
  452. }
  453. }
  454. }
  455.  
  456.  
  457. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  458.  
  459. function insertBefore(next,el) {
  460. next.parentNode.insertBefore(el,next);
  461. }
  462.  
  463. function appendTr(tbody,clas) {
  464. var tr = document.createElement('tr');
  465. if(clas) tr.className = clas;
  466. tbody.appendChild(tr);
  467. return tr;
  468. }
  469.  
  470. function insertTr(next,clas) {
  471. var tr = document.createElement('tr');
  472. if(clas) tr.className = clas;
  473. insertBefore(next,tr);
  474. return tr;
  475. }
  476.  
  477. function appendTd(tr) {
  478. var td = document.createElement('td');
  479. if(tr) tr.appendChild(td);
  480. return td;
  481. }
  482.  
  483. function insertTd(next) {
  484. var td = document.createElement('td');
  485. insertBefore(next,td);
  486. return td;
  487. }
  488.  
  489. function appendTdCenter(tr,colspan) {
  490. var td = appendTd(tr);
  491. td.align = 'center'; // WARNING - Obsolete
  492. if(colspan) td.colSpan = colspan;
  493. return td;
  494. }
  495.  
  496. function insertTdElement(next,el) {
  497. var td = insertTd(next);
  498. if(el) td.appendChild(el);
  499. return td;
  500. }
  501.  
  502. function appendA(paren,href,cssClass,text) {
  503. var a = document.createElement('a');
  504. if (href) a.href = href;
  505. if (cssClass) a.className = cssClass;
  506. if (text) a.appendChild(document.createTextNode(text));
  507. paren.appendChild(a);
  508. }
  509.  
  510. function appendText(paren,text,bold) {
  511. if(bold) {
  512. var b = document.createElement('b');
  513. b.appendChild(document.createTextNode(text));
  514. paren.appendChild(b);
  515. }
  516. else
  517. paren.appendChild(document.createTextNode(text));
  518. }
  519.  
  520. function insertText(next,text,bold) {
  521. if(bold) {
  522. var b = document.createElement('b');
  523. appendText(b,text);
  524. insertBefore(next,b);
  525. }
  526. else
  527. insertBefore(next,document.createTextNode(text));
  528. }
  529.  
  530. function appendTdText(tr,text,bold) {
  531. var td = appendTd(tr);
  532. appendText(td,text,bold);
  533. return td;
  534. }
  535.  
  536. function insertTdText(next,text,bold) {
  537. var td = insertTd(next);
  538. appendText(td,text,bold);
  539. return td;
  540. }
  541.  
  542. function appendBr(paren) {
  543. paren.appendChild(document.createElement('br'));
  544. }
  545.  
  546. function insertBr(next) {
  547. insertBefore(next,document.createElement('br'));
  548. }
  549.  
  550. function appendLI(ul,text) {
  551. // uniquement utilisé dans les options (crédits)
  552. var li = document.createElement('li');
  553. appendText(li,text);
  554. ul.appendChild(li);
  555. return li;
  556. }
  557.  
  558. function appendTextbox(paren,type,nam,size,maxlength,value) {
  559. var input = document.createElement('input');
  560. input.className = 'TextboxV2';
  561. input.type = type;
  562. input.name = nam;
  563. input.id = nam;
  564. input.size = size;
  565. input.maxLength = maxlength;
  566. if(value) input.value = value;
  567. paren.appendChild(input);
  568. return input;
  569. }
  570.  
  571. function appendCheckBox(paren,nam,checked,onClick) {
  572. var input = document.createElement('input');
  573. input.type = 'checkbox';
  574. input.name = nam;
  575. input.id = nam;
  576. if(checked) input.checked = true;
  577. if(onClick) input.onclick = onClick;
  578. paren.appendChild(input);
  579. return input;
  580. }
  581.  
  582. function appendNobr(paren,id,delgg,text) {
  583. var nobr = document.createElement('nobr');
  584. appendCheckBox(nobr,id,null,delgg);
  585. appendText(nobr,text);
  586. paren.appendChild(nobr);
  587. appendText(paren,' ');
  588. return nobr;
  589. }
  590.  
  591. function appendCheckBoxSpan(paren,id,onClick,text) {
  592. var span = document.createElement('span');
  593. span.style.whiteSpace = 'nowrap';
  594. appendCheckBox(span,id,false,onClick);
  595. var label = document.createElement('label');
  596. appendText(label,text);
  597. label.htmlFor = id;
  598. label.style.marginLeft = '-5px';
  599. span.appendChild(label);
  600. span.style.marginRight = '3px';
  601. paren.appendChild(span);
  602. appendText(paren, ' ');
  603. return span;
  604. }
  605.  
  606. function appendOption(select,value,text) {
  607. var option = document.createElement('option');
  608. option.value = value;
  609. appendText(option,text);
  610. select.appendChild(option);
  611. return option;
  612. }
  613.  
  614. function appendHidden(form,nam,value) {
  615. var input = document.createElement('input');
  616. input.type = 'hidden';
  617. input.name = nam;
  618. input.id = nam;
  619. input.value = value;
  620. form.appendChild(input);
  621. }
  622.  
  623. function appendButton(paren,value,onClick) {
  624. var input = document.createElement('input');
  625. input.type = 'button';
  626. input.className = 'mh_form_submit';
  627. input.value = value;
  628. input.onmouseover = function(){this.style.cursor='pointer';};
  629. if(onClick) input.onclick = onClick;
  630. paren.appendChild(input);
  631. return input;
  632. }
  633.  
  634. function insertButton(next,value,onClick) {
  635. var input = document.createElement('input');
  636. input.type = 'button';
  637. input.className = 'mh_form_submit';
  638. input.value = value;
  639. input.onmouseover = function(){this.style.cursor='pointer';};
  640. input.onclick = onClick;
  641. insertBefore(next,input);
  642. return input;
  643. }
  644.  
  645. function appendSubmit(paren,value,onClick) {
  646. var input = document.createElement('input');
  647. input.type = 'submit';
  648. input.className = 'mh_form_submit';
  649. input.value = value;
  650. input.onmouseover = function(){this.style.cursor='pointer';};
  651. if(onClick) input.onclick = onClick;
  652. paren.appendChild(input);
  653. return input;
  654. }
  655.  
  656. function createImage(url,title) {
  657. var img = document.createElement('img');
  658. img.src = url;
  659. img.title = title;
  660. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  661. return img;
  662. }
  663.  
  664. function createAltImage(url,alt,title) {
  665. var img = document.createElement('img');
  666. img.src = url;
  667. img.alt = alt;
  668. if (title) img.title = title;
  669. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  670. return img;
  671. }
  672.  
  673. function createImageSpan(url,alt,title,text,bold) {
  674. var span = document.createElement('span');
  675. span.title = title;
  676. var img = document.createElement('img');
  677. img.src = url;
  678. img.alt = alt;
  679. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  680. span.appendChild(img);
  681. appendText(span,text,bold);
  682. return span;
  683. }
  684.  
  685. function createCase(titre,table,width) {
  686. if(!width) width=120;
  687. var tr = appendTr(table,'mh_tdpage');
  688. var td = appendTdText(tr,titre,true);
  689. td.className = 'mh_tdtitre';
  690. td.width = width;
  691. td = appendTdText(tr,'');
  692. td.className = 'mh_tdpage';
  693. return td;
  694. }
  695.  
  696. function getMyID(e) {
  697. var parent = e.parentNode;
  698. for(var i=0 ; i<parent.childNodes.length ; i++) {
  699. if(e==parent.childNodes[i])
  700. return i;
  701. }
  702. return -1;
  703. }
  704.  
  705. function insertAfter(elt,newElt) {
  706. var id = getMyID(elt);
  707. if(id==-1) return;
  708. if(id<elt.parentNode.childNodes.length-1)
  709. insertBefore(elt.nextSibling,newElt);
  710. else
  711. elt.parentNode.appendChild(newElt);
  712. }
  713.  
  714.  
  715. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  716.  
  717. function aff(nb) {
  718. return (nb>=0) ? '+'+nb : nb;
  719. }
  720.  
  721. function getNumber(str) {
  722. var nbr = str.match(/\d+/);
  723. return nbr ? Number(nbr[0]) : Number.NaN;
  724. }
  725.  
  726. function getNumbers(str) {
  727. var nbrs = str.match(/-?\d+/g);
  728. if (!nbrs) return [];
  729. for(var i=0 ; i<nbrs.length ; i++)
  730. nbrs[i] = Number(nbrs[i]);
  731. return nbrs;
  732. }
  733.  
  734. function trim(str) {
  735. return str.replace(/(^\s*)|(\s*$)/g,'');
  736. }
  737.  
  738. String.prototype.trim = function() {
  739. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  740. }
  741.  
  742. function epure(texte) {
  743. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  744. .replace(/[ç]/g,'c')
  745. .replace(/[éêèë]/g,'e')
  746. .replace(/[ïî]/g,'i')
  747. .replace(/[ôöõ]/g,'o')
  748. .replace(/[ùûü]/g,'u');
  749. }
  750.  
  751. String.prototype.epure = function () {
  752. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  753. .replace(/[ç]/g,'c')
  754. .replace(/[éêèë]/g,'e')
  755. .replace(/[ïî]/g,'i')
  756. .replace(/[ôöõ]/g,'o')
  757. .replace(/[ùûü]/g,'u');
  758. }
  759.  
  760. function bbcode(texte) {
  761. return texte.replace(/&/g,'&amp;')
  762. .replace(/"/g,'&quot;')
  763. .replace(/</g,'&lt;')
  764. .replace(/>/g,'&gt;')
  765. .replace(/'/g,'&#146;')
  766. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  767. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  768. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  769. }
  770.  
  771.  
  772. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  773.  
  774. function addZero(i) {
  775. return (i<10) ? '0'+i : i;
  776. }
  777.  
  778. function DateToString(date) {
  779. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  780. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  781. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  782. }
  783.  
  784. function StringToDate(str) {
  785. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  786. }
  787.  
  788. // fonctionne aussi avec datetime
  789. function SQLDateToFrench(str) {
  790. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  791. }
  792.  
  793. // ... et ajoute un "à" du plus bel effet
  794. function SQLDateToFrenchTime(str) {
  795. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  796. }
  797.  
  798. // SQLDate vers objet date Javascript
  799. function SQLDateToObject(str) {
  800. var t = str.split(/[- :]/);
  801. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  802. }
  803.  
  804. var mz_ie = (window.attachEvent)? true:false;
  805. if ("function" !== typeof addEvent) {
  806. if (mz_ie) {
  807. function addEvent(obj, typ, fn, sens) {
  808. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  809. obj["e"+typ+fn]( window.event );
  810. }
  811. obj.attachEvent("on"+typ, obj[typ+fn] );
  812. }
  813. }
  814. else {
  815. function addEvent(obj, typ, fn, sens) {
  816. obj.addEventListener(typ, fn, sens);
  817. }
  818. }
  819. }
  820.  
  821. /**********************
  822. * glissière en mode objet
  823. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  824. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  825. *
  826. * Usage:
  827. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  828. * ref : utilisé pour diversifier les IDs HTML
  829. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  830. * target : peut être de 3 types
  831. * - élément HTML : l'élément HTML à zoomer
  832. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  833. * - function : callback quand le curseur bouge
  834. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  835. * dans le mode dynamique, la callback est appelée sur mouseMove
  836. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  837. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  838. * autres méthodes
  839. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  840. **********************/
  841.  
  842. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  843. try {
  844. var mouseDown = false;
  845. var div_gliss = document.createElement("div"); // la DIV mère
  846. div_gliss.id = "MZ_gliss_"+ref;
  847. var div_label = document.createElement("span"); // le label
  848. div_label.innerHTML = labelHTML;
  849. div_gliss.appendChild(div_label);
  850. div_gliss.className = "choix_zoom";
  851. var dessin = document.createElement("canvas"); // le dessin lui-même
  852. dessin.id = "MZ_gliss_dessin_"+ref;
  853. dessin.style.cursor = "pointer";
  854. dessin.width = 104;
  855. dessin.height = 12;
  856. dessin.style.marginLeft = '2px';
  857. dessin.style.marginRight = '2px';
  858. div_gliss.appendChild(dessin);
  859. var pourcent = document.createElement("span"); // le pourcentage
  860. pourcent.id = "MZ_gliss_pourcent_"+ref;
  861. var pourcent_text = document.createTextNode('');
  862. var previousVal;
  863. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  864.  
  865. // alignement vertical
  866. dessin.style.verticalAlign = 'middle';
  867. div_label.style.verticalAlign = 'middle';
  868. pourcent.style.verticalAlign = 'middle';
  869.  
  870. pourcent.appendChild(pourcent_text);
  871. div_gliss.appendChild(pourcent);
  872.  
  873. var bulle_pourcent = document.createElement("div"); // la bulle
  874. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  875. bulle_pourcent.style.display = 'block';
  876. bulle_pourcent.style.visibility = 'hidden';
  877. bulle_pourcent.style.position = 'absolute';
  878. bulle_pourcent.style.zIndex = 3500;
  879. bulle_pourcent.style.border = '1px solid #a1927f';
  880. var bulle_pourcent_text = document.createTextNode('');
  881. bulle_pourcent.appendChild(bulle_pourcent_text);
  882. document.body.appendChild(bulle_pourcent);
  883.  
  884. this.getElt = function() {return div_gliss;};
  885.  
  886. ////////////////////////////////////
  887. // dessine et redessine le curseur
  888. ////////////////////////////////////
  889. var dessine_glissiere = function(val) {
  890. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  891. var ctx = dessin.getContext('2d');
  892. ctx.clearRect(0, 0,104, 12);
  893. ctx.fillStyle = "rgb(0,0,0)";
  894. ctx.fillRect(0,0,2,12);
  895. ctx.fillRect(102,0,2,12);
  896. ctx.fillRect(0,5,104,2);
  897.  
  898. ctx.fillStyle = "rgb(80,80,80)";
  899. ctx.fillRect(pos_0_100,0,5,12);
  900. ctx.fillStyle = "rgb(200,200,200)";
  901. ctx.fillRect(pos_0_100+1,1,3,10);
  902. pourcent_text.nodeValue = val+'%';
  903. previousVal = parseInt(val);
  904. };
  905.  
  906. ////////////////////////////////////
  907. // action sur mousedown et mousemove
  908. // stocker la nouvelle valeur
  909. // redessiner
  910. // afficher la nouvelle valeur
  911. // action selon ce qui a été demandé
  912. ////////////////////////////////////
  913. var doCallback_glissiere = function (evt) {
  914. try {
  915. if (evt.type === 'mousedown') mouseDown = true;
  916. if (evt.offsetX) {
  917. var xsouris = evt.offsetX;
  918. var xpos = evt.clientX;
  919. var ypos = evt.clientY + document.body.scrollTop;
  920. }
  921. else {
  922. var xsouris = evt.layerX;
  923. var xpos = evt.pageX;
  924. var ypos = evt.pageY;
  925. }
  926. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  927. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  928. // afficher la nouvelle valeur dans la bulle
  929. bulle_pourcent_text.nodeValue = val + '%';
  930. bulle_pourcent.style.top = (ypos+3)+'px';
  931. bulle_pourcent.style.left = (xpos+16)+'px';
  932. if (evt.buttons === undefined) {
  933. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  934. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  935. } else {
  936. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  937. }
  938. // stocker la nouvelle valeur
  939. MY_setValue("MZ_glissiere_" + ref, val);
  940. // redessiner la glissière avec le curseur où il faut
  941. dessine_glissiere(val);
  942. // action selon ce qui a été demandé
  943. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  944. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  945. if (typeof paramTarget === 'object') {
  946. var elt = paramTarget;
  947. } else if (typeof paramTarget === 'string') {
  948. var elt = document.getElementById(paramTarget);
  949. } else if (typeof paramTarget === 'function') {
  950. paramTarget(val);
  951. return;
  952. }
  953. if (elt.setZoom != undefined) elt.setZoom(val);
  954. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  955. };
  956.  
  957. ////////////////////////////////////
  958. // event mousedown et mousemove : redessiner et callback
  959. ////////////////////////////////////
  960. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  961. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  962. ////////////////////////////////////
  963. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  964. ////////////////////////////////////
  965. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  966. ////////////////////////////////////
  967. // event mouseout & mouseover : afficher/cacher la bulle
  968. ////////////////////////////////////
  969. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  970. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  971.  
  972. ////////////////////////////////////
  973. // dessiner la première fois
  974. ////////////////////////////////////
  975. var val_init = MY_getValue("MZ_glissiere_" + ref);
  976. if (val_init === undefined) val_init = valDef;
  977. dessine_glissiere(val_init);
  978. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  979. }
  980.  
  981. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  982. // reçoit 2 objets avec des propriétés x et y
  983. // rend un objet avec x et y (rend undefined si le trajet est direct)
  984. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  985. var deltaX = locArrivee.x - locDepart.x;
  986. if (deltaX == 0) return; // pas de point intermédiaire
  987. var deltaY = locArrivee.y - locDepart.y;
  988. if (deltaY == 0) return; // pas de point intermédiaire
  989. var absDeltaX = Math.abs(deltaX);
  990. var absDeltaY = Math.abs(deltaY);
  991. if (absDeltaX > absDeltaY) {
  992. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  993. } else if (absDeltaY > absDeltaX) {
  994. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  995. } else {
  996. return; // égalité, pas de point intermédiaire
  997. }
  998. }
  999.  
  1000. /**********************
  1001. * carte en mode objet
  1002. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1003. *
  1004. * Usage:
  1005. * carte = new carte_MZ(ref, tabDepl);
  1006. * ref : utilisé pour diversifier les IDs HTML
  1007. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1008. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1009. * autres méthodes
  1010. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1011. **********************/
  1012.  
  1013. function carte_MZ(ref, tabDepl) {
  1014. try {
  1015. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1016. div1_carte.id = "MZ_carte_"+ref;
  1017. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1018. div1_carte.style.backgroundImage = 'none';
  1019. div1_carte.style.backgroundColor = 'transparent';
  1020. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1021. div2_carte.className = "carte_MZ";
  1022. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1023. var dessin = document.createElement("canvas"); // le dessin lui-même
  1024. dessin.id = "MZ_carte_dessin_"+ref;
  1025. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1026. div1_carte.appendChild(div2_carte);
  1027. div2_carte.appendChild(dessin);
  1028.  
  1029. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1030. , [-66.5, -37.5, 2, 1.5, -69]
  1031. , [-63.5, 8.5, 2, 1.5, -69]
  1032. , [-59.5, -32.5, 2, 1.5, -69]
  1033. , [-52, 57, 0.25, 0.8, -59]
  1034. , [-50.5, -22.5, 2, 1.5, -69]
  1035. , [-35.5, -51.5, 2, 1.5, -69]
  1036. , [-34.5, 14.5, 2, 1.5, -69]
  1037. , [-34.5, 64.5, 2, 1.5, -69]
  1038. , [-11.5, 72.5, 2, 1.5, -69]
  1039. , [5.5, -49.5, 2, 1.5, -69]
  1040. , [5.5, 31.5, 2, 1.5, -69]
  1041. , [10.5, 63.5, 2, 1.5, -69]
  1042. , [12, -15, 0.25, 0.8, -59]
  1043. , [21.5, 35.5, 2, 1.5, -69]
  1044. , [30, -52, 0.25, 0.8, -59]
  1045. , [46.5, 51.5, 2, 1.5, -69]
  1046. , [48, -39, 0.25, 0.8, -59]
  1047. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1048. , [56.5, 23.5, 75, 8.7, -99]
  1049. , [64, 70, 0.25, 0.8, -59]
  1050. , [74.5, 31.5, 2, 1.5, -69]];
  1051.  
  1052. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1053. var couleur_cible = 'rgba(0,0,0,0.5)';
  1054. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1055. var couleur_trou = 'rgb(200,0,0)';
  1056.  
  1057. var coord_x = function(val) {
  1058. return decalh+coeff*(val+100);
  1059. };
  1060. var coord_y = function(val) {
  1061. return decalv+coeff*(100-val);
  1062. };
  1063.  
  1064. var ctx = dessin.getContext('2d');
  1065. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1066. if (coeff) coeff /= 50;
  1067. else coeff = 2;
  1068. var decalv=30, decalh=30;
  1069.  
  1070. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1071. //var res = false
  1072. var x0 = pos0.x;
  1073. var y0 = pos0.x;
  1074. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1075. var px = Math.sign(pos1.x - pos0.x);
  1076. var py = Math.sign(pos1.y - pos0.y);
  1077. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1078. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1079.  
  1080. for(var k in position_trous_MZ) {
  1081. a = parseFloat(px*px+py*py);
  1082. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1083. 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]);
  1084. delta = b*b-a*c
  1085. if(delta >= 0) {
  1086. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1087. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1088. if(t0 <= tmax && t1 >= 0) {
  1089. // 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
  1090. //res = true;
  1091. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1092. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1093. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1094. // Roule : pas utile pour nous
  1095. //res = true;
  1096. //chute.push([x0+l*px, y0+l*py]);
  1097. return true;
  1098. }
  1099. }
  1100. }
  1101. }
  1102. //return res;
  1103. return false;
  1104. };
  1105.  
  1106. var dessine_carte = function () {
  1107. dessin.width = 200*coeff+2*decalh;
  1108. dessin.height = 200*coeff+2*decalv;
  1109.  
  1110. //repere
  1111. ctx.beginPath();
  1112. ctx.moveTo(coord_x(0), coord_y(100));
  1113. ctx.lineTo(coord_x(0), coord_y(-100));
  1114. ctx.moveTo(coord_x(-100), coord_y(0));
  1115. ctx.lineTo(coord_x(100), coord_y(0));
  1116. ctx.stroke();
  1117. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1118.  
  1119. //trous
  1120. ctx.fillStyle = couleur_trou;
  1121. for(var i in position_trous_MZ) {
  1122. ctx.beginPath();
  1123. 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);
  1124. ctx.fill();
  1125. }
  1126. // trajets
  1127. ctx.lineCap = "round";
  1128. ctx.lineJoin = "round";
  1129. for (var iSuivant in tabDepl) {
  1130. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1131. var tabDeplOneSuivant = tabDepl[iSuivant];
  1132. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1133. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1134. // La "cible" au départ
  1135. var typeDepart = tabDeplOneSuivant[0].typ;
  1136. switch (typeDepart) {
  1137. case 'tp':
  1138. ctx.beginPath();
  1139. ctx.lineWidth = 2;
  1140. ctx.strokeStyle = couleur_cible;
  1141. ctx.fillStyle = couleur_cible;
  1142. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1143. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1144. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1145. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1146. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1147. ctx.moveTo(x0 + coeff * 3, y0);
  1148. ctx.lineTo(x0 - coeff * 3, y0);
  1149. ctx.moveTo(x0, y0 + coeff * 3);
  1150. ctx.lineTo(x0, y0 - coeff * 3);
  1151. ctx.stroke();
  1152. break;
  1153. default:
  1154. ctx.beginPath();
  1155. ctx.lineWidth = 1;
  1156. ctx.strokeStyle = couleur_cible;
  1157. ctx.fillStyle = couleur_cible;
  1158. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1159. ctx.moveTo(x0 + coeff * 4, y0);
  1160. ctx.lineTo(x0 - coeff * 4, y0);
  1161. ctx.moveTo(x0, y0 + coeff * 4);
  1162. ctx.lineTo(x0, y0 - coeff * 4);
  1163. ctx.stroke();
  1164. break;
  1165. }
  1166. // les segments
  1167. var nb_pts = tabDeplOneSuivant.length;
  1168. var pointPrecedent = tabDeplOneSuivant[0];
  1169. for (var i=1; i<nb_pts; i++) {
  1170. ctx.beginPath();
  1171. ctx.lineWidth = coeff;
  1172. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1173. ctx.strokeStyle = couleur_depl_normal;
  1174. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1175. if (pointIntermediaire === undefined) {
  1176. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1177. ctx.strokeStyle = couleur_depl_collision_trou;
  1178. else
  1179. ctx.strokeStyle = couleur_depl_normal;
  1180. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1181. } else {
  1182. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1183. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1184. ctx.strokeStyle = couleur_depl_collision_trou;
  1185. else
  1186. ctx.strokeStyle = couleur_depl_normal;
  1187. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1188. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1189. }
  1190. pointPrecedent = tabDeplOneSuivant[i];
  1191. ctx.stroke();
  1192. }
  1193. // Les points à chaque étape
  1194. ctx.fillStyle = couleur_depl_normal;
  1195. for (var i=1; i<nb_pts; i++) {
  1196. ctx.beginPath();
  1197. var x = coord_x(tabDeplOneSuivant[i].x);
  1198. var y = coord_y(tabDeplOneSuivant[i].y);
  1199. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1200. ctx.fill();
  1201. }
  1202. }
  1203. }
  1204.  
  1205. this.setZoom = function (val) {
  1206. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1207. coeff = val / 50;
  1208. dessine_carte();
  1209. }
  1210.  
  1211. // glissiere
  1212. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1213. var eGliss = gliss.getElt();
  1214. eGliss.style.position = 'absolute';
  1215. eGliss.style.top = (coeff * 2) + 'px';
  1216. eGliss.style.left = decalh + 'px';
  1217. dessin.style.position = 'relative';
  1218. div2_carte.style.position = 'relative';
  1219. eGliss.style.zIndex = 9000;
  1220. div2_carte.appendChild(eGliss);
  1221.  
  1222. // affichage au survol de la souris
  1223. var bulle = document.createElement('div');
  1224. bulle.style.visibility = 'hidden';
  1225. bulle.style.position = 'absolute';
  1226. bulle.style.zIndex = 3100;
  1227. bulle.style.border = 'solid 1px #a1927f';
  1228. bulle.className = 'mh_tdpage';
  1229. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1230. var bulleHaut = document.createElement('div');
  1231. bulleHaut.style.display = 'block';
  1232. bulleHaut.style.paddingRight = '3px';
  1233. bulleHaut.className = 'mh_tdtitre';
  1234. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1235. bulle.appendChild(bulleHaut);
  1236. var bulleBas = document.createElement('div');
  1237. bulleBas.style.display = 'block';
  1238. bulleBas.style.whiteSpace = "nowrap";
  1239. bulleBas.style.paddingRight = '3px';
  1240.  
  1241. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1242. bulle.appendChild(bulleBas);
  1243. div2_carte.appendChild(bulle);
  1244. var affichePosition = function(evt) {
  1245. if (evt.offsetX) {
  1246. var xsouris = evt.offsetX;
  1247. var ysouris = evt.offsetY;
  1248. var xpos = evt.clientX;
  1249. var ypos = evt.clientY + document.body.scrollTop;
  1250. }
  1251. else {
  1252. var xsouris = evt.layerX;
  1253. var ysouris = evt.layerY;
  1254. var xpos = evt.pageX;
  1255. var ypos = evt.pageY;
  1256. }
  1257. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1258. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1259. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1260. var tabHTMLbas = [];
  1261. // message pour les trous
  1262. for (var i in position_trous_MZ) {
  1263. var ceTrou = position_trous_MZ[i];
  1264. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1265. if(dist <= 0) {
  1266. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1267. break;
  1268. }
  1269. }
  1270. // messages pour les suivants
  1271. for (var i in tabDepl) {
  1272. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1273. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1274. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1275. }
  1276. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1277. bulle.style.top = (ysouris+8) + 'px';
  1278. bulle.style.left = (xsouris+16) + 'px';
  1279. };
  1280. addEvent(dessin, "mousemove", affichePosition, true);
  1281. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1282. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1283.  
  1284. // dessin initial
  1285. dessine_carte();
  1286.  
  1287. this.getElt = function() {return div1_carte;};
  1288.  
  1289. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1290. }
  1291.  
  1292.  
  1293. /**********************************************************
  1294. **** Fin de zone à déplacer dans une bibli commune ********
  1295. **********************************************************/
  1296.  
  1297. /* DEBUG: NETTOYAGE TAGS */
  1298. if(MY_getValue(numTroll+'.TAGSURL')) {
  1299. MY_removeValue(numTroll+'.TAGSURL');
  1300. }
  1301.  
  1302. // Alerte si mode dev
  1303. if (isDEV) {
  1304. var divpopup = document.createElement('div');
  1305. divpopup.id = 'divDEV';
  1306. divpopup.style =
  1307. 'position: fixed;'+
  1308. 'border: 15px solid red;'+
  1309. 'top: 10px;right: 10px;'+
  1310. 'background-color: white;'+
  1311. 'color: black;'+
  1312. 'font-size: large;'+
  1313. 'padding: 5px'+
  1314. 'z-index: 200;';
  1315. appendText(divpopup, '[MZ] Mode DEV');
  1316. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1317. document.body.appendChild(divpopup);
  1318. }
  1319.  
  1320. /*---------- regroupement des getPortee() ------------------------------------*/
  1321. // issu des script profil et profil2
  1322. function getPortee__Profil(param) {
  1323. param = Math.max(0,Number(param));
  1324. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1325. // ça devrait être floor, +10.25, -2.5
  1326. }
  1327.  
  1328. // issu du script vue
  1329. function getPortee__Vue(param) {
  1330. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1331. }
  1332.  
  1333.  
  1334. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1335.  
  1336. function getPXKill(niv) {
  1337. return Math.max(0,10+3*niv-2*nivTroll);
  1338. }
  1339.  
  1340. function getPXDeath(niv) {
  1341. return Math.max(0,10+3*nivTroll-2*niv);
  1342. }
  1343.  
  1344. function analysePX(niv) {
  1345. niv = niv+'';
  1346. var i = niv.indexOf('+');
  1347. if(i!=-1) // si niv = 'XX+' ??
  1348. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1349. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1350. if(i!=-1) {
  1351. var max = getPXKill(niv.slice(i+2));
  1352. if(max==0)
  1353. return ' --> <b>0</b> PX';
  1354. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1355. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1356. }
  1357. i = niv.indexOf('='); // ???
  1358. if(i!=-1) {
  1359. var max = getPXKill(niv.slice(i+1));
  1360. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1361. }
  1362. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1363. }
  1364.  
  1365. function analysePXTroll(niv) {
  1366. var str = analysePX(niv);
  1367. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1368. return str;
  1369. }
  1370.  
  1371.  
  1372. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1373. // Refonte totale du code de Zorya
  1374.  
  1375. // Elements à implémenter en dur dans MZ2.0
  1376. var numQualite = {
  1377. 'Très Mauvaise':1,
  1378. 'Mauvaise':2,
  1379. 'Moyenne':3,
  1380. 'Bonne':4,
  1381. 'Très Bonne':5
  1382. };
  1383.  
  1384. var qualiteNum = [
  1385. '_dummy_',
  1386. 'Très Mauvaise',
  1387. 'Mauvaise',
  1388. 'Moyenne',
  1389. 'Bonne',
  1390. 'Très Bonne'
  1391. ];
  1392.  
  1393. var nival = {
  1394. 'Abishaii Bleu':19,
  1395. 'Abishaii Noir':10,
  1396. 'Abishaii Rouge':23,
  1397. 'Abishaii Vert':15,
  1398. 'Ame-en-peine':8,
  1399. 'Amibe Geante':9,
  1400. 'Anaconda des Catacombes':8,
  1401. 'Ankheg':10,
  1402. 'Anoploure Purpurin':36,
  1403. 'Araignee Geante':2,
  1404. 'Ashashin':35,
  1405. 'Balrog':50,
  1406. 'Banshee':16,
  1407. 'Barghest':36,
  1408. 'Basilisk':11,
  1409. 'Behemoth':34,
  1410. 'Behir':14,
  1411. 'Beholder':50,
  1412. 'Boggart':3,
  1413. 'Bondin':9,
  1414. "Bouj'Dla Placide":37,
  1415. "Bouj'Dla":19,
  1416. 'Bulette':19,
  1417. 'Caillouteux':1,
  1418. 'Capitan':35,
  1419. 'Carnosaure':25,
  1420. 'Champi-Glouton':3,
  1421. 'Chauve-Souris Geante':4,
  1422. 'Cheval a Dents de Sabre':23,
  1423. 'Chevalier du Chaos':20,
  1424. 'Chimere':13,
  1425. 'Chonchon':24,
  1426. 'Coccicruelle':22,
  1427. 'Cockatrice':5,
  1428. 'Crasc Medius':17,
  1429. 'Crasc Maexus':25,
  1430. 'Crasc':10,
  1431. 'Croquemitaine':6,
  1432. 'Cube Gelatineux':32,
  1433. 'Daemonite':27,
  1434. 'Diablotin':5,
  1435. 'Dindon du Chaos':1,
  1436. 'Djinn':29,
  1437. 'Ectoplasme':18,
  1438. 'Effrit':27,
  1439. "Elementaire d'Air":23,
  1440. "Elementaire d'Eau":17,
  1441. 'Elementaire de Feu':21,
  1442. 'Elementaire de Terre':21,
  1443. 'Elementaire du Chaos':26,
  1444. 'Erinyes':7,
  1445. 'Esprit-Follet':16,
  1446. 'Essaim Craterien':30,
  1447. 'Essaim Sanguinaire':25,
  1448. 'Ettin':8,
  1449. 'Familier':1,
  1450. 'Fantome':24,
  1451. 'Feu Follet':20,
  1452. 'Flagelleur Mental':33,
  1453. 'Foudroyeur':38,
  1454. 'Fumeux':22,
  1455. 'Fungus Geant':9,
  1456. 'Fungus Violet':4,
  1457. 'Furgolin':10,
  1458. 'Gargouille':3,
  1459. 'Geant de Pierre':13,
  1460. 'Geant des Gouffres':22,
  1461. "Geck'oo Majestueux":40,
  1462. "Geck'oo":15,
  1463. 'Glouton':20,
  1464. 'Gnoll':5,
  1465. 'Gnu Domestique':1,
  1466. 'Gnu Sauvage':1,
  1467. 'Goblin':4,
  1468. 'Goblours':4,
  1469. "Golem d'Argile":15,
  1470. 'Golem de cuir':1,
  1471. 'Golem de Chair':8,
  1472. 'Golem de Fer':31,
  1473. 'Golem de mithril':1,
  1474. 'Golem de metal':1,
  1475. 'Golem de papier':1,
  1476. 'Golem de Pierre':23,
  1477. 'Gorgone':11,
  1478. 'Goule':4,
  1479. 'Gowap Apprivoise':1,
  1480. 'Gowap Sauvage':1,
  1481. 'Gremlins':3,
  1482. 'Gritche':39,
  1483. 'Grouilleux':4,
  1484. 'Grylle':31,
  1485. 'Harpie':4,
  1486. 'Hellrot':18,
  1487. 'Homme-Lezard':4,
  1488. 'Hurleur':8,
  1489. 'Hydre':50,
  1490. 'Incube':13,
  1491. 'Kobold':2,
  1492. 'Labeilleux':26,
  1493. 'Lezard Geant':5,
  1494. 'Liche':50,
  1495. 'Limace Geante':10,
  1496. 'Loup-Garou':8,
  1497. 'Lutin':4,
  1498. 'Mante Fulcreuse':30,
  1499. 'Manticore':9,
  1500. 'Marilith':33,
  1501. 'Meduse':6,
  1502. 'Megacephale':38,
  1503. 'Mille-Pattes Geant':14,
  1504. 'Mimique':6,
  1505. 'Minotaure':7,
  1506. 'Molosse Satanique':8,
  1507. 'Momie':4,
  1508. 'Monstre Rouilleur':3,
  1509. "Mouch'oo Domestique":14,
  1510. "Mouch'oo Majestueux Sauvage":33,
  1511. "Mouch'oo Sauvage":14,
  1512. 'Na-Haniym-Heee':0,
  1513. 'Necrochore':37,
  1514. 'Necromant':39,
  1515. 'Necrophage':8,
  1516. 'Naga':10,
  1517. 'Nuee de Vermine':13,
  1518. "Nuage d'Insectes":7,
  1519. 'Ogre':7,
  1520. 'Ombre de Roches':13,
  1521. 'Ombre':2,
  1522. 'Orque':3,
  1523. 'Ours-Garou':18,
  1524. 'Palefroi Infernal':29,
  1525. 'Phoenix':32,
  1526. 'Pititabeille':0,
  1527. 'Plante Carnivore':4,
  1528. 'Pseudo-Dragon':5,
  1529. 'Rat Geant':2,
  1530. 'Rat-Garou':3,
  1531. 'Rocketeux':5,
  1532. 'Sagouin':3,
  1533. 'Scarabee Geant':4,
  1534. 'Scorpion Geant':10,
  1535. 'Shai':28,
  1536. 'Sirene':8,
  1537. 'Slaad':5,
  1538. 'Sorciere':17,
  1539. 'Spectre':14,
  1540. 'Sphinx':30,
  1541. 'Squelette':1,
  1542. 'Strige':2,
  1543. 'Succube':13,
  1544. 'Tertre Errant':20,
  1545. 'Thri-kreen':10,
  1546. 'Tigre-Garou':12,
  1547. 'Titan':26,
  1548. 'Trancheur':35,
  1549. 'Tubercule Tueur':14,
  1550. 'Tutoki':4,
  1551. 'Vampire':29,
  1552. 'Ver Carnivore Geant':12,
  1553. 'Ver Carnivore':11,
  1554. 'Veskan Du Chaos':14,
  1555. 'Vouivre':33,
  1556. 'Worg':5,
  1557. 'Xorn':14,
  1558. 'Yeti':8,
  1559. 'Yuan-ti':15,
  1560. 'Zombie':2
  1561. }
  1562.  
  1563. var tabEM = {
  1564. //Monstre: [Compo exact, Sort, Position, Localisation]
  1565. // AA
  1566. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1567. // AE
  1568. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1569. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1570. // AdA
  1571. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1572. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1573. // AdE
  1574. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1575. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1576. // AdD
  1577. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1578. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1579. // BAM
  1580. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1581. // BuM
  1582. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1583. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1584. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1585. // Explo
  1586. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1587. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1588. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1589. // FP
  1590. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1591. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1592. // FA
  1593. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1594. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1595. // Glue
  1596. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1597. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1598. // GdS
  1599. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1600. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1601. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1602. // Invi
  1603. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1604. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1605. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1606. // Lévitation
  1607. // ???
  1608. // PréM :
  1609. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1610. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1611. // Proj
  1612. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1613. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1614. // PuM :
  1615. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1616. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1617. // Sacro
  1618. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1619. // Télék
  1620. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1621. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1622. // TP
  1623. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1624. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1625. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1626. // VA
  1627. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1628. // VL
  1629. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1630. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1631. // VlC
  1632. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1633. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1634. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1635. // VT
  1636. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1637. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1638. // Variables
  1639. 'Rat':["d'un"],
  1640. 'Rat Géant':["d'un"],
  1641. 'Dindon':["d'un"],
  1642. 'Goblin':["d'un"],
  1643. 'Limace':["d'une"],
  1644. 'Limace Géante':["d'une"],
  1645. 'Ver':["d'un"],
  1646. 'Ver Carnivore':["d'un"],
  1647. 'Ver Carnivore Géant':["d'un"],
  1648. 'Fungus':["d'un"],
  1649. 'Vouivre':["d'une"],
  1650. 'Gnu':["d'un"],
  1651. 'Scarabée':["d'un"]
  1652. };
  1653.  
  1654. var mundiChampi = {
  1655. 'Préscientus Reguis':'du Phoenix',
  1656. 'Amanite Trolloïde':'de la Mouche',
  1657. 'Girolle Sanglante':'du Dindon',
  1658. 'Horreur Des Prés':'du Gobelin',
  1659. 'Bolet Péteur':'du Démon',
  1660. 'Pied Jaune':'de la Limace',
  1661. 'Agaric Sous-Terrain':'du Rat',
  1662. 'Suinte Cadavre':"de l'Hydre",
  1663. 'Cèpe Lumineux':'du Ver',
  1664. 'Fungus Rampant':'du Fungus',
  1665. 'Nez Noir':'de la Vouivre',
  1666. 'Pleurote Pleureuse':'du Gnu',
  1667. 'Phytomassus Xilénique':'du Scarabée'
  1668. };
  1669.  
  1670. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1671. appendText(node,' ');
  1672. var urlImg = URL_MZimg
  1673. +'Competences/melangeMagique.png';
  1674. var text = ' [-'+(niv+effetQ)+' %]';
  1675. var str = '';
  1676. switch(mob[0]) {
  1677. case 'A':
  1678. case 'E':
  1679. case 'I':
  1680. case 'O':
  1681. case 'U':
  1682. str = "Compo d'";
  1683. break;
  1684. default:
  1685. str = 'Compo de ';
  1686. }
  1687. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1688. var span = createImageSpan(urlImg,'MM:',title,text);
  1689. node.appendChild(span);
  1690. }
  1691. function addInfoEM(node,mob,compo,qualite,localisation) {
  1692. if(!tabEM[mob]) return;
  1693. var title = 'Composant variable', texte = 'Variable';
  1694. var bold = false;
  1695. if(tabEM[mob].length>1) {
  1696. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1697. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1698. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1699. if(pc<-20) return;
  1700. if(pc>=0) bold = true;
  1701. texte = aff(pc)+'%';
  1702. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1703. }
  1704. var urlImg = URL_MZimg
  1705. +'Competences/ecritureMagique.png';
  1706. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1707. node.appendChild(span);
  1708. }
  1709.  
  1710. function insererInfosEM(tbody) {
  1711. // lancé par equip, equipgowap
  1712. var trCompos = document.evaluate(
  1713. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1714. tbody,null,7,null);
  1715. var strCompos = '';
  1716. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1717. var node = trCompos.snapshotItem(i).childNodes[7];
  1718. var str = node.firstChild.textContent;
  1719. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1720. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1721. // Si non-EM on stoppe le traitement
  1722. if(!tabEM[mob]) continue;
  1723. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1724. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1725. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1726. addInfoEM(node,mob,compo,qualite,localisation);
  1727. }
  1728. }
  1729.  
  1730. function getQualite(qualite) {
  1731. var nb = numQualite[qualite];
  1732. return nb ? nb-1 : -1;
  1733. }
  1734.  
  1735. function getEM(nom) {
  1736. if(nom.indexOf('[')!=-1)
  1737. nom = trim(nom.substring(0,nom.indexOf('[')));
  1738. if(tabEM[nom]) return nom;
  1739. return '';
  1740. }
  1741.  
  1742. // DEBUG ex-fonction composantEM
  1743. function compoMobEM(mob) {
  1744. if(!tabEM[mob]) return '';
  1745. if(tabEM[mob].length==1)
  1746. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1747. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1748. +") pour l'écriture de "+tabEM[mob][1];
  1749. }
  1750.  
  1751. // DEBUG ex-fonction compoEM
  1752. function titreCompoEM(mob,compo,localisation,qualite) {
  1753. if(!tabEM[mob]) return '';
  1754. if(tabEM[mob].length==1) return 'Composant variable';
  1755. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1756. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1757. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1758. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1759. return '';
  1760. }
  1761.  
  1762. // DEBUG - rétrocompatibilité
  1763. function compoEM(mob) {
  1764. // appelé dans libs, vue
  1765. return compoMobEM(mob);
  1766. }
  1767. function composantEM(mob,compo,localisation,qualite) {
  1768. // appelé dans libs, tancompo
  1769. return titreCompoEM(mob,compo,localisation,qualite);
  1770. }
  1771. //
  1772.  
  1773.  
  1774. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1775.  
  1776. arrayTalents = {
  1777. /* Compétences */
  1778. 'Acceleration du Metabolisme':'AM',
  1779. 'Attaque Precise':'AP',
  1780. 'Balayage':'Balayage',
  1781. //'Balluchonnage':'Ballu',
  1782. 'Baroufle':'Baroufle',
  1783. 'Bidouille':'Bidouille',
  1784. 'Botte Secrete':'BS',
  1785. 'Camouflage':'Camou',
  1786. 'Charger':'Charger',
  1787. 'Connaissance des Monstres':'CdM',
  1788. 'Construire un Piege':'Piege',
  1789. 'Piege a Feu':'PiegeFeu',
  1790. 'Piege a Glue':'PiegeGlue',
  1791. 'Contre-Attaquer':'CA',
  1792. 'Coup de Butoir':'CdB',
  1793. 'Course':'Course',
  1794. 'Deplacement Eclair':'DE',
  1795. 'Dressage':'Dressage',
  1796. 'Ecriture Magique':'EM',
  1797. 'Frenesie':'Frenesie',
  1798. 'Golemologie':'Golemo',
  1799. 'Golem de cuir':'GolemCuir',
  1800. 'Golem de metal':'GolemMetal',
  1801. 'Golem de mithril':'GolemMithril',
  1802. 'Golem de papier':'GolemPapier',
  1803. 'Grattage':'Grattage',
  1804. 'Hurlement Effrayant':'HE',
  1805. 'Identification des Champignons':'IdC',
  1806. 'Insultes':'Insultes',
  1807. 'Lancer de Potions':'LdP',
  1808. 'Marquage':'Marquage',
  1809. 'Melange Magique':'Melange',
  1810. 'Miner':'Miner',
  1811. 'Necromancie':'Necro',
  1812. 'Painthure de Guerre':'PG',
  1813. 'Parer':'Parer',
  1814. 'Pistage':'Pistage',
  1815. 'Planter un Champignon':'PuC',
  1816. 'Regeneration Accrue':'RA',
  1817. 'Reparation':'Reparation',
  1818. 'Retraite':'Retraite',
  1819. 'Rotobaffe':'RB',
  1820. 'Shamaner':'Shamaner',
  1821. "S'interposer":'SInterposer',
  1822. 'Tailler':'Tailler',
  1823. //'Vol':'Vol',
  1824. /* Sortilèges */
  1825. 'Analyse Anatomique':'AA',
  1826. 'Armure Etheree':'AE',
  1827. 'Augmentation de l´Attaque':'AdA',
  1828. 'Augmentation de l´Esquive':'AdE',
  1829. 'Augmentation des Degats':'AdD',
  1830. 'Bulle Anti-Magie':'BAM',
  1831. 'Bulle Magique':'BuM',
  1832. 'Explosion':'Explo',
  1833. 'Faiblesse Passagere':'FP',
  1834. 'Flash Aveuglant':'FA',
  1835. 'Glue':'Glue',
  1836. 'Griffe du Sorcier':'GdS',
  1837. 'Hypnotisme':'Hypno',
  1838. 'Identification des tresors':'IdT',
  1839. 'Invisibilite':'Invi',
  1840. 'Levitation':'Levitation',
  1841. 'Precision Magique':'PreM',
  1842. 'Projectile Magique':'Projo',
  1843. 'Projection':'Proj',
  1844. 'Puissance Magique':'PuM',
  1845. 'Rafale Psychique':'Rafale',
  1846. 'Sacrifice':'Sacro',
  1847. 'Siphon des ames':'Siphon',
  1848. 'Telekinesie':'Telek',
  1849. 'Teleportation':'TP',
  1850. 'Vampirisme':'Vampi',
  1851. 'Vision Accrue':'VA',
  1852. 'Vision lointaine':'VL',
  1853. 'Voir le Cache':'VlC',
  1854. 'Vue Troublee':'VT'
  1855. //'':''
  1856. }
  1857.  
  1858. // DEBUG - Pour rétrocompatibilité
  1859. function getSortComp(nom,niveau) {
  1860. return getTalent(nom,niveau);
  1861. }
  1862. //
  1863.  
  1864. function getTalent(nom,niveau) {
  1865. var nomEnBase = arrayTalents[epure(nom)];
  1866. if(!nomEnBase) return 0;
  1867. if(!niveau) var niveau = '';
  1868. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1869. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1870. return 0;
  1871. }
  1872.  
  1873. function removeAllTalents() {
  1874. for(var talent in arrayTalents) {
  1875. var nomEnBase = arrayTalents[talent];
  1876. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1877. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1878. continue;
  1879. }
  1880. var niveau = 1;
  1881. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1882. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1883. niveau++;
  1884. }
  1885. }
  1886. }
  1887.  
  1888. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1889. var att = MY_getValue(numTroll+'.caracs.attaque');
  1890. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1891. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1892. var mm = MY_getValue(numTroll+'.caracs.mm');
  1893. var deg = MY_getValue(numTroll+'.caracs.degats');
  1894. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1895. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1896. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1897. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1898. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1899. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1900. return false;
  1901. return true;
  1902. }
  1903.  
  1904.  
  1905. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1906.  
  1907. function getPVsRestants(pv,bless,vue) {
  1908. bless = Number(bless.match(/\d+/)[0]);
  1909. if(bless==0) return null;
  1910. var pvminmax = pv.match(/\d+/g);
  1911. if(bless==95) {
  1912. var pvb = 1;
  1913. var pvh = Math.floor( pvminmax[1]/20 );
  1914. }
  1915. else if(bless==5) {
  1916. var pvb = Math.floor( pvminmax[0]*19/20 );
  1917. var pvh = pvminmax[1];
  1918. }
  1919. else {
  1920. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1921. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1922. }
  1923. return vue ? ' ('+pvb+'-'+pvh+')' :
  1924. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1925. }
  1926.  
  1927. function insertButtonCdm(nextName,onClick,texte) {
  1928. if(texte==null) texte = 'Participer au bestiaire';
  1929. var nextNode = document.getElementsByName(nextName)[0];
  1930.  
  1931. var espace = document.createTextNode('\t');
  1932. insertBefore(nextNode,espace);
  1933.  
  1934. var button = document.createElement('input');
  1935. button.type = 'button';
  1936. button.className = 'mh_form_submit';
  1937. button.value = texte;
  1938. button.onmouseover = function(){this.style.cursor='pointer';};
  1939. if(onClick) button.onclick = onClick;
  1940. insertBefore(espace,button);
  1941. return button;
  1942. }
  1943.  
  1944. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1945. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1946. 'Capacité spéciale','Résistance Magique','Autres'];
  1947.  
  1948. function createImageTactique(url,id,nom) {
  1949. var img = document.createElement('img');
  1950. img.src = url;
  1951. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1952. img.id = id;
  1953. img.nom = nom;
  1954. img.onmouseover = showPopupTactique;
  1955. img.onmouseout = hidePopup;
  1956. return img;
  1957. }
  1958.  
  1959. function createCDMTable(id,nom,donneesMonstre) {
  1960. try {
  1961. var urlImg = URL_MZimg;
  1962. var table = document.createElement('table');
  1963. var profilActif = isProfilActif();
  1964. table.className = 'mh_tdborder';
  1965. table.border = 0;
  1966. table.cellSpacing = 1;
  1967. table.cellPadding = 4;
  1968. var thead = document.createElement('thead');
  1969. var tr = appendTr(thead,'mh_tdtitre');
  1970. var td = appendTdText(tr,
  1971. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1972. true
  1973. );
  1974. td.colSpan = 2;
  1975. table.appendChild(thead);
  1976. var tbody = document.createElement('tbody');
  1977. table.appendChild(tbody);
  1978. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1979. createCase(listeTitres[i],tbody,80);
  1980. }
  1981. var TypeMonstre = getEM(nom);
  1982. var infosCompo='';
  1983. if(TypeMonstre!='') {
  1984. infosCompo = compoEM(TypeMonstre);
  1985. }
  1986. var nodes = tbody.childNodes;
  1987. nodes[0].childNodes[1].innerHTML =
  1988. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  1989. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  1990. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  1991. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  1992. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  1993. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  1994. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  1995. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  1996. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  1997. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  1998. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  1999. td = createCase(listeTitres[10],tbody);
  2000. td.innerHTML = bbcode(donneesMonstre[10]);
  2001. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2002. td.appendChild(document.createTextNode(" "));
  2003. if(donneesMonstre[16] == "De zone")
  2004. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2005. else if(donneesMonstre[16] == "Automatique")
  2006. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2007. else if(donneesMonstre[16] == "Au toucher")
  2008. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2009. }
  2010. }
  2011. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2012. {
  2013. td = createCase(listeTitres[11],tbody);
  2014. td.innerHTML = bbcode(donneesMonstre[9]);
  2015. // seuil de résistance du monstre
  2016. var lb = td.getElementsByTagName('b');
  2017. if(lb.length == 1) {
  2018. var mrm = lb[0].firstChild.nodeValue * 1;
  2019. var v = (mrm / mmTroll);
  2020. lb[0].firstChild.nodeValue += " ("
  2021. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2022. }
  2023. }
  2024. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2025. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2026. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2027. {
  2028. td = createCase(listeTitres[12],tbody);
  2029. if(donneesMonstre[12]==1)
  2030. {
  2031. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2032. }
  2033. if(donneesMonstre[13]==1)
  2034. {
  2035. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2036. }
  2037. else if(donneesMonstre[13]==0)
  2038. {
  2039. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2040. }
  2041. if(donneesMonstre[14]==1)
  2042. {
  2043. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2044. }
  2045. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2046. {
  2047. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2048. }
  2049. else if(donneesMonstre[14]>6)
  2050. {
  2051. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2052. }
  2053. if(donneesMonstre[15]=="Lente")
  2054. {
  2055. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2056. }
  2057. else if(donneesMonstre[15]=="Normale")
  2058. {
  2059. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2060. }
  2061. else if(donneesMonstre[15]=="Rapide")
  2062. {
  2063. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2064. }
  2065. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2066. {
  2067. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2068. }
  2069. if(infosCompo.length>0)
  2070. {
  2071. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2072. }
  2073. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2074. {
  2075. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2076. }
  2077. }
  2078. // pourcentage de blessure
  2079. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2080. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2081. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2082. if(pvs)
  2083. lb[0].firstChild.nodeValue += pvs;
  2084. }
  2085. return table;
  2086. }
  2087. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2088. }
  2089.  
  2090.  
  2091. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2092.  
  2093. var listeMonstreEnchantement = null,
  2094. listeEquipementEnchantement = null,
  2095. listeInfoEnchantement = null;
  2096.  
  2097. function computeCompoEnchantement()
  2098. {
  2099. listeMonstreEnchantement = new Array();
  2100. listeInfoEnchantement = new Array();
  2101. listeEquipementEnchantement = new Array();
  2102. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2103. for(var i=0;i<liste.length;i++)
  2104. {
  2105. var idEquipement = liste[i]*1;
  2106. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2107. continue;
  2108. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2109. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2110. var texteGlobal='';
  2111. for(var j=0;j<3;j++)
  2112. {
  2113. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  2114. listeMonstreEnchantement[infoComposant[2]] = 1;
  2115. var array = new Array();
  2116. array[0]=infoComposant[0].replace("Ril","Œil");
  2117. array[1]=infoComposant[1];
  2118. array[2]=infoComposant[2];
  2119. array[3]=getQualite(infoComposant[3]);
  2120. var texte = infoComposant[4].replace("Ril","Œil");
  2121. for(var k=5;k<infoComposant.length;k++)
  2122. {
  2123. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2124. }
  2125. texteGlobal+=texte+'\n';
  2126. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2127. array[4]=texte;
  2128. listeInfoEnchantement.push(array);
  2129. }
  2130. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2131. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2132. }
  2133. }
  2134.  
  2135. function isEnchant(nom) {
  2136. var monstreEnchant = '';
  2137. for(j in listeInfoEnchantement) {
  2138. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2139. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2140. monstreEnchant=monstre;
  2141. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2142. }
  2143. }
  2144. return trim(monstreEnchant);
  2145. }
  2146.  
  2147. function getInfoEnchantementFromMonstre(nom)
  2148. {
  2149. try
  2150. {
  2151. if(!listeMonstreEnchantement)
  2152. {
  2153. computeCompoEnchantement();
  2154. }
  2155. var infosEnchant = '';
  2156. for(j in listeInfoEnchantement) {
  2157. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2158. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2159. if(infosEnchant=='')
  2160. infosEnchant=listeInfoEnchantement[j][4];
  2161. else
  2162. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2163. }
  2164. }
  2165. return trim(infosEnchant);
  2166. }
  2167. catch(e)
  2168. {
  2169. window.alert(e);
  2170. }
  2171. }
  2172.  
  2173. function composantEnchant(Monstre,composant,localisation,qualite) {
  2174. var compo='';
  2175. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2176. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2177. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2178. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2179. listeInfoEnchantement[i][3]<=qualite
  2180. ) {
  2181. return listeInfoEnchantement[i][4];
  2182. }
  2183. }
  2184. return compo;
  2185. }
  2186.  
  2187. function insertEnchantInfos(tbody) {
  2188. try
  2189. {
  2190. if(!listeMonstreEnchantement)
  2191. computeCompoEnchantement();
  2192. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2193. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2194. if(nodes.snapshotLength == 0)
  2195. return false;
  2196. var urlImg = URL_MZimg + 'enchant.png';
  2197. for(var i = 0; i < nodes.snapshotLength; i++) {
  2198. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2199. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2200. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2201. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2202. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2203. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2204. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2205. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2206. if(isEnchant(nomMonstre).length>0)
  2207. {
  2208. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2209. if(infos.length>0)
  2210. {
  2211. if(link.parentNode == link.nextSibling.parentNode)
  2212. {
  2213. var tmp = link.nextSibling;
  2214. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2215. }
  2216. else
  2217. {
  2218. link.parentNode.appendChild(createImage(urlImg,infos));
  2219. }
  2220. }
  2221. }
  2222. }
  2223. }
  2224. catch(e)
  2225. {
  2226. window.alert(e);
  2227. }
  2228. }
  2229.  
  2230. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2231. {
  2232. try
  2233. {
  2234. if(!listeMonstreEnchantement)
  2235. computeCompoEnchantement();
  2236. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2237. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2238. if(nodes.snapshotLength == 0)
  2239. return false;
  2240. var urlImg = URL_MZimg + 'enchant.png';
  2241. for(var i = 0; i < nodes.snapshotLength; i++)
  2242. {
  2243. var link = nodes.snapshotItem(i);
  2244. var idEquipement = link.getAttribute('href');
  2245. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2246. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2247. var nomEquipement = trim(link.firstChild.nodeValue);
  2248. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2249. if(!enchanteur || enchanteur == '')
  2250. continue;
  2251. var infos = listeEquipementEnchantement[idEquipement];
  2252. infos=formateTexte(infos);
  2253. if(infos.length>0)
  2254. {
  2255. if(link.parentNode == link.nextSibling.parentNode)
  2256. {
  2257. var tmp = link.nextSibling;
  2258. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2259. }
  2260. else
  2261. {
  2262. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2263. }
  2264. }
  2265. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2266. }
  2267. }
  2268. catch(e)
  2269. {
  2270. window.alert(e);
  2271. }
  2272. }
  2273.  
  2274. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2275.  
  2276.  
  2277. // Les % de toucher
  2278. var c = new Array();
  2279.  
  2280. // coefficients binomiaux
  2281. function cnp(n,k)
  2282. {
  2283. if(c[n] != null && c[n][k] != null)
  2284. return c[n][k];
  2285. if(c[n] == null)
  2286. c[n] = new Array();
  2287. if(k==0)
  2288. {
  2289. c[n][k] = 1;
  2290. return 1;
  2291. }
  2292. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2293. c[n][k] = result;
  2294. // Roule debug
  2295. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2296. return result;
  2297. }
  2298.  
  2299. // by Dab, à comparer
  2300. function binom(n,p) {
  2301. if(p<0 || p>n) return 0;
  2302. if(c[n])
  2303. if(c[n][p]) return c[n][p];
  2304. else {
  2305. c[n]=[1];
  2306. c[n][n]=1;
  2307. if(p==0 || p==n) return 1;
  2308. }
  2309. if(2*p>n)
  2310. c[n][p]=binom(n,n-p);
  2311. else
  2312. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2313. return c[n][p];
  2314. }
  2315.  
  2316. var coeff = new Array();
  2317.  
  2318. function coef(n,p)
  2319. {
  2320. if(n==0 && p==0)
  2321. return 1;
  2322. if(p>n*3.5)
  2323. p = 7*n-p
  2324. // roule désactive cache
  2325. if(coeff[n] != null && coeff[n][p] !=null)
  2326. return coeff[n][p];
  2327. if(coeff[n] == null)
  2328. coeff[n] = new Array();
  2329. var kmax = Math.floor((p-n)/6);
  2330. var x=0;
  2331. for(var k=0;k<=kmax;k++)
  2332. {
  2333. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2334. }
  2335. coeff[n][p] = x;
  2336. // Roule debug
  2337. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2338. return x;
  2339. }
  2340.  
  2341. function chanceEsquiveParfaite(a,d,ba,bd)
  2342. {
  2343. var win = 0;
  2344. var los = 0;
  2345. if(ba==null)
  2346. ba=0;
  2347. if(bd==null)
  2348. bd=0;
  2349. /* if(6*a+ba<2*(d+bd))
  2350. return 100;
  2351. if(a+ba>2*(6*d+bd))
  2352. return 0;*/
  2353. for(var ds=d;ds<=6*d;ds++)
  2354. {
  2355. var cd = coef(d,ds);
  2356. for(var as=a;as<=6*a;as++)
  2357. {
  2358. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2359. win += cd * coef(a,as);
  2360. else
  2361. los += cd * coef(a,as);
  2362. }
  2363. }
  2364. // roule debug
  2365. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2366. return Math.round(100*win/(win+los));
  2367. }
  2368.  
  2369. function chanceTouche(a,d,ba,bd)
  2370. {
  2371. var win = 0;
  2372. var los = 0;
  2373. if(ba==null)
  2374. ba=0;
  2375. if(bd==null)
  2376. bd=0;
  2377. if(a+ba>6*d+bd)
  2378. return 100;
  2379. if(6*a+ba<d+bd)
  2380. return 0;
  2381. for(var ds=d;ds<=6*d;ds++)
  2382. {
  2383. var cd = coef(d,ds);
  2384. for(var as=a;as<=6*a;as++)
  2385. {
  2386. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2387. win += cd * coef(a,as);
  2388. else
  2389. los += cd * coef(a,as);
  2390. }
  2391. }
  2392. return Math.round(100*win/(win+los));
  2393. }
  2394.  
  2395. function chanceCritique(a,d,ba,bd)
  2396. {
  2397. var win = 0;
  2398. var los = 0;
  2399. if(ba==null)
  2400. ba=0;
  2401. if(bd==null)
  2402. bd=0;
  2403. if(a+ba>2*(6*d+bd))
  2404. return 100;
  2405. if(6*a+ba<2*(d+bd))
  2406. return 0;
  2407. for(var ds=d;ds<=6*d;ds++)
  2408. {
  2409. var cd = coef(d,ds);
  2410. for(var as=a;as<=6*a;as++)
  2411. {
  2412. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2413. win += cd * coef(a,as);
  2414. else
  2415. los += cd * coef(a,as);
  2416. }
  2417. }
  2418. return Math.round(100*win/(win+los));
  2419. }
  2420.  
  2421. /***********************************************
  2422. Analyse tactique
  2423. ***********************************************/
  2424.  
  2425. function getTexteAnalyse(modificateur,chiffre)
  2426. {
  2427. if(chiffre==0)
  2428. return chiffre;
  2429. return modificateur+chiffre;
  2430. }
  2431.  
  2432. // rend le HTML pour le tableau de la "calculette"
  2433. function getAnalyseTactique(id,nom)
  2434. {
  2435. var donneesMonstre = listeCDM[id];
  2436. var needAutres=false;
  2437. var i;
  2438. if(donneesMonstre == null)
  2439. return;
  2440. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2441. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2442. if(array==null)
  2443. return "";
  2444. 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>";
  2445. for(i=0;i<array.length;i++)
  2446. {
  2447. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2448. {
  2449. needAutres=true;
  2450. break;
  2451. }
  2452. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2453. 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>";
  2454. else if(i==0) // attaque du monstre sur le Trõll => italique
  2455. 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>";
  2456. else // autre, pas de décoration
  2457. 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>";
  2458. }
  2459. if(needAutres)
  2460. {
  2461. if(i==array.length-1)
  2462. 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>";
  2463. else if(i==1)
  2464. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2465. else
  2466. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2467. }
  2468. return str+"</table>";
  2469. }
  2470.  
  2471. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2472. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2473. function analyseTactique(donneesMonstre,nom) {
  2474. try
  2475. {
  2476. var listeAttaques = [];
  2477. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2478. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2479. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2480. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2481. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2482. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2483. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2484. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2485. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2486. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2487. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2488. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2489. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2490. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2491. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2492. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2493. var modificateurEsquive = '';
  2494. var modificateurArmure = '';
  2495. var modificateurMagie = '';
  2496. var modificateurEsquiveM = '';
  2497. var modificateurArmureM = '';
  2498. var pasDeSR=false;
  2499. var esqM,attM,armM,degM;
  2500. 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)
  2501. return null;
  2502. var td = document.createElement('td')
  2503. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2504. var esqM = 0;
  2505. try
  2506. {
  2507. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2508. }
  2509. catch(e)
  2510. {
  2511. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2512. modificateurEsquive = '<';
  2513. modificateurArmure = '<';
  2514. modificateurMagie = '<';
  2515. }
  2516. td.innerHTML = bbcode(donneesMonstre[3]);
  2517. var attM = 0;
  2518. try
  2519. {
  2520. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2521. }
  2522. catch(e)
  2523. {
  2524. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2525. modificateurEsquiveM = '>';
  2526. modificateurArmureM = '>';
  2527. }
  2528. td.innerHTML = bbcode(donneesMonstre[5]);
  2529. var degM = 0;
  2530. try
  2531. {
  2532. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2533. }
  2534. catch(e)
  2535. {
  2536. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2537. modificateurArmureM = '>';
  2538. }
  2539. td.innerHTML = bbcode(donneesMonstre[7]);
  2540. var armM = 0;
  2541. try
  2542. {
  2543. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2544. }
  2545. catch(e)
  2546. {
  2547. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2548. modificateurArmure = '<';
  2549. }
  2550. var coeffSeuil = 0.95;
  2551. try
  2552. {
  2553. td.innerHTML = bbcode(donneesMonstre[9]);
  2554. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2555. var v = (rm / mm);
  2556. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2557. coeffSeuil = (200-seuil)/200;
  2558. }
  2559. catch(e)
  2560. {
  2561. modificateurMagie = '<';
  2562. pasDeSR = true;
  2563. }
  2564. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2565. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2566. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2567. // roule debug
  2568. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2569. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2570. 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);
  2571. //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);
  2572. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2573. if(getSortComp("Vampirisme")>0)
  2574. {
  2575. var pour = getSortComp("Vampirisme");
  2576. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2577. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2578. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2579. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2580. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2581. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2582. }
  2583. if(getSortComp("Siphon des âmes")>0)
  2584. {
  2585. var pour = getSortComp("Siphon des âmes");
  2586. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2587. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2588. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2589. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2590. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2591. }
  2592. if(getSortComp("Botte Secrète")>0)
  2593. {
  2594. var pour = getSortComp("Botte Secrète");
  2595. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2596. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2597. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2598. 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;
  2599. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2600. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2601. }
  2602. if(getSortComp("Rafale Psychique")>0)
  2603. {
  2604. var pour = getSortComp("Rafale Psychique");
  2605. chanceDEsquiveParfaite = 0;
  2606. chanceDeTouche = Math.round(100*pour/100);
  2607. chanceDeCritique = Math.round(0*pour/100);
  2608. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2609. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2610. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2611. }
  2612. if(getSortComp("Explosion")>0)
  2613. {
  2614. var pour = getSortComp("Explosion");
  2615. chanceDEsquiveParfaite = 0;
  2616. chanceDeTouche = Math.round(100*pour/100);
  2617. chanceDeCritique = Math.round(0*pour/100);
  2618. 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;
  2619. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2620. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2621. }
  2622. if(getSortComp("Projectile Magique")>0)
  2623. {
  2624. var pour = getSortComp("Projectile Magique");
  2625. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2626. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2627. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2628. 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;
  2629. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2630. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2631. }
  2632. if(getSortComp("Frénésie")>0)
  2633. {
  2634. var pour = getSortComp("Frénésie");
  2635. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2636. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2637. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2638. 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;
  2639. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2640. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2641. }
  2642. if(getSortComp("Charger")>0)
  2643. {
  2644. var pour = getSortComp("Charger");
  2645. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2646. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2647. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2648. 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;
  2649. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2650. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2651. }
  2652. if(getSortComp("Griffe du Sorcier")>0)
  2653. {
  2654. var pour = getSortComp("Griffe du Sorcier");
  2655. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2656. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2657. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2658. 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;
  2659. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2660. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2661. }
  2662. if(getSortComp("Attaque Précise",1)>0)
  2663. {
  2664. var niveau = 5;
  2665. var oldPour = 0;
  2666. var chanceDEsquiveParfaite = 0;
  2667. var chanceDeTouche = 0;
  2668. var chanceDeCritique = 0;
  2669. degats = 0;
  2670. while(niveau>0)
  2671. {
  2672. var pour = getSortComp("Attaque Précise",niveau);
  2673. if(pour>oldPour)
  2674. {
  2675. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2676. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2677. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2678. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2679. chanceDeTouche += chanceDeToucheNiveau;
  2680. chanceDeCritique += chanceDeCritiqueNiveau;
  2681. 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);
  2682. oldPour = pour;
  2683. }
  2684. niveau--;
  2685. }
  2686. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2687. 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));
  2688. }
  2689. if(getSortComp("Coup de Butoir",1)>0)
  2690. {
  2691. var niveau = 5;
  2692. var oldPour =0;
  2693. var chanceDEsquiveParfaite = 0;
  2694. var chanceDeTouche=0;
  2695. var chanceDeCritique=0;
  2696. degats=0;
  2697. while(niveau>0)
  2698. {
  2699. var pour = getSortComp("Coup de Butoir",niveau);
  2700. if(pour>oldPour)
  2701. {
  2702. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2703. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2704. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2705. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2706. chanceDeTouche += chanceDeToucheNiveau;
  2707. chanceDeCritique += chanceDeCritiqueNiveau;
  2708. 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);
  2709. oldPour = pour;
  2710. }
  2711. niveau--;
  2712. }
  2713. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2714. 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));
  2715. }
  2716. 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;});
  2717. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2718. {
  2719. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2720. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2721. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2722. }
  2723. else
  2724. {
  2725. chanceDEsquiveParfaite = 0;
  2726. chanceDeTouche = 100;
  2727. chanceDeCritique = 0;
  2728. }
  2729. 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;
  2730.  
  2731. 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));
  2732. return listeAttaques;
  2733. }
  2734. catch(e) { window.alert(e);}
  2735. }
  2736.  
  2737. // x~~x marque pour s'y retrouver sous l'éditeur
  2738.  
  2739. /*
  2740. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2741. * published under GNU License v2.
  2742. *
  2743. * Patch :
  2744. * gestion des missions terminées
  2745. */
  2746. // x~x mission_liste
  2747.  
  2748. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2749. try {
  2750. var titresMimis = document.evaluate(
  2751. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2752. document, null, 7, null
  2753. );
  2754. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2755. } catch(e) {
  2756. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2757. return;
  2758. }
  2759. var enCours = {};
  2760. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2761. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2762. enCours[num] = true;
  2763. }
  2764. for(var numMimi in obMissions) {
  2765. if(!enCours[numMimi]) {
  2766. delete obMissions[numMimi];
  2767. }
  2768. }
  2769. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2770. }
  2771.  
  2772. function do_mission_liste() {
  2773. checkLesMimis();
  2774. }
  2775.  
  2776. /*******************************************************************************
  2777. * This file is part of Mountyzilla. *
  2778. * *
  2779. * Mountyzilla is free software; you can redistribute it and/or modify *
  2780. * it under the terms of the GNU General Public License as published by *
  2781. * the Free Software Foundation; either version 2 of the License, or *
  2782. * (at your option) any later version. *
  2783. * *
  2784. * Mountyzilla is distributed in the hope that it will be useful, *
  2785. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2786. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2787. * GNU General Public License for more details. *
  2788. * *
  2789. * You should have received a copy of the GNU General Public License *
  2790. * along with Mountyzilla; if not, write to the Free Software *
  2791. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2792. *******************************************************************************/
  2793.  
  2794. // x~x actions
  2795.  
  2796. /* TODO
  2797. * getLvl pour Explo, Rotobaffe et cie
  2798. */
  2799.  
  2800.  
  2801.  
  2802. /* Page de combat */
  2803.  
  2804. function getLevel() {
  2805. var divList = document.getElementsByTagName('div');
  2806. if(divList.length <= 2)
  2807. return;
  2808. // On essaie de voir si cette action était une attaque
  2809. var pList = document.getElementsByTagName('p');
  2810. var nomM = '';
  2811. // Modification pour Frénésie by TetDure
  2812. var numAtt = 0;
  2813. for (var i = 0; i < pList.length; i++) {
  2814. if(pList[i].firstChild) {
  2815. nomM = pList[i].firstChild.nodeValue;
  2816. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2817. numAtt++;
  2818. }
  2819. }
  2820. if(nomM == '')
  2821. return;
  2822. // Si c'est une attaque normale, un seul PX
  2823. var comPX = 1;
  2824. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2825. comPX++;
  2826.  
  2827. // Extraction des infos du monstre attaqué
  2828. var idM;
  2829. var male;
  2830. if(nomM.slice(20, 21) == 'e') {
  2831. male = false;
  2832. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2833. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2834. }
  2835. else {
  2836. male = true;
  2837. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2838. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2839. }
  2840. if(idM == '')
  2841. return;
  2842. var bList = document.getElementsByTagName('b');
  2843. var niveau = '';
  2844. for (var i = 0; i < bList.length; i++) {
  2845. var b = bList[i];
  2846. if(b.childNodes[0].nodeValue != "TUÉ")
  2847. continue;
  2848. var nbPX = "";
  2849. for (i++; i < bList.length; i++) {
  2850. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2851. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2852. return;
  2853. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2854. nbPX = bList[i].childNodes[0].nodeValue;
  2855. break;
  2856. }
  2857. }
  2858. if(nbPX == '')
  2859. return;
  2860. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2861. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2862. if(!nbPX)
  2863. nbPX = 0;
  2864. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2865. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2866. if(comPX > nbPX) {
  2867. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2868. niveau = "";
  2869. } else if(Math.floor(niveau) == niveau) {
  2870. chaine += niveau + ".";
  2871. } else {
  2872. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2873. niveau = "";
  2874. }
  2875. insertBr(b.nextSibling.nextSibling.nextSibling);
  2876. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2877. }
  2878.  
  2879. if(niveau != '') {
  2880. var button = insertButtonCdm('as_Action');
  2881. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2882. + escape(nomM) + "&niveau=" + escape(niveau)
  2883. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2884. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2885. }
  2886. }
  2887.  
  2888.  
  2889. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2890.  
  2891. function insertInfoMagie(node, intitule, magie) {
  2892. if(node.nextSibling) {
  2893. node = node.nextSibling;
  2894. insertBr(node);
  2895. insertText(node, intitule);
  2896. insertText(node, magie, true);
  2897. } else {
  2898. node = node.parentNode;
  2899. appendBr(node);
  2900. appendText(node, intitule);
  2901. appendText(node, magie, true);
  2902. }
  2903. }
  2904.  
  2905. function getMM(sr) {
  2906. if(rmTroll<=0) {
  2907. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2908. }
  2909. sr = Number(sr.match(/\d+/)[0]);
  2910. if(sr==10) {
  2911. return '\u2265 '+5*rmTroll;
  2912. }
  2913. if(sr<=50) {
  2914. return Math.round(50*rmTroll/sr);
  2915. }
  2916. if(sr<90) {
  2917. return Math.round((100-sr)*rmTroll/50);
  2918. }
  2919. return '\u2264 '+Math.round(rmTroll/5);
  2920. }
  2921.  
  2922. function traiteMM() {
  2923. var node = document.evaluate(
  2924. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2925. document, null, 9, null).singleNodeValue;
  2926. if(node) {
  2927. var mm = getMM(node.nodeValue);
  2928. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2929. } else {
  2930. var node = document.evaluate(
  2931. "//p/text()[contains(., 'Seuil de Résistance')]",
  2932. document, null, 9, null).singleNodeValue;
  2933. if(!node) {
  2934. return;
  2935. }
  2936. var mm = getMM(node.nodeValue);
  2937. node = node.nextSibling.nextSibling;
  2938. }
  2939. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2940. }
  2941.  
  2942. function getRM(sr) {
  2943. if(mmTroll<=0) {
  2944. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2945. }
  2946. sr = Number(sr.match(/\d+/)[0]);
  2947. if(sr==10) {
  2948. return '\u2264 '+Math.round(mmTroll/5);
  2949. }
  2950. if(sr<=50) {
  2951. return Math.round(sr*mmTroll/50);
  2952. }
  2953. if(sr<90) {
  2954. return Math.round(50*mmTroll/(100-sr));
  2955. }
  2956. return '\u2265 '+5*mmTroll;
  2957. }
  2958.  
  2959. function traiteRM() {
  2960. var nodes = document.evaluate(
  2961. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2962. document, null, 7, null);
  2963. if(nodes.snapshotLength==0) {
  2964. return;
  2965. }
  2966. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2967. var node = nodes.snapshotItem(i);
  2968. var rm = getRM(node.nodeValue);
  2969. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2970. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2971. }
  2972. }
  2973.  
  2974.  
  2975. /* Fonction stats IdT par Raistlin */
  2976. /*function getIdt() {
  2977. if(MY_getValue("SEND_IDT") == "non")
  2978. return false;
  2979. var regExpBeginning = /^\s+/;
  2980. var regExpEnd = /\s+$/;
  2981.  
  2982. var nomIdt = document.evaluate(
  2983. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  2984. document, null, XPathResult.STRING_TYPE, null).stringValue;
  2985. if(!nomIdt)
  2986. return false;
  2987.  
  2988. var caracIdt;
  2989. if(nomIdt.indexOf("Malédiction !") != -1) {
  2990. caracIdt = "";
  2991. nomIdt = "Mission maudite";
  2992. } else {
  2993. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  2994. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  2995. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  2996. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  2997. }
  2998. FF_XMLHttpRequest({
  2999. method: 'GET',
  3000. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3001. headers : {
  3002. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3003. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3004. }
  3005. });
  3006. return true;
  3007. }*/
  3008.  
  3009.  
  3010. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3011.  
  3012. function confirmeDecalage() {
  3013. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3014. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3015. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3016. var newDLA = new Date( oldDLA );
  3017. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3018. return window.confirm(
  3019. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3020. +'\nConfirmez-vous ce décalage ?'
  3021. );
  3022. }
  3023.  
  3024. function newsubmitDLA(evt) {
  3025. evt.stopPropagation();
  3026. evt.preventDefault();
  3027. if(confirmeDecalage()) {
  3028. this.submit();
  3029. }
  3030. }
  3031.  
  3032. function changeActionDecalage() {
  3033. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3034. return;
  3035. }
  3036. try {
  3037. // On récupère le contenu du script JS MH de calcul du décalage
  3038. var scriptTxt = document.evaluate(
  3039. ".//script[ not(@src) ]",
  3040. document, null, 9, null
  3041. ).singleNodeValue.textContent;
  3042. // On en extrait la DLA courante
  3043. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3044. scriptTxt = scriptTxt.split('\n')[0];
  3045. var nbs = scriptTxt.match(/\d+/g);
  3046. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3047. } catch(e) {
  3048. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3049. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3050. return;
  3051. }
  3052. var form = document.getElementsByName('ActionForm')[0];
  3053. if(form) {
  3054. form.addEventListener('submit', newsubmitDLA, true);
  3055. } else {
  3056. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3057. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3058. }
  3059. }
  3060.  
  3061. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3062.  
  3063. function prochainMundi() {
  3064. try {
  3065. var node = document.evaluate(
  3066. "//div[@class='dateAction']/b",
  3067. document, null, 9, null
  3068. ).singleNodeValue;
  3069. } catch(e) {
  3070. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3071. return;
  3072. }
  3073. if(!node) { return; }
  3074.  
  3075. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3076. var jour = longueurMois+1-getNumber(node.textContent);
  3077. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3078. var txt = '[Prochain Mundidey ';
  3079. if(jour>1) {
  3080. txt += 'dans '+jour+' jours]';
  3081. } else {
  3082. txt += 'demain]';
  3083. }
  3084. insertText(node.parentNode.nextSibling,txt,true);
  3085. }
  3086.  
  3087.  
  3088. /* Fonction principale */
  3089.  
  3090. function dispatch() {
  3091. if(isPage('MH_Play/Play_action')) {
  3092. prochainMundi();
  3093. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3094. var oldDLA;
  3095. changeActionDecalage();
  3096. } else if(isPage('MH_Play/Actions')) {
  3097. if(document.evaluate(
  3098. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3099. document, null, 2, null
  3100. ).stringValue) {
  3101. traiteMM();
  3102. } else if(document.evaluate(
  3103. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3104. document, null, 2, null
  3105. ).stringValue) {
  3106. //getIdt();
  3107. traiteRM();
  3108. } /*else {
  3109. // Est censé se lancer sur quoi *précisément* ?
  3110. traiteRM();
  3111. getLevel();
  3112. }*/
  3113. } else {
  3114. /* Traitement des messages du bot */
  3115. var messageTitle = document.evaluate(
  3116. "//form/table/tbody/tr[1]/td[1]/"
  3117. +"descendant::text()[contains(.,'[MountyHall]')]",
  3118. document, null, 2, null
  3119. ).stringValue;
  3120. if(messageTitle.indexOf('Attaquant') != -1 &&
  3121. messageTitle.indexOf('sur') != -1) {
  3122. getLevel();
  3123. traiteRM();
  3124. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3125. messageTitle.indexOf('Défenseur') != -1) {
  3126. traiteMM();
  3127. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3128. // à replacer avec Attaque après révision getLvl :
  3129. messageTitle.indexOf('Explosion') != -1 ||
  3130. messageTitle.indexOf('Insulte') != -1) {
  3131. traiteRM();
  3132. }
  3133. }
  3134. }
  3135.  
  3136. function do_actions() {
  3137. start_script(31);
  3138. dispatch();
  3139. displayScriptTime();
  3140. }
  3141.  
  3142. /*********************************************************************************
  3143. * This file is part of Mountyzilla. *
  3144. * *
  3145. * Mountyzilla is free software; you can redistribute it and/or modify *
  3146. * it under the terms of the GNU General Public License as published by *
  3147. * the Free Software Foundation; either version 2 of the License, or *
  3148. * (at your option) any later version. *
  3149. * *
  3150. * Mountyzilla is distributed in the hope that it will be useful, *
  3151. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3152. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3153. * GNU General Public License for more details. *
  3154. * *
  3155. * You should have received a copy of the GNU General Public License *
  3156. * along with Mountyzilla; if not, write to the Free Software *
  3157. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3158. *********************************************************************************/
  3159.  
  3160. // x~x pre-enchant
  3161.  
  3162. /* 2013-08-19 : correction auto syntaxe alert */
  3163.  
  3164. var combobox=null;
  3165.  
  3166. function changeObject()
  3167. {
  3168. if(!combobox)
  3169. return ;
  3170. var id = combobox.options[combobox.selectedIndex].value;
  3171. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3172. if(!id || id=="")
  3173. {
  3174. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3175. return;
  3176. }
  3177. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3178. }
  3179.  
  3180. function treatePreEnchantement() {
  3181. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3182. if(!input || input.getAttribute("type")=="hidden")
  3183. {
  3184. return false;
  3185. }
  3186. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3187. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3188. if(!combobox)
  3189. {
  3190. return true;
  3191. }
  3192. combobox.addEventListener('change', changeObject, true);
  3193. return true;
  3194. }
  3195.  
  3196. function treateEnchantement() {
  3197. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3198. if(!input || input.getAttribute("type")!="hidden")
  3199. {
  3200. return false;
  3201. }
  3202. var idEquipement = input.getAttribute("value");
  3203. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3204. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3205. if(enchanteur && enchanteur != null)
  3206. return true;
  3207. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3208. if(!input || input.getAttribute("type")!="hidden")
  3209. {
  3210. return false;
  3211. }
  3212. var idEnchanteur = input.getAttribute("value");
  3213. var nodes = document.evaluate(
  3214. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3215. if (nodes.snapshotLength != 3)
  3216. return;
  3217. for(var i=0;i<3;i++)
  3218. {
  3219. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3220. texte = texte.replace(" d'une "," d'un ");
  3221. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3222. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3223. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3224. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3225. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3226. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3227. }
  3228. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3229. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3230. var liste = MY_getValue(numTroll+".enchantement.liste");
  3231. if(!liste || liste=="")
  3232. {
  3233. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3234. }
  3235. else
  3236. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3237. }
  3238.  
  3239. function do_pre_enchant() {
  3240. start_script(60);
  3241. if(!treatePreEnchantement())
  3242. treateEnchantement();
  3243. displayScriptTime();
  3244. }
  3245.  
  3246. /*********************************************************************************
  3247. * This file is part of Mountyzilla. *
  3248. * *
  3249. * Mountyzilla is free software; you can redistribute it and/or modify *
  3250. * it under the terms of the GNU General Public License as published by *
  3251. * the Free Software Foundation; either version 2 of the License, or *
  3252. * (at your option) any later version. *
  3253. * *
  3254. * Mountyzilla is distributed in the hope that it will be useful, *
  3255. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3256. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3257. * GNU General Public License for more details. *
  3258. * *
  3259. * You should have received a copy of the GNU General Public License *
  3260. * along with Mountyzilla; if not, write to the Free Software *
  3261. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3262. *********************************************************************************/
  3263.  
  3264. // x~x enchant
  3265.  
  3266. /* 2013-08-19 : correction auto syntaxe alert */
  3267.  
  3268. function treateEnchantement() {
  3269. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3270. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3271. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3272. return;
  3273. var tab = infoEquipement.split(";");
  3274. if(tab.length<2)
  3275. return;
  3276. var idEquipement = tab[0];
  3277. var nomEquipement = tab[1];
  3278. for(var i=2;i<tab.length;i++)
  3279. nomEquipement += ";"+tab[i];
  3280. var nodes = document.evaluate(
  3281. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3282. if (nodes.snapshotLength != 3)
  3283. return;
  3284. for(var i=0;i<3;i++)
  3285. {
  3286. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3287. texte = texte.replace(" d'une "," d'un ");
  3288. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3289. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3290. monstre = monstre.replace(/ Géante?/,"");
  3291. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3292. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3293. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3294. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3295. }
  3296. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3297. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3298. var liste = MY_getValue(numTroll+".enchantement.liste");
  3299. if(!liste || liste=="")
  3300. {
  3301. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3302. }
  3303. else
  3304. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3305. }
  3306.  
  3307. function do_enchant() {
  3308. start_script(60);
  3309.  
  3310. treateEnchantement();
  3311. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3312. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3313. displayScriptTime();
  3314. }
  3315.  
  3316. /*********************************************************************************
  3317. * This file is part of Mountyzilla. *
  3318. * *
  3319. * Mountyzilla is free software; you can redistribute it and/or modify *
  3320. * it under the terms of the GNU General Public License as published by *
  3321. * the Free Software Foundation; either version 2 of the License, or *
  3322. * (at your option) any later version. *
  3323. * *
  3324. * Mountyzilla is distributed in the hope that it will be useful, *
  3325. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3326. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3327. * GNU General Public License for more details. *
  3328. * *
  3329. * You should have received a copy of the GNU General Public License *
  3330. * along with Mountyzilla; if not, write to the Free Software *
  3331. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3332. *********************************************************************************/
  3333.  
  3334. // x~x myevent
  3335.  
  3336. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3337. function do_myevent() {
  3338. }
  3339.  
  3340. /*********************************************************************************
  3341. * This file is part of Mountyzilla. *
  3342. * *
  3343. * Mountyzilla is free software; you can redistribute it and/or modify *
  3344. * it under the terms of the GNU General Public License as published by *
  3345. * the Free Software Foundation; either version 2 of the License, or *
  3346. * (at your option) any later version. *
  3347. * *
  3348. * Mountyzilla is distributed in the hope that it will be useful, *
  3349. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3350. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3351. * GNU General Public License for more details. *
  3352. * *
  3353. * You should have received a copy of the GNU General Public License *
  3354. * along with Mountyzilla; if not, write to the Free Software *
  3355. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3356. *********************************************************************************/
  3357.  
  3358. // x~x malus
  3359.  
  3360. /* v1.4 - 2014-01-06
  3361. * - Gestion des sorts double composante
  3362. * v1.4.1 - 2014-01-22
  3363. * - Correction décumul
  3364. * TODO
  3365. * - Identifier la position de "PV" dans l'ordre MH
  3366. */
  3367.  
  3368. var listeBM;
  3369.  
  3370.  
  3371. /* [functions] Utilitaires */
  3372.  
  3373. function decumul(bmt,nbr) {
  3374. var bmr;
  3375. if(!nbr || nbr<2) bmr = bmt;
  3376. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3377. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3378. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3379. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3380. else bmr = parseInt(0.1*bmt);
  3381. if(bmt<0) return Math.min(-1,bmr);
  3382. return Math.max(1,bmr);
  3383. }
  3384.  
  3385. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3386. // Roule 23/11/2016 ajout PV
  3387. switch( a ) {
  3388. case 'ATT':
  3389. return -1;
  3390. case 'ESQ':
  3391. if(b=='ATT') return 1;
  3392. return -1;
  3393. case 'DEG':
  3394. switch( b ) {
  3395. case 'ATT':
  3396. case 'ESQ':
  3397. return 1;
  3398. default:
  3399. return -1;
  3400. }
  3401. case 'REG':
  3402. switch( b ) {
  3403. case 'ATT':
  3404. case 'ESQ':
  3405. case 'DEG':
  3406. return 1;
  3407. default:
  3408. return -1;
  3409. }
  3410. case 'Vue':
  3411. switch( b ) {
  3412. case 'ATT':
  3413. case 'ESQ':
  3414. case 'DEG':
  3415. case 'REG':
  3416. return 1;
  3417. default:
  3418. return -1;
  3419. }
  3420. case 'TOUR':
  3421. switch( b ) {
  3422. case 'ATT':
  3423. case 'ESQ':
  3424. case 'DEG':
  3425. case 'REG':
  3426. case 'Vue':
  3427. return 1;
  3428. default:
  3429. return -1;
  3430. }
  3431. case 'PV':
  3432. switch( b ) {
  3433. case 'ATT':
  3434. case 'ESQ':
  3435. case 'DEG':
  3436. case 'REG':
  3437. case 'Vue':
  3438. case 'TOUR':
  3439. return 1;
  3440. default:
  3441. return -1;
  3442. }
  3443. case 'Armure':
  3444. switch( b ) {
  3445. case 'ATT':
  3446. case 'ESQ':
  3447. case 'DEG':
  3448. case 'REG':
  3449. case 'Vue':
  3450. case 'TOUR':
  3451. case 'PV':
  3452. return 1;
  3453. default:
  3454. return -1;
  3455. }
  3456. case 'RM':
  3457. switch( b ) {
  3458. case 'ATT':
  3459. case 'ESQ':
  3460. case 'DEG':
  3461. case 'REG':
  3462. case 'Vue':
  3463. case 'TOUR':
  3464. case 'PV':
  3465. case 'Armure':
  3466. return 1;
  3467. default:
  3468. return -1;
  3469. }
  3470. case 'MM':
  3471. switch( b ) {
  3472. case 'ATT':
  3473. case 'ESQ':
  3474. case 'DEG':
  3475. case 'REG':
  3476. case 'Vue':
  3477. case 'TOUR':
  3478. case 'PV':
  3479. case 'Armure':
  3480. case 'RM':
  3481. return 1;
  3482. default:
  3483. return -1;
  3484. }
  3485. case 'Concentration':
  3486. switch( b ) {
  3487. case 'ATT':
  3488. case 'ESQ':
  3489. case 'DEG':
  3490. case 'REG':
  3491. case 'Vue':
  3492. case 'TOUR':
  3493. case 'PV':
  3494. case 'Armure':
  3495. case 'RM':
  3496. case 'MM':
  3497. return 1;
  3498. default:
  3499. return -1;
  3500. }
  3501. case 'Fatigue':
  3502. switch( b ) {
  3503. case 'ATT':
  3504. case 'ESQ':
  3505. case 'DEG':
  3506. case 'REG':
  3507. case 'Vue':
  3508. case 'TOUR':
  3509. case 'PV':
  3510. case 'Armure':
  3511. case 'RM':
  3512. case 'MM':
  3513. case 'Concentration':
  3514. return 1;
  3515. default:
  3516. return -1;
  3517. }
  3518. case "Dés d'attaque":
  3519. switch( b ) {
  3520. case 'ATT':
  3521. case 'ESQ':
  3522. case 'DEG':
  3523. case 'REG':
  3524. case 'Vue':
  3525. case 'TOUR':
  3526. case 'PV':
  3527. case 'Armure':
  3528. case 'RM':
  3529. case 'MM':
  3530. case 'Concentration':
  3531. case 'Fatigue':
  3532. return 1;
  3533. default:
  3534. return -1;
  3535. }
  3536. case 'Dés de dégâts':
  3537. switch( b ) {
  3538. case 'ATT':
  3539. case 'ESQ':
  3540. case 'DEG':
  3541. case 'REG':
  3542. case 'Vue':
  3543. case 'TOUR':
  3544. case 'PV':
  3545. case 'Armure':
  3546. case 'RM':
  3547. case 'MM':
  3548. case 'Concentration':
  3549. case 'Fatigue':
  3550. case "Dés d'attaque":
  3551. return 1;
  3552. default:
  3553. return -1;
  3554. }
  3555. default :
  3556. switch( b ) {
  3557. case 'ATT':
  3558. case 'ESQ':
  3559. case 'DEG':
  3560. case 'REG':
  3561. case 'Vue':
  3562. case 'TOUR':
  3563. case 'PV':
  3564. case 'Armure':
  3565. case 'RM':
  3566. case 'MM':
  3567. case 'Concentration':
  3568. case 'Fatigue':
  3569. case "Dés d'attaque":
  3570. case 'Dés de dégâts':
  3571. return 1;
  3572. default:
  3573. return -1;
  3574. }
  3575. }
  3576. }
  3577.  
  3578.  
  3579. /* [functions] Fonctions hide / display */
  3580.  
  3581. function toggleDetailsBM() {
  3582. if(MY_getValue('BMDETAIL')!='false') {
  3583. MY_setValue('BMDETAIL','false');
  3584. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3585. for(var i=0 ; i<trlist.length ; i++)
  3586. trlist[i].style.display = 'none';
  3587. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3588. for(var i=0 ; i<trlist.length ; i++)
  3589. trlist[i].style = '';
  3590. }
  3591. else {
  3592. MY_setValue('BMDETAIL','true');
  3593. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3594. for(var i=0 ; i<trlist.length ; i++)
  3595. trlist[i].style.display = 'none';
  3596. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3597. for(var i=0 ; i<trlist.length ; i++)
  3598. trlist[i].style = '';
  3599. }
  3600. }
  3601.  
  3602. function toggleBMList() {
  3603. if(MY_getValue('BMHIDELIST')=='true') {
  3604. MY_setValue('BMHIDELIST','false');
  3605. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3606. listeBM.snapshotItem(i).style = '';
  3607. document.getElementsByTagName('thead')[0].style = '';
  3608. document.getElementById('trhelp').style = '';
  3609. }
  3610. else {
  3611. MY_setValue('BMHIDELIST','true');
  3612. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3613. listeBM.snapshotItem(i).style.display = 'none';
  3614. document.getElementsByTagName('thead')[0].style.display = 'none';
  3615. document.getElementById('trhelp').style.display = 'none';
  3616. }
  3617. }
  3618.  
  3619. function setDisplayBM() {
  3620. if(!listeBM) return;
  3621. var titre = document.getElementById('titre2');
  3622. if(titre) {
  3623. titre.style.cursor = 'pointer';
  3624. titre.onclick = toggleBMList;
  3625. }
  3626. var tfoot = document.getElementsByTagName('tfoot')[0];
  3627. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3628. tfoot, null, 9, null).singleNodeValue;
  3629. tr.id = 'trhelp';
  3630. if(MY_getValue('BMHIDELIST')=='true') {
  3631. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3632. listeBM.snapshotItem(i).style.display = 'none';
  3633. document.getElementsByTagName('thead')[0].style.display = 'none';
  3634. tr.style.display = 'none';
  3635. }
  3636. }
  3637.  
  3638.  
  3639. /* [functions] Fonction principale */
  3640.  
  3641. function traiteMalus() {
  3642. var mainTab = document.getElementsByTagName('table')[0];
  3643. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3644. if(listeBM.snapshotLength==0) return;
  3645. /* Suppression des BM de fatigue stockés */
  3646. if(MY_getValue(numTroll+'.bm.fatigue'))
  3647. MY_removeValue(numTroll+'.bm.fatigue');
  3648. /* Extraction des données */
  3649. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3650. var nb = 0;
  3651. while(nb<listeBM.snapshotLength) {
  3652. tr = listeBM.snapshotItem(nb); nb++;
  3653. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3654. var phymag = tr.childNodes[9].textContent;
  3655. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3656. var type = tr.childNodes[3].textContent, nom;
  3657. // si c'est un type à décumul
  3658. /*
  3659. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3660. switch(type) {
  3661. case 'Potion':
  3662. case 'Parchemin':
  3663. case 'Sortilège':
  3664. case 'Capacité Spéciale':
  3665. nom = tr.childNodes[1].textContent+phymag;
  3666. break;
  3667. default:
  3668. nom = 'pasdedecumul';
  3669. }
  3670. */
  3671. nom = tr.childNodes[1].textContent+phymag;
  3672. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3673. nom = 'pasdedecumul';
  3674. uniListe[nb] = {
  3675. 'duree':duree,
  3676. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3677. 'caracs':{}
  3678. }
  3679. for(var i=0 ; i<effetsT.length ; i++) {
  3680. if(effetsT[i].indexOf(':')==-1) continue;
  3681. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3682. // nom = 'pasdedecumul' si pas de décumul
  3683. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3684. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3685. uniListe[nb]['type'] = phymag;
  3686. var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3687. uniListe[nb]['caracs'][carac] = bm;
  3688. if (MY_DEBUG) window.console.log('[MZ debug] uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm);
  3689. listeDurees[duree] = true;
  3690. }
  3691. } // fin boucle sur les lignes de bonus/malus
  3692. /* Gestion des décumuls et cumuls des durées */
  3693. var toursGeres = [];
  3694. for(var d in listeDurees) toursGeres.push(d);
  3695. toursGeres.sort( function (a,b){return b-a;} );
  3696. // pour sauvegarder les bm de fatigue
  3697. var strfat = '';
  3698. // Pour affichage & adpatation à footable.js (statique)
  3699. var thead = document.getElementsByTagName('thead')[0];
  3700. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3701. thead, null, 7, null).snapshotLength;
  3702. var tfoot = document.getElementsByTagName('tfoot')[0];
  3703. for(var i=0 ; i<toursGeres.length ; i++) {
  3704. var tour = toursGeres[i];
  3705. var effetsCeTour = {}; decumulsCeTour = {};
  3706. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3707. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3708. continue;
  3709. var nom = uniListe[nb]['nom'];
  3710. if(nom!='pasdedecumul') {
  3711. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3712. decumulsCeTour[nom]++;
  3713. }
  3714. for(var carac in uniListe[nb]['caracs']) {
  3715. var bm = uniListe[nb]['caracs'][carac];
  3716. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3717. var type = uniListe[nb]['type'];
  3718. if(!effetsCeTour[carac])
  3719. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3720. if(nom=='pasdedecumul')
  3721. effetsCeTour[carac][type] += bm;
  3722. else
  3723. effetsCeTour[carac][type] += decumul(bm,decumulsCeTour[nom]);
  3724. } else {
  3725. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3726. var thisBm;
  3727. if(nom=='pasdedecumul' || carac=='Fatigue')
  3728. thisBm = bm;
  3729. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3730. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3731. else
  3732. thisBm = decumul(bm,decumulsCeTour[nom]);
  3733. effetsCeTour[carac] += thisBm;
  3734. //window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3735. }
  3736. } // fin boucle sur les caractéristiques
  3737. } // fin boucle sur les bonus/malus
  3738. /* Création du bilan du tour */
  3739. var texteD = '', texteS = '';
  3740. var caracGerees = [];
  3741. for(var k in effetsCeTour) caracGerees.push(k);
  3742. caracGerees.sort( triecaracs );
  3743. for(var j=0 ; j<caracGerees.length ; j++) {
  3744. var carac = caracGerees[j], str = '';
  3745. switch( carac ) {
  3746. case 'ATT':
  3747. case 'DEG':
  3748. case 'Armure':
  3749. var phy = effetsCeTour[carac]['Physique'];
  3750. var mag = effetsCeTour[carac]['Magie'];
  3751. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3752. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3753. break;
  3754. case 'TOUR':
  3755. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3756. break;
  3757. case 'Fatigue':
  3758. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3759. case 'PV':
  3760. case 'ESQ':
  3761. case 'REG':
  3762. case 'Vue':
  3763. case 'Voir le Caché':
  3764. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3765. break;
  3766. default:
  3767. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3768. }
  3769. if(str) {
  3770. texteD += str;
  3771. texteS += str;
  3772. }
  3773. } // fin boucle sur les caractéristiques
  3774. /* Affichage */
  3775. // Si rien à afficher on passe
  3776. if(!texteD) continue;
  3777. // Si BMM+BMP=0
  3778. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3779. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3780. if(MY_getValue('BMDETAIL')=='false')
  3781. tr.style.display = 'none';
  3782. var td = appendTdText(tr,texteD.substring(3));
  3783. td.colSpan = 5-nbHidden;
  3784. var txttour = toursGeres[i]+' Tour';
  3785. if(toursGeres[i]>1) txttour += 's';
  3786. appendTdText(tr,txttour);
  3787. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3788. if(MY_getValue('BMDETAIL')!='false')
  3789. tr.style.display = 'none';
  3790. td = appendTdText(tr,texteS);
  3791. td.colSpan = 5-nbHidden;
  3792. appendTdText(tr,txttour);
  3793. } // fin boucle sur les tours générés
  3794. /* mise en place toggleDetails */
  3795. tfoot.style.cursor = 'pointer';
  3796. tfoot.onclick = toggleDetailsBM;
  3797. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3798. if(strfat)
  3799. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3800. }
  3801.  
  3802. function do_malus() {
  3803. try {
  3804. start_script();
  3805. traiteMalus();
  3806. setDisplayBM();
  3807. displayScriptTime();
  3808. }
  3809. catch(e) {window.alert(e)};
  3810. }
  3811.  
  3812. /*******************************************************************************
  3813. * This file is part of Mountyzilla. *
  3814. * *
  3815. * Mountyzilla is free software; you can redistribute it and/or modify *
  3816. * it under the terms of the GNU General Public License as published by *
  3817. * the Free Software Foundation; either version 2 of the License, or *
  3818. * (at your option) any later version. *
  3819. * *
  3820. * Mountyzilla is distributed in the hope that it will be useful, *
  3821. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3822. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3823. * GNU General Public License for more details. *
  3824. * *
  3825. * You should have received a copy of the GNU General Public License *
  3826. * along with Mountyzilla; if not, write to the Free Software *
  3827. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3828. *******************************************************************************/
  3829.  
  3830. // x~x mouches
  3831.  
  3832. var mainTab, tr_mouches;
  3833.  
  3834. function initialiseMouches() {
  3835. // Lanceur global
  3836. try {
  3837. mainTab = document.getElementById('mouches');
  3838. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3839. } catch(e) {
  3840. avertissement('Erreur MZ:<br />Consulter la console.');
  3841. window.console.error(traceStack(e, 'mouches'));
  3842. return;
  3843. }
  3844. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3845. setDisplayMouches();
  3846. traiteMouches();
  3847. }
  3848.  
  3849. function setDisplayMouches() {
  3850. // Initialise l'affichage / l'effacement du détail des mouches
  3851. var titre = document.getElementById('titre2');
  3852. if(titre) {
  3853. titre.style.cursor = 'pointer';
  3854. titre.onclick = toggleMouches;
  3855. }
  3856. var tfoot = document.getElementsByTagName('tfoot')[0];
  3857. if(tfoot) {
  3858. tfoot.style.cursor = 'pointer';
  3859. tfoot.onclick = toggleMouches;
  3860. }
  3861. if(MY_getValue('HIDEMOUCHES')=='true') {
  3862. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3863. tr_mouches.snapshotItem(i).style.display = 'none';
  3864. }
  3865. document.getElementsByTagName('thead')[0].style.display = 'none';
  3866. }
  3867. }
  3868.  
  3869. function toggleMouches() {
  3870. // Handler pour afficher / masquer les détasil
  3871. if(MY_getValue('HIDEMOUCHES')=='true') {
  3872. MY_setValue('HIDEMOUCHES','false');
  3873. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3874. tr_mouches.snapshotItem(i).style.display = '';
  3875. }
  3876. document.getElementsByTagName('thead')[0].style.display = '';
  3877. } else {
  3878. MY_setValue('HIDEMOUCHES','true');
  3879. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3880. tr_mouches.snapshotItem(i).style.display = 'none';
  3881. }
  3882. document.getElementsByTagName('thead')[0].style.display = 'none';
  3883. }
  3884. }
  3885.  
  3886. function traiteMouches() {
  3887. // Traitement complet: présence et effets des mouches
  3888. var listeTypes = {}, effetsActifs = {};
  3889. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3890. var tr = tr_mouches.snapshotItem(i);
  3891. // La mouche est-elle présente?
  3892. var etat = document.evaluate(
  3893. './img',
  3894. tr.cells[6], null, 9, null
  3895. ).singleNodeValue.alt;
  3896. if(etat!='La Mouche est là') { continue; }
  3897. // Extraction du type de mouche
  3898. var type = trim(tr.cells[3].textContent);
  3899. if(!listeTypes[type]) {
  3900. listeTypes[type] = 1;
  3901. } else {
  3902. listeTypes[type]++;
  3903. }
  3904. // La mouche a-t-elle un effet?
  3905. var effet = trim(tr.cells[2].textContent);
  3906. if(etat!='La Mouche est là' || !effet) { continue; }
  3907. // Si oui, extraction des effets (multiples pour pogées)
  3908. var caracs = effet.split(' | ');
  3909. for(var j=0 ; j<caracs.length ; j++) {
  3910. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3911. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3912. if(effetsActifs[carac]===void(0)) {
  3913. effetsActifs[carac] = valeur;
  3914. } else {
  3915. effetsActifs[carac] += valeur;
  3916. }
  3917. }
  3918. }
  3919. // Extraction Effet total et affichage des différences à la normale
  3920. var tfoot = document.getElementsByTagName('tfoot')[0];
  3921. if(!tfoot) { return; }
  3922. var nodeTotal = document.evaluate(
  3923. ".//b[contains(./text(),'Effet total')]",
  3924. tfoot, null, 9, null
  3925. ).singleNodeValue.nextSibling;
  3926. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3927. var texte = ' ';
  3928. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3929. if(texte.length>1) { texte += ' | '; }
  3930. var carac = trim(
  3931. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3932. );
  3933. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3934. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3935. texte += effetsTheoriques[i];
  3936. } else {
  3937. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3938. if(carac=='TOUR') { texte += ' min'; }
  3939. texte += '</b>';
  3940. }
  3941. }
  3942. var span = document.createElement('span');
  3943. span.innerHTML = texte;
  3944. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3945. // Affichage des différences du nombre de mouches de chaque type
  3946. var mouchesParType = document.evaluate(
  3947. "./tr/td/ul/li/text()",
  3948. tfoot, null, 7, null
  3949. );
  3950. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3951. var node = mouchesParType.snapshotItem(i);
  3952. var mots = node.nodeValue.split(' ');
  3953. var type = mots.pop();
  3954. if(!listeTypes[type]) {
  3955. node.nodeValue += ' (0 présente)';
  3956. } else if(mots[0]!=listeTypes[type]) {
  3957. if(listeTypes[type]==1) {
  3958. node.nodeValue += ' (1 présente)';
  3959. } else {
  3960. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3961. }
  3962. }
  3963. }
  3964. }
  3965.  
  3966. function do_mouches() {
  3967. start_script();
  3968. initialiseMouches();
  3969. displayScriptTime();
  3970. }
  3971.  
  3972. /*********************************************************************************
  3973. * This file is part of Mountyzilla. *
  3974. * *
  3975. * Mountyzilla is free software; you can redistribute it and/or modify *
  3976. * it under the terms of the GNU General Public License as published by *
  3977. * the Free Software Foundation; either version 2 of the License, or *
  3978. * (at your option) any later version. *
  3979. * *
  3980. * Mountyzilla is distributed in the hope that it will be useful, *
  3981. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3982. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3983. * GNU General Public License for more details. *
  3984. * *
  3985. * You should have received a copy of the GNU General Public License *
  3986. * along with Mountyzilla; if not, write to the Free Software *
  3987. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3988. *********************************************************************************/
  3989.  
  3990. // x~x equipgowap
  3991.  
  3992. var popup;
  3993.  
  3994. function initPopupEquipgowap() {
  3995. popup = document.createElement('div');
  3996. popup.setAttribute('id', 'popup');
  3997. popup.setAttribute('class', 'mh_textbox');
  3998. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  3999. 'display: inline; z-index: 3; max-width: 400px;');
  4000. document.body.appendChild(popup);
  4001. }
  4002.  
  4003. function showPopupEquipgowap(evt) {
  4004. var texte = this.getAttribute("texteinfo");
  4005. popup.innerHTML = texte;
  4006. popup.style.left = evt.pageX + 15 + 'px';
  4007. popup.style.top = evt.pageY + 'px';
  4008. popup.style.visibility = "visible";
  4009. }
  4010.  
  4011. function hidePopup() {
  4012. popup.style.visibility = "hidden";
  4013. }
  4014.  
  4015. function createPopupImage(url, text)
  4016. {
  4017. var img = document.createElement('img');
  4018. img.setAttribute('src',url);
  4019. img.setAttribute('align','ABSMIDDLE');
  4020. img.setAttribute("texteinfo",text);
  4021. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4022. img.addEventListener("mouseout", hidePopup,true);
  4023. return img;
  4024. }
  4025.  
  4026. function formateTexte(texte)
  4027. {
  4028. texte = texte.replace(/\n/g,"<br/>");
  4029. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4030. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4031. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4032. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4033. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4034. return texte;
  4035. }
  4036.  
  4037.  
  4038. function treateGowaps() {
  4039. //On récupère les gowaps possédants des composants
  4040. var tbodys = document.evaluate(
  4041. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4042. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4043. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4044. var tbody = tbodys.snapshotItem(j);
  4045. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4046. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4047. if(MY_getValue("NOINFOEM") != "true")
  4048. insertEMInfos(tbody);
  4049. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4050. insertEnchantInfos(tbody);
  4051. }
  4052. }
  4053.  
  4054. function treateChampi() {
  4055. if(MY_getValue("NOINFOEM") == "true")
  4056. return false;
  4057. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4058. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4059. if (nodes.snapshotLength == 0)
  4060. return false;
  4061.  
  4062. for (var i = 0; i < nodes.snapshotLength; i++) {
  4063. var node = nodes.snapshotItem(i);
  4064. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4065. if(texte.indexOf("*")!=-1)
  4066. texte = texte.substring(0,texte.lastIndexOf(" "));
  4067. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4068. if(moisChampi[nomChampi])
  4069. {
  4070. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4071. }
  4072. }
  4073. }
  4074.  
  4075. function do_equipgowap() {
  4076. start_script();
  4077.  
  4078. treateGowaps();
  4079. treateChampi();
  4080. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4081. {
  4082. initPopupEquipgowap();
  4083. computeEnchantementEquipement(createPopupImage,formateTexte);
  4084. }
  4085.  
  4086. displayScriptTime();
  4087. }
  4088.  
  4089. /*********************************************************************************
  4090. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4091. *********************************************************************************/
  4092.  
  4093. // x~x ordresgowap
  4094.  
  4095. // version Roule' janvier 2017
  4096. function MZ_setCarteUnGogoHTML5() {
  4097. // fabriquer la liste des positions successives
  4098. var listeDepl = []; // ce sera un tableau d'objets
  4099. // position courrante
  4100. var eTitle = document.getElementById('titre2');
  4101. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4102. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4103. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4104. , y: parseInt(tabPos[1])
  4105. , n: parseInt(tabPos[2])
  4106. , nom: tabNomID[2]
  4107. , id: tabNomID[1]});
  4108. // déplacements
  4109. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4110. for(var i=0 ; i<lignes.length ; i++) {
  4111. if(lignes[i].className == 'mh_tdpage_fo') {
  4112. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4113. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4114. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4115. }
  4116. }
  4117. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4118. }
  4119.  
  4120. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4121. function MZ_showCarteBottom(listeSuiv) {
  4122. // générer la carte
  4123. var carte = new carte_MZ('cartegogo', listeSuiv);
  4124. // positionner la carte
  4125. var eCarte = carte.getElt();
  4126. eCarte.style.textAlign = 'left';
  4127. eCarte.style.marginTop = '2px';
  4128. var footer = document.getElementById('footer1');
  4129. // Lieu_Teleport.php n'a pas de footer1 :(
  4130. if (!footer) footer = document.getElementById('footer2');
  4131. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4132. else document.body.appendChild(eCarte);
  4133. }
  4134.  
  4135. function MZ_setCarteTousGogoHTML5() {
  4136. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4137. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4138. var suivants = [];
  4139. for (var i=0;i<ligne.length;i++) {
  4140. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4141. var cas = ligne[i].getElementsByTagName("td")[0];
  4142. //if (cas.className == "mh_tdtitre") {
  4143. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4144. var oGogo = {};
  4145. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4146. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4147. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4148. oGogo.x = parseInt(point[1]);
  4149. oGogo.y = parseInt(point[2]);
  4150. oGogo.n = parseInt(point[3]);
  4151. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4152. }
  4153. }
  4154. if (suivants.length == 0) return;
  4155. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4156. }
  4157.  
  4158. function MZ_setCarteTP() {
  4159. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4160. var pos = window.document.getElementsByTagName("body")[0].innerHTML.match(/X[\n\r\t ]*=[\n\r\t ]*(-?\d+)[\n\r\t ]*\|[\n\r\t ]*Y[\n\r\t ]*=[\n\r\t ]*(-?\d+) *\|[\n\r\t ]*N[\n\r\t ]*=[\n\r\t ]*(-?\d+)/i);
  4161. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4162. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4163. }
  4164.  
  4165. /* v0.2 by Dab - 2013-08-31
  4166. * - correction acquisition posale initiale
  4167. * - correction tare et affichage mire
  4168. */
  4169.  
  4170. function setCarteGogo() {
  4171. try {
  4172. //var pars = document.getElementsByTagName('p');
  4173. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4174. var eTitle = document.getElementById('titre2');
  4175. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4176. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4177. var serv_img_cible = URL_MZimg + "rep.png";
  4178.  
  4179. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4180. //var lignes = pars[0].getElementsByTagName('tr');
  4181. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4182. var nbpt = 0;
  4183. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4184. for(var i=0 ; i<lignes.length ; i++) {
  4185. if(lignes[i].className == 'mh_tdpage_fo') {
  4186. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4187. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4188. if(point) {
  4189. nbpt++;
  4190. trajet += point[1]+','+point[2]+','+point[3]+',';
  4191. }
  4192. }
  4193. }
  4194. }
  4195. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4196. 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'/>";
  4197. var base = [-229,-5];
  4198. if (nbpt>0) {
  4199. base = [-684,-5];
  4200. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4201. }
  4202. 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;'/>";
  4203.  
  4204. 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>';
  4205.  
  4206. var nvspan = document.createElement('div');
  4207. nvspan.align = 'center';
  4208. nvspan.id = 'mz_mapdiv';
  4209. nvspan.valign = 'top';
  4210. nvspan.innerHTML = nvdiv;
  4211. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4212. var footer = document.getElementById('footer1');
  4213. footer.parentNode.insertBefore(nvspan,footer);
  4214. }
  4215.  
  4216. function testeGlissiere() {
  4217. try {
  4218. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4219. var footer = document.getElementById('footer1');
  4220. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4221. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4222. }
  4223.  
  4224. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4225. if (x0 !== undefined) {
  4226. // ouais, récursif une fois
  4227. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4228. if (PtInterm === undefined)
  4229. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4230. else
  4231. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4232. return;
  4233. }
  4234. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4235. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4236. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4237. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4238. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4239. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4240. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4241. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4242. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4243. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4244. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4245. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4246. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4247. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4248. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4249. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4250. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4251. }
  4252.  
  4253. function do_ordresgowap() {
  4254. if (newCarte) {
  4255. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4256. //testeGlissiere();
  4257. //MZ_testsUnitairesCalculIntermediaire();
  4258. } else {
  4259. setCarteGogo(); // Via script des trouillots
  4260. }
  4261. }
  4262.  
  4263. function do_listegowap() {
  4264. if (!newCarte) return;
  4265. MZ_setCarteTousGogoHTML5();
  4266. }
  4267.  
  4268. function do_lieuDescription() {
  4269. if (!newCarte) return;
  4270. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4271. MZ_setCarteTP();
  4272. }
  4273.  
  4274. function do_lieuTeleport() {
  4275. changeButtonValidate();
  4276. if (!newCarte) return;
  4277. MZ_setCarteTP();
  4278. }
  4279.  
  4280. /*********************************************************************************
  4281. * This file is part of Mountyzilla. *
  4282. * *
  4283. * Mountyzilla is free software; you can redistribute it and/or modify *
  4284. * it under the terms of the GNU General Public License as published by *
  4285. * the Free Software Foundation; either version 2 of the License, or *
  4286. * (at your option) any later version. *
  4287. * *
  4288. * Mountyzilla is distributed in the hope that it will be useful, *
  4289. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4290. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4291. * GNU General Public License for more details. *
  4292. * *
  4293. * You should have received a copy of the GNU General Public License *
  4294. * along with Mountyzilla; if not, write to the Free Software *
  4295. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4296. *********************************************************************************/
  4297.  
  4298. // x~x attaque
  4299.  
  4300. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4301.  
  4302. function do_attaque() {
  4303. }
  4304.  
  4305. /*******************************************************************************
  4306. * This file is part of Mountyzilla. *
  4307. * *
  4308. * Mountyzilla is free software; you can redistribute it and/or modify *
  4309. * it under the terms of the GNU General Public License as published by *
  4310. * the Free Software Foundation; either version 2 of the License, or *
  4311. * (at your option) any later version. *
  4312. * *
  4313. * Mountyzilla is distributed in the hope that it will be useful, *
  4314. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4315. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4316. * GNU General Public License for more details. *
  4317. * *
  4318. * You should have received a copy of the GNU General Public License *
  4319. * along with Mountyzilla; if not, write to the Free Software *
  4320. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4321. *******************************************************************************/
  4322.  
  4323. // x~x infomonstre
  4324.  
  4325. // DEBUG
  4326. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4327. // À corriger, évidemment.
  4328. var listeCDM = {};
  4329. var nomMonstre='';
  4330. var idMonstre=-1;
  4331. var tbody;
  4332. var popup;
  4333.  
  4334. function traiteMonstre() {
  4335. try {
  4336. var nodeTitre = document.evaluate(
  4337. "//div[@class='titre2' and contains(text(),'(')]",
  4338. document, null, 9, null
  4339. ).singleNodeValue;
  4340. var texte = nodeTitre.firstChild.nodeValue;
  4341. } catch(e) {
  4342. window.console.log(traceStack(e, 'traiteMonstre'));
  4343. return;
  4344. }
  4345. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4346. if(nomMonstre.indexOf(']')!=-1) {
  4347. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4348. }
  4349. idMonstre = texte.match(/\d+/)[0];
  4350. FF_XMLHttpRequest({
  4351. method: 'GET',
  4352. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4353. +MY_getValue('CDMID')
  4354. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4355. headers : {
  4356. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4357. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4358. },
  4359. onload: function(responseDetails) {
  4360. try {
  4361. var texte = responseDetails.responseText;
  4362. var lines = texte.split("\n");
  4363. if(lines.length>=1) {
  4364. var infos = lines[0].split(";");
  4365. if(infos.length<4) { return; }
  4366. var idMonstre = infos[0];
  4367. infos=infos.slice(3);
  4368. listeCDM[idMonstre]=infos;
  4369. computeMissionInfomonstre();
  4370. }
  4371. } catch(e) {
  4372. window.alert(e);
  4373. }
  4374. }
  4375. });
  4376. }
  4377.  
  4378. function initPopupInfomonstre() {
  4379. // Initialise le popup tactique (calculs att/deg)
  4380. popup = document.createElement('div');
  4381. popup.id = 'popup';
  4382. popup.className = 'mh_textbox';
  4383. popup.style =
  4384. 'position: absolute;'+
  4385. 'border: 1px solid #000000;'+
  4386. 'visibility: hidden;'+
  4387. 'display: inline;'+
  4388. 'z-index: 3;'+
  4389. 'max-width: 400px;';
  4390. document.body.appendChild(popup);
  4391. }
  4392.  
  4393. function showPopupTactique(evt) {
  4394. try {
  4395. var id = this.id;
  4396. var nom = this.nom;
  4397. var texte = getAnalyseTactique(id,nom);
  4398. if(texte=='') { return; }
  4399. popup.innerHTML = texte;
  4400. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4401. if(isPage("View/MonsterView")) {
  4402. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4403. } else {
  4404. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4405. }
  4406. popup.style.top = evt.pageY+15+'px';
  4407. popup.style.visibility = 'visible';
  4408. } catch(e) {
  4409. window.alert(e);
  4410. }
  4411. }
  4412.  
  4413. // roule 16/03/2016, existe déjà ailleurs
  4414. // function hidePopup() {
  4415. // popup.style.visibility = 'hidden';
  4416. // }
  4417.  
  4418. function toggleTableau() {
  4419. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4420. }
  4421.  
  4422. function computeMissionInfomonstre() {
  4423. // C'est quoi ce titre de fonction ? (O_o)
  4424. try {
  4425. var nodeInsert = document.evaluate(
  4426. "//div[@class = 'titre3']",
  4427. document, null, 9, null
  4428. ).singleNodeValue;
  4429. } catch(e) {
  4430. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4431. return;
  4432. }
  4433. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4434. table.align = 'center';
  4435. tbody = table.childNodes[1];
  4436. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4437. table.firstChild.firstChild.onmouseover = function() {
  4438. this.style.cursor = 'pointer';
  4439. this.className = 'mh_tdpage';
  4440. };
  4441. table.firstChild.firstChild.onmouseout = function() {
  4442. this.className = 'mh_tdtitre';
  4443. };
  4444. tbody.style.display = 'none';
  4445. table.style.width = '350px';
  4446. insertBefore(nodeInsert,table);
  4447. }
  4448.  
  4449. function do_infomonstre() {
  4450. start_script();
  4451. try {
  4452. initPopupInfomonstre();
  4453. traiteMonstre();
  4454. } catch(e) {
  4455. window.alert('Erreur infoMonstre:\n'+e);
  4456. }
  4457. displayScriptTime();
  4458. }
  4459.  
  4460. /*******************************************************************************
  4461. * This file is part of Mountyzilla. *
  4462. * *
  4463. * Mountyzilla is free software; you can redistribute it and/or modify *
  4464. * it under the terms of the GNU General Public License as published by *
  4465. * the Free Software Foundation; either version 2 of the License, or *
  4466. * (at your option) any later version. *
  4467. * *
  4468. * Mountyzilla is distributed in the hope that it will be useful, *
  4469. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4470. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4471. * GNU General Public License for more details. *
  4472. * *
  4473. * You should have received a copy of the GNU General Public License *
  4474. * along with Mountyzilla; if not, write to the Free Software *
  4475. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4476. *******************************************************************************/
  4477.  
  4478. // x~x mission
  4479.  
  4480. /* TODO
  4481. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4482. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4483. *
  4484. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4485. */
  4486.  
  4487. function saveMission(num,obEtape) {
  4488. var obMissions = {};
  4489. if(MY_getValue(numTroll+'.MISSIONS')) {
  4490. try {
  4491. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4492. } catch(e) {
  4493. window.console.error(traceStack(e, 'Mission parsage'));
  4494. return;
  4495. }
  4496. }
  4497. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4498. if(obEtape) {
  4499. obMissions[num] = obEtape;
  4500. } else if(obMissions[num]) {
  4501. delete obMissions[num];
  4502. }
  4503. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4504. }
  4505.  
  4506. function addtroogle(tdLibelle, sRestrict) {
  4507. var img = document.createElement('img');
  4508. img.src = URL_MZimg + 'troogle.ico';
  4509. img.alt = 'Troogle logo';
  4510. var a = document.createElement('a');
  4511. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4512. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4513. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4514. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4515. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4516. a.href = url;
  4517. a.title = 'Chercher sur Troogle';
  4518. a.target = 'troogle';
  4519. a.appendChild(img);
  4520. tdLibelle.appendChild(a);
  4521. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4522. }
  4523.  
  4524. function traiteMission() {
  4525. try {
  4526. var titreMission = document.getElementsByClassName('titre2')[0];
  4527. var numMission = titreMission.textContent.match(/\d+/)[0];
  4528. var missionForm = document.getElementsByName('ActionForm')[0];
  4529. var tdLibelle = document.evaluate(
  4530. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4531. missionForm, null, 9, null).singleNodeValue;
  4532. } catch(e) {
  4533. window.console.error(traceStack(e, 'récupération mission'));
  4534. return;
  4535. }
  4536. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4537. try {
  4538. if(!tdLibelle) {
  4539. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4540. debugMZ('traiteMission, la mission semble terminée');
  4541. saveMission(numMission,false);
  4542. return;
  4543. }
  4544.  
  4545. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4546. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4547. // debug Roule'
  4548. if (MY_DEBUG) {
  4549. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4550. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4551. }
  4552. if(libelle.indexOf('niveau égal à')!=-1) {
  4553. var nbKills = 1, niveau, mod;
  4554. // exemples :
  4555. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4556. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4557. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4558. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4559. if (tdLibelle.childNodes.length == 1) {
  4560. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4561. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4562. if (m) {
  4563. niveau = Number(m[1]);
  4564. mod = 'plus'
  4565. } else {
  4566. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4567. if (m) {
  4568. niveau = Number(m[1]);
  4569. mod = Number(m[2]);
  4570. } else {
  4571. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4572. return;
  4573. }
  4574. }
  4575. } else {
  4576. // ancienne méthode (multi childnode)
  4577. // à supprimer un jour peut-être
  4578. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4579. // Étape de kill multiple de niveau donné
  4580. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4581. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4582. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4583. niveau = Number(mod[0]);
  4584. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4585. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4586. } else {
  4587. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4588. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4589. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4590. mod = mod ? Number(mod[0]) : 'plus';
  4591. }
  4592. } else {
  4593. // Étape de kill unique de niveau donné
  4594. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4595. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4596. mod = mod ? Number(mod[0]) : 'plus';
  4597. }
  4598. }
  4599. // debug Roule'
  4600. if (MY_DEBUG) {
  4601. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4602. }
  4603. saveMission(numMission,{
  4604. type: 'Niveau',
  4605. niveau: niveau,
  4606. mod: mod,
  4607. mundidey: siMundidey,
  4608. libelle: libelle
  4609. });
  4610. if (mod == 'plus')
  4611. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4612. else
  4613. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4614. } else if(libelle.indexOf('de la race')!=-1) {
  4615. var nbKills = 1, race;
  4616. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4617. // Étape de kill multiple de race donnée
  4618. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4619. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4620. } else {
  4621. // Étape de kill unique de race donnée
  4622. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4623. }
  4624. race = race.replace(/\"/g,'');
  4625. saveMission(numMission,{
  4626. type: 'Race',
  4627. race: race,
  4628. mundidey: siMundidey,
  4629. libelle: libelle
  4630. });
  4631. addtroogle(tdLibelle, '@monstre ' + race);
  4632. } else if(libelle.indexOf('de la famille')!=-1) {
  4633. var nbKills = 1, famille;
  4634. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4635. // Étape de kill multiple de famille donnée
  4636. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4637. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4638. } else {
  4639. // Étape de kill unique de famille donnée
  4640. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4641. }
  4642. famille = famille.replace(/\"/g,'');
  4643. saveMission(numMission,{
  4644. type: 'Famille',
  4645. famille: famille,
  4646. mundidey: siMundidey,
  4647. libelle: libelle
  4648. });
  4649. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4650. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4651. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4652. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4653. debugMZ('traiteMission étape capacité spéciale');
  4654. saveMission(numMission,{
  4655. type: 'Pouvoir',
  4656. pouvoir: pouvoir,
  4657. libelle: libelle
  4658. });
  4659. } else {
  4660. debugMZ('traiteMission étape pas pour troogle');
  4661. saveMission(numMission,false);
  4662. }
  4663. } catch(e) {
  4664. window.console.error(traceStack(e, 'récupération étape mission'));
  4665. return;
  4666. }
  4667. }
  4668.  
  4669. function do_mission() {
  4670. start_script(60);
  4671.  
  4672. traiteMission();
  4673.  
  4674. displayScriptTime();
  4675. }
  4676.  
  4677. /*******************************************************************************
  4678. * This file is part of Mountyzilla. *
  4679. * *
  4680. * Mountyzilla is free software; you can redistribute it and/or modify *
  4681. * it under the terms of the GNU General Public License as published by *
  4682. * the Free Software Foundation; either version 2 of the License, or *
  4683. * (at your option) any later version. *
  4684. * *
  4685. * Mountyzilla is distributed in the hope that it will be useful, *
  4686. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4687. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4688. * GNU General Public License for more details. *
  4689. * *
  4690. * You should have received a copy of the GNU General Public License *
  4691. * along with Mountyzilla; if not, write to the Free Software *
  4692. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4693. *******************************************************************************/
  4694.  
  4695. // x~x move
  4696.  
  4697. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4698.  
  4699. var petitsTrous = {
  4700. '-52;57': true,
  4701. '55;70': true,
  4702. '64;70': true,
  4703. '12;-15': true,
  4704. '30;-52': true,
  4705. '48;-39': true
  4706. };
  4707.  
  4708. var grosTrous = {
  4709. '-35;65': true,
  4710. '-13;73': true,
  4711. '-64;9': true,
  4712. '-35;15': true,
  4713. '5;32': true,
  4714. '10;64': true,
  4715. '21;36': true,
  4716. '46;52': true,
  4717. '74;32': true,
  4718. '-71;-7': true,
  4719. '-67;-37': true,
  4720. '-60;-32': true,
  4721. '-51;-22': true,
  4722. '-36;-51': true,
  4723. '5;-49': true
  4724. };
  4725.  
  4726. var centreCarmine_X = 56.5;
  4727. var centreCarmine_Y = 23.5;
  4728. var rayonCarmine = 8.7;
  4729.  
  4730. function isTrou(x,y,n) {
  4731. if(petitsTrous[x+';'+y]) {
  4732. return n<0 && n>-60;
  4733. }
  4734. if(grosTrous[x+';'+y]
  4735. || grosTrous[x-1+';'+y]
  4736. || grosTrous[x+';'+y+1]
  4737. || grosTrous[x-1+';'+y+1]) {
  4738. return n<0 && n>-70;
  4739. }
  4740. if(Math.sqrt(
  4741. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4742. )<=rayonCarmine) {
  4743. return n<0 && n>-100;
  4744. }
  4745. return false;
  4746. }
  4747.  
  4748. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4749.  
  4750. function validateDestination() {
  4751. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4752. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4753. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4754. var form = document.getElementsByName('ActionForm')[0];
  4755. if(form) {
  4756. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4757. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4758. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4759. }
  4760. }
  4761. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4762. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4763. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4764. }
  4765. }
  4766. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4767. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4768. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4769. }
  4770. }
  4771. if(isTrou(x,y,n)) {
  4772. return window.confirm(
  4773. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4774. +'Vous allez tomber dans un trou de météorite.\n'
  4775. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4776. );
  4777. }
  4778. }
  4779. return true;
  4780. }
  4781.  
  4782. function newsubmitDE(event) {
  4783. event.stopPropagation();
  4784. event.preventDefault();
  4785. if(validateDestination()) {
  4786. this.submit();
  4787. }
  4788. }
  4789.  
  4790. function changeValidation() {
  4791. var form = document.getElementsByName('ActionForm')[0];
  4792. if(form) {
  4793. form.addEventListener('submit', newsubmitDE, true);
  4794. }
  4795. }
  4796.  
  4797.  
  4798. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4799.  
  4800. function validateTPDestination() {
  4801. try {
  4802. var text = document.getElementsByTagName('B')[0];
  4803. var a = text.firstChild.nodeValue.split('|');
  4804. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4805. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4806. var pos_n = a[2].substring(5, a[2].length) * 1;
  4807.  
  4808. var nbtrous = 0;
  4809. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4810. for(var x=0 ; x<=2 ; x++) {
  4811. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4812. for(var y=0 ; y<=2 ; y++) {
  4813. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4814. for(var n = 0 ; n <= 1 ; n++) {
  4815. if(isTrou(
  4816. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4817. )) {
  4818. nbtrous++;
  4819. }
  4820. }
  4821. }
  4822. }
  4823. }
  4824. }
  4825. }
  4826. if(nbtrous>0 && nbtrous<72) {
  4827. return window.confirm(
  4828. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4829. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4830. +'% de risque de tomber dans un trou de météorite.\n'
  4831. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4832. );
  4833. }
  4834. else if(nbtrous>=72) {
  4835. return window.confirm(
  4836. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4837. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4838. +'% de risque de tomber dans un trou de météorite !\n'
  4839. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4840. );
  4841. }
  4842. return true;
  4843. }
  4844. catch(e) {
  4845. window.alert(e)
  4846. }
  4847. }
  4848.  
  4849. function newsubmitTP(event) {
  4850. event.stopPropagation();
  4851. event.preventDefault();
  4852. if(validateTPDestination()) {
  4853. this.submit();
  4854. }
  4855. }
  4856.  
  4857. function changeButtonValidate() {
  4858. var form = document.getElementsByName('Formulaire')[0];
  4859. if(form) {
  4860. if(!form.getAttribute('onsubmit')) {
  4861. form.setAttribute('onsubmit','return true;');
  4862. }
  4863. form.addEventListener('submit', newsubmitTP, true);
  4864. }
  4865. }
  4866.  
  4867.  
  4868. /*-[functions]---------------- Partie Principale -----------------------------*/
  4869.  
  4870. function do_move() {
  4871. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  4872. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4873. changeValidation();
  4874. //}
  4875. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4876. // changeButtonValidate();
  4877. //}
  4878. }
  4879.  
  4880. /*******************************************************************************
  4881. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4882. * Mountyzilla is free software; provided under the GNU General Public License *
  4883. *******************************************************************************/
  4884.  
  4885. // x~x news
  4886.  
  4887. // Nombre de news à afficher & nb max de caractères par news:
  4888. const nbItems = 5;
  4889. const maxCarDescription = 300;
  4890.  
  4891. /*-[functions]------------------- Utilitaires --------------------------------*/
  4892.  
  4893. // Ne semble avoir strictement aucun effet:
  4894. String.prototype.epureDescription = function() {
  4895. return this.replace(/\\(.)/g,"$1");
  4896. }
  4897.  
  4898. function appendTitledTable(node,titre,description) {
  4899. // Crée les tables contenant les infos (avec titre)
  4900. var table = document.createElement('table');
  4901. table.border = 0;
  4902. table.className = 'mh_tdborder';
  4903. table.cellSpacing = 1;
  4904. table.cellPadding = 1;
  4905. table.style.maxWidth = '98%';
  4906. table.style.marginLeft = 'auto';
  4907. table.style.marginRight = 'auto';
  4908. var tbody = document.createElement('tbody');
  4909. table.appendChild(tbody);
  4910. var tr = appendTr(tbody,'mh_tdtitre');
  4911. var td = appendTdCenter(tr,2);
  4912. var span = document.createElement('span');
  4913. appendText(span,titre,true);
  4914. if(description) {
  4915. span.title = description;
  4916. }
  4917. td.appendChild(span);
  4918. node.appendChild(table);
  4919. return tbody;
  4920. }
  4921.  
  4922. function testCertif(paramURL, callbackOnError) {
  4923. try {
  4924. FF_XMLHttpRequest({
  4925. method: 'GET',
  4926. url: paramURL,
  4927. onload: function(responseDetails) {
  4928. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4929. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4930. }
  4931. });
  4932. } catch(e) {
  4933. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4934. callbackOnError();
  4935. }
  4936. }
  4937.  
  4938. function createOrGetGrandCadre() {
  4939. var grandCadre = document.getElementById('grandCadre');
  4940. if (grandCadre) return grandCadre;
  4941. try {
  4942. var rappels = document.evaluate(
  4943. "//p[contains(a/text(),'messagerie')]",
  4944. document, null, 9, null).singleNodeValue;
  4945. }
  4946. catch(e) {
  4947. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4948. grandCadre = document.createElement('div');
  4949. return grandCadre;
  4950. }
  4951. grandCadre = document.createElement('div');
  4952. grandCadre.id = 'grandCadre';
  4953. var sousCadre = document.createElement('div');
  4954. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4955. sousCadre.style.textAlign = 'center';
  4956. sousCadre.style.fontSize = 'xx-large';
  4957. grandCadre.appendChild(sousCadre);
  4958.  
  4959. grandCadre.style.border = 'solid 5px red';
  4960. grandCadre.style.width = 'auto';
  4961. insertBefore(rappels,grandCadre);
  4962. return grandCadre;
  4963. }
  4964.  
  4965. function showHttpsErrorCadre1() {
  4966. var grandCadre = createOrGetGrandCadre();
  4967. var sousCadre = document.createElement('div');
  4968. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4969. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4970. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4971. + URL_CertifRaistlin1
  4972. + '" target="raistlin">clique ici</a>'
  4973. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4974. + ' « Confirmer l\'exception de sécurité »'
  4975. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4976. sousCadre.style.width = 'auto';
  4977. sousCadre.style.fontSize = 'large';
  4978. sousCadre.style.border = 'solid 1px black';
  4979. sousCadre.style.backgroundColor = 'red';
  4980. grandCadre.appendChild(sousCadre);
  4981. }
  4982.  
  4983. function showHttpsErrorCadre2() {
  4984. var grandCadre = createOrGetGrandCadre();
  4985. var sousCadre = document.createElement('div');
  4986. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  4987. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  4988. + '<a style="color:blue;font-size: inherits;" href="'
  4989. + URL_CertifRaistlin2
  4990. + '" target="raistlin">clique ici</a>'
  4991. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  4992. + ' « Confirmer l\'exception de sécurité »'
  4993. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  4994. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  4995. sousCadre.style.width = 'auto';
  4996. sousCadre.style.fontSize = 'large';
  4997. sousCadre.style.border = 'solid 1px black';
  4998. sousCadre.style.backgroundColor = 'red';
  4999. grandCadre.appendChild(sousCadre);
  5000. }
  5001.  
  5002. function showHttpsErrorContenuMixte() {
  5003. var grandCadre = createOrGetGrandCadre();
  5004. var sousCadre = document.createElement('div');
  5005. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5006. + '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)'
  5007. + '<ul>'
  5008. + '<li>Interface Bricol\'Troll</li>'
  5009. + '<li>Nouveautés de Mountyzilla</li>'
  5010. + '</ul>'
  5011. + '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 />'
  5012. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5013. sousCadre.style.width = 'auto';
  5014. sousCadre.style.fontSize = 'large';
  5015. sousCadre.style.border = 'solid 1px black';
  5016. grandCadre.appendChild(sousCadre);
  5017. }
  5018.  
  5019. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5020.  
  5021. function traiterJubilaires() {
  5022. // à faire
  5023. }
  5024.  
  5025. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5026. try {
  5027. FF_XMLHttpRequest({
  5028. method: 'GET',
  5029. url: URL_anniv,
  5030. headers: {
  5031. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5032. 'Accept': 'application/xml,text/xml',
  5033. },
  5034. onload: function(responseDetails) {
  5035. if ((responseDetails.status == 0) && isHTTPS) {
  5036. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5037. showHttpsErrorContenuMixte();
  5038. return;
  5039. }
  5040. var listeTrolls = responseDetails.responseText.split('\n');
  5041. if(!listeTrolls || listeTrolls.length==0) {
  5042. return;
  5043. }
  5044. afficherJubilaires(listeTrolls);
  5045. },
  5046. });
  5047. }
  5048. catch(e) {
  5049. if (isHTTPS) {
  5050. window.console.log(traceStack(e, 'appel jubilaires'));
  5051. showHttpsErrorContenuMixte();
  5052. } else {
  5053. window.alert('Erreur Jubilaires:\n'+e);
  5054. }
  5055. }
  5056. }
  5057.  
  5058. function afficherJubilaires(listeTrolls) {
  5059. try {
  5060. var rappels = document.evaluate(
  5061. "//p[contains(a/text(),'messagerie')]",
  5062. document, null, 9, null).singleNodeValue;
  5063. }
  5064. catch(e) {
  5065. return;
  5066. }
  5067. var p = document.createElement('p');
  5068. var tbody = appendTitledTable(p,
  5069. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5070. 'Envoyez leur un message ou un cadeau !'
  5071. );
  5072. tr = appendTr(tbody,'mh_tdpage');
  5073. td = appendTdCenter(tr);
  5074. var small = document.createElement('small');
  5075. td.appendChild(small);
  5076. var first = true;
  5077. for(var i=0 ; i<listeTrolls.length ; i++) {
  5078. var infos = listeTrolls[i].split(';');
  5079. if(infos.length!=3 || infos[2]==='0') {
  5080. continue;
  5081. }
  5082. if(first) {
  5083. first = false;
  5084. }
  5085. else {
  5086. appendText(small,', ');
  5087. }
  5088. var a = document.createElement('a');
  5089. a.href = 'javascript:EPV('+infos[0]+')';
  5090. appendText(a,infos[1]);
  5091. small.appendChild(a);
  5092. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5093. }
  5094. insertBefore(rappels,p);
  5095. }
  5096.  
  5097.  
  5098. /*-[functions]--------------------- News MZ ----------------------------------*/
  5099.  
  5100. function traiterNouvelles() {
  5101. var news = new Array;
  5102. 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 ;).']);
  5103. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5104. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5105. 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']);
  5106. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5107. afficherNouvelles(news);
  5108. }
  5109.  
  5110. function afficherNouvelles(items) {
  5111. var footer = document.getElementById('footer1');
  5112. if(!footer) {
  5113. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5114. return;
  5115. }
  5116. var p = document.createElement('p');
  5117. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5118. var div = document.createElement('div');
  5119. div.style.position = 'absolute';
  5120. div.style.right = 0;
  5121. div.style.top = 0;
  5122. div.style.paddingRight = '3px';
  5123. div.style.whiteSpace = 'nowrap';
  5124. appendText(div, '(version ' + GM_info.script.version + ')');
  5125. tbody.rows[0].cells[0].style.position = 'relative';
  5126. tbody.rows[0].cells[0].appendChild(div);
  5127. for(var i=0 ; i<items.length ; i++) {
  5128. var tr = appendTr(tbody,'mh_tdpage');
  5129. var td = appendTdCenter(tr);
  5130. td.style.verticalAlign = 'top'; // semble sans effet
  5131. appendText(td,items[i][0],true);
  5132. td = appendTd(tr);
  5133. td.innerHTML = items[i][1];
  5134. }
  5135. insertBefore(footer,p);
  5136.  
  5137. // changelog
  5138. var p = document.createElement('p');
  5139. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5140. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5141. tbody.rows[0].cells[0].onclick = function() {
  5142. try {
  5143. tbody.rows[0].cells[0].onclick = undefined;
  5144. tbody.rows[0].cells[0].style.cursor = '';
  5145. var tr = appendTr(tbody,'mh_tdpage');
  5146. var td = appendTd(tr);
  5147. td.colSpan = 2;
  5148. var pre = document.createElement('pre');
  5149. appendText(pre,MZ_changeLog.join("\n"));
  5150. td.appendChild(pre);
  5151. } catch (e) {
  5152. window.console.log('[MZ] affichage changeLog', e);
  5153. }
  5154. };
  5155. insertBefore(footer,p);
  5156.  
  5157. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5158. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5159. if (isHTTPS) {
  5160. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5161. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5162. } else {
  5163. window.console.log('[MZ test] début switch to https');
  5164. window.sessionStorage.setItem('xxx', "test session trans https");
  5165. window.parent.xxx = "autre test";
  5166. var url = document.location.href;
  5167. window.console.log('[MZ test] url=' + url);
  5168. url = url.replace(/http:\/\//i, 'https://')
  5169. window.console.log('[MZ test] switched url=' + url);
  5170. document.location.href = url;
  5171. }
  5172. }
  5173. if (false) { // version par utilisation d'un IFrame en https
  5174. if (isHTTPS) {
  5175. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5176. //window.console.log('[MZ test] window.name=' + window.name);
  5177. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5178. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5179. var txt = window.name;
  5180. var tabtxt = txt.split(/µ/);
  5181. for (var i = 0; i < tabtxt.length; i++) {
  5182. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5183. }
  5184. } else {
  5185. var txt = '';
  5186. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5187. var k = localStorage.key(i);
  5188. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5189. txt += k + "£" + localStorage.getItem(k) + "µ";
  5190. }
  5191. var iframe = document.createElement('iframe');
  5192. var url = document.location.href;
  5193. //window.console.log('[MZ test] url=' + url);
  5194. url = url.replace(/http:\/\//i, 'https://')
  5195. //window.console.log('[MZ test] switched url=' + url);
  5196. //iframe.xxx = "truc en plume";
  5197. iframe.name = txt;
  5198. //window.xxx = "machin";
  5199. iframe.src = url;
  5200. //iframe.document.xxx = "truc en plume";
  5201. document.body.appendChild(iframe);
  5202. iframe.style.display = 'none';
  5203. }
  5204. }
  5205. }
  5206. }
  5207.  
  5208.  
  5209. /*---------------------------------- Main ------------------------------------*/
  5210.  
  5211. function do_news() {
  5212. start_script();
  5213.  
  5214. traiterJubilaires();
  5215. traiterNouvelles();
  5216.  
  5217. if (isHTTPS) {
  5218. // test si les certificats raistlin ont été acceptés
  5219. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5220. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5221. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5222. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5223. }
  5224. }
  5225.  
  5226. displayScriptTime();
  5227. }
  5228.  
  5229. /*********************************************************************************
  5230. * This file is part of Mountyzilla. *
  5231. * *
  5232. * Mountyzilla is free software; you can redistribute it and/or modify *
  5233. * it under the terms of the GNU General Public License as published by *
  5234. * the Free Software Foundation; either version 2 of the License, or *
  5235. * (at your option) any later version. *
  5236. * *
  5237. * Mountyzilla is distributed in the hope that it will be useful, *
  5238. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5239. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5240. * GNU General Public License for more details. *
  5241. * *
  5242. * You should have received a copy of the GNU General Public License *
  5243. * along with Mountyzilla; if not, write to the Free Software *
  5244. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5245. *********************************************************************************/
  5246.  
  5247. // x~x tabcompo
  5248.  
  5249. var popup;
  5250.  
  5251. function initPopupTabcompo() {
  5252. popup = document.createElement('div');
  5253. popup.setAttribute('id', 'popup');
  5254. popup.setAttribute('class', 'mh_textbox');
  5255. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5256. + 'display: inline; z-index: 3; max-width: 400px;');
  5257. document.body.appendChild(popup);
  5258. }
  5259.  
  5260. function showPopup(evt) {
  5261. var texte = this.getAttribute("texteinfo");
  5262. popup.innerHTML = texte;
  5263. popup.style.left = evt.pageX + 15 + 'px';
  5264. popup.style.top = evt.pageY + 'px';
  5265. popup.style.visibility = "visible";
  5266. }
  5267.  
  5268. // roule 16/03/2016, existe déjà ailleurs
  5269. // function hidePopup() {
  5270. // popup.style.visibility = 'hidden';
  5271. // }
  5272.  
  5273. function createPopupImage(url, text)
  5274. {
  5275. var img = document.createElement('img');
  5276. img.setAttribute('src',url);
  5277. img.setAttribute('align','ABSMIDDLE');
  5278. img.setAttribute("texteinfo",text);
  5279. img.addEventListener("mouseover", showPopup,true);
  5280. img.addEventListener("mouseout", hidePopup,true);
  5281. return img;
  5282. }
  5283.  
  5284. function formateTexte(texte)
  5285. {
  5286. texte = texte.replace(/\n/g,"<br/>");
  5287. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5288. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5289. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5290. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5291. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5292. return texte;
  5293. }
  5294.  
  5295. function arrondi(x) {
  5296. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5297. }
  5298.  
  5299. function traiteMinerai() {
  5300. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5301. try {
  5302. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5303. +" and contains(./tr/th/text(),'Minerai')]",
  5304. document, null, 9, null).singleNodeValue;
  5305. node = node.nextSibling.nextSibling;
  5306. }
  5307. catch(e) {return;}
  5308. var trlist = document.evaluate('./tr', node, null, 7, null);
  5309. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5310. var node = trlist.snapshotItem(i);
  5311. var nature = node.childNodes[5].textContent;
  5312. var caracs = node.childNodes[7].textContent;
  5313. var taille = caracs.match(/\d+/)[0];
  5314. var coef = 1;
  5315. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5316. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5317. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5318. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5319. if (nature.indexOf('Mithril')!=-1) {
  5320. coef = 0.2*coef;
  5321. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5322. }
  5323. else {
  5324. coef = 0.75*coef+1.25;
  5325. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5326. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5327. }
  5328. }
  5329. }
  5330.  
  5331. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5332. function treateComposants() {
  5333. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5334. //On récupère les composants
  5335. var nodes = document.evaluate(
  5336. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5337. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5338. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5339. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5340. if (nodes.snapshotLength == 0) {
  5341. //window.console.log('[MZ] treateComposants DOWN');
  5342. return;
  5343. }
  5344. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5345.  
  5346. var texte = "";
  5347. for (var i = 0; i < nodes.snapshotLength; i++) {
  5348. var n1 = nodes.snapshotItem(i).childNodes[1];
  5349. var n3 = nodes.snapshotItem(i).childNodes[3];
  5350. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5351. var prix = n3.childNodes[0].nodeValue;
  5352. if (!prix)
  5353. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5354. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5355. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5356. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5357. + prix.replace(/\n/g, '') + "\n";
  5358. }
  5359.  
  5360. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5361. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5362. var id_taniere = c.snapshotItem(0).nodeValue;
  5363. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5364.  
  5365. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5366. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5367. if (form)
  5368. {
  5369. if(document.getElementsByTagName('form').length>0)
  5370. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5371. else
  5372. {
  5373. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5374. insertBefore(thisP, form);
  5375. }
  5376. }
  5377. }
  5378.  
  5379. function treateAllComposants() {
  5380. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5381. //On récupère les composants
  5382. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5383. document, null, 0, null ).numberValue;
  5384. var c = (categ == 0 ? 3 : 4);
  5385. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5386. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5387. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5388. + "td["+c+"]/text()[1] = '\240-\240' "
  5389. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5390. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5391. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5392. + "and td[1]/img/@alt = 'Identifié']",
  5393. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5394. if (nodes.snapshotLength == 0) {
  5395. // window.alert('treateAllComposants DOWN');
  5396. return;
  5397. }
  5398.  
  5399. var texte = "";
  5400. for (var i = 0; i < nodes.snapshotLength; i++) {
  5401. var n1 = nodes.snapshotItem(i).childNodes[1];
  5402. var n3 = nodes.snapshotItem(i).childNodes[3];
  5403. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5404. var prix = n3.childNodes[0].nodeValue;
  5405. if (!prix)
  5406. {
  5407. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5408. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5409. }
  5410. else
  5411. {
  5412. prix= prix.replace(/[\240 ]/g, "");
  5413. if(prix=="-")
  5414. prix=null;
  5415. }
  5416. if(prix)
  5417. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5418. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5419. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5420. + prix.replace(/\n/g, '') + "\n";
  5421. else
  5422. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5423. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5424. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5425. }
  5426.  
  5427. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5428. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5429. var id_taniere = c.snapshotItem(0).nodeValue;
  5430. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5431.  
  5432. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5433. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5434. if (form)
  5435. {
  5436. if(document.getElementsByTagName('form').length>0)
  5437. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5438. else
  5439. {
  5440. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5441. insertBefore(thisP, form);
  5442. }
  5443. }
  5444. }
  5445.  
  5446. function treateEM()
  5447. {
  5448. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5449. if(currentURL.indexOf("as_type=Compo")==-1)
  5450. return false;
  5451. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5452. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5453. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5454. if (nodes.snapshotLength == 0)
  5455. return false;
  5456. for (var i = 0; i < nodes.snapshotLength; i++) {
  5457. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5458. var link = desc[2].firstChild ;
  5459. var nomCompoTotal = desc[2].textContent ;
  5460. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5461. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5462. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5463. var locqual = desc[3].textContent ;
  5464. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5465. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5466. if(isEM(nomMonstre).length>0)
  5467. {
  5468. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5469. if(infos.length>0)
  5470. {
  5471. var shortDescr = "Variable";
  5472. var bold = 0;
  5473. if(infos != "Composant variable")
  5474. {
  5475. shortDescr = infos.substring(0,infos.indexOf(" "));
  5476. if(parseInt(shortDescr)>=0)
  5477. bold=1;
  5478. }
  5479. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5480. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5481. }
  5482. }
  5483. }
  5484. }
  5485.  
  5486. function treateChampi() {
  5487. if (currentURL.indexOf('as_type=Champi')==-1)
  5488. return false;
  5489. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5490. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5491. if (nodes.snapshotLength == 0)
  5492. return false;
  5493.  
  5494. for (var i = 0; i < nodes.snapshotLength; i++) {
  5495. var node = nodes.snapshotItem(i);
  5496. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5497. if (moisChampi[nomChampi])
  5498. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5499. }
  5500. }
  5501.  
  5502. function treateEnchant()
  5503. {
  5504. if(currentURL.indexOf("as_type=Compo")==-1)
  5505. return false;
  5506. try
  5507. {
  5508. if(!listeMonstreEnchantement)
  5509. computeCompoEnchantement();
  5510. var nodes = document.evaluate(
  5511. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5512. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5513. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5514. if (nodes.snapshotLength == 0)
  5515. return false;
  5516. var urlImg = URL_MZimg + "enchant.png";
  5517. for (var i = 0; i < nodes.snapshotLength; i++) {
  5518. var link = nodes.snapshotItem(i);
  5519. var nomCompoTotal = link.firstChild.nodeValue;
  5520. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5521. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5522. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5523. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5524. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5525. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5526. if(isEnchant(nomMonstre).length>0)
  5527. {
  5528. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5529. if(infos.length>0)
  5530. {
  5531. link.parentNode.appendChild(createImage(urlImg,infos));
  5532. }
  5533. }
  5534. }
  5535. }
  5536. catch(e)
  5537. {
  5538. window.alert(e);
  5539. }
  5540. }
  5541.  
  5542. function treateEquipEnchant()
  5543. {
  5544. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5545. return false;
  5546. initPopupTabcompo();
  5547. computeEnchantementEquipement(createPopupImage,formateTexte);
  5548. }
  5549.  
  5550. function do_tancompo() {
  5551. start_script();
  5552.  
  5553. treateAllComposants();
  5554. treateComposants();
  5555. traiteMinerai();
  5556. if (MY_getValue('NOINFOEM')!='true') {
  5557. treateChampi();
  5558. treateEM();
  5559. }
  5560. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5561. treateEnchant();
  5562. treateEquipEnchant();
  5563. }
  5564.  
  5565. displayScriptTime();
  5566. }
  5567.  
  5568. /*******************************************************************************
  5569. * This file is part of Mountyzilla. *
  5570. * *
  5571. * Mountyzilla is free software; you can redistribute it and/or modify *
  5572. * it under the terms of the GNU General Public License as published by *
  5573. * the Free Software Foundation; either version 2 of the License, or *
  5574. * (at your option) any later version. *
  5575. * *
  5576. * Mountyzilla is distributed in the hope that it will be useful, *
  5577. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5578. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5579. * GNU General Public License for more details. *
  5580. * *
  5581. * You should have received a copy of the GNU General Public License *
  5582. * along with Mountyzilla; if not, write to the Free Software *
  5583. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5584. *******************************************************************************/
  5585.  
  5586. // x~x pjview
  5587.  
  5588. /* TODO
  5589. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5590. */
  5591.  
  5592. // Bulle d'infos
  5593. var DivInfo;
  5594. // Booléen stockant l'état de freezing de la bulle
  5595. var freezed = false;
  5596.  
  5597. // liste du matos
  5598. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5599. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5600. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5601. var mh_caracs = {
  5602. 'anneau de protection':
  5603. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5604. "armure d'anneaux":
  5605. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5606. 'armure de bois':
  5607. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5608. 'armure de cuir':
  5609. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5610. 'armure de peaux':
  5611. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5612. 'armure de pierre':
  5613. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5614. 'armure de plates':
  5615. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5616. 'baton lesté':
  5617. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5618. 'bâtons de parade':
  5619. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5620. 'bottes':
  5621. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5622. 'bouclier à pointes':
  5623. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5624. 'boulet et chaîne':
  5625. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5626. 'cagoule':
  5627. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5628. 'casque à cornes':
  5629. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5630. 'casque à pointes':
  5631. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5632. 'casque en cuir':
  5633. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5634. 'casque en métal':
  5635. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5636. 'chaîne cloutée':
  5637. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5638. 'chapeau pointu':
  5639. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5640. 'collier de dents':
  5641. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5642. 'collier de pierre':
  5643. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5644. 'collier à pointes':
  5645. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5646. 'cotte de mailles':
  5647. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5648. 'couronne de cristal':
  5649. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5650. "couronne d'obsidienne":
  5651. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5652. "coutelas d'obsidienne":
  5653. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5654. 'coutelas en os':
  5655. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5656. 'crochet':
  5657. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5658. 'cuir bouilli':
  5659. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5660. "cuirasse d'ossements":
  5661. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5662. "cuirasse d'écailles":
  5663. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5664. 'culotte en cuir':
  5665. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5666. 'dague':
  5667. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5668. 'epée courte':
  5669. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5670. 'epée longue':
  5671. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5672. 'espadon':
  5673. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5674. 'fouet':
  5675. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5676. 'fourrures':
  5677. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5678. 'gantelet':
  5679. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5680. 'gorgeron en cuir':
  5681. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5682. 'gorgeron en métal':
  5683. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5684. 'gourdin':
  5685. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5686. 'gourdin clouté':
  5687. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5688. 'grimoire':
  5689. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5690. "gros'porte":
  5691. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5692. 'grosse racine':
  5693. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5694. 'grosse stalagmite':
  5695. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5696. 'hache de bataille':
  5697. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5698. 'hache de guerre en os':
  5699. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5700. 'hache de guerre en pierre':
  5701. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5702. "hache à deux mains d'obsidienne":
  5703. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5704. 'hallebarde':
  5705. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5706. "haubert d'écailles":
  5707. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5708. 'haubert de mailles':
  5709. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5710. 'heaume':
  5711. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5712. 'jambières en cuir':
  5713. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5714. 'jambières en fourrure':
  5715. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5716. 'jambières en maille':
  5717. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5718. 'jambières en métal':
  5719. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5720. 'jambières en os':
  5721. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5722. "lame d'obsidienne":
  5723. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5724. 'lame en os':
  5725. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5726. 'lame en pierre':
  5727. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5728. 'lorgnons':
  5729. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5730. 'machette':
  5731. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5732. "masse d'arme":
  5733. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5734. 'pagne de mailles':
  5735. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5736. 'pagne en cuir':
  5737. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5738. 'robe de mage':
  5739. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5740. 'rondache en bois':
  5741. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5742. 'rondache en métal':
  5743. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5744. 'sandales':
  5745. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5746. 'souliers dorés':
  5747. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5748. "talisman d'obsidienne":
  5749. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5750. 'talisman de pierre':
  5751. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5752. 'targe':
  5753. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5754. 'torche':
  5755. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5756. 'torque de pierre':
  5757. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5758. 'tunique':
  5759. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5760. "tunique d'écailles":
  5761. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5762. 'turban':
  5763. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5764. }
  5765.  
  5766. // liste des templates
  5767. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5768. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5769. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5770. var mh_templates = {
  5771. 'de Feu':
  5772. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5773. 'de Résistance':
  5774. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5775. "de l'Aigle":
  5776. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5777. 'de la Salamandre':
  5778. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5779. 'des Cyclopes':
  5780. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5781. 'des Enragés':
  5782. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5783. 'des Tortues':
  5784. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5785. 'des Vampires':
  5786. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5787. 'du Glacier':
  5788. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5789. 'du Rat':
  5790. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5791. 'du Roc':
  5792. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5793. 'du Temps':
  5794. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5795. 'du Vent':
  5796. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5797. 'en Mithril':
  5798. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5799. 'des Anciens':
  5800. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5801. 'des Champions':
  5802. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5803. 'des Duellistes':
  5804. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5805. 'de la Terre':
  5806. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5807. "de l'Orage":
  5808. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5809. "de l'Ours":
  5810. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5811. 'des Béhémoths':
  5812. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5813. 'des Mages':
  5814. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5815. 'du Pic':
  5816. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5817. 'du Sable':
  5818. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5819. 'acéré':
  5820. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5821. 'acérée':
  5822. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5823. 'équilibré':
  5824. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5825. 'équilibrée':
  5826. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5827. 'léger':
  5828. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5829. 'légère':
  5830. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5831. 'renforcé':
  5832. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5833. 'renforcée':
  5834. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5835. 'robuste':
  5836. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5837. }
  5838.  
  5839. function clone(arr) {
  5840. // Clonage rapide
  5841. return arr.slice(0);
  5842. }
  5843.  
  5844. function addArray(arr1,arr2) {
  5845. // Somme matricielle
  5846. var res = clone(arr1);
  5847. for(i=res.length-1 ; i>=0 ; i--) {
  5848. res[i] += arr2[i];
  5849. }
  5850. return res;
  5851. }
  5852.  
  5853. function getTemplates(nomItem) {
  5854. // Déstructure le nom de l'item en array [nom, template1, ...]
  5855. var tempFound = true;
  5856. var str = nomItem.trim();
  5857. var arr = [];
  5858. while(tempFound) {
  5859. tempFound = false;
  5860. for(var temp in mh_templates) {
  5861. // on teste la fin du nom contre chaque template
  5862. if(str.slice(-temp.length)!=temp) { continue; }
  5863. tempFound = true;
  5864. str = str.slice(0,-temp.length-1);
  5865. arr.unshift(temp);
  5866. if(str.slice(-3)==' et') {
  5867. str = str.slice(0,-3);
  5868. }
  5869. }
  5870. }
  5871. arr.unshift(str);
  5872. return arr;
  5873. }
  5874.  
  5875. function addMithril(arrayCaracs,typeItem) {
  5876. // Ajoute l'effet du Mithril sur les caracs
  5877. if(typeItem=='arme') {
  5878. if(arrayCaracs[0]<0) {
  5879. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5880. }
  5881. }
  5882. else {
  5883. if(arrayCaracs[4]<0) {
  5884. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5885. }
  5886. }
  5887. arrayCaracs[15] /= 2;
  5888. arrayCaracs[16] /= 2;
  5889. return arrayCaracs;
  5890. }
  5891.  
  5892. function addRenfort(arrayCaracs,template) {
  5893. // Ajoute l'effet des pseudo-templates sur les caracs
  5894. // S'applique APRÈS le mithril
  5895. // WARNING - Cette formule n'a rien d'officiel, gare !
  5896. var coef = 0;
  5897. if(/^lég[e,è]re?$/.test(template)) {
  5898. coef = -1;
  5899. }
  5900. else if(/^renforcée?$/.test(template)
  5901. || template==='robuste') {
  5902. coef = 1;
  5903. }
  5904. if(coef) {
  5905. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5906. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5907. }
  5908. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5909. return arrayCaracs;
  5910. }
  5911.  
  5912. function getCaracs(item) {
  5913. // Calcule les caractéristiques de l'item
  5914. var templates = getTemplates(item);
  5915. if(!mh_caracs[templates[0]]) {
  5916. // Si l'item est inconnu
  5917. return [];
  5918. }
  5919. var caracs = clone(mh_caracs[templates[0]]);
  5920. var typeItem = caracs[0];
  5921. caracs.shift();
  5922. templates.shift();
  5923. if(templates[templates.length-1]=='en Mithril') {
  5924. caracs = addMithril(caracs,typeItem);
  5925. templates.pop();
  5926. }
  5927. if(/^acérée?$/.test(templates[0])
  5928. || /^équilibrée?$/.test(templates[0])
  5929. || /^lég[e,è]re?$/.test(templates[0])
  5930. || /^renforcée?$/.test(templates[0])
  5931. || templates[0]=='robuste') {
  5932. caracs = addRenfort(caracs,templates[0]);
  5933. templates.shift();
  5934. }
  5935. for(var i=templates.length-1 ; i>=0 ; i--) {
  5936. caracs = addArray(caracs,mh_templates[templates[i]]);
  5937. }
  5938. return caracs;
  5939. }
  5940.  
  5941. function getLine(tab) {
  5942. // Préparation de la ligne à afficher lors d'un mouseover
  5943. var str = '';
  5944. if(tab[0]!=0 || tab[1]!=0) {
  5945. str += '<b>Att : </b>'+aff(tab[0]);
  5946. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5947. str += ' | ';
  5948. }
  5949. if(tab[4]!=0) {
  5950. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5951. }
  5952. if(tab[2]!=0 || tab[3]!=0) {
  5953. str += '<b>Deg : </b>'+aff(tab[2]);
  5954. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5955. str += ' | ';
  5956. }
  5957. if(tab[8]!=0) {
  5958. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5959. }
  5960. if(tab[7]!=0) {
  5961. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5962. }
  5963. if(tab[5]!=0 || tab[6]!=0) {
  5964. str += '<b>Arm : </b>'+aff(tab[5]);
  5965. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5966. str += ' | ';
  5967. }
  5968. if(tab[9]!=0 || tab[10]!=0) {
  5969. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5970. if(tab[9]!=tab[10]) {
  5971. str += '/'+aff(tab[10])+'%';
  5972. }
  5973. str += ' | ';
  5974. }
  5975. if(tab[11]!=0 || tab[12]!=0) {
  5976. str += '<b>MM : </b>'+aff(tab[11])+'%';
  5977. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  5978. str += ' | ';
  5979. }
  5980. if(tab[13]!=0) {
  5981. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  5982. }
  5983. if(tab[14]!=0) {
  5984. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  5985. }
  5986. str += '<b>Poids : </b>'+tab[15]+' min';
  5987. if(tab[15]!=tab[16]) {
  5988. str += ' / '+tab[16]+' min';
  5989. }
  5990. return str;
  5991. }
  5992.  
  5993. function toolTipInit() {
  5994. DivInfo = document.createElement('div');
  5995. DivInfo.id = 'infosVue';
  5996. DivInfo.className = 'mh_textbox';
  5997. DivInfo.style =
  5998. 'position: absolute;'
  5999. +'border: 1px solid #000000;'
  6000. +'visibility:hidden;'
  6001. +'display:inline;'
  6002. +'z-index:99;';
  6003. document.body.appendChild(DivInfo);
  6004. document.onmousemove = getXY;
  6005. document.onclick = changeFreezeStatus;
  6006. }
  6007.  
  6008. function getXY(evt) {
  6009. if(!freezed && DivInfo.style.visibility=='visible') {
  6010. DivInfo.style.left = evt.pageX+'px';
  6011. DivInfo.style.top = evt.pageY+10+'px';
  6012. }
  6013. }
  6014.  
  6015. function changeFreezeStatus() {
  6016. if(DivInfo.style.visibility=='visible') {
  6017. freezed = !freezed;
  6018. if(!freezed) { hideInfos(); }
  6019. }
  6020. }
  6021.  
  6022. function showInfos() {
  6023. if(freezed) { return; }
  6024. var currentInfos = this.infos;
  6025. DivInfo.innerHTML = currentInfos;
  6026. DivInfo.style.visibility = 'visible';
  6027. }
  6028.  
  6029. function hideInfos() {
  6030. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6031. }
  6032.  
  6033. function treateEquipement() {
  6034. // Extrait les données du matos et réinjecte les infos déduites
  6035. if(MY_getValue('INFOCARAC')=='false') { return; }
  6036. var faireLigne = false;
  6037. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6038. var nodes = document.evaluate(
  6039. "//td/b[text()='Equipement Utilisé']/../../"
  6040. +"td[2]/img[contains(@src,bullet)]",
  6041. document, null, 7, null);
  6042. if(nodes.snapshotLength>0) {
  6043. // Si CSS de base
  6044. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6045. var node = nodes.snapshotItem(i);
  6046. var next = node.nextSibling;
  6047. var nnext = next.nextSibling;
  6048. var nom = next.nodeValue.toLowerCase();
  6049. if(nnext.childNodes.length==1) {
  6050. nom += nnext.firstChild.nodeValue;
  6051. }
  6052. nom = nom.trim();
  6053. // gestion winpostrophe
  6054. var c = String.fromCharCode(180);
  6055. while(nom.indexOf(c)!=-1) {
  6056. nom = nom.replace(c,"'");
  6057. }
  6058. var arr = getCaracs(nom);
  6059. if(arr.length>0) {
  6060. faireLigne = true;
  6061. caracs = addArray(caracs,arr);
  6062. var span = document.createElement('span');
  6063. span.appendChild(next);
  6064. span.appendChild(nnext);
  6065. span.infos = getLine(arr);
  6066. span.onmouseover = showInfos;
  6067. span.onmouseout = hideInfos;
  6068. insertBefore(node.nextSibling,span);
  6069. }
  6070. }
  6071. if(faireLigne) {
  6072. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6073. document, null, 9, null).singleNodeValue;
  6074. node.infos = getLine(caracs);
  6075. node.onmouseover = showInfos;
  6076. node.onmouseout = hideInfos;
  6077. }
  6078. }
  6079. else {
  6080. // Si CSS avancée
  6081. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6082. document, null, 7, null);
  6083. if(nodes.snapshotLength>0) {
  6084. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6085. var node = nodes.snapshotItem(i);
  6086. var nom = node.firstChild.nodeValue.toLowerCase();
  6087. if(node.childNodes.length>1) {
  6088. nom += node.childNodes[1].firstChild.nodeValue;
  6089. }
  6090. nom = nom.trim();
  6091. // gestion winpostrophe
  6092. var c = String.fromCharCode(180);
  6093. while(nom.indexOf(c)!=-1) {
  6094. nom = nom.replace(c,"'");
  6095. }
  6096. var arr = getCaracs(nom);
  6097. if(arr.length!=0) {
  6098. caracs = addArray(caracs,arr);
  6099. node.infos = getLine(arr);
  6100. node.onmouseover = showInfos;
  6101. node.onmouseout = hideInfos;
  6102. }
  6103. }
  6104. var nodes = document.evaluate("//dt[@class='equipement']",
  6105. document, null, 7, null);
  6106. var node = nodes.snapshotItem(0);
  6107. node.infos = getLine(caracs);
  6108. node.onmouseover = showInfos;
  6109. node.onmouseout = hideInfos;
  6110. }
  6111. }
  6112. }
  6113.  
  6114. function do_pjview() {
  6115. treateEquipement();
  6116. toolTipInit();
  6117. }
  6118.  
  6119. /*******************************************************************************
  6120. * This file is part of Mountyzilla. *
  6121. * *
  6122. * Mountyzilla is free software; you can redistribute it and/or modify *
  6123. * it under the terms of the GNU General Public License as published by *
  6124. * the Free Software Foundation; either version 2 of the License, or *
  6125. * (at your option) any later version. *
  6126. * *
  6127. * Mountyzilla is distributed in the hope that it will be useful, *
  6128. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6129. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6130. * GNU General Public License for more details. *
  6131. * *
  6132. * You should have received a copy of the GNU General Public License *
  6133. * along with Mountyzilla; if not, write to the Free Software *
  6134. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6135. *******************************************************************************/
  6136.  
  6137. // x~x option
  6138.  
  6139. /* TODO
  6140. * Passer le HTML injecté aux conventions HTML5
  6141. */
  6142.  
  6143.  
  6144. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6145.  
  6146. function saveITData() {
  6147. var IT = document.getElementById('itSelect').value;
  6148. if(IT=='bricol') {
  6149. var system = document.getElementById('urlbricol').value;
  6150. var login = document.getElementById('loginbricol').value;
  6151. var pass = document.getElementById('passbricol').value;
  6152. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6153. if(system && login) {
  6154. if (pass) {
  6155. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6156. MY_setValue(numTroll+'.INFOSIT', v);
  6157. //window.console.log('v=' + v);
  6158. } else {
  6159. // vérif que rien n'a changé
  6160. var str = MY_getValue(numTroll+'.INFOSIT');
  6161. if(str) {
  6162. var arr = str.split('$');
  6163. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6164. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  6165. }
  6166. }
  6167. }
  6168. }
  6169. }
  6170. else {
  6171. MY_removeValue(numTroll+'.INFOSIT');
  6172. }
  6173. }
  6174.  
  6175. function saveLinks() {
  6176. var numLinks = document.getElementById('linksBody').childNodes.length;
  6177. var data=[ [] ];
  6178. /* Récupération et tri des liens */
  6179. for(var i=1 ; i<=numLinks ; i++) {
  6180. MY_removeValue('URL'+i);
  6181. MY_removeValue('URL'+i+'.nom');
  6182. MY_removeValue('URL'+i+'.ico');
  6183. var url = document.getElementById('url'+i).value;
  6184. var nom = document.getElementById('nom'+i).value;
  6185. var ico = document.getElementById('ico'+i).value;
  6186. if(url && (nom || ico) ) {
  6187. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6188. }
  6189. }
  6190. /* Sauvegarde */
  6191. for(var i=1 ; i<data.length ; i++) {
  6192. MY_setValue('URL'+i,data[i][0]);
  6193. MY_setValue('URL'+i+'.nom',data[i][1]);
  6194. MY_setValue('URL'+i+'.ico',data[i][2]);
  6195. }
  6196. }
  6197.  
  6198. function saveAll() {
  6199. var urlIco = document.getElementById('icoMenuIco').value;
  6200. if(urlIco) {
  6201. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6202. }
  6203. else {
  6204. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6205. document.getElementById('icoMenuIco').value = '';
  6206. }
  6207. saveLinks();
  6208. refreshLinks();
  6209. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6210. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6211. if(maxcdm) {
  6212. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6213. }
  6214. else {
  6215. MY_removeValue(numTroll+'.MAXCDM');
  6216. document.getElementById('maxcdm').value = '';
  6217. }
  6218.  
  6219. MY_setValue('NOINFOEM',
  6220. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6221. // Pourquoi Tilk stockait-il tout en str ?
  6222. // -> parce que les booléens c'est foireux (vérifié)
  6223. MY_setValue(numTroll+'.USECSS',
  6224. document.getElementById('usecss').checked ? 'true':'false');
  6225. MY_setValue('INFOCARAC',
  6226. document.getElementById('infocarac').checked ? 'true' : 'false');
  6227. //MY_setValue(numTroll+'.SEND_IDT',
  6228. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6229. // Fonctionnalité désactivée
  6230.  
  6231. MY_setValue(numTroll+'.AUTOCDM',
  6232. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6233. MY_setValue('VUECARAC',
  6234. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6235. MY_setValue('CONFIRMEDECALAGE',
  6236. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6237.  
  6238. saveITData();
  6239. var bouton = document.getElementById('saveAll');
  6240. bouton.value = (bouton.value=='Sauvegardé !') ?
  6241. 'Re-sauvegardé !' : 'Sauvegardé !';
  6242. }
  6243.  
  6244.  
  6245. /*-[functions]----------------- EventListeners -------------------------------*/
  6246.  
  6247. function onChangeIT() {
  6248. var IT = document.getElementById('itSelect').value;
  6249. var itBody = document.getElementById('itBody');
  6250. itBody.innerHTML = '';
  6251. if(IT=='bricol') {
  6252. var tr = appendTr(itBody,'mh_tdpage')
  6253. var td = appendTd(tr);
  6254. var str = MY_getValue(numTroll+'.INFOSIT');
  6255. //window.console.log('onChangeIT str=' + str);
  6256. if(str) {
  6257. var arr = str.split('$');
  6258. var system = arr[1];
  6259. var login = arr[2];
  6260. var affhv = arr[4];
  6261. }
  6262. appendText(td,'Nom du système : ');
  6263. appendTextbox(td,'text','urlbricol',20,50,system);
  6264. td = appendTd(tr);
  6265. appendText(td,'Login du compte : ');
  6266. appendTextbox(td,'text','loginbricol',20,50,login);
  6267. td = appendTd(tr);
  6268. appendText(td,'Mot de passe du compte : ');
  6269. appendTextbox(td,'password','passbricol',20,50);
  6270. td = appendTd(tr);
  6271. appendText(td,'Affichage des Trõlls hors vue : ');
  6272. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  6273. appendCheckBox(td,'affhvbricol', (affhv>0));
  6274. }
  6275. }
  6276.  
  6277. function refreshLinks() {
  6278. document.getElementById('linksBody').innerHTML = '';
  6279. var anotherURL = MY_getValue('URL1');
  6280. if(!anotherURL) { addLinkField(); }
  6281. var i=1;
  6282. while(anotherURL && i<99) {
  6283. addLinkField(i,anotherURL,
  6284. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6285. i++;
  6286. anotherURL = MY_getValue('URL'+i);
  6287. }
  6288. }
  6289.  
  6290. function addLinkField(i,url,nom,ico) {
  6291. var linksBody = document.getElementById('linksBody');
  6292. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6293. var tr = appendTr(linksBody);
  6294. var td = appendTdCenter(tr);
  6295. appendText(td,'Lien '+i+' : ');
  6296. appendTextbox(td,'text','url'+i,40,150,url);
  6297. td = appendTdCenter(tr);
  6298. appendText(td,'Nom : ');
  6299. appendTextbox(td,'text','nom'+i,20,150,nom);
  6300. td = appendTdCenter(tr);
  6301. appendText(td,'Icône : ');
  6302. appendTextbox(td,'text','ico'+i,40,150,ico);
  6303. }
  6304.  
  6305. function removeLinkField() {
  6306. var linksBody = document.getElementById('linksBody');
  6307. var i = linksBody.childNodes.length;
  6308. MY_removeValue('URL'+i);
  6309. MY_removeValue('URL'+i+'.nom');
  6310. MY_removeValue('URL'+i+'.ico');
  6311. linksBody.removeChild(linksBody.lastChild);
  6312. if(linksBody.childNodes.length==0) { addLinkField(); }
  6313. }
  6314.  
  6315. function resetMainIco() {
  6316. document.getElementById('icoMenuIco').value=
  6317. URL_MZimg + 'mz_logo_small.png';
  6318. }
  6319.  
  6320.  
  6321. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6322.  
  6323. function insertTitle(next,txt) {
  6324. var div = document.createElement('div');
  6325. div.className = 'titre2';
  6326. appendText(div,txt);
  6327. insertBefore(next,div);
  6328. return div;
  6329. }
  6330.  
  6331. function insertMainTable(next) {
  6332. var table = document.createElement('table');
  6333. table.width = '98%';
  6334. table.border = 0;
  6335. table.align = 'center';
  6336. table.cellPadding = 2;
  6337. table.cellSpacing = 1;
  6338. table.className = 'mh_tdborder';
  6339. var tbody = document.createElement('tbody');
  6340. table.appendChild(tbody);
  6341. insertBefore(next,table);
  6342. return tbody;
  6343. }
  6344.  
  6345. function appendSubTable(node) {
  6346. var table = document.createElement('table');
  6347. table.width = '100%';
  6348. var tbody = document.createElement('tbody');
  6349. table.appendChild(tbody);
  6350. node.appendChild(table);
  6351. return tbody;
  6352. }
  6353.  
  6354. function insertOptionTable(insertPt) {
  6355. var mainBody = insertMainTable(insertPt);
  6356. /* Liens dans le Menu */
  6357. var tr = appendTr(mainBody,'mh_tdtitre');
  6358. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6359. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6360. appendText(td,'Icône du Menu: ');
  6361. var url = MY_getValue(numTroll+'.ICOMENU');
  6362. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6363. url = URL_MZimg + 'mz_logo_small.png';
  6364. }
  6365. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6366. appendButton(td,'Réinitialiser',resetMainIco);
  6367. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6368. var tbody = appendSubTable(td);
  6369. tbody.id = 'linksBody';
  6370. refreshLinks();
  6371. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6372. appendButton(td,'Ajouter',addLinkField);
  6373. appendButton(td,'Supprimer',removeLinkField);
  6374. /* Options de la Vue : vue externe, nb de CdM, etc */
  6375. tr = appendTr(mainBody,'mh_tdtitre');
  6376. appendTdText(tr,'Options de la Vue :',true);
  6377. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6378. tbody = appendSubTable(td);
  6379. tr = appendTr(tbody);
  6380. td = appendTdText(tr,'Vue externe : ');
  6381. var select = document.createElement('select');
  6382. select.id = 'vueext';
  6383. td.appendChild(select);
  6384. var listeVues2D = [
  6385. 'Bricol\' Vue',
  6386. 'Vue du CCM',
  6387. 'Vue Gloumfs 2D',
  6388. 'Vue Gloumfs 3D',
  6389. 'Grouky Vue!'
  6390. ];
  6391. for(var i=0 ; i<listeVues2D.length ; i++) {
  6392. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6393. }
  6394. if(MY_getValue('VUEEXT')) {
  6395. select.value = MY_getValue('VUEEXT');
  6396. }
  6397. td = appendTd(tr);
  6398. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6399. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6400. tr = appendTr(tbody);
  6401. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6402. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6403. td = appendTd(tr);
  6404. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6405. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6406. /* Interface Tactique */
  6407. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6408. appendText(td,'Interface Tactique : ',true);
  6409. select = document.createElement('select');
  6410. select.id = 'itSelect';
  6411. appendOption(select,'none','Aucune');
  6412. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6413. // seule interface supportée !
  6414. td.appendChild(select);
  6415. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6416. tbody = appendSubTable(td);
  6417. tbody.id = 'itBody';
  6418. select.onchange = onChangeIT;
  6419. var str = MY_getValue(numTroll+'.INFOSIT');
  6420. if(str) {
  6421. select.value = str.slice(0,str.indexOf('$'));
  6422. onChangeIT();
  6423. }
  6424. /* Options diverses */
  6425. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6426. appendText(td,'Options diverses :',true);
  6427. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6428. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6429. appendText(td,
  6430. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6431. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6432. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6433. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6434. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6435. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6436. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6437. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6438. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6439. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6440. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6441. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6442. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6443. /* Bouton SaveAll */
  6444. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6445. input = appendButton(td,'Sauvegarder',saveAll);
  6446. input.id = 'saveAll';
  6447. }
  6448.  
  6449. function insertCreditsTable(insertPt) {
  6450. var tbody = insertMainTable(insertPt);
  6451. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6452. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6453. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6454.  
  6455. var ul = document.createElement('ul');
  6456. td.appendChild(ul);
  6457. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6458. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6459. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6460. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6461. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6462. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6463. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6464. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6465. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6466. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6467. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6468. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6469. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6470. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6471. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6472. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6473. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6474. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6475. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6476. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6477. }
  6478.  
  6479.  
  6480. /* [functions] Obsolètes */
  6481. function deleteEnchantement()
  6482. {
  6483. try
  6484. {
  6485. var idEquipement = this.getAttribute('name');
  6486. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6487. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6488. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6489. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6490. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6491. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6492. var string = "";
  6493. for(var i=0;i<listeEquipement.length;i++)
  6494. {
  6495. if(listeEquipement[i]!=idEquipement)
  6496. if(string=="")
  6497. string = listeEquipement[i];
  6498. else
  6499. string += ";"+listeEquipement[i];
  6500. }
  6501. if(string=="")
  6502. {
  6503. MY_removeValue(numTroll+".enchantement.liste");
  6504. var table = this.parentNode.parentNode.parentNode.parentNode;
  6505. var parent = table.parentNode;
  6506. for(var i=0;i<parent.childNodes.length;i++)
  6507. {
  6508. if(parent.childNodes[i]==table)
  6509. {
  6510. parent.removeChild(parent.childNodes[i-1]);
  6511. parent.removeChild(parent.childNodes[i-1]);
  6512. parent.removeChild(parent.childNodes[i-1]);
  6513. break;
  6514. }
  6515. }
  6516. }
  6517. else
  6518. {
  6519. MY_getValue(numTroll+".enchantement.liste",string);
  6520. this.parentNode.parentNode.parentNode
  6521. .removeChild(this.parentNode.parentNode);
  6522. }
  6523. }
  6524. catch(e)
  6525. {
  6526. window.alert(e);
  6527. }
  6528. }
  6529. /* [functions] fin Obsolètes */
  6530.  
  6531. /*-[functions]---------------- Partie principale -----------------------------*/
  6532.  
  6533. function do_option() {
  6534. start_script(712);
  6535. var insertPoint = document.getElementById('footer1');
  6536. insertBefore(insertPoint,document.createElement('p'));
  6537. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  6538. ti.onclick = function (e) {
  6539. var evt = e || window.event;
  6540. if (!evt.shiftKey) return;
  6541. var txt = '';
  6542. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6543. var k = localStorage.key(i);
  6544. if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6545. txt += k + "\t" + localStorage.getItem(k) + "\n";
  6546. }
  6547. copyTextToClipboard(txt);
  6548. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  6549. }
  6550. ti.title = 'Version ' + GM_info.script.version;
  6551. insertOptionTable(insertPoint);
  6552. /* insertion enchantements ici
  6553. if(...)
  6554. insertEnchantementTable();
  6555. */
  6556. insertBefore(insertPoint,document.createElement('p'));
  6557. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6558. ti.onclick = function (e) {
  6559. var evt = e || window.event;
  6560. if (!evt.shiftKey) return;
  6561. var oldDev = MY_getValue('MZ_dev');
  6562. if (oldDev) {
  6563. MY_removeValue('MZ_dev');
  6564. } else {
  6565. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6566. MY_setValue('MZ_dev', 1);
  6567. }
  6568. document.location.href = document.location.href;
  6569. }
  6570. insertCreditsTable(insertPoint);
  6571. insertBefore(insertPoint,document.createElement('p'));
  6572.  
  6573. /* [zone] Obsolète ?? */
  6574. if(MY_getValue(numTroll+".enchantement.liste")
  6575. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6576. {
  6577. insertTitle(insertPoint, 'Les Enchantements en cours');
  6578. table = document.createElement('table');
  6579. table.setAttribute('width', '98%');
  6580. table.setAttribute('border', '0');
  6581. table.setAttribute('align', 'center');
  6582. table.setAttribute('cellpadding', '2');
  6583. table.setAttribute('cellspacing', '1');
  6584. table.setAttribute('class', 'mh_tdborder');
  6585.  
  6586. tbody = document.createElement('tbody');
  6587. table.appendChild(tbody);
  6588. tr = appendTr(tbody, 'mh_tdtitre');
  6589. appendTdText(tr, 'Equipement',1);
  6590. appendTdText(tr, 'Composants',1);
  6591. appendTdText(tr, 'Enchanteur',1);
  6592. appendTdText(tr, 'Action',1);
  6593. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6594. for(var i=0;i<listeEquipement.length;i++)
  6595. {
  6596. try
  6597. {
  6598. var idEquipement = listeEquipement[i];
  6599. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6600. +idEquipement+".objet");
  6601. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6602. +idEquipement+".enchanteur").split(";");
  6603. var ul = document.createElement('UL');
  6604. for(var j=0;j<3;j++)
  6605. {
  6606. var infoComposant = MY_getValue(numTroll+".enchantement."
  6607. +idEquipement+".composant."+j).split(";");
  6608. var texte = infoComposant[4].replace("Ril ","Œil ");
  6609. for(var k=5;k<infoComposant.length;k++)
  6610. {
  6611. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6612. }
  6613. li = appendLI(ul,texte);
  6614. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6615. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6616. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6617. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6618. string+= '<input type="hidden" name="q" value="min" />';
  6619. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6620. 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>';
  6621.  
  6622. string+= '</form>';
  6623. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6624. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6625. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6626. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6627. li.innerHTML += string;
  6628. }
  6629. tr = appendTr(tbody, 'mh_tdpage');
  6630. td = appendTdText(tr, nomEquipement);
  6631. td.setAttribute('valign', 'center');
  6632. td = document.createElement('td');
  6633. td.appendChild(ul);
  6634. tr.appendChild(td);
  6635. td.setAttribute('valign', 'center');
  6636. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6637. td.setAttribute('valign', 'center');
  6638. td = document.createElement('td');
  6639. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6640. input.setAttribute('name', idEquipement);
  6641. tr.appendChild(td);
  6642. td.setAttribute('valign', 'center');
  6643. }
  6644. catch(e)
  6645. {
  6646. }
  6647. }
  6648. insertBefore(insertPoint, table);
  6649. insertBefore(insertPoint, document.createElement('p'));
  6650. }
  6651. /* [zone] fin Obsolète ?? */
  6652.  
  6653.  
  6654. displayScriptTime();
  6655. }
  6656.  
  6657. /*******************************************************************************
  6658. * This file is part of Mountyzilla. *
  6659. * *
  6660. * Mountyzilla is free software; you can redistribute it and/or modify *
  6661. * it under the terms of the GNU General Public License as published by *
  6662. * the Free Software Foundation; either version 2 of the License, or *
  6663. * (at your option) any later version. *
  6664. * *
  6665. * Mountyzilla is distributed in the hope that it will be useful, *
  6666. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6667. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6668. * GNU General Public License for more details. *
  6669. * *
  6670. * You should have received a copy of the GNU General Public License *
  6671. * along with Mountyzilla; if not, write to the Free Software *
  6672. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6673. *******************************************************************************/
  6674.  
  6675. // x~x equip
  6676.  
  6677. /**
  6678. * 2014-02-08 - v2.0a (from scratch)
  6679. * 2014-02-18 - v2.0a0
  6680. * - ajout calcul Carats / UM des minerais + totaux
  6681. * 2014-03-06 - v2.0a1
  6682. * - retour Infos EM des Champis
  6683. * TODO
  6684. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6685. */
  6686.  
  6687. function traiteChampis() {
  6688. try{
  6689. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6690. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6691. }
  6692. catch(e){return;}
  6693. if(trlist.length<=0) return;
  6694. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6695. var node = trlist.snapshotItem(i).childNodes[7];
  6696. var str = node.textContent.trim();
  6697. var type = str.slice(0,str.lastIndexOf(' '));
  6698. var mundi = mundiChampi[type];
  6699. if(!mundi) continue;
  6700. var urlImg = URL_MZimg
  6701. +'Competences/ecritureMagique.png';
  6702. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6703. appendText(node,' ');
  6704. node.appendChild(img);
  6705. }
  6706. }
  6707.  
  6708. function traiteCompos() {
  6709. try {
  6710. var tr = document.getElementById('mh_objet_hidden_Composant');
  6711. var tbody = document.evaluate("./td/table/tbody",
  6712. tr, null, 9, null).singleNodeValue;
  6713. }
  6714. catch(e) {return;}
  6715. insererInfosEM(tbody);
  6716. }
  6717.  
  6718. function traiteMinerai() {
  6719. try{
  6720. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6721. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6722. }
  6723. catch(e){return;}
  6724. if(trlist.length<=0) return;
  6725. var totaux = {};
  6726. var str;
  6727. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6728. var node = trlist.snapshotItem(i);
  6729. var nature = node.childNodes[7].textContent,
  6730. caracs = node.childNodes[9].textContent;
  6731. var taille = Number(caracs.match(/\d+/)[0]);
  6732. var coef = 1;
  6733. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6734. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6735. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6736. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6737. if(nature.indexOf('Mithril')!=-1) {
  6738. coef = 0.2*coef;
  6739. str = ' | UM: ';
  6740. }
  6741. else {
  6742. coef = 0.75*coef+1.25;
  6743. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6744. str = ' | Carats: ';
  6745. }
  6746. var carats = Math.round(taille*coef)
  6747. appendText(node.childNodes[9], str+carats );
  6748. if(!totaux[nature]) {
  6749. totaux[nature] = [taille,carats];
  6750. }
  6751. else {
  6752. totaux[nature][0] += taille;
  6753. totaux[nature][1] += carats;
  6754. }
  6755. }
  6756. str = 'Total : ';
  6757. for(var nature in totaux) {
  6758. if(str.length>8) str += ', ';
  6759. if(nature.indexOf('Mithril')!=-1) {
  6760. str += nature+totaux[nature][1]+' UM';
  6761. }
  6762. else {
  6763. str += nature+totaux[nature][0]+'U/'
  6764. +totaux[nature][1]+'c';
  6765. }
  6766. }
  6767. /*var node = document.getElementById('mh_plus_Minerai');
  6768. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6769. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6770. if(!titre) return;*/
  6771. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6772. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6773. td.colSpan = 7;
  6774. }
  6775.  
  6776. function do_equip() {
  6777. start_script();
  6778.  
  6779. traiteChampis();
  6780. traiteCompos();
  6781. traiteMinerai();
  6782.  
  6783. displayScriptTime();
  6784. }
  6785.  
  6786. /*******************************************************************************
  6787. * This file is part of Mountyzilla. *
  6788. * *
  6789. * Mountyzilla is free software; you can redistribute it and/or modify *
  6790. * it under the terms of the GNU General Public License as published by *
  6791. * the Free Software Foundation; either version 2 of the License, or *
  6792. * (at your option) any later version. *
  6793. * *
  6794. * Mountyzilla is distributed in the hope that it will be useful, *
  6795. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6796. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6797. * GNU General Public License for more details. *
  6798. * *
  6799. * You should have received a copy of the GNU General Public License *
  6800. * along with Mountyzilla; if not, write to the Free Software *
  6801. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6802. *******************************************************************************/
  6803.  
  6804. // x~x diplo
  6805.  
  6806. /*
  6807. TODO:
  6808. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6809. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6810. V Étape 3: Ajout de la diplo perso
  6811. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6812. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6813. Options Globales:
  6814. Actuelles:
  6815. numTroll.USECSS,
  6816. numTroll.NODIPLO
  6817. NOMYTH
  6818. Nouvelles:
  6819. TODO numTroll.USECSS
  6820. numTroll.diplo.off (remplace NODIPLO)
  6821. numTroll.diplo.guilde
  6822. numTroll.diplo.perso
  6823. Structure de diplo.guilde:
  6824. isOn: 'true' ou 'false'
  6825. isDetailOn: 'true' ou 'false'
  6826. guilde
  6827. > id
  6828. > couleur
  6829. AllAmis,AllEnnemis: couleur
  6830. Amis0,...,Ennemis5
  6831. > Troll: idTroll1;...;
  6832. > Guilde: idGuilde1;...;
  6833. > titre
  6834. > couleur
  6835. Structure de diplo.perso:
  6836. isOn: 'true' ou 'false'
  6837. mythiques: couleur
  6838. Troll,Guilde,Monstre:
  6839. > id
  6840. > couleur
  6841. > description
  6842. */
  6843.  
  6844. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6845.  
  6846. function couleurAleatoire() {
  6847. var alph = '0123456789ABCDEF'.split('');
  6848. var clr = '#';
  6849. for (var i=0; i<6; i++) {
  6850. clr+=alph[ Math.floor(16*Math.random()) ];
  6851. }
  6852. return clr;
  6853. }
  6854.  
  6855. function isCouleur(str) {
  6856. return /^#[0-9A-F]{6}$/i.test(str);
  6857. }
  6858.  
  6859. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6860.  
  6861. function appendChoixCouleur(node,id) {
  6862. var span = document.createElement('span');
  6863. span.id = 'span'+id;
  6864. if(isDetailOn) {
  6865. span.style.display = 'none';
  6866. }
  6867. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6868. if(diploGuilde[id]) {
  6869. couleur = diploGuilde[id];
  6870. }
  6871. appendText(span,' - Couleur HTML: ');
  6872. var input = appendTextbox(span,'text',id,7,7,couleur);
  6873. input.onkeyup = previewCouleur;
  6874. input.onchange = previewCouleur;
  6875. input.onkeyup();
  6876. node.appendChild(span);
  6877. }
  6878.  
  6879. function insertChoixCouleur(node,id) {
  6880. var span = document.createElement('span');
  6881. span.id = 'span'+id;
  6882. // La couleur détaillée passera à une valeur aléatoire
  6883. // si toggle vers isDetailOn
  6884. var couleur = couleurAleatoire();
  6885. if(!isDetailOn) {
  6886. span.style.display = 'none';
  6887. } else if(diploGuilde[id]) {
  6888. couleur = diploGuilde[id].couleur;
  6889. }
  6890. appendText(span,' - Couleur HTML: ');
  6891. var input = appendTextbox(span,'text',id,7,7,couleur);
  6892. input.onkeyup = previewCouleur;
  6893. input.onchange = previewCouleur;
  6894. input.onkeyup();
  6895. insertBefore(node,span);
  6896. }
  6897.  
  6898. function setChoixCouleurs() {
  6899. try {
  6900. var form = document.getElementsByName('ActionForm')[0];
  6901. var nodesAE = document.evaluate(
  6902. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6903. form, null, 7, null
  6904. );
  6905. var nodes = document.evaluate(
  6906. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6907. form, null, 7, null
  6908. );
  6909. } catch(e) {
  6910. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6911. return false;
  6912. };
  6913. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6914. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6915. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6916. for(var i=0 ; i<5 ; i++) {
  6917. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6918. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6919. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6920. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6921. }
  6922. return true;
  6923. }
  6924.  
  6925. function fetchDiploGuilde() {
  6926. try {
  6927. for(var AE in {Amis:0,Ennemis:0}) {
  6928. for(var i=0 ; i<5 ; i++) {
  6929. /* Récup des A/E de rang i */
  6930. var td = document.getElementById('td'+AE+i);
  6931. var ligne = td.getElementsByTagName('table')[0].rows;
  6932. var titre = trim(td.firstChild.textContent);
  6933. // On laisse la gestion des couleurs à setChoixCouleurs:
  6934. var couleur = document.getElementById(AE+i).value;
  6935. diploGuilde[AE+i] = {
  6936. Troll:'',
  6937. Guilde:'',
  6938. titre: titre,
  6939. couleur: couleur
  6940. };
  6941. for(var j=1 ; j<ligne.length ; j++) {
  6942. var str = trim(ligne[j].cells[0].textContent);
  6943. var idx = str.lastIndexOf('(');
  6944. var num = str.slice(idx+1,-1);
  6945. var type = trim(ligne[j].cells[1].textContent);
  6946. diploGuilde[AE+i][type] += num+';';
  6947. }
  6948. }
  6949. }
  6950. } catch(e) {
  6951. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6952. return false;
  6953. }
  6954. return true;
  6955. }
  6956.  
  6957.  
  6958. /*-[functions]--------------------- Handlers ---------------------------------*/
  6959.  
  6960. function toggleDetails() {
  6961. isDetailOn = !isDetailOn;
  6962. for(var AE in {Amis:0,Ennemis:0}) {
  6963. document.getElementById('spanAll'+AE).style.display =
  6964. (isDetailOn?'none':'');
  6965. for(var i=0 ; i<5 ; i++) {
  6966. document.getElementById('span'+AE+i).style.display =
  6967. (isDetailOn?'':'none');
  6968. }
  6969. }
  6970. }
  6971.  
  6972. function toggleMythiques() {
  6973. isMythiquesOn = !isMythiquesOn;
  6974. document.getElementById('spanMythiques').style.display =
  6975. (isMythiquesOn?'':'none');
  6976. }
  6977.  
  6978. function previewCouleur() {
  6979. var value = this.value;
  6980. if(isCouleur(value)) {
  6981. this.style.backgroundColor = value;
  6982. this.title = '';
  6983. } else {
  6984. this.style.backgroundColor = '';
  6985. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  6986. }
  6987. }
  6988.  
  6989. function appendMenuType(node,duType) {
  6990. var select = document.createElement('select');
  6991. select.className = 'SelectboxV2';
  6992. var type = ['Guilde','Troll','Monstre'];
  6993. for(var i=0 ; i<3 ; i++) {
  6994. appendOption(select,type[i],type[i]);
  6995. if(type[i]==duType) { select.selectedIndex=i; }
  6996. }
  6997. node.appendChild(select);
  6998. }
  6999.  
  7000. function ajouteChamp(type,num,couleur,descr) {
  7001. var champs = document.getElementById('diploPerso');
  7002. var nb = champs.rows.length;
  7003. var tr = champs.insertRow(-1);
  7004. var td = appendTd(tr);
  7005. appendMenuType(td,type);
  7006. td = appendTd(tr);
  7007. appendText(td,' n°');
  7008. appendTextbox(td,'text','num'+nb,6,15,num);
  7009. td = appendTd(tr);
  7010. appendText(td,' couleur HTML:');
  7011. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7012. input.onkeyup = previewCouleur;
  7013. input.onchange = previewCouleur;
  7014. input.onkeyup();
  7015. td = appendTd(tr);
  7016. appendText(td,' Description:');
  7017. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7018. td = appendTd(tr);
  7019. var span = document.createElement('span');
  7020. appendText(span,'[ok!]',true);
  7021. span.style.visibility = 'hidden';
  7022. td.appendChild(span);
  7023. td = appendTd(tr);
  7024. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7025. }
  7026.  
  7027. function retireCeChamp() {
  7028. var thisTr = this.parentNode.parentNode;
  7029. thisTr.parentNode.removeChild(thisTr);
  7030. var champs = document.getElementById('diploPerso');
  7031. if(champs.rows.length==0) { ajouteChamp(); }
  7032. }
  7033.  
  7034. function valideChamp(champ) {
  7035. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7036. isCouleur(champ.cells[2].childNodes[1].value);
  7037. if(isValide) {
  7038. champ.cells[4].firstChild.style.visibility = 'visible';
  7039. } else {
  7040. champ.cells[4].firstChild.style.visibility = 'hidden';
  7041. }
  7042. return isValide;
  7043. }
  7044.  
  7045. function sauvegarderTout() {
  7046. /* Diplo de guilde */
  7047. diploGuilde.isOn =
  7048. document.getElementById('isGuildeOn').checked?'true':'false';
  7049. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7050. var numGuilde = Number(document.getElementById('numGuilde').value);
  7051. var couleur = document.getElementById('couleurGuilde').value;
  7052. if(numGuilde) {
  7053. diploGuilde.guilde = {
  7054. id: numGuilde,
  7055. couleur: couleur
  7056. };
  7057. } else {
  7058. delete diploGuilde.guilde;
  7059. }
  7060. for(var AE in {Amis:0,Ennemis:0}) {
  7061. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7062. for(var i=0 ; i<5 ; i++) {
  7063. if(isDetailOn) {
  7064. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7065. } else {
  7066. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7067. }
  7068. }
  7069. }
  7070. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7071. /* Diplo personnelle (ex-fonction saveChamps) */
  7072. var champs = document.getElementById('diploPerso');
  7073. diploPerso = {
  7074. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7075. Guilde: {},
  7076. Troll: {},
  7077. Monstre: {}
  7078. };
  7079. if(isMythiquesOn &&
  7080. isCouleur(document.getElementById('couleurMythiques').value)) {
  7081. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7082. }
  7083. for(var i=0 ; i<champs.rows.length ; i++) {
  7084. if(valideChamp(champs.rows[i])) {
  7085. var type = champs.rows[i].cells[0].firstChild.value;
  7086. var num = champs.rows[i].cells[1].childNodes[1].value;
  7087. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7088. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7089. diploPerso[type][num] = {
  7090. couleur: couleur
  7091. };
  7092. if(descr) {
  7093. diploPerso[type][num].titre = descr;
  7094. }
  7095. }
  7096. }
  7097. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7098.  
  7099. avertissement('Données sauvegardées');
  7100. }
  7101.  
  7102.  
  7103. /*-[functions]------------- Modifications de la page -------------------------*/
  7104.  
  7105. function creeTablePrincipale() {
  7106. var insertPt = document.getElementById('insertPt');
  7107. /* Titre + bouton de Sauvegarde */
  7108. var tr = insertTr(insertPt,'mh_tdtitre');
  7109. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7110. appendButton(td,'Sauvegarder',sauvegarderTout);
  7111. /* Options fixes */
  7112. tr = insertTr(insertPt,'mh_tdpage');
  7113. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7114. appendBr(td);
  7115. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7116. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7117. appendBr(td);
  7118. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7119. appendText(td,'Utiliser des couleurs détaillées (10)');
  7120. /* Diplo personnelle */
  7121. tr = insertTr(insertPt,'mh_tdpage');
  7122. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7123. appendBr(td);
  7124. // Diplo Mythiques
  7125. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7126. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7127. var span = document.createElement('span');
  7128. span.id = 'spanMythiques';
  7129. if(!isMythiquesOn) {
  7130. span.style.display = 'none';
  7131. }
  7132. var couleur = '#FFAAAA';
  7133. if(diploPerso.mythiques) {
  7134. couleur = diploPerso.mythiques;
  7135. }
  7136. appendText(span,' - couleur HTML:');
  7137. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7138. input.onkeyup = previewCouleur;
  7139. input.onchange = previewCouleur;
  7140. input.onkeyup();
  7141. td.appendChild(span);
  7142. appendBr(td);
  7143. // Diplo éditable
  7144. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7145. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7146. appendBr(td);
  7147. var table = document.createElement('table');
  7148. table.id = 'diploPerso'
  7149. td.appendChild(table);
  7150. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7151. for(var num in diploPerso[type]) {
  7152. ajouteChamp(
  7153. type,
  7154. num,
  7155. diploPerso[type][num].couleur,
  7156. diploPerso[type][num].titre
  7157. );
  7158. }
  7159. }
  7160. if(table.rows.length==0) {
  7161. ajouteChamp();
  7162. }
  7163. appendButton(td,'Ajouter',ajouteChamp)
  7164. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7165. appendText(td,' ');
  7166. appendButton(td,
  7167. 'Exemples de couleur',
  7168. function() {
  7169. var fenetre = window.open(
  7170. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7171. 'Divers',
  7172. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7173. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7174. );
  7175. fenetre.focus();
  7176. }
  7177. );
  7178. /* Couleur de Guilde */
  7179. tr = insertTr(insertPt,'mh_tdtitre');
  7180. td = appendTdText(tr,'GUILDE',true);
  7181. appendText(td,' - n°');
  7182. appendTextbox(td,'text','numGuilde',5,10,
  7183. diploGuilde.guilde && diploGuilde.guilde.id ?
  7184. diploGuilde.guilde.id : ''
  7185. );
  7186. appendText(td,' - Couleur HTML: ');
  7187. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7188. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7189. diploGuilde.guilde.couleur : '#BBBBFF'
  7190. );
  7191. input.onkeyup = previewCouleur;
  7192. input.onchange = previewCouleur;
  7193. input.onkeyup();
  7194. }
  7195.  
  7196.  
  7197. /*-[functions]----------------------- Main -----------------------------------*/
  7198.  
  7199. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  7200. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  7201. var isDetailOn = diploGuilde.isDetailOn=='true';
  7202. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  7203. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  7204. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7205.  
  7206. function do_diplo() {
  7207. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7208. creeTablePrincipale();
  7209. }
  7210. }
  7211.  
  7212. /*******************************************************************************
  7213. * This file is part of Mountyzilla. *
  7214. * *
  7215. * Mountyzilla is free software; you can redistribute it and/or modify *
  7216. * it under the terms of the GNU General Public License as published by *
  7217. * the Free Software Foundation; either version 2 of the License, or *
  7218. * (at your option) any later version. *
  7219. * *
  7220. * Mountyzilla is distributed in the hope that it will be useful, *
  7221. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7222. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7223. * GNU General Public License for more details. *
  7224. * *
  7225. * You should have received a copy of the GNU General Public License *
  7226. * along with Mountyzilla; if not, write to the Free Software *
  7227. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7228. *******************************************************************************/
  7229.  
  7230. // x~x cdmcomp
  7231.  
  7232. var cdm = '';
  7233.  
  7234. function getNonNegInts(str) {
  7235. var nbrs = str.match(/\d+/g);
  7236. for(var i=0 ; i<nbrs.length ; i++) {
  7237. nbrs[i] = Number(nbrs[i]);
  7238. }
  7239. return nbrs;
  7240. }
  7241.  
  7242. function traiteCdMcomp() {
  7243. try {
  7244. var msgEffet = document.getElementById('msgEffet');
  7245. } catch(e) {
  7246. window.console.log('[traiteCdMcomp] msgEffet non trouvé');
  7247. return;
  7248. }
  7249.  
  7250. // Teste si ce message du bot est un message de CdM
  7251. if(!document.evaluate(
  7252. "./p/b/text()[contains(.,'fait partie')]",
  7253. msgEffet, null, 9, null
  7254. ).singleNodeValue) {
  7255. return;
  7256. }
  7257. // Début de récupération de la CdM
  7258. cdm = document.evaluate(
  7259. "./p/b/text()[contains(.,'fait partie')]",
  7260. msgEffet, null, 9, null
  7261. ).singleNodeValue.nodeValue+'\n';
  7262. var tbody = document.evaluate(
  7263. "descendant::table/tbody",
  7264. msgEffet, null, 9, null
  7265. ).singleNodeValue;
  7266. var nomStat = document.evaluate(
  7267. "./tr/td[1]/b/text()",
  7268. tbody, null, 7, null
  7269. );
  7270. var valStat = document.evaluate(
  7271. "./tr/td[2]/descendant::text()",
  7272. tbody, null, 7, null
  7273. );
  7274. var i=0;
  7275. while(i<nomStat.snapshotLength) {
  7276. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7277. cdm += 'Armure : ';
  7278. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7279. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7280. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7281. armp = [0,armp[0]];
  7282. }
  7283. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7284. armm = [0,armm[0]];
  7285. }
  7286. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7287. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7288. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7289. } else {
  7290. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7291. }
  7292. cdm += ')\n';
  7293. i++;
  7294. } else {
  7295. cdm += nomStat.snapshotItem(i).nodeValue+
  7296. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7297. }
  7298. i++;
  7299. }
  7300. // Envoi auto ou insertion bouton envoi (suivant option)
  7301. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7302. sendInfoCDM();
  7303. var p = document.createElement('p');
  7304. p.style.color = 'green';
  7305. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7306. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7307. } else {
  7308. insertButtonCdm('as_Action', sendInfoCDM);
  7309. }
  7310.  
  7311. // Insertion de l'estimation des PV restants
  7312. var pv = valStat.snapshotItem(1).nodeValue;
  7313. if(pv.indexOf("entre")==-1) {
  7314. return;
  7315. }
  7316. pv = getPVsRestants(pv,valStat.snapshotItem(2).nodeValue);
  7317. if(pv) {
  7318. var tr = insertTr(nomStat.snapshotItem(3).parentNode.parentNode.parentNode);
  7319. appendTdText(tr, pv[0], true);
  7320. appendTdText(tr, pv[1], true);
  7321. }
  7322. }
  7323.  
  7324. function sendInfoCDM() {
  7325. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7326. var buttonCDM = this;
  7327. var texte = '';
  7328. FF_XMLHttpRequest({
  7329. method: 'GET',
  7330. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  7331. headers : {
  7332. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7333. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7334. },
  7335. onload: function(responseDetails) {
  7336. texte = responseDetails.responseText;
  7337. buttonCDM.value = texte;
  7338. buttonCDM.disabled = true;
  7339. }
  7340. });
  7341. }
  7342.  
  7343. function do_cdmcomp() {
  7344. start_script(31);
  7345. traiteCdMcomp();
  7346. displayScriptTime();
  7347. }
  7348.  
  7349. /*********************************************************************************
  7350. * This file is part of Mountyzilla. *
  7351. * *
  7352. * Mountyzilla is free software; you can redistribute it and/or modify *
  7353. * it under the terms of the GNU General Public License as published by *
  7354. * the Free Software Foundation; either version 2 of the License, or *
  7355. * (at your option) any later version. *
  7356. * *
  7357. * Mountyzilla is distributed in the hope that it will be useful, *
  7358. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7359. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7360. * GNU General Public License for more details. *
  7361. * *
  7362. * You should have received a copy of the GNU General Public License *
  7363. * along with Mountyzilla; if not, write to the Free Software *
  7364. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7365. *********************************************************************************/
  7366.  
  7367. // x~x cmdbot
  7368.  
  7369. /* v0.2 by Dab - 2013-08-20
  7370. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7371. */
  7372.  
  7373. var buttonCDM;
  7374.  
  7375. /*******************************************************************************************
  7376. CDM :
  7377. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7378.  
  7379. Il ne vous est pas possible d'améliorer cette compétence.
  7380.  
  7381. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7382. Niveau : Inimaginable (entre 49 et 51)
  7383. Points de Vie : Surtrollesque (entre 450 et 470)
  7384. Blessure (Approximatif) : 0 %
  7385. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7386. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7387. Dés de Dégat : Très Fort (entre 18 et 20)
  7388. Dés de Régénération : Excellent (égal à 13)
  7389. Armure Physique : Moyen (entre 10 et 12)
  7390. Armure Magique : Faible (inférieur à 6)
  7391. Vue : Moyen (entre 9 et 11)
  7392. Maitrise Magique : Inimaginable (supérieur à 6000)
  7393. Résistance Magique : Inimaginable (supérieur à 6000)
  7394. Nombre d'attaques : 1
  7395. Vitesse de Déplacement : Normale
  7396. Voir le Caché : Oui
  7397. Attaque à distance : Non
  7398. Attaque magique : Oui
  7399. Vole : Non
  7400. Sang froid : Inexistant
  7401. DLA : Milieu
  7402. Durée Tour : Remarquable (entre 9 et 11)
  7403. Chargement : Vide
  7404. Bonus Malus : Aucun
  7405.  
  7406. Vous avez également gagné 1 PX pour la réussite.
  7407. *******************************************************************************************
  7408. BOT :
  7409. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7410.  
  7411. Le Monstre ciblé fait partie des : Mort-Vivant
  7412.  
  7413. Niveau : Incroyable (entre 36 et 38)
  7414. *******************************************************************************************/
  7415.  
  7416. function getNNInt(str) {
  7417. var nbrs = str.match(/\d+/g);
  7418. for (var i=0 ; i<nbrs.length ; i++)
  7419. nbrs[i] = parseInt(nbrs[i]);
  7420. return nbrs;
  7421. }
  7422.  
  7423. function sendCDM() {
  7424. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7425. document, null, 9, null).singleNodeValue;
  7426. cdm = td.innerHTML;
  7427. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7428. "$3$4 ($1 - N°$2)<br>");
  7429. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7430. 'Blessure : XX % (approximativement)');
  7431. // Supprime la décomposition P/M de l'Armure
  7432. var bgn = cdm.indexOf('Armure Physique');
  7433. if (bgn!=-1) {
  7434. var end = cdm.indexOf('Vue')-2;
  7435. var lines = cdm.substring(bgn,end).split('<br>');
  7436. var armp = getNNInt(lines[0]);
  7437. var armm = getNNInt(lines[1]);
  7438. if (lines[0].indexOf('(inf')!=-1)
  7439. armp = [0,armp[0]];
  7440. if (lines[1].indexOf('(inf')!=-1)
  7441. armm = [0,armm[0]];
  7442. var insrt = 'Armure : ';
  7443. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7444. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7445. else
  7446. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7447. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7448. }
  7449. cdm = cdm.replace(/<br>/g,'\n');
  7450. FF_XMLHttpRequest({
  7451. method: 'GET',
  7452. url: URL_pageDispatcher+'?cdm='+escape(cdm),
  7453. headers : {
  7454. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7455. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7456. },
  7457. onload: function(responseDetails) {
  7458. buttonCDM.value=responseDetails.responseText;
  7459. buttonCDM.disabled = true;
  7460. }
  7461. });
  7462. }
  7463.  
  7464. function traiteCdMmsg() {
  7465. // Teste si ce message du bot est un message de CdM
  7466. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7467. document, null, 9, null).singleNodeValue;
  7468. if (!td) return false;
  7469. cdm = td.innerHTML;
  7470. // Insertion de l'estimation des PV restants
  7471. var des = cdm.indexOf('Dés');
  7472. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7473. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7474. if(pv)
  7475. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7476.  
  7477. // Insertion bouton envoi + espace
  7478. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7479. }
  7480.  
  7481. /*function traitePouvoir() {
  7482. // Teste si ce message du bot est un message de CdM
  7483. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7484. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7485. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7486. if (!td)
  7487. return false;
  7488. var infos = td.innerHTML;
  7489. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7490. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7491. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7492. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7493. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7494. var effetPouvoir="";
  7495. var full=false;
  7496. if(infos.indexOf("REDUIT")!=-1) {
  7497. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7498. }
  7499. else {
  7500. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7501. full=true;
  7502. }
  7503. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7504. // On insère le bouton et un espace
  7505. //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));
  7506. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7507. if(!MY_getValue('AUTOSENDPOUV'))
  7508. {
  7509. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7510. button.setAttribute("onClick", "window.open('" + url
  7511. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7512. + "this.value='Merci de votre participation'; this.disabled = true;");
  7513. }
  7514. else
  7515. {
  7516. FF_XMLHttpRequest({
  7517. method: 'GET',
  7518. url: url,
  7519. headers : {
  7520. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7521. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7522. }});
  7523. }
  7524. }*/
  7525.  
  7526. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7527. traiteCdMmsg();
  7528. }
  7529. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7530.  
  7531. /*******************************************************************************
  7532. * This file is part of Mountyzilla. *
  7533. * *
  7534. * Mountyzilla is free software; you can redistribute it and/or modify *
  7535. * it under the terms of the GNU General Public License as published by *
  7536. * the Free Software Foundation; either version 2 of the License, or *
  7537. * (at your option) any later version. *
  7538. * *
  7539. * Mountyzilla is distributed in the hope that it will be useful, *
  7540. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7541. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7542. * GNU General Public License for more details. *
  7543. * *
  7544. * You should have received a copy of the GNU General Public License *
  7545. * along with Mountyzilla; if not, write to the Free Software *
  7546. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7547. *******************************************************************************/
  7548.  
  7549. // x~x menu
  7550. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7551.  
  7552. var menuRac, mainIco;
  7553.  
  7554. // met à jour les carac sauvegardées (position, DLA, etc.)
  7555. function updateData() {
  7556. var inputs = document.getElementsByTagName('input');
  7557. var divs = document.getElementsByTagName('div');
  7558. numTroll = inputs[0].value;
  7559. MY_setValue('NUM_TROLL', numTroll);
  7560. MY_setValue('NIV_TROLL',inputs[1].value);
  7561. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7562. MY_setValue(numTroll+'.caracs.rm',0);
  7563. // assure l'init des 4 var de libs
  7564. }
  7565. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7566. var DLA = new Date(
  7567. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  7568. );
  7569. if(MY_getValue(numTroll+'.DLA.encours')) {
  7570. var DLAstockee = new Date(
  7571. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  7572. );
  7573. if(DLA>DLAstockee) {
  7574. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  7575. // Pose un pb en cas de décalage de DLA
  7576. }
  7577. }
  7578. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  7579. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  7580. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  7581. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  7582. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  7583. }
  7584.  
  7585. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7586. function initRaccourcis() {
  7587. var anotherURL = MY_getValue('URL1');
  7588. if(!anotherURL) { return; }
  7589. /* Création de l'icône faisant apparaître le menu */
  7590. mainIco = document.createElement('img');
  7591. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  7592. if(!urlIco) {
  7593. urlIco =
  7594. URL_MZimg + 'mz_logo_small.png';
  7595. }
  7596. mainIco.src = urlIco;
  7597. mainIco.alt = 'MZ';
  7598. mainIco.style = 'position:fixed; top:0px; left:0px';
  7599. mainIco.onmouseover = afficheMenu;
  7600. document.body.appendChild(mainIco);
  7601. /* Création du menu des Raccourcis */
  7602. menuRac = document.createElement('div');
  7603. menuRac.className = 'mh_textbox';
  7604. menuRac.style =
  7605. 'position:fixed; top:10px; left:10px;'+
  7606. 'max-width:190px;'+
  7607. 'border-radius: 4px; padding: 4px;'+
  7608. 'z-index: 500;'+
  7609. 'visibility: hidden;';
  7610. document.body.appendChild(menuRac);
  7611. document.addEventListener('mousemove',cacheMenu,false);
  7612. var i=1;
  7613. while(anotherURL) {
  7614. var a = document.createElement('a');
  7615. var url = MY_getValue('URL'+i);
  7616. var nom = MY_getValue('URL'+i+'.nom');
  7617. var ico = MY_getValue('URL'+i+'.ico');
  7618. a.href = url;
  7619. a.target = '_blank';
  7620. if(ico) {
  7621. var txt = nom ? nom : '';
  7622. var img = createImage(ico,txt);
  7623. a.appendChild(img);
  7624. }
  7625. else {
  7626. appendText(a,'['+nom+']');
  7627. }
  7628. menuRac.appendChild(a);
  7629. appendBr(menuRac);
  7630. i++;
  7631. anotherURL = MY_getValue('URL'+i);
  7632. }
  7633. }
  7634.  
  7635. function afficheMenu() {
  7636. menuRac.style.visibility = 'visible';
  7637. }
  7638.  
  7639. function cacheMenu(e) {
  7640. if(menuRac.style.visibility=='hidden') { return; }
  7641. // Position souris
  7642. var ptX = e.clientX;
  7643. var ptY = e.clientY;
  7644. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7645. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7646. var menuRect = menuRac.getBoundingClientRect();
  7647. var icoRect = mainIco.getBoundingClientRect();
  7648. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7649. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7650. menuRac.style.visibility = 'hidden';
  7651. }
  7652. }
  7653.  
  7654. // ajout de l'icône, branchée sur un refresh
  7655. function initUpdateCoordGauche() {
  7656. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7657. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7658. var img = document.createElement('img');
  7659. img.src = URL_MZimg + 'recycl.png'
  7660. img.onclick = function(evt) {
  7661. document.location.href = document.location.href;
  7662. };
  7663. img.title = 'Mise à jour de la localisation';
  7664. img.style.cursor = 'pointer';
  7665. img.style.position = 'absolute';
  7666. img.style.bottom = 0;
  7667. img.style.left = 0;
  7668. div.appendChild(img);
  7669. }
  7670.  
  7671. function do_menu() {
  7672. // met à jour les carac sauvegardées (position, DLA, etc.)
  7673. updateData();
  7674. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7675. initRaccourcis();
  7676. // Ajout bouton de mise à jour coordonnées
  7677. initUpdateCoordGauche();
  7678. }
  7679.  
  7680. /*******************************************************************************
  7681. * This file is part of Mountyzilla. *
  7682. * *
  7683. * Mountyzilla is free software; you can redistribute it and/or modify *
  7684. * it under the terms of the GNU General Public License as published by *
  7685. * the Free Software Foundation; either version 2 of the License, or *
  7686. * (at your option) any later version. *
  7687. * *
  7688. * Mountyzilla is distributed in the hope that it will be useful, *
  7689. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7690. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7691. * GNU General Public License for more details. *
  7692. * *
  7693. * You should have received a copy of the GNU General Public License *
  7694. * along with Mountyzilla; if not, write to the Free Software *
  7695. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7696. *******************************************************************************/
  7697.  
  7698. // x~x vue
  7699.  
  7700. /* TODO
  7701. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7702. * prévoir fix ("delete infos")
  7703. */
  7704.  
  7705. /*--------------------------- Variables Globales -----------------------------*/
  7706.  
  7707. // Infos remplies par des scripts extérieurs
  7708. var listeCDM = [], listeLevels = [];
  7709.  
  7710. // Position actuelle
  7711. var currentPosition=[0,0,0];
  7712.  
  7713. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7714. var porteeVue=[0,0,0,0];
  7715.  
  7716. // Fenêtres déplaçables
  7717. var winCurr = null;
  7718. var offsetX, offsetY;
  7719.  
  7720. // Diplomatie
  7721. var Diplo = {
  7722. Guilde: {},
  7723. Troll: {},
  7724. Monstre: {}
  7725. // .mythiques: uniquement si option activée
  7726. };
  7727. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7728.  
  7729. // Infos tactiques
  7730. var popup;
  7731.  
  7732. // Gère l'affichage en cascade des popups de CdM
  7733. var nbCDM = 0;
  7734.  
  7735. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7736.  
  7737. // Utilisé pour supprimer les monstres "engagés"
  7738. var listeEngages = {};
  7739. var isEngagesComputed = false;
  7740. var cursorOnLink = false; // DEBUG: wtf ?
  7741.  
  7742. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7743. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7744.  
  7745. // Checkboxes de filtrage
  7746. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7747. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7748. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  7749. comboBoxNiveauMin, comboBoxNiveauMax;
  7750.  
  7751. /* Acquisition & Stockage des données de DB */
  7752. const typesAFetcher = {
  7753. 'monstres':1,
  7754. 'trolls':1,
  7755. 'tresors':1,
  7756. 'champignons':1,
  7757. 'lieux':1
  7758. }
  7759. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7760. tr_champignons = {}, tr_lieux = {};
  7761. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7762. nbChampignons = 0, nbLieux = 0;
  7763.  
  7764. function fetchData(type) {
  7765. try {
  7766. var node = document.getElementById('mh_vue_hidden_'+type);
  7767. // this = MZ.global = sandBox de travail de MZ
  7768. // On définit donc des variables MZ-globales
  7769. this['tr_'+type] = node.getElementsByTagName('tr');
  7770. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7771. } catch(e) {
  7772. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7773. }
  7774. }
  7775.  
  7776.  
  7777. /*---------------------------------- DEBUG -----------------------------------*/
  7778. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7779. var x_monstres = tr_monstres;
  7780. var x_trolls = tr_trolls;
  7781. var x_tresors = tr_tresors;
  7782. var x_champis = tr_champignons;
  7783. var x_lieux = tr_lieux;
  7784. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7785.  
  7786.  
  7787. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7788.  
  7789. function positionToString(arr) {
  7790. return arr.join(';');
  7791. }
  7792.  
  7793. function savePosition() {
  7794. // Stocke la position (à jour) de la vue pour les autres scripts
  7795. // DEBUG: Lesquels et pourquoi?
  7796. var pos = getPosition();
  7797. MY_setValue(numTroll+'.position.X',pos[0]);
  7798. MY_setValue(numTroll+'.position.Y',pos[1]);
  7799. MY_setValue(numTroll+'.position.N',pos[2]);
  7800. }
  7801.  
  7802.  
  7803. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7804. /* INFOS :
  7805. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7806. * sont identifiables via leur Name
  7807. * les tables-listings sont identifiables via l'ID du tr conteneur
  7808. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7809. */
  7810.  
  7811. /* [functions] Récup données Utilisateur */
  7812. function getPosition() {
  7813. // Pour rétrocompatibilité
  7814. return currentPosition;
  7815. }
  7816.  
  7817. function getPorteVue() {
  7818. // Pour rétrocompatibilité
  7819. return porteeVue;
  7820. }
  7821.  
  7822. function getVue() {
  7823. // Retourne [vueHpure, vueVpure]
  7824. var vues = getPorteVue();
  7825. return [ vues[0], vues[1] ];
  7826. }
  7827.  
  7828. // Roule 11/03/2016
  7829. /* [functions] Récup données monstres, trolls, etc. */
  7830. function getXxxDistance(xxx, i) {
  7831. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7832. }
  7833. function getXxxPosition(xxx, i) {
  7834. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7835. var l = tds.length;
  7836. return [
  7837. parseInt(tds[l-3].textContent),
  7838. parseInt(tds[l-2].textContent),
  7839. parseInt(tds[l-1].textContent)
  7840. ];
  7841. }
  7842.  
  7843.  
  7844. /* [functions] Récup données monstres */
  7845. function getMonstreDistance(i) {
  7846. return parseInt(tr_monstres[i].cells[0].textContent);
  7847. }
  7848.  
  7849. function getMonstreID(i) {
  7850. return tr_monstres[i].cells[2].firstChild.nodeValue;
  7851. }
  7852.  
  7853. function getMonstreIDByTR(tr) {
  7854. return tr.cells[2].firstChild.nodeValue;
  7855. }
  7856.  
  7857. function getMonstreLevelNode(i) {
  7858. return tr_monstres[i].cells[3];
  7859. }
  7860.  
  7861. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  7862. // function getMonstreLevel(i) {
  7863. // if(!isCDMsRetrieved) return -1;
  7864. // var donneesMonstre = listeCDM[getMonstreID(i)];
  7865. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  7866. // }
  7867.  
  7868. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  7869. if(!isCDMsRetrieved) return false;
  7870. var donneesMonstre = listeCDM[getMonstreID(i)];
  7871. if (!donneesMonstre) return false;
  7872. var nivTxt = donneesMonstre[0];
  7873. // calcul min/max du monstre
  7874. var monstreMin, monstreMax, iPos;
  7875. if (nivTxt.substring(0, 2) == '<=') {
  7876. monstreMin = 0;
  7877. monstreMax = parseInt(nivTxt.substring(2, 99));
  7878. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  7879. monstreMin = parseInt(nivTxt.substring(0, iPos));
  7880. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  7881. } else {
  7882. monstreMin = monstreMax = parseInt(nivTxt);
  7883. }
  7884. if (limitMin > 0 && monstreMax < limitMin) return true;
  7885. if (limitMax > 0 && monstreMin > limitMax) return true;
  7886. return false;
  7887. }
  7888.  
  7889. function getMonstreNomNode(i) {
  7890. try {
  7891. var td = document.evaluate(
  7892. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  7893. tr_monstres[i], null, 9, null
  7894. ).singleNodeValue;
  7895. return td;
  7896. } catch(e) {
  7897. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  7898. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  7899. }
  7900. }
  7901.  
  7902. function getMonstreNom(i) {
  7903. return getMonstreNomByTR(tr_monstres[i]);
  7904. }
  7905.  
  7906. function getMonstreNomByTR(tr) {
  7907. try {
  7908. var nom = document.evaluate(
  7909. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  7910. tr, null, 2, null
  7911. ).stringValue;
  7912. return nom;
  7913. } catch(e) {
  7914. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  7915. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  7916. }
  7917. }
  7918.  
  7919. function getMonstrePosition(i) {
  7920. var tds = tr_monstres[i].childNodes;
  7921. var l = tds.length;
  7922. return [
  7923. parseInt(tds[l-3].textContent),
  7924. parseInt(tds[l-2].textContent),
  7925. parseInt(tds[l-1].textContent)
  7926. ];
  7927. }
  7928.  
  7929. function appendMonstres(txt) {
  7930. for(var i=1; i<=nbMonstres ; i++)
  7931. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  7932. return txt;
  7933. }
  7934.  
  7935. function getMonstres() {
  7936. var vue = getVue();
  7937. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  7938. }
  7939.  
  7940. function bddMonstres(start,stop) {
  7941. if(!start) { var start = 1; }
  7942. if(!stop) { var stop = nbMonstres; }
  7943. stop = Math.min(nbMonstres,stop);
  7944. var txt='';
  7945. for(var i=start ; i<=stop ; i++) {
  7946. txt += getMonstreID(i)+';'+
  7947. getMonstreNom(i)+';'+
  7948. positionToString(getMonstrePosition(i))+'\n';
  7949. }
  7950. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  7951. }
  7952.  
  7953. /* [functions] Récup données Trolls */
  7954. function getTrollDistance(i) {
  7955. return parseInt(tr_trolls[i].cells[0].textContent);
  7956. }
  7957.  
  7958. function getTrollID(i) {
  7959. return parseInt(tr_trolls[i].cells[2].textContent);
  7960. }
  7961.  
  7962. function getTrollNomNode(i) {
  7963. var isEnvoiOn =
  7964. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  7965. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  7966. }
  7967.  
  7968. function getTrollNivNode(i) {
  7969. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  7970. return tr_trolls[i].cells[4];
  7971. }
  7972.  
  7973. function getTrollGuilde(i) {
  7974. return trim(tr_trolls[i].cells[6].textContent);
  7975. }
  7976.  
  7977. function getTrollGuildeID(i) {
  7978. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  7979. var href;
  7980. try {
  7981. 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"
  7982. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  7983. } catch(e) { // debug pb remonté par Marsak
  7984. window.console.error(traceStack(e, 'getTrollGuildeID')
  7985. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  7986. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  7987. return -1;
  7988. }
  7989. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  7990. }
  7991. return -1;
  7992. }
  7993.  
  7994. function getTrollPosition(i) {
  7995. var tds = tr_trolls[i].childNodes;
  7996. var l = tds.length;
  7997. return [
  7998. parseInt(tds[l-3].textContent),
  7999. parseInt(tds[l-2].textContent),
  8000. parseInt(tds[l-1].textContent)
  8001. ];
  8002. }
  8003.  
  8004. function bddTrolls() {
  8005. var txt='#DEBUT TROLLS\n'+
  8006. numTroll+';'+positionToString(getPosition())+'\n';
  8007. for(var i=1 ; i<=nbTrolls ; i++) {
  8008. txt += getTrollID(i)+';'+
  8009. positionToString(getTrollPosition(i))+'\n';
  8010. }
  8011. return txt+'#FIN TROLLS';
  8012. }
  8013.  
  8014. /* [functions] Récup données Trésors */
  8015. function getTresorDistance(i) {
  8016. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8017. }
  8018.  
  8019. function getTresorID(i) {
  8020. return trim(tr_tresors[i].cells[2].textContent);
  8021. }
  8022.  
  8023. function getTresorNom(i) {
  8024. // Utilisation de textContent pour régler le "bug de Pollux"
  8025. return trim(tr_tresors[i].cells[3].textContent);
  8026. }
  8027.  
  8028. function getTresorPosition(i) {
  8029. var tds = tr_tresors[i].childNodes;
  8030. var l = tds.length;
  8031. return [
  8032. parseInt(tds[l-3].textContent),
  8033. parseInt(tds[l-2].textContent),
  8034. parseInt(tds[l-1].textContent),
  8035. ];
  8036. }
  8037.  
  8038. function bddTresors(dmin,start,stop) {
  8039. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8040. if(!dmin) { var dmin = 0; }
  8041. if(!start) { var start = 1; }
  8042. if(!stop) { var stop = nbTresors; }
  8043. stop = Math.min(nbTresors,stop);
  8044. var txt='';
  8045. for(var i=start ; i<=stop ; i++) {
  8046. if(getTresorDistance(i)>=dmin) {
  8047. txt += getTresorID(i)+';'+
  8048. getTresorNom(i)+';'+
  8049. positionToString(getTresorPosition(i))+'\n';
  8050. }
  8051. }
  8052. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8053. }
  8054.  
  8055. /* [functions] Récup données Champignons */
  8056. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8057. function getChampignonNom(i) {
  8058. return trim(tr_champignons[i].cells[2].textContent);
  8059. }
  8060.  
  8061. function getChampignonPosition(i) {
  8062. var tds = tr_champignons[i].childNodes;
  8063. var l = tds.length;
  8064. return [
  8065. parseInt(tds[l-3].textContent),
  8066. parseInt(tds[l-2].textContent),
  8067. parseInt(tds[l-1].textContent)
  8068. ];
  8069. }
  8070.  
  8071. function bddChampignons() {
  8072. var txt='';
  8073. for(var i=1 ; i<=nbChampignons ; i++) {
  8074. txt += ';'+ // Les champis n'ont pas de Référence
  8075. getChampignonNom(i)+';'+
  8076. positionToString(getChampignonPosition(i))+'\n';
  8077. }
  8078. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8079. }
  8080.  
  8081. /* [functions] Récup données Lieux */
  8082. function getLieuDistance(i) {
  8083. return parseInt(tr_lieux[i].cells[0].textContent);
  8084. }
  8085.  
  8086. function getLieuID(i) {
  8087. return parseInt(tr_lieux[i].cells[2].textContent);
  8088. }
  8089.  
  8090. function getLieuNom(i) {
  8091. // Conversion ASCII pour éviter les bugs des Vues externes
  8092. return trim(tr_lieux[i].cells[3].textContent);
  8093. }
  8094.  
  8095. function getLieuPosition(i) {
  8096. var tds = tr_lieux[i].childNodes;
  8097. var l = tds.length;
  8098. return [
  8099. parseInt(tds[l-3].textContent),
  8100. parseInt(tds[l-2].textContent),
  8101. parseInt(tds[l-1].textContent)
  8102. ];
  8103. }
  8104.  
  8105. function appendLieux(txt) {
  8106. for(var i = 1; i < nbLieux+1; i++) {
  8107. var tds = x_lieux[i].childNodes;
  8108. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8109. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8110. }
  8111. return txt;
  8112. }
  8113.  
  8114. function getLieux() {
  8115. var vue = getVue();
  8116. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8117. }
  8118.  
  8119. function bddLieux(start,stop) {
  8120. if(!start) { var start = 1; }
  8121. if(!stop) { var stop = nbLieux; }
  8122. stop = Math.min(nbLieux,stop);
  8123. var txt='';
  8124. for(var i=start ; i<=stop ; i++) {
  8125. txt += getLieuID(i)+';'+
  8126. epure(getLieuNom(i))+';'+
  8127. positionToString(getLieuPosition(i))+'\n';
  8128. }
  8129. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8130. }
  8131.  
  8132.  
  8133. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8134.  
  8135. function saveCheckBox(chkbo, pref) {
  8136. // Enregistre et retourne l'état d'une CheckBox
  8137. var etat = chkbo.checked;
  8138. MY_setValue(pref, etat ? 'true' : 'false' );
  8139. return etat;
  8140. }
  8141.  
  8142. function recallCheckBox(chkbox, pref) {
  8143. // Restitue l'état d'une CheckBox
  8144. chkbox.checked = (MY_getValue(pref)=='true');
  8145. }
  8146.  
  8147. function saveComboBox(cbb, pref) {
  8148. // Enregistre et retourne l'état d'une ComboBox
  8149. var etat = cbb.selectedIndex;
  8150. MY_setValue(pref, etat);
  8151. return etat;
  8152. }
  8153.  
  8154. function recallComboBox(cbb, pref) {
  8155. // Restitue l'état d'une ComboBox
  8156. var nb = MY_getValue(pref);
  8157. if(nb) cbb.value = nb;
  8158. return nb;
  8159. }
  8160.  
  8161. function synchroniseFiltres() {
  8162. // Récupération de toutes les options de la vue
  8163. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8164. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8165. if(numBool) {
  8166. debutFiltrage('Monstres');
  8167. }
  8168. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8169. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8170. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8171. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8172. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8173. recallCheckBox(checkBoxIntangibles,'NOINT');
  8174. recallCheckBox(checkBoxGG,'NOGG');
  8175. recallCheckBox(checkBoxCompos,'NOCOMP');
  8176. recallCheckBox(checkBoxBidouilles,'NOBID');
  8177. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8178. recallCheckBox(checkBoxTrou,'NOTROU');
  8179. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8180. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8181. if(MY_getValue('NOINFOEM')!='true')
  8182. recallCheckBox(checkBoxEM,'NOEM');
  8183. }
  8184.  
  8185.  
  8186. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  8187.  
  8188. function getVueScript() {
  8189. try {
  8190. var txt = bddTrolls()+
  8191. bddMonstres()+
  8192. bddChampignons()+
  8193. bddTresors()+
  8194. bddLieux()+
  8195. '#DEBUT ORIGINE\n'+
  8196. getPorteVue()[2]+';'+positionToString(getPosition())+
  8197. '\n#FIN ORIGINE\n';
  8198. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  8199. return txt;
  8200. } catch(e) {
  8201. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  8202. window.console.error(traceStack(e, 'getVueScript'))
  8203. }
  8204. }
  8205.  
  8206. /* [functions] Menu Vue 2D */
  8207. var vue2Ddata = {
  8208. 'Bricol\' Vue': {
  8209. url: URL_bricol_mountyhall + 'vue_form.php',
  8210. paramid: 'vue',
  8211. func: getVueScript,
  8212. extra_params: {
  8213. 'mode': 'vue_SP_Vue2',
  8214. 'screen_width': window.screen.width
  8215. }
  8216. },
  8217. 'Vue du CCM': {
  8218. url: URL_vue_CCM,
  8219. paramid: 'vue',
  8220. func: getVueScript,
  8221. extra_params: {
  8222. 'id': numTroll+';'+positionToString(getPosition())
  8223. }
  8224. },
  8225. 'Vue Gloumfs 2D': {
  8226. url: URL_vue_Gloumfs2D,
  8227. paramid: 'vue_mountyzilla',
  8228. func: getVueScript,
  8229. extra_params: {}
  8230. },
  8231. 'Vue Gloumfs 3D': {
  8232. url: URL_vue_Gloumfs3D,
  8233. paramid: 'vue_mountyzilla',
  8234. func: getVueScript,
  8235. extra_params: {}
  8236. },
  8237. 'Grouky Vue!': {
  8238. url: URL_vue_Grouky,
  8239. paramid: 'vue',
  8240. func: getVueScript,
  8241. extra_params: {
  8242. 'type_vue': 'V5b1'
  8243. }
  8244. },
  8245. /*'DEBUG': {
  8246. url: 'http://weblocal/testeur.php',
  8247. paramid: 'vue',
  8248. func: getVueScript,
  8249. extra_params: {}
  8250. }*/
  8251. };
  8252.  
  8253. function refresh2DViewButton() {
  8254. // = EventListener menu+bouton vue 2D
  8255. var vueext = document.getElementById('selectVue2D').value;
  8256. MY_setValue('VUEEXT',vueext);
  8257. var form = document.getElementById('viewForm');
  8258. form.innerHTML = '';
  8259. form.method = 'post';
  8260. form.action = vue2Ddata[vueext].url;
  8261. form.target = '_blank';
  8262. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8263. for(var key in vue2Ddata[vueext].extra_params) {
  8264. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8265. }
  8266. appendSubmit(form, 'Voir',
  8267. function() {
  8268. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8269. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8270. vue2Ddata[vueext].func();
  8271. }
  8272. );
  8273. }
  8274.  
  8275. function set2DViewSystem() {
  8276. // Initialise le système de vue 2D
  8277. // Recherche du point d'insertion
  8278. try {
  8279. var center = document.evaluate(
  8280. "//h2[@id='titre2']/following-sibling::center",
  8281. document, null, 9, null
  8282. ).singleNodeValue;
  8283. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8284. if (!center) center = document.evaluate(
  8285. "//h2[@id='titre2']/following-sibling::div",
  8286. document, null, 9, null
  8287. ).singleNodeValue;
  8288. } catch(e) {
  8289. avertissement("Erreur d'initialisation du système de vue 2D");
  8290. window.console.error(traceStack(e, 'set2DViewSystem'));
  8291. return;
  8292. }
  8293. // Récupération de la dernière vue utilisée
  8294. var vueext = MY_getValue('VUEEXT');
  8295. if(!vueext || !vue2Ddata[vueext]) {
  8296. // sinon, la vue Bricol'Trolls est employée par défaut
  8297. vueext = 'Bricol\' Vue';
  8298. }
  8299. try {
  8300. // Création du sélecteur de vue externe
  8301. selectVue2D = document.createElement('select');
  8302. selectVue2D.id = 'selectVue2D';
  8303. selectVue2D.className = 'SelectboxV2';
  8304. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  8305. for(var view in vue2Ddata) {
  8306. appendOption(selectVue2D, view, view);
  8307. }
  8308. selectVue2D.value = vueext;
  8309. selectVue2D.onchange = refresh2DViewButton;
  8310. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8311. var form = document.createElement('form');
  8312. form.id = 'viewForm';
  8313. // Insertion du système de vue
  8314. var table = document.createElement('table');
  8315. var tr = appendTr(table);
  8316. var td = appendTd(tr);
  8317. td.appendChild(selectVue2D);
  8318. td = appendTd(tr);
  8319. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8320. td.appendChild(form);
  8321. center.insertBefore(table,center.firstChild);
  8322. insertBr(center.childNodes[1]);
  8323. // Appelle le handler pour initialiser le bouton de submit
  8324. refresh2DViewButton();
  8325. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8326. } catch(e) {
  8327. avertissement("Erreur de traitement du système de vue 2D");
  8328. window.console.error(traceStack(e, 'set2DViewSystem'));
  8329. }
  8330. }
  8331.  
  8332. /* [functions] Tableau d'Infos */
  8333. function initialiseInfos() {
  8334. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8335. var
  8336. infoTab = document.getElementsByName('LimitViewForm')[0].
  8337. getElementsByTagName('table')[0],
  8338. tbody = infoTab.tBodies[0],
  8339. thead = infoTab.createTHead(),
  8340. tr = appendTr(thead,'mh_tdtitre'),
  8341. td = appendTdText(tr,'INFORMATIONS',true),
  8342. span = document.createElement('span');
  8343. // Récupération de la position du joueur
  8344. try {
  8345. var strPos = document.evaluate(
  8346. ".//li/b/text()[contains(.,'X = ')]",
  8347. infoTab, null, 9, null
  8348. ).singleNodeValue.nodeValue;
  8349. // ***INIT GLOBALE*** currentPosition
  8350. currentPosition = getNumbers(strPos);
  8351. debugMZ("retrievePosition(): "+currentPosition);
  8352. } catch(e) {
  8353. // Si on ne trouve pas le "X ="
  8354. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8355. }
  8356. // Récupération des portées (max et limitée) de la vue
  8357. try {
  8358. var
  8359. nodes = document.evaluate(
  8360. ".//li/b/text()[contains(.,'horizontalement') "+
  8361. "or contains(.,'verticalement')]",
  8362. infoTab, null, 7, null
  8363. ),
  8364. array = [];
  8365. for(var i=0 ; i<4 ; i++) {
  8366. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8367. }
  8368. // ***INIT GLOBALE*** porteeVue
  8369. porteeVue = array;
  8370. } catch(e) {
  8371. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8372. }
  8373.  
  8374. infoTab.id = 'infoTab'; // Pour scripts externes
  8375. tbody.id = 'corpsInfoTab';
  8376. tbody.rows[0].cells[0].colSpan = 2;
  8377. td.colSpan = 3;
  8378. td.onmouseover = function() {
  8379. this.style.cursor = 'pointer';
  8380. this.className = 'mh_tdpage';
  8381. };
  8382. td.onmouseout = function() {
  8383. this.className = 'mh_tdtitre';
  8384. };
  8385. td.onclick = function() {
  8386. toggleTableauInfos(false);
  8387. };
  8388. span.id = 'msgInfoTab';
  8389. span.style.display = 'none';
  8390. appendText(
  8391. span,
  8392. ' => Position : X = '+currentPosition[0]+
  8393. ', Y = '+currentPosition[1]+
  8394. ', N = '+currentPosition[2]+
  8395. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8396. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8397. true
  8398. );
  8399. td.appendChild(span);
  8400. tr = appendTr(tbody,'mh_tdpage');
  8401. td = appendTdText(tr,'EFFACER : ',true);
  8402. td.align = 'center';
  8403. td.className = 'mh_tdtitre';
  8404. td.width = 100;
  8405. td = appendTdCenter(tr,2);
  8406. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8407. checkBoxGG = appendCheckBoxSpan(
  8408. td,'delgg',filtreTresors," Les GG'"
  8409. ).firstChild;
  8410. checkBoxCompos = appendCheckBoxSpan(
  8411. td,'delcomp',filtreTresors,' Les Compos'
  8412. ).firstChild;
  8413. checkBoxBidouilles = appendCheckBoxSpan(
  8414. td,'delbid',filtreTresors,' Les Bidouilles'
  8415. ).firstChild;
  8416. checkBoxIntangibles = appendCheckBoxSpan(
  8417. td,'delint',filtreTrolls,' Les Intangibles'
  8418. ).firstChild;
  8419. checkBoxGowapsA = appendCheckBoxSpan(
  8420. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  8421. ).firstChild;
  8422. checkBoxGowapsS = appendCheckBoxSpan(
  8423. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  8424. ).firstChild;
  8425. checkBoxEngages = appendCheckBoxSpan(
  8426. td,'delengage',filtreMonstres,' Les Engagés'
  8427. ).firstChild;
  8428. checkBoxLevels = appendCheckBoxSpan(
  8429. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8430. ).firstChild;
  8431. checkBoxDiplo = appendCheckBoxSpan(
  8432. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8433. ).firstChild;
  8434. checkBoxTrou = appendCheckBoxSpan(
  8435. td,'deltrou',filtreLieux,' Les Trous'
  8436. ).firstChild;
  8437. checkBoxMythiques = appendCheckBoxSpan(
  8438. td,'delmyth',filtreMonstres,' Les Mythiques'
  8439. ).firstChild;
  8440. if(MY_getValue('NOINFOEM')!='true') {
  8441. checkBoxEM = appendCheckBoxSpan(
  8442. td,'delem',filtreMonstres,' Les Composants EM'
  8443. ).firstChild;
  8444. }
  8445. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8446. td,'deltres',filtreTresors,' Les Trésors non libres'
  8447. ).firstChild;
  8448. checkBoxTactique = appendCheckBoxSpan(
  8449. td,'deltactique',updateTactique,' Les Infos tactiques'
  8450. ).firstChild;
  8451. if(MY_getValue('INFOPLIE')) {
  8452. toggleTableauInfos(true);
  8453. }
  8454. }
  8455.  
  8456. function toggleTableauInfos(firstRun) {
  8457. var
  8458. msg = document.getElementById('msgInfoTab'),
  8459. corps = document.getElementById('corpsInfoTab'),
  8460. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8461. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8462. if(!firstRun) {
  8463. infoplie = !infoplie;
  8464. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8465. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8466. }
  8467. if(infoplie) {
  8468. msg.style.display = '';
  8469. corps.style.display = 'none';
  8470. } else {
  8471. msg.style.display = 'none';
  8472. corps.style.display = '';
  8473. }
  8474. }
  8475.  
  8476. /* [functions] Filtres */
  8477. function prepareFiltrage(ref,width) {
  8478. // = Initialise le filtre 'ref'
  8479. try {
  8480. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8481. } catch(e) {
  8482. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8483. return false;
  8484. }
  8485. if(width) { tdTitre.width = width; }
  8486. // Ajout du tr de Filtrage (masqué)
  8487. var tbody = tdTitre.parentNode.parentNode;
  8488. var tr = appendTr(tbody,'mh_tdpage');
  8489. tr.style.display = 'none';
  8490. tr.id = 'trFiltre'+ref;
  8491. var td = appendTd(tr);
  8492. td.colSpan = 5;
  8493. // Ajout du bouton de gestion de Filtrage
  8494. var tdBtn = insertTd(tdTitre.nextSibling);
  8495. tdBtn.id = 'tdInsert'+ref;
  8496. var btn = appendButton(tdBtn,'Filtrer');
  8497. btn.id = 'btnFiltre'+ref;
  8498. btn.onclick = function() {
  8499. debutFiltrage(ref)
  8500. };
  8501. return td;
  8502. }
  8503.  
  8504. function debutFiltrage(ref) {
  8505. // = Handler de début de filtrage (filtre 'ref')
  8506. document.getElementById('trFiltre'+ref).style.display = '';
  8507. var btn = document.getElementById('btnFiltre'+ref);
  8508. btn.value = 'Annuler Filtre';
  8509. btn.onclick = function() {
  8510. finFiltrage(ref);
  8511. };
  8512. }
  8513.  
  8514. function finFiltrage(ref) {
  8515. // = Handler de fin de filtrage (filtre 'ref')
  8516. /* On réassigne le bouton 'Filtrer' */
  8517. document.getElementById('trFiltre'+ref).style.display = 'none';
  8518. var btn = document.getElementById('btnFiltre'+ref);
  8519. btn.value = 'Filtrer';
  8520. btn.onclick = function() {
  8521. debutFiltrage(ref);
  8522. };
  8523. /* Réinitialisation filtres */
  8524. document.getElementById('str'+ref).value = '';
  8525. switch(ref) {
  8526. case 'Monstres':
  8527. document.getElementById('nivMinMonstres').value = 0;
  8528. document.getElementById('nivMaxMonstres').value = 0;
  8529. break;
  8530. case 'Trolls':
  8531. document.getElementById('strGuildes').value = '';
  8532. }
  8533. /* Nettoyage (=lance le filtre) */
  8534. // Ici this = MZ.global = sandBox de travail de MZ
  8535. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  8536. //this['filtre'+ref]();
  8537. switch (ref) {
  8538. case 'Monstres':
  8539. filtreMonstres();
  8540. break;
  8541. case 'Trolls':
  8542. filtreTrolls();
  8543. break;
  8544. case 'Tresors':
  8545. filtreTresors();
  8546. break;
  8547. case 'Lieux':
  8548. filtreLieux();
  8549. break;
  8550. default:
  8551. window.console.log('cas incongru dans finFiltrage : ' + ref);
  8552. break;
  8553. }
  8554. }
  8555.  
  8556. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  8557. var bouton = appendButton(td,nomBouton,onClick);
  8558. appendText(td,'\u00a0');
  8559. var textbox = appendTextbox(td,'text',id,15,30);
  8560. textbox.onkeypress = function(event) {
  8561. try {
  8562. if(event.keyCode==13) {
  8563. event.preventDefault();
  8564. bouton.click();
  8565. }
  8566. }
  8567. catch(e){
  8568. window.alert(e)
  8569. }
  8570. };
  8571. }
  8572.  
  8573. function ajoutFiltreMenu(tr,id,onChange) {
  8574. var select = document.createElement('select');
  8575. select.id = id;
  8576. select.onchange = onChange;
  8577. appendOption(select,0,'Aucun');
  8578. for(var i=1 ; i<=60 ; i++) {
  8579. appendOption(select,i,i);
  8580. }
  8581. tr.appendChild(select);
  8582. return select;
  8583. }
  8584.  
  8585. function ajoutDesFiltres() {
  8586. /* Monstres */
  8587. var td = prepareFiltrage('Monstres',120);
  8588. if(td) {
  8589. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  8590. appendText(td,'\u00a0\u00a0\u00a0');
  8591. appendText(td,'Niveau Min: ');
  8592. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  8593. appendText(td,'\u00a0');
  8594. appendText(td,'Niveau Max: ');
  8595. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  8596. }
  8597. /* Trõlls */
  8598. td = prepareFiltrage('Trolls',50);
  8599. if(td) {
  8600. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  8601. appendText(td,'\u00a0\u00a0\u00a0');
  8602. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  8603. }
  8604. /* Trésors */
  8605. td = prepareFiltrage('Tresors',55);
  8606. if(td) {
  8607. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  8608. }
  8609. /* Lieux */
  8610. td = prepareFiltrage('Lieux',40);
  8611. if(td) {
  8612. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  8613. }
  8614. }
  8615.  
  8616. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  8617.  
  8618. /* [functions] Affichage de la colonne des niveaux */
  8619. function insertLevelColumn() {
  8620. // Déclenché si bascule vers affichage des niveaux des mobs
  8621. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8622. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  8623. td.width = 25;
  8624. for(var i=1 ; i<=nbMonstres ; i++) {
  8625. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8626. td = insertTdText(getMonstreLevelNode(i), '-');
  8627. td.onclick = function() {
  8628. basculeCDM(
  8629. getMonstreNomByTR(this.parentNode),
  8630. getMonstreIDByTR(this.parentNode)
  8631. );
  8632. };
  8633. td.onmouseover = function() {
  8634. this.style.cursor = 'pointer';
  8635. this.className = 'mh_tdtitre';
  8636. };
  8637. td.onmouseout = function() {
  8638. if(this.parentNode.diploActive=='oui') {
  8639. this.className = '';
  8640. } else {
  8641. this.className = 'mh_tdpage';
  8642. }
  8643. };
  8644. td.style = 'font-weight:bold;text-align:center;';
  8645. if(isCDMsRetrieved) {
  8646. // Rappel des niveaux si mémorisés
  8647. td.innerHTML = listeLevels[i];
  8648. }
  8649. }
  8650. }
  8651.  
  8652. function toggleLevelColumn() {
  8653. // = Handler checkBox noLevel
  8654. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8655. insertLevelColumn();
  8656. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8657. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8658. for(var i=0 ; i<=nbMonstres ; i++) {
  8659. if(isCDMsRetrieved) {
  8660. // Mémorisation des niveaux pour rappel éventuel
  8661. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8662. }
  8663. // Suppression du td Niveau
  8664. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8665. }
  8666. }
  8667. }
  8668.  
  8669. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8670. function basculeCDM(nom,id) {
  8671. // = Bascule l'affichage des popups CdM
  8672. if(listeCDM[id]) {
  8673. if(!document.getElementById('popupCDM'+id)) {
  8674. afficherCDM(nom, id);
  8675. } else {
  8676. cacherPopupCDM('popupCDM'+id);
  8677. }
  8678. }
  8679. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8680. }
  8681.  
  8682. function cacherPopupCDM(titre) {
  8683. var popup = document.getElementById(titre);
  8684. popup.parentNode.removeChild(popup);
  8685. }
  8686.  
  8687. /* DEBUG: Section à mettre à jour */
  8688. var selectionFunction;
  8689.  
  8690. function startDrag(evt) {
  8691. winCurr = this.parentNode;
  8692. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8693. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8694. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8695. selectionFunction = document.body.style.MozUserSelect;
  8696. document.body.style.MozUserSelect = 'none';
  8697. winCurr.style.MozUserSelect = 'none';
  8698. return false;
  8699. }
  8700.  
  8701. function stopDrag(evt) {
  8702. winCurr.style.MozUserSelect = selectionFunction;
  8703. document.body.style.MozUserSelect = selectionFunction;
  8704. winCurr = null;
  8705. }
  8706.  
  8707. function drag(evt) {
  8708. if(winCurr==null) { return; }
  8709. evt = evt || window.event;
  8710. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8711. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8712. return false;
  8713. }
  8714. /* FIN DEBUG */
  8715. document.onmousemove = drag;
  8716.  
  8717. function afficherCDM(nom,id) {
  8718. // Crée la table de CdM du mob n° id
  8719. var donneesMonstre = listeCDM[id];
  8720. /* Début création table */
  8721. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8722. table.id = 'popupCDM'+id;
  8723. table.style =
  8724. 'position:fixed;'+
  8725. 'z-index:1;'+
  8726. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8727. 'left:'+(window.innerWidth-365)+'px;'+
  8728. 'width:300px;'+
  8729. 'height:200px;';
  8730. /* Ajout du titre avec gestion Drag & Drop */
  8731. var tr = table.firstChild;
  8732. tr.style.cursor = 'move';
  8733. tr.onmousedown = startDrag;
  8734. tr.onmouseup = stopDrag;
  8735. /* Ajout du bouton "Fermer" */
  8736. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8737. tr.onmouseover = function() {
  8738. this.style.cursor = 'pointer';
  8739. this.className = 'mh_tdpage';
  8740. };
  8741. tr.onmouseout = function() {
  8742. this.className = 'mh_tdtitre';
  8743. };
  8744. tr.idcdm = id;
  8745. tr.onclick = function() {
  8746. cacherPopupCDM('popupCDM'+this.idcdm);
  8747. this.className = 'mh_tdtitre';
  8748. };
  8749. td = appendTdText(tr,'Fermer',true);
  8750. td.colSpan = 2;
  8751. td.style = 'text-align:center;';
  8752. nbCDM++;
  8753. /* Fin création table & Affichage */
  8754. document.body.appendChild(table);
  8755. }
  8756.  
  8757. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8758. function initPopupVue() {
  8759. popup = document.createElement('div');
  8760. popup.id = 'popup';
  8761. popup.className = 'mh_textbox';
  8762. popup.style =
  8763. 'position: absolute;'+
  8764. 'border: 1px solid #000000;'+
  8765. 'visibility: hidden;'+
  8766. 'display: inline;'+
  8767. 'z-index: 3;'+
  8768. 'max-width: 400px;';
  8769. document.body.appendChild(popup);
  8770. }
  8771.  
  8772. /* [functions] Récupération / Computation des Infos Tactiques */
  8773. // TODO à revoir
  8774. function retireMarquage(nom) {
  8775. var i = nom.indexOf(']');
  8776. switch(i) {
  8777. case -1:
  8778. case nom.length-1:
  8779. return nom;
  8780. default:
  8781. return nom.slice(0,i+1);
  8782. }
  8783. }
  8784.  
  8785. function showPopupError(sHTML) {
  8786. var divpopup = document.createElement('div');
  8787. divpopup.id = 'divpopup';
  8788. divpopup.style =
  8789. 'position: fixed;'+
  8790. 'border: 3px solid #000000;'+
  8791. 'top: 300px;left: 10px;'+
  8792. 'background-color: red;'+
  8793. 'color: white;'+
  8794. 'font-size: xx-large;'+
  8795. 'z-index: 200;';
  8796. divpopup.innerHTML = sHTML;
  8797. var divcroix = document.createElement('div');
  8798. divcroix.style =
  8799. 'position: absolute;'+
  8800. 'top: 0;right: 0;'+
  8801. 'color: inherit;'+
  8802. 'font-size: inherit;'+
  8803. 'cursor: pointer;'+
  8804. 'z-index: 201;';
  8805. divcroix.innerHTML = "X";
  8806. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8807. document.body.appendChild(divpopup);
  8808. divpopup.appendChild(divcroix);
  8809. }
  8810.  
  8811. function retrieveCDMs() {
  8812. // Récupère les CdM disponibles dans la BDD
  8813. // Lancé uniquement sur toggleLevelColumn
  8814. if(checkBoxLevels.checked) { return; }
  8815. var str = '';
  8816. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8817. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8818. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8819. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  8820. for(var i=1 ; i<=cdmMax ; i++) {
  8821. var nomMonstre = retireMarquage(getMonstreNom(i));
  8822. if(nomMonstre.indexOf(']') != -1) {
  8823. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  8824. }
  8825. // *** WARNING : PROXY RATIBUS ***
  8826. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  8827. str += 'nom[]='+escape(nomMonstre)+'$'+(
  8828. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  8829. )+'&';
  8830. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  8831. FF_XMLHttpRequest({
  8832. method: 'POST',
  8833. url: URL_MZinfoMonstre,
  8834. headers : {
  8835. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  8836. 'Accept': 'application/atom+xml,application/xml,text/xml',
  8837. 'Content-type':'application/x-www-form-urlencoded'
  8838. },
  8839. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  8840. onload: function(responseDetails) {
  8841. try {
  8842. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  8843. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  8844. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  8845. '" target="raistlin">Mountyzilla - https<br />'+
  8846. 'Tu dois accepter le certificat de Raistlin<br />'+
  8847. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  8848. ' « Confirmer l\'exception de sécurité »</a>');
  8849. return;
  8850. }
  8851. var texte = responseDetails.responseText;
  8852. var lines = texte.split('\n');
  8853. if(lines.length==0) { return; }
  8854. var begin2, end2, index;
  8855. for(var j=0 ; j<lines.length ; j++) {
  8856. var infos = lines[j].split(';');
  8857. if(infos.length<4) { continue; }
  8858. var idMonstre=infos[0];
  8859. var isCDM = infos[1];
  8860. index = parseInt(infos[2]);
  8861. var level = infos[3];
  8862. infos = infos.slice(3);
  8863. if(begin2==null) { begin2 = index; }
  8864. end2 = index;
  8865. listeCDM[idMonstre] = infos;
  8866. if(isCDM==1) {
  8867. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  8868. } else {
  8869. getMonstreLevelNode(index).innerHTML = level;
  8870. }
  8871. }
  8872. computeMission(begin2,end2);
  8873. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  8874. } catch(e) {
  8875. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  8876. }
  8877. }
  8878. });
  8879. str = '';
  8880. begin = i+1;
  8881. }
  8882. }
  8883. isCDMsRetrieved=true;
  8884. }
  8885.  
  8886. function computeMission(begin,end) {
  8887. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  8888. computeVLC(begin,end);
  8889. if(!begin) begin=1;
  8890. if(!end) end=nbMonstres;
  8891. var str = MY_getValue(numTroll+'.MISSIONS');
  8892. if(!str) { return; }
  8893. var urlImg = URL_MZimg+'mission.png';
  8894. var obMissions = JSON.parse(str);
  8895. for(var i=end ; i>=begin ; i--) {
  8896. var mess = '';
  8897. for(var num in obMissions) {
  8898. var mobMission = false;
  8899. switch(obMissions[num].type) {
  8900. case 'Race':
  8901. var race = epure(obMissions[num].race.toLowerCase());
  8902. var nom = epure(getMonstreNom(i).toLowerCase());
  8903. if(nom.indexOf(race)!=-1) {
  8904. mobMission = true;
  8905. }
  8906. break;
  8907. case 'Niveau':
  8908. var donneesMonstre = listeCDM[getMonstreID(i)];
  8909. if(donneesMonstre) {
  8910. var nivMob = Number(donneesMonstre[0]);
  8911. var nivMimi = Number(obMissions[num].niveau),
  8912. mod = obMissions[num].mod;
  8913. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  8914. || (isNaN(mod) && nivMob>=nivMimi)) {
  8915. mobMission = true;
  8916. }
  8917. }
  8918. break;
  8919. case 'Famille':
  8920. var donneesMonstre = listeCDM[getMonstreID(i)];
  8921. if(donneesMonstre) {
  8922. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  8923. var familleMob = epure(donneesMonstre[1].toLowerCase());
  8924. if(familleMob.indexOf(familleMimi)!=-1) {
  8925. mobMission = true;
  8926. }
  8927. }
  8928. break;
  8929. case 'Pouvoir':
  8930. var donneesMonstre = listeCDM[getMonstreID(i)];
  8931. if(donneesMonstre) {
  8932. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  8933. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  8934. if(pvrMob.indexOf(pvrMimi)!=-1) {
  8935. mobMission = true;
  8936. }
  8937. }
  8938. }
  8939. if(mobMission) {
  8940. mess += mess ? '\n\n' : '';
  8941. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  8942. }
  8943. }
  8944. if(mess) {
  8945. var td = getMonstreNomNode(i);
  8946. appendText(td,' ');
  8947. td.appendChild(createImage(urlImg,mess));
  8948. }
  8949. }
  8950. }
  8951.  
  8952. function computeVLC(begin,end) {
  8953. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  8954. computeTactique(begin,end);
  8955. if(!begin) begin=1;
  8956. if(!end) end=nbMonstres;
  8957. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  8958. if(!cache)
  8959. return false;
  8960. var urlImg = URL_MZimg + "oeil.png";
  8961. for(var i = end; i >= begin;i--)
  8962. {
  8963. var id = getMonstreID(i);
  8964. var donneesMonstre = listeCDM[id];
  8965. if(donneesMonstre && donneesMonstre.length>12)
  8966. {
  8967. if(donneesMonstre[12]==1)
  8968. {
  8969. var td = getMonstreNomNode(i);
  8970. td.appendChild(document.createTextNode(" "));
  8971. td.appendChild(createImage(urlImg, "Voit le caché"));
  8972. }
  8973. }
  8974. }
  8975. }
  8976.  
  8977. function computeTactique(begin, end) {
  8978. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  8979. try {
  8980. if(!begin) begin = 1;
  8981. if(!end) end = nbMonstres;
  8982. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  8983. if(noTactique || !isProfilActif()) return;
  8984. for(var j=end ; j>=begin ; j--) {
  8985. var id = getMonstreID(j);
  8986. var nom = getMonstreNom(j);
  8987. var donneesMonstre = listeCDM[id];
  8988. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  8989. var td = getMonstreNomNode(j);
  8990. appendText(td,' ');
  8991. td.appendChild(
  8992. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  8993. );
  8994. }
  8995. }
  8996. }
  8997. catch(e) {
  8998. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  8999. }
  9000. filtreMonstres();
  9001. }
  9002.  
  9003. function updateTactique() {
  9004. // = Handler checkBox noTactique
  9005. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9006. if(!isCDMsRetrieved) return;
  9007. if(noTactique) {
  9008. for(var i=nbMonstres ; i>0 ; i--) {
  9009. var tr = getMonstreNomNode(i);
  9010. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9011. tr, null, 9, null).singleNodeValue;
  9012. if(img) {
  9013. img.parentNode.removeChild(img.previousSibling);
  9014. img.parentNode.removeChild(img);
  9015. }
  9016. }
  9017. }
  9018. else
  9019. computeTactique();
  9020. }
  9021.  
  9022. function filtreMonstres() {
  9023. // = Handler universel pour les fonctions liées aux monstres
  9024. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9025. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9026. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9027. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9028. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9029. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9030. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9031. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9032. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9033. // old/new : détermine s'il faut ou non nettoyer les tr
  9034. var oldNOEM = true, noEM = true;
  9035. if(MY_getValue('NOINFOEM')!='true') {
  9036. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9037. }
  9038. // Filtrage par nom
  9039. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9040. // Génère la liste des mobs engagés (si filtrés)
  9041. if(noEngages && !isEngagesComputed) {
  9042. for(var i=nbTrolls ; i>0 ; i--) {
  9043. var pos = getTrollPosition(i);
  9044. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9045. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9046. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9047. }
  9048. isEngagesComputed = true;
  9049. }
  9050. /*** FILTRAGE ***/
  9051. /* À computer :
  9052. * - EM (nom suffit)
  9053. * - Enchant (nom suffit)
  9054. * - Mission (nécessite CdM)
  9055. * - mob VlC (nécessite CdM)
  9056. * Sans computation :
  9057. * - Gowap ? engagé ?
  9058. */
  9059. for(var i=nbMonstres ; i>0 ; i--) {
  9060. var pos = getMonstrePosition(i);
  9061. var nom = getMonstreNom(i).toLowerCase();
  9062. if(noEM!=oldNOEM) {
  9063. if(noEM) {
  9064. // Si noEM passe de false à true, on nettoie les td "Nom"
  9065. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9066. var tr = getMonstreNomNode(i);
  9067. while(tr.childNodes.length>1) {
  9068. tr.removeChild(tr.childNodes[1]);
  9069. }
  9070. } else {
  9071. var tr = getMonstreNomNode(i);
  9072. var TypeMonstre=getEM(nom);
  9073. if(TypeMonstre!='') {
  9074. var infosCompo=compoMobEM(TypeMonstre);
  9075. if(infosCompo.length>0) {
  9076. tr.appendChild(document.createTextNode(' '));
  9077. tr.appendChild(createImage(urlImg, infosCompo));
  9078. }
  9079. }
  9080. }
  9081. }
  9082. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  9083. var texte = getInfoEnchantementFromMonstre(nom);
  9084. if(texte!='') {
  9085. var td = getMonstreNomNode(i);
  9086. td.appendChild(document.createTextNode(' '));
  9087. td.appendChild(createImage(urlEnchantImg, texte));
  9088. }
  9089. }
  9090. tr_monstres[i].style.display = (
  9091. noGowapsS &&
  9092. nom.indexOf('gowap sauvage')!=-1 &&
  9093. getMonstreDistance(i)>1
  9094. ) || (
  9095. noGowapsA &&
  9096. nom.indexOf('gowap apprivoisé')!=-1 &&
  9097. getMonstreDistance(i)>1
  9098. ) || (
  9099. noEngages &&
  9100. getMonstreDistance(i)!=0 &&
  9101. listeEngages[pos[0]] &&
  9102. listeEngages[pos[0]][pos[1]] &&
  9103. listeEngages[pos[0]][pos[1]][pos[2]]
  9104. ) || (
  9105. strMonstre!='' &&
  9106. nom.indexOf(strMonstre)==-1
  9107. ) || (
  9108. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  9109. getMonstreDistance(i)>1 &&
  9110. nom.toLowerCase().indexOf("kilamo")==-1
  9111. ) ? 'none' : '';
  9112. }
  9113. if(MY_getValue('NOINFOEM')!='true') {
  9114. if(noEM != oldNOEM) {
  9115. if(noEM && isCDMsRetrieved) computeMission();
  9116. }
  9117. oldNOEM = noEM;
  9118. }
  9119. needComputeEnchantement = false;
  9120. }
  9121.  
  9122.  
  9123. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  9124.  
  9125. function filtreTrolls() {
  9126. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  9127. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  9128. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  9129. for(var i=1 ; i<=nbTrolls ; i++) {
  9130. tr_trolls[i].style.display = (
  9131. noIntangibles &&
  9132. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  9133. ) || (
  9134. strTroll!='' &&
  9135. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  9136. ) || (
  9137. strGuilde!='' &&
  9138. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  9139. ) ? 'none' : '';
  9140. }
  9141. }
  9142.  
  9143. /* [functions] Bulle PX Trolls */
  9144. var bulle;
  9145.  
  9146. function initPXTroll() {
  9147. bulle = document.createElement('div');
  9148. bulle.id = 'bulle';
  9149. bulle.className = 'mh_textbox';
  9150. bulle.style =
  9151. 'position: absolute;'+
  9152. 'border: 1px solid #000000;'+
  9153. 'visibility: hidden;'+
  9154. 'display: inline;'+
  9155. 'z-index: 2;';
  9156. document.body.appendChild(bulle);
  9157.  
  9158. for(var i=nbTrolls ; i>0 ; i--) {
  9159. var td_niv = getTrollNivNode(i);
  9160. td_niv.onmouseover = showPXTroll;
  9161. td_niv.onmouseout = hidePXTroll;
  9162. }
  9163. }
  9164.  
  9165. function showPXTroll(evt) {
  9166. var lvl = this.firstChild.nodeValue;
  9167. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  9168. bulle.style.left = evt.pageX+15+'px';
  9169. bulle.style.top = evt.pageY+'px';
  9170. bulle.style.visibility = 'visible';
  9171. }
  9172.  
  9173. function hidePXTroll() {
  9174. bulle.style.visibility = 'hidden';
  9175. }
  9176.  
  9177. /* [functions] Envoi PX / MP */
  9178. function putBoutonPXMP() {
  9179. // Bouton d'initialisation du mode Envoi
  9180. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  9181. var td = document.getElementById('tdInsertTrolls');
  9182. if(!td) { return; }
  9183. td.width = 100;
  9184. td = insertTd(td.nextSibling);
  9185. td.style.verticalAlign = 'top';
  9186. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  9187. bouton.id = 'btnEnvoi';
  9188. }
  9189.  
  9190. function prepareEnvoi() {
  9191. // = 1er Handler du bouton d'envoi
  9192. /* Ajout de la colonne des CheckBoxes */
  9193. var td = insertTdText(getTrollNomNode(0),'');
  9194. td.width = 5;
  9195. for(var i=nbTrolls ; i>0 ; i--) {
  9196. td = insertTd(getTrollNomNode(i));
  9197. appendCheckBox(td,'envoi'+i);
  9198. }
  9199. /* Ajout du radio de choix PX ou MP */
  9200. var btnEnvoi = document.getElementById('btnEnvoi');
  9201. if(!btnEnvoi) { return; }
  9202. var tdEnvoi = btnEnvoi.parentNode;
  9203. appendText(tdEnvoi,' ');
  9204. var span = document.createElement('span');
  9205. span.style.whiteSpace = 'nowrap';
  9206. var radioElt = document.createElement('input');
  9207. radioElt.type = 'radio';
  9208. radioElt.name = 'envoiPXMP';
  9209. radioElt.id = 'radioPX';
  9210. span.appendChild(radioElt);
  9211. appendText(span,' des PX ');
  9212. radioElt = document.createElement('input');
  9213. radioElt.type = 'radio';
  9214. radioElt.name = 'envoiPXMP';
  9215. radioElt.checked = true;
  9216. span.appendChild(radioElt);
  9217. appendText(span,' un MP');
  9218. tdEnvoi.appendChild(span);
  9219. /* Insertion du bouton Annuler */
  9220. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  9221. /* Modification de l'effet du bouton Envoi */
  9222. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  9223. }
  9224.  
  9225. function annuleEnvoi() {
  9226. // = Handler bouton Annuler
  9227. /* Nettoyage du td du bouton Envoi */
  9228. var btnEnvoi = document.getElementById('btnEnvoi');
  9229. var tdEnvoi = btnEnvoi.parentNode;
  9230. while(tdEnvoi.firstChild) {
  9231. tdEnvoi.removeChild(tdEnvoi.firstChild);
  9232. }
  9233. /* Retour à l'effet de base du bouton Envoi */
  9234. btnEnvoi.onclick = prepareEnvoi;
  9235. tdEnvoi.appendChild(btnEnvoi);
  9236. /* Suppression CheckBoxes */
  9237. for(var i=nbTrolls ; i>=0 ; i--) {
  9238. var td = getTrollNomNode(i);
  9239. td.parentNode.removeChild(td);
  9240. }
  9241. }
  9242.  
  9243. function effectueEnvoi() {
  9244. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9245. var str='';
  9246. for(var i=nbTrolls ; i>0 ; i--) {
  9247. var chb = document.getElementById('envoi'+i);
  9248. if(chb.checked) {
  9249. str += (str?',':'')+getTrollID(i);
  9250. }
  9251. }
  9252. var PXchecked = document.getElementById('radioPX').checked;
  9253. if(PXchecked) {
  9254. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9255. } else {
  9256. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9257. }
  9258. }
  9259.  
  9260. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9261.  
  9262. function filtreTresors() {
  9263. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9264. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9265. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9266. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9267. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9268. if(noEngages && !isEngagesComputed) {
  9269. for(var i=nbTrolls ; i>0 ; i--) {
  9270. var pos = getTrollPosition(i);
  9271. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9272. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9273. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9274. }
  9275. isEngagesComputed = true;
  9276. }
  9277. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9278. for(var i=nbTresors ; i>0 ; i--) {
  9279. var nom = getTresorNom(i);
  9280. var pos = getTresorPosition(i);
  9281. tr_tresors[i].style.display = (
  9282. noGG &&
  9283. nom.indexOf('Gigots de Gob')!=-1
  9284. ) || (
  9285. noCompos &&
  9286. nom.indexOf('Composant')!=-1
  9287. ) || (
  9288. noEngages &&
  9289. listeEngages[pos[2]] &&
  9290. listeEngages[pos[2]][pos[1]] &&
  9291. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9292. getTresorDistance(i)>0
  9293. ) || (
  9294. strTresor!='' &&
  9295. nom.toLowerCase().indexOf(strTresor)==-1
  9296. ) || (
  9297. noBidouilles &&
  9298. nom.indexOf('Bidouille')!=-1
  9299. ) ? 'none' : '';
  9300. }
  9301. }
  9302.  
  9303.  
  9304. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9305.  
  9306. function filtreLieux() {
  9307. // += Handler checkbox trous
  9308. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9309. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9310. for(var i=nbLieux ; i>0 ; i--) {
  9311. tr_lieux[i].style.display = (
  9312. strLieu &&
  9313. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9314. ) || (
  9315. noTrou &&
  9316. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9317. getLieuDistance(i)>1
  9318. ) ? 'none' : '';
  9319. }
  9320. }
  9321.  
  9322.  
  9323. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9324.  
  9325. function refreshDiplo() {
  9326. MY_setValue(numTroll+'.diplo.off',
  9327. checkBoxDiplo.checked?'true':'false'
  9328. );
  9329. if(isDiploRaw) { computeDiplo(); }
  9330. appliqueDiplo();
  9331. }
  9332.  
  9333. function computeDiplo() {
  9334. // On extrait les données de couleur et on les stocke par id
  9335. // Ordre de préséance :
  9336. // source Guilde < source Perso
  9337. // guilde cible < troll cible
  9338. /* Diplo de Guilde */
  9339. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9340. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9341. if(diploGuilde && diploGuilde.isOn=='true') {
  9342. // Guilde perso
  9343. if(diploGuilde.guilde) {
  9344. Diplo.Guilde[diploGuilde.guilde.id] = {
  9345. couleur: diploGuilde.guilde.couleur,
  9346. titre: 'Ma Guilde'
  9347. };
  9348. }
  9349. // Guildes/Trolls A/E
  9350. for(var AE in {Amis:0,Ennemis:0}) {
  9351. for(var i=0 ; i<5 ; i++) {
  9352. if(diploGuilde[AE+i]) {
  9353. for(var type in {Guilde:0,Troll:0}) {
  9354. var liste = diploGuilde[AE+i][type].split(';');
  9355. for(var j=liste.length-2 ; j>=0 ; j--) {
  9356. Diplo[type][liste[j]] = {
  9357. couleur: diploGuilde[AE+i].couleur,
  9358. titre: diploGuilde[AE+i].titre
  9359. };
  9360. }
  9361. }
  9362. }
  9363. }
  9364. }
  9365. }
  9366. /* Diplo Perso */
  9367. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9368. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9369. if(diploPerso && diploPerso.isOn=='true') {
  9370. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9371. for(var id in diploPerso[type]) {
  9372. Diplo[type][id] = diploPerso[type][id];
  9373. }
  9374. }
  9375. }
  9376. if(diploPerso.mythiques) {
  9377. Diplo.mythiques = diploPerso.mythiques;
  9378. }
  9379. isDiploRaw = false;
  9380. }
  9381.  
  9382. function appliqueDiplo() {
  9383. var aAppliquer = Diplo;
  9384. if(checkBoxDiplo.checked) {
  9385. // Pour retour à l'affichage basique sur désactivation de la diplo
  9386. aAppliquer = {
  9387. Guilde: {},
  9388. Troll: {},
  9389. Monstre: {}
  9390. };
  9391. }
  9392. /* On applique "aAppliquer" */
  9393. // Diplo Trõlls
  9394. for(var i=nbTrolls ; i>0 ; i--) {
  9395. var idG = getTrollGuildeID(i);
  9396. var idT = getTrollID(i);
  9397. var tr = tr_trolls[i];
  9398. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9399. if(aAppliquer.Troll[idT]) {
  9400. tr.className = '';
  9401. var descr = aAppliquer.Troll[idT].titre;
  9402. if(descr) {
  9403. getTrollNomNode(i).title = descr
  9404. }
  9405. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9406. } else if(aAppliquer.Guilde[idG]) {
  9407. tr.className = '';
  9408. var descr = aAppliquer.Guilde[idG].titre;
  9409. if(descr) {
  9410. getTrollNomNode(i).title = descr
  9411. }
  9412. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9413. } else {
  9414. tr.className = 'mh_tdpage';
  9415. getTrollNomNode(i).title = '';
  9416. }
  9417. }
  9418. // Diplo Monstres
  9419. for(var i=nbMonstres ; i>0 ; i--) {
  9420. var id = getMonstreID(i);
  9421. var nom = getMonstreNom(i).toLowerCase();
  9422. if(aAppliquer.Monstre[id]) {
  9423. tr_monstres[i].className = '';
  9424. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  9425. tr_monstres[i].diploActive = 'oui';
  9426. var descr = aAppliquer.Monstre[id].titre;
  9427. if(descr) {
  9428. getMonstreNomNode(i).title = descr;
  9429. }
  9430. } else if(aAppliquer.mythiques &&
  9431. (nom.indexOf('liche')==0 ||
  9432. nom.indexOf('hydre')==0 ||
  9433. nom.indexOf('balrog')==0 ||
  9434. nom.indexOf('beholder')==0)) {
  9435. tr_monstres[i].className = '';
  9436. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  9437. tr_monstres[i].diploActive = 'oui';
  9438. getMonstreNomNode(i).title = 'Monstre Mythique';
  9439. } else {
  9440. tr_monstres[i].className = 'mh_tdpage';
  9441. tr_monstres[i].diploActive = '';
  9442. }
  9443. }
  9444. }
  9445.  
  9446.  
  9447. /*-[functions]---------------- Actions à distance ----------------------------*/
  9448.  
  9449. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  9450. var monN = parseInt(getPosition()[2]);
  9451. for(var type in keltypes) {
  9452. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  9453. for(var i=this['nb'+type] ; i>0 ; i--) {
  9454. var tr = this['tr_'+type.toLowerCase()][i];
  9455. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  9456. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  9457. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  9458. var sonN = getXxxPosition(type, i)[2];
  9459. var d = getXxxDistance(type, i);
  9460. if(sonN==monN && d>=dmin && d<=dmax) {
  9461. var iconeAction = document.evaluate(
  9462. "./descendant::img[@alt='"+alt+"']",
  9463. tr, null, 9, null
  9464. ).singleNodeValue;
  9465. if(iconeAction) {
  9466. if(iconeAction.title) {
  9467. iconeAction.title += "\n"+message;
  9468. } else {
  9469. iconeAction.title = message;
  9470. }
  9471. iconeAction.src = urlIcon;
  9472. } else {
  9473. var tdAction = tr.getElementsByTagName('td')[1];
  9474. var icon = document.createElement('img');
  9475. icon.src = urlIcon;
  9476. icon.height = 20;
  9477. icon.alt = alt;
  9478. icon.title = message;
  9479. tdAction.appendChild(icon);
  9480. }
  9481. }
  9482. }
  9483. }
  9484. }
  9485.  
  9486. function computeCharge() {
  9487. computeActionDistante(1,
  9488. getPortee__Vue(
  9489. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  9490. MY_getValue(numTroll+".caracs.regeneration")
  9491. ),
  9492. {'Monstres':1, 'Trolls':1},
  9493. 'Attaquer',
  9494. MHicons+'E_Metal09.png',
  9495. 'Cible à portée de Charge'
  9496. );
  9497. }
  9498.  
  9499. function computeProjo() {
  9500. computeActionDistante(0,
  9501. getPortee__Vue(
  9502. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9503. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9504. ),
  9505. {'Monstres':1, 'Trolls':1},
  9506. 'Attaquer',
  9507. MHicons+'S_Fire05.png',
  9508. 'Cible à portée de Projo'
  9509. );
  9510. }
  9511.  
  9512. function computeTelek() {
  9513. computeActionDistante(0,
  9514. Math.floor((
  9515. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9516. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9517. )/2),
  9518. {'Tresors':1},
  9519. 'Telek',
  9520. MHicons+'S_Magic04.png',
  9521. 'Trésor à portée de Télékinésie'
  9522. );
  9523. }
  9524.  
  9525. function computeLdP() {
  9526. computeActionDistante(0,
  9527. 2+Math.floor((
  9528. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9529. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9530. )/5),
  9531. {'Monstres':1, 'Trolls':1},
  9532. 'self',
  9533. MHicons+'P_Red01.png',
  9534. 'Cible à portée de Lancer de Potions'
  9535. );
  9536. }
  9537.  
  9538.  
  9539. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  9540.  
  9541. function putScriptExterne() {
  9542. var infoit = MY_getValue(numTroll+'.INFOSIT');
  9543. if(!infoit || infoit=='') return;
  9544.  
  9545. var nomit = infoit.slice(0,infoit.indexOf('$'));
  9546. if(nomit=='bricol') {
  9547. var data = infoit.split('$');
  9548. try {
  9549. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  9550. // appendNewScript(URL_bricol+data[1]
  9551. // +'/mz.php?login='+data[2]
  9552. // +'&password='+data[3]
  9553. // );
  9554. FF_XMLHttpRequest({
  9555. method: 'GET',
  9556. url: URL_bricol+data[1]
  9557. +'/mz_json.php?login='+data[2]
  9558. +'&password='+data[3],
  9559. onload: function(responseDetails) {
  9560. try {
  9561. if (responseDetails.status == 0) {
  9562. if (isHTTPS) {
  9563. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  9564. } else {
  9565. window.console.log('status=0 à l\'appel bricol\'troll');
  9566. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  9567. }
  9568. return;
  9569. }
  9570. var ratibusData;
  9571. try {
  9572. ratibusData = JSON.parse(responseDetails.responseText);
  9573. } catch(e) {}
  9574. if (ratibusData === undefined) {
  9575. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  9576. return;
  9577. }
  9578. if (ratibusData.error) {
  9579. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  9580. } else {
  9581. putInfosTrolls(ratibusData.data.trolls);
  9582. }
  9583. } catch(e) {
  9584. window.console.log(traceStack(e, 'retour bricol\'troll'));
  9585. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  9586. }
  9587. }
  9588. });
  9589. } catch(e) {
  9590. if (isHTTPS) {
  9591. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  9592. } else {
  9593. window.console.log(traceStack(e, 'appel bricol\'troll'));
  9594. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  9595. }
  9596. }
  9597. }
  9598. }
  9599.  
  9600. /* Le script mz.php de Ratibus renvoie :
  9601. + infosTrolls = new Array();
  9602. + infosTrolls[numdutroll] =
  9603. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  9604. + etc ...
  9605. + putInfosTrolls();
  9606. *
  9607. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  9608. * Roule 07/11/2016, on utilise mz_json qui envoie
  9609. {
  9610. "data": {
  9611. "trolls": {
  9612. "59424": {
  9613. "id": 59424,
  9614. "pv": xx,
  9615. "pv_max": xx,
  9616. "updated_at": "2016-10-31 07:28:40",
  9617. "dla": "2016-10-05 07:28:04",
  9618. "pa": 0
  9619. },
  9620. }
  9621. }
  9622. }
  9623. */
  9624.  
  9625. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  9626. function corrigeBricolTrolls(infosTrolls) {
  9627. for(var i in infosTrolls) {
  9628. var pv = infosTrolls[i][0];
  9629. var pvmax = infosTrolls[i][1];
  9630. var pvmem = MY_getValue(i+'.caracs.pv.max');
  9631. if(pvmem && pvmem>pvmax) {
  9632. infosTrolls[i][1] = pvmem;
  9633. pvmax = pvmem;
  9634. }
  9635. if(pv>pvmax) {
  9636. var newpvmax = 5*Math.ceil(pv/5);
  9637. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9638. infosTrolls[i][1] = newpvmax;
  9639. }
  9640. }
  9641. }
  9642.  
  9643. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9644. function addTdInfosTroll(infos, nextTD) {
  9645. /* cadre barre PV */
  9646. var tab = document.createElement('div');
  9647. /* ancienne méthode par img, à supprimer
  9648. tab.width = 100;
  9649. tab.style.width = 100;
  9650. tab.height = 10;
  9651. tab.style.background = '#FFFFFF';
  9652. tab.style.border = 1;
  9653. */
  9654. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9655. /* barre PV */
  9656. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9657. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9658. .vieContainer {
  9659. background-color: #CCC;
  9660. width: 50px;
  9661. height: 6px;
  9662. border: 1px solid #000;
  9663. text-align: left;
  9664. }
  9665. */
  9666. tab.style.width = '100px';
  9667. tab.style.height = '10px';
  9668. tab.style.border = '1px solid #000';
  9669. tab.style.textAlign = 'left';
  9670. var div2 = document.createElement('div');
  9671. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9672. var dateLimite = new Date();
  9673. dateLimite.setDate(dateLimite.getDate() - 7);
  9674. if (infos.oUpdatedAt < dateLimite) {
  9675. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9676. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9677. } else if (pourcentVie > 66) {
  9678. div2.style.backgroundColor = '#77EE77';
  9679. } else if (pourcentVie > 33) {
  9680. div2.style.backgroundColor = '#EEEE77';
  9681. } else {
  9682. div2.style.backgroundColor = '#FF0000';
  9683. }
  9684. div2.style.width = pourcentVie + '%';
  9685. div2.style.height = '10px';
  9686. tab.appendChild(div2);
  9687. /* ancienne méthode par img, à supprimer
  9688. var img = document.createElement('img');
  9689. img.src = '../Images/Interface/milieu.gif';
  9690. img.height = 10;
  9691. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9692. tab.appendChild(img);
  9693. */
  9694.  
  9695. /* lien vers l'IT */
  9696. var lien = document.createElement('a');
  9697. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9698. lien.href = URL_bricol+nomit+'/index.php';
  9699. lien.target = '_blank';
  9700. lien.appendChild(tab);
  9701. insertTdElement(nextTD,lien);
  9702. /* PAs dispos */
  9703. var span = document.createElement('span');
  9704. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9705. appendText(span, infos.pa +' PA' );
  9706. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9707. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9708. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9709. span.style.backgroundColor = 'B8EEB8';
  9710. }
  9711. insertTdElement(nextTD, span);
  9712. }
  9713.  
  9714. function putInfosTrolls(infosTrolls) {
  9715. try {
  9716. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9717. // supression des infos trop vieilles (un mois)
  9718. var IDs = Object.keys(infosTrolls);
  9719. var dateLimite = new Date();
  9720. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9721. for (var i = 0; i < IDs.length; i++) {
  9722. var idTroll = IDs[i];
  9723. var infos = infosTrolls[idTroll];
  9724. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9725. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9726. }
  9727. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9728. td.width = 40;
  9729. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9730. td.width = 105;
  9731.  
  9732. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9733. //corrigeBricolTrolls(infosTrolls);
  9734.  
  9735. for(i=nbTrolls ; i>0 ; i--) {
  9736. var infos = infosTrolls[getTrollID(i)];
  9737. if(infos && (!infos.bIgnore)) {
  9738. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9739. infos.done = true;
  9740. } else {
  9741. insertTd(tr_trolls[i].childNodes[6]);
  9742. insertTd(tr_trolls[i].childNodes[6]);
  9743. }
  9744. }
  9745. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9746. var str = MY_getValue(numTroll+'.INFOSIT');
  9747. if(!str) return;
  9748. var arr = str.split('$');
  9749. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9750.  
  9751. //window.console.log('nb Troll IT : ' + IDs.length);
  9752. var tBody = tr_trolls[0].parentNode;
  9753. if (tr_trolls[1] === undefined)
  9754. tBody = tr_trolls[0].parentNode;
  9755. else
  9756. tBody = tr_trolls[1].parentNode;
  9757. var pos = getPosition();
  9758. for (i = 0; i < IDs.length; i++) {
  9759. var idTroll = IDs[i];
  9760. infos = infosTrolls[idTroll];
  9761. if (infos.done) continue; // déjà vu
  9762. if (infos.bIgnore) continue; // trop vieux
  9763. if (idTroll == numTroll) continue; // pas nous-même
  9764. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9765. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9766. // trouver où insérer ce Troll
  9767. var next = undefined;
  9768. for(var j=0 ; j<tr_trolls.length ; j++) {
  9769. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9770. if (thisDist > distance) {
  9771. next = tr_trolls[j]
  9772. break;
  9773. }
  9774. }
  9775. var tr;
  9776. if (next !== undefined) {
  9777. tr = insertTr(next,'mh_tdpage')
  9778. } else {
  9779. tr = appendTr(tBody,'mh_tdpage');
  9780. }
  9781. var td = appendTd(tr); // distance
  9782. appendText(td, distance);
  9783. td = appendTd(tr); // actions
  9784. td = appendTd(tr); // ID
  9785. appendText(td, idTroll);
  9786. td = appendTd(tr); // Nom
  9787. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9788. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9789. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9790. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9791. td = appendTd(tr); // Niveau
  9792. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9793. td.align = 'center';
  9794. td = appendTd(tr); // Race
  9795. if (infos.race) appendText(td, infos.race);
  9796. // PV et PA ajoutés par addTdInfosTroll
  9797. td = appendTd(tr); // Guilde
  9798. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9799. td = appendTd(tr); // X
  9800. td.align = 'center';
  9801. if (infos.x !== undefined) appendText(td, infos.x);
  9802. td = appendTd(tr); // Y
  9803. td.align = 'center';
  9804. if (infos.y !== undefined) appendText(td, infos.y);
  9805. td = appendTd(tr); // N
  9806. td.align = 'center';
  9807. if (infos.n !== undefined) appendText(td, infos.n);
  9808. addTdInfosTroll(infos, tr.childNodes[6]);
  9809. }
  9810. } catch(e) {
  9811. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  9812. }
  9813. }
  9814.  
  9815.  
  9816. /* Mode Tétalanvert! ---------------------------------------------------------*/
  9817.  
  9818. function calculeDistance(maPos,posArr) {
  9819. return Math.max(
  9820. Math.abs(maPos[0]-posArr[0]),
  9821. Math.abs(maPos[1]-posArr[1]),
  9822. Math.abs(maPos[2]-posArr[2])
  9823. );
  9824. }
  9825.  
  9826. function inversionCoord() {
  9827. var maPos = getPosition();
  9828. var listeOffsets = {
  9829. 'monstres':checkBoxLevels.checked?4:3,
  9830. 'trolls':6,
  9831. };
  9832. for(var type in listeOffsets) {
  9833. var trList = this['tr_'+type];
  9834. var offset = listeOffsets[type];
  9835. for(var i=trList.length-1 ; i>0 ; i--) {
  9836. var oldX = parseInt(trList[i].cells[offset].textContent);
  9837. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  9838. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  9839. trList[i].cells[offset].innerHTML = oldY;
  9840. trList[i].cells[offset+1].innerHTML = oldX;
  9841. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  9842. }
  9843. }
  9844. }
  9845.  
  9846.  
  9847. /* Partie principale */
  9848. function do_vue() {
  9849. for(var type in typesAFetcher) {
  9850. fetchData(type);
  9851. }
  9852.  
  9853. // roule' 11/03/2016
  9854. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  9855. // je fais une recopie :(
  9856. tr_monstres = this['tr_monstres'];
  9857. tr_trolls = this['tr_trolls'];
  9858. tr_tresors = this['tr_tresors'];
  9859. tr_champignons = this['tr_champignons'];
  9860. tr_lieux = this['tr_lieux'];
  9861.  
  9862. nbMonstres = this['nbMonstres'];
  9863. nbTrolls = this['nbTrolls'];
  9864. nbTresors = this['nbTresors'];
  9865. nbChampignons = this['nbChampignons'];
  9866. nbLieux = this['nbLieux'];
  9867.  
  9868. try {
  9869. start_script(31);
  9870. initialiseInfos();
  9871. savePosition();
  9872.  
  9873. // Fonctionnalité "Têtalenvert" cachée, en test :
  9874. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  9875. inversionCoord();
  9876. }
  9877. ajoutDesFiltres();
  9878. set2DViewSystem();
  9879. //putBoutonTroogle();
  9880. putBoutonPXMP();
  9881. synchroniseFiltres();
  9882. toggleLevelColumn();
  9883.  
  9884. refreshDiplo();
  9885. //400 ms
  9886. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  9887. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  9888. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  9889. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  9890. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  9891. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  9892. var noTresorsEngages =
  9893. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  9894. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  9895. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  9896. filtreMonstres();
  9897. if(noIntangibles) {
  9898. filtreTrolls();
  9899. }
  9900. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  9901. filtreTresors();
  9902. }
  9903. if(noTrou) {
  9904. filtreLieux();
  9905. }
  9906.  
  9907. initPopupVue();
  9908. initPXTroll();
  9909.  
  9910. if(getTalent("Projectile Magique")!=0) {
  9911. computeProjo();
  9912. }
  9913. if(getTalent("Charger")!=0) {
  9914. computeCharge();
  9915. }
  9916. if(getTalent("Télékinésie")!=0) {
  9917. computeTelek();
  9918. }
  9919. if(getTalent("Lancer de Potions")!=0) {
  9920. computeLdP();
  9921. }
  9922. putScriptExterne();
  9923. displayScriptTime();
  9924. } catch(e) {
  9925. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  9926. window.console.error(traceStack(e, 'vue'));
  9927. }
  9928. }
  9929.  
  9930.  
  9931.  
  9932. /*******************************************************************************
  9933. * This file is part of Mountyzilla. *
  9934. * *
  9935. * Mountyzilla is free software; you can redistribute it and/or modify *
  9936. * it under the terms of the GNU General Public License as published by *
  9937. * the Free Software Foundation; either version 2 of the License, or *
  9938. * (at your option) any later version. *
  9939. * *
  9940. * Mountyzilla is distributed in the hope that it will be useful, *
  9941. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  9942. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  9943. * GNU General Public License for more details. *
  9944. * *
  9945. * You should have received a copy of the GNU General Public License *
  9946. * along with Mountyzilla; if not, write to the Free Software *
  9947. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  9948. *******************************************************************************/
  9949.  
  9950. // x~x profil2
  9951.  
  9952. /*---------------------------- Variables globales ----------------------------*/
  9953.  
  9954. var
  9955. // Anatrolliseur
  9956. urlAnatrolliseur,
  9957. // Infobulles talents
  9958. hauteur = 50, bulleStyle = null,
  9959. // Caracteristiques
  9960. // Infos troll
  9961. race, niv, idtroll, datecrea,
  9962. idguilde, nomguilde,
  9963. // Etats du troll
  9964. fatigue, bmfatigue,
  9965.  
  9966. // Experience, Pi, ...
  9967. pxdistribuables, pxperso,
  9968. piutilisable, pitotal,
  9969. nbmeurtres, nbmorts,
  9970. // utilisee pour les moyennes MM/jour, kill/jour, etc
  9971. NBjours,
  9972. // calcul des DLA suivantes
  9973. DLA, DLAsuiv, HeureServeur,
  9974. // details duree du tour (calcul pvdispo) :
  9975. dtb, pdm, bmt, adb, dpt,
  9976. //posale
  9977. posX, posY, posN,
  9978. // caracs physiques
  9979. vue, vuebp, vuebm, vuetotale,
  9980. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  9981. reg, regbp, regbm, regmoy,
  9982. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  9983. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  9984. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  9985. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  9986. rm, rmbp, rmbm, rmtotale,
  9987. mm, mmbp, mmbm, mmtotale,
  9988.  
  9989. // Variables speciales Kastars
  9990. pvActuelKastar, minParPV, overDLA,
  9991. // id pour edition manuelle de lastDLA :
  9992. inJour, inMois, inAn, inHr, inMin, inSec,
  9993. // id pour auto-refresh lastDLA :
  9994. lastDLAZone, maxAMZone, cumulZone,
  9995. lastDLA, DLAaccel;
  9996.  
  9997.  
  9998. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  9999.  
  10000. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10001. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10002. function getUniqueValueBySelector(selector, defaultValue){
  10003. var valNode = document.querySelector(selector);
  10004. if(valNode!=null){
  10005. if(valNode.hasChildNodes()) {
  10006. return valNode.childNodes[0].nodeValue;
  10007. }else{
  10008. return defaultValue;
  10009. }
  10010. } else{
  10011. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10012. return defaultValue;
  10013. }
  10014. }
  10015. function getUniqueStringValueBySelector(selector){
  10016. return getUniqueValueBySelector(selector,"");
  10017. }
  10018. function getUniqueIntValueBySelector(selector){
  10019. var ret = getUniqueValueBySelector(selector,0);
  10020. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10021. ret = 0;
  10022. }
  10023. return parseInt(ret);
  10024. }
  10025. function getUniqueFloatValueBySelector(selector){
  10026. var ret = getUniqueValueBySelector(selector,0.0);
  10027. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10028. ret = 0.0;
  10029. }
  10030. return parseFloat(ret);
  10031. }
  10032.  
  10033.  
  10034. function resiste(Ddeg,bm) {
  10035. // version naive mais compréhensible ^^
  10036. // DEBUG: à revoir
  10037. if(!bm) {
  10038. return 2*Math.floor(Ddeg/2);
  10039. }
  10040. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10041. }
  10042.  
  10043. function retourAZero(fatig) {
  10044. var fat = fatig, raz = 0;
  10045. while(fat>0) {
  10046. raz++;
  10047. fat = Math.floor(fat/1.25);
  10048. }
  10049. return raz;
  10050. }
  10051.  
  10052. function decumulPumPrem(bonus) {
  10053. switch(bonus) {
  10054. case 20: return 33;
  10055. case 33: return 41;
  10056. case 41: return 46;
  10057. case 46: return 49;
  10058. case 49: return 51;
  10059. default: return 20;
  10060. }
  10061. }
  10062.  
  10063. function coefDecumul(i) {
  10064. switch(i) {
  10065. case 2: return 0.67;
  10066. case 3: return 0.4;
  10067. case 4: return 0.25;
  10068. case 5: return 0.15;
  10069. default: return 0.1;
  10070. }
  10071. }
  10072.  
  10073. function dureeHM(dmin) {
  10074. var ret = "";
  10075. dmin = Math.floor(dmin);
  10076. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  10077. var mins = dmin%60;
  10078. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  10079. return (ret) ? ret : "-";
  10080. }
  10081.  
  10082. // extraction d'une durée
  10083. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  10084. // c'est protégé (rend 0 si l'élément est absent)
  10085. // Roule' 24/12/2016
  10086. function extractionDuree(selecteur) {
  10087. var s = getUniqueStringValueBySelector(selecteur);
  10088. if (!s) return 0;
  10089. var tabN = getNumbers(s);
  10090. if (tabN.length < 2) return 0;
  10091. return tabN[0] * 60 + tabN[1];
  10092. }
  10093.  
  10094. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  10095.  
  10096. function extractionDonnees() {
  10097. // Variables temporaires
  10098. var Nbrs = {};
  10099.  
  10100. // *********************
  10101. // Cadre "Description"
  10102. // *********************
  10103. race = getUniqueStringValueBySelector('#descr #race');
  10104. debugMZ("Race : " + race);
  10105. idtroll = getUniqueStringValueBySelector('#descr #id');
  10106. debugMZ("Id troll : " + idtroll);
  10107. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  10108. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  10109. datecrea = new Date(StringToDate(strDateCrea));
  10110. debugMZ("Date creation : " + datecrea);
  10111. // Guilde
  10112. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  10113. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  10114. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  10115.  
  10116. // *******************
  10117. // Cadre "Experience"
  10118. // *******************
  10119. // Niveau de troll
  10120. niv = getUniqueIntValueBySelector('#exp #niv');
  10121. nivTroll = niv;
  10122. debugMZ("Niveau : " + niv);
  10123. // PX
  10124. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  10125. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  10126. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  10127. // PI
  10128. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  10129. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  10130. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  10131. // Meutres/Morts
  10132. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  10133. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  10134. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  10135.  
  10136. // *********************
  10137. // Cadre "Tour de Jeu"
  10138. // *********************
  10139. // DLA
  10140. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  10141. DLA = new Date(StringToDate(Nbrs["dla"]));
  10142. debugMZ("DLA: " + DLA);
  10143. // DLA suivante
  10144. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  10145. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  10146. debugMZ("DLAsuiv: " + DLAsuiv);
  10147. // Duree normale de mon Tour
  10148. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  10149. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  10150. dtb = extractionDuree("#dla #tour");
  10151. debugMZ("Duree normale de mon Tour : " + dtb);
  10152. // Bonus/Malus sur la duree
  10153. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  10154. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  10155. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  10156. debugMZ("Bonus/Malus sur la duree : " + bmt);
  10157. // Augmentation due aux blessures
  10158. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  10159. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  10160. adb = extractionDuree("#dla #blessure");
  10161. debugMZ("Augmentation due aux blessures : " + adb);
  10162. // Poids de l'equipement
  10163. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  10164. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  10165. pdm = extractionDuree("#dla #poids");
  10166. debugMZ("Poids de l'equipement : " + pdm);
  10167. // Duree de mon prochain Tour
  10168. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  10169. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  10170. dpt = extractionDuree("#dla #duree>b");
  10171. debugMZ('Duree de mon prochain Tour : ' + dpt);
  10172.  
  10173. // ****************
  10174. // Cadre "Etats"
  10175. // ****************
  10176. // Position du troll :
  10177. posX = getUniqueIntValueBySelector('#pos #x');
  10178. posY = getUniqueIntValueBySelector('#pos #y');
  10179. posN = getUniqueIntValueBySelector('#pos #n');
  10180. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  10181. // PV actuel
  10182. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  10183. pvActuelKastar = pvcourant;
  10184. debugMZ("PV actuel : " + pvcourant)
  10185. // Fatigue
  10186. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  10187. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  10188. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  10189.  
  10190. // **************************
  10191. // Cadre "Caracteristiques"
  10192. // **************************
  10193. // Attaque
  10194. att = getUniqueIntValueBySelector('#carac #att');
  10195. attbp = getUniqueIntValueBySelector('#carac #att_p');
  10196. attbm = getUniqueIntValueBySelector('#carac #att_m');
  10197. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  10198. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  10199. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  10200. attmoy = 3.5*att + attbp + attbm;
  10201. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10202. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  10203. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  10204. // Esquive
  10205. esq = getUniqueIntValueBySelector('#carac #esq');
  10206. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  10207. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  10208. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  10209. esqmoy = 3.5*esq + esqbp+esqbm;
  10210. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  10211. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  10212. // Degat
  10213. deg = getUniqueIntValueBySelector('#carac #deg');
  10214. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  10215. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  10216. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  10217. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  10218. degmoy = 2*deg + degbp+degbm;
  10219. degmoycrit = 3*deg + degbp+degbm;
  10220. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10221. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  10222. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  10223. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  10224. // PV
  10225. pvbase = getUniqueIntValueBySelector('#carac #pv');
  10226. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  10227. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  10228. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  10229. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  10230. // Regeneration
  10231. reg = getUniqueIntValueBySelector('#carac #reg');
  10232. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  10233. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  10234. regmoy = 2 * reg + regbp + regbm; // D3
  10235. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  10236. // Armure
  10237. arm = getUniqueIntValueBySelector('#carac #arm');
  10238. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  10239. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  10240. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  10241. armmoy = 2*arm + armbp+armbm;
  10242. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  10243. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  10244. // TODO : D d'armure non active
  10245. // Vue
  10246. vue = getUniqueIntValueBySelector('#carac #vue');
  10247. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10248. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10249. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10250. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10251. // RM
  10252. rm = getUniqueIntValueBySelector('#carac #rm');
  10253. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10254. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10255. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10256. rmTroll = rmtotale;
  10257. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10258. // MM
  10259. mm = getUniqueIntValueBySelector('#carac #mm');
  10260. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10261. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10262. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10263. mmTroll = mmtotale;
  10264. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10265.  
  10266. // Heure Serveur
  10267. try {
  10268. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10269. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10270. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10271. } catch (e) {
  10272. window.console.warn(
  10273. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10274. );
  10275. HeureServeur = new Date();
  10276. }
  10277. debugMZ("HeureServeur: " + HeureServeur);
  10278.  
  10279. // ***INIT GLOBALE*** NBjours
  10280. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10281.  
  10282. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10283. var amelio_dtb = function(dtb) {
  10284. if(dtb>555) {
  10285. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10286. }
  10287. return 10+Math.ceil((555-dtb)/2.5);
  10288. },
  10289. amelio_pv = Math.floor(pvbase/10)-3,
  10290. amelio_vue = vue-3,
  10291. amelio_att = att-3,
  10292. amelio_esq = esq-3,
  10293. amelio_deg = deg-3,
  10294. amelio_reg = reg-1,
  10295. amelio_arm = arm-1;
  10296. if(race==="Darkling"){amelio_reg--; }
  10297. if(race==="Durakuir"){amelio_pv-- ; }
  10298. if(race==="Kastar") {amelio_deg--; }
  10299. if(race==="Skrim") {amelio_att--; }
  10300. if(race==="Tomawak") {amelio_vue--; }
  10301.  
  10302. urlAnatrolliseur = URL_AnatrolDispas
  10303. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10304. +"|r="+race.toLowerCase()
  10305. +"|dla="+amelio_dtb(dtb)
  10306. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10307. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10308. +"|att="+amelio_att+","+attbp+","+attbm
  10309. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10310. +"|deg="+amelio_deg+","+degbp+","+degbm
  10311. +"|reg="+amelio_reg+","+regbp+","+regbm
  10312. +"|arm="+amelio_arm+","+armbp+","+armbm
  10313. +"|mm="+mmtotale
  10314. +"|rm="+rmtotale+"|";
  10315. }
  10316.  
  10317. function saveProfil() {
  10318. MY_setValue(idtroll+'.caracs.attaque',att);
  10319. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10320. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10321. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10322. if(atttourD||atttourP||atttourM) {
  10323. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10324. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10325. }
  10326. MY_setValue(idtroll+'.caracs.esquive',esq);
  10327. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10328. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10329. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10330. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10331. MY_setValue(idtroll+'.caracs.degats',deg);
  10332. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10333. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10334. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10335. if(degtourP||degtourM){
  10336. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10337. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10338. }
  10339. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10340. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10341. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10342. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10343. MY_setValue(idtroll+'.caracs.vue',vue);
  10344. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10345. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10346. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10347. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10348. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10349. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10350. MY_setValue(idtroll+'.caracs.rm',rm);
  10351. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10352. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10353. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10354. MY_setValue(idtroll+'.caracs.mm',mm);
  10355. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10356. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10357. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10358. MY_setValue(idtroll+'.caracs.armure',arm);
  10359. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10360. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10361. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10362. MY_setValue(idtroll+'.position.X',posX);
  10363. MY_setValue(idtroll+'.position.Y',posY);
  10364. MY_setValue(idtroll+'.position.N',posN);
  10365. MY_setValue(idtroll+'.race',race);
  10366. MY_setValue(idtroll+'.niveau',niv);
  10367. MY_setValue(idtroll+'.idguilde',idguilde);
  10368. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10369. }
  10370.  
  10371.  
  10372. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10373.  
  10374. function setInfosCaracteristiques() {
  10375. // Modification de l'entete
  10376. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10377. thTotal.innerHTML+='|<i>Moyenne</i>';
  10378. thTotal.title="Moyenne (Moyenne ce tour)";
  10379.  
  10380. // Ajout des informations calculees
  10381. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10382. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10383. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10384.  
  10385. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10386. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10387. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10388.  
  10389. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10390. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10391. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10392.  
  10393. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10394. var tdRegTotal = trRegeneration.children[5];
  10395. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10396. // Temps recupere par reg (propale R')
  10397. var regmoyTemp = Math.max(0, regmoy);
  10398. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10399. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10400. if (sec != 0) {
  10401. regTitle += " " + sec + " sec";
  10402. }
  10403. trRegeneration.title = regTitle;
  10404.  
  10405. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  10406. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  10407. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  10408.  
  10409. var trRM=document.querySelector("table#caracs #rm").parentElement;
  10410. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  10411. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  10412.  
  10413.  
  10414. var trMM=document.querySelector("table#caracs #mm").parentElement;
  10415. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  10416. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  10417.  
  10418. var tdRefl=document.querySelector("#refl");
  10419. // TODO : prendre en compte bonus/malus D esq du tour ?
  10420. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  10421. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  10422. }
  10423.  
  10424. function setLienAnatrolliseur(){
  10425. var pTableAmelio = document.querySelector("#carac>div>p");
  10426. pTableAmelio.innerHTML+=" - ";
  10427. var aElt = document.createElement("a");
  10428. aElt.setAttribute("href",urlAnatrolliseur);
  10429. aElt.setAttribute("target","_blank");
  10430. aElt.className="AllLinks";
  10431. aElt.innerHTML="Anatrolliser";
  10432. pTableAmelio.appendChild(aElt);
  10433. }
  10434. function setInfoDescription() {
  10435. var txtDateCrea = (NBjours!=1) ?
  10436. " ("+NBjours+" jours dans le hall)" :
  10437. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  10438. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  10439. }
  10440.  
  10441. function setInfosEtatLieux() {
  10442. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  10443. '?search=position&orderBy=distance&posx='+
  10444. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  10445. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  10446. appendBr(tdPosition);
  10447. var aElt = document.createElement("a");
  10448. aElt.setAttribute("href",urlBricol);
  10449. aElt.setAttribute("target","_blank");
  10450. aElt.className="AllLinks";
  10451. aElt.innerHTML="Lieux à proximité";
  10452. tdPosition.appendChild(aElt);
  10453. }
  10454.  
  10455. function setInfosEtatPV() { // pour AM et Sacro
  10456. var
  10457. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  10458. sec = Math.floor(15000/pvtotal)%60,
  10459. lifebar = document.querySelector("#pos .barre-vie");
  10460. if(sec!=0) { txt += " "+sec+" sec"; }
  10461. if(lifebar) { lifebar.title = txt; }
  10462. if(pvcourant<=0) { return; }
  10463. // Difference PV p/r a equilibre de temps (propale R')
  10464. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  10465. // ***INIT GLOBALE*** pvdispo
  10466. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10467. var span = document.createElement("span");
  10468. span.title = txt;
  10469. span.style.fontStyle = "italic";
  10470. if(bmt+pdm>=0) {
  10471. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  10472. } else if(pvdispo>0) {
  10473. txt = "Vous pouvez encore perdre "+
  10474. Math.min(pvdispo,pvcourant)+
  10475. " PV sans malus de temps.";
  10476. } else if(pvdispo<0) {
  10477. txt = "Il vous manque "
  10478. +(-pvdispo)
  10479. +" PV pour ne plus avoir de malus de temps.";
  10480. } else {
  10481. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  10482. }
  10483. appendText(span,txt);
  10484. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  10485. }
  10486.  
  10487. // Complete le cadre "Experience"
  10488. function setInfosExp() {
  10489. var tdNiv = document.querySelector("#exp #niv");
  10490.  
  10491. // Calcul niveau monstre/troll min pour gain PX
  10492. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  10493. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  10494.  
  10495. // Calcul PX restant
  10496. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  10497. if (pxRestant >= 0) {
  10498. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  10499. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  10500. }
  10501.  
  10502. // Calul pi/jour
  10503. var
  10504. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  10505. tdPi = document.querySelector("#exp #pi").parentElement;
  10506. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  10507. tdPi.title = tdPiTotal.title;
  10508.  
  10509. // Rapports meurtres,morts
  10510. var tdKill = document.querySelector("#exp #kill");
  10511. tdKill.setAttribute("colspan", 1);
  10512. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  10513.  
  10514. var tdMort = document.querySelector("#exp #mort");
  10515. tdMort.setAttribute("colspan", 1);
  10516. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  10517.  
  10518. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  10519. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  10520. }
  10521.  
  10522.  
  10523. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  10524.  
  10525. function minParPVsac(fat,bm) {
  10526. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  10527. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  10528. var out = [];
  10529. out[0] = (fat>4) ?
  10530. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  10531. 30;
  10532. if(bm && bm>0) {
  10533. var totalfat=fat+bm;
  10534. out[1] = (totalfat>4) ?
  10535. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  10536. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  10537. }
  10538. return out;
  10539. }
  10540.  
  10541. function toInt(str) {
  10542. str = parseInt(str);
  10543. return (str) ? str : 0;
  10544. }
  10545.  
  10546. function saveLastDLA() {
  10547. // pour les calculs d'AM max
  10548. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  10549. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  10550. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  10551. lastDLA = new Date( StringToDate(str) );
  10552. MY_setValue(numTroll+'.DLA.ancienne',str);
  10553. lastDLAZone.innerHTML = '';
  10554. var b = document.createElement('b');
  10555. b.addEventListener('click',inputMode,false);
  10556. appendText(b,str);
  10557. lastDLAZone.appendChild(b);
  10558. refreshAccel();
  10559. }
  10560.  
  10561. function inputMode() {
  10562. // Edition manuelle lastDLA
  10563. var date;
  10564. if(lastDLA)
  10565. date = new Date( lastDLA );
  10566. else
  10567. date = new Date( DLAaccel );
  10568. lastDLAZone.innerHTML = '';
  10569. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  10570. appendText(lastDLAZone,'/');
  10571. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  10572. appendText(lastDLAZone,'/');
  10573. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  10574. appendText(lastDLAZone,' - ');
  10575. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  10576. appendText(lastDLAZone,':');
  10577. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  10578. appendText(lastDLAZone,':');
  10579. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  10580. appendText(lastDLAZone,' - ');
  10581. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  10582. }
  10583.  
  10584. function setAccel() {
  10585. var
  10586. BMfrais=false,
  10587. fat=fatigue, listeBmFat=[],
  10588. tr, th, insertPt;
  10589.  
  10590. // Creation ligne speciale pour AM dans le cadre "Etat"
  10591. tr = document.createElement('tr');
  10592. th = document.createElement('th');
  10593. appendText(th,'Fatigue et AM',true);
  10594. tr.appendChild(th);
  10595. insertPt = document.createElement('td');
  10596. tr.appendChild(insertPt);
  10597. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  10598.  
  10599. // Est-on en over-DLA ?
  10600. // ***INIT GLOBALE*** overDLA
  10601. overDLA = (HeureServeur>DLA.getTime()+3e5);
  10602. if(overDLA) {
  10603. fat=Math.floor(fatigue/1.25);
  10604. }
  10605.  
  10606. // Gestion des BM de fatigue
  10607. if(bmfatigue>0) {
  10608. // On tente de recuperer les BM de fatigue de la page des BM
  10609. if(MY_getValue(numTroll+'.bm.fatigue')) {
  10610. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  10611. BMmemoire.pop();
  10612. var tour = 0;
  10613. for(var i=0 ; i<BMmemoire.length ; i++) {
  10614. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  10615. while(tour<=parseInt(nbrs[0])) {
  10616. listeBmFat[tour]=parseInt(nbrs[1]);
  10617. tour++;
  10618. }
  10619. }
  10620. }
  10621. if(listeBmFat[0]==bmfatigue) {
  10622. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  10623. BMfrais = true;
  10624. MY_removeValue(numTroll+".bm.fatigue");
  10625. }
  10626. } else {
  10627. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  10628. BMfrais = true;
  10629. }
  10630. if(!BMfrais && bmfatigue>0) {
  10631. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  10632. if(bmfatigue==15) {
  10633. listeBmFat = [15,15,15];
  10634. } else {
  10635. listeBmFat = [30,30,15];
  10636. }
  10637. }
  10638. if(overDLA) {
  10639. // Si on est en over-DLA, on decale les bm d'un tour
  10640. listeBmFat.shift();
  10641. }
  10642. // Tableau des fatigues et accel futures
  10643. var
  10644. minppv = minParPVsac(fat,listeBmFat[0]),
  10645. table, tbody,
  10646. ligneTour, ligneFat, ligneMin,
  10647. col;
  10648. // ***INIT GLOBALE*** minParPV
  10649. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10650. if(fat>0 || listeBmFat[0]>0) {
  10651. table = document.createElement('table');
  10652. table.className = 'mh_tdborder';
  10653. table.border = 0;
  10654. table.cellSpacing = 1;
  10655. table.cellPadding = 1;
  10656. table.style.textAlign = "center";
  10657. tbody = document.createElement('tbody');
  10658. table.appendChild(tbody);
  10659. insertPt.appendChild(table);
  10660. ligneTour = appendTr(tbody,'mh_tdtitre');
  10661. ligneTour.style.fontWeight = "bold";
  10662. var td = appendTdText(ligneTour,'Tour :',true);
  10663. td.align = 'left';
  10664. ligneFat = appendTr(tbody,'mh_tdpage');
  10665. td = appendTdText(ligneFat,'Fatigue :',true);
  10666. td.className = 'mh_tdtitre';
  10667. td.align = 'left';
  10668. ligneMin = appendTr(tbody,'mh_tdpage');
  10669. td = appendTdText(ligneMin,'1 PV =',true);
  10670. td.className = 'mh_tdtitre';
  10671. td.align = 'left';
  10672. col=0;
  10673. while(col<9 && (fat>0 || listeBmFat[col])) {
  10674. if(col==0) {
  10675. if(overDLA) {
  10676. var i = document.createElement('i');
  10677. appendText(i,'A activer');
  10678. ligneTour.appendChild(i);
  10679. } else {
  10680. appendTdText(ligneTour,'En cours');
  10681. }
  10682. } else {
  10683. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10684. }
  10685. if(listeBmFat[col]) {
  10686. if(BMfrais || (!overDLA && col==0)) {
  10687. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10688. appendTdText(ligneMin,minppv[1]+'\'');
  10689. } else {
  10690. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10691. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10692. }
  10693. } else {
  10694. appendTdText(ligneFat,fat);
  10695. appendTdText(ligneMin,minppv[0]+'\'');
  10696. }
  10697. col++;
  10698. fat = Math.floor(fat / 1.25);
  10699. minppv = minParPVsac(fat,listeBmFat[col]);
  10700. }
  10701. if(fat>1 || (fat==1 && !overDLA)) {
  10702. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10703. appendTdText(ligneFat,'-');
  10704. appendTdText(ligneMin,'-');
  10705. }
  10706. col = (overDLA) ?
  10707. Math.max(retourAZero(fatigue)-1,col) :
  10708. Math.max(retourAZero(fatigue),col);
  10709. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10710. appendTdText(ligneFat,'0');
  10711. appendTdText(ligneMin,'30\'');
  10712. if(!BMfrais && bmfatigue) {
  10713. // si les BM n'ont pas ete rafraichis, on signale:
  10714. appendText(
  10715. insertPt,
  10716. '/!\\ Visitez la page des Bonus/Malus '+
  10717. 'pour mettre à jour votre fatigue. /!\\',
  10718. true
  10719. );
  10720. appendBr(insertPt);
  10721. }
  10722. appendBr(insertPt);
  10723. }
  10724. if(pvcourant<=0) {
  10725. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10726. return;
  10727. }
  10728. if(fatigue>30) {
  10729. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10730. return;
  10731. }
  10732. // Setup lastDLAZone
  10733. if(overDLA) {
  10734. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10735. DLAaccel = new Date( DLAsuiv );
  10736. lastDLA = new Date( DLA );
  10737. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10738. // ***INIT GLOBALE*** pvActuelKastar
  10739. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10740. appendText(
  10741. insertPt,
  10742. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10743. true
  10744. );
  10745. appendBr(insertPt);
  10746. } else {
  10747. DLAaccel = new Date( DLA );
  10748. pvActuelKastar = pvcourant;
  10749. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10750. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10751. } else {
  10752. lastDLA = false;
  10753. }
  10754. }
  10755. appendText(insertPt,'Dernière DLA enregistrée : ');
  10756. lastDLAZone = document.createElement('span');
  10757. lastDLAZone.style.cursor = 'pointer';
  10758. var b = document.createElement('b');
  10759. b.onclick = inputMode;
  10760. lastDLAZone.appendChild(b);
  10761. insertPt.appendChild(lastDLAZone);
  10762. if(lastDLA) {
  10763. appendText(b,DateToString(lastDLA));
  10764. } else {
  10765. appendText(b,'aucune');
  10766. }
  10767. appendBr(insertPt);
  10768. // Setup maxAMZone et cumulZone
  10769. appendText(insertPt,'Accélération maximale possible : ');
  10770. maxAMZone = document.createElement('b');
  10771. insertPt.appendChild(maxAMZone);
  10772. appendBr(insertPt);
  10773. cumulZone = document.createElement('span');
  10774. insertPt.appendChild(cumulZone);
  10775. refreshAccel();
  10776. }
  10777.  
  10778. function refreshAccel() {
  10779. var pvs, pvsmax;
  10780. // Acceleration pour cumul instantane
  10781. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10782. if(lastDLA) {
  10783. pvsmax = Math.min(
  10784. pvActuelKastar-1,
  10785. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10786. );
  10787. maxAMZone.innerHTML = pvsmax+" PV";
  10788. } else {
  10789. pvsmax = pvActuelKastar-1;
  10790. maxAMZone.innerHTML = "inconnue";
  10791. }
  10792. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10793. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10794. cumulZone.innerHTML = '';
  10795. if(pvs<=pvsmax) {
  10796. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10797. appendText(cumulZone,pvs+' PV', true);
  10798. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10799. if(pvs!=1) {
  10800. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10801. -(pvs-1)*60*minParPV;
  10802. appendText(
  10803. cumulZone,
  10804. ' ('+(pvs-1)+' PV dans '+
  10805. Math.floor(gainSec/60)+'min'+
  10806. addZero(gainSec%60)+'s)'
  10807. );
  10808. }
  10809. } else {
  10810. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10811. appendText(
  10812. cumulZone,
  10813. 'Après votre accélération maximale, il vous faudra encore attendre '+
  10814. dureeHM(avantDLA/6e4)+
  10815. ' avant de réactiver.'
  10816. );
  10817. }
  10818. }
  10819.  
  10820.  
  10821. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  10822.  
  10823. function traitementTalents() {
  10824. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  10825. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  10826. removeAllTalents();
  10827. var totalComp = injecteInfosBulles(trCompetence,'competences');
  10828. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  10829. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  10830. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  10831. }
  10832.  
  10833. function injecteInfosBulles(liste,fonction) {
  10834. var totalpc = 0;
  10835. // on parse la liste des talents du type 'fonction'
  10836. for(var i=0 ; i<liste.length ; i++) {
  10837. var
  10838. trTalent=liste[i],
  10839. node=trTalent.cells[1].querySelector('a'),
  10840. nomTalent=epure(trim(node.textContent)),
  10841. indiceTDniveaux=7,
  10842. indiceTDSousCompetence=2,
  10843. sousCompetences=undefined;
  10844. if(fonction=="competences"){
  10845. // un TD en plus pour des information complementaire liees a la comp
  10846. indiceTDniveaux++;
  10847. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  10848. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  10849. for (var j=0; j < sousCompetences.length; j++) {
  10850. sousCompetences[j] = sousCompetences[j].epure().trim();
  10851. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  10852. }
  10853. }
  10854. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  10855. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  10856. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  10857. totalpc += niveauxMaitrisesTalentArray[1];
  10858.  
  10859. // stockage des niveaux inferieurs du talent si presents
  10860. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  10861. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  10862. totalpc+=niveauxMaitrisesTalentArray[j+1];
  10863. }
  10864. }
  10865. return totalpc;
  10866. }
  10867.  
  10868. function setInfos(node,nom,fonction,niveau) {
  10869. node.nom = nom;
  10870. node.fonction = fonction;
  10871. node.niveau = niveau;
  10872. node.onmouseover = setBulle;
  10873. node.onmouseout = cacherBulle;
  10874. }
  10875.  
  10876. var arrayModifAnatroll = {
  10877. 'Glue':'Glu',
  10878. 'PuM':'PuiM',
  10879. 'HE':'Hurlement',
  10880. //'Insultes':'Insu',
  10881. 'Pistage':'Pist',
  10882. 'PuC':'Planter'
  10883. }
  10884.  
  10885. function setTalent(nom,pc,niveau,sousCompetences) {
  10886. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  10887. // (et pas les % dont osf) ne serait pas plus rentable
  10888. var nomEnBase = arrayTalents[epure(nom)];
  10889. if(!nomEnBase) { return; }
  10890. if(!niveau) { niveau = 1; }
  10891. switch(nomEnBase) {
  10892. case 'Insultes':
  10893. urlAnatrolliseur += 'Insu'+niveau+'|';
  10894. case 'IdT':
  10895. nomEnBase += niveau;
  10896. break;
  10897. case 'Golemo':
  10898. case 'Piege':
  10899. for (var i=0 ; i < sousCompetences.length ; i++) {
  10900. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  10901. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  10902. }
  10903. break;
  10904. case 'AP':
  10905. case 'Baroufle':
  10906. case 'CdB':
  10907. case 'CdM':
  10908. case 'Parer':
  10909. case 'Retraite':
  10910. case 'RB':
  10911. case 'SInterposer':
  10912. nomEnBase += niveau;
  10913. default:
  10914. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  10915. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  10916. }
  10917. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  10918. }
  10919.  
  10920. function creerBulleVide() {
  10921. var table = document.createElement('table');
  10922. table.id = 'bulle';
  10923. table.className = 'mh_tdborder';
  10924. table.width = 300;
  10925. table.border = 0;
  10926. table.cellPadding = 5;
  10927. table.cellSpacing = 1;
  10928. table.style =
  10929. 'position:absolute;'
  10930. +'visibility:hidden;'
  10931. +'z-index:800;'
  10932. +'height:auto;';
  10933. var tr = appendTr(table,'mh_tdtitre');
  10934. appendTdText(tr,'Titre');
  10935. tr = appendTr(table,'mh_tdpage');
  10936. appendTdText(tr,'Contenu');
  10937. var aList = document.getElementsByTagName('a');
  10938. aList[aList.length-1].parentNode.appendChild(table);
  10939. }
  10940.  
  10941. function cacherBulle() {
  10942. if(bulleStyle)
  10943. bulleStyle.visibility = 'hidden';
  10944. }
  10945.  
  10946. function setBulle(evt) {
  10947. var nom = this.nom;
  10948. var fonction = this.fonction;
  10949. var niveau = parseInt(this.niveau);
  10950. var str='';
  10951. if(fonction=='competences'){
  10952. str=competences(nom,niveau);
  10953. } else if(fonction=='sortileges') {
  10954. str=sortileges(nom,true);
  10955. }
  10956. if(str=='') return;
  10957. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  10958. var xfenetre, yfenetre, xpage, ypage, element = null;
  10959. var offset = 15;
  10960. var bulleWidth = 300;
  10961. if(!hauteur) hauteur = 50;
  10962. element = document.getElementById('bulle');
  10963. xfenetre = evt.clientX;
  10964. yfenetre = evt.clientY;
  10965. xpage = xfenetre;
  10966. ypage = yfenetre;
  10967. if(evt.pageX) xpage = evt.pageX;
  10968. if(evt.pageY) ypage = evt.pageY;
  10969. if(element) {
  10970. bulleStyle = element.style;
  10971. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  10972. element.childNodes[1].firstChild.innerHTML = str;
  10973. }
  10974. if(bulleStyle) {
  10975. if(xfenetre>bulleWidth+offset)
  10976. xpage -= bulleWidth+offset;
  10977. else
  10978. xpage += offset;
  10979. if(yfenetre>hauteur+offset)
  10980. ypage -= hauteur + offset;
  10981. bulleStyle.width = bulleWidth;
  10982. bulleStyle.left = xpage + 'px';
  10983. bulleStyle.top = ypage + 'px';
  10984. bulleStyle.visibility = 'visible';
  10985. }
  10986. }
  10987.  
  10988.  
  10989. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  10990.  
  10991. function competences(comp,niveau) {
  10992. var texte = '';
  10993. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  10994. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  10995. if(minParPV>1) texte += 's';
  10996. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  10997. }
  10998. else if(comp.indexOf('Attaque Precise')!=-1) {
  10999. var pc, lastmax=0, espatt=0;
  11000. var notMaxedOut = false;
  11001. for(var i=niveau ; i>0 ; i--) {
  11002. pc = getTalent(comp,i);
  11003. if(lastmax!=0 && pc<=lastmax) continue;
  11004. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11005. attbp+attbm;
  11006. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11007. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11008. ' => <b>'+jetatt+'</b><br/>';
  11009. espatt += (pc-lastmax)*jetatt;
  11010. lastmax = pc;
  11011. if(i<niveau) notMaxedOut = true;
  11012. }
  11013. if(notMaxedOut) {
  11014. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11015. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11016. }
  11017. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11018. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11019. }
  11020. else if(comp.indexOf('Balayage')!=-1)
  11021. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11022. +' => <b>'+attmoy+'</b><br/>'
  11023. +'Effet : <b>Met à terre l\'adversaire</b>';
  11024. else if(comp.indexOf('Bidouille')!=-1)
  11025. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11026. +'de votre inventaire avec le texte de votre choix.';
  11027. else if(comp.indexOf('Baroufle')!=-1){
  11028. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11029. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11030. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11031. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11032. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11033. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11034. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11035. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11036. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11037. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11038. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11039. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11040. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11041. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11042. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11043. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11044. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11045. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11046. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11047. '</tbody></table>';
  11048. }
  11049. else if(comp.indexOf('Botte Secrete')!=-1){
  11050. texte = 'Attaque : <b>'
  11051. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11052. +' => <b>'
  11053. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  11054. +'</b><br/>Dégâts : <b>'
  11055. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  11056. +' => <b>'
  11057. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  11058. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  11059. +'</b>';
  11060. }
  11061. else if(comp.indexOf('Camouflage')!=-1) {
  11062. var camou = getTalent('Camouflage');
  11063. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  11064. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  11065. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  11066. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  11067. }
  11068. else if(comp.indexOf('Charger')!=-1) {
  11069. if(pvcourant<=0)
  11070. return '<i>On ne peut charger personne quand on est mort !</i>';
  11071. var portee = Math.min(
  11072. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  11073. vuetotale);
  11074. if(portee<1)
  11075. return '<b>Impossible de charger</b>';
  11076. else {
  11077. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11078. +' => <b>'+attmoy+'</b><br/>'
  11079. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11080. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  11081. +'<br/>Portée : <b>'+portee+'</b> case';
  11082. if(portee>1) texte += 's';
  11083. }
  11084. }
  11085. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  11086. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  11087. if(vuetotale>1) texte += 's';
  11088. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11089. if(vuetotale>2) texte += 's';
  11090. }
  11091. else if(comp.indexOf('Piege')!=-1) {
  11092. if(comp.indexOf('Glue')!=-1)
  11093. texte = 'Et si vous colliez vos adversaires au sol ?';
  11094. if(comp.indexOf('Feu')!=-1) {
  11095. if(texte){
  11096. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  11097. }
  11098. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  11099. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  11100. }
  11101. }
  11102. else if(comp.indexOf('Contre-Attaquer')!=-1){
  11103. texte = 'Attaque : <b>'
  11104. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11105. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11106. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11107. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11108. }
  11109. else if(comp.indexOf('Coup de Butoir')!=-1) {
  11110. var pc, lastmax=0, espdeg=0;
  11111. var notMaxedOut = false;
  11112. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11113. +' => <b>'+attmoy+'</b>';
  11114. for(var i=niveau ; i>0 ; i--) {
  11115. pc = getTalent(comp,i);
  11116. if(lastmax!=0 && pc<=lastmax) continue;
  11117. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  11118. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11119. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  11120. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  11121. espdeg += (pc-lastmax)*jetdeg;
  11122. lastmax = pc;
  11123. if(i<niveau) notMaxedOut = true;
  11124. }
  11125. if(notMaxedOut) {
  11126. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  11127. Math.floor(10*espdeg/lastmax)/10+'/'+
  11128. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  11129. }
  11130. }
  11131. else if(comp.indexOf('Course')!=-1)
  11132. texte = 'Déplacement gratuit : <b>'
  11133. +Math.floor(getTalent('Course')/2)
  11134. +' %</b> de chance';
  11135. else if(comp.indexOf('Deplacement Eclair')!=-1)
  11136. texte = 'Permet d\'économiser <b>1</b> PA '
  11137. +'par rapport au déplacement classique';
  11138. else if(comp.indexOf('Dressage')!=-1)
  11139. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  11140. +'ou un gnu sauvage.';
  11141. else if(comp.indexOf('Ecriture Magique')!=-1)
  11142. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  11143. +'la formule nécessite de réunir les composants de cette formule, '
  11144. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  11145. +'un champignon adéquat pour confectionner l\'encre.';
  11146. else if(comp.indexOf('Frenesie')!=-1) {
  11147. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11148. +' => <b>'+attmoy+'</b><br/>'
  11149. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11150. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11151. }
  11152. else if(comp.indexOf('Golem')!=-1)
  11153. texte = 'Animez votre golem en assemblant divers matériaux '
  11154. +'autour d\'un cerveau minéral.'
  11155. else if(comp.indexOf('Grattage')!=-1) {
  11156. texte = 'Permet de confectionner un Parchemin Vierge '
  11157. +'à partir de composants et de Gigots de Gob\'.';
  11158. }
  11159. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  11160. texte = 'Fait fuir un monstre si tout se passe bien.'
  11161. +'<br/>Lui donne de gros bonus sinon...';
  11162. else if(comp.indexOf('Identification des Champignons')!=-1) {
  11163. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11164. if(vuetotale>2) texte += 's';
  11165. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  11166. if(vuetotale>4) texte += 's';
  11167. }
  11168. else if(comp.indexOf('Insultes')!=-1)
  11169. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  11170. else if(comp.indexOf('interposer')!=-1)
  11171. texte = 'Jet de réflexe : <b>'
  11172. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  11173. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  11174. else if(comp.indexOf('Lancer de Potions') != -1)
  11175. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  11176. else if(comp.indexOf('Marquage')!=-1)
  11177. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  11178. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  11179. +'se trouver dans la même caverne que le monstre pour le marquer.';
  11180. else if(comp.indexOf('Melange Magique')!=-1)
  11181. texte = 'Cette Compétence permet de combiner deux Potions pour '
  11182. +'en réaliser une nouvelle dont l\'effet est la somme '
  11183. +'des effets des potions initiales.';
  11184. else if(comp.indexOf('Miner')!=-1)
  11185. texte = 'Portée horizontale (officieuse) : <b>'
  11186. +2*vuetotale+'</b> cases<br/>'
  11187. +'Portée verticale (officieuse) : <b>'
  11188. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11189. else if(comp.indexOf('Necromancie')!=-1)
  11190. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  11191. +'de faire "revivre" ce monstre.';
  11192. else if(comp.indexOf('Painthure de Guerre')!=-1)
  11193. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  11194. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  11195. +'pour s\'inspirer, et laissez parler votre créativité.'
  11196. else if(comp.indexOf('Parer')!=-1)
  11197. texte = 'Jet de parade : <b>'
  11198. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  11199. +' => <b>'
  11200. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11201. +'</b><hr><i>Equivalent esquive : <b>'
  11202. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  11203. +' => <b>'
  11204. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  11205. +'</b></i>';
  11206. else if(comp.indexOf('Pistage')!=-1)
  11207. texte = 'Portée horizontale : <b>'
  11208. +2*vuetotale+'</b> cases<br/>'
  11209. +'Portée verticale : <b>'
  11210. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11211. else if(comp.indexOf('Planter un Champignon')!=-1)
  11212. texte = 'Planter un Champignon est une compétence qui vous permet de '
  11213. +'créer des colonies d\'une variété donnée de champignon à partir de '
  11214. +'quelques exemplaires préalablement enterrés.';
  11215. else if(comp.indexOf('Regeneration Accrue')!=-1)
  11216. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  11217. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  11218. else if(comp.indexOf('Reparation')!=-1)
  11219. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  11220. +'et réparez vous-même votre matériel !';
  11221. else if(comp.indexOf('Retraite')!=-1)
  11222. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  11223. +'préférable de préparer un repli stratégique pour déconcerter '
  11224. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  11225. +'Quelle intelligence démoniaque.';
  11226. else if(comp.indexOf('Rotobaffe')!=-1) {
  11227. var Datt = att, vattbm = attbp+attbm;
  11228. var Ddeg = deg, vdegbm = degbp+degbm;
  11229. for(var i=1 ; i<niveau+2 ; i++) {
  11230. texte += '<b>Attaque n°'+i+' :</b><br/>'
  11231. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  11232. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  11233. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  11234. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  11235. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  11236. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  11237. if(i<niveau+1) texte += '<hr>';
  11238. }
  11239. }
  11240. else if(comp.indexOf('Shamaner')!=-1)
  11241. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  11242. +'des monstres en utilisant des champignons (de 1 à 3).';
  11243. else if(comp.indexOf('Tailler')!=-1){
  11244. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11245. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11246. }
  11247. return texte;
  11248. }
  11249.  
  11250. function decumul_buff(nom,str,buff) {
  11251. // Decumul des sorts de buff
  11252. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11253. var dec = buff, total = buff, i=1;
  11254. while(i<6) {
  11255. i++;
  11256. dec = Math.floor(coefDecumul(i)*buff);
  11257. if(dec<=1 || i==6) break;
  11258. total += dec;
  11259. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11260. +str+' +'+dec+' (+'+total+')</i>';
  11261. }
  11262. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11263. return ret;
  11264. }
  11265.  
  11266.  
  11267. function sortileges(sort,mainCall,pcA,pcD) {
  11268. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11269. var texte = '';
  11270. if (mainCall) {
  11271. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11272. pcA = (atttourP+atttourM);
  11273. pcD = (degtourP+degtourM);
  11274. }
  11275. if (sort.indexOf('Analyse Anatomique') != -1) {
  11276. texte = 'Portée horizontale : <b>'
  11277. + Math.floor(vuetotale / 2) + '</b> case';
  11278. if (vuetotale > 3){ texte += 's'; }
  11279. texte += '<br/>Portée verticale : <b>'
  11280. + Math.floor((vuetotale+1)/4)+'</b> case';
  11281. if (vuetotale > 7){ texte += 's'; }
  11282. }
  11283. else if (sort.indexOf('Armure Etheree') != -1){
  11284. texte = decumul_buff('AE', 'Armure magique', reg);
  11285. }
  11286. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11287. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11288. }
  11289. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11290. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11291. }
  11292. else if (sort.indexOf('Augmentation des Degats') != -1){
  11293. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11294. }
  11295. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11296. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11297. }
  11298. else if(sort.indexOf('Bulle Magique')!=-1){
  11299. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11300. }
  11301. else if(sort.indexOf('Explosion')!=-1){
  11302. texte = 'Dégâts : <b>'
  11303. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11304. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11305. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11306. }
  11307. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11308. if(pvcourant<=0)
  11309. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11310. texte = 'Portée horizontale : <b>'
  11311. +Math.min(1,vuetotale)+'</b> case<br/>'
  11312. +'Dégâts physiques : <b>-'
  11313. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11314. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11315. +'Dégâts magiques : <b>-'
  11316. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11317. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11318. }
  11319. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11320. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11321. }
  11322. else if(sort.indexOf('Glue')!=-1) {
  11323. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11324. if(vuetotale>2) texte += 's';
  11325. }
  11326. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11327. /* Frappe */
  11328. var modD = 0;
  11329. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11330. if(pcA!=0){
  11331. modD = parseInt(att*pcA/100);
  11332. texte += '<i>'+aff(modD)+'D6</i> ';
  11333. }
  11334. texte += aff(attbm)
  11335. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11336. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11337. if(pcD!=0) {
  11338. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11339. texte += '<i>'+aff(modD)+'D3</i> ';
  11340. }else
  11341. modD = 0;
  11342. texte += aff(degbm)+' => <b>'
  11343. +(2*(Math.floor(deg/2)+modD)+degbm)
  11344. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11345. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11346. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11347. +')</b>';
  11348. if(!mainCall) return texte;
  11349. /* Venins */
  11350. function addVenin(type,effet,duree) {
  11351. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11352. +' pendant <b>'+duree+'</b> tour';
  11353. if(duree>1) ret += 's';
  11354. var dred = Math.max(Math.floor(duree/2),1);
  11355. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11356. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11357. }
  11358. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11359. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11360. effet = Math.floor(1.5*effet);
  11361. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11362. }
  11363. else if(sort.indexOf('Hypnotisme')!=-1)
  11364. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11365. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11366. else if(sort.indexOf('Identification des tresors')!=-1)
  11367. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11368. +'d\'un trésor.';
  11369. else if(sort.indexOf('Invisibilite')!=-1)
  11370. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11371. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11372. +'fait disparaître l\'invisibilité.';
  11373. else if(sort.indexOf('Levitation')!=-1)
  11374. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11375. +'Comme les pièges ou les trous par exemple...';
  11376. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11377. var eps = 1,
  11378. pc = 20;
  11379. var str = 'PréM';
  11380. var newSort;
  11381. var sortAtt = [
  11382. 'Projectile Magique',
  11383. 'Rafale Psychique',
  11384. 'Siphon des Ames',
  11385. 'Vampirisme',
  11386. 'Griffe du Sorcier'
  11387. ];
  11388. if(sort.indexOf('Puissance')!=-1) {
  11389. eps = -1; str='PuM';
  11390. }
  11391. for(var i=1 ; i<4 ; i++) {
  11392. if(texte) { texte += '<hr>'; }
  11393. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11394. newSort = false;
  11395. for(var j=0 ; j<sortAtt.length ; j++) {
  11396. if(getTalent(sortAtt[j])) {
  11397. if(newSort) { texte += '<br/><br/>'; }
  11398. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  11399. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  11400. newSort = true;
  11401. }
  11402. }
  11403. pc = decumulPumPrem(pc);
  11404. }
  11405. }
  11406. else if(sort.indexOf('Projectile Magique')!=-1) {
  11407. var modD = 0;
  11408. var portee = getPortee__Profil(vuetotale);
  11409. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  11410. if(pcA!=0) {
  11411. modD = parseInt(vue*pcA/100);
  11412. texte += '<i>'+aff(modD)+'D6</i> ';
  11413. }
  11414. texte += aff(attbm)
  11415. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  11416. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  11417. if(pcD!=0) {
  11418. modD = parseInt(Math.floor(vue/2)+pcD);
  11419. texte += '<i>'+aff(modD)+'D3</i> ';
  11420. }else
  11421. modD = 0;
  11422. texte += aff(degbm)
  11423. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  11424. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  11425. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  11426. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  11427. if(!mainCall) return texte;
  11428. texte += '<br/>Portée : <b>'+portee+'</b> case';
  11429. if(portee>1) texte += 's';
  11430. }
  11431. else if(sort.indexOf('Projection')!=-1) {
  11432. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  11433. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  11434. +'Si le jet de résistance de la victime est réussi:<br/>'
  11435. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  11436. }
  11437. else if(sort.indexOf('Rafale Psychique')!=-1) {
  11438. var modD = 0;
  11439. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  11440. if(pcD!=0) {
  11441. modD = parseInt(deg*pcD/100);
  11442. texte += '<i>'+aff(modD)+'D3</i> ';
  11443. }
  11444. texte += aff(degbm)
  11445. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  11446. if(!mainCall) return texte;
  11447. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  11448. }
  11449. else if(sort.indexOf('Sacrifice')!=-1) {
  11450. if(pvcourant<=0)
  11451. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  11452.  
  11453. function perteSacro(sac) {
  11454. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  11455. }
  11456.  
  11457. var sac = Math.floor((pvcourant-1)/2);
  11458. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11459. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  11460. /* Sacros max et optimal sans malus (propale R') */
  11461. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11462. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  11463. if(sac>0)
  11464. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  11465. else
  11466. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  11467. /*if(sac>3) {
  11468. sac = 5*Math.floor((sac+1)/5)-1;
  11469. texte += '<br/>Soin optimal sans malus de temps : <b>'
  11470. +sac+'</b> PV'+perteSacro(sac);
  11471. }*/
  11472. }
  11473. else if(sort.indexOf('Siphon')!=-1) {
  11474. var modD = 0;
  11475. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11476. if(pcA!=0) {
  11477. modD = parseInt(att*pcA/100);
  11478. texte += '<i>'+aff(modD)+'D6</i> ';
  11479. }
  11480. texte += aff(attbm)
  11481. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  11482. +'Dégâts : <b>'+reg+'</b> D3 ';
  11483. if(pcD!=0) {
  11484. modD = parseInt(reg*pcD/100);
  11485. texte += '<i>'+aff(modD)+'D3</i> ';
  11486. }else
  11487. modD = 0;
  11488. texte += aff(degbm)
  11489. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  11490. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  11491. if(!mainCall) return texte;
  11492. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  11493. }
  11494. else if(sort.indexOf('Telekinesie')!=-1) {
  11495. texte = 'Portée horizontale :';
  11496. var vt = Math.floor(vuetotale/2)+2;
  11497. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  11498. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  11499. for(var i=0 ; i<5 ; i++) {
  11500. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  11501. if(vt>1) texte += 's';
  11502. vt=Math.max(0,vt-1);
  11503. }
  11504. }
  11505. else if(sort.indexOf('Teleportation')!=-1) {
  11506. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  11507. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  11508. var pmh = (20+vue+portee);
  11509. var pmv = 3+Math.floor(portee/3);
  11510. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  11511. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  11512. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  11513. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  11514. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  11515. }
  11516. else if(sort.indexOf('Vampirisme')!=-1) {
  11517. var modD = 0;
  11518. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  11519. if(pcA!=0) {
  11520. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  11521. texte += '<i>'+aff(modD)+'D6</i> ';
  11522. }
  11523. texte += aff(attbm)
  11524. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  11525. +'Dégâts : <b>'+deg+'</b> D3 ';
  11526. if(pcD!=0) {
  11527. modD = parseInt(deg*pcD/100);
  11528. texte += '<i>'+aff(modD)+'D3</i> ';
  11529. }else
  11530. modD = 0;
  11531. texte += aff(degbm)
  11532. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  11533. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  11534. }
  11535. else if(sort.indexOf('Vision Accrue')!=-1)
  11536. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  11537. else if(sort.indexOf('Vision lointaine')!=-1)
  11538. texte = 'En ciblant une zone située n\'importe où dans le '
  11539. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  11540. else if(sort.indexOf('Voir le Cache')!=-1)
  11541. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  11542. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  11543. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  11544. +getPortee__Profil(vuetotale)+'</b> cases';
  11545. else if(sort.indexOf('Vue Troublee')!=-1)
  11546. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11547. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  11548. return texte;
  11549. }
  11550.  
  11551.  
  11552. /*---------------------------------- Main ------------------------------------*/
  11553.  
  11554. function do_profil2()
  11555. {
  11556. try {
  11557. start_script(31);
  11558.  
  11559. extractionDonnees();
  11560. setInfosCaracteristiques();
  11561. setInfoDescription();
  11562. setInfosEtatLieux();
  11563. setInfosEtatPV();
  11564. setInfosExp();
  11565.  
  11566. creerBulleVide();
  11567. traitementTalents();
  11568. setLienAnatrolliseur();
  11569.  
  11570. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  11571. if(race=='Kastar'){ setAccel(); }
  11572. saveProfil();
  11573. displayScriptTime();
  11574. } catch(e) {
  11575. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  11576. window.console.error(traceStack(e, 'profil2'));
  11577. }
  11578. }
  11579.  
  11580. /*******************************************************************************
  11581. * This file is part of Mountyzilla. *
  11582. * *
  11583. * Mountyzilla is free software; you can redistribute it and/or modify *
  11584. * it under the terms of the GNU General Public License as published by *
  11585. * the Free Software Foundation; either version 2 of the License, or *
  11586. * (at your option) any later version. *
  11587. * *
  11588. * Mountyzilla is distributed in the hope that it will be useful, *
  11589. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11590. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11591. * GNU General Public License for more details. *
  11592. * *
  11593. * You should have received a copy of the GNU General Public License *
  11594. * along with Mountyzilla; if not, write to the Free Software *
  11595. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11596. *******************************************************************************/
  11597.  
  11598. // x~x script_principal
  11599.  
  11600. function isPage(url) {
  11601. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11602. }
  11603.  
  11604. // x~x md5.js
  11605. /*
  11606. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11607. * Digest Algorithm, as defined in RFC 1321.
  11608. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11609. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11610. * Distributed under the BSD License
  11611. * See http://pajhome.org.uk/crypt/md5 for more info.
  11612. */
  11613.  
  11614. /*
  11615. * Configurable variables. You may need to tweak these to be compatible with
  11616. * the server-side, but the defaults work in most cases.
  11617. */
  11618. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11619. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11620. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11621.  
  11622. /*
  11623. * These are the functions you'll usually want to call
  11624. * They take string arguments and return either hex or base-64 encoded strings
  11625. */
  11626. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11627. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11628. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11629. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11630. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11631. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11632.  
  11633. /*
  11634. * Perform a simple self-test to see if the VM is working
  11635. */
  11636. function md5_vm_test()
  11637. {
  11638. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11639. }
  11640.  
  11641. /*
  11642. * Calculate the MD5 of an array of little-endian words, and a bit length
  11643. */
  11644. function core_md5(x, len)
  11645. {
  11646. /* append padding */
  11647. x[len >> 5] |= 0x80 << ((len) % 32);
  11648. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11649.  
  11650. var a = 1732584193;
  11651. var b = -271733879;
  11652. var c = -1732584194;
  11653. var d = 271733878;
  11654.  
  11655. for(var i = 0; i < x.length; i += 16)
  11656. {
  11657. var olda = a;
  11658. var oldb = b;
  11659. var oldc = c;
  11660. var oldd = d;
  11661.  
  11662. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11663. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11664. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11665. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11666. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11667. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11668. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11669. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11670. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11671. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11672. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11673. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11674. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11675. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11676. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11677. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11678.  
  11679. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11680. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11681. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11682. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11683. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11684. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11685. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11686. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11687. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11688. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11689. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11690. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11691. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11692. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11693. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11694. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11695.  
  11696. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11697. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11698. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11699. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11700. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11701. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11702. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11703. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11704. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11705. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11706. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11707. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11708. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11709. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11710. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11711. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11712.  
  11713. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11714. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11715. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11716. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11717. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11718. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11719. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11720. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11721. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11722. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11723. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11724. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11725. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11726. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11727. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11728. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11729.  
  11730. a = safe_add(a, olda);
  11731. b = safe_add(b, oldb);
  11732. c = safe_add(c, oldc);
  11733. d = safe_add(d, oldd);
  11734. }
  11735. return Array(a, b, c, d);
  11736.  
  11737. }
  11738.  
  11739. /*
  11740. * These functions implement the four basic operations the algorithm uses.
  11741. */
  11742. function md5_cmn(q, a, b, x, s, t)
  11743. {
  11744. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11745. }
  11746. function md5_ff(a, b, c, d, x, s, t)
  11747. {
  11748. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11749. }
  11750. function md5_gg(a, b, c, d, x, s, t)
  11751. {
  11752. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11753. }
  11754. function md5_hh(a, b, c, d, x, s, t)
  11755. {
  11756. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11757. }
  11758. function md5_ii(a, b, c, d, x, s, t)
  11759. {
  11760. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11761. }
  11762.  
  11763. /*
  11764. * Calculate the HMAC-MD5, of a key and some data
  11765. */
  11766. function core_hmac_md5(key, data)
  11767. {
  11768. var bkey = str2binl(key);
  11769. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11770.  
  11771. var ipad = Array(16), opad = Array(16);
  11772. for(var i = 0; i < 16; i++)
  11773. {
  11774. ipad[i] = bkey[i] ^ 0x36363636;
  11775. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11776. }
  11777.  
  11778. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11779. return core_md5(opad.concat(hash), 512 + 128);
  11780. }
  11781.  
  11782. /*
  11783. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11784. * to work around bugs in some JS interpreters.
  11785. */
  11786. function safe_add(x, y)
  11787. {
  11788. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11789. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11790. return (msw << 16) | (lsw & 0xFFFF);
  11791. }
  11792.  
  11793. /*
  11794. * Bitwise rotate a 32-bit number to the left.
  11795. */
  11796. function bit_rol(num, cnt)
  11797. {
  11798. return (num << cnt) | (num >>> (32 - cnt));
  11799. }
  11800.  
  11801. /*
  11802. * Convert a string to an array of little-endian words
  11803. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11804. */
  11805. function str2binl(str)
  11806. {
  11807. var bin = Array();
  11808. var mask = (1 << chrsz) - 1;
  11809. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11810. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11811. return bin;
  11812. }
  11813.  
  11814. /*
  11815. * Convert an array of little-endian words to a string
  11816. */
  11817. function binl2str(bin)
  11818. {
  11819. var str = "";
  11820. var mask = (1 << chrsz) - 1;
  11821. for(var i = 0; i < bin.length * 32; i += chrsz)
  11822. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  11823. return str;
  11824. }
  11825.  
  11826. /*
  11827. * Convert an array of little-endian words to a hex string.
  11828. */
  11829. function binl2hex(binarray)
  11830. {
  11831. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  11832. var str = "";
  11833. for(var i = 0; i < binarray.length * 4; i++)
  11834. {
  11835. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  11836. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  11837. }
  11838. return str;
  11839. }
  11840.  
  11841. /*
  11842. * Convert an array of little-endian words to a base-64 string
  11843. */
  11844. function binl2b64(binarray)
  11845. {
  11846. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  11847. var str = "";
  11848. for(var i = 0; i < binarray.length * 4; i += 3)
  11849. {
  11850. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  11851. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  11852. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  11853. for(var j = 0; j < 4; j++)
  11854. {
  11855. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  11856. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  11857. }
  11858. }
  11859. return str;
  11860. }
  11861.  
  11862. ///////////////////////////////////////////
  11863. // debug cartes capitan Roule 07/12/2016
  11864. ///////////////////////////////////
  11865. // essais : objet
  11866. // .mode : description
  11867. // .essais : tableau d'objets essai
  11868. // .mode : description
  11869. // .essais : tableau de cartes
  11870. // .noCarte : id de la carte
  11871. // .essais : tableau d'essais, [x, y, n, nb]
  11872. function AfficheEssais(essais, sMode) {
  11873. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  11874. if (!eBigDiv) {
  11875. var insertPoint = document.getElementById('footer1');
  11876. eBigDiv = document.createElement('table');
  11877. eBigDiv.id = 'ListeEssaiCapitan';
  11878. insertBefore(insertPoint, document.createElement('p'));
  11879. insertTitle(insertPoint,'Capitan : Liste des essais');
  11880. insertBefore(insertPoint, eBigDiv);
  11881. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  11882. }
  11883. if (!essais) {
  11884. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  11885. return;
  11886. }
  11887. var carte;
  11888. for (carte in essais) {
  11889. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  11890. }
  11891. if (carte === undefined) {
  11892. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  11893. }
  11894. }
  11895.  
  11896. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  11897. var tr = appendTr(eTable);
  11898. var td = appendTd(tr);
  11899. appendText(td, sMode, bBold);
  11900. td = appendTd(tr);
  11901. appendText(td, sCarte, bBold);
  11902. td = appendTd(tr);
  11903. appendText(td, sText, bBold);
  11904. }
  11905.  
  11906. function getEssaiV1_0() {
  11907. try {
  11908. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  11909. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  11910. var tabK, nK;
  11911. prefs.getChildList('', nK, tabK);
  11912. window.console.log('getEssaiV1_0, nb key : ' + nK);
  11913. //window.console.log('getEssaiV1_0, ' + nK);
  11914. return;
  11915. //return r;
  11916. } catch (e) {
  11917. window.console.log(traceStack(e, 'getEssaiV1_0'));
  11918. }
  11919. }
  11920.  
  11921. function getEssaiV1_1() {
  11922. var locSto = window.localStorage;
  11923. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  11924. var r = [];
  11925. for (var i = 0; i < locSto.length; i++) {
  11926. var k = locSto.key(i);
  11927. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  11928. var t = k.split(/\./);
  11929. if (t[0] !== 'capitan') continue;
  11930. if (t[2] !== 'essai') continue;
  11931. var carte = 'carte n°' + t[1];
  11932. if (r[carte]) r[carte]++;
  11933. else r[carte] = 1;
  11934. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  11935. }
  11936. return r;
  11937. }
  11938.  
  11939. function showEssaiCartes() {
  11940. window.console.log('début showEssai Tout_MZ');
  11941. var essais = getEssaiV1_0();
  11942. AfficheEssais(essais, 'V1.0');
  11943. essais = getEssaiV1_1();
  11944. AfficheEssais(essais, 'V1.1');
  11945. window.console.log('fin showEssai Tout_MZ');
  11946. }
  11947.  
  11948. function testBoolLocalStorage() {
  11949. var b = false;
  11950. MY_setValue('MZ_essai_bool', b);
  11951. window.console.log('recup true => ' + MY_getValue('MZ_essai_bool'));
  11952. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  11953. window.console.log('recup LocalStorage inconnu => ' + typeof(x));
  11954. var y = GM_getValue('654654897894654654');
  11955. window.console.log('recup GM inconnu => ' + typeof(y));
  11956. window.console.log('égalité ? => ' + (x == y));
  11957. }
  11958.  
  11959. /*--------------------------------- Création liste trolligion ---------------------------------*/
  11960. function export_trolligion() {
  11961. try {
  11962. var tabDl = document.getElementsByTagName('dl');
  11963. if ((!tabDl) || !tabDl[0]) {
  11964. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  11965. return;
  11966. }
  11967. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  11968. // nom : string
  11969. // rayonnement : entier
  11970. // grades : table d'objets (une occurence par grade)
  11971. // nom : string
  11972. // trolls : table d'objets (un par Trõll)
  11973. // id
  11974. // nom
  11975. // idguilde
  11976. // guilde
  11977. // race
  11978. // niveau
  11979. // ferveur
  11980. var currentDieu;
  11981. var currentGrade;
  11982. for (var iChild1 in tabDl[0].children) {
  11983. var eChild1 = tabDl[0].children[iChild1];
  11984. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  11985. case 'dd': // Trõll
  11986. var oTroll = {};
  11987. var tabFigcaption = eChild1.getElementsByTagName('figcaption');
  11988. if ((!tabFigcaption) || !tabFigcaption[0]) {
  11989. window.console.log('[MZ ' + GM_info.script.version + '] ignore dd sans figcaption ' + eChild1.innerHTML);
  11990. break;
  11991. }
  11992. for (var iChild2 in tabFigcaption[0].childNodes) { // childNodes pour obtenir les éléments texte aussi
  11993. var eChild2 = tabFigcaption[0].childNodes[iChild2];
  11994. if (eChild2.nodeType === undefined) continue; // properties
  11995. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  11996. switch (eChild2.nodeType) {
  11997. case 1: //ELEMENT_NODE:
  11998. switch (eChild2.nodeName.toLowerCase()) {
  11999. case 'a':
  12000. var m;
  12001. if (!eChild2.href) {
  12002. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  12003. break;
  12004. }
  12005. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  12006. if (m) {
  12007. oTroll.id = parseInt(m[1]);
  12008. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  12009. break;
  12010. }
  12011. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  12012. if (m) {
  12013. var idGuilde = parseInt(m[1]);
  12014. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  12015. oTroll.idguilde = parseInt(m[1]);
  12016. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  12017. }
  12018. break;
  12019. }
  12020. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  12021. break;
  12022. case 'br': // ignore
  12023. case 'style': // ignore
  12024. break;
  12025. case 'div': // barre de vie
  12026. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  12027. eChild3 = eChild2.children[0];
  12028. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  12029. var eChild4 = eChild3.children[0];
  12030. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  12031. break;
  12032. }
  12033. }
  12034. // pas de break pour bénéficier du log ci-dessous
  12035. default:
  12036. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  12037. break;
  12038. }
  12039. break;
  12040. case 3: //TEXT_NODE:
  12041. var txt = eChild2.nodeValue.trim();
  12042. if (txt === '') break;
  12043. var m = txt.match(/(.*) *\((\d+)\)/);
  12044. if (m) {
  12045. oTroll.race = m[1].trim();
  12046. oTroll.niveau = parseInt(m[2]);
  12047. } else {
  12048. oTroll.race = txt;
  12049. }
  12050. break;
  12051. default: // ne devrait pas arriver
  12052. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  12053. break;
  12054. }
  12055. }
  12056. currentGrade.trolls.push(oTroll);
  12057. break;
  12058. case 'dt':
  12059. var tabH3 = eChild1.getElementsByTagName('h3');
  12060. if (tabH3 && tabH3[0]) { // changement de dieu
  12061. currentDieu = {
  12062. nom: tabH3[0].innerText || tabH3[0].textContent
  12063. , grades: []};
  12064. var txt = eChild1.innerText || eChild1.textContent;
  12065. var m = txt.match(/yon*ement *:* *(\d+)/);
  12066. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12067. currentGrade = undefined;
  12068. tabDieux.push(currentDieu);
  12069. break;
  12070. }
  12071. var tabH4 = eChild1.getElementsByTagName('h4');
  12072. if (tabH4 && tabH4[0]) { // changement de grade
  12073. var grade;
  12074. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12075. tabI = tabH4[0].getElementsByTagName('i');
  12076. if (tabI && tabI[0]) {
  12077. grade = tabI[0].innerText || tabI[0].textContent;
  12078. grade = grade.replace(/"/g, '');
  12079. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12080. if (m) grade += ' (' + m[1] + ')';
  12081. } else {
  12082. grade = txt.replace(/"/g, '');
  12083. }
  12084. currentGrade = {nom: grade, trolls: []};
  12085. currentDieu.grades.push(currentGrade);
  12086. break;
  12087. }
  12088. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12089. break;
  12090. default:
  12091. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12092. }
  12093. }
  12094.  
  12095. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12096. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12097. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12098. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12099. for (var iDieu in tabDieux) {
  12100. var oDieu = tabDieux[iDieu];
  12101. for (var iGrade in oDieu.grades) {
  12102. var oGrade = oDieu.grades[iGrade];
  12103. for (var iTroll in oGrade.trolls) {
  12104. var oTroll = oGrade.trolls[iTroll];
  12105. var t = [oDieu.nom, oDieu.rayonnement
  12106. , oGrade.nom
  12107. , oTroll.id, oTroll.nom
  12108. , oTroll.idguilde, oTroll.guilde
  12109. , oTroll.race, oTroll.niveau
  12110. , oTroll.ferveur];
  12111. for (var iParam in t) {
  12112. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12113. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12114. }
  12115. txt += t.join("\t") + "\n";
  12116. }
  12117. }
  12118. var t = [oDieu.nom, oDieu.rayonnement];
  12119. for (var iParam in t) {
  12120. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12121. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12122. }
  12123. txt2 += t.join("\t") + "\n";
  12124. }
  12125. txt += "\n" + txt2;
  12126. } catch (e) {
  12127. window.alert("Échec à l'extraction\n" + e);
  12128. }
  12129. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  12130. try {
  12131. if (copyTextToClipboard(txt)) {
  12132. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  12133. + "Collez dans Calc\n"
  12134. + "ou, au pire, dans EXCEL®");
  12135. } else {
  12136. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  12137. }
  12138. } catch(e) {
  12139. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  12140. }
  12141. }
  12142.  
  12143. function do_trolligion() {
  12144. var divpopup = document.createElement('div');
  12145. divpopup.id = 'MZ_divCopier';
  12146. divpopup.style.position = 'fixed';
  12147. divpopup.style.top = '2px';
  12148. divpopup.style.left = '2px;';
  12149. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  12150. divpopup.style.cursor = 'pointer';
  12151. divpopup.style.zIndex = 200;
  12152. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  12153. divpopup.onclick = export_trolligion;
  12154. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  12155. divpopup.appendChild(img);
  12156. document.body.appendChild(divpopup);
  12157. }
  12158.  
  12159. /*--------------------------------- Dispatch ---------------------------------*/
  12160.  
  12161. //chargerScriptDev("libs");
  12162. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  12163. //if (isDEV) testBoolLocalStorage();
  12164.  
  12165. // Détection de la page à traiter
  12166. if(isPage("Messagerie/ViewMessageBot")) {
  12167. do_cdmbot();
  12168. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  12169. do_cdmcomp();
  12170. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  12171. do_diplo();
  12172. } else if(isPage("MH_Play/Play_equipement")) {
  12173. do_equip();
  12174. } else if(isPage("MH_Play/Play_menu")) {
  12175. do_menu();
  12176. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  12177. do_option();
  12178. //showEssaiCartes();
  12179. } else if(isPage("View/PJView")) {
  12180. do_pjview();
  12181. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  12182. do_profil();
  12183. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  12184. do_tancompo();
  12185. } else if(isPage("MH_Play/Play_vue")) {
  12186. do_vue();
  12187. } else if(isPage("MH_Play/Play_news")) {
  12188. do_news();
  12189. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  12190. do_move();
  12191. } else if(isPage("MH_Missions/Mission_Etape")) {
  12192. do_mission();
  12193. } else if(isPage("View/MonsterView")) {
  12194. do_infomonstre();
  12195. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  12196. do_attaque();
  12197. } else if(isPage("MH_Play/Play_e_follo.php")) {
  12198. do_listegowap();
  12199. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  12200. do_lieuDescription();
  12201. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  12202. do_lieuTeleport();
  12203. } else if(isPage("MH_Follower/FO_Ordres")) {
  12204. do_ordresgowap();
  12205. } else if(isPage("MH_Follower/FO_Equipement")) {
  12206. do_equipgowap();
  12207. } else if(isPage("MH_Play/Play_mouche")) {
  12208. do_mouches();
  12209. } else if(isPage("MH_Play/Play_BM")) {
  12210. do_malus();
  12211. } else if(isPage("MH_Play/Play_evenement")) {
  12212. do_myevent();
  12213. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  12214. do_enchant();
  12215. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  12216. do_pre_enchant();
  12217. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  12218. do_actions();
  12219. } 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')) {
  12220. do_mission_liste();
  12221. } else if(isPage('MH_Play/Play_action')) {
  12222. do_actions();
  12223. } else if(isPage('MH_Play/Play_profil2')) {
  12224. do_profil2();
  12225. } else if(isPage('View/TrolligionView.php')) {
  12226. do_trolligion();
  12227. }
  12228. } catch(e) {
  12229. try {
  12230. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  12231. } catch(e2) {
  12232. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  12233. }
  12234. }