Tout_MZ

Client MountyZilla

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

  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.17.4
  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.17.4 08/04/2017",
  37. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  38. " Adaptation de la diplomacie à une modification de la page MH",
  39. "V1.2.17.3 04/04/2017",
  40. " Messages console en cas de cadre d'erreur",
  41. " Trolls de l'IT mais pas dans le vue en orange",
  42. "V1.2.17.2 20/03/2017",
  43. " Correction des PV restants",
  44. "V1.2.17.1 20/03/2017",
  45. " Blocage des PV restants en attendant résolution de bug",
  46. "V1.2.17 19/03/2017",
  47. " Refonte de l'envoi des CdM",
  48. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  49. "V1.2.16.4 08/03/2017",
  50. " correction ID de troll en envoi de PX/MP",
  51. "V1.2.16.3 27/02/2017",
  52. " correction bonus/malus FP",
  53. "V1.2.16.2 24/02/2017",
  54. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  55. "V1.2.16.1 21/02/2017",
  56. " corrige bug sur Fx 38.8 ESR",
  57. "V1.2.16 21/02/2017",
  58. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  59. " possibilité de masquer les Gowaps Sauvages dans la vue",
  60. " calcul des caractéristiques du siphon des âmes",
  61. "V1.2.15.2 02/02/2017",
  62. " adaptation décumul VlC (page des bonus/malus)",
  63. "V1.2.15.1 29/01/2017",
  64. " carte sur la page de description du lieu TP",
  65. "V1.2.15 25/01/2017",
  66. " mise en place des nouvelles cartes (suivants, TP)",
  67. "V1.2.14.3 25/01/2017",
  68. " résumé dans l'export des données Trõlligion",
  69. "V1.2.14.2 20/01/2017",
  70. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  71. "V1.2.14.1 20/01/2017",
  72. " réécriture filtrage des monstres par niveau dans la vue",
  73. " Changelog dans la page des news MZ",
  74. "V1.2.14 20/01/2017",
  75. " Ajout de l'export des données Trõlligion",
  76. "V1.2.13.7 10/01/2017",
  77. " Exclusion Bricoll'troll dans l'entête GM",
  78. "V1.2.13.6 08/01/2017",
  79. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  80. "V1.2.13.5 07/01/2017",
  81. " Correction bug qui se manisfestait sous LINUX",
  82. "V1.2.13.4 07/01/2017",
  83. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  84. "V1.2.13.3 07/01/2017",
  85. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  86. "V1.2.13.2 07/01/2017",
  87. " Correction missions, recherche troogle (familles et types de monstres)",
  88. "V1.2.13.1 06/01/2017",
  89. " Suppression oldSchoolProfile qui n'existe plus",
  90. " Ajout du 'refresh' du cadre de gauche",
  91. "V1.2.13 01/01/2017",
  92. " homogénéisation des messages d'erreur",
  93. " Ajout du lien Troogle sur les étapes de mission monstre",
  94. "V1.2.12.2 30/12/2016",
  95. " retour en mode normal (http si jeu en http)",
  96. "V1.2.12.1 27/12/2016",
  97. " Correction mode IP",
  98. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  99. "V1.2.12 24/12/2016",
  100. " Nettoyage des URL",
  101. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  102. " Interface bricoll'Troll en https",
  103. " Remise en marche des cartes des trajets des gowaps",
  104. "V1.2.11.5 à 7 20 & 21/12/2016",
  105. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  106. "V1.2.11.4 19/12/2016",
  107. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  108. "V1.2.11.3 19/12/2016",
  109. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  110. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  111. "V1.2.11.2 18/12/2016",
  112. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  113. "V1.2.11.1 17/12/2016",
  114. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  115. "V1.2.11 13/12/2016",
  116. " Passage sur BdD Raistlin \\o/",
  117. "V1.2.10.4 12/12/2016",
  118. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  119. "V1.2.10.3 09/12/2016",
  120. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  121. "V1.2.10.2 09/12/2016",
  122. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  123. "V1.2.10.1 08/12/2016",
  124. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  125. "V1.2.10 07/12/2016",
  126. " correction décumul des bonus/malus",
  127. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  128. "V1.2.9 16/11/2016",
  129. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  130. "V1.2.8 10/11/2016",
  131. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  132. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  133. "V1.2.7 07/11/2016",
  134. " remise en route de l'interface avec l'IT bricol'Troll",
  135. "V1.2.6 19/10/2016",
  136. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  137. " stockage idguilde et nomguilde",
  138. "V1.2.5 17/10/2016",
  139. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  140. " remise en route de la gestion des options avec intégration md5 dans ce script",
  141. "V1.2.4 14/10/2016",
  142. " utilisation du relai raistlin pour l'envoi des CdM",
  143. "V1.2.3 :",
  144. " suppression ancien profil",
  145. " nettoyage doublon sur getPortee",
  146. " adaptation portee TP basée sur les PI",
  147. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  148. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  149. "V1.2.1 :",
  150. " include des URLs MH alternatives",
  151. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  152. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  153. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  154. "V1.1 : regroupement en un gros paquet sale",
  155. ];
  156.  
  157. /**********************************************************
  158. À faire / propositions d'évolutions
  159.  
  160. breizhou13 20/12/2016
  161. envoyer les données à l'IT (Bricol'Trolls) aussi
  162. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  163. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  164. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  165. Akkila le boeuf le 26-03-2017 à 15:56
  166. - bouton pour rafraîchir les infos des trolls de son groupe
  167. - (ajout de Roule') ne pas afficher
  168. Roule'
  169. Réactiver les jubilaires
  170. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  171. Traces console à l'affichage des cadres d'info MZ
  172. (Hera) Pour la portée IdC, l'arrondi est par défaut et MZ le fait par excès (1 fois en horizontal + 1 fois en vertical)
  173. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  174. - voir l'intérêt de refaire fonctionner
  175. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  176. Prévision des DLA de monstre
  177. Niveau des monstres à la méthode Roule'
  178. Raistlin
  179. pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  180. Les cibles de mission ont disparu dans la vue (remonté par Hera)
  181. **********************************************************/
  182.  
  183. /**********************************************************
  184. **** Début de zone à déplacer dans une bibli commune ******
  185. **********************************************************/
  186.  
  187. // URL de base serveur MZ
  188. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  189. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  190. //var URL_MZ = 'http://192.99.225.92/mz';
  191.  
  192. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  193. // à supprimer
  194. const newCarte = true;
  195. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  196.  
  197. // URLs externes redirection (pas de souci CORS)
  198. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  199. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  200. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  201. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  202. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  203. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  204. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  205. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  206. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  207.  
  208. // URLs de test HTTPS
  209. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  210. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  211.  
  212. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  213. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  214. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  215.  
  216. // x~x Libs
  217.  
  218. /* ancien TODO
  219. * - revoir la gestion des CdM --> nott armure magique
  220. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  221. * - vérfier la gestion des enchants
  222. */
  223.  
  224. // Roule 04/09/2016 switch extern URLs to https if available
  225. var isHTTPS = false;
  226. if (window.location.protocol.indexOf('https') === 0) {
  227. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  228. URL_bricol = URL_bricol_https;
  229. isHTTPS = true;
  230. }
  231.  
  232. // Roule 23/12/2016 mode dev
  233. var isDEV = false;
  234. if (window.localStorage.getItem('MZ_dev') || window.location.href.indexOf('rouletabille.mh.free.fr') > 0) {
  235. URL_MZ = URL_MZ.replace(/$/, 'dev');
  236. isDEV = true;
  237. }
  238.  
  239. // Images (pas de souci CORS)
  240. var URL_MZimg = URL_MZ + '/img/';
  241. // URLs externes ajax (CORS OK)
  242. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  243. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  244.  
  245. // liens externes détuits
  246. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  247. var MHicons = '/mountyhall/Images/Icones/';
  248. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  249. var MY_DEBUG = false;
  250.  
  251. if (GM_getValue === undefined) { // éviter le blocage si pas sous GM
  252. window.console.log('*** warning *** GM_getValue n\'est pas défini (c\'est normal en test de compilation)');
  253. var GM_getValue = function(key) {};
  254. var GM_setValue = function(key, val) {};
  255. var GM_deleteValue = function(key) {};
  256. }
  257.  
  258. /* Utilisation de la gestion de l'enregistrement des données de
  259. GreaseMonkey, avec partage entre scripts via le localStorage, par
  260. Vapulabehemot (82169) 07/02/2017 */
  261. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  262. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  263. function MY_getValue(key) {
  264. var v = window.localStorage.getItem(key);
  265. vGM = GM_getValue(key);
  266. if ((vGM == null)
  267. || (v != null && v != vGM)){
  268. GM_setValue(key, v);
  269. } else if (v == null && vGM != null) {
  270. v = vGM;
  271. window.localStorage[key] = vGM;
  272. }
  273. return v;
  274. }
  275. function MY_removeValue(key) {
  276. GM_deleteValue(key);
  277. window.localStorage.removeItem(key);
  278. }
  279. function MY_setValue(key, val) {
  280. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  281. val = 1;
  282. else if (val === false)
  283. val = 0;
  284. GM_setValue(key, val);
  285. window.localStorage[key] = val;
  286. }
  287.  
  288. /*---------------- mise à jour de variables globales utiles ------------------*/
  289. // utilisé pour accès bdd (un peu partout) :
  290. var numTroll = MY_getValue('NUM_TROLL');
  291. // utilisé dans vue pour PX :
  292. var nivTroll = MY_getValue('NIV_TROLL');
  293. // utilisés dans actions et vue (calculs SR) :
  294. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  295. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  296. var currentURL = window.location.href;
  297.  
  298. /*-[functions]------------ Fonctions durée de script -------------------------*/
  299. var date_debut = null;
  300.  
  301. function start_script(nbJours_exp) {
  302. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  303. if(date_debut) return;
  304. date_debut = new Date();
  305. // Créé la variable expdate si demandé
  306. if(nbJours_exp) {
  307. expdate = new Date();
  308. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  309. }
  310. }
  311.  
  312. function displayScriptTime() {
  313. var footerNode = document.getElementById('footer2');
  314. if(!footerNode) return;
  315. try{
  316. var node = document.evaluate(
  317. ".//text()[contains(.,'Page générée en')]/../br",
  318. footerNode,null,9,null).singleNodeValue;
  319. }
  320. catch(e){return;}
  321. insertText(node,
  322. ' - [Script exécuté en '
  323. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  324. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  325. }
  326.  
  327. function traceStack(e, sModule) {
  328. var version = '';
  329. if (GM_info && GM_info.script && GM_info.script.version)
  330. version = ' ' + GM_info.script.version;
  331. sRet = '[MZ' + version + ']'
  332. if (sModule) sRet += ' {' + sModule + '}';
  333. if (e.message) sRet += ' ' + e.message;
  334. if (e.stack) {
  335. var sStack = e.stack;
  336. // enlever les infos confidentielles
  337. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  338. }
  339. return sRet;
  340. }
  341.  
  342. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  343.  
  344. function debugMZ(str){
  345. if(MY_DEBUG){
  346. window.console.debug('[MY_DEBUG] '+str);
  347. if(typeof str === "object"){
  348. window.console.debug(str);
  349. }
  350. }
  351. }
  352.  
  353. function FF_XMLHttpRequest(MY_XHR_Ob) {
  354. var request = new XMLHttpRequest();
  355. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  356. for(var head in MY_XHR_Ob.headers) {
  357. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  358. }
  359. request.onreadystatechange = function() {
  360. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  361. if(request.readyState!=4) { return; }
  362. if(request.error) {
  363. if(MY_XHR_Ob.onerror) {
  364. MY_XHR_Ob.onerror(request);
  365. }
  366. }
  367. else if(MY_XHR_Ob.onload) {
  368. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  369. MY_XHR_Ob.onload(request);
  370. }
  371. };
  372. request.send(MY_XHR_Ob.data);
  373. }
  374.  
  375.  
  376. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  377.  
  378. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  379. function copyTextToClipboard(text) {
  380. var textArea = document.createElement("textarea");
  381.  
  382. //
  383. // *** This styling is an extra step which is likely not required. ***
  384. //
  385. // Why is it here? To ensure:
  386. // 1. the element is able to have focus and selection.
  387. // 2. if element was to flash render it has minimal visual impact.
  388. // 3. less flakyness with selection and copying which **might** occur if
  389. // the textarea element is not visible.
  390. //
  391. // The likelihood is the element won't even render, not even a flash,
  392. // so some of these are just precautions. However in IE the element
  393. // is visible whilst the popup box asking the user for permission for
  394. // the web page to copy to the clipboard.
  395. //
  396.  
  397. // Place in top-left corner of screen regardless of scroll position.
  398. textArea.style.position = 'fixed';
  399. textArea.style.top = 0;
  400. textArea.style.left = 0;
  401.  
  402. // Ensure it has a small width and height. Setting to 1px / 1em
  403. // doesn't work as this gives a negative w/h on some browsers.
  404. textArea.style.width = '2em';
  405. textArea.style.height = '2em';
  406.  
  407. // We don't need padding, reducing the size if it does flash render.
  408. textArea.style.padding = 0;
  409.  
  410. // Clean up any borders.
  411. textArea.style.border = 'none';
  412. textArea.style.outline = 'none';
  413. textArea.style.boxShadow = 'none';
  414.  
  415. // Avoid flash of white box if rendered for any reason.
  416. textArea.style.background = 'transparent';
  417.  
  418. textArea.value = text;
  419.  
  420. document.body.appendChild(textArea);
  421.  
  422. textArea.select();
  423.  
  424. var successful = document.execCommand('copy');
  425.  
  426. document.body.removeChild(textArea);
  427. return successful;
  428. }
  429.  
  430. function avertissement(txt,duree) {
  431. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  432. if(!duree) duree = 15000;
  433. var div = document.createElement('div');
  434. // On numérote les avertissements pour destruction sélective
  435. var num = document.getElementsByName('avertissement').length;
  436. div.num = num;
  437. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  438. div.setAttribute('name','avertissement');
  439. div.className = 'mh_textbox';
  440. div.style.position = 'fixed';
  441. div.style.top = (10+15*num)+'px';
  442. div.style.left = (10+5*num)+'px';
  443. div.style.border = '5px solid red';
  444. div.style.zIndex = 2+num;
  445. div.style.cursor = 'pointer';
  446. div.style.fontSize = 'large';
  447. div.innerHTML = txt;
  448. div.onclick=function(){ tueAvertissement(this.num) };
  449.  
  450. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  451. var divcroix = document.createElement('div');
  452. divcroix.style.position = 'absolute';
  453. divcroix.style.top = 0;
  454. divcroix.style.right = 0;
  455. divcroix.style.color = 'black';
  456. divcroix.style.fontSize = 'inherit';
  457. divcroix.style.cursor = 'pointer'
  458. divcroix.style.zIndex = 2+num;
  459. divcroix.innerHTML = "X";
  460. div.appendChild(divcroix);
  461.  
  462. document.body.appendChild(div);
  463. // Destruction automatique de l'avertissement après "un certain temps"
  464. window.setTimeout(function(){ tueAvertissement(num) },duree);
  465. }
  466.  
  467. function tueAvertissement(num) {
  468. var divs = document.getElementsByName('avertissement');
  469. if(divs.length==0) { return; }
  470. for(var i=0 ; i<divs.length ; i++) {
  471. if(divs[i].num==num) {
  472. divs[i].parentNode.removeChild(divs[i]);
  473. return;
  474. }
  475. }
  476. }
  477.  
  478.  
  479. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  480.  
  481. function insertBefore(next,el) {
  482. next.parentNode.insertBefore(el,next);
  483. }
  484.  
  485. function appendTr(tbody,clas) {
  486. var tr = document.createElement('tr');
  487. if(clas) tr.className = clas;
  488. tbody.appendChild(tr);
  489. return tr;
  490. }
  491.  
  492. function insertTr(next,clas) {
  493. var tr = document.createElement('tr');
  494. if(clas) tr.className = clas;
  495. insertBefore(next,tr);
  496. return tr;
  497. }
  498.  
  499. function appendTd(tr) {
  500. var td = document.createElement('td');
  501. if(tr) tr.appendChild(td);
  502. return td;
  503. }
  504.  
  505. function insertTd(next) {
  506. var td = document.createElement('td');
  507. insertBefore(next,td);
  508. return td;
  509. }
  510.  
  511. function appendTdCenter(tr,colspan) {
  512. var td = appendTd(tr);
  513. td.align = 'center'; // WARNING - Obsolete
  514. if(colspan) td.colSpan = colspan;
  515. return td;
  516. }
  517.  
  518. function insertTdElement(next,el) {
  519. var td = insertTd(next);
  520. if(el) td.appendChild(el);
  521. return td;
  522. }
  523.  
  524. function appendA(paren,href,cssClass,text) {
  525. var a = document.createElement('a');
  526. if (href) a.href = href;
  527. if (cssClass) a.className = cssClass;
  528. if (text) a.appendChild(document.createTextNode(text));
  529. paren.appendChild(a);
  530. }
  531.  
  532. function appendText(paren,text,bold) {
  533. if(bold) {
  534. var b = document.createElement('b');
  535. b.appendChild(document.createTextNode(text));
  536. paren.appendChild(b);
  537. }
  538. else
  539. paren.appendChild(document.createTextNode(text));
  540. }
  541.  
  542. function insertText(next,text,bold) {
  543. if(bold) {
  544. var b = document.createElement('b');
  545. appendText(b,text);
  546. insertBefore(next,b);
  547. }
  548. else
  549. insertBefore(next,document.createTextNode(text));
  550. }
  551.  
  552. function appendTdText(tr,text,bold) {
  553. var td = appendTd(tr);
  554. appendText(td,text,bold);
  555. return td;
  556. }
  557.  
  558. function insertTdText(next,text,bold) {
  559. var td = insertTd(next);
  560. appendText(td,text,bold);
  561. return td;
  562. }
  563.  
  564. function appendBr(paren) {
  565. paren.appendChild(document.createElement('br'));
  566. }
  567.  
  568. function insertBr(next) {
  569. insertBefore(next,document.createElement('br'));
  570. }
  571.  
  572. function appendLI(ul,text) {
  573. // uniquement utilisé dans les options (crédits)
  574. var li = document.createElement('li');
  575. appendText(li,text);
  576. ul.appendChild(li);
  577. return li;
  578. }
  579.  
  580. function appendTextbox(paren,type,nam,size,maxlength,value) {
  581. var input = document.createElement('input');
  582. input.className = 'TextboxV2';
  583. input.type = type;
  584. input.name = nam;
  585. input.id = nam;
  586. input.size = size;
  587. input.maxLength = maxlength;
  588. if(value) input.value = value;
  589. paren.appendChild(input);
  590. return input;
  591. }
  592.  
  593. function appendCheckBox(paren,nam,checked,onClick) {
  594. var input = document.createElement('input');
  595. input.type = 'checkbox';
  596. input.name = nam;
  597. input.id = nam;
  598. if(checked) input.checked = true;
  599. if(onClick) input.onclick = onClick;
  600. paren.appendChild(input);
  601. return input;
  602. }
  603.  
  604. function appendNobr(paren,id,delgg,text) {
  605. var nobr = document.createElement('nobr');
  606. appendCheckBox(nobr,id,null,delgg);
  607. appendText(nobr,text);
  608. paren.appendChild(nobr);
  609. appendText(paren,' ');
  610. return nobr;
  611. }
  612.  
  613. function appendCheckBoxSpan(paren,id,onClick,text) {
  614. var span = document.createElement('span');
  615. span.style.whiteSpace = 'nowrap';
  616. appendCheckBox(span,id,false,onClick);
  617. var label = document.createElement('label');
  618. appendText(label,text);
  619. label.htmlFor = id;
  620. label.style.marginLeft = '-5px';
  621. span.appendChild(label);
  622. span.style.marginRight = '3px';
  623. paren.appendChild(span);
  624. appendText(paren, ' ');
  625. return span;
  626. }
  627.  
  628. function appendOption(select,value,text) {
  629. var option = document.createElement('option');
  630. option.value = value;
  631. appendText(option,text);
  632. select.appendChild(option);
  633. return option;
  634. }
  635.  
  636. function appendHidden(form,nam,value) {
  637. var input = document.createElement('input');
  638. input.type = 'hidden';
  639. input.name = nam;
  640. input.id = nam;
  641. input.value = value;
  642. form.appendChild(input);
  643. }
  644.  
  645. function appendButton(paren,value,onClick) {
  646. var input = document.createElement('input');
  647. input.type = 'button';
  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 insertButton(next,value,onClick) {
  657. var input = document.createElement('input');
  658. input.type = 'button';
  659. input.className = 'mh_form_submit';
  660. input.value = value;
  661. input.onmouseover = function(){this.style.cursor='pointer';};
  662. input.onclick = onClick;
  663. insertBefore(next,input);
  664. return input;
  665. }
  666.  
  667. function appendSubmit(paren,value,onClick) {
  668. var input = document.createElement('input');
  669. input.type = 'submit';
  670. input.className = 'mh_form_submit';
  671. input.value = value;
  672. input.onmouseover = function(){this.style.cursor='pointer';};
  673. if(onClick) input.onclick = onClick;
  674. paren.appendChild(input);
  675. return input;
  676. }
  677.  
  678. function createImage(url,title,style) {
  679. var img = document.createElement('img');
  680. img.src = url;
  681. img.title = title;
  682. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  683. if (style) img.style = style;
  684. return img;
  685. }
  686.  
  687. function createAltImage(url,alt,title) {
  688. var img = document.createElement('img');
  689. img.src = url;
  690. img.alt = alt;
  691. if (title) img.title = title;
  692. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  693. return img;
  694. }
  695.  
  696. function createImageSpan(url,alt,title,text,bold) {
  697. var span = document.createElement('span');
  698. span.title = title;
  699. var img = document.createElement('img');
  700. img.src = url;
  701. img.alt = alt;
  702. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  703. span.appendChild(img);
  704. appendText(span,text,bold);
  705. return span;
  706. }
  707.  
  708. function createCase(titre,table,width) {
  709. if(!width) width=120;
  710. var tr = appendTr(table,'mh_tdpage');
  711. var td = appendTdText(tr,titre,true);
  712. td.className = 'mh_tdtitre';
  713. td.width = width;
  714. td = appendTdText(tr,'');
  715. td.className = 'mh_tdpage';
  716. return td;
  717. }
  718.  
  719. function getMyID(e) {
  720. var parent = e.parentNode;
  721. for(var i=0 ; i<parent.childNodes.length ; i++) {
  722. if(e==parent.childNodes[i])
  723. return i;
  724. }
  725. return -1;
  726. }
  727.  
  728. function insertAfter(elt,newElt) {
  729. var id = getMyID(elt);
  730. if(id==-1) return;
  731. if(id<elt.parentNode.childNodes.length-1)
  732. insertBefore(elt.nextSibling,newElt);
  733. else
  734. elt.parentNode.appendChild(newElt);
  735. }
  736.  
  737.  
  738. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  739.  
  740. function aff(nb) {
  741. return (nb>=0) ? '+'+nb : nb;
  742. }
  743.  
  744. function getNumber(str) {
  745. var nbr = str.match(/\d+/);
  746. return nbr ? Number(nbr[0]) : Number.NaN;
  747. }
  748.  
  749. function getNumbers(str) {
  750. var nbrs = str.match(/-?\d+/g);
  751. if (!nbrs) return [];
  752. for(var i=0 ; i<nbrs.length ; i++)
  753. nbrs[i] = Number(nbrs[i]);
  754. return nbrs;
  755. }
  756.  
  757. function trim(str) {
  758. return str.replace(/(^\s*)|(\s*$)/g,'');
  759. }
  760.  
  761. String.prototype.trim = function() {
  762. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  763. }
  764.  
  765. function epure(texte) {
  766. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  767. .replace(/[ç]/g,'c')
  768. .replace(/[éêèë]/g,'e')
  769. .replace(/[ïî]/g,'i')
  770. .replace(/[ôöõ]/g,'o')
  771. .replace(/[ùûü]/g,'u');
  772. }
  773.  
  774. String.prototype.epure = function () {
  775. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  776. .replace(/[ç]/g,'c')
  777. .replace(/[éêèë]/g,'e')
  778. .replace(/[ïî]/g,'i')
  779. .replace(/[ôöõ]/g,'o')
  780. .replace(/[ùûü]/g,'u');
  781. }
  782.  
  783. function bbcode(texte) {
  784. return texte.replace(/&/g,'&amp;')
  785. .replace(/"/g,'&quot;')
  786. .replace(/</g,'&lt;')
  787. .replace(/>/g,'&gt;')
  788. .replace(/'/g,'&#146;')
  789. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  790. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  791. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  792. }
  793.  
  794.  
  795. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  796.  
  797. function addZero(i) {
  798. return (i<10) ? '0'+i : i;
  799. }
  800.  
  801. function DateToString(date) {
  802. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  803. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  804. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  805. }
  806.  
  807. function StringToDate(str) {
  808. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  809. }
  810.  
  811. // fonctionne aussi avec datetime
  812. function SQLDateToFrench(str) {
  813. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  814. }
  815.  
  816. // ... et ajoute un "à" du plus bel effet
  817. function SQLDateToFrenchTime(str) {
  818. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  819. }
  820.  
  821. // SQLDate vers objet date Javascript
  822. function SQLDateToObject(str) {
  823. var t = str.split(/[- :]/);
  824. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  825. }
  826.  
  827. var mz_ie = (window.attachEvent)? true:false;
  828. if ("function" !== typeof addEvent) {
  829. if (mz_ie) {
  830. function addEvent(obj, typ, fn, sens) {
  831. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  832. obj["e"+typ+fn]( window.event );
  833. }
  834. obj.attachEvent("on"+typ, obj[typ+fn] );
  835. }
  836. }
  837. else {
  838. function addEvent(obj, typ, fn, sens) {
  839. obj.addEventListener(typ, fn, sens);
  840. }
  841. }
  842. }
  843.  
  844. /**********************
  845. * glissière en mode objet
  846. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  847. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  848. *
  849. * Usage:
  850. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  851. * ref : utilisé pour diversifier les IDs HTML
  852. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  853. * target : peut être de 3 types
  854. * - élément HTML : l'élément HTML à zoomer
  855. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  856. * - function : callback quand le curseur bouge
  857. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  858. * dans le mode dynamique, la callback est appelée sur mouseMove
  859. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  860. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  861. * autres méthodes
  862. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  863. **********************/
  864.  
  865. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  866. try {
  867. var mouseDown = false;
  868. var div_gliss = document.createElement("div"); // la DIV mère
  869. div_gliss.id = "MZ_gliss_"+ref;
  870. var div_label = document.createElement("span"); // le label
  871. div_label.innerHTML = labelHTML;
  872. div_gliss.appendChild(div_label);
  873. div_gliss.className = "choix_zoom";
  874. var dessin = document.createElement("canvas"); // le dessin lui-même
  875. dessin.id = "MZ_gliss_dessin_"+ref;
  876. dessin.style.cursor = "pointer";
  877. dessin.width = 104;
  878. dessin.height = 12;
  879. dessin.style.marginLeft = '2px';
  880. dessin.style.marginRight = '2px';
  881. div_gliss.appendChild(dessin);
  882. var pourcent = document.createElement("span"); // le pourcentage
  883. pourcent.id = "MZ_gliss_pourcent_"+ref;
  884. var pourcent_text = document.createTextNode('');
  885. var previousVal;
  886. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  887.  
  888. // alignement vertical
  889. dessin.style.verticalAlign = 'middle';
  890. div_label.style.verticalAlign = 'middle';
  891. pourcent.style.verticalAlign = 'middle';
  892.  
  893. pourcent.appendChild(pourcent_text);
  894. div_gliss.appendChild(pourcent);
  895.  
  896. var bulle_pourcent = document.createElement("div"); // la bulle
  897. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  898. bulle_pourcent.style.display = 'block';
  899. bulle_pourcent.style.visibility = 'hidden';
  900. bulle_pourcent.style.position = 'absolute';
  901. bulle_pourcent.style.zIndex = 3500;
  902. bulle_pourcent.style.border = '1px solid #a1927f';
  903. var bulle_pourcent_text = document.createTextNode('');
  904. bulle_pourcent.appendChild(bulle_pourcent_text);
  905. document.body.appendChild(bulle_pourcent);
  906.  
  907. this.getElt = function() {return div_gliss;};
  908.  
  909. ////////////////////////////////////
  910. // dessine et redessine le curseur
  911. ////////////////////////////////////
  912. var dessine_glissiere = function(val) {
  913. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  914. var ctx = dessin.getContext('2d');
  915. ctx.clearRect(0, 0,104, 12);
  916. ctx.fillStyle = "rgb(0,0,0)";
  917. ctx.fillRect(0,0,2,12);
  918. ctx.fillRect(102,0,2,12);
  919. ctx.fillRect(0,5,104,2);
  920.  
  921. ctx.fillStyle = "rgb(80,80,80)";
  922. ctx.fillRect(pos_0_100,0,5,12);
  923. ctx.fillStyle = "rgb(200,200,200)";
  924. ctx.fillRect(pos_0_100+1,1,3,10);
  925. pourcent_text.nodeValue = val+'%';
  926. previousVal = parseInt(val);
  927. };
  928.  
  929. ////////////////////////////////////
  930. // action sur mousedown et mousemove
  931. // stocker la nouvelle valeur
  932. // redessiner
  933. // afficher la nouvelle valeur
  934. // action selon ce qui a été demandé
  935. ////////////////////////////////////
  936. var doCallback_glissiere = function (evt) {
  937. try {
  938. if (evt.type === 'mousedown') mouseDown = true;
  939. if (evt.offsetX) {
  940. var xsouris = evt.offsetX;
  941. var xpos = evt.clientX;
  942. var ypos = evt.clientY + document.body.scrollTop;
  943. }
  944. else {
  945. var xsouris = evt.layerX;
  946. var xpos = evt.pageX;
  947. var ypos = evt.pageY;
  948. }
  949. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  950. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  951. // afficher la nouvelle valeur dans la bulle
  952. bulle_pourcent_text.nodeValue = val + '%';
  953. bulle_pourcent.style.top = (ypos+3)+'px';
  954. bulle_pourcent.style.left = (xpos+16)+'px';
  955. if (evt.buttons === undefined) {
  956. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  957. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  958. } else {
  959. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  960. }
  961. // stocker la nouvelle valeur
  962. MY_setValue("MZ_glissiere_" + ref, val);
  963. // redessiner la glissière avec le curseur où il faut
  964. dessine_glissiere(val);
  965. // action selon ce qui a été demandé
  966. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  967. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  968. if (typeof paramTarget === 'object') {
  969. var elt = paramTarget;
  970. } else if (typeof paramTarget === 'string') {
  971. var elt = document.getElementById(paramTarget);
  972. } else if (typeof paramTarget === 'function') {
  973. paramTarget(val);
  974. return;
  975. }
  976. if (elt.setZoom != undefined) elt.setZoom(val);
  977. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  978. };
  979.  
  980. ////////////////////////////////////
  981. // event mousedown et mousemove : redessiner et callback
  982. ////////////////////////////////////
  983. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  984. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  985. ////////////////////////////////////
  986. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  987. ////////////////////////////////////
  988. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  989. ////////////////////////////////////
  990. // event mouseout & mouseover : afficher/cacher la bulle
  991. ////////////////////////////////////
  992. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  993. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  994.  
  995. ////////////////////////////////////
  996. // dessiner la première fois
  997. ////////////////////////////////////
  998. var val_init = MY_getValue("MZ_glissiere_" + ref);
  999. if (val_init === undefined) val_init = valDef;
  1000. dessine_glissiere(val_init);
  1001. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1002. }
  1003.  
  1004. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1005. // reçoit 2 objets avec des propriétés x et y
  1006. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1007. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1008. var deltaX = locArrivee.x - locDepart.x;
  1009. if (deltaX == 0) return; // pas de point intermédiaire
  1010. var deltaY = locArrivee.y - locDepart.y;
  1011. if (deltaY == 0) return; // pas de point intermédiaire
  1012. var absDeltaX = Math.abs(deltaX);
  1013. var absDeltaY = Math.abs(deltaY);
  1014. if (absDeltaX > absDeltaY) {
  1015. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1016. } else if (absDeltaY > absDeltaX) {
  1017. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1018. } else {
  1019. return; // égalité, pas de point intermédiaire
  1020. }
  1021. }
  1022.  
  1023. /**********************
  1024. * carte en mode objet
  1025. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1026. *
  1027. * Usage:
  1028. * carte = new carte_MZ(ref, tabDepl);
  1029. * ref : utilisé pour diversifier les IDs HTML
  1030. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1031. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1032. * autres méthodes
  1033. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1034. **********************/
  1035.  
  1036. function carte_MZ(ref, tabDepl) {
  1037. try {
  1038. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1039. div1_carte.id = "MZ_carte_"+ref;
  1040. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1041. div1_carte.style.backgroundImage = 'none';
  1042. div1_carte.style.backgroundColor = 'transparent';
  1043. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1044. div2_carte.className = "carte_MZ";
  1045. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1046. var dessin = document.createElement("canvas"); // le dessin lui-même
  1047. dessin.id = "MZ_carte_dessin_"+ref;
  1048. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1049. div1_carte.appendChild(div2_carte);
  1050. div2_carte.appendChild(dessin);
  1051.  
  1052. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1053. , [-66.5, -37.5, 2, 1.5, -69]
  1054. , [-63.5, 8.5, 2, 1.5, -69]
  1055. , [-59.5, -32.5, 2, 1.5, -69]
  1056. , [-52, 57, 0.25, 0.8, -59]
  1057. , [-50.5, -22.5, 2, 1.5, -69]
  1058. , [-35.5, -51.5, 2, 1.5, -69]
  1059. , [-34.5, 14.5, 2, 1.5, -69]
  1060. , [-34.5, 64.5, 2, 1.5, -69]
  1061. , [-11.5, 72.5, 2, 1.5, -69]
  1062. , [5.5, -49.5, 2, 1.5, -69]
  1063. , [5.5, 31.5, 2, 1.5, -69]
  1064. , [10.5, 63.5, 2, 1.5, -69]
  1065. , [12, -15, 0.25, 0.8, -59]
  1066. , [21.5, 35.5, 2, 1.5, -69]
  1067. , [30, -52, 0.25, 0.8, -59]
  1068. , [46.5, 51.5, 2, 1.5, -69]
  1069. , [48, -39, 0.25, 0.8, -59]
  1070. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1071. , [56.5, 23.5, 75, 8.7, -99]
  1072. , [64, 70, 0.25, 0.8, -59]
  1073. , [74.5, 31.5, 2, 1.5, -69]];
  1074.  
  1075. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1076. var couleur_cible = 'rgba(0,0,0,0.5)';
  1077. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1078. var couleur_trou = 'rgb(200,0,0)';
  1079.  
  1080. var coord_x = function(val) {
  1081. return decalh+coeff*(val+100);
  1082. };
  1083. var coord_y = function(val) {
  1084. return decalv+coeff*(100-val);
  1085. };
  1086.  
  1087. var ctx = dessin.getContext('2d');
  1088. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1089. if (coeff) coeff /= 50;
  1090. else coeff = 2;
  1091. var decalv=30, decalh=30;
  1092.  
  1093. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1094. //var res = false
  1095. var x0 = pos0.x;
  1096. var y0 = pos0.x;
  1097. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1098. var px = Math.sign(pos1.x - pos0.x);
  1099. var py = Math.sign(pos1.y - pos0.y);
  1100. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1101. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1102.  
  1103. for(var k in position_trous_MZ) {
  1104. a = parseFloat(px*px+py*py);
  1105. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1106. 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]);
  1107. delta = b*b-a*c
  1108. if(delta >= 0) {
  1109. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1110. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1111. if(t0 <= tmax && t1 >= 0) {
  1112. // 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
  1113. //res = true;
  1114. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1115. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1116. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1117. // Roule : pas utile pour nous
  1118. //res = true;
  1119. //chute.push([x0+l*px, y0+l*py]);
  1120. return true;
  1121. }
  1122. }
  1123. }
  1124. }
  1125. //return res;
  1126. return false;
  1127. };
  1128.  
  1129. var dessine_carte = function () {
  1130. dessin.width = 200*coeff+2*decalh;
  1131. dessin.height = 200*coeff+2*decalv;
  1132.  
  1133. //repere
  1134. ctx.beginPath();
  1135. ctx.moveTo(coord_x(0), coord_y(100));
  1136. ctx.lineTo(coord_x(0), coord_y(-100));
  1137. ctx.moveTo(coord_x(-100), coord_y(0));
  1138. ctx.lineTo(coord_x(100), coord_y(0));
  1139. ctx.stroke();
  1140. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1141.  
  1142. //trous
  1143. ctx.fillStyle = couleur_trou;
  1144. for(var i in position_trous_MZ) {
  1145. ctx.beginPath();
  1146. 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);
  1147. ctx.fill();
  1148. }
  1149. // trajets
  1150. ctx.lineCap = "round";
  1151. ctx.lineJoin = "round";
  1152. for (var iSuivant in tabDepl) {
  1153. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1154. var tabDeplOneSuivant = tabDepl[iSuivant];
  1155. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1156. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1157. // La "cible" au départ
  1158. var typeDepart = tabDeplOneSuivant[0].typ;
  1159. switch (typeDepart) {
  1160. case 'tp':
  1161. ctx.beginPath();
  1162. ctx.lineWidth = 2;
  1163. ctx.strokeStyle = couleur_cible;
  1164. ctx.fillStyle = couleur_cible;
  1165. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1166. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1167. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1168. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1169. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1170. ctx.moveTo(x0 + coeff * 3, y0);
  1171. ctx.lineTo(x0 - coeff * 3, y0);
  1172. ctx.moveTo(x0, y0 + coeff * 3);
  1173. ctx.lineTo(x0, y0 - coeff * 3);
  1174. ctx.stroke();
  1175. break;
  1176. default:
  1177. ctx.beginPath();
  1178. ctx.lineWidth = 1;
  1179. ctx.strokeStyle = couleur_cible;
  1180. ctx.fillStyle = couleur_cible;
  1181. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1182. ctx.moveTo(x0 + coeff * 4, y0);
  1183. ctx.lineTo(x0 - coeff * 4, y0);
  1184. ctx.moveTo(x0, y0 + coeff * 4);
  1185. ctx.lineTo(x0, y0 - coeff * 4);
  1186. ctx.stroke();
  1187. break;
  1188. }
  1189. // les segments
  1190. var nb_pts = tabDeplOneSuivant.length;
  1191. var pointPrecedent = tabDeplOneSuivant[0];
  1192. for (var i=1; i<nb_pts; i++) {
  1193. ctx.beginPath();
  1194. ctx.lineWidth = coeff;
  1195. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1196. ctx.strokeStyle = couleur_depl_normal;
  1197. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1198. if (pointIntermediaire === undefined) {
  1199. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1200. ctx.strokeStyle = couleur_depl_collision_trou;
  1201. else
  1202. ctx.strokeStyle = couleur_depl_normal;
  1203. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1204. } else {
  1205. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1206. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1207. ctx.strokeStyle = couleur_depl_collision_trou;
  1208. else
  1209. ctx.strokeStyle = couleur_depl_normal;
  1210. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1211. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1212. }
  1213. pointPrecedent = tabDeplOneSuivant[i];
  1214. ctx.stroke();
  1215. }
  1216. // Les points à chaque étape
  1217. ctx.fillStyle = couleur_depl_normal;
  1218. for (var i=1; i<nb_pts; i++) {
  1219. ctx.beginPath();
  1220. var x = coord_x(tabDeplOneSuivant[i].x);
  1221. var y = coord_y(tabDeplOneSuivant[i].y);
  1222. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1223. ctx.fill();
  1224. }
  1225. }
  1226. }
  1227.  
  1228. this.setZoom = function (val) {
  1229. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1230. coeff = val / 50;
  1231. dessine_carte();
  1232. }
  1233.  
  1234. // glissiere
  1235. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1236. var eGliss = gliss.getElt();
  1237. eGliss.style.position = 'absolute';
  1238. eGliss.style.top = (coeff * 2) + 'px';
  1239. eGliss.style.left = decalh + 'px';
  1240. dessin.style.position = 'relative';
  1241. div2_carte.style.position = 'relative';
  1242. eGliss.style.zIndex = 9000;
  1243. div2_carte.appendChild(eGliss);
  1244.  
  1245. // affichage au survol de la souris
  1246. var bulle = document.createElement('div');
  1247. bulle.style.visibility = 'hidden';
  1248. bulle.style.position = 'absolute';
  1249. bulle.style.zIndex = 3100;
  1250. bulle.style.border = 'solid 1px #a1927f';
  1251. bulle.className = 'mh_tdpage';
  1252. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1253. var bulleHaut = document.createElement('div');
  1254. bulleHaut.style.display = 'block';
  1255. bulleHaut.style.paddingRight = '3px';
  1256. bulleHaut.className = 'mh_tdtitre';
  1257. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1258. bulle.appendChild(bulleHaut);
  1259. var bulleBas = document.createElement('div');
  1260. bulleBas.style.display = 'block';
  1261. bulleBas.style.whiteSpace = "nowrap";
  1262. bulleBas.style.paddingRight = '3px';
  1263.  
  1264. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1265. bulle.appendChild(bulleBas);
  1266. div2_carte.appendChild(bulle);
  1267. var affichePosition = function(evt) {
  1268. if (evt.offsetX) {
  1269. var xsouris = evt.offsetX;
  1270. var ysouris = evt.offsetY;
  1271. var xpos = evt.clientX;
  1272. var ypos = evt.clientY + document.body.scrollTop;
  1273. }
  1274. else {
  1275. var xsouris = evt.layerX;
  1276. var ysouris = evt.layerY;
  1277. var xpos = evt.pageX;
  1278. var ypos = evt.pageY;
  1279. }
  1280. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1281. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1282. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1283. var tabHTMLbas = [];
  1284. // message pour les trous
  1285. for (var i in position_trous_MZ) {
  1286. var ceTrou = position_trous_MZ[i];
  1287. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1288. if(dist <= 0) {
  1289. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1290. break;
  1291. }
  1292. }
  1293. // messages pour les suivants
  1294. for (var i in tabDepl) {
  1295. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1296. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1297. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1298. }
  1299. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1300. bulle.style.top = (ysouris+8) + 'px';
  1301. bulle.style.left = (xsouris+16) + 'px';
  1302. };
  1303. addEvent(dessin, "mousemove", affichePosition, true);
  1304. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1305. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1306.  
  1307. // dessin initial
  1308. dessine_carte();
  1309.  
  1310. this.getElt = function() {return div1_carte;};
  1311.  
  1312. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1313. }
  1314.  
  1315.  
  1316. /**********************************************************
  1317. **** Fin de zone à déplacer dans une bibli commune ********
  1318. **********************************************************/
  1319.  
  1320. /* DEBUG: NETTOYAGE TAGS */
  1321. if(MY_getValue(numTroll+'.TAGSURL')) {
  1322. MY_removeValue(numTroll+'.TAGSURL');
  1323. }
  1324.  
  1325. // Alerte si mode dev
  1326. if (isDEV) {
  1327. var divpopup = document.createElement('div');
  1328. divpopup.id = 'divDEV';
  1329. divpopup.style =
  1330. 'position: fixed;'+
  1331. 'border: 15px solid red;'+
  1332. 'top: 10px;right: 10px;'+
  1333. 'background-color: white;'+
  1334. 'color: black;'+
  1335. 'font-size: large;'+
  1336. 'padding: 5px'+
  1337. 'z-index: 200;';
  1338. appendText(divpopup, '[MZ] Mode DEV');
  1339. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1340. document.body.appendChild(divpopup);
  1341. }
  1342.  
  1343. /*---------- regroupement des getPortee() ------------------------------------*/
  1344. // issu des script profil et profil2
  1345. function getPortee__Profil(param) {
  1346. param = Math.max(0,Number(param));
  1347. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1348. // ça devrait être floor, +10.25, -2.5
  1349. }
  1350.  
  1351. // issu du script vue
  1352. function getPortee__Vue(param) {
  1353. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1354. }
  1355.  
  1356.  
  1357. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1358.  
  1359. function getPXKill(niv) {
  1360. return Math.max(0,10+3*niv-2*nivTroll);
  1361. }
  1362.  
  1363. function getPXDeath(niv) {
  1364. return Math.max(0,10+3*nivTroll-2*niv);
  1365. }
  1366.  
  1367. function analysePX(niv) {
  1368. niv = niv+'';
  1369. var i = niv.indexOf('+');
  1370. if(i!=-1) // si niv = 'XX+' ??
  1371. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1372. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1373. if(i!=-1) {
  1374. var max = getPXKill(niv.slice(i+2));
  1375. if(max==0)
  1376. return ' --> <b>0</b> PX';
  1377. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1378. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1379. }
  1380. i = niv.indexOf('='); // ???
  1381. if(i!=-1) {
  1382. var max = getPXKill(niv.slice(i+1));
  1383. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1384. }
  1385. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1386. }
  1387.  
  1388. function analysePXTroll(niv) {
  1389. var str = analysePX(niv);
  1390. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1391. return str;
  1392. }
  1393.  
  1394.  
  1395. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1396. // Refonte totale du code de Zorya
  1397.  
  1398. // Elements à implémenter en dur dans MZ2.0
  1399. var numQualite = {
  1400. 'Très Mauvaise':1,
  1401. 'Mauvaise':2,
  1402. 'Moyenne':3,
  1403. 'Bonne':4,
  1404. 'Très Bonne':5
  1405. };
  1406.  
  1407. var qualiteNum = [
  1408. '_dummy_',
  1409. 'Très Mauvaise',
  1410. 'Mauvaise',
  1411. 'Moyenne',
  1412. 'Bonne',
  1413. 'Très Bonne'
  1414. ];
  1415.  
  1416. var nival = {
  1417. 'Abishaii Bleu':19,
  1418. 'Abishaii Noir':10,
  1419. 'Abishaii Rouge':23,
  1420. 'Abishaii Vert':15,
  1421. 'Ame-en-peine':8,
  1422. 'Amibe Geante':9,
  1423. 'Anaconda des Catacombes':8,
  1424. 'Ankheg':10,
  1425. 'Anoploure Purpurin':36,
  1426. 'Araignee Geante':2,
  1427. 'Ashashin':35,
  1428. 'Balrog':50,
  1429. 'Banshee':16,
  1430. 'Barghest':36,
  1431. 'Basilisk':11,
  1432. 'Behemoth':34,
  1433. 'Behir':14,
  1434. 'Beholder':50,
  1435. 'Boggart':3,
  1436. 'Bondin':9,
  1437. "Bouj'Dla Placide":37,
  1438. "Bouj'Dla":19,
  1439. 'Bulette':19,
  1440. 'Caillouteux':1,
  1441. 'Capitan':35,
  1442. 'Carnosaure':25,
  1443. 'Champi-Glouton':3,
  1444. 'Chauve-Souris Geante':4,
  1445. 'Cheval a Dents de Sabre':23,
  1446. 'Chevalier du Chaos':20,
  1447. 'Chimere':13,
  1448. 'Chonchon':24,
  1449. 'Coccicruelle':22,
  1450. 'Cockatrice':5,
  1451. 'Crasc Medius':17,
  1452. 'Crasc Maexus':25,
  1453. 'Crasc':10,
  1454. 'Croquemitaine':6,
  1455. 'Cube Gelatineux':32,
  1456. 'Daemonite':27,
  1457. 'Diablotin':5,
  1458. 'Dindon du Chaos':1,
  1459. 'Djinn':29,
  1460. 'Ectoplasme':18,
  1461. 'Effrit':27,
  1462. "Elementaire d'Air":23,
  1463. "Elementaire d'Eau":17,
  1464. 'Elementaire de Feu':21,
  1465. 'Elementaire de Terre':21,
  1466. 'Elementaire du Chaos':26,
  1467. 'Erinyes':7,
  1468. 'Esprit-Follet':16,
  1469. 'Essaim Craterien':30,
  1470. 'Essaim Sanguinaire':25,
  1471. 'Ettin':8,
  1472. 'Familier':1,
  1473. 'Fantome':24,
  1474. 'Feu Follet':20,
  1475. 'Flagelleur Mental':33,
  1476. 'Foudroyeur':38,
  1477. 'Fumeux':22,
  1478. 'Fungus Geant':9,
  1479. 'Fungus Violet':4,
  1480. 'Furgolin':10,
  1481. 'Gargouille':3,
  1482. 'Geant de Pierre':13,
  1483. 'Geant des Gouffres':22,
  1484. "Geck'oo Majestueux":40,
  1485. "Geck'oo":15,
  1486. 'Glouton':20,
  1487. 'Gnoll':5,
  1488. 'Gnu Domestique':1,
  1489. 'Gnu Sauvage':1,
  1490. 'Goblin':4,
  1491. 'Goblours':4,
  1492. "Golem d'Argile":15,
  1493. 'Golem de cuir':1,
  1494. 'Golem de Chair':8,
  1495. 'Golem de Fer':31,
  1496. 'Golem de mithril':1,
  1497. 'Golem de metal':1,
  1498. 'Golem de papier':1,
  1499. 'Golem de Pierre':23,
  1500. 'Gorgone':11,
  1501. 'Goule':4,
  1502. 'Gowap Apprivoise':1,
  1503. 'Gowap Sauvage':1,
  1504. 'Gremlins':3,
  1505. 'Gritche':39,
  1506. 'Grouilleux':4,
  1507. 'Grylle':31,
  1508. 'Harpie':4,
  1509. 'Hellrot':18,
  1510. 'Homme-Lezard':4,
  1511. 'Hurleur':8,
  1512. 'Hydre':50,
  1513. 'Incube':13,
  1514. 'Kobold':2,
  1515. 'Labeilleux':26,
  1516. 'Lezard Geant':5,
  1517. 'Liche':50,
  1518. 'Limace Geante':10,
  1519. 'Loup-Garou':8,
  1520. 'Lutin':4,
  1521. 'Mante Fulcreuse':30,
  1522. 'Manticore':9,
  1523. 'Marilith':33,
  1524. 'Meduse':6,
  1525. 'Megacephale':38,
  1526. 'Mille-Pattes Geant':14,
  1527. 'Mimique':6,
  1528. 'Minotaure':7,
  1529. 'Molosse Satanique':8,
  1530. 'Momie':4,
  1531. 'Monstre Rouilleur':3,
  1532. "Mouch'oo Domestique":14,
  1533. "Mouch'oo Majestueux Sauvage":33,
  1534. "Mouch'oo Sauvage":14,
  1535. 'Na-Haniym-Heee':0,
  1536. 'Necrochore':37,
  1537. 'Necromant':39,
  1538. 'Necrophage':8,
  1539. 'Naga':10,
  1540. 'Nuee de Vermine':13,
  1541. "Nuage d'Insectes":7,
  1542. 'Ogre':7,
  1543. 'Ombre de Roches':13,
  1544. 'Ombre':2,
  1545. 'Orque':3,
  1546. 'Ours-Garou':18,
  1547. 'Palefroi Infernal':29,
  1548. 'Phoenix':32,
  1549. 'Pititabeille':0,
  1550. 'Plante Carnivore':4,
  1551. 'Pseudo-Dragon':5,
  1552. 'Rat Geant':2,
  1553. 'Rat-Garou':3,
  1554. 'Rocketeux':5,
  1555. 'Sagouin':3,
  1556. 'Scarabee Geant':4,
  1557. 'Scorpion Geant':10,
  1558. 'Shai':28,
  1559. 'Sirene':8,
  1560. 'Slaad':5,
  1561. 'Sorciere':17,
  1562. 'Spectre':14,
  1563. 'Sphinx':30,
  1564. 'Squelette':1,
  1565. 'Strige':2,
  1566. 'Succube':13,
  1567. 'Tertre Errant':20,
  1568. 'Thri-kreen':10,
  1569. 'Tigre-Garou':12,
  1570. 'Titan':26,
  1571. 'Trancheur':35,
  1572. 'Tubercule Tueur':14,
  1573. 'Tutoki':4,
  1574. 'Vampire':29,
  1575. 'Ver Carnivore Geant':12,
  1576. 'Ver Carnivore':11,
  1577. 'Veskan Du Chaos':14,
  1578. 'Vouivre':33,
  1579. 'Worg':5,
  1580. 'Xorn':14,
  1581. 'Yeti':8,
  1582. 'Yuan-ti':15,
  1583. 'Zombie':2
  1584. }
  1585.  
  1586. var tabEM = {
  1587. //Monstre: [Compo exact, Sort, Position, Localisation]
  1588. // AA
  1589. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1590. // AE
  1591. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1592. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1593. // AdA
  1594. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1595. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1596. // AdE
  1597. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1598. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1599. // AdD
  1600. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1601. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1602. // BAM
  1603. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1604. // BuM
  1605. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1606. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1607. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1608. // Explo
  1609. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1610. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1611. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1612. // FP
  1613. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1614. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1615. // FA
  1616. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1617. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1618. // Glue
  1619. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1620. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1621. // GdS
  1622. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1623. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1624. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1625. // Invi
  1626. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1627. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1628. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1629. // Lévitation
  1630. // ???
  1631. // PréM :
  1632. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1633. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1634. // Proj
  1635. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1636. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1637. // PuM :
  1638. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1639. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1640. // Sacro
  1641. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1642. // Télék
  1643. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1644. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1645. // TP
  1646. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1647. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1648. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1649. // VA
  1650. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1651. // VL
  1652. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1653. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1654. // VlC
  1655. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1656. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1657. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1658. // VT
  1659. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1660. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1661. // Variables
  1662. 'Rat':["d'un"],
  1663. 'Rat Géant':["d'un"],
  1664. 'Dindon':["d'un"],
  1665. 'Goblin':["d'un"],
  1666. 'Limace':["d'une"],
  1667. 'Limace Géante':["d'une"],
  1668. 'Ver':["d'un"],
  1669. 'Ver Carnivore':["d'un"],
  1670. 'Ver Carnivore Géant':["d'un"],
  1671. 'Fungus':["d'un"],
  1672. 'Vouivre':["d'une"],
  1673. 'Gnu':["d'un"],
  1674. 'Scarabée':["d'un"]
  1675. };
  1676.  
  1677. var mundiChampi = {
  1678. 'Préscientus Reguis':'du Phoenix',
  1679. 'Amanite Trolloïde':'de la Mouche',
  1680. 'Girolle Sanglante':'du Dindon',
  1681. 'Horreur Des Prés':'du Gobelin',
  1682. 'Bolet Péteur':'du Démon',
  1683. 'Pied Jaune':'de la Limace',
  1684. 'Agaric Sous-Terrain':'du Rat',
  1685. 'Suinte Cadavre':"de l'Hydre",
  1686. 'Cèpe Lumineux':'du Ver',
  1687. 'Fungus Rampant':'du Fungus',
  1688. 'Nez Noir':'de la Vouivre',
  1689. 'Pleurote Pleureuse':'du Gnu',
  1690. 'Phytomassus Xilénique':'du Scarabée'
  1691. };
  1692.  
  1693. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1694. appendText(node,' ');
  1695. var urlImg = URL_MZimg
  1696. +'Competences/melangeMagique.png';
  1697. var text = ' [-'+(niv+effetQ)+' %]';
  1698. var str = '';
  1699. switch(mob[0]) {
  1700. case 'A':
  1701. case 'E':
  1702. case 'I':
  1703. case 'O':
  1704. case 'U':
  1705. str = "Compo d'";
  1706. break;
  1707. default:
  1708. str = 'Compo de ';
  1709. }
  1710. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1711. var span = createImageSpan(urlImg,'MM:',title,text);
  1712. node.appendChild(span);
  1713. }
  1714. function addInfoEM(node,mob,compo,qualite,localisation) {
  1715. if(!tabEM[mob]) return;
  1716. var title = 'Composant variable', texte = 'Variable';
  1717. var bold = false;
  1718. if(tabEM[mob].length>1) {
  1719. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1720. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1721. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1722. if(pc<-20) return;
  1723. if(pc>=0) bold = true;
  1724. texte = aff(pc)+'%';
  1725. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1726. }
  1727. var urlImg = URL_MZimg
  1728. +'Competences/ecritureMagique.png';
  1729. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1730. node.appendChild(span);
  1731. }
  1732.  
  1733. function insererInfosEM(tbody) {
  1734. // lancé par equip, equipgowap
  1735. var trCompos = document.evaluate(
  1736. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1737. tbody,null,7,null);
  1738. var strCompos = '';
  1739. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1740. var node = trCompos.snapshotItem(i).childNodes[7];
  1741. var str = node.firstChild.textContent;
  1742. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1743. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1744. // Si non-EM on stoppe le traitement
  1745. if(!tabEM[mob]) continue;
  1746. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1747. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1748. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1749. addInfoEM(node,mob,compo,qualite,localisation);
  1750. }
  1751. }
  1752.  
  1753. function getQualite(qualite) {
  1754. var nb = numQualite[qualite];
  1755. return nb ? nb-1 : -1;
  1756. }
  1757.  
  1758. function getEM(nom) {
  1759. if(nom.indexOf('[')!=-1)
  1760. nom = trim(nom.substring(0,nom.indexOf('[')));
  1761. if(tabEM[nom]) return nom;
  1762. return '';
  1763. }
  1764.  
  1765. // DEBUG ex-fonction composantEM
  1766. function compoMobEM(mob) {
  1767. if(!tabEM[mob]) return '';
  1768. if(tabEM[mob].length==1)
  1769. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1770. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1771. +") pour l'écriture de "+tabEM[mob][1];
  1772. }
  1773.  
  1774. // DEBUG ex-fonction compoEM
  1775. function titreCompoEM(mob,compo,localisation,qualite) {
  1776. if(!tabEM[mob]) return '';
  1777. if(tabEM[mob].length==1) return 'Composant variable';
  1778. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1779. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1780. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1781. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1782. return '';
  1783. }
  1784.  
  1785. // DEBUG - rétrocompatibilité
  1786. function compoEM(mob) {
  1787. // appelé dans libs, vue
  1788. return compoMobEM(mob);
  1789. }
  1790. function composantEM(mob,compo,localisation,qualite) {
  1791. // appelé dans libs, tancompo
  1792. return titreCompoEM(mob,compo,localisation,qualite);
  1793. }
  1794. //
  1795.  
  1796.  
  1797. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1798.  
  1799. arrayTalents = {
  1800. /* Compétences */
  1801. 'Acceleration du Metabolisme':'AM',
  1802. 'Attaque Precise':'AP',
  1803. 'Balayage':'Balayage',
  1804. //'Balluchonnage':'Ballu',
  1805. 'Baroufle':'Baroufle',
  1806. 'Bidouille':'Bidouille',
  1807. 'Botte Secrete':'BS',
  1808. 'Camouflage':'Camou',
  1809. 'Charger':'Charger',
  1810. 'Connaissance des Monstres':'CdM',
  1811. 'Construire un Piege':'Piege',
  1812. 'Piege a Feu':'PiegeFeu',
  1813. 'Piege a Glue':'PiegeGlue',
  1814. 'Contre-Attaquer':'CA',
  1815. 'Coup de Butoir':'CdB',
  1816. 'Course':'Course',
  1817. 'Deplacement Eclair':'DE',
  1818. 'Dressage':'Dressage',
  1819. 'Ecriture Magique':'EM',
  1820. 'Frenesie':'Frenesie',
  1821. 'Golemologie':'Golemo',
  1822. 'Golem de cuir':'GolemCuir',
  1823. 'Golem de metal':'GolemMetal',
  1824. 'Golem de mithril':'GolemMithril',
  1825. 'Golem de papier':'GolemPapier',
  1826. 'Grattage':'Grattage',
  1827. 'Hurlement Effrayant':'HE',
  1828. 'Identification des Champignons':'IdC',
  1829. 'Insultes':'Insultes',
  1830. 'Lancer de Potions':'LdP',
  1831. 'Marquage':'Marquage',
  1832. 'Melange Magique':'Melange',
  1833. 'Miner':'Miner',
  1834. 'Necromancie':'Necro',
  1835. 'Painthure de Guerre':'PG',
  1836. 'Parer':'Parer',
  1837. 'Pistage':'Pistage',
  1838. 'Planter un Champignon':'PuC',
  1839. 'Regeneration Accrue':'RA',
  1840. 'Reparation':'Reparation',
  1841. 'Retraite':'Retraite',
  1842. 'Rotobaffe':'RB',
  1843. 'Shamaner':'Shamaner',
  1844. "S'interposer":'SInterposer',
  1845. 'Tailler':'Tailler',
  1846. //'Vol':'Vol',
  1847. /* Sortilèges */
  1848. 'Analyse Anatomique':'AA',
  1849. 'Armure Etheree':'AE',
  1850. 'Augmentation de l´Attaque':'AdA',
  1851. 'Augmentation de l´Esquive':'AdE',
  1852. 'Augmentation des Degats':'AdD',
  1853. 'Bulle Anti-Magie':'BAM',
  1854. 'Bulle Magique':'BuM',
  1855. 'Explosion':'Explo',
  1856. 'Faiblesse Passagere':'FP',
  1857. 'Flash Aveuglant':'FA',
  1858. 'Glue':'Glue',
  1859. 'Griffe du Sorcier':'GdS',
  1860. 'Hypnotisme':'Hypno',
  1861. 'Identification des tresors':'IdT',
  1862. 'Invisibilite':'Invi',
  1863. 'Levitation':'Levitation',
  1864. 'Precision Magique':'PreM',
  1865. 'Projectile Magique':'Projo',
  1866. 'Projection':'Proj',
  1867. 'Puissance Magique':'PuM',
  1868. 'Rafale Psychique':'Rafale',
  1869. 'Sacrifice':'Sacro',
  1870. 'Siphon des ames':'Siphon',
  1871. 'Telekinesie':'Telek',
  1872. 'Teleportation':'TP',
  1873. 'Vampirisme':'Vampi',
  1874. 'Vision Accrue':'VA',
  1875. 'Vision lointaine':'VL',
  1876. 'Voir le Cache':'VlC',
  1877. 'Vue Troublee':'VT'
  1878. //'':''
  1879. }
  1880.  
  1881. // DEBUG - Pour rétrocompatibilité
  1882. function getSortComp(nom,niveau) {
  1883. return getTalent(nom,niveau);
  1884. }
  1885. //
  1886.  
  1887. function getTalent(nom,niveau) {
  1888. var nomEnBase = arrayTalents[epure(nom)];
  1889. if(!nomEnBase) return 0;
  1890. if(!niveau) var niveau = '';
  1891. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1892. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1893. return 0;
  1894. }
  1895.  
  1896. function removeAllTalents() {
  1897. for(var talent in arrayTalents) {
  1898. var nomEnBase = arrayTalents[talent];
  1899. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1900. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1901. continue;
  1902. }
  1903. var niveau = 1;
  1904. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1905. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1906. niveau++;
  1907. }
  1908. }
  1909. }
  1910.  
  1911. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1912. var att = MY_getValue(numTroll+'.caracs.attaque');
  1913. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1914. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1915. var mm = MY_getValue(numTroll+'.caracs.mm');
  1916. var deg = MY_getValue(numTroll+'.caracs.degats');
  1917. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1918. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1919. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1920. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1921. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1922. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1923. return false;
  1924. return true;
  1925. }
  1926.  
  1927.  
  1928. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1929.  
  1930. function getPVsRestants(pv,bless,vue) {
  1931. bless = Number(bless.match(/\d+/)[0]);
  1932. if(bless==0) return null;
  1933. var pvminmax = pv.match(/\d+/g);
  1934. if(bless==95) {
  1935. var pvb = 1;
  1936. var pvh = Math.floor( pvminmax[1]/20 );
  1937. }
  1938. else if(bless==5) {
  1939. var pvb = Math.floor( pvminmax[0]*19/20 );
  1940. var pvh = pvminmax[1];
  1941. }
  1942. else {
  1943. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1944. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1945. }
  1946. return vue ? ' ('+pvb+'-'+pvh+')' :
  1947. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1948. }
  1949.  
  1950. function insertButtonCdm(nextName,onClick,texte) {
  1951. if(texte==null) texte = 'Participer au bestiaire';
  1952. var nextNode = document.getElementsByName(nextName)[0];
  1953.  
  1954. var espace = document.createTextNode('\t');
  1955. insertBefore(nextNode,espace);
  1956.  
  1957. var button = document.createElement('input');
  1958. button.type = 'button';
  1959. button.className = 'mh_form_submit';
  1960. button.value = texte;
  1961. button.onmouseover = function(){this.style.cursor='pointer';};
  1962. if(onClick) button.onclick = onClick;
  1963. insertBefore(espace,button);
  1964. return button;
  1965. }
  1966.  
  1967. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1968. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1969. 'Capacité spéciale','Résistance Magique','Autres'];
  1970.  
  1971. function createImageTactique(url,id,nom) {
  1972. var img = document.createElement('img');
  1973. img.src = url;
  1974. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1975. img.id = id;
  1976. img.nom = nom;
  1977. img.onmouseover = showPopupTactique;
  1978. img.onmouseout = hidePopup;
  1979. return img;
  1980. }
  1981.  
  1982. function createCDMTable(id,nom,donneesMonstre) {
  1983. try {
  1984. var urlImg = URL_MZimg;
  1985. var table = document.createElement('table');
  1986. var profilActif = isProfilActif();
  1987. table.className = 'mh_tdborder';
  1988. table.border = 0;
  1989. table.cellSpacing = 1;
  1990. table.cellPadding = 4;
  1991. var thead = document.createElement('thead');
  1992. var tr = appendTr(thead,'mh_tdtitre');
  1993. var td = appendTdText(tr,
  1994. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1995. true
  1996. );
  1997. td.colSpan = 2;
  1998. table.appendChild(thead);
  1999. var tbody = document.createElement('tbody');
  2000. table.appendChild(tbody);
  2001. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2002. createCase(listeTitres[i],tbody,80);
  2003. }
  2004. var TypeMonstre = getEM(nom);
  2005. var infosCompo='';
  2006. if(TypeMonstre!='') {
  2007. infosCompo = compoEM(TypeMonstre);
  2008. }
  2009. var nodes = tbody.childNodes;
  2010. nodes[0].childNodes[1].innerHTML =
  2011. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2012. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2013. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2014. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2015. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2016. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2017. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2018. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2019. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2020. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2021. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2022. td = createCase(listeTitres[10],tbody);
  2023. td.innerHTML = bbcode(donneesMonstre[10]);
  2024. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2025. td.appendChild(document.createTextNode(" "));
  2026. if(donneesMonstre[16] == "De zone")
  2027. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2028. else if(donneesMonstre[16] == "Automatique")
  2029. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2030. else if(donneesMonstre[16] == "Au toucher")
  2031. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2032. }
  2033. }
  2034. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2035. {
  2036. td = createCase(listeTitres[11],tbody);
  2037. td.innerHTML = bbcode(donneesMonstre[9]);
  2038. // seuil de résistance du monstre
  2039. var lb = td.getElementsByTagName('b');
  2040. if(lb.length == 1) {
  2041. var mrm = lb[0].firstChild.nodeValue * 1;
  2042. var v = (mrm / mmTroll);
  2043. lb[0].firstChild.nodeValue += " ("
  2044. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2045. }
  2046. }
  2047. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2048. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2049. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2050. {
  2051. td = createCase(listeTitres[12],tbody);
  2052. if(donneesMonstre[12]==1)
  2053. {
  2054. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2055. }
  2056. if(donneesMonstre[13]==1)
  2057. {
  2058. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2059. }
  2060. else if(donneesMonstre[13]==0)
  2061. {
  2062. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2063. }
  2064. if(donneesMonstre[14]==1)
  2065. {
  2066. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2067. }
  2068. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2069. {
  2070. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2071. }
  2072. else if(donneesMonstre[14]>6)
  2073. {
  2074. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2075. }
  2076. if(donneesMonstre[15]=="Lente")
  2077. {
  2078. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2079. }
  2080. else if(donneesMonstre[15]=="Normale")
  2081. {
  2082. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2083. }
  2084. else if(donneesMonstre[15]=="Rapide")
  2085. {
  2086. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2087. }
  2088. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2089. {
  2090. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2091. }
  2092. if(infosCompo.length>0)
  2093. {
  2094. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2095. }
  2096. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2097. {
  2098. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2099. }
  2100. }
  2101. // pourcentage de blessure
  2102. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2103. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2104. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2105. if(pvs)
  2106. lb[0].firstChild.nodeValue += pvs;
  2107. }
  2108. return table;
  2109. }
  2110. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2111. }
  2112.  
  2113.  
  2114. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2115.  
  2116. var listeMonstreEnchantement = null,
  2117. listeEquipementEnchantement = null,
  2118. listeInfoEnchantement = null;
  2119.  
  2120. function computeCompoEnchantement()
  2121. {
  2122. listeMonstreEnchantement = new Array();
  2123. listeInfoEnchantement = new Array();
  2124. listeEquipementEnchantement = new Array();
  2125. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2126. for(var i=0;i<liste.length;i++)
  2127. {
  2128. var idEquipement = liste[i]*1;
  2129. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2130. continue;
  2131. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2132. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2133. var texteGlobal='';
  2134. for(var j=0;j<3;j++)
  2135. {
  2136. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  2137. listeMonstreEnchantement[infoComposant[2]] = 1;
  2138. var array = new Array();
  2139. array[0]=infoComposant[0].replace("Ril","Œil");
  2140. array[1]=infoComposant[1];
  2141. array[2]=infoComposant[2];
  2142. array[3]=getQualite(infoComposant[3]);
  2143. var texte = infoComposant[4].replace("Ril","Œil");
  2144. for(var k=5;k<infoComposant.length;k++)
  2145. {
  2146. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2147. }
  2148. texteGlobal+=texte+'\n';
  2149. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2150. array[4]=texte;
  2151. listeInfoEnchantement.push(array);
  2152. }
  2153. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2154. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2155. }
  2156. }
  2157.  
  2158. function isEnchant(nom) {
  2159. var monstreEnchant = '';
  2160. for(j in listeInfoEnchantement) {
  2161. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2162. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2163. monstreEnchant=monstre;
  2164. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2165. }
  2166. }
  2167. return trim(monstreEnchant);
  2168. }
  2169.  
  2170. function getInfoEnchantementFromMonstre(nom)
  2171. {
  2172. try
  2173. {
  2174. if(!listeMonstreEnchantement)
  2175. {
  2176. computeCompoEnchantement();
  2177. }
  2178. var infosEnchant = '';
  2179. for(j in listeInfoEnchantement) {
  2180. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2181. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2182. if(infosEnchant=='')
  2183. infosEnchant=listeInfoEnchantement[j][4];
  2184. else
  2185. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2186. }
  2187. }
  2188. return trim(infosEnchant);
  2189. }
  2190. catch(e)
  2191. {
  2192. window.alert(e);
  2193. }
  2194. }
  2195.  
  2196. function composantEnchant(Monstre,composant,localisation,qualite) {
  2197. var compo='';
  2198. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2199. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2200. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2201. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2202. listeInfoEnchantement[i][3]<=qualite
  2203. ) {
  2204. return listeInfoEnchantement[i][4];
  2205. }
  2206. }
  2207. return compo;
  2208. }
  2209.  
  2210. function insertEnchantInfos(tbody) {
  2211. try
  2212. {
  2213. if(!listeMonstreEnchantement)
  2214. computeCompoEnchantement();
  2215. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2216. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2217. if(nodes.snapshotLength == 0)
  2218. return false;
  2219. var urlImg = URL_MZimg + 'enchant.png';
  2220. for(var i = 0; i < nodes.snapshotLength; i++) {
  2221. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2222. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2223. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2224. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2225. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2226. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2227. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2228. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2229. if(isEnchant(nomMonstre).length>0)
  2230. {
  2231. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2232. if(infos.length>0)
  2233. {
  2234. if(link.parentNode == link.nextSibling.parentNode)
  2235. {
  2236. var tmp = link.nextSibling;
  2237. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2238. }
  2239. else
  2240. {
  2241. link.parentNode.appendChild(createImage(urlImg,infos));
  2242. }
  2243. }
  2244. }
  2245. }
  2246. }
  2247. catch(e)
  2248. {
  2249. window.alert(e);
  2250. }
  2251. }
  2252.  
  2253. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2254. {
  2255. try
  2256. {
  2257. if(!listeMonstreEnchantement)
  2258. computeCompoEnchantement();
  2259. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2260. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2261. if(nodes.snapshotLength == 0)
  2262. return false;
  2263. var urlImg = URL_MZimg + 'enchant.png';
  2264. for(var i = 0; i < nodes.snapshotLength; i++)
  2265. {
  2266. var link = nodes.snapshotItem(i);
  2267. var idEquipement = link.getAttribute('href');
  2268. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2269. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2270. var nomEquipement = trim(link.firstChild.nodeValue);
  2271. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2272. if(!enchanteur || enchanteur == '')
  2273. continue;
  2274. var infos = listeEquipementEnchantement[idEquipement];
  2275. infos=formateTexte(infos);
  2276. if(infos.length>0)
  2277. {
  2278. if(link.parentNode == link.nextSibling.parentNode)
  2279. {
  2280. var tmp = link.nextSibling;
  2281. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2282. }
  2283. else
  2284. {
  2285. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2286. }
  2287. }
  2288. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2289. }
  2290. }
  2291. catch(e)
  2292. {
  2293. window.alert(e);
  2294. }
  2295. }
  2296.  
  2297. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2298.  
  2299.  
  2300. // Les % de toucher
  2301. var c = new Array();
  2302.  
  2303. // coefficients binomiaux
  2304. function cnp(n,k)
  2305. {
  2306. if(c[n] != null && c[n][k] != null)
  2307. return c[n][k];
  2308. if(c[n] == null)
  2309. c[n] = new Array();
  2310. if(k==0)
  2311. {
  2312. c[n][k] = 1;
  2313. return 1;
  2314. }
  2315. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2316. c[n][k] = result;
  2317. // Roule debug
  2318. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2319. return result;
  2320. }
  2321.  
  2322. // by Dab, à comparer
  2323. function binom(n,p) {
  2324. if(p<0 || p>n) return 0;
  2325. if(c[n])
  2326. if(c[n][p]) return c[n][p];
  2327. else {
  2328. c[n]=[1];
  2329. c[n][n]=1;
  2330. if(p==0 || p==n) return 1;
  2331. }
  2332. if(2*p>n)
  2333. c[n][p]=binom(n,n-p);
  2334. else
  2335. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2336. return c[n][p];
  2337. }
  2338.  
  2339. var coeff = new Array();
  2340.  
  2341. function coef(n,p)
  2342. {
  2343. if(n==0 && p==0)
  2344. return 1;
  2345. if(p>n*3.5)
  2346. p = 7*n-p
  2347. // roule désactive cache
  2348. if(coeff[n] != null && coeff[n][p] !=null)
  2349. return coeff[n][p];
  2350. if(coeff[n] == null)
  2351. coeff[n] = new Array();
  2352. var kmax = Math.floor((p-n)/6);
  2353. var x=0;
  2354. for(var k=0;k<=kmax;k++)
  2355. {
  2356. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2357. }
  2358. coeff[n][p] = x;
  2359. // Roule debug
  2360. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2361. return x;
  2362. }
  2363.  
  2364. function chanceEsquiveParfaite(a,d,ba,bd)
  2365. {
  2366. var win = 0;
  2367. var los = 0;
  2368. if(ba==null)
  2369. ba=0;
  2370. if(bd==null)
  2371. bd=0;
  2372. /* if(6*a+ba<2*(d+bd))
  2373. return 100;
  2374. if(a+ba>2*(6*d+bd))
  2375. return 0;*/
  2376. for(var ds=d;ds<=6*d;ds++)
  2377. {
  2378. var cd = coef(d,ds);
  2379. for(var as=a;as<=6*a;as++)
  2380. {
  2381. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2382. win += cd * coef(a,as);
  2383. else
  2384. los += cd * coef(a,as);
  2385. }
  2386. }
  2387. // roule debug
  2388. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2389. return Math.round(100*win/(win+los));
  2390. }
  2391.  
  2392. function chanceTouche(a,d,ba,bd)
  2393. {
  2394. var win = 0;
  2395. var los = 0;
  2396. if(ba==null)
  2397. ba=0;
  2398. if(bd==null)
  2399. bd=0;
  2400. if(a+ba>6*d+bd)
  2401. return 100;
  2402. if(6*a+ba<d+bd)
  2403. return 0;
  2404. for(var ds=d;ds<=6*d;ds++)
  2405. {
  2406. var cd = coef(d,ds);
  2407. for(var as=a;as<=6*a;as++)
  2408. {
  2409. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2410. win += cd * coef(a,as);
  2411. else
  2412. los += cd * coef(a,as);
  2413. }
  2414. }
  2415. return Math.round(100*win/(win+los));
  2416. }
  2417.  
  2418. function chanceCritique(a,d,ba,bd)
  2419. {
  2420. var win = 0;
  2421. var los = 0;
  2422. if(ba==null)
  2423. ba=0;
  2424. if(bd==null)
  2425. bd=0;
  2426. if(a+ba>2*(6*d+bd))
  2427. return 100;
  2428. if(6*a+ba<2*(d+bd))
  2429. return 0;
  2430. for(var ds=d;ds<=6*d;ds++)
  2431. {
  2432. var cd = coef(d,ds);
  2433. for(var as=a;as<=6*a;as++)
  2434. {
  2435. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2436. win += cd * coef(a,as);
  2437. else
  2438. los += cd * coef(a,as);
  2439. }
  2440. }
  2441. return Math.round(100*win/(win+los));
  2442. }
  2443.  
  2444. /***********************************************
  2445. Analyse tactique
  2446. ***********************************************/
  2447.  
  2448. function getTexteAnalyse(modificateur,chiffre)
  2449. {
  2450. if(chiffre==0)
  2451. return chiffre;
  2452. return modificateur+chiffre;
  2453. }
  2454.  
  2455. // rend le HTML pour le tableau de la "calculette"
  2456. function getAnalyseTactique(id,nom)
  2457. {
  2458. var donneesMonstre = listeCDM[id];
  2459. var needAutres=false;
  2460. var i;
  2461. if(donneesMonstre == null)
  2462. return;
  2463. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2464. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2465. if(array==null)
  2466. return "";
  2467. 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>";
  2468. for(i=0;i<array.length;i++)
  2469. {
  2470. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2471. {
  2472. needAutres=true;
  2473. break;
  2474. }
  2475. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2476. 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>";
  2477. else if(i==0) // attaque du monstre sur le Trõll => italique
  2478. 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>";
  2479. else // autre, pas de décoration
  2480. 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>";
  2481. }
  2482. if(needAutres)
  2483. {
  2484. if(i==array.length-1)
  2485. 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>";
  2486. else if(i==1)
  2487. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2488. else
  2489. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2490. }
  2491. return str+"</table>";
  2492. }
  2493.  
  2494. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2495. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2496. function analyseTactique(donneesMonstre,nom) {
  2497. try
  2498. {
  2499. var listeAttaques = [];
  2500. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2501. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2502. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2503. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2504. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2505. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2506. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2507. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2508. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2509. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2510. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2511. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2512. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2513. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2514. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2515. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2516. var modificateurEsquive = '';
  2517. var modificateurArmure = '';
  2518. var modificateurMagie = '';
  2519. var modificateurEsquiveM = '';
  2520. var modificateurArmureM = '';
  2521. var pasDeSR=false;
  2522. var esqM,attM,armM,degM;
  2523. 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)
  2524. return null;
  2525. var td = document.createElement('td')
  2526. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2527. var esqM = 0;
  2528. try
  2529. {
  2530. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2531. }
  2532. catch(e)
  2533. {
  2534. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2535. modificateurEsquive = '<';
  2536. modificateurArmure = '<';
  2537. modificateurMagie = '<';
  2538. }
  2539. td.innerHTML = bbcode(donneesMonstre[3]);
  2540. var attM = 0;
  2541. try
  2542. {
  2543. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2544. }
  2545. catch(e)
  2546. {
  2547. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2548. modificateurEsquiveM = '>';
  2549. modificateurArmureM = '>';
  2550. }
  2551. td.innerHTML = bbcode(donneesMonstre[5]);
  2552. var degM = 0;
  2553. try
  2554. {
  2555. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2556. }
  2557. catch(e)
  2558. {
  2559. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2560. modificateurArmureM = '>';
  2561. }
  2562. td.innerHTML = bbcode(donneesMonstre[7]);
  2563. var armM = 0;
  2564. try
  2565. {
  2566. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2567. }
  2568. catch(e)
  2569. {
  2570. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2571. modificateurArmure = '<';
  2572. }
  2573. var coeffSeuil = 0.95;
  2574. try
  2575. {
  2576. td.innerHTML = bbcode(donneesMonstre[9]);
  2577. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2578. var v = (rm / mm);
  2579. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2580. coeffSeuil = (200-seuil)/200;
  2581. }
  2582. catch(e)
  2583. {
  2584. modificateurMagie = '<';
  2585. pasDeSR = true;
  2586. }
  2587. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2588. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2589. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2590. // roule debug
  2591. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2592. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2593. 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);
  2594. //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);
  2595. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2596. if(getSortComp("Vampirisme")>0)
  2597. {
  2598. var pour = getSortComp("Vampirisme");
  2599. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2600. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2601. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2602. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2603. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2604. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2605. }
  2606. if(getSortComp("Siphon des âmes")>0)
  2607. {
  2608. var pour = getSortComp("Siphon des âmes");
  2609. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2610. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2611. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2612. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2613. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2614. }
  2615. if(getSortComp("Botte Secrète")>0)
  2616. {
  2617. var pour = getSortComp("Botte Secrète");
  2618. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2619. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2620. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2621. 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;
  2622. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2623. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2624. }
  2625. if(getSortComp("Rafale Psychique")>0)
  2626. {
  2627. var pour = getSortComp("Rafale Psychique");
  2628. chanceDEsquiveParfaite = 0;
  2629. chanceDeTouche = Math.round(100*pour/100);
  2630. chanceDeCritique = Math.round(0*pour/100);
  2631. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2632. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2633. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2634. }
  2635. if(getSortComp("Explosion")>0)
  2636. {
  2637. var pour = getSortComp("Explosion");
  2638. chanceDEsquiveParfaite = 0;
  2639. chanceDeTouche = Math.round(100*pour/100);
  2640. chanceDeCritique = Math.round(0*pour/100);
  2641. 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;
  2642. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2643. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2644. }
  2645. if(getSortComp("Projectile Magique")>0)
  2646. {
  2647. var pour = getSortComp("Projectile Magique");
  2648. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2649. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2650. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2651. 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;
  2652. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2653. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2654. }
  2655. if(getSortComp("Frénésie")>0)
  2656. {
  2657. var pour = getSortComp("Frénésie");
  2658. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2659. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2660. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2661. 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;
  2662. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2663. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2664. }
  2665. if(getSortComp("Charger")>0)
  2666. {
  2667. var pour = getSortComp("Charger");
  2668. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2669. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2670. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2671. 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;
  2672. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2673. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2674. }
  2675. if(getSortComp("Griffe du Sorcier")>0)
  2676. {
  2677. var pour = getSortComp("Griffe du Sorcier");
  2678. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2679. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2680. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2681. 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;
  2682. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2683. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2684. }
  2685. if(getSortComp("Attaque Précise",1)>0)
  2686. {
  2687. var niveau = 5;
  2688. var oldPour = 0;
  2689. var chanceDEsquiveParfaite = 0;
  2690. var chanceDeTouche = 0;
  2691. var chanceDeCritique = 0;
  2692. degats = 0;
  2693. while(niveau>0)
  2694. {
  2695. var pour = getSortComp("Attaque Précise",niveau);
  2696. if(pour>oldPour)
  2697. {
  2698. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2699. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2700. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2701. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2702. chanceDeTouche += chanceDeToucheNiveau;
  2703. chanceDeCritique += chanceDeCritiqueNiveau;
  2704. 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);
  2705. oldPour = pour;
  2706. }
  2707. niveau--;
  2708. }
  2709. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2710. 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));
  2711. }
  2712. if(getSortComp("Coup de Butoir",1)>0)
  2713. {
  2714. var niveau = 5;
  2715. var oldPour =0;
  2716. var chanceDEsquiveParfaite = 0;
  2717. var chanceDeTouche=0;
  2718. var chanceDeCritique=0;
  2719. degats=0;
  2720. while(niveau>0)
  2721. {
  2722. var pour = getSortComp("Coup de Butoir",niveau);
  2723. if(pour>oldPour)
  2724. {
  2725. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2726. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2727. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2728. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2729. chanceDeTouche += chanceDeToucheNiveau;
  2730. chanceDeCritique += chanceDeCritiqueNiveau;
  2731. 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);
  2732. oldPour = pour;
  2733. }
  2734. niveau--;
  2735. }
  2736. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2737. 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));
  2738. }
  2739. 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;});
  2740. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2741. {
  2742. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2743. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2744. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2745. }
  2746. else
  2747. {
  2748. chanceDEsquiveParfaite = 0;
  2749. chanceDeTouche = 100;
  2750. chanceDeCritique = 0;
  2751. }
  2752. 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;
  2753.  
  2754. 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));
  2755. return listeAttaques;
  2756. }
  2757. catch(e) { window.alert(e);}
  2758. }
  2759.  
  2760. // x~~x marque pour s'y retrouver sous l'éditeur
  2761.  
  2762. /*
  2763. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2764. * published under GNU License v2.
  2765. *
  2766. * Patch :
  2767. * gestion des missions terminées
  2768. */
  2769. // x~x mission_liste
  2770.  
  2771. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2772. try {
  2773. var titresMimis = document.evaluate(
  2774. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2775. document, null, 7, null
  2776. );
  2777. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2778. } catch(e) {
  2779. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2780. return;
  2781. }
  2782. var enCours = {};
  2783. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2784. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2785. enCours[num] = true;
  2786. }
  2787. for(var numMimi in obMissions) {
  2788. if(!enCours[numMimi]) {
  2789. delete obMissions[numMimi];
  2790. }
  2791. }
  2792. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2793. }
  2794.  
  2795. function do_mission_liste() {
  2796. checkLesMimis();
  2797. }
  2798.  
  2799. /*******************************************************************************
  2800. * This file is part of Mountyzilla. *
  2801. * *
  2802. * Mountyzilla is free software; you can redistribute it and/or modify *
  2803. * it under the terms of the GNU General Public License as published by *
  2804. * the Free Software Foundation; either version 2 of the License, or *
  2805. * (at your option) any later version. *
  2806. * *
  2807. * Mountyzilla is distributed in the hope that it will be useful, *
  2808. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2809. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2810. * GNU General Public License for more details. *
  2811. * *
  2812. * You should have received a copy of the GNU General Public License *
  2813. * along with Mountyzilla; if not, write to the Free Software *
  2814. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2815. *******************************************************************************/
  2816.  
  2817. // x~x actions
  2818.  
  2819. /* TODO
  2820. * getLvl pour Explo, Rotobaffe et cie
  2821. */
  2822.  
  2823.  
  2824.  
  2825. /* Page de combat */
  2826.  
  2827. function getLevel() {
  2828. var divList = document.getElementsByTagName('div');
  2829. if(divList.length <= 2)
  2830. return;
  2831. // On essaie de voir si cette action était une attaque
  2832. var pList = document.getElementsByTagName('p');
  2833. var nomM = '';
  2834. // Modification pour Frénésie by TetDure
  2835. var numAtt = 0;
  2836. for (var i = 0; i < pList.length; i++) {
  2837. if(pList[i].firstChild) {
  2838. nomM = pList[i].firstChild.nodeValue;
  2839. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2840. numAtt++;
  2841. }
  2842. }
  2843. if(nomM == '')
  2844. return;
  2845. // Si c'est une attaque normale, un seul PX
  2846. var comPX = 1;
  2847. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2848. comPX++;
  2849.  
  2850. // Extraction des infos du monstre attaqué
  2851. var idM;
  2852. var male;
  2853. if(nomM.slice(20, 21) == 'e') {
  2854. male = false;
  2855. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2856. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2857. }
  2858. else {
  2859. male = true;
  2860. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2861. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2862. }
  2863. if(idM == '')
  2864. return;
  2865. var bList = document.getElementsByTagName('b');
  2866. var niveau = '';
  2867. for (var i = 0; i < bList.length; i++) {
  2868. var b = bList[i];
  2869. if(b.childNodes[0].nodeValue != "TUÉ")
  2870. continue;
  2871. var nbPX = "";
  2872. for (i++; i < bList.length; i++) {
  2873. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2874. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2875. return;
  2876. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2877. nbPX = bList[i].childNodes[0].nodeValue;
  2878. break;
  2879. }
  2880. }
  2881. if(nbPX == '')
  2882. return;
  2883. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2884. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2885. if(!nbPX)
  2886. nbPX = 0;
  2887. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2888. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2889. if(comPX > nbPX) {
  2890. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2891. niveau = "";
  2892. } else if(Math.floor(niveau) == niveau) {
  2893. chaine += niveau + ".";
  2894. } else {
  2895. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2896. niveau = "";
  2897. }
  2898. insertBr(b.nextSibling.nextSibling.nextSibling);
  2899. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2900. }
  2901.  
  2902. if(niveau != '') {
  2903. var button = insertButtonCdm('as_Action');
  2904. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2905. + escape(nomM) + "&niveau=" + escape(niveau)
  2906. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2907. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2908. }
  2909. }
  2910.  
  2911.  
  2912. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2913.  
  2914. function insertInfoMagie(node, intitule, magie) {
  2915. if(node.nextSibling) {
  2916. node = node.nextSibling;
  2917. insertBr(node);
  2918. insertText(node, intitule);
  2919. insertText(node, magie, true);
  2920. } else {
  2921. node = node.parentNode;
  2922. appendBr(node);
  2923. appendText(node, intitule);
  2924. appendText(node, magie, true);
  2925. }
  2926. }
  2927.  
  2928. function getMM(sr) {
  2929. if(rmTroll<=0) {
  2930. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2931. }
  2932. sr = Number(sr.match(/\d+/)[0]);
  2933. if(sr==10) {
  2934. return '\u2265 '+5*rmTroll;
  2935. }
  2936. if(sr<=50) {
  2937. return Math.round(50*rmTroll/sr);
  2938. }
  2939. if(sr<90) {
  2940. return Math.round((100-sr)*rmTroll/50);
  2941. }
  2942. return '\u2264 '+Math.round(rmTroll/5);
  2943. }
  2944.  
  2945. function traiteMM() {
  2946. var node = document.evaluate(
  2947. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2948. document, null, 9, null).singleNodeValue;
  2949. if(node) {
  2950. var mm = getMM(node.nodeValue);
  2951. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2952. } else {
  2953. var node = document.evaluate(
  2954. "//p/text()[contains(., 'Seuil de Résistance')]",
  2955. document, null, 9, null).singleNodeValue;
  2956. if(!node) {
  2957. return;
  2958. }
  2959. var mm = getMM(node.nodeValue);
  2960. node = node.nextSibling.nextSibling;
  2961. }
  2962. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2963. }
  2964.  
  2965. function getRM(sr) {
  2966. if(mmTroll<=0) {
  2967. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2968. }
  2969. sr = Number(sr.match(/\d+/)[0]);
  2970. if(sr==10) {
  2971. return '\u2264 '+Math.round(mmTroll/5);
  2972. }
  2973. if(sr<=50) {
  2974. return Math.round(sr*mmTroll/50);
  2975. }
  2976. if(sr<90) {
  2977. return Math.round(50*mmTroll/(100-sr));
  2978. }
  2979. return '\u2265 '+5*mmTroll;
  2980. }
  2981.  
  2982. function traiteRM() {
  2983. var nodes = document.evaluate(
  2984. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2985. document, null, 7, null);
  2986. if(nodes.snapshotLength==0) {
  2987. return;
  2988. }
  2989. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2990. var node = nodes.snapshotItem(i);
  2991. var rm = getRM(node.nodeValue);
  2992. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2993. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2994. }
  2995. }
  2996.  
  2997.  
  2998. /* Fonction stats IdT par Raistlin */
  2999. /*function getIdt() {
  3000. if(MY_getValue("SEND_IDT") == "non")
  3001. return false;
  3002. var regExpBeginning = /^\s+/;
  3003. var regExpEnd = /\s+$/;
  3004.  
  3005. var nomIdt = document.evaluate(
  3006. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3007. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3008. if(!nomIdt)
  3009. return false;
  3010.  
  3011. var caracIdt;
  3012. if(nomIdt.indexOf("Malédiction !") != -1) {
  3013. caracIdt = "";
  3014. nomIdt = "Mission maudite";
  3015. } else {
  3016. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3017. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3018. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3019. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3020. }
  3021. FF_XMLHttpRequest({
  3022. method: 'GET',
  3023. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3024. headers : {
  3025. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3026. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3027. }
  3028. });
  3029. return true;
  3030. }*/
  3031.  
  3032.  
  3033. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3034.  
  3035. function confirmeDecalage() {
  3036. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3037. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3038. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3039. var newDLA = new Date( oldDLA );
  3040. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3041. return window.confirm(
  3042. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3043. +'\nConfirmez-vous ce décalage ?'
  3044. );
  3045. }
  3046.  
  3047. function newsubmitDLA(evt) {
  3048. evt.stopPropagation();
  3049. evt.preventDefault();
  3050. if(confirmeDecalage()) {
  3051. this.submit();
  3052. }
  3053. }
  3054.  
  3055. function changeActionDecalage() {
  3056. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3057. return;
  3058. }
  3059. try {
  3060. // On récupère le contenu du script JS MH de calcul du décalage
  3061. var scriptTxt = document.evaluate(
  3062. ".//script[ not(@src) ]",
  3063. document, null, 9, null
  3064. ).singleNodeValue.textContent;
  3065. // On en extrait la DLA courante
  3066. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3067. scriptTxt = scriptTxt.split('\n')[0];
  3068. var nbs = scriptTxt.match(/\d+/g);
  3069. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3070. } catch(e) {
  3071. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3072. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3073. return;
  3074. }
  3075. var form = document.getElementsByName('ActionForm')[0];
  3076. if(form) {
  3077. form.addEventListener('submit', newsubmitDLA, true);
  3078. } else {
  3079. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3080. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3081. }
  3082. }
  3083.  
  3084. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3085.  
  3086. function prochainMundi() {
  3087. try {
  3088. var node = document.evaluate(
  3089. "//div[@class='dateAction']/b",
  3090. document, null, 9, null
  3091. ).singleNodeValue;
  3092. } catch(e) {
  3093. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3094. return;
  3095. }
  3096. if(!node) { return; }
  3097.  
  3098. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3099. var jour = longueurMois+1-getNumber(node.textContent);
  3100. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3101. var txt = '[Prochain Mundidey ';
  3102. if(jour>1) {
  3103. txt += 'dans '+jour+' jours]';
  3104. } else {
  3105. txt += 'demain]';
  3106. }
  3107. insertText(node.parentNode.nextSibling,txt,true);
  3108. }
  3109.  
  3110.  
  3111. /* Fonction principale */
  3112.  
  3113. function dispatch() {
  3114. if(isPage('MH_Play/Play_action')) {
  3115. prochainMundi();
  3116. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3117. var oldDLA;
  3118. changeActionDecalage();
  3119. } else if(isPage('MH_Play/Actions')) {
  3120. if(document.evaluate(
  3121. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3122. document, null, 2, null
  3123. ).stringValue) {
  3124. traiteMM();
  3125. } else if(document.evaluate(
  3126. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3127. document, null, 2, null
  3128. ).stringValue) {
  3129. //getIdt();
  3130. traiteRM();
  3131. } /*else {
  3132. // Est censé se lancer sur quoi *précisément* ?
  3133. traiteRM();
  3134. getLevel();
  3135. }*/
  3136. } else {
  3137. /* Traitement des messages du bot */
  3138. var messageTitle = document.evaluate(
  3139. "//form/table/tbody/tr[1]/td[1]/"
  3140. +"descendant::text()[contains(.,'[MountyHall]')]",
  3141. document, null, 2, null
  3142. ).stringValue;
  3143. if(messageTitle.indexOf('Attaquant') != -1 &&
  3144. messageTitle.indexOf('sur') != -1) {
  3145. getLevel();
  3146. traiteRM();
  3147. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3148. messageTitle.indexOf('Défenseur') != -1) {
  3149. traiteMM();
  3150. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3151. // à replacer avec Attaque après révision getLvl :
  3152. messageTitle.indexOf('Explosion') != -1 ||
  3153. messageTitle.indexOf('Insulte') != -1) {
  3154. traiteRM();
  3155. }
  3156. }
  3157. }
  3158.  
  3159. function do_actions() {
  3160. start_script(31);
  3161. dispatch();
  3162. displayScriptTime();
  3163. }
  3164.  
  3165. /*********************************************************************************
  3166. * This file is part of Mountyzilla. *
  3167. * *
  3168. * Mountyzilla is free software; you can redistribute it and/or modify *
  3169. * it under the terms of the GNU General Public License as published by *
  3170. * the Free Software Foundation; either version 2 of the License, or *
  3171. * (at your option) any later version. *
  3172. * *
  3173. * Mountyzilla is distributed in the hope that it will be useful, *
  3174. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3175. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3176. * GNU General Public License for more details. *
  3177. * *
  3178. * You should have received a copy of the GNU General Public License *
  3179. * along with Mountyzilla; if not, write to the Free Software *
  3180. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3181. *********************************************************************************/
  3182.  
  3183. // x~x pre-enchant
  3184.  
  3185. /* 2013-08-19 : correction auto syntaxe alert */
  3186.  
  3187. var combobox=null;
  3188.  
  3189. function changeObject()
  3190. {
  3191. if(!combobox)
  3192. return ;
  3193. var id = combobox.options[combobox.selectedIndex].value;
  3194. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3195. if(!id || id=="")
  3196. {
  3197. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3198. return;
  3199. }
  3200. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3201. }
  3202.  
  3203. function treatePreEnchantement() {
  3204. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3205. if(!input || input.getAttribute("type")=="hidden")
  3206. {
  3207. return false;
  3208. }
  3209. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3210. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3211. if(!combobox)
  3212. {
  3213. return true;
  3214. }
  3215. combobox.addEventListener('change', changeObject, true);
  3216. return true;
  3217. }
  3218.  
  3219. function treateEnchantement() {
  3220. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3221. if(!input || input.getAttribute("type")!="hidden")
  3222. {
  3223. return false;
  3224. }
  3225. var idEquipement = input.getAttribute("value");
  3226. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3227. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3228. if(enchanteur && enchanteur != null)
  3229. return true;
  3230. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3231. if(!input || input.getAttribute("type")!="hidden")
  3232. {
  3233. return false;
  3234. }
  3235. var idEnchanteur = input.getAttribute("value");
  3236. var nodes = document.evaluate(
  3237. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3238. if (nodes.snapshotLength != 3)
  3239. return;
  3240. for(var i=0;i<3;i++)
  3241. {
  3242. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3243. texte = texte.replace(" d'une "," d'un ");
  3244. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3245. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3246. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3247. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3248. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3249. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3250. }
  3251. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3252. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3253. var liste = MY_getValue(numTroll+".enchantement.liste");
  3254. if(!liste || liste=="")
  3255. {
  3256. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3257. }
  3258. else
  3259. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3260. }
  3261.  
  3262. function do_pre_enchant() {
  3263. start_script(60);
  3264. if(!treatePreEnchantement())
  3265. treateEnchantement();
  3266. displayScriptTime();
  3267. }
  3268.  
  3269. /*********************************************************************************
  3270. * This file is part of Mountyzilla. *
  3271. * *
  3272. * Mountyzilla is free software; you can redistribute it and/or modify *
  3273. * it under the terms of the GNU General Public License as published by *
  3274. * the Free Software Foundation; either version 2 of the License, or *
  3275. * (at your option) any later version. *
  3276. * *
  3277. * Mountyzilla is distributed in the hope that it will be useful, *
  3278. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3279. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3280. * GNU General Public License for more details. *
  3281. * *
  3282. * You should have received a copy of the GNU General Public License *
  3283. * along with Mountyzilla; if not, write to the Free Software *
  3284. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3285. *********************************************************************************/
  3286.  
  3287. // x~x enchant
  3288.  
  3289. /* 2013-08-19 : correction auto syntaxe alert */
  3290.  
  3291. function treateEnchantement() {
  3292. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3293. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3294. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3295. return;
  3296. var tab = infoEquipement.split(";");
  3297. if(tab.length<2)
  3298. return;
  3299. var idEquipement = tab[0];
  3300. var nomEquipement = tab[1];
  3301. for(var i=2;i<tab.length;i++)
  3302. nomEquipement += ";"+tab[i];
  3303. var nodes = document.evaluate(
  3304. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3305. if (nodes.snapshotLength != 3)
  3306. return;
  3307. for(var i=0;i<3;i++)
  3308. {
  3309. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3310. texte = texte.replace(" d'une "," d'un ");
  3311. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3312. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3313. monstre = monstre.replace(/ Géante?/,"");
  3314. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3315. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3316. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3317. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3318. }
  3319. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3320. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3321. var liste = MY_getValue(numTroll+".enchantement.liste");
  3322. if(!liste || liste=="")
  3323. {
  3324. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3325. }
  3326. else
  3327. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3328. }
  3329.  
  3330. function do_enchant() {
  3331. start_script(60);
  3332.  
  3333. treateEnchantement();
  3334. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3335. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3336. displayScriptTime();
  3337. }
  3338.  
  3339. /*********************************************************************************
  3340. * This file is part of Mountyzilla. *
  3341. * *
  3342. * Mountyzilla is free software; you can redistribute it and/or modify *
  3343. * it under the terms of the GNU General Public License as published by *
  3344. * the Free Software Foundation; either version 2 of the License, or *
  3345. * (at your option) any later version. *
  3346. * *
  3347. * Mountyzilla is distributed in the hope that it will be useful, *
  3348. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3349. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3350. * GNU General Public License for more details. *
  3351. * *
  3352. * You should have received a copy of the GNU General Public License *
  3353. * along with Mountyzilla; if not, write to the Free Software *
  3354. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3355. *********************************************************************************/
  3356.  
  3357. // x~x myevent
  3358.  
  3359. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3360. function do_myevent() {
  3361. }
  3362.  
  3363. /*********************************************************************************
  3364. * This file is part of Mountyzilla. *
  3365. * *
  3366. * Mountyzilla is free software; you can redistribute it and/or modify *
  3367. * it under the terms of the GNU General Public License as published by *
  3368. * the Free Software Foundation; either version 2 of the License, or *
  3369. * (at your option) any later version. *
  3370. * *
  3371. * Mountyzilla is distributed in the hope that it will be useful, *
  3372. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3373. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3374. * GNU General Public License for more details. *
  3375. * *
  3376. * You should have received a copy of the GNU General Public License *
  3377. * along with Mountyzilla; if not, write to the Free Software *
  3378. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3379. *********************************************************************************/
  3380.  
  3381. // x~x malus
  3382.  
  3383. /* v1.4 - 2014-01-06
  3384. * - Gestion des sorts double composante
  3385. * v1.4.1 - 2014-01-22
  3386. * - Correction décumul
  3387. * TODO
  3388. * - Identifier la position de "PV" dans l'ordre MH
  3389. */
  3390.  
  3391. var listeBM;
  3392.  
  3393.  
  3394. /* [functions] Utilitaires */
  3395.  
  3396. function decumul(bmt,nbr) {
  3397. var bmr;
  3398. if(!nbr || nbr<2) bmr = bmt;
  3399. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3400. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3401. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3402. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3403. else bmr = parseInt(0.1*bmt);
  3404. if(bmt<0) return Math.min(-1,bmr);
  3405. return Math.max(1,bmr);
  3406. }
  3407.  
  3408. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3409. // Roule 23/11/2016 ajout PV
  3410. switch( a ) {
  3411. case 'ATT':
  3412. return -1;
  3413. case 'ESQ':
  3414. if(b=='ATT') return 1;
  3415. return -1;
  3416. case 'DEG':
  3417. switch( b ) {
  3418. case 'ATT':
  3419. case 'ESQ':
  3420. return 1;
  3421. default:
  3422. return -1;
  3423. }
  3424. case 'REG':
  3425. switch( b ) {
  3426. case 'ATT':
  3427. case 'ESQ':
  3428. case 'DEG':
  3429. return 1;
  3430. default:
  3431. return -1;
  3432. }
  3433. case 'Vue':
  3434. switch( b ) {
  3435. case 'ATT':
  3436. case 'ESQ':
  3437. case 'DEG':
  3438. case 'REG':
  3439. return 1;
  3440. default:
  3441. return -1;
  3442. }
  3443. case 'TOUR':
  3444. switch( b ) {
  3445. case 'ATT':
  3446. case 'ESQ':
  3447. case 'DEG':
  3448. case 'REG':
  3449. case 'Vue':
  3450. return 1;
  3451. default:
  3452. return -1;
  3453. }
  3454. case 'PV':
  3455. switch( b ) {
  3456. case 'ATT':
  3457. case 'ESQ':
  3458. case 'DEG':
  3459. case 'REG':
  3460. case 'Vue':
  3461. case 'TOUR':
  3462. return 1;
  3463. default:
  3464. return -1;
  3465. }
  3466. case 'Armure':
  3467. switch( b ) {
  3468. case 'ATT':
  3469. case 'ESQ':
  3470. case 'DEG':
  3471. case 'REG':
  3472. case 'Vue':
  3473. case 'TOUR':
  3474. case 'PV':
  3475. return 1;
  3476. default:
  3477. return -1;
  3478. }
  3479. case 'RM':
  3480. switch( b ) {
  3481. case 'ATT':
  3482. case 'ESQ':
  3483. case 'DEG':
  3484. case 'REG':
  3485. case 'Vue':
  3486. case 'TOUR':
  3487. case 'PV':
  3488. case 'Armure':
  3489. return 1;
  3490. default:
  3491. return -1;
  3492. }
  3493. case 'MM':
  3494. switch( b ) {
  3495. case 'ATT':
  3496. case 'ESQ':
  3497. case 'DEG':
  3498. case 'REG':
  3499. case 'Vue':
  3500. case 'TOUR':
  3501. case 'PV':
  3502. case 'Armure':
  3503. case 'RM':
  3504. return 1;
  3505. default:
  3506. return -1;
  3507. }
  3508. case 'Concentration':
  3509. switch( b ) {
  3510. case 'ATT':
  3511. case 'ESQ':
  3512. case 'DEG':
  3513. case 'REG':
  3514. case 'Vue':
  3515. case 'TOUR':
  3516. case 'PV':
  3517. case 'Armure':
  3518. case 'RM':
  3519. case 'MM':
  3520. return 1;
  3521. default:
  3522. return -1;
  3523. }
  3524. case 'Fatigue':
  3525. switch( b ) {
  3526. case 'ATT':
  3527. case 'ESQ':
  3528. case 'DEG':
  3529. case 'REG':
  3530. case 'Vue':
  3531. case 'TOUR':
  3532. case 'PV':
  3533. case 'Armure':
  3534. case 'RM':
  3535. case 'MM':
  3536. case 'Concentration':
  3537. return 1;
  3538. default:
  3539. return -1;
  3540. }
  3541. case "Dés d'attaque":
  3542. switch( b ) {
  3543. case 'ATT':
  3544. case 'ESQ':
  3545. case 'DEG':
  3546. case 'REG':
  3547. case 'Vue':
  3548. case 'TOUR':
  3549. case 'PV':
  3550. case 'Armure':
  3551. case 'RM':
  3552. case 'MM':
  3553. case 'Concentration':
  3554. case 'Fatigue':
  3555. return 1;
  3556. default:
  3557. return -1;
  3558. }
  3559. case 'Dés de dégâts':
  3560. switch( b ) {
  3561. case 'ATT':
  3562. case 'ESQ':
  3563. case 'DEG':
  3564. case 'REG':
  3565. case 'Vue':
  3566. case 'TOUR':
  3567. case 'PV':
  3568. case 'Armure':
  3569. case 'RM':
  3570. case 'MM':
  3571. case 'Concentration':
  3572. case 'Fatigue':
  3573. case "Dés d'attaque":
  3574. return 1;
  3575. default:
  3576. return -1;
  3577. }
  3578. default :
  3579. switch( b ) {
  3580. case 'ATT':
  3581. case 'ESQ':
  3582. case 'DEG':
  3583. case 'REG':
  3584. case 'Vue':
  3585. case 'TOUR':
  3586. case 'PV':
  3587. case 'Armure':
  3588. case 'RM':
  3589. case 'MM':
  3590. case 'Concentration':
  3591. case 'Fatigue':
  3592. case "Dés d'attaque":
  3593. case 'Dés de dégâts':
  3594. return 1;
  3595. default:
  3596. return -1;
  3597. }
  3598. }
  3599. }
  3600.  
  3601.  
  3602. /* [functions] Fonctions hide / display */
  3603.  
  3604. function toggleDetailsBM() {
  3605. if(MY_getValue('BMDETAIL')!='false') {
  3606. MY_setValue('BMDETAIL','false');
  3607. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3608. for(var i=0 ; i<trlist.length ; i++)
  3609. trlist[i].style.display = 'none';
  3610. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3611. for(var i=0 ; i<trlist.length ; i++)
  3612. trlist[i].style = '';
  3613. }
  3614. else {
  3615. MY_setValue('BMDETAIL','true');
  3616. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3617. for(var i=0 ; i<trlist.length ; i++)
  3618. trlist[i].style.display = 'none';
  3619. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3620. for(var i=0 ; i<trlist.length ; i++)
  3621. trlist[i].style = '';
  3622. }
  3623. }
  3624.  
  3625. function toggleBMList() {
  3626. if(MY_getValue('BMHIDELIST')=='true') {
  3627. MY_setValue('BMHIDELIST','false');
  3628. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3629. listeBM.snapshotItem(i).style = '';
  3630. document.getElementsByTagName('thead')[0].style = '';
  3631. document.getElementById('trhelp').style = '';
  3632. }
  3633. else {
  3634. MY_setValue('BMHIDELIST','true');
  3635. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3636. listeBM.snapshotItem(i).style.display = 'none';
  3637. document.getElementsByTagName('thead')[0].style.display = 'none';
  3638. document.getElementById('trhelp').style.display = 'none';
  3639. }
  3640. }
  3641.  
  3642. function setDisplayBM() {
  3643. if(!listeBM) return;
  3644. var titre = document.getElementById('titre2');
  3645. if(titre) {
  3646. titre.style.cursor = 'pointer';
  3647. titre.onclick = toggleBMList;
  3648. }
  3649. var tfoot = document.getElementsByTagName('tfoot')[0];
  3650. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3651. tfoot, null, 9, null).singleNodeValue;
  3652. tr.id = 'trhelp';
  3653. if(MY_getValue('BMHIDELIST')=='true') {
  3654. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3655. listeBM.snapshotItem(i).style.display = 'none';
  3656. document.getElementsByTagName('thead')[0].style.display = 'none';
  3657. tr.style.display = 'none';
  3658. }
  3659. }
  3660.  
  3661.  
  3662. /* [functions] Fonction principale */
  3663.  
  3664. function traiteMalus() {
  3665. var mainTab = document.getElementsByTagName('table')[0];
  3666. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3667. if(listeBM.snapshotLength==0) return;
  3668. /* Suppression des BM de fatigue stockés */
  3669. if(MY_getValue(numTroll+'.bm.fatigue'))
  3670. MY_removeValue(numTroll+'.bm.fatigue');
  3671. /* Extraction des données */
  3672. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3673. var nb = 0;
  3674. while(nb<listeBM.snapshotLength) {
  3675. tr = listeBM.snapshotItem(nb); nb++;
  3676. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3677. var phymag = tr.childNodes[9].textContent;
  3678. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3679. var type = tr.childNodes[3].textContent, nom;
  3680. // si c'est un type à décumul
  3681. /*
  3682. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3683. switch(type) {
  3684. case 'Potion':
  3685. case 'Parchemin':
  3686. case 'Sortilège':
  3687. case 'Capacité Spéciale':
  3688. nom = tr.childNodes[1].textContent+phymag;
  3689. break;
  3690. default:
  3691. nom = 'pasdedecumul';
  3692. }
  3693. */
  3694. nom = tr.childNodes[1].textContent+phymag;
  3695. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3696. nom = 'pasdedecumul';
  3697. uniListe[nb] = {
  3698. 'duree':duree,
  3699. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3700. 'caracs':{}
  3701. }
  3702. for(var i=0 ; i<effetsT.length ; i++) {
  3703. if(effetsT[i].indexOf(':')==-1) continue;
  3704. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3705. // nom = 'pasdedecumul' si pas de décumul
  3706. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3707. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3708. uniListe[nb]['type'] = phymag;
  3709. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3710. var tmatch = effetsT[i].match(/(-?\d+)(\\(-?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3711. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3712. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3713. uniListe[nb]['caracs'][carac] = bm;
  3714. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3715. listeDurees[duree] = true;
  3716. }
  3717. } // fin boucle sur les lignes de bonus/malus
  3718. /* Gestion des décumuls et cumuls des durées */
  3719. var toursGeres = [];
  3720. for(var d in listeDurees) toursGeres.push(d);
  3721. toursGeres.sort( function (a,b){return b-a;} );
  3722. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3723. // pour sauvegarder les bm de fatigue
  3724. var strfat = '';
  3725. // Pour affichage & adpatation à footable.js (statique)
  3726. var thead = document.getElementsByTagName('thead')[0];
  3727. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3728. thead, null, 7, null).snapshotLength;
  3729. var tfoot = document.getElementsByTagName('tfoot')[0];
  3730. for(var i=0 ; i<toursGeres.length ; i++) {
  3731. var tour = toursGeres[i];
  3732. var effetsCeTour = {}; decumulsCeTour = {};
  3733. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3734. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3735. continue;
  3736. var nom = uniListe[nb]['nom'];
  3737. if(nom!='pasdedecumul') {
  3738. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3739. decumulsCeTour[nom]++;
  3740. }
  3741. for(var carac in uniListe[nb]['caracs']) {
  3742. var bm = uniListe[nb]['caracs'][carac];
  3743. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3744. var type = uniListe[nb]['type'];
  3745. if(!effetsCeTour[carac])
  3746. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3747. var thisBm;
  3748. if(nom=='pasdedecumul')
  3749. thisBm = bm;
  3750. else
  3751. thisBm = decumul(bm,decumulsCeTour[nom]);
  3752. effetsCeTour[carac][type] += thisBm;
  3753. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', type=' + type + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac][type]);
  3754. } else {
  3755. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3756. var thisBm;
  3757. if(nom=='pasdedecumul' || carac=='Fatigue')
  3758. thisBm = bm;
  3759. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3760. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3761. else
  3762. thisBm = decumul(bm,decumulsCeTour[nom]);
  3763. effetsCeTour[carac] += thisBm;
  3764. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3765. }
  3766. } // fin boucle sur les caractéristiques
  3767. } // fin boucle sur les bonus/malus
  3768. /* Création du bilan du tour */
  3769. var texteD = '', texteS = '';
  3770. var caracGerees = [];
  3771. for(var k in effetsCeTour) caracGerees.push(k);
  3772. caracGerees.sort( triecaracs );
  3773. for(var j=0 ; j<caracGerees.length ; j++) {
  3774. var carac = caracGerees[j], str = '';
  3775. switch( carac ) {
  3776. case 'ATT':
  3777. case 'DEG':
  3778. case 'Armure':
  3779. var phy = effetsCeTour[carac]['Physique'];
  3780. var mag = effetsCeTour[carac]['Magie'];
  3781. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3782. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3783. break;
  3784. case 'TOUR':
  3785. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3786. break;
  3787. case 'Fatigue':
  3788. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3789. case 'PV':
  3790. case 'ESQ':
  3791. case 'REG':
  3792. case 'Vue':
  3793. case 'Voir le Caché':
  3794. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3795. break;
  3796. default:
  3797. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3798. }
  3799. if(str) {
  3800. texteD += str;
  3801. texteS += str;
  3802. }
  3803. } // fin boucle sur les caractéristiques
  3804. /* Affichage */
  3805. // Si rien à afficher on passe
  3806. if(!texteD) continue;
  3807. // Si BMM+BMP=0
  3808. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3809. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3810. if(MY_getValue('BMDETAIL')=='false')
  3811. tr.style.display = 'none';
  3812. var td = appendTdText(tr,texteD.substring(3));
  3813. td.colSpan = 5-nbHidden;
  3814. var txttour = toursGeres[i]+' Tour';
  3815. if(toursGeres[i]>1) txttour += 's';
  3816. appendTdText(tr,txttour);
  3817. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3818. if(MY_getValue('BMDETAIL')!='false')
  3819. tr.style.display = 'none';
  3820. td = appendTdText(tr,texteS);
  3821. td.colSpan = 5-nbHidden;
  3822. appendTdText(tr,txttour);
  3823. } // fin boucle sur les tours générés
  3824. /* mise en place toggleDetails */
  3825. tfoot.style.cursor = 'pointer';
  3826. tfoot.onclick = toggleDetailsBM;
  3827. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3828. if(strfat)
  3829. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3830. }
  3831.  
  3832. function do_malus() {
  3833. try {
  3834. start_script();
  3835. traiteMalus();
  3836. setDisplayBM();
  3837. displayScriptTime();
  3838. }
  3839. catch(e) {window.alert(e)};
  3840. }
  3841.  
  3842. /*******************************************************************************
  3843. * This file is part of Mountyzilla. *
  3844. * *
  3845. * Mountyzilla is free software; you can redistribute it and/or modify *
  3846. * it under the terms of the GNU General Public License as published by *
  3847. * the Free Software Foundation; either version 2 of the License, or *
  3848. * (at your option) any later version. *
  3849. * *
  3850. * Mountyzilla is distributed in the hope that it will be useful, *
  3851. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3852. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3853. * GNU General Public License for more details. *
  3854. * *
  3855. * You should have received a copy of the GNU General Public License *
  3856. * along with Mountyzilla; if not, write to the Free Software *
  3857. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3858. *******************************************************************************/
  3859.  
  3860. // x~x mouches
  3861.  
  3862. var mainTab, tr_mouches;
  3863.  
  3864. function initialiseMouches() {
  3865. // Lanceur global
  3866. try {
  3867. mainTab = document.getElementById('mouches');
  3868. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3869. } catch(e) {
  3870. avertissement('Erreur MZ:<br />Consulter la console.');
  3871. window.console.error(traceStack(e, 'mouches'));
  3872. return;
  3873. }
  3874. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3875. setDisplayMouches();
  3876. traiteMouches();
  3877. }
  3878.  
  3879. function setDisplayMouches() {
  3880. // Initialise l'affichage / l'effacement du détail des mouches
  3881. var titre = document.getElementById('titre2');
  3882. if(titre) {
  3883. titre.style.cursor = 'pointer';
  3884. titre.onclick = toggleMouches;
  3885. }
  3886. var tfoot = document.getElementsByTagName('tfoot')[0];
  3887. if(tfoot) {
  3888. tfoot.style.cursor = 'pointer';
  3889. tfoot.onclick = toggleMouches;
  3890. }
  3891. if(MY_getValue('HIDEMOUCHES')=='true') {
  3892. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3893. tr_mouches.snapshotItem(i).style.display = 'none';
  3894. }
  3895. document.getElementsByTagName('thead')[0].style.display = 'none';
  3896. }
  3897. }
  3898.  
  3899. function toggleMouches() {
  3900. // Handler pour afficher / masquer les détasil
  3901. if(MY_getValue('HIDEMOUCHES')=='true') {
  3902. MY_setValue('HIDEMOUCHES','false');
  3903. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3904. tr_mouches.snapshotItem(i).style.display = '';
  3905. }
  3906. document.getElementsByTagName('thead')[0].style.display = '';
  3907. } else {
  3908. MY_setValue('HIDEMOUCHES','true');
  3909. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3910. tr_mouches.snapshotItem(i).style.display = 'none';
  3911. }
  3912. document.getElementsByTagName('thead')[0].style.display = 'none';
  3913. }
  3914. }
  3915.  
  3916. function traiteMouches() {
  3917. // Traitement complet: présence et effets des mouches
  3918. var listeTypes = {}, effetsActifs = {};
  3919. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3920. var tr = tr_mouches.snapshotItem(i);
  3921. // La mouche est-elle présente?
  3922. var etat = document.evaluate(
  3923. './img',
  3924. tr.cells[6], null, 9, null
  3925. ).singleNodeValue.alt;
  3926. if(etat!='La Mouche est là') { continue; }
  3927. // Extraction du type de mouche
  3928. var type = trim(tr.cells[3].textContent);
  3929. if(!listeTypes[type]) {
  3930. listeTypes[type] = 1;
  3931. } else {
  3932. listeTypes[type]++;
  3933. }
  3934. // La mouche a-t-elle un effet?
  3935. var effet = trim(tr.cells[2].textContent);
  3936. if(etat!='La Mouche est là' || !effet) { continue; }
  3937. // Si oui, extraction des effets (multiples pour pogées)
  3938. var caracs = effet.split(' | ');
  3939. for(var j=0 ; j<caracs.length ; j++) {
  3940. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3941. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3942. if(effetsActifs[carac]===void(0)) {
  3943. effetsActifs[carac] = valeur;
  3944. } else {
  3945. effetsActifs[carac] += valeur;
  3946. }
  3947. }
  3948. }
  3949. // Extraction Effet total et affichage des différences à la normale
  3950. var tfoot = document.getElementsByTagName('tfoot')[0];
  3951. if(!tfoot) { return; }
  3952. var nodeTotal = document.evaluate(
  3953. ".//b[contains(./text(),'Effet total')]",
  3954. tfoot, null, 9, null
  3955. ).singleNodeValue.nextSibling;
  3956. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3957. var texte = ' ';
  3958. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3959. if(texte.length>1) { texte += ' | '; }
  3960. var carac = trim(
  3961. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3962. );
  3963. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3964. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3965. texte += effetsTheoriques[i];
  3966. } else {
  3967. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3968. if(carac=='TOUR') { texte += ' min'; }
  3969. texte += '</b>';
  3970. }
  3971. }
  3972. var span = document.createElement('span');
  3973. span.innerHTML = texte;
  3974. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3975. // Affichage des différences du nombre de mouches de chaque type
  3976. var mouchesParType = document.evaluate(
  3977. "./tr/td/ul/li/text()",
  3978. tfoot, null, 7, null
  3979. );
  3980. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3981. var node = mouchesParType.snapshotItem(i);
  3982. var mots = node.nodeValue.split(' ');
  3983. var type = mots.pop();
  3984. if(!listeTypes[type]) {
  3985. node.nodeValue += ' (0 présente)';
  3986. } else if(mots[0]!=listeTypes[type]) {
  3987. if(listeTypes[type]==1) {
  3988. node.nodeValue += ' (1 présente)';
  3989. } else {
  3990. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3991. }
  3992. }
  3993. }
  3994. }
  3995.  
  3996. function do_mouches() {
  3997. start_script();
  3998. initialiseMouches();
  3999. displayScriptTime();
  4000. }
  4001.  
  4002. /*********************************************************************************
  4003. * This file is part of Mountyzilla. *
  4004. * *
  4005. * Mountyzilla is free software; you can redistribute it and/or modify *
  4006. * it under the terms of the GNU General Public License as published by *
  4007. * the Free Software Foundation; either version 2 of the License, or *
  4008. * (at your option) any later version. *
  4009. * *
  4010. * Mountyzilla is distributed in the hope that it will be useful, *
  4011. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4012. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4013. * GNU General Public License for more details. *
  4014. * *
  4015. * You should have received a copy of the GNU General Public License *
  4016. * along with Mountyzilla; if not, write to the Free Software *
  4017. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4018. *********************************************************************************/
  4019.  
  4020. // x~x equipgowap
  4021.  
  4022. var popup;
  4023.  
  4024. function initPopupEquipgowap() {
  4025. popup = document.createElement('div');
  4026. popup.setAttribute('id', 'popup');
  4027. popup.setAttribute('class', 'mh_textbox');
  4028. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4029. 'display: inline; z-index: 3; max-width: 400px;');
  4030. document.body.appendChild(popup);
  4031. }
  4032.  
  4033. function showPopupEquipgowap(evt) {
  4034. var texte = this.getAttribute("texteinfo");
  4035. popup.innerHTML = texte;
  4036. popup.style.left = evt.pageX + 15 + 'px';
  4037. popup.style.top = evt.pageY + 'px';
  4038. popup.style.visibility = "visible";
  4039. }
  4040.  
  4041. function hidePopup() {
  4042. popup.style.visibility = "hidden";
  4043. }
  4044.  
  4045. function createPopupImage(url, text)
  4046. {
  4047. var img = document.createElement('img');
  4048. img.setAttribute('src',url);
  4049. img.setAttribute('align','ABSMIDDLE');
  4050. img.setAttribute("texteinfo",text);
  4051. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4052. img.addEventListener("mouseout", hidePopup,true);
  4053. return img;
  4054. }
  4055.  
  4056. function formateTexte(texte)
  4057. {
  4058. texte = texte.replace(/\n/g,"<br/>");
  4059. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4060. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4061. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4062. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4063. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4064. return texte;
  4065. }
  4066.  
  4067.  
  4068. function treateGowaps() {
  4069. //On récupère les gowaps possédants des composants
  4070. var tbodys = document.evaluate(
  4071. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4072. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4073. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4074. var tbody = tbodys.snapshotItem(j);
  4075. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4076. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4077. if(MY_getValue("NOINFOEM") != "true")
  4078. insertEMInfos(tbody);
  4079. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4080. insertEnchantInfos(tbody);
  4081. }
  4082. }
  4083.  
  4084. function treateChampi() {
  4085. if(MY_getValue("NOINFOEM") == "true")
  4086. return false;
  4087. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4088. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4089. if (nodes.snapshotLength == 0)
  4090. return false;
  4091.  
  4092. for (var i = 0; i < nodes.snapshotLength; i++) {
  4093. var node = nodes.snapshotItem(i);
  4094. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4095. if(texte.indexOf("*")!=-1)
  4096. texte = texte.substring(0,texte.lastIndexOf(" "));
  4097. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4098. if(moisChampi[nomChampi])
  4099. {
  4100. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4101. }
  4102. }
  4103. }
  4104.  
  4105. function do_equipgowap() {
  4106. start_script();
  4107.  
  4108. treateGowaps();
  4109. treateChampi();
  4110. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4111. {
  4112. initPopupEquipgowap();
  4113. computeEnchantementEquipement(createPopupImage,formateTexte);
  4114. }
  4115.  
  4116. displayScriptTime();
  4117. }
  4118.  
  4119. /*********************************************************************************
  4120. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4121. *********************************************************************************/
  4122.  
  4123. // x~x ordresgowap
  4124.  
  4125. // version Roule' janvier 2017
  4126. function MZ_setCarteUnGogoHTML5() {
  4127. // fabriquer la liste des positions successives
  4128. var listeDepl = []; // ce sera un tableau d'objets
  4129. // position courrante
  4130. var eTitle = document.getElementById('titre2');
  4131. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4132. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4133. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4134. , y: parseInt(tabPos[1])
  4135. , n: parseInt(tabPos[2])
  4136. , nom: tabNomID[2]
  4137. , id: tabNomID[1]});
  4138. // déplacements
  4139. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4140. for(var i=0 ; i<lignes.length ; i++) {
  4141. if(lignes[i].className == 'mh_tdpage_fo') {
  4142. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4143. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4144. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4145. }
  4146. }
  4147. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4148. }
  4149.  
  4150. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4151. function MZ_showCarteBottom(listeSuiv) {
  4152. // générer la carte
  4153. var carte = new carte_MZ('cartegogo', listeSuiv);
  4154. // positionner la carte
  4155. var eCarte = carte.getElt();
  4156. eCarte.style.textAlign = 'left';
  4157. eCarte.style.marginTop = '2px';
  4158. var footer = document.getElementById('footer1');
  4159. // Lieu_Teleport.php n'a pas de footer1 :(
  4160. if (!footer) footer = document.getElementById('footer2');
  4161. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4162. else document.body.appendChild(eCarte);
  4163. }
  4164.  
  4165. function MZ_setCarteTousGogoHTML5() {
  4166. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4167. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4168. var suivants = [];
  4169. for (var i=0;i<ligne.length;i++) {
  4170. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4171. var cas = ligne[i].getElementsByTagName("td")[0];
  4172. //if (cas.className == "mh_tdtitre") {
  4173. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4174. var oGogo = {};
  4175. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4176. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4177. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4178. oGogo.x = parseInt(point[1]);
  4179. oGogo.y = parseInt(point[2]);
  4180. oGogo.n = parseInt(point[3]);
  4181. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4182. }
  4183. }
  4184. if (suivants.length == 0) return;
  4185. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4186. }
  4187.  
  4188. function MZ_setCarteTP() {
  4189. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4190. 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);
  4191. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4192. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4193. }
  4194.  
  4195. /* v0.2 by Dab - 2013-08-31
  4196. * - correction acquisition posale initiale
  4197. * - correction tare et affichage mire
  4198. */
  4199.  
  4200. function setCarteGogo() {
  4201. try {
  4202. //var pars = document.getElementsByTagName('p');
  4203. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4204. var eTitle = document.getElementById('titre2');
  4205. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4206. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4207. var serv_img_cible = URL_MZimg + "rep.png";
  4208.  
  4209. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4210. //var lignes = pars[0].getElementsByTagName('tr');
  4211. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4212. var nbpt = 0;
  4213. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4214. for(var i=0 ; i<lignes.length ; i++) {
  4215. if(lignes[i].className == 'mh_tdpage_fo') {
  4216. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4217. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4218. if(point) {
  4219. nbpt++;
  4220. trajet += point[1]+','+point[2]+','+point[3]+',';
  4221. }
  4222. }
  4223. }
  4224. }
  4225. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4226. 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'/>";
  4227. var base = [-229,-5];
  4228. if (nbpt>0) {
  4229. base = [-684,-5];
  4230. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4231. }
  4232. 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;'/>";
  4233.  
  4234. 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>';
  4235.  
  4236. var nvspan = document.createElement('div');
  4237. nvspan.align = 'center';
  4238. nvspan.id = 'mz_mapdiv';
  4239. nvspan.valign = 'top';
  4240. nvspan.innerHTML = nvdiv;
  4241. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4242. var footer = document.getElementById('footer1');
  4243. footer.parentNode.insertBefore(nvspan,footer);
  4244. }
  4245.  
  4246. function testeGlissiere() {
  4247. try {
  4248. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4249. var footer = document.getElementById('footer1');
  4250. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4251. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4252. }
  4253.  
  4254. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4255. if (x0 !== undefined) {
  4256. // ouais, récursif une fois
  4257. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4258. if (PtInterm === undefined)
  4259. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4260. else
  4261. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4262. return;
  4263. }
  4264. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4265. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4266. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4267. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4268. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4269. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4270. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4271. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4272. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4273. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4274. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4275. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4276. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4277. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4278. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4279. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4280. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4281. }
  4282.  
  4283. function do_ordresgowap() {
  4284. if (newCarte) {
  4285. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4286. //testeGlissiere();
  4287. //MZ_testsUnitairesCalculIntermediaire();
  4288. } else {
  4289. setCarteGogo(); // Via script des trouillots
  4290. }
  4291. }
  4292.  
  4293. function do_listegowap() {
  4294. if (!newCarte) return;
  4295. MZ_setCarteTousGogoHTML5();
  4296. }
  4297.  
  4298. function do_lieuDescription() {
  4299. if (!newCarte) return;
  4300. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4301. MZ_setCarteTP();
  4302. }
  4303.  
  4304. function do_lieuTeleport() {
  4305. changeButtonValidate();
  4306. if (!newCarte) return;
  4307. MZ_setCarteTP();
  4308. }
  4309.  
  4310. /*********************************************************************************
  4311. * This file is part of Mountyzilla. *
  4312. * *
  4313. * Mountyzilla is free software; you can redistribute it and/or modify *
  4314. * it under the terms of the GNU General Public License as published by *
  4315. * the Free Software Foundation; either version 2 of the License, or *
  4316. * (at your option) any later version. *
  4317. * *
  4318. * Mountyzilla is distributed in the hope that it will be useful, *
  4319. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4320. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4321. * GNU General Public License for more details. *
  4322. * *
  4323. * You should have received a copy of the GNU General Public License *
  4324. * along with Mountyzilla; if not, write to the Free Software *
  4325. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4326. *********************************************************************************/
  4327.  
  4328. // x~x attaque
  4329.  
  4330. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4331.  
  4332. function do_attaque() {
  4333. }
  4334.  
  4335. /*******************************************************************************
  4336. * This file is part of Mountyzilla. *
  4337. * *
  4338. * Mountyzilla is free software; you can redistribute it and/or modify *
  4339. * it under the terms of the GNU General Public License as published by *
  4340. * the Free Software Foundation; either version 2 of the License, or *
  4341. * (at your option) any later version. *
  4342. * *
  4343. * Mountyzilla is distributed in the hope that it will be useful, *
  4344. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4345. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4346. * GNU General Public License for more details. *
  4347. * *
  4348. * You should have received a copy of the GNU General Public License *
  4349. * along with Mountyzilla; if not, write to the Free Software *
  4350. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4351. *******************************************************************************/
  4352.  
  4353. // x~x infomonstre
  4354.  
  4355. // DEBUG
  4356. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4357. // À corriger, évidemment.
  4358. var listeCDM = {};
  4359. var nomMonstre='';
  4360. var idMonstre=-1;
  4361. var tbody;
  4362. var popup;
  4363.  
  4364. function traiteMonstre() {
  4365. try {
  4366. var nodeTitre = document.evaluate(
  4367. "//div[@class='titre2' and contains(text(),'(')]",
  4368. document, null, 9, null
  4369. ).singleNodeValue;
  4370. var texte = nodeTitre.firstChild.nodeValue;
  4371. } catch(e) {
  4372. window.console.log(traceStack(e, 'traiteMonstre'));
  4373. return;
  4374. }
  4375. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4376. if(nomMonstre.indexOf(']')!=-1) {
  4377. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4378. }
  4379. idMonstre = texte.match(/\d+/)[0];
  4380. FF_XMLHttpRequest({
  4381. method: 'GET',
  4382. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4383. +MY_getValue('CDMID')
  4384. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4385. headers : {
  4386. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4387. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4388. },
  4389. onload: function(responseDetails) {
  4390. try {
  4391. var texte = responseDetails.responseText;
  4392. var lines = texte.split("\n");
  4393. if(lines.length>=1) {
  4394. var infos = lines[0].split(";");
  4395. if(infos.length<4) { return; }
  4396. var idMonstre = infos[0];
  4397. infos=infos.slice(3);
  4398. listeCDM[idMonstre]=infos;
  4399. computeMissionInfomonstre();
  4400. }
  4401. } catch(e) {
  4402. window.alert(e);
  4403. }
  4404. }
  4405. });
  4406. }
  4407.  
  4408. function initPopupInfomonstre() {
  4409. // Initialise le popup tactique (calculs att/deg)
  4410. popup = document.createElement('div');
  4411. popup.id = 'popup';
  4412. popup.className = 'mh_textbox';
  4413. popup.style =
  4414. 'position: absolute;'+
  4415. 'border: 1px solid #000000;'+
  4416. 'visibility: hidden;'+
  4417. 'display: inline;'+
  4418. 'z-index: 3;'+
  4419. 'max-width: 400px;';
  4420. document.body.appendChild(popup);
  4421. }
  4422.  
  4423. function showPopupTactique(evt) {
  4424. try {
  4425. var id = this.id;
  4426. var nom = this.nom;
  4427. var texte = getAnalyseTactique(id,nom);
  4428. if(texte=='') { return; }
  4429. popup.innerHTML = texte;
  4430. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4431. if(isPage("View/MonsterView")) {
  4432. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4433. } else {
  4434. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4435. }
  4436. popup.style.top = evt.pageY+15+'px';
  4437. popup.style.visibility = 'visible';
  4438. } catch(e) {
  4439. window.alert(e);
  4440. }
  4441. }
  4442.  
  4443. // roule 16/03/2016, existe déjà ailleurs
  4444. // function hidePopup() {
  4445. // popup.style.visibility = 'hidden';
  4446. // }
  4447.  
  4448. function toggleTableau() {
  4449. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4450. }
  4451.  
  4452. function computeMissionInfomonstre() {
  4453. // C'est quoi ce titre de fonction ? (O_o)
  4454. try {
  4455. var nodeInsert = document.evaluate(
  4456. "//div[@class = 'titre3']",
  4457. document, null, 9, null
  4458. ).singleNodeValue;
  4459. } catch(e) {
  4460. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4461. return;
  4462. }
  4463. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4464. table.align = 'center';
  4465. tbody = table.childNodes[1];
  4466. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4467. table.firstChild.firstChild.onmouseover = function() {
  4468. this.style.cursor = 'pointer';
  4469. this.className = 'mh_tdpage';
  4470. };
  4471. table.firstChild.firstChild.onmouseout = function() {
  4472. this.className = 'mh_tdtitre';
  4473. };
  4474. tbody.style.display = 'none';
  4475. table.style.width = '350px';
  4476. insertBefore(nodeInsert,table);
  4477. }
  4478.  
  4479. function do_infomonstre() {
  4480. start_script();
  4481. try {
  4482. initPopupInfomonstre();
  4483. traiteMonstre();
  4484. } catch(e) {
  4485. window.alert('Erreur infoMonstre:\n'+e);
  4486. }
  4487. displayScriptTime();
  4488. }
  4489.  
  4490. /*******************************************************************************
  4491. * This file is part of Mountyzilla. *
  4492. * *
  4493. * Mountyzilla is free software; you can redistribute it and/or modify *
  4494. * it under the terms of the GNU General Public License as published by *
  4495. * the Free Software Foundation; either version 2 of the License, or *
  4496. * (at your option) any later version. *
  4497. * *
  4498. * Mountyzilla is distributed in the hope that it will be useful, *
  4499. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4500. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4501. * GNU General Public License for more details. *
  4502. * *
  4503. * You should have received a copy of the GNU General Public License *
  4504. * along with Mountyzilla; if not, write to the Free Software *
  4505. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4506. *******************************************************************************/
  4507.  
  4508. // x~x mission
  4509.  
  4510. /* TODO
  4511. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4512. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4513. *
  4514. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4515. */
  4516.  
  4517. function saveMission(num,obEtape) {
  4518. var obMissions = {};
  4519. if(MY_getValue(numTroll+'.MISSIONS')) {
  4520. try {
  4521. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4522. } catch(e) {
  4523. window.console.error(traceStack(e, 'Mission parsage'));
  4524. return;
  4525. }
  4526. }
  4527. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4528. if(obEtape) {
  4529. obMissions[num] = obEtape;
  4530. } else if(obMissions[num]) {
  4531. delete obMissions[num];
  4532. }
  4533. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4534. }
  4535.  
  4536. function addtroogle(tdLibelle, sRestrict) {
  4537. var img = document.createElement('img');
  4538. img.src = URL_MZimg + 'troogle.ico';
  4539. img.alt = 'Troogle logo';
  4540. var a = document.createElement('a');
  4541. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4542. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4543. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4544. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4545. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4546. a.href = url;
  4547. a.title = 'Chercher sur Troogle';
  4548. a.target = 'troogle';
  4549. a.appendChild(img);
  4550. tdLibelle.appendChild(a);
  4551. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4552. }
  4553.  
  4554. function traiteMission() {
  4555. try {
  4556. var titreMission = document.getElementsByClassName('titre2')[0];
  4557. var numMission = titreMission.textContent.match(/\d+/)[0];
  4558. var missionForm = document.getElementsByName('ActionForm')[0];
  4559. var tdLibelle = document.evaluate(
  4560. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4561. missionForm, null, 9, null).singleNodeValue;
  4562. } catch(e) {
  4563. window.console.error(traceStack(e, 'récupération mission'));
  4564. return;
  4565. }
  4566. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4567. try {
  4568. if(!tdLibelle) {
  4569. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4570. debugMZ('traiteMission, la mission semble terminée');
  4571. saveMission(numMission,false);
  4572. return;
  4573. }
  4574.  
  4575. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4576. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4577. // debug Roule'
  4578. if (MY_DEBUG) {
  4579. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4580. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4581. }
  4582. if(libelle.indexOf('niveau égal à')!=-1) {
  4583. var nbKills = 1, niveau, mod;
  4584. // exemples :
  4585. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4586. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4587. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4588. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4589. if (tdLibelle.childNodes.length == 1) {
  4590. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4591. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4592. if (m) {
  4593. niveau = Number(m[1]);
  4594. mod = 'plus'
  4595. } else {
  4596. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4597. if (m) {
  4598. niveau = Number(m[1]);
  4599. mod = Number(m[2]);
  4600. } else {
  4601. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4602. return;
  4603. }
  4604. }
  4605. } else {
  4606. // ancienne méthode (multi childnode)
  4607. // à supprimer un jour peut-être
  4608. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4609. // Étape de kill multiple de niveau donné
  4610. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4611. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4612. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4613. niveau = Number(mod[0]);
  4614. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4615. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4616. } else {
  4617. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4618. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4619. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4620. mod = mod ? Number(mod[0]) : 'plus';
  4621. }
  4622. } else {
  4623. // Étape de kill unique de niveau donné
  4624. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4625. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4626. mod = mod ? Number(mod[0]) : 'plus';
  4627. }
  4628. }
  4629. // debug Roule'
  4630. if (MY_DEBUG) {
  4631. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4632. }
  4633. saveMission(numMission,{
  4634. type: 'Niveau',
  4635. niveau: niveau,
  4636. mod: mod,
  4637. mundidey: siMundidey,
  4638. libelle: libelle
  4639. });
  4640. if (mod == 'plus')
  4641. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4642. else
  4643. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4644. } else if(libelle.indexOf('de la race')!=-1) {
  4645. var nbKills = 1, race;
  4646. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4647. // Étape de kill multiple de race donnée
  4648. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4649. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4650. } else {
  4651. // Étape de kill unique de race donnée
  4652. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4653. }
  4654. race = race.replace(/\"/g,'');
  4655. saveMission(numMission,{
  4656. type: 'Race',
  4657. race: race,
  4658. mundidey: siMundidey,
  4659. libelle: libelle
  4660. });
  4661. addtroogle(tdLibelle, '@monstre ' + race);
  4662. } else if(libelle.indexOf('de la famille')!=-1) {
  4663. var nbKills = 1, famille;
  4664. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4665. // Étape de kill multiple de famille donnée
  4666. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4667. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4668. } else {
  4669. // Étape de kill unique de famille donnée
  4670. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4671. }
  4672. famille = famille.replace(/\"/g,'');
  4673. saveMission(numMission,{
  4674. type: 'Famille',
  4675. famille: famille,
  4676. mundidey: siMundidey,
  4677. libelle: libelle
  4678. });
  4679. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4680. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4681. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4682. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4683. debugMZ('traiteMission étape capacité spéciale');
  4684. saveMission(numMission,{
  4685. type: 'Pouvoir',
  4686. pouvoir: pouvoir,
  4687. libelle: libelle
  4688. });
  4689. } else {
  4690. debugMZ('traiteMission étape pas pour troogle');
  4691. saveMission(numMission,false);
  4692. }
  4693. } catch(e) {
  4694. window.console.error(traceStack(e, 'récupération étape mission'));
  4695. return;
  4696. }
  4697. }
  4698.  
  4699. function do_mission() {
  4700. start_script(60);
  4701.  
  4702. traiteMission();
  4703.  
  4704. displayScriptTime();
  4705. }
  4706.  
  4707. /*******************************************************************************
  4708. * This file is part of Mountyzilla. *
  4709. * *
  4710. * Mountyzilla is free software; you can redistribute it and/or modify *
  4711. * it under the terms of the GNU General Public License as published by *
  4712. * the Free Software Foundation; either version 2 of the License, or *
  4713. * (at your option) any later version. *
  4714. * *
  4715. * Mountyzilla is distributed in the hope that it will be useful, *
  4716. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4717. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4718. * GNU General Public License for more details. *
  4719. * *
  4720. * You should have received a copy of the GNU General Public License *
  4721. * along with Mountyzilla; if not, write to the Free Software *
  4722. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4723. *******************************************************************************/
  4724.  
  4725. // x~x move
  4726.  
  4727. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4728.  
  4729. var petitsTrous = {
  4730. '-52;57': true,
  4731. '55;70': true,
  4732. '64;70': true,
  4733. '12;-15': true,
  4734. '30;-52': true,
  4735. '48;-39': true
  4736. };
  4737.  
  4738. var grosTrous = {
  4739. '-35;65': true,
  4740. '-13;73': true,
  4741. '-64;9': true,
  4742. '-35;15': true,
  4743. '5;32': true,
  4744. '10;64': true,
  4745. '21;36': true,
  4746. '46;52': true,
  4747. '74;32': true,
  4748. '-71;-7': true,
  4749. '-67;-37': true,
  4750. '-60;-32': true,
  4751. '-51;-22': true,
  4752. '-36;-51': true,
  4753. '5;-49': true
  4754. };
  4755.  
  4756. var centreCarmine_X = 56.5;
  4757. var centreCarmine_Y = 23.5;
  4758. var rayonCarmine = 8.7;
  4759.  
  4760. function isTrou(x,y,n) {
  4761. if(petitsTrous[x+';'+y]) {
  4762. return n<0 && n>-60;
  4763. }
  4764. if(grosTrous[x+';'+y]
  4765. || grosTrous[x-1+';'+y]
  4766. || grosTrous[x+';'+y+1]
  4767. || grosTrous[x-1+';'+y+1]) {
  4768. return n<0 && n>-70;
  4769. }
  4770. if(Math.sqrt(
  4771. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4772. )<=rayonCarmine) {
  4773. return n<0 && n>-100;
  4774. }
  4775. return false;
  4776. }
  4777.  
  4778. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4779.  
  4780. function validateDestination() {
  4781. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4782. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4783. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4784. var form = document.getElementsByName('ActionForm')[0];
  4785. if(form) {
  4786. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4787. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4788. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4789. }
  4790. }
  4791. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4792. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4793. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4794. }
  4795. }
  4796. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4797. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4798. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4799. }
  4800. }
  4801. if(isTrou(x,y,n)) {
  4802. return window.confirm(
  4803. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4804. +'Vous allez tomber dans un trou de météorite.\n'
  4805. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4806. );
  4807. }
  4808. }
  4809. return true;
  4810. }
  4811.  
  4812. function newsubmitDE(event) {
  4813. event.stopPropagation();
  4814. event.preventDefault();
  4815. if(validateDestination()) {
  4816. this.submit();
  4817. }
  4818. }
  4819.  
  4820. function changeValidation() {
  4821. var form = document.getElementsByName('ActionForm')[0];
  4822. if(form) {
  4823. form.addEventListener('submit', newsubmitDE, true);
  4824. }
  4825. }
  4826.  
  4827.  
  4828. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4829.  
  4830. function validateTPDestination() {
  4831. try {
  4832. var text = document.getElementsByTagName('B')[0];
  4833. var a = text.firstChild.nodeValue.split('|');
  4834. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4835. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4836. var pos_n = a[2].substring(5, a[2].length) * 1;
  4837.  
  4838. var nbtrous = 0;
  4839. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4840. for(var x=0 ; x<=2 ; x++) {
  4841. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4842. for(var y=0 ; y<=2 ; y++) {
  4843. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4844. for(var n = 0 ; n <= 1 ; n++) {
  4845. if(isTrou(
  4846. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4847. )) {
  4848. nbtrous++;
  4849. }
  4850. }
  4851. }
  4852. }
  4853. }
  4854. }
  4855. }
  4856. if(nbtrous>0 && nbtrous<72) {
  4857. return window.confirm(
  4858. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4859. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4860. +'% de risque de tomber dans un trou de météorite.\n'
  4861. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4862. );
  4863. }
  4864. else if(nbtrous>=72) {
  4865. return window.confirm(
  4866. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4867. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4868. +'% de risque de tomber dans un trou de météorite !\n'
  4869. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4870. );
  4871. }
  4872. return true;
  4873. }
  4874. catch(e) {
  4875. window.alert(e)
  4876. }
  4877. }
  4878.  
  4879. function newsubmitTP(event) {
  4880. event.stopPropagation();
  4881. event.preventDefault();
  4882. if(validateTPDestination()) {
  4883. this.submit();
  4884. }
  4885. }
  4886.  
  4887. function changeButtonValidate() {
  4888. var form = document.getElementsByName('Formulaire')[0];
  4889. if(form) {
  4890. if(!form.getAttribute('onsubmit')) {
  4891. form.setAttribute('onsubmit','return true;');
  4892. }
  4893. form.addEventListener('submit', newsubmitTP, true);
  4894. }
  4895. }
  4896.  
  4897.  
  4898. /*-[functions]---------------- Partie Principale -----------------------------*/
  4899.  
  4900. function do_move() {
  4901. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  4902. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4903. changeValidation();
  4904. //}
  4905. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4906. // changeButtonValidate();
  4907. //}
  4908. }
  4909.  
  4910. /*******************************************************************************
  4911. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4912. * Mountyzilla is free software; provided under the GNU General Public License *
  4913. *******************************************************************************/
  4914.  
  4915. // x~x news
  4916.  
  4917. // Nombre de news à afficher & nb max de caractères par news:
  4918. const nbItems = 5;
  4919. const maxCarDescription = 300;
  4920.  
  4921. /*-[functions]------------------- Utilitaires --------------------------------*/
  4922.  
  4923. // Ne semble avoir strictement aucun effet:
  4924. String.prototype.epureDescription = function() {
  4925. return this.replace(/\\(.)/g,"$1");
  4926. }
  4927.  
  4928. function appendTitledTable(node,titre,description) {
  4929. // Crée les tables contenant les infos (avec titre)
  4930. var table = document.createElement('table');
  4931. table.border = 0;
  4932. table.className = 'mh_tdborder';
  4933. table.cellSpacing = 1;
  4934. table.cellPadding = 1;
  4935. table.style.maxWidth = '98%';
  4936. table.style.marginLeft = 'auto';
  4937. table.style.marginRight = 'auto';
  4938. var tbody = document.createElement('tbody');
  4939. table.appendChild(tbody);
  4940. var tr = appendTr(tbody,'mh_tdtitre');
  4941. var td = appendTdCenter(tr,2);
  4942. var span = document.createElement('span');
  4943. appendText(span,titre,true);
  4944. if(description) {
  4945. span.title = description;
  4946. }
  4947. td.appendChild(span);
  4948. node.appendChild(table);
  4949. return tbody;
  4950. }
  4951.  
  4952. function testCertif(paramURL, callbackOnError) {
  4953. try {
  4954. FF_XMLHttpRequest({
  4955. method: 'GET',
  4956. url: paramURL,
  4957. onload: function(responseDetails) {
  4958. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4959. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4960. }
  4961. });
  4962. } catch(e) {
  4963. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4964. callbackOnError();
  4965. }
  4966. }
  4967.  
  4968. function createOrGetGrandCadre() {
  4969. var grandCadre = document.getElementById('grandCadre');
  4970. if (grandCadre) return grandCadre;
  4971. try {
  4972. var rappels = document.evaluate(
  4973. "//p[contains(a/text(),'messagerie')]",
  4974. document, null, 9, null).singleNodeValue;
  4975. }
  4976. catch(e) {
  4977. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4978. grandCadre = document.createElement('div');
  4979. return grandCadre;
  4980. }
  4981. grandCadre = document.createElement('div');
  4982. grandCadre.id = 'grandCadre';
  4983. var sousCadre = document.createElement('div');
  4984. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4985. sousCadre.style.textAlign = 'center';
  4986. sousCadre.style.fontSize = 'xx-large';
  4987. grandCadre.appendChild(sousCadre);
  4988.  
  4989. grandCadre.style.border = 'solid 5px red';
  4990. grandCadre.style.width = 'auto';
  4991. insertBefore(rappels,grandCadre);
  4992. return grandCadre;
  4993. }
  4994.  
  4995. function showHttpsErrorCadre1() {
  4996. window.console.log('[MZ] showHttpsErrorCadre1');
  4997. var grandCadre = createOrGetGrandCadre();
  4998. var sousCadre = document.createElement('div');
  4999. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5000. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5001. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5002. + URL_CertifRaistlin1
  5003. + '" target="raistlin">clique ici</a>'
  5004. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5005. + ' « Confirmer l\'exception de sécurité »'
  5006. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5007. sousCadre.style.width = 'auto';
  5008. sousCadre.style.fontSize = 'large';
  5009. sousCadre.style.border = 'solid 1px black';
  5010. sousCadre.style.backgroundColor = 'red';
  5011. grandCadre.appendChild(sousCadre);
  5012. }
  5013.  
  5014. function showHttpsErrorCadre2() {
  5015. window.console.log('[MZ] showHttpsErrorCadre2');
  5016. var grandCadre = createOrGetGrandCadre();
  5017. var sousCadre = document.createElement('div');
  5018. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5019. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5020. + '<a style="color:blue;font-size: inherits;" href="'
  5021. + URL_CertifRaistlin2
  5022. + '" target="raistlin">clique ici</a>'
  5023. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5024. + ' « Confirmer l\'exception de sécurité »'
  5025. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5026. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5027. sousCadre.style.width = 'auto';
  5028. sousCadre.style.fontSize = 'large';
  5029. sousCadre.style.border = 'solid 1px black';
  5030. sousCadre.style.backgroundColor = 'red';
  5031. grandCadre.appendChild(sousCadre);
  5032. }
  5033.  
  5034. function showHttpsErrorContenuMixte() {
  5035. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5036. var grandCadre = createOrGetGrandCadre();
  5037. var sousCadre = document.createElement('div');
  5038. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5039. + '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)'
  5040. + '<ul>'
  5041. + '<li>Interface Bricol\'Troll</li>'
  5042. + '<li>Nouveautés de Mountyzilla</li>'
  5043. + '</ul>'
  5044. + '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 />'
  5045. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5046. sousCadre.style.width = 'auto';
  5047. sousCadre.style.fontSize = 'large';
  5048. sousCadre.style.border = 'solid 1px black';
  5049. grandCadre.appendChild(sousCadre);
  5050. }
  5051.  
  5052. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5053.  
  5054. function traiterJubilaires() {
  5055. // à faire
  5056. }
  5057.  
  5058. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5059. try {
  5060. FF_XMLHttpRequest({
  5061. method: 'GET',
  5062. url: URL_anniv,
  5063. headers: {
  5064. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5065. 'Accept': 'application/xml,text/xml',
  5066. },
  5067. onload: function(responseDetails) {
  5068. if ((responseDetails.status == 0) && isHTTPS) {
  5069. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5070. showHttpsErrorContenuMixte();
  5071. return;
  5072. }
  5073. var listeTrolls = responseDetails.responseText.split('\n');
  5074. if(!listeTrolls || listeTrolls.length==0) {
  5075. return;
  5076. }
  5077. afficherJubilaires(listeTrolls);
  5078. },
  5079. });
  5080. }
  5081. catch(e) {
  5082. if (isHTTPS) {
  5083. window.console.log(traceStack(e, 'appel jubilaires'));
  5084. showHttpsErrorContenuMixte();
  5085. } else {
  5086. window.alert('Erreur Jubilaires:\n'+e);
  5087. }
  5088. }
  5089. }
  5090.  
  5091. function afficherJubilaires(listeTrolls) {
  5092. try {
  5093. var rappels = document.evaluate(
  5094. "//p[contains(a/text(),'messagerie')]",
  5095. document, null, 9, null).singleNodeValue;
  5096. }
  5097. catch(e) {
  5098. return;
  5099. }
  5100. var p = document.createElement('p');
  5101. var tbody = appendTitledTable(p,
  5102. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5103. 'Envoyez leur un message ou un cadeau !'
  5104. );
  5105. tr = appendTr(tbody,'mh_tdpage');
  5106. td = appendTdCenter(tr);
  5107. var small = document.createElement('small');
  5108. td.appendChild(small);
  5109. var first = true;
  5110. for(var i=0 ; i<listeTrolls.length ; i++) {
  5111. var infos = listeTrolls[i].split(';');
  5112. if(infos.length!=3 || infos[2]==='0') {
  5113. continue;
  5114. }
  5115. if(first) {
  5116. first = false;
  5117. }
  5118. else {
  5119. appendText(small,', ');
  5120. }
  5121. var a = document.createElement('a');
  5122. a.href = 'javascript:EPV('+infos[0]+')';
  5123. appendText(a,infos[1]);
  5124. small.appendChild(a);
  5125. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5126. }
  5127. insertBefore(rappels,p);
  5128. }
  5129.  
  5130.  
  5131. /*-[functions]--------------------- News MZ ----------------------------------*/
  5132.  
  5133. function traiterNouvelles() {
  5134. var news = new Array;
  5135. 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 ;).']);
  5136. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5137. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5138. 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']);
  5139. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5140. afficherNouvelles(news);
  5141. }
  5142.  
  5143. function afficherNouvelles(items) {
  5144. var footer = document.getElementById('footer1');
  5145. if(!footer) {
  5146. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5147. return;
  5148. }
  5149. var p = document.createElement('p');
  5150. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5151. var div = document.createElement('div');
  5152. div.style.position = 'absolute';
  5153. div.style.right = 0;
  5154. div.style.top = 0;
  5155. div.style.paddingRight = '3px';
  5156. div.style.whiteSpace = 'nowrap';
  5157. appendText(div, '(version ' + GM_info.script.version + ')');
  5158. tbody.rows[0].cells[0].style.position = 'relative';
  5159. tbody.rows[0].cells[0].appendChild(div);
  5160. for(var i=0 ; i<items.length ; i++) {
  5161. var tr = appendTr(tbody,'mh_tdpage');
  5162. var td = appendTdCenter(tr);
  5163. td.style.verticalAlign = 'top'; // semble sans effet
  5164. appendText(td,items[i][0],true);
  5165. td = appendTd(tr);
  5166. td.innerHTML = items[i][1];
  5167. }
  5168. insertBefore(footer,p);
  5169.  
  5170. // changelog
  5171. var p = document.createElement('p');
  5172. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5173. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5174. tbody.rows[0].cells[0].onclick = function() {
  5175. try {
  5176. tbody.rows[0].cells[0].onclick = undefined;
  5177. tbody.rows[0].cells[0].style.cursor = '';
  5178. var tr = appendTr(tbody,'mh_tdpage');
  5179. var td = appendTd(tr);
  5180. td.colSpan = 2;
  5181. var pre = document.createElement('pre');
  5182. appendText(pre,MZ_changeLog.join("\n"));
  5183. td.appendChild(pre);
  5184. } catch (e) {
  5185. window.console.log('[MZ] affichage changeLog', e);
  5186. }
  5187. };
  5188. insertBefore(footer,p);
  5189.  
  5190. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5191. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5192. if (isHTTPS) {
  5193. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5194. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5195. } else {
  5196. window.console.log('[MZ test] début switch to https');
  5197. window.sessionStorage.setItem('xxx', "test session trans https");
  5198. window.parent.xxx = "autre test";
  5199. var url = document.location.href;
  5200. window.console.log('[MZ test] url=' + url);
  5201. url = url.replace(/http:\/\//i, 'https://')
  5202. window.console.log('[MZ test] switched url=' + url);
  5203. document.location.href = url;
  5204. }
  5205. }
  5206. if (false) { // version par utilisation d'un IFrame en https
  5207. if (isHTTPS) {
  5208. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5209. //window.console.log('[MZ test] window.name=' + window.name);
  5210. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5211. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5212. var txt = window.name;
  5213. var tabtxt = txt.split(/µ/);
  5214. for (var i = 0; i < tabtxt.length; i++) {
  5215. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5216. }
  5217. } else {
  5218. var txt = '';
  5219. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5220. var k = localStorage.key(i);
  5221. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5222. txt += k + "£" + localStorage.getItem(k) + "µ";
  5223. }
  5224. var iframe = document.createElement('iframe');
  5225. var url = document.location.href;
  5226. //window.console.log('[MZ test] url=' + url);
  5227. url = url.replace(/http:\/\//i, 'https://')
  5228. //window.console.log('[MZ test] switched url=' + url);
  5229. //iframe.xxx = "truc en plume";
  5230. iframe.name = txt;
  5231. //window.xxx = "machin";
  5232. iframe.src = url;
  5233. //iframe.document.xxx = "truc en plume";
  5234. document.body.appendChild(iframe);
  5235. iframe.style.display = 'none';
  5236. }
  5237. }
  5238. }
  5239. }
  5240.  
  5241.  
  5242. /*---------------------------------- Main ------------------------------------*/
  5243.  
  5244. function do_news() {
  5245. start_script();
  5246.  
  5247. traiterJubilaires();
  5248. traiterNouvelles();
  5249.  
  5250. if (isHTTPS) {
  5251. // test si les certificats raistlin ont été acceptés
  5252. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5253. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5254. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5255. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5256. }
  5257. }
  5258.  
  5259. displayScriptTime();
  5260. }
  5261.  
  5262. /*********************************************************************************
  5263. * This file is part of Mountyzilla. *
  5264. * *
  5265. * Mountyzilla is free software; you can redistribute it and/or modify *
  5266. * it under the terms of the GNU General Public License as published by *
  5267. * the Free Software Foundation; either version 2 of the License, or *
  5268. * (at your option) any later version. *
  5269. * *
  5270. * Mountyzilla is distributed in the hope that it will be useful, *
  5271. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5272. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5273. * GNU General Public License for more details. *
  5274. * *
  5275. * You should have received a copy of the GNU General Public License *
  5276. * along with Mountyzilla; if not, write to the Free Software *
  5277. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5278. *********************************************************************************/
  5279.  
  5280. // x~x tabcompo
  5281.  
  5282. var popup;
  5283.  
  5284. function initPopupTabcompo() {
  5285. popup = document.createElement('div');
  5286. popup.setAttribute('id', 'popup');
  5287. popup.setAttribute('class', 'mh_textbox');
  5288. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5289. + 'display: inline; z-index: 3; max-width: 400px;');
  5290. document.body.appendChild(popup);
  5291. }
  5292.  
  5293. function showPopup(evt) {
  5294. var texte = this.getAttribute("texteinfo");
  5295. popup.innerHTML = texte;
  5296. popup.style.left = evt.pageX + 15 + 'px';
  5297. popup.style.top = evt.pageY + 'px';
  5298. popup.style.visibility = "visible";
  5299. }
  5300.  
  5301. // roule 16/03/2016, existe déjà ailleurs
  5302. // function hidePopup() {
  5303. // popup.style.visibility = 'hidden';
  5304. // }
  5305.  
  5306. function createPopupImage(url, text)
  5307. {
  5308. var img = document.createElement('img');
  5309. img.setAttribute('src',url);
  5310. img.setAttribute('align','ABSMIDDLE');
  5311. img.setAttribute("texteinfo",text);
  5312. img.addEventListener("mouseover", showPopup,true);
  5313. img.addEventListener("mouseout", hidePopup,true);
  5314. return img;
  5315. }
  5316.  
  5317. function formateTexte(texte)
  5318. {
  5319. texte = texte.replace(/\n/g,"<br/>");
  5320. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5321. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5322. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5323. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5324. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5325. return texte;
  5326. }
  5327.  
  5328. function arrondi(x) {
  5329. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5330. }
  5331.  
  5332. function traiteMinerai() {
  5333. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5334. try {
  5335. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5336. +" and contains(./tr/th/text(),'Minerai')]",
  5337. document, null, 9, null).singleNodeValue;
  5338. node = node.nextSibling.nextSibling;
  5339. }
  5340. catch(e) {return;}
  5341. var trlist = document.evaluate('./tr', node, null, 7, null);
  5342. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5343. var node = trlist.snapshotItem(i);
  5344. var nature = node.childNodes[5].textContent;
  5345. var caracs = node.childNodes[7].textContent;
  5346. var taille = caracs.match(/\d+/)[0];
  5347. var coef = 1;
  5348. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5349. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5350. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5351. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5352. if (nature.indexOf('Mithril')!=-1) {
  5353. coef = 0.2*coef;
  5354. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5355. }
  5356. else {
  5357. coef = 0.75*coef+1.25;
  5358. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5359. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5360. }
  5361. }
  5362. }
  5363.  
  5364. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5365. function treateComposants() {
  5366. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5367. //On récupère les composants
  5368. var nodes = document.evaluate(
  5369. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5370. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5371. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5372. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5373. if (nodes.snapshotLength == 0) {
  5374. //window.console.log('[MZ] treateComposants DOWN');
  5375. return;
  5376. }
  5377. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5378.  
  5379. var texte = "";
  5380. for (var i = 0; i < nodes.snapshotLength; i++) {
  5381. var n1 = nodes.snapshotItem(i).childNodes[1];
  5382. var n3 = nodes.snapshotItem(i).childNodes[3];
  5383. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5384. var prix = n3.childNodes[0].nodeValue;
  5385. if (!prix)
  5386. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5387. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5388. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5389. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5390. + prix.replace(/\n/g, '') + "\n";
  5391. }
  5392.  
  5393. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5394. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5395. var id_taniere = c.snapshotItem(0).nodeValue;
  5396. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5397.  
  5398. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5399. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5400. if (form)
  5401. {
  5402. if(document.getElementsByTagName('form').length>0)
  5403. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5404. else
  5405. {
  5406. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5407. insertBefore(thisP, form);
  5408. }
  5409. }
  5410. }
  5411.  
  5412. function treateAllComposants() {
  5413. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5414. //On récupère les composants
  5415. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5416. document, null, 0, null ).numberValue;
  5417. var c = (categ == 0 ? 3 : 4);
  5418. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5419. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5420. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5421. + "td["+c+"]/text()[1] = '\240-\240' "
  5422. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5423. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5424. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5425. + "and td[1]/img/@alt = 'Identifié']",
  5426. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5427. if (nodes.snapshotLength == 0) {
  5428. // window.alert('treateAllComposants DOWN');
  5429. return;
  5430. }
  5431.  
  5432. var texte = "";
  5433. for (var i = 0; i < nodes.snapshotLength; i++) {
  5434. var n1 = nodes.snapshotItem(i).childNodes[1];
  5435. var n3 = nodes.snapshotItem(i).childNodes[3];
  5436. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5437. var prix = n3.childNodes[0].nodeValue;
  5438. if (!prix)
  5439. {
  5440. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5441. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5442. }
  5443. else
  5444. {
  5445. prix= prix.replace(/[\240 ]/g, "");
  5446. if(prix=="-")
  5447. prix=null;
  5448. }
  5449. if(prix)
  5450. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5451. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5452. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5453. + prix.replace(/\n/g, '') + "\n";
  5454. else
  5455. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5456. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5457. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5458. }
  5459.  
  5460. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5461. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5462. var id_taniere = c.snapshotItem(0).nodeValue;
  5463. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5464.  
  5465. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5466. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5467. if (form)
  5468. {
  5469. if(document.getElementsByTagName('form').length>0)
  5470. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5471. else
  5472. {
  5473. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5474. insertBefore(thisP, form);
  5475. }
  5476. }
  5477. }
  5478.  
  5479. function treateEM()
  5480. {
  5481. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5482. if(currentURL.indexOf("as_type=Compo")==-1)
  5483. return false;
  5484. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5485. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5486. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5487. if (nodes.snapshotLength == 0)
  5488. return false;
  5489. for (var i = 0; i < nodes.snapshotLength; i++) {
  5490. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5491. var link = desc[2].firstChild ;
  5492. var nomCompoTotal = desc[2].textContent ;
  5493. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5494. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5495. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5496. var locqual = desc[3].textContent ;
  5497. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5498. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5499. if(isEM(nomMonstre).length>0)
  5500. {
  5501. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5502. if(infos.length>0)
  5503. {
  5504. var shortDescr = "Variable";
  5505. var bold = 0;
  5506. if(infos != "Composant variable")
  5507. {
  5508. shortDescr = infos.substring(0,infos.indexOf(" "));
  5509. if(parseInt(shortDescr)>=0)
  5510. bold=1;
  5511. }
  5512. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5513. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5514. }
  5515. }
  5516. }
  5517. }
  5518.  
  5519. function treateChampi() {
  5520. if (currentURL.indexOf('as_type=Champi')==-1)
  5521. return false;
  5522. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5523. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5524. if (nodes.snapshotLength == 0)
  5525. return false;
  5526.  
  5527. for (var i = 0; i < nodes.snapshotLength; i++) {
  5528. var node = nodes.snapshotItem(i);
  5529. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5530. if (moisChampi[nomChampi])
  5531. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5532. }
  5533. }
  5534.  
  5535. function treateEnchant()
  5536. {
  5537. if(currentURL.indexOf("as_type=Compo")==-1)
  5538. return false;
  5539. try
  5540. {
  5541. if(!listeMonstreEnchantement)
  5542. computeCompoEnchantement();
  5543. var nodes = document.evaluate(
  5544. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5545. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5546. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5547. if (nodes.snapshotLength == 0)
  5548. return false;
  5549. var urlImg = URL_MZimg + "enchant.png";
  5550. for (var i = 0; i < nodes.snapshotLength; i++) {
  5551. var link = nodes.snapshotItem(i);
  5552. var nomCompoTotal = link.firstChild.nodeValue;
  5553. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5554. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5555. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5556. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5557. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5558. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5559. if(isEnchant(nomMonstre).length>0)
  5560. {
  5561. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5562. if(infos.length>0)
  5563. {
  5564. link.parentNode.appendChild(createImage(urlImg,infos));
  5565. }
  5566. }
  5567. }
  5568. }
  5569. catch(e)
  5570. {
  5571. window.alert(e);
  5572. }
  5573. }
  5574.  
  5575. function treateEquipEnchant()
  5576. {
  5577. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5578. return false;
  5579. initPopupTabcompo();
  5580. computeEnchantementEquipement(createPopupImage,formateTexte);
  5581. }
  5582.  
  5583. function do_tancompo() {
  5584. start_script();
  5585.  
  5586. treateAllComposants();
  5587. treateComposants();
  5588. traiteMinerai();
  5589. if (MY_getValue('NOINFOEM')!='true') {
  5590. treateChampi();
  5591. treateEM();
  5592. }
  5593. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5594. treateEnchant();
  5595. treateEquipEnchant();
  5596. }
  5597.  
  5598. displayScriptTime();
  5599. }
  5600.  
  5601. /*******************************************************************************
  5602. * This file is part of Mountyzilla. *
  5603. * *
  5604. * Mountyzilla is free software; you can redistribute it and/or modify *
  5605. * it under the terms of the GNU General Public License as published by *
  5606. * the Free Software Foundation; either version 2 of the License, or *
  5607. * (at your option) any later version. *
  5608. * *
  5609. * Mountyzilla is distributed in the hope that it will be useful, *
  5610. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5611. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5612. * GNU General Public License for more details. *
  5613. * *
  5614. * You should have received a copy of the GNU General Public License *
  5615. * along with Mountyzilla; if not, write to the Free Software *
  5616. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5617. *******************************************************************************/
  5618.  
  5619. // x~x pjview
  5620.  
  5621. /* TODO
  5622. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5623. */
  5624.  
  5625. // Bulle d'infos
  5626. var DivInfo;
  5627. // Booléen stockant l'état de freezing de la bulle
  5628. var freezed = false;
  5629.  
  5630. // liste du matos
  5631. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5632. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5633. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5634. var mh_caracs = {
  5635. 'anneau de protection':
  5636. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5637. "armure d'anneaux":
  5638. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5639. 'armure de bois':
  5640. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5641. 'armure de cuir':
  5642. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5643. 'armure de peaux':
  5644. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5645. 'armure de pierre':
  5646. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5647. 'armure de plates':
  5648. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5649. 'baton lesté':
  5650. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5651. 'bâtons de parade':
  5652. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5653. 'bottes':
  5654. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5655. 'bouclier à pointes':
  5656. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5657. 'boulet et chaîne':
  5658. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5659. 'cagoule':
  5660. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5661. 'casque à cornes':
  5662. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5663. 'casque à pointes':
  5664. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5665. 'casque en cuir':
  5666. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5667. 'casque en métal':
  5668. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5669. 'chaîne cloutée':
  5670. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5671. 'chapeau pointu':
  5672. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5673. 'collier de dents':
  5674. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5675. 'collier de pierre':
  5676. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5677. 'collier à pointes':
  5678. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5679. 'cotte de mailles':
  5680. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5681. 'couronne de cristal':
  5682. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5683. "couronne d'obsidienne":
  5684. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5685. "coutelas d'obsidienne":
  5686. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5687. 'coutelas en os':
  5688. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5689. 'crochet':
  5690. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5691. 'cuir bouilli':
  5692. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5693. "cuirasse d'ossements":
  5694. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5695. "cuirasse d'écailles":
  5696. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5697. 'culotte en cuir':
  5698. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5699. 'dague':
  5700. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5701. 'epée courte':
  5702. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5703. 'epée longue':
  5704. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5705. 'espadon':
  5706. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5707. 'fouet':
  5708. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5709. 'fourrures':
  5710. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5711. 'gantelet':
  5712. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5713. 'gorgeron en cuir':
  5714. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5715. 'gorgeron en métal':
  5716. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5717. 'gourdin':
  5718. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5719. 'gourdin clouté':
  5720. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5721. 'grimoire':
  5722. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5723. "gros'porte":
  5724. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5725. 'grosse racine':
  5726. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5727. 'grosse stalagmite':
  5728. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5729. 'hache de bataille':
  5730. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5731. 'hache de guerre en os':
  5732. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5733. 'hache de guerre en pierre':
  5734. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5735. "hache à deux mains d'obsidienne":
  5736. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5737. 'hallebarde':
  5738. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5739. "haubert d'écailles":
  5740. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5741. 'haubert de mailles':
  5742. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5743. 'heaume':
  5744. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5745. 'jambières en cuir':
  5746. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5747. 'jambières en fourrure':
  5748. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5749. 'jambières en maille':
  5750. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5751. 'jambières en métal':
  5752. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5753. 'jambières en os':
  5754. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5755. "lame d'obsidienne":
  5756. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5757. 'lame en os':
  5758. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5759. 'lame en pierre':
  5760. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5761. 'lorgnons':
  5762. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5763. 'machette':
  5764. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5765. "masse d'arme":
  5766. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5767. 'pagne de mailles':
  5768. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5769. 'pagne en cuir':
  5770. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5771. 'robe de mage':
  5772. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5773. 'rondache en bois':
  5774. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5775. 'rondache en métal':
  5776. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5777. 'sandales':
  5778. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5779. 'souliers dorés':
  5780. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5781. "talisman d'obsidienne":
  5782. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5783. 'talisman de pierre':
  5784. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5785. 'targe':
  5786. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5787. 'torche':
  5788. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5789. 'torque de pierre':
  5790. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5791. 'tunique':
  5792. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5793. "tunique d'écailles":
  5794. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5795. 'turban':
  5796. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5797. }
  5798.  
  5799. // liste des templates
  5800. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5801. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5802. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5803. var mh_templates = {
  5804. 'de Feu':
  5805. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5806. 'de Résistance':
  5807. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5808. "de l'Aigle":
  5809. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5810. 'de la Salamandre':
  5811. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5812. 'des Cyclopes':
  5813. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5814. 'des Enragés':
  5815. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5816. 'des Tortues':
  5817. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5818. 'des Vampires':
  5819. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5820. 'du Glacier':
  5821. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5822. 'du Rat':
  5823. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5824. 'du Roc':
  5825. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5826. 'du Temps':
  5827. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5828. 'du Vent':
  5829. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5830. 'en Mithril':
  5831. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5832. 'des Anciens':
  5833. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5834. 'des Champions':
  5835. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5836. 'des Duellistes':
  5837. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5838. 'de la Terre':
  5839. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5840. "de l'Orage":
  5841. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5842. "de l'Ours":
  5843. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5844. 'des Béhémoths':
  5845. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5846. 'des Mages':
  5847. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5848. 'du Pic':
  5849. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5850. 'du Sable':
  5851. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5852. 'acéré':
  5853. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5854. 'acérée':
  5855. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5856. 'équilibré':
  5857. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5858. 'équilibrée':
  5859. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5860. 'léger':
  5861. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5862. 'légère':
  5863. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5864. 'renforcé':
  5865. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5866. 'renforcée':
  5867. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5868. 'robuste':
  5869. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5870. }
  5871.  
  5872. function clone(arr) {
  5873. // Clonage rapide
  5874. return arr.slice(0);
  5875. }
  5876.  
  5877. function addArray(arr1,arr2) {
  5878. // Somme matricielle
  5879. var res = clone(arr1);
  5880. for(i=res.length-1 ; i>=0 ; i--) {
  5881. res[i] += arr2[i];
  5882. }
  5883. return res;
  5884. }
  5885.  
  5886. function getTemplates(nomItem) {
  5887. // Déstructure le nom de l'item en array [nom, template1, ...]
  5888. var tempFound = true;
  5889. var str = nomItem.trim();
  5890. var arr = [];
  5891. while(tempFound) {
  5892. tempFound = false;
  5893. for(var temp in mh_templates) {
  5894. // on teste la fin du nom contre chaque template
  5895. if(str.slice(-temp.length)!=temp) { continue; }
  5896. tempFound = true;
  5897. str = str.slice(0,-temp.length-1);
  5898. arr.unshift(temp);
  5899. if(str.slice(-3)==' et') {
  5900. str = str.slice(0,-3);
  5901. }
  5902. }
  5903. }
  5904. arr.unshift(str);
  5905. return arr;
  5906. }
  5907.  
  5908. function addMithril(arrayCaracs,typeItem) {
  5909. // Ajoute l'effet du Mithril sur les caracs
  5910. if(typeItem=='arme') {
  5911. if(arrayCaracs[0]<0) {
  5912. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5913. }
  5914. }
  5915. else {
  5916. if(arrayCaracs[4]<0) {
  5917. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5918. }
  5919. }
  5920. arrayCaracs[15] /= 2;
  5921. arrayCaracs[16] /= 2;
  5922. return arrayCaracs;
  5923. }
  5924.  
  5925. function addRenfort(arrayCaracs,template) {
  5926. // Ajoute l'effet des pseudo-templates sur les caracs
  5927. // S'applique APRÈS le mithril
  5928. // WARNING - Cette formule n'a rien d'officiel, gare !
  5929. var coef = 0;
  5930. if(/^lég[e,è]re?$/.test(template)) {
  5931. coef = -1;
  5932. }
  5933. else if(/^renforcée?$/.test(template)
  5934. || template==='robuste') {
  5935. coef = 1;
  5936. }
  5937. if(coef) {
  5938. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5939. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5940. }
  5941. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5942. return arrayCaracs;
  5943. }
  5944.  
  5945. function getCaracs(item) {
  5946. // Calcule les caractéristiques de l'item
  5947. var templates = getTemplates(item);
  5948. if(!mh_caracs[templates[0]]) {
  5949. // Si l'item est inconnu
  5950. return [];
  5951. }
  5952. var caracs = clone(mh_caracs[templates[0]]);
  5953. var typeItem = caracs[0];
  5954. caracs.shift();
  5955. templates.shift();
  5956. if(templates[templates.length-1]=='en Mithril') {
  5957. caracs = addMithril(caracs,typeItem);
  5958. templates.pop();
  5959. }
  5960. if(/^acérée?$/.test(templates[0])
  5961. || /^équilibrée?$/.test(templates[0])
  5962. || /^lég[e,è]re?$/.test(templates[0])
  5963. || /^renforcée?$/.test(templates[0])
  5964. || templates[0]=='robuste') {
  5965. caracs = addRenfort(caracs,templates[0]);
  5966. templates.shift();
  5967. }
  5968. for(var i=templates.length-1 ; i>=0 ; i--) {
  5969. caracs = addArray(caracs,mh_templates[templates[i]]);
  5970. }
  5971. return caracs;
  5972. }
  5973.  
  5974. function getLine(tab) {
  5975. // Préparation de la ligne à afficher lors d'un mouseover
  5976. var str = '';
  5977. if(tab[0]!=0 || tab[1]!=0) {
  5978. str += '<b>Att : </b>'+aff(tab[0]);
  5979. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5980. str += ' | ';
  5981. }
  5982. if(tab[4]!=0) {
  5983. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5984. }
  5985. if(tab[2]!=0 || tab[3]!=0) {
  5986. str += '<b>Deg : </b>'+aff(tab[2]);
  5987. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5988. str += ' | ';
  5989. }
  5990. if(tab[8]!=0) {
  5991. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5992. }
  5993. if(tab[7]!=0) {
  5994. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5995. }
  5996. if(tab[5]!=0 || tab[6]!=0) {
  5997. str += '<b>Arm : </b>'+aff(tab[5]);
  5998. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5999. str += ' | ';
  6000. }
  6001. if(tab[9]!=0 || tab[10]!=0) {
  6002. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6003. if(tab[9]!=tab[10]) {
  6004. str += '/'+aff(tab[10])+'%';
  6005. }
  6006. str += ' | ';
  6007. }
  6008. if(tab[11]!=0 || tab[12]!=0) {
  6009. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6010. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6011. str += ' | ';
  6012. }
  6013. if(tab[13]!=0) {
  6014. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6015. }
  6016. if(tab[14]!=0) {
  6017. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6018. }
  6019. str += '<b>Poids : </b>'+tab[15]+' min';
  6020. if(tab[15]!=tab[16]) {
  6021. str += ' / '+tab[16]+' min';
  6022. }
  6023. return str;
  6024. }
  6025.  
  6026. function toolTipInit() {
  6027. DivInfo = document.createElement('div');
  6028. DivInfo.id = 'infosVue';
  6029. DivInfo.className = 'mh_textbox';
  6030. DivInfo.style =
  6031. 'position: absolute;'
  6032. +'border: 1px solid #000000;'
  6033. +'visibility:hidden;'
  6034. +'display:inline;'
  6035. +'z-index:99;';
  6036. document.body.appendChild(DivInfo);
  6037. document.onmousemove = getXY;
  6038. document.onclick = changeFreezeStatus;
  6039. }
  6040.  
  6041. function getXY(evt) {
  6042. if(!freezed && DivInfo.style.visibility=='visible') {
  6043. DivInfo.style.left = evt.pageX+'px';
  6044. DivInfo.style.top = evt.pageY+10+'px';
  6045. }
  6046. }
  6047.  
  6048. function changeFreezeStatus() {
  6049. if(DivInfo.style.visibility=='visible') {
  6050. freezed = !freezed;
  6051. if(!freezed) { hideInfos(); }
  6052. }
  6053. }
  6054.  
  6055. function showInfos() {
  6056. if(freezed) { return; }
  6057. var currentInfos = this.infos;
  6058. DivInfo.innerHTML = currentInfos;
  6059. DivInfo.style.visibility = 'visible';
  6060. }
  6061.  
  6062. function hideInfos() {
  6063. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6064. }
  6065.  
  6066. function treateEquipement() {
  6067. // Extrait les données du matos et réinjecte les infos déduites
  6068. if(MY_getValue('INFOCARAC')=='false') { return; }
  6069. var faireLigne = false;
  6070. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6071. var nodes = document.evaluate(
  6072. "//td/b[text()='Equipement Utilisé']/../../"
  6073. +"td[2]/img[contains(@src,bullet)]",
  6074. document, null, 7, null);
  6075. if(nodes.snapshotLength>0) {
  6076. // Si CSS de base
  6077. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6078. var node = nodes.snapshotItem(i);
  6079. var next = node.nextSibling;
  6080. var nnext = next.nextSibling;
  6081. var nom = next.nodeValue.toLowerCase();
  6082. if(nnext.childNodes.length==1) {
  6083. nom += nnext.firstChild.nodeValue;
  6084. }
  6085. nom = nom.trim();
  6086. // gestion winpostrophe
  6087. var c = String.fromCharCode(180);
  6088. while(nom.indexOf(c)!=-1) {
  6089. nom = nom.replace(c,"'");
  6090. }
  6091. var arr = getCaracs(nom);
  6092. if(arr.length>0) {
  6093. faireLigne = true;
  6094. caracs = addArray(caracs,arr);
  6095. var span = document.createElement('span');
  6096. span.appendChild(next);
  6097. span.appendChild(nnext);
  6098. span.infos = getLine(arr);
  6099. span.onmouseover = showInfos;
  6100. span.onmouseout = hideInfos;
  6101. insertBefore(node.nextSibling,span);
  6102. }
  6103. }
  6104. if(faireLigne) {
  6105. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6106. document, null, 9, null).singleNodeValue;
  6107. node.infos = getLine(caracs);
  6108. node.onmouseover = showInfos;
  6109. node.onmouseout = hideInfos;
  6110. }
  6111. }
  6112. else {
  6113. // Si CSS avancée
  6114. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6115. document, null, 7, null);
  6116. if(nodes.snapshotLength>0) {
  6117. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6118. var node = nodes.snapshotItem(i);
  6119. var nom = node.firstChild.nodeValue.toLowerCase();
  6120. if(node.childNodes.length>1) {
  6121. nom += node.childNodes[1].firstChild.nodeValue;
  6122. }
  6123. nom = nom.trim();
  6124. // gestion winpostrophe
  6125. var c = String.fromCharCode(180);
  6126. while(nom.indexOf(c)!=-1) {
  6127. nom = nom.replace(c,"'");
  6128. }
  6129. var arr = getCaracs(nom);
  6130. if(arr.length!=0) {
  6131. caracs = addArray(caracs,arr);
  6132. node.infos = getLine(arr);
  6133. node.onmouseover = showInfos;
  6134. node.onmouseout = hideInfos;
  6135. }
  6136. }
  6137. var nodes = document.evaluate("//dt[@class='equipement']",
  6138. document, null, 7, null);
  6139. var node = nodes.snapshotItem(0);
  6140. node.infos = getLine(caracs);
  6141. node.onmouseover = showInfos;
  6142. node.onmouseout = hideInfos;
  6143. }
  6144. }
  6145. }
  6146.  
  6147. function do_pjview() {
  6148. treateEquipement();
  6149. toolTipInit();
  6150. }
  6151.  
  6152. /*******************************************************************************
  6153. * This file is part of Mountyzilla. *
  6154. * *
  6155. * Mountyzilla is free software; you can redistribute it and/or modify *
  6156. * it under the terms of the GNU General Public License as published by *
  6157. * the Free Software Foundation; either version 2 of the License, or *
  6158. * (at your option) any later version. *
  6159. * *
  6160. * Mountyzilla is distributed in the hope that it will be useful, *
  6161. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6162. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6163. * GNU General Public License for more details. *
  6164. * *
  6165. * You should have received a copy of the GNU General Public License *
  6166. * along with Mountyzilla; if not, write to the Free Software *
  6167. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6168. *******************************************************************************/
  6169.  
  6170. // x~x option
  6171.  
  6172. /* TODO
  6173. * Passer le HTML injecté aux conventions HTML5
  6174. */
  6175.  
  6176.  
  6177. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6178.  
  6179. function saveITData() {
  6180. var IT = document.getElementById('itSelect').value;
  6181. if(IT=='bricol') {
  6182. var system = document.getElementById('urlbricol').value;
  6183. var login = document.getElementById('loginbricol').value;
  6184. var pass = document.getElementById('passbricol').value;
  6185. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6186. if(system && login) {
  6187. if (pass) {
  6188. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6189. MY_setValue(numTroll+'.INFOSIT', v);
  6190. //window.console.log('v=' + v);
  6191. } else {
  6192. // vérif que rien n'a changé
  6193. var str = MY_getValue(numTroll+'.INFOSIT');
  6194. if(str) {
  6195. var arr = str.split('$');
  6196. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6197. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  6198. }
  6199. }
  6200. }
  6201. }
  6202. }
  6203. else {
  6204. MY_removeValue(numTroll+'.INFOSIT');
  6205. }
  6206. }
  6207.  
  6208. function saveLinks() {
  6209. var numLinks = document.getElementById('linksBody').childNodes.length;
  6210. var data=[ [] ];
  6211. /* Récupération et tri des liens */
  6212. for(var i=1 ; i<=numLinks ; i++) {
  6213. MY_removeValue('URL'+i);
  6214. MY_removeValue('URL'+i+'.nom');
  6215. MY_removeValue('URL'+i+'.ico');
  6216. var url = document.getElementById('url'+i).value;
  6217. var nom = document.getElementById('nom'+i).value;
  6218. var ico = document.getElementById('ico'+i).value;
  6219. if(url && (nom || ico) ) {
  6220. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6221. }
  6222. }
  6223. /* Sauvegarde */
  6224. for(var i=1 ; i<data.length ; i++) {
  6225. MY_setValue('URL'+i,data[i][0]);
  6226. MY_setValue('URL'+i+'.nom',data[i][1]);
  6227. MY_setValue('URL'+i+'.ico',data[i][2]);
  6228. }
  6229. }
  6230.  
  6231. function saveAll() {
  6232. var urlIco = document.getElementById('icoMenuIco').value;
  6233. if(urlIco) {
  6234. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6235. }
  6236. else {
  6237. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6238. document.getElementById('icoMenuIco').value = '';
  6239. }
  6240. saveLinks();
  6241. refreshLinks();
  6242. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6243. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6244. if(maxcdm) {
  6245. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6246. }
  6247. else {
  6248. MY_removeValue(numTroll+'.MAXCDM');
  6249. document.getElementById('maxcdm').value = '';
  6250. }
  6251.  
  6252. MY_setValue('NOINFOEM',
  6253. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6254. // Pourquoi Tilk stockait-il tout en str ?
  6255. // -> parce que les booléens c'est foireux (vérifié)
  6256. MY_setValue(numTroll+'.USECSS',
  6257. document.getElementById('usecss').checked ? 'true':'false');
  6258. MY_setValue('INFOCARAC',
  6259. document.getElementById('infocarac').checked ? 'true' : 'false');
  6260. //MY_setValue(numTroll+'.SEND_IDT',
  6261. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6262. // Fonctionnalité désactivée
  6263.  
  6264. MY_setValue(numTroll+'.AUTOCDM',
  6265. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6266. MY_setValue('VUECARAC',
  6267. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6268. MY_setValue('CONFIRMEDECALAGE',
  6269. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6270.  
  6271. saveITData();
  6272. var bouton = document.getElementById('saveAll');
  6273. bouton.value = (bouton.value=='Sauvegardé !') ?
  6274. 'Re-sauvegardé !' : 'Sauvegardé !';
  6275. }
  6276.  
  6277.  
  6278. /*-[functions]----------------- EventListeners -------------------------------*/
  6279.  
  6280. function onChangeIT() {
  6281. var IT = document.getElementById('itSelect').value;
  6282. var itBody = document.getElementById('itBody');
  6283. itBody.innerHTML = '';
  6284. if(IT=='bricol') {
  6285. var tr = appendTr(itBody,'mh_tdpage')
  6286. var td = appendTd(tr);
  6287. var str = MY_getValue(numTroll+'.INFOSIT');
  6288. //window.console.log('onChangeIT str=' + str);
  6289. if(str) {
  6290. var arr = str.split('$');
  6291. var system = arr[1];
  6292. var login = arr[2];
  6293. var affhv = arr[4];
  6294. }
  6295. appendText(td,'Nom du système : ');
  6296. appendTextbox(td,'text','urlbricol',20,50,system);
  6297. td = appendTd(tr);
  6298. appendText(td,'Login du compte : ');
  6299. appendTextbox(td,'text','loginbricol',20,50,login);
  6300. td = appendTd(tr);
  6301. appendText(td,'Mot de passe du compte : ');
  6302. appendTextbox(td,'password','passbricol',20,50);
  6303. td = appendTd(tr);
  6304. appendText(td,'Affichage des Trõlls hors vue : ');
  6305. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  6306. appendCheckBox(td,'affhvbricol', (affhv>0));
  6307. }
  6308. }
  6309.  
  6310. function refreshLinks() {
  6311. document.getElementById('linksBody').innerHTML = '';
  6312. var anotherURL = MY_getValue('URL1');
  6313. if(!anotherURL) { addLinkField(); }
  6314. var i=1;
  6315. while(anotherURL && i<99) {
  6316. addLinkField(i,anotherURL,
  6317. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6318. i++;
  6319. anotherURL = MY_getValue('URL'+i);
  6320. }
  6321. }
  6322.  
  6323. function addLinkField(i,url,nom,ico) {
  6324. var linksBody = document.getElementById('linksBody');
  6325. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6326. var tr = appendTr(linksBody);
  6327. var td = appendTdCenter(tr);
  6328. appendText(td,'Lien '+i+' : ');
  6329. appendTextbox(td,'text','url'+i,40,150,url);
  6330. td = appendTdCenter(tr);
  6331. appendText(td,'Nom : ');
  6332. appendTextbox(td,'text','nom'+i,20,150,nom);
  6333. td = appendTdCenter(tr);
  6334. appendText(td,'Icône : ');
  6335. appendTextbox(td,'text','ico'+i,40,150,ico);
  6336. }
  6337.  
  6338. function removeLinkField() {
  6339. var linksBody = document.getElementById('linksBody');
  6340. var i = linksBody.childNodes.length;
  6341. MY_removeValue('URL'+i);
  6342. MY_removeValue('URL'+i+'.nom');
  6343. MY_removeValue('URL'+i+'.ico');
  6344. linksBody.removeChild(linksBody.lastChild);
  6345. if(linksBody.childNodes.length==0) { addLinkField(); }
  6346. }
  6347.  
  6348. function resetMainIco() {
  6349. document.getElementById('icoMenuIco').value=
  6350. URL_MZimg + 'mz_logo_small.png';
  6351. }
  6352.  
  6353.  
  6354. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6355.  
  6356. function insertTitle(next,txt) {
  6357. var div = document.createElement('div');
  6358. div.className = 'titre2';
  6359. appendText(div,txt);
  6360. insertBefore(next,div);
  6361. return div;
  6362. }
  6363.  
  6364. function insertMainTable(next) {
  6365. var table = document.createElement('table');
  6366. table.width = '98%';
  6367. table.border = 0;
  6368. table.align = 'center';
  6369. table.cellPadding = 2;
  6370. table.cellSpacing = 1;
  6371. table.className = 'mh_tdborder';
  6372. var tbody = document.createElement('tbody');
  6373. table.appendChild(tbody);
  6374. insertBefore(next,table);
  6375. return tbody;
  6376. }
  6377.  
  6378. function appendSubTable(node) {
  6379. var table = document.createElement('table');
  6380. table.width = '100%';
  6381. var tbody = document.createElement('tbody');
  6382. table.appendChild(tbody);
  6383. node.appendChild(table);
  6384. return tbody;
  6385. }
  6386.  
  6387. function insertOptionTable(insertPt) {
  6388. var mainBody = insertMainTable(insertPt);
  6389. /* Liens dans le Menu */
  6390. var tr = appendTr(mainBody,'mh_tdtitre');
  6391. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6392. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6393. appendText(td,'Icône du Menu: ');
  6394. var url = MY_getValue(numTroll+'.ICOMENU');
  6395. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6396. url = URL_MZimg + 'mz_logo_small.png';
  6397. }
  6398. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6399. appendButton(td,'Réinitialiser',resetMainIco);
  6400. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6401. var tbody = appendSubTable(td);
  6402. tbody.id = 'linksBody';
  6403. refreshLinks();
  6404. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6405. appendButton(td,'Ajouter',addLinkField);
  6406. appendButton(td,'Supprimer',removeLinkField);
  6407. /* Options de la Vue : vue externe, nb de CdM, etc */
  6408. tr = appendTr(mainBody,'mh_tdtitre');
  6409. appendTdText(tr,'Options de la Vue :',true);
  6410. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6411. tbody = appendSubTable(td);
  6412. tr = appendTr(tbody);
  6413. td = appendTdText(tr,'Vue externe : ');
  6414. var select = document.createElement('select');
  6415. select.id = 'vueext';
  6416. td.appendChild(select);
  6417. var listeVues2D = [
  6418. 'Bricol\' Vue',
  6419. 'Vue du CCM',
  6420. 'Vue Gloumfs 2D',
  6421. 'Vue Gloumfs 3D',
  6422. 'Grouky Vue!'
  6423. ];
  6424. for(var i=0 ; i<listeVues2D.length ; i++) {
  6425. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6426. }
  6427. if(MY_getValue('VUEEXT')) {
  6428. select.value = MY_getValue('VUEEXT');
  6429. }
  6430. td = appendTd(tr);
  6431. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6432. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6433. tr = appendTr(tbody);
  6434. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6435. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6436. td = appendTd(tr);
  6437. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6438. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6439. /* Interface Tactique */
  6440. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6441. appendText(td,'Interface Tactique : ',true);
  6442. select = document.createElement('select');
  6443. select.id = 'itSelect';
  6444. appendOption(select,'none','Aucune');
  6445. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6446. // seule interface supportée !
  6447. td.appendChild(select);
  6448. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6449. tbody = appendSubTable(td);
  6450. tbody.id = 'itBody';
  6451. select.onchange = onChangeIT;
  6452. var str = MY_getValue(numTroll+'.INFOSIT');
  6453. if(str) {
  6454. select.value = str.slice(0,str.indexOf('$'));
  6455. onChangeIT();
  6456. }
  6457. /* Options diverses */
  6458. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6459. appendText(td,'Options diverses :',true);
  6460. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6461. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6462. appendText(td,
  6463. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6464. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6465. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6466. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6467. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6468. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6469. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6470. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6471. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6472. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6473. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6474. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6475. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6476. /* Bouton SaveAll */
  6477. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6478. input = appendButton(td,'Sauvegarder',saveAll);
  6479. input.id = 'saveAll';
  6480. }
  6481.  
  6482. function insertCreditsTable(insertPt) {
  6483. var tbody = insertMainTable(insertPt);
  6484. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6485. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6486. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6487.  
  6488. var ul = document.createElement('ul');
  6489. td.appendChild(ul);
  6490. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6491. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6492. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6493. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6494. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6495. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6496. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6497. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6498. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6499. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6500. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6501. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6502. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6503. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6504. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6505. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6506. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6507. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6508. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6509. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6510. }
  6511.  
  6512.  
  6513. /* [functions] Obsolètes */
  6514. function deleteEnchantement()
  6515. {
  6516. try
  6517. {
  6518. var idEquipement = this.getAttribute('name');
  6519. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6520. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6521. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6522. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6523. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6524. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6525. var string = "";
  6526. for(var i=0;i<listeEquipement.length;i++)
  6527. {
  6528. if(listeEquipement[i]!=idEquipement)
  6529. if(string=="")
  6530. string = listeEquipement[i];
  6531. else
  6532. string += ";"+listeEquipement[i];
  6533. }
  6534. if(string=="")
  6535. {
  6536. MY_removeValue(numTroll+".enchantement.liste");
  6537. var table = this.parentNode.parentNode.parentNode.parentNode;
  6538. var parent = table.parentNode;
  6539. for(var i=0;i<parent.childNodes.length;i++)
  6540. {
  6541. if(parent.childNodes[i]==table)
  6542. {
  6543. parent.removeChild(parent.childNodes[i-1]);
  6544. parent.removeChild(parent.childNodes[i-1]);
  6545. parent.removeChild(parent.childNodes[i-1]);
  6546. break;
  6547. }
  6548. }
  6549. }
  6550. else
  6551. {
  6552. MY_getValue(numTroll+".enchantement.liste",string);
  6553. this.parentNode.parentNode.parentNode
  6554. .removeChild(this.parentNode.parentNode);
  6555. }
  6556. }
  6557. catch(e)
  6558. {
  6559. window.alert(e);
  6560. }
  6561. }
  6562. /* [functions] fin Obsolètes */
  6563.  
  6564. /*-[functions]---------------- Partie principale -----------------------------*/
  6565.  
  6566. function do_option() {
  6567. start_script(712);
  6568. var insertPoint = document.getElementById('footer1');
  6569. insertBefore(insertPoint,document.createElement('p'));
  6570. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  6571. ti.onclick = function (e) {
  6572. var evt = e || window.event;
  6573. if (!evt.shiftKey) return;
  6574. var txt = '';
  6575. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6576. var k = localStorage.key(i);
  6577. if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6578. txt += k + "\t" + localStorage.getItem(k) + "\n";
  6579. }
  6580. copyTextToClipboard(txt);
  6581. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  6582. }
  6583. ti.title = 'Version ' + GM_info.script.version;
  6584. insertOptionTable(insertPoint);
  6585. /* insertion enchantements ici
  6586. if(...)
  6587. insertEnchantementTable();
  6588. */
  6589. insertBefore(insertPoint,document.createElement('p'));
  6590. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6591. ti.onclick = function (e) {
  6592. var evt = e || window.event;
  6593. if (!evt.shiftKey) return;
  6594. var oldDev = MY_getValue('MZ_dev');
  6595. if (oldDev) {
  6596. MY_removeValue('MZ_dev');
  6597. } else {
  6598. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6599. MY_setValue('MZ_dev', 1);
  6600. }
  6601. document.location.href = document.location.href;
  6602. }
  6603. insertCreditsTable(insertPoint);
  6604. insertBefore(insertPoint,document.createElement('p'));
  6605.  
  6606. /* [zone] Obsolète ?? */
  6607. if(MY_getValue(numTroll+".enchantement.liste")
  6608. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6609. {
  6610. insertTitle(insertPoint, 'Les Enchantements en cours');
  6611. table = document.createElement('table');
  6612. table.setAttribute('width', '98%');
  6613. table.setAttribute('border', '0');
  6614. table.setAttribute('align', 'center');
  6615. table.setAttribute('cellpadding', '2');
  6616. table.setAttribute('cellspacing', '1');
  6617. table.setAttribute('class', 'mh_tdborder');
  6618.  
  6619. tbody = document.createElement('tbody');
  6620. table.appendChild(tbody);
  6621. tr = appendTr(tbody, 'mh_tdtitre');
  6622. appendTdText(tr, 'Equipement',1);
  6623. appendTdText(tr, 'Composants',1);
  6624. appendTdText(tr, 'Enchanteur',1);
  6625. appendTdText(tr, 'Action',1);
  6626. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6627. for(var i=0;i<listeEquipement.length;i++)
  6628. {
  6629. try
  6630. {
  6631. var idEquipement = listeEquipement[i];
  6632. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6633. +idEquipement+".objet");
  6634. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6635. +idEquipement+".enchanteur").split(";");
  6636. var ul = document.createElement('UL');
  6637. for(var j=0;j<3;j++)
  6638. {
  6639. var infoComposant = MY_getValue(numTroll+".enchantement."
  6640. +idEquipement+".composant."+j).split(";");
  6641. var texte = infoComposant[4].replace("Ril ","Œil ");
  6642. for(var k=5;k<infoComposant.length;k++)
  6643. {
  6644. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6645. }
  6646. li = appendLI(ul,texte);
  6647. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6648. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6649. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6650. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6651. string+= '<input type="hidden" name="q" value="min" />';
  6652. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6653. 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>';
  6654.  
  6655. string+= '</form>';
  6656. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6657. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6658. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6659. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6660. li.innerHTML += string;
  6661. }
  6662. tr = appendTr(tbody, 'mh_tdpage');
  6663. td = appendTdText(tr, nomEquipement);
  6664. td.setAttribute('valign', 'center');
  6665. td = document.createElement('td');
  6666. td.appendChild(ul);
  6667. tr.appendChild(td);
  6668. td.setAttribute('valign', 'center');
  6669. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6670. td.setAttribute('valign', 'center');
  6671. td = document.createElement('td');
  6672. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6673. input.setAttribute('name', idEquipement);
  6674. tr.appendChild(td);
  6675. td.setAttribute('valign', 'center');
  6676. }
  6677. catch(e)
  6678. {
  6679. }
  6680. }
  6681. insertBefore(insertPoint, table);
  6682. insertBefore(insertPoint, document.createElement('p'));
  6683. }
  6684. /* [zone] fin Obsolète ?? */
  6685.  
  6686.  
  6687. displayScriptTime();
  6688. }
  6689.  
  6690. /*******************************************************************************
  6691. * This file is part of Mountyzilla. *
  6692. * *
  6693. * Mountyzilla is free software; you can redistribute it and/or modify *
  6694. * it under the terms of the GNU General Public License as published by *
  6695. * the Free Software Foundation; either version 2 of the License, or *
  6696. * (at your option) any later version. *
  6697. * *
  6698. * Mountyzilla is distributed in the hope that it will be useful, *
  6699. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6700. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6701. * GNU General Public License for more details. *
  6702. * *
  6703. * You should have received a copy of the GNU General Public License *
  6704. * along with Mountyzilla; if not, write to the Free Software *
  6705. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6706. *******************************************************************************/
  6707.  
  6708. // x~x equip
  6709.  
  6710. /**
  6711. * 2014-02-08 - v2.0a (from scratch)
  6712. * 2014-02-18 - v2.0a0
  6713. * - ajout calcul Carats / UM des minerais + totaux
  6714. * 2014-03-06 - v2.0a1
  6715. * - retour Infos EM des Champis
  6716. * TODO
  6717. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6718. */
  6719.  
  6720. function traiteChampis() {
  6721. try{
  6722. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6723. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6724. }
  6725. catch(e){return;}
  6726. if(trlist.length<=0) return;
  6727. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6728. var node = trlist.snapshotItem(i).childNodes[7];
  6729. var str = node.textContent.trim();
  6730. var type = str.slice(0,str.lastIndexOf(' '));
  6731. var mundi = mundiChampi[type];
  6732. if(!mundi) continue;
  6733. var urlImg = URL_MZimg
  6734. +'Competences/ecritureMagique.png';
  6735. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6736. appendText(node,' ');
  6737. node.appendChild(img);
  6738. }
  6739. }
  6740.  
  6741. function traiteCompos() {
  6742. try {
  6743. var tr = document.getElementById('mh_objet_hidden_Composant');
  6744. var tbody = document.evaluate("./td/table/tbody",
  6745. tr, null, 9, null).singleNodeValue;
  6746. }
  6747. catch(e) {return;}
  6748. insererInfosEM(tbody);
  6749. }
  6750.  
  6751. function traiteMinerai() {
  6752. try{
  6753. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6754. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6755. }
  6756. catch(e){return;}
  6757. if(trlist.length<=0) return;
  6758. var totaux = {};
  6759. var str;
  6760. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6761. var node = trlist.snapshotItem(i);
  6762. var nature = node.childNodes[7].textContent,
  6763. caracs = node.childNodes[9].textContent;
  6764. var taille = Number(caracs.match(/\d+/)[0]);
  6765. var coef = 1;
  6766. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6767. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6768. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6769. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6770. if(nature.indexOf('Mithril')!=-1) {
  6771. coef = 0.2*coef;
  6772. str = ' | UM: ';
  6773. }
  6774. else {
  6775. coef = 0.75*coef+1.25;
  6776. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6777. str = ' | Carats: ';
  6778. }
  6779. var carats = Math.round(taille*coef)
  6780. appendText(node.childNodes[9], str+carats );
  6781. if(!totaux[nature]) {
  6782. totaux[nature] = [taille,carats];
  6783. }
  6784. else {
  6785. totaux[nature][0] += taille;
  6786. totaux[nature][1] += carats;
  6787. }
  6788. }
  6789. str = 'Total : ';
  6790. for(var nature in totaux) {
  6791. if(str.length>8) str += ', ';
  6792. if(nature.indexOf('Mithril')!=-1) {
  6793. str += nature+totaux[nature][1]+' UM';
  6794. }
  6795. else {
  6796. str += nature+totaux[nature][0]+'U/'
  6797. +totaux[nature][1]+'c';
  6798. }
  6799. }
  6800. /*var node = document.getElementById('mh_plus_Minerai');
  6801. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6802. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6803. if(!titre) return;*/
  6804. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6805. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6806. td.colSpan = 7;
  6807. }
  6808.  
  6809. function do_equip() {
  6810. start_script();
  6811.  
  6812. traiteChampis();
  6813. traiteCompos();
  6814. traiteMinerai();
  6815.  
  6816. displayScriptTime();
  6817. }
  6818.  
  6819. /*******************************************************************************
  6820. * This file is part of Mountyzilla. *
  6821. * *
  6822. * Mountyzilla is free software; you can redistribute it and/or modify *
  6823. * it under the terms of the GNU General Public License as published by *
  6824. * the Free Software Foundation; either version 2 of the License, or *
  6825. * (at your option) any later version. *
  6826. * *
  6827. * Mountyzilla is distributed in the hope that it will be useful, *
  6828. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6829. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6830. * GNU General Public License for more details. *
  6831. * *
  6832. * You should have received a copy of the GNU General Public License *
  6833. * along with Mountyzilla; if not, write to the Free Software *
  6834. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6835. *******************************************************************************/
  6836.  
  6837. // x~x diplo
  6838.  
  6839. /*
  6840. TODO:
  6841. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6842. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6843. V Étape 3: Ajout de la diplo perso
  6844. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6845. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6846. Options Globales:
  6847. Actuelles:
  6848. numTroll.USECSS,
  6849. numTroll.NODIPLO
  6850. NOMYTH
  6851. Nouvelles:
  6852. TODO numTroll.USECSS
  6853. numTroll.diplo.off (remplace NODIPLO)
  6854. numTroll.diplo.guilde
  6855. numTroll.diplo.perso
  6856. Structure de diplo.guilde:
  6857. isOn: 'true' ou 'false'
  6858. isDetailOn: 'true' ou 'false'
  6859. guilde
  6860. > id
  6861. > couleur
  6862. AllAmis,AllEnnemis: couleur
  6863. Amis0,...,Ennemis5
  6864. > Troll: idTroll1;...;
  6865. > Guilde: idGuilde1;...;
  6866. > titre
  6867. > couleur
  6868. Structure de diplo.perso:
  6869. isOn: 'true' ou 'false'
  6870. mythiques: couleur
  6871. Troll,Guilde,Monstre:
  6872. > id
  6873. > couleur
  6874. > description
  6875. */
  6876.  
  6877. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6878.  
  6879. function couleurAleatoire() {
  6880. var alph = '0123456789ABCDEF'.split('');
  6881. var clr = '#';
  6882. for (var i=0; i<6; i++) {
  6883. clr+=alph[ Math.floor(16*Math.random()) ];
  6884. }
  6885. return clr;
  6886. }
  6887.  
  6888. function isCouleur(str) {
  6889. return /^#[0-9A-F]{6}$/i.test(str);
  6890. }
  6891.  
  6892. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6893.  
  6894. function appendChoixCouleur(node,id) {
  6895. var span = document.createElement('span');
  6896. span.id = 'span'+id;
  6897. if(isDetailOn) {
  6898. span.style.display = 'none';
  6899. }
  6900. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6901. if(diploGuilde[id]) {
  6902. couleur = diploGuilde[id];
  6903. }
  6904. appendText(span,' - Couleur HTML: ');
  6905. var input = appendTextbox(span,'text',id,7,7,couleur);
  6906. input.onkeyup = previewCouleur;
  6907. input.onchange = previewCouleur;
  6908. input.onkeyup();
  6909. node.appendChild(span);
  6910. }
  6911.  
  6912. function insertChoixCouleur(node,id) {
  6913. var span = document.createElement('span');
  6914. span.id = 'span'+id;
  6915. // La couleur détaillée passera à une valeur aléatoire
  6916. // si toggle vers isDetailOn
  6917. var couleur = couleurAleatoire();
  6918. if(!isDetailOn) {
  6919. span.style.display = 'none';
  6920. } else if(diploGuilde[id]) {
  6921. couleur = diploGuilde[id].couleur;
  6922. }
  6923. appendText(span,' - Couleur HTML: ');
  6924. var input = appendTextbox(span,'text',id,7,7,couleur);
  6925. input.onkeyup = previewCouleur;
  6926. input.onchange = previewCouleur;
  6927. input.onkeyup();
  6928. insertBefore(node,span);
  6929. }
  6930.  
  6931. function setChoixCouleurs() {
  6932. try {
  6933. //var form = document.getElementsByName('ActionForm')[0];
  6934. var form = document.getElementById('mhPlay');
  6935. var nodesAE = document.evaluate(
  6936. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  6937. "./table/tbody/tr/th[@class='mh_tdtitre']",
  6938. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  6939. form, null, 7, null
  6940. );
  6941. var nodes = document.evaluate(
  6942. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6943. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  6944. form, null, 7, null
  6945. );
  6946. } catch(e) {
  6947. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6948. return false;
  6949. };
  6950. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6951. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6952. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6953. for(var i=0 ; i<5 ; i++) {
  6954. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6955. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6956. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6957. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6958. }
  6959. return true;
  6960. }
  6961.  
  6962. function fetchDiploGuilde() {
  6963. try {
  6964. for(var AE in {Amis:0,Ennemis:0}) {
  6965. for(var i=0 ; i<5 ; i++) {
  6966. /* Récup des A/E de rang i */
  6967. var td = document.getElementById('td'+AE+i);
  6968. var ligne = td.getElementsByTagName('table')[0].rows;
  6969. var titre = trim(td.firstChild.textContent);
  6970. // On laisse la gestion des couleurs à setChoixCouleurs:
  6971. var couleur = document.getElementById(AE+i).value;
  6972. diploGuilde[AE+i] = {
  6973. Troll:'',
  6974. Guilde:'',
  6975. titre: titre,
  6976. couleur: couleur
  6977. };
  6978. for(var j=1 ; j<ligne.length ; j++) {
  6979. var str = trim(ligne[j].cells[0].textContent);
  6980. var idx = str.lastIndexOf('(');
  6981. var num = str.slice(idx+1,-1);
  6982. var type = trim(ligne[j].cells[1].textContent);
  6983. diploGuilde[AE+i][type] += num+';';
  6984. }
  6985. }
  6986. }
  6987. } catch(e) {
  6988. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6989. return false;
  6990. }
  6991. return true;
  6992. }
  6993.  
  6994.  
  6995. /*-[functions]--------------------- Handlers ---------------------------------*/
  6996.  
  6997. function toggleDetails() {
  6998. isDetailOn = !isDetailOn;
  6999. for(var AE in {Amis:0,Ennemis:0}) {
  7000. document.getElementById('spanAll'+AE).style.display =
  7001. (isDetailOn?'none':'');
  7002. for(var i=0 ; i<5 ; i++) {
  7003. document.getElementById('span'+AE+i).style.display =
  7004. (isDetailOn?'':'none');
  7005. }
  7006. }
  7007. }
  7008.  
  7009. function toggleMythiques() {
  7010. isMythiquesOn = !isMythiquesOn;
  7011. document.getElementById('spanMythiques').style.display =
  7012. (isMythiquesOn?'':'none');
  7013. }
  7014.  
  7015. function previewCouleur() {
  7016. var value = this.value;
  7017. if(isCouleur(value)) {
  7018. this.style.backgroundColor = value;
  7019. this.title = '';
  7020. } else {
  7021. this.style.backgroundColor = '';
  7022. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7023. }
  7024. }
  7025.  
  7026. function appendMenuType(node,duType) {
  7027. var select = document.createElement('select');
  7028. select.className = 'SelectboxV2';
  7029. var type = ['Guilde','Troll','Monstre'];
  7030. for(var i=0 ; i<3 ; i++) {
  7031. appendOption(select,type[i],type[i]);
  7032. if(type[i]==duType) { select.selectedIndex=i; }
  7033. }
  7034. node.appendChild(select);
  7035. }
  7036.  
  7037. function ajouteChamp(type,num,couleur,descr) {
  7038. var champs = document.getElementById('diploPerso');
  7039. var nb = champs.rows.length;
  7040. var tr = champs.insertRow(-1);
  7041. var td = appendTd(tr);
  7042. appendMenuType(td,type);
  7043. td = appendTd(tr);
  7044. appendText(td,' n°');
  7045. appendTextbox(td,'text','num'+nb,6,15,num);
  7046. td = appendTd(tr);
  7047. appendText(td,' couleur HTML:');
  7048. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7049. input.onkeyup = previewCouleur;
  7050. input.onchange = previewCouleur;
  7051. input.onkeyup();
  7052. td = appendTd(tr);
  7053. appendText(td,' Description:');
  7054. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7055. td = appendTd(tr);
  7056. var span = document.createElement('span');
  7057. appendText(span,'[ok!]',true);
  7058. span.style.visibility = 'hidden';
  7059. td.appendChild(span);
  7060. td = appendTd(tr);
  7061. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7062. }
  7063.  
  7064. function retireCeChamp() {
  7065. var thisTr = this.parentNode.parentNode;
  7066. thisTr.parentNode.removeChild(thisTr);
  7067. var champs = document.getElementById('diploPerso');
  7068. if(champs.rows.length==0) { ajouteChamp(); }
  7069. }
  7070.  
  7071. function valideChamp(champ) {
  7072. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7073. isCouleur(champ.cells[2].childNodes[1].value);
  7074. if(isValide) {
  7075. champ.cells[4].firstChild.style.visibility = 'visible';
  7076. } else {
  7077. champ.cells[4].firstChild.style.visibility = 'hidden';
  7078. }
  7079. return isValide;
  7080. }
  7081.  
  7082. function sauvegarderTout() {
  7083. /* Diplo de guilde */
  7084. diploGuilde.isOn =
  7085. document.getElementById('isGuildeOn').checked?'true':'false';
  7086. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7087. var numGuilde = Number(document.getElementById('numGuilde').value);
  7088. var couleur = document.getElementById('couleurGuilde').value;
  7089. if(numGuilde) {
  7090. diploGuilde.guilde = {
  7091. id: numGuilde,
  7092. couleur: couleur
  7093. };
  7094. } else {
  7095. delete diploGuilde.guilde;
  7096. }
  7097. for(var AE in {Amis:0,Ennemis:0}) {
  7098. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7099. for(var i=0 ; i<5 ; i++) {
  7100. if(isDetailOn) {
  7101. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7102. } else {
  7103. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7104. }
  7105. }
  7106. }
  7107. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7108. /* Diplo personnelle (ex-fonction saveChamps) */
  7109. var champs = document.getElementById('diploPerso');
  7110. diploPerso = {
  7111. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7112. Guilde: {},
  7113. Troll: {},
  7114. Monstre: {}
  7115. };
  7116. if(isMythiquesOn &&
  7117. isCouleur(document.getElementById('couleurMythiques').value)) {
  7118. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7119. }
  7120. for(var i=0 ; i<champs.rows.length ; i++) {
  7121. if(valideChamp(champs.rows[i])) {
  7122. var type = champs.rows[i].cells[0].firstChild.value;
  7123. var num = champs.rows[i].cells[1].childNodes[1].value;
  7124. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7125. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7126. diploPerso[type][num] = {
  7127. couleur: couleur
  7128. };
  7129. if(descr) {
  7130. diploPerso[type][num].titre = descr;
  7131. }
  7132. }
  7133. }
  7134. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7135.  
  7136. avertissement('Données sauvegardées');
  7137. }
  7138.  
  7139.  
  7140. /*-[functions]------------- Modifications de la page -------------------------*/
  7141.  
  7142. function creeTablePrincipale() {
  7143. var insertPt = document.getElementById('insertPt');
  7144. /* Titre + bouton de Sauvegarde */
  7145. var tr = insertTr(insertPt,'mh_tdtitre');
  7146. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7147. appendButton(td,'Sauvegarder',sauvegarderTout);
  7148. /* Options fixes */
  7149. tr = insertTr(insertPt,'mh_tdpage');
  7150. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7151. appendBr(td);
  7152. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7153. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7154. appendBr(td);
  7155. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7156. appendText(td,'Utiliser des couleurs détaillées (10)');
  7157. /* Diplo personnelle */
  7158. tr = insertTr(insertPt,'mh_tdpage');
  7159. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7160. appendBr(td);
  7161. // Diplo Mythiques
  7162. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7163. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7164. var span = document.createElement('span');
  7165. span.id = 'spanMythiques';
  7166. if(!isMythiquesOn) {
  7167. span.style.display = 'none';
  7168. }
  7169. var couleur = '#FFAAAA';
  7170. if(diploPerso.mythiques) {
  7171. couleur = diploPerso.mythiques;
  7172. }
  7173. appendText(span,' - couleur HTML:');
  7174. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7175. input.onkeyup = previewCouleur;
  7176. input.onchange = previewCouleur;
  7177. input.onkeyup();
  7178. td.appendChild(span);
  7179. appendBr(td);
  7180. // Diplo éditable
  7181. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7182. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7183. appendBr(td);
  7184. var table = document.createElement('table');
  7185. table.id = 'diploPerso'
  7186. td.appendChild(table);
  7187. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7188. for(var num in diploPerso[type]) {
  7189. ajouteChamp(
  7190. type,
  7191. num,
  7192. diploPerso[type][num].couleur,
  7193. diploPerso[type][num].titre
  7194. );
  7195. }
  7196. }
  7197. if(table.rows.length==0) {
  7198. ajouteChamp();
  7199. }
  7200. appendButton(td,'Ajouter',ajouteChamp)
  7201. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7202. appendText(td,' ');
  7203. appendButton(td,
  7204. 'Exemples de couleur',
  7205. function() {
  7206. var fenetre = window.open(
  7207. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7208. 'Divers',
  7209. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7210. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7211. );
  7212. fenetre.focus();
  7213. }
  7214. );
  7215. /* Couleur de Guilde */
  7216. tr = insertTr(insertPt,'mh_tdtitre');
  7217. td = appendTdText(tr,'GUILDE',true);
  7218. appendText(td,' - n°');
  7219. appendTextbox(td,'text','numGuilde',5,10,
  7220. diploGuilde.guilde && diploGuilde.guilde.id ?
  7221. diploGuilde.guilde.id : ''
  7222. );
  7223. appendText(td,' - Couleur HTML: ');
  7224. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7225. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7226. diploGuilde.guilde.couleur : '#BBBBFF'
  7227. );
  7228. input.onkeyup = previewCouleur;
  7229. input.onchange = previewCouleur;
  7230. input.onkeyup();
  7231. }
  7232.  
  7233.  
  7234. /*-[functions]----------------------- Main -----------------------------------*/
  7235.  
  7236. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  7237. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  7238. var isDetailOn = diploGuilde.isDetailOn=='true';
  7239. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  7240. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  7241. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7242.  
  7243. function do_diplo() {
  7244. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7245. creeTablePrincipale();
  7246. }
  7247. }
  7248.  
  7249. /*******************************************************************************
  7250. * This file is part of Mountyzilla. *
  7251. * *
  7252. * Mountyzilla is free software; you can redistribute it and/or modify *
  7253. * it under the terms of the GNU General Public License as published by *
  7254. * the Free Software Foundation; either version 2 of the License, or *
  7255. * (at your option) any later version. *
  7256. * *
  7257. * Mountyzilla is distributed in the hope that it will be useful, *
  7258. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7259. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7260. * GNU General Public License for more details. *
  7261. * *
  7262. * You should have received a copy of the GNU General Public License *
  7263. * along with Mountyzilla; if not, write to the Free Software *
  7264. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7265. *******************************************************************************/
  7266.  
  7267. // x~x cdmcomp
  7268.  
  7269. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7270.  
  7271. function getNonNegInts(str) {
  7272. var nbrs = str.match(/\d+/g);
  7273. for(var i=0 ; i<nbrs.length ; i++) {
  7274. nbrs[i] = Number(nbrs[i]);
  7275. }
  7276. return nbrs;
  7277. }
  7278.  
  7279. function traiteCdMcomp() {
  7280. try {
  7281. var msgEffet = document.getElementById('msgEffet');
  7282. } catch(e) {
  7283. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7284. return;
  7285. }
  7286.  
  7287. // Teste si ce message du bot est un message de CdM
  7288. if(!document.evaluate(
  7289. "./p/text()[contains(.,'fait partie')]",
  7290. msgEffet, null, 9, null
  7291. ).singleNodeValue) {
  7292. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7293. return;
  7294. }
  7295. // Début de récupération de la CdM
  7296. /*
  7297. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7298. zone à supprimer
  7299. traitement Armure Physique/Magique reporté en php
  7300.  
  7301. cdm = document.evaluate(
  7302. "./p/text()[contains(.,'fait partie')]",
  7303. msgEffet, null, 9, null
  7304. ).singleNodeValue.nodeValue+'\n';
  7305. var tbody = document.evaluate(
  7306. "descendant::table/tbody",
  7307. msgEffet, null, 9, null
  7308. ).singleNodeValue;
  7309. var nomStat = document.evaluate(
  7310. "./tr/td[1]/b/text()",
  7311. tbody, null, 7, null
  7312. );
  7313. var valStat = document.evaluate(
  7314. "./tr/td[2]/descendant::text()",
  7315. tbody, null, 7, null
  7316. );
  7317. var i=0;
  7318. while(i<nomStat.snapshotLength) {
  7319. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7320. cdm += 'Armure : ';
  7321. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7322. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7323. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7324. armp = [0,armp[0]];
  7325. }
  7326. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7327. armm = [0,armm[0]];
  7328. }
  7329. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7330. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7331. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7332. } else {
  7333. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7334. }
  7335. cdm += ')\n';
  7336. i++;
  7337. } else {
  7338. cdm += nomStat.snapshotItem(i).nodeValue+
  7339. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7340. }
  7341. i++;
  7342. }
  7343. */
  7344. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7345. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7346.  
  7347. // envoi au serveur (PHP) d'un objet avec
  7348. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7349. // tstamp: l'horodatage
  7350. var tabCdM = new Array();
  7351. var etimestamp = document.getElementById('hserveur');
  7352. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7353. var txtBlessure;
  7354. var txtPv;
  7355. for (var eHTML of msgEffet.childNodes) {
  7356. switch (eHTML.nodeName) {
  7357. case '#text':
  7358. var s = eHTML.nodeValue.trim();
  7359. if (s != '') tabCdM.push(s);
  7360. break;
  7361. case 'P':
  7362. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7363. s = s.trim();
  7364. if (s != '') tabCdM.push(s);
  7365. break;
  7366. case 'TABLE':
  7367. var s = 'table';
  7368. for (var eTr of eHTML.rows) {
  7369. var tabTd = new Array();
  7370. for (var eTd of eTr.cells) {
  7371. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7372. s = s.trim();
  7373. tabTd.push(s);
  7374. }
  7375. if (tabTd.length >= 2) {
  7376. if (tabTd[0].match(/Blessure/i)) {
  7377. txtBlessure = tabTd[1]
  7378. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  7379. txtPv = tabTd[1]
  7380. }
  7381. }
  7382. tabCdM.push(tabTd);
  7383. }
  7384. break;
  7385. default:
  7386. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  7387. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7388. if (s != '') tabCdM.push(s);
  7389. break;
  7390. }
  7391. }
  7392. var oData = {};
  7393. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  7394. oData.idTroll = numTroll;
  7395. oData.tabCdM = tabCdM;
  7396. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  7397.  
  7398. // envoi d'une CdM issue de compte-rendu de compétence
  7399. // fonction définie ici pour avoir vue sur la variable tabCdM
  7400. var sendInfoCDM = function () {
  7401. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7402. var buttonCDM = this;
  7403. var texte = '';
  7404. FF_XMLHttpRequest({
  7405. method: 'POST',
  7406. url: URL_pageDispatcherV2,
  7407. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7408. headers : {
  7409. /* inutile, à supprimer
  7410. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7411. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7412. */
  7413. 'Content-type':'application/x-www-form-urlencoded',
  7414. },
  7415. onload: function(responseDetails) {
  7416. texte = responseDetails.responseText;
  7417. buttonCDM.value = texte;
  7418. if (!isDEV) buttonCDM.disabled = true;
  7419. }
  7420. });
  7421. }
  7422.  
  7423. // Envoi auto ou insertion bouton envoi (suivant option)
  7424. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7425. sendInfoCDM();
  7426. var p = document.createElement('p');
  7427. p.style.color = 'green';
  7428. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7429. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7430. } else {
  7431. insertButtonCdm('as_Action', sendInfoCDM);
  7432. }
  7433.  
  7434. // Insertion de l'estimation des PV restants
  7435. /*
  7436. var pv = valStat.snapshotItem(1).nodeValue;
  7437. if(pv.indexOf("entre")==-1) {
  7438. return;
  7439. }
  7440. var trPv = document.evaluate(
  7441. "//tr[contains(td/b/text(),'Points de Vie')]",
  7442. msgEffet, null, 9, null).singleNodeValue;
  7443. tdPv = trPv.cells[1];
  7444. txtPv = tdPv.innerText || tdPv.textContent;
  7445. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  7446. if(0) { //pv) { // bloqué en attendant correction
  7447. */
  7448. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  7449. if (txtBlessure !== undefined && txtPv !== undefined) {
  7450. var pv = getPVsRestants(txtPv,txtBlessure);
  7451. if (MY_DEBUG) window.console.log('pv=' + pv);
  7452. if (pv) { // pv null si le monstre n'est pas blessé
  7453. var trBless = document.evaluate(
  7454. "//tr[contains(td/b/text(),'Blessure')]",
  7455. msgEffet, null, 9, null).singleNodeValue;
  7456. var tr = document.createElement('tr');
  7457. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  7458. appendTr(trBless);
  7459. appendTdText(tr, pv[0], true);
  7460. appendTdText(tr, pv[1], true);
  7461. }
  7462. }
  7463. }
  7464.  
  7465. function do_cdmcomp() {
  7466. start_script(31);
  7467. traiteCdMcomp();
  7468. displayScriptTime();
  7469. }
  7470.  
  7471. /*********************************************************************************
  7472. * This file is part of Mountyzilla. *
  7473. * *
  7474. * Mountyzilla is free software; you can redistribute it and/or modify *
  7475. * it under the terms of the GNU General Public License as published by *
  7476. * the Free Software Foundation; either version 2 of the License, or *
  7477. * (at your option) any later version. *
  7478. * *
  7479. * Mountyzilla is distributed in the hope that it will be useful, *
  7480. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7481. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7482. * GNU General Public License for more details. *
  7483. * *
  7484. * You should have received a copy of the GNU General Public License *
  7485. * along with Mountyzilla; if not, write to the Free Software *
  7486. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7487. *********************************************************************************/
  7488.  
  7489. // x~x cmdbot
  7490.  
  7491. /* v0.2 by Dab - 2013-08-20
  7492. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7493. */
  7494.  
  7495. var buttonCDM;
  7496.  
  7497. /*******************************************************************************************
  7498. CDM :
  7499. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7500.  
  7501. Il ne vous est pas possible d'améliorer cette compétence.
  7502.  
  7503. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7504. Niveau : Inimaginable (entre 49 et 51)
  7505. Points de Vie : Surtrollesque (entre 450 et 470)
  7506. Blessure (Approximatif) : 0 %
  7507. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7508. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7509. Dés de Dégat : Très Fort (entre 18 et 20)
  7510. Dés de Régénération : Excellent (égal à 13)
  7511. Armure Physique : Moyen (entre 10 et 12)
  7512. Armure Magique : Faible (inférieur à 6)
  7513. Vue : Moyen (entre 9 et 11)
  7514. Maitrise Magique : Inimaginable (supérieur à 6000)
  7515. Résistance Magique : Inimaginable (supérieur à 6000)
  7516. Nombre d'attaques : 1
  7517. Vitesse de Déplacement : Normale
  7518. Voir le Caché : Oui
  7519. Attaque à distance : Non
  7520. Attaque magique : Oui
  7521. Vole : Non
  7522. Sang froid : Inexistant
  7523. DLA : Milieu
  7524. Durée Tour : Remarquable (entre 9 et 11)
  7525. Chargement : Vide
  7526. Bonus Malus : Aucun
  7527.  
  7528. Vous avez également gagné 1 PX pour la réussite.
  7529. *******************************************************************************************
  7530. BOT :
  7531. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7532.  
  7533. Le Monstre ciblé fait partie des : Mort-Vivant
  7534.  
  7535. Niveau : Incroyable (entre 36 et 38)
  7536. *******************************************************************************************/
  7537.  
  7538. function getNNInt(str) {
  7539. var nbrs = str.match(/\d+/g);
  7540. for (var i=0 ; i<nbrs.length ; i++)
  7541. nbrs[i] = parseInt(nbrs[i]);
  7542. return nbrs;
  7543. }
  7544.  
  7545. // envoi d'une CdM issue d'un message du BOT
  7546. function sendCDM() {
  7547. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  7548. document, null, 9, null).singleNodeValue;
  7549. /* ancienne version à supprimer
  7550. cdm = td.innerHTML;
  7551. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7552. "$3$4 ($1 - N°$2)<br>");
  7553. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7554. 'Blessure : XX % (approximativement)');
  7555. // Supprime la décomposition P/M de l'Armure
  7556. var bgn = cdm.indexOf('Armure Physique');
  7557. if (bgn!=-1) {
  7558. var end = cdm.indexOf('Vue')-2;
  7559. var lines = cdm.substring(bgn,end).split('<br>');
  7560. var armp = getNNInt(lines[0]);
  7561. var armm = getNNInt(lines[1]);
  7562. if (lines[0].indexOf('(inf')!=-1)
  7563. armp = [0,armp[0]];
  7564. if (lines[1].indexOf('(inf')!=-1)
  7565. armm = [0,armm[0]];
  7566. var insrt = 'Armure : ';
  7567. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7568. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7569. else
  7570. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7571. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7572. }
  7573. cdm = cdm.replace(/<br>/g,'\n');
  7574. */
  7575.  
  7576. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  7577. //window.console.log(tdTxt);
  7578. var oData = {};
  7579. oData.tabCdM = tdTxt.split(/\n/);
  7580. // nettoyage entête : enlève le premier élément tant que
  7581. // - suite de *
  7582. // - "MOUNTYHALL - La Terre des Trõlls"
  7583. // - ligne vide (la première expression régulière matche les lignes vides)
  7584. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  7585. // nettoyage entête : enlève tout ce qui suit une ligne composée uniquement d'étoiles suivie de '^Vous avez configuré' + les lignes vides au dessus
  7586. var iLigneNonVide;
  7587. for (var i = 0; i < oData.tabCdM.length; i++) {
  7588. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  7589. if (iLigneNonVide === undefined)
  7590. oData.tabCdM.splice(i);
  7591. else
  7592. oData.tabCdM.splice(iLigneNonVide+1);
  7593. break;
  7594. }
  7595. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  7596. }
  7597. //window.console.log(JSON.stringify(oData));
  7598.  
  7599. FF_XMLHttpRequest({
  7600. method: 'POST',
  7601. url: URL_pageDispatcherV2,
  7602. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7603. headers : {
  7604. /* inutile, à supprimer
  7605. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7606. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7607. */
  7608. 'Content-type':'application/x-www-form-urlencoded',
  7609. },
  7610. onload: function(responseDetails) {
  7611. buttonCDM.value=responseDetails.responseText;
  7612. buttonCDM.disabled = true;
  7613. }
  7614. });
  7615. }
  7616.  
  7617. function traiteCdMmsg() {
  7618. // Teste si ce message du bot est un message de CdM
  7619. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7620. document, null, 9, null).singleNodeValue;
  7621. if (!td) return false;
  7622. cdm = td.innerHTML;
  7623. // Insertion de l'estimation des PV restants
  7624. var des = cdm.indexOf('Dés');
  7625. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7626. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7627. if(pv)
  7628. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7629.  
  7630. // Insertion bouton envoi + espace
  7631. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7632. }
  7633.  
  7634. /*function traitePouvoir() {
  7635. // Teste si ce message du bot est un message de CdM
  7636. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7637. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7638. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7639. if (!td)
  7640. return false;
  7641. var infos = td.innerHTML;
  7642. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7643. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7644. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7645. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7646. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7647. var effetPouvoir="";
  7648. var full=false;
  7649. if(infos.indexOf("REDUIT")!=-1) {
  7650. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7651. }
  7652. else {
  7653. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7654. full=true;
  7655. }
  7656. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7657. // On insère le bouton et un espace
  7658. //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));
  7659. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7660. if(!MY_getValue('AUTOSENDPOUV'))
  7661. {
  7662. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7663. button.setAttribute("onClick", "window.open('" + url
  7664. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7665. + "this.value='Merci de votre participation'; this.disabled = true;");
  7666. }
  7667. else
  7668. {
  7669. FF_XMLHttpRequest({
  7670. method: 'GET',
  7671. url: url,
  7672. headers : {
  7673. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7674. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7675. }});
  7676. }
  7677. }*/
  7678.  
  7679. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7680. traiteCdMmsg();
  7681. }
  7682. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7683.  
  7684. /*******************************************************************************
  7685. * This file is part of Mountyzilla. *
  7686. * *
  7687. * Mountyzilla is free software; you can redistribute it and/or modify *
  7688. * it under the terms of the GNU General Public License as published by *
  7689. * the Free Software Foundation; either version 2 of the License, or *
  7690. * (at your option) any later version. *
  7691. * *
  7692. * Mountyzilla is distributed in the hope that it will be useful, *
  7693. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7694. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7695. * GNU General Public License for more details. *
  7696. * *
  7697. * You should have received a copy of the GNU General Public License *
  7698. * along with Mountyzilla; if not, write to the Free Software *
  7699. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7700. *******************************************************************************/
  7701.  
  7702. // x~x menu
  7703. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7704.  
  7705. var menuRac, mainIco;
  7706.  
  7707. // met à jour les carac sauvegardées (position, DLA, etc.)
  7708. function updateData() {
  7709. var inputs = document.getElementsByTagName('input');
  7710. var divs = document.getElementsByTagName('div');
  7711.  
  7712. //window.console.log('inputs=' + JSON.stringify(inputs));
  7713. if (inputs && inputs.length > 0) {
  7714. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  7715. numTroll = inputs[0].value;
  7716. MY_setValue('NUM_TROLL', numTroll);
  7717. MY_setValue('NIV_TROLL',inputs[1].value);
  7718. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7719. MY_setValue(numTroll+'.caracs.rm',0);
  7720. // assure l'init des 4 var de libs
  7721. }
  7722. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7723. } else {
  7724. // onclick="EnterPJView(91305,750,550)"
  7725. var tabA = document.getElementsByTagName('a');
  7726. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  7727. var s = tabA[0].onclick.toString();;
  7728. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  7729. var m = s.match(/\((\d+) *,/);
  7730. //window.console.log('m=' + JSON.stringify(m));
  7731. numTroll = parseInt(m[1]);
  7732. MY_setValue('NUM_TROLL', numTroll);
  7733. }
  7734. }
  7735.  
  7736. var DLA = new Date(
  7737. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  7738. );
  7739. if(MY_getValue(numTroll+'.DLA.encours')) {
  7740. var DLAstockee = new Date(
  7741. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  7742. );
  7743. if(DLA>DLAstockee) {
  7744. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  7745. // Pose un pb en cas de décalage de DLA
  7746. }
  7747. }
  7748. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  7749.  
  7750. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  7751. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  7752. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  7753. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  7754. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  7755. }
  7756.  
  7757. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7758. function initRaccourcis() {
  7759. var anotherURL = MY_getValue('URL1');
  7760. if(!anotherURL) { return; }
  7761. /* Création de l'icône faisant apparaître le menu */
  7762. mainIco = document.createElement('img');
  7763. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  7764. if(!urlIco) {
  7765. urlIco =
  7766. URL_MZimg + 'mz_logo_small.png';
  7767. }
  7768. mainIco.src = urlIco;
  7769. mainIco.alt = 'MZ';
  7770. mainIco.style = 'position:fixed; top:0px; left:0px';
  7771. mainIco.onmouseover = afficheMenu;
  7772. document.body.appendChild(mainIco);
  7773. /* Création du menu des Raccourcis */
  7774. menuRac = document.createElement('div');
  7775. menuRac.className = 'mh_textbox';
  7776. menuRac.style =
  7777. 'position:fixed; top:10px; left:10px;'+
  7778. 'max-width:190px;'+
  7779. 'border-radius: 4px; padding: 4px;'+
  7780. 'z-index: 500;'+
  7781. 'visibility: hidden;';
  7782. document.body.appendChild(menuRac);
  7783. document.addEventListener('mousemove',cacheMenu,false);
  7784. var i=1;
  7785. while(anotherURL) {
  7786. var a = document.createElement('a');
  7787. var url = MY_getValue('URL'+i);
  7788. var nom = MY_getValue('URL'+i+'.nom');
  7789. var ico = MY_getValue('URL'+i+'.ico');
  7790. a.href = url;
  7791. a.target = '_blank';
  7792. if(ico) {
  7793. var txt = nom ? nom : '';
  7794. var img = createImage(ico,txt);
  7795. a.appendChild(img);
  7796. }
  7797. else {
  7798. appendText(a,'['+nom+']');
  7799. }
  7800. menuRac.appendChild(a);
  7801. appendBr(menuRac);
  7802. i++;
  7803. anotherURL = MY_getValue('URL'+i);
  7804. }
  7805. }
  7806.  
  7807. function afficheMenu() {
  7808. menuRac.style.visibility = 'visible';
  7809. }
  7810.  
  7811. function cacheMenu(e) {
  7812. if(menuRac.style.visibility=='hidden') { return; }
  7813. // Position souris
  7814. var ptX = e.clientX;
  7815. var ptY = e.clientY;
  7816. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7817. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7818. var menuRect = menuRac.getBoundingClientRect();
  7819. var icoRect = mainIco.getBoundingClientRect();
  7820. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7821. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7822. menuRac.style.visibility = 'hidden';
  7823. }
  7824. }
  7825.  
  7826. // ajout de l'icône, branchée sur un refresh
  7827. function initUpdateCoordGauche() {
  7828. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7829. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7830. var img = document.createElement('img');
  7831. img.src = URL_MZimg + 'recycl.png'
  7832. img.onclick = function(evt) {
  7833. document.location.href = document.location.href;
  7834. };
  7835. img.title = 'Mise à jour de la localisation';
  7836. img.style.cursor = 'pointer';
  7837. img.style.position = 'absolute';
  7838. img.style.bottom = 0;
  7839. img.style.left = 0;
  7840. div.appendChild(img);
  7841. }
  7842.  
  7843. function do_menu() {
  7844. // met à jour les carac sauvegardées (position, DLA, etc.)
  7845. updateData();
  7846. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7847. initRaccourcis();
  7848. // Ajout bouton de mise à jour coordonnées
  7849. initUpdateCoordGauche();
  7850. }
  7851.  
  7852. /*******************************************************************************
  7853. * This file is part of Mountyzilla. *
  7854. * *
  7855. * Mountyzilla is free software; you can redistribute it and/or modify *
  7856. * it under the terms of the GNU General Public License as published by *
  7857. * the Free Software Foundation; either version 2 of the License, or *
  7858. * (at your option) any later version. *
  7859. * *
  7860. * Mountyzilla is distributed in the hope that it will be useful, *
  7861. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7862. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7863. * GNU General Public License for more details. *
  7864. * *
  7865. * You should have received a copy of the GNU General Public License *
  7866. * along with Mountyzilla; if not, write to the Free Software *
  7867. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7868. *******************************************************************************/
  7869.  
  7870. // x~x vue
  7871.  
  7872. /* TODO
  7873. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7874. * prévoir fix ("delete infos")
  7875. */
  7876.  
  7877. /*--------------------------- Variables Globales -----------------------------*/
  7878.  
  7879. // Infos remplies par des scripts extérieurs
  7880. var listeCDM = [], listeLevels = [];
  7881.  
  7882. // Position actuelle
  7883. var currentPosition=[0,0,0];
  7884.  
  7885. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7886. var porteeVue=[0,0,0,0];
  7887.  
  7888. // Fenêtres déplaçables
  7889. var winCurr = null;
  7890. var offsetX, offsetY;
  7891.  
  7892. // Diplomatie
  7893. var Diplo = {
  7894. Guilde: {},
  7895. Troll: {},
  7896. Monstre: {}
  7897. // .mythiques: uniquement si option activée
  7898. };
  7899. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7900.  
  7901. // Infos tactiques
  7902. var popup;
  7903.  
  7904. // Gère l'affichage en cascade des popups de CdM
  7905. var nbCDM = 0;
  7906.  
  7907. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7908.  
  7909. // Utilisé pour supprimer les monstres "engagés"
  7910. var listeEngages = {};
  7911. var isEngagesComputed = false;
  7912. var cursorOnLink = false; // DEBUG: wtf ?
  7913.  
  7914. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7915. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7916.  
  7917. // Checkboxes de filtrage
  7918. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7919. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7920. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  7921. comboBoxNiveauMin, comboBoxNiveauMax;
  7922.  
  7923. /* Acquisition & Stockage des données de DB */
  7924. const typesAFetcher = {
  7925. 'monstres':1,
  7926. 'trolls':1,
  7927. 'tresors':1,
  7928. 'champignons':1,
  7929. 'lieux':1
  7930. }
  7931. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7932. tr_champignons = {}, tr_lieux = {};
  7933. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7934. nbChampignons = 0, nbLieux = 0;
  7935.  
  7936. function fetchData(type) {
  7937. try {
  7938. var node = document.getElementById('mh_vue_hidden_'+type);
  7939. // this = MZ.global = sandBox de travail de MZ
  7940. // On définit donc des variables MZ-globales
  7941. this['tr_'+type] = node.getElementsByTagName('tr');
  7942. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7943. } catch(e) {
  7944. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7945. }
  7946. }
  7947.  
  7948.  
  7949. /*---------------------------------- DEBUG -----------------------------------*/
  7950. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7951. var x_monstres = tr_monstres;
  7952. var x_trolls = tr_trolls;
  7953. var x_tresors = tr_tresors;
  7954. var x_champis = tr_champignons;
  7955. var x_lieux = tr_lieux;
  7956. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7957.  
  7958.  
  7959. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7960.  
  7961. function positionToString(arr) {
  7962. return arr.join(';');
  7963. }
  7964.  
  7965. function savePosition() {
  7966. // Stocke la position (à jour) de la vue pour les autres scripts
  7967. // DEBUG: Lesquels et pourquoi?
  7968. var pos = getPosition();
  7969. MY_setValue(numTroll+'.position.X',pos[0]);
  7970. MY_setValue(numTroll+'.position.Y',pos[1]);
  7971. MY_setValue(numTroll+'.position.N',pos[2]);
  7972. }
  7973.  
  7974.  
  7975. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7976. /* INFOS :
  7977. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7978. * sont identifiables via leur Name
  7979. * les tables-listings sont identifiables via l'ID du tr conteneur
  7980. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7981. */
  7982.  
  7983. /* [functions] Récup données Utilisateur */
  7984. function getPosition() {
  7985. // Pour rétrocompatibilité
  7986. return currentPosition;
  7987. }
  7988.  
  7989. function getPorteVue() {
  7990. // Pour rétrocompatibilité
  7991. return porteeVue;
  7992. }
  7993.  
  7994. function getVue() {
  7995. // Retourne [vueHpure, vueVpure]
  7996. var vues = getPorteVue();
  7997. return [ vues[0], vues[1] ];
  7998. }
  7999.  
  8000. // Roule 11/03/2016
  8001. /* [functions] Récup données monstres, trolls, etc. */
  8002. function getXxxDistance(xxx, i) {
  8003. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8004. }
  8005. function getXxxPosition(xxx, i) {
  8006. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8007. var l = tds.length;
  8008. return [
  8009. parseInt(tds[l-3].textContent),
  8010. parseInt(tds[l-2].textContent),
  8011. parseInt(tds[l-1].textContent)
  8012. ];
  8013. }
  8014.  
  8015.  
  8016. /* [functions] Récup données monstres */
  8017. function getMonstreDistance(i) {
  8018. return parseInt(tr_monstres[i].cells[0].textContent);
  8019. }
  8020.  
  8021. function getMonstreID(i) {
  8022. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8023. }
  8024.  
  8025. function getMonstreIDByTR(tr) {
  8026. return tr.cells[2].firstChild.nodeValue;
  8027. }
  8028.  
  8029. function getMonstreLevelNode(i) {
  8030. return tr_monstres[i].cells[3];
  8031. }
  8032.  
  8033. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8034. // function getMonstreLevel(i) {
  8035. // if(!isCDMsRetrieved) return -1;
  8036. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8037. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8038. // }
  8039.  
  8040. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8041. if(!isCDMsRetrieved) return false;
  8042. var donneesMonstre = listeCDM[getMonstreID(i)];
  8043. if (!donneesMonstre) return false;
  8044. var nivTxt = donneesMonstre[0];
  8045. // calcul min/max du monstre
  8046. var monstreMin, monstreMax, iPos;
  8047. if (nivTxt.substring(0, 2) == '<=') {
  8048. monstreMin = 0;
  8049. monstreMax = parseInt(nivTxt.substring(2, 99));
  8050. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8051. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8052. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8053. } else {
  8054. monstreMin = monstreMax = parseInt(nivTxt);
  8055. }
  8056. if (limitMin > 0 && monstreMax < limitMin) return true;
  8057. if (limitMax > 0 && monstreMin > limitMax) return true;
  8058. return false;
  8059. }
  8060.  
  8061. function getMonstreNomNode(i) {
  8062. try {
  8063. var td = document.evaluate(
  8064. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8065. tr_monstres[i], null, 9, null
  8066. ).singleNodeValue;
  8067. return td;
  8068. } catch(e) {
  8069. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8070. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8071. }
  8072. }
  8073.  
  8074. function getMonstreNom(i) {
  8075. return getMonstreNomByTR(tr_monstres[i]);
  8076. }
  8077.  
  8078. function getMonstreNomByTR(tr) {
  8079. try {
  8080. var nom = document.evaluate(
  8081. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8082. tr, null, 2, null
  8083. ).stringValue;
  8084. return nom;
  8085. } catch(e) {
  8086. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8087. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8088. }
  8089. }
  8090.  
  8091. function getMonstrePosition(i) {
  8092. var tds = tr_monstres[i].childNodes;
  8093. var l = tds.length;
  8094. return [
  8095. parseInt(tds[l-3].textContent),
  8096. parseInt(tds[l-2].textContent),
  8097. parseInt(tds[l-1].textContent)
  8098. ];
  8099. }
  8100.  
  8101. function appendMonstres(txt) {
  8102. for(var i=1; i<=nbMonstres ; i++)
  8103. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8104. return txt;
  8105. }
  8106.  
  8107. function getMonstres() {
  8108. var vue = getVue();
  8109. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8110. }
  8111.  
  8112. function bddMonstres(start,stop) {
  8113. if(!start) { var start = 1; }
  8114. if(!stop) { var stop = nbMonstres; }
  8115. stop = Math.min(nbMonstres,stop);
  8116. var txt='';
  8117. for(var i=start ; i<=stop ; i++) {
  8118. txt += getMonstreID(i)+';'+
  8119. getMonstreNom(i)+';'+
  8120. positionToString(getMonstrePosition(i))+'\n';
  8121. }
  8122. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8123. }
  8124.  
  8125. /* [functions] Récup données Trolls */
  8126. function getTrollDistance(i) {
  8127. return parseInt(tr_trolls[i].cells[0].textContent);
  8128. }
  8129.  
  8130. var MZ_cache_col_TrollID;
  8131. function getTrollID(i) {
  8132. // Roule 08/03/2017 l'ID de troll peut être colonne 1 ou 2 selon que la case "Menu d'actions contextuelles" est cochée ou pas
  8133. if (MZ_cache_col_TrollID === undefined) {
  8134. if (tr_trolls[0].cells[1].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8135. MZ_cache_col_TrollID = 1;
  8136. } else if (tr_trolls[0].cells[2].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8137. MZ_cache_col_TrollID = 2;
  8138. } else {
  8139. window.console.log('MZ : impossible de trouver la colonne des ID des Trõlls, ' + tr_trolls[0].cells[1].textContent + ' -- ' + tr_trolls[0].cells[2].textContent);
  8140. MZ_cache_col_TrollID = 2;
  8141. }
  8142. }
  8143. // Roule 08/03/2017 protection
  8144. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8145. if (isNaN(iTroll)) return;
  8146. if (iTroll == 0) return;
  8147. return iTroll;
  8148. }
  8149.  
  8150. function getTrollNomNode(i) {
  8151. var isEnvoiOn =
  8152. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  8153. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  8154. }
  8155.  
  8156. function getTrollNivNode(i) {
  8157. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  8158. return tr_trolls[i].cells[4];
  8159. }
  8160.  
  8161. function getTrollGuilde(i) {
  8162. return trim(tr_trolls[i].cells[6].textContent);
  8163. }
  8164.  
  8165. function getTrollGuildeID(i) {
  8166. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  8167. var href;
  8168. try {
  8169. 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"
  8170. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  8171. } catch(e) { // debug pb remonté par Marsak
  8172. window.console.error(traceStack(e, 'getTrollGuildeID')
  8173. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  8174. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8175. return -1;
  8176. }
  8177. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8178. }
  8179. return -1;
  8180. }
  8181.  
  8182. function getTrollPosition(i) {
  8183. var tds = tr_trolls[i].childNodes;
  8184. var l = tds.length;
  8185. return [
  8186. parseInt(tds[l-3].textContent),
  8187. parseInt(tds[l-2].textContent),
  8188. parseInt(tds[l-1].textContent)
  8189. ];
  8190. }
  8191.  
  8192. function bddTrolls() {
  8193. var txt='#DEBUT TROLLS\n'+
  8194. numTroll+';'+positionToString(getPosition())+'\n';
  8195. for(var i=1 ; i<=nbTrolls ; i++) {
  8196. txt += getTrollID(i)+';'+
  8197. positionToString(getTrollPosition(i))+'\n';
  8198. }
  8199. return txt+'#FIN TROLLS';
  8200. }
  8201.  
  8202. /* [functions] Récup données Trésors */
  8203. function getTresorDistance(i) {
  8204. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8205. }
  8206.  
  8207. function getTresorID(i) {
  8208. return trim(tr_tresors[i].cells[2].textContent);
  8209. }
  8210.  
  8211. function getTresorNom(i) {
  8212. // Utilisation de textContent pour régler le "bug de Pollux"
  8213. return trim(tr_tresors[i].cells[3].textContent);
  8214. }
  8215.  
  8216. function getTresorPosition(i) {
  8217. var tds = tr_tresors[i].childNodes;
  8218. var l = tds.length;
  8219. return [
  8220. parseInt(tds[l-3].textContent),
  8221. parseInt(tds[l-2].textContent),
  8222. parseInt(tds[l-1].textContent),
  8223. ];
  8224. }
  8225.  
  8226. function bddTresors(dmin,start,stop) {
  8227. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8228. if(!dmin) { var dmin = 0; }
  8229. if(!start) { var start = 1; }
  8230. if(!stop) { var stop = nbTresors; }
  8231. stop = Math.min(nbTresors,stop);
  8232. var txt='';
  8233. for(var i=start ; i<=stop ; i++) {
  8234. if(getTresorDistance(i)>=dmin) {
  8235. txt += getTresorID(i)+';'+
  8236. getTresorNom(i)+';'+
  8237. positionToString(getTresorPosition(i))+'\n';
  8238. }
  8239. }
  8240. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8241. }
  8242.  
  8243. /* [functions] Récup données Champignons */
  8244. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8245. function getChampignonNom(i) {
  8246. return trim(tr_champignons[i].cells[2].textContent);
  8247. }
  8248.  
  8249. function getChampignonPosition(i) {
  8250. var tds = tr_champignons[i].childNodes;
  8251. var l = tds.length;
  8252. return [
  8253. parseInt(tds[l-3].textContent),
  8254. parseInt(tds[l-2].textContent),
  8255. parseInt(tds[l-1].textContent)
  8256. ];
  8257. }
  8258.  
  8259. function bddChampignons() {
  8260. var txt='';
  8261. for(var i=1 ; i<=nbChampignons ; i++) {
  8262. txt += ';'+ // Les champis n'ont pas de Référence
  8263. getChampignonNom(i)+';'+
  8264. positionToString(getChampignonPosition(i))+'\n';
  8265. }
  8266. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8267. }
  8268.  
  8269. /* [functions] Récup données Lieux */
  8270. function getLieuDistance(i) {
  8271. return parseInt(tr_lieux[i].cells[0].textContent);
  8272. }
  8273.  
  8274. function getLieuID(i) {
  8275. return parseInt(tr_lieux[i].cells[2].textContent);
  8276. }
  8277.  
  8278. function getLieuNom(i) {
  8279. // Conversion ASCII pour éviter les bugs des Vues externes
  8280. return trim(tr_lieux[i].cells[3].textContent);
  8281. }
  8282.  
  8283. function getLieuPosition(i) {
  8284. var tds = tr_lieux[i].childNodes;
  8285. var l = tds.length;
  8286. return [
  8287. parseInt(tds[l-3].textContent),
  8288. parseInt(tds[l-2].textContent),
  8289. parseInt(tds[l-1].textContent)
  8290. ];
  8291. }
  8292.  
  8293. function appendLieux(txt) {
  8294. for(var i = 1; i < nbLieux+1; i++) {
  8295. var tds = x_lieux[i].childNodes;
  8296. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8297. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8298. }
  8299. return txt;
  8300. }
  8301.  
  8302. function getLieux() {
  8303. var vue = getVue();
  8304. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8305. }
  8306.  
  8307. function bddLieux(start,stop) {
  8308. if(!start) { var start = 1; }
  8309. if(!stop) { var stop = nbLieux; }
  8310. stop = Math.min(nbLieux,stop);
  8311. var txt='';
  8312. for(var i=start ; i<=stop ; i++) {
  8313. txt += getLieuID(i)+';'+
  8314. epure(getLieuNom(i))+';'+
  8315. positionToString(getLieuPosition(i))+'\n';
  8316. }
  8317. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8318. }
  8319.  
  8320.  
  8321. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8322.  
  8323. function saveCheckBox(chkbo, pref) {
  8324. // Enregistre et retourne l'état d'une CheckBox
  8325. var etat = chkbo.checked;
  8326. MY_setValue(pref, etat ? 'true' : 'false' );
  8327. return etat;
  8328. }
  8329.  
  8330. function recallCheckBox(chkbox, pref) {
  8331. // Restitue l'état d'une CheckBox
  8332. chkbox.checked = (MY_getValue(pref)=='true');
  8333. }
  8334.  
  8335. function saveComboBox(cbb, pref) {
  8336. // Enregistre et retourne l'état d'une ComboBox
  8337. var etat = cbb.selectedIndex;
  8338. MY_setValue(pref, etat);
  8339. return etat;
  8340. }
  8341.  
  8342. function recallComboBox(cbb, pref) {
  8343. // Restitue l'état d'une ComboBox
  8344. var nb = MY_getValue(pref);
  8345. if(nb) cbb.value = nb;
  8346. return nb;
  8347. }
  8348.  
  8349. function synchroniseFiltres() {
  8350. // Récupération de toutes les options de la vue
  8351. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8352. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8353. if(numBool) {
  8354. debutFiltrage('Monstres');
  8355. }
  8356. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8357. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8358. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8359. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8360. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8361. recallCheckBox(checkBoxIntangibles,'NOINT');
  8362. recallCheckBox(checkBoxGG,'NOGG');
  8363. recallCheckBox(checkBoxCompos,'NOCOMP');
  8364. recallCheckBox(checkBoxBidouilles,'NOBID');
  8365. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8366. recallCheckBox(checkBoxTrou,'NOTROU');
  8367. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8368. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8369. if(MY_getValue('NOINFOEM')!='true')
  8370. recallCheckBox(checkBoxEM,'NOEM');
  8371. }
  8372.  
  8373.  
  8374. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  8375.  
  8376. function getVueScript() {
  8377. try {
  8378. var txt = bddTrolls()+
  8379. bddMonstres()+
  8380. bddChampignons()+
  8381. bddTresors()+
  8382. bddLieux()+
  8383. '#DEBUT ORIGINE\n'+
  8384. getPorteVue()[2]+';'+positionToString(getPosition())+
  8385. '\n#FIN ORIGINE\n';
  8386. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  8387. return txt;
  8388. } catch(e) {
  8389. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  8390. window.console.error(traceStack(e, 'getVueScript'))
  8391. }
  8392. }
  8393.  
  8394. /* [functions] Menu Vue 2D */
  8395. var vue2Ddata = {
  8396. 'Bricol\' Vue': {
  8397. url: URL_bricol_mountyhall + 'vue_form.php',
  8398. paramid: 'vue',
  8399. func: getVueScript,
  8400. extra_params: {
  8401. 'mode': 'vue_SP_Vue2',
  8402. 'screen_width': window.screen.width
  8403. }
  8404. },
  8405. 'Vue du CCM': {
  8406. url: URL_vue_CCM,
  8407. paramid: 'vue',
  8408. func: getVueScript,
  8409. extra_params: {
  8410. 'id': numTroll+';'+positionToString(getPosition())
  8411. }
  8412. },
  8413. 'Vue Gloumfs 2D': {
  8414. url: URL_vue_Gloumfs2D,
  8415. paramid: 'vue_mountyzilla',
  8416. func: getVueScript,
  8417. extra_params: {}
  8418. },
  8419. 'Vue Gloumfs 3D': {
  8420. url: URL_vue_Gloumfs3D,
  8421. paramid: 'vue_mountyzilla',
  8422. func: getVueScript,
  8423. extra_params: {}
  8424. },
  8425. 'Grouky Vue!': {
  8426. url: URL_vue_Grouky,
  8427. paramid: 'vue',
  8428. func: getVueScript,
  8429. extra_params: {
  8430. 'type_vue': 'V5b1'
  8431. }
  8432. },
  8433. /*'DEBUG': {
  8434. url: 'http://weblocal/testeur.php',
  8435. paramid: 'vue',
  8436. func: getVueScript,
  8437. extra_params: {}
  8438. }*/
  8439. };
  8440.  
  8441. function refresh2DViewButton() {
  8442. // = EventListener menu+bouton vue 2D
  8443. var vueext = document.getElementById('selectVue2D').value;
  8444. MY_setValue('VUEEXT',vueext);
  8445. var form = document.getElementById('viewForm');
  8446. form.innerHTML = '';
  8447. form.method = 'post';
  8448. form.action = vue2Ddata[vueext].url;
  8449. form.target = '_blank';
  8450. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8451. for(var key in vue2Ddata[vueext].extra_params) {
  8452. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8453. }
  8454. appendSubmit(form, 'Voir',
  8455. function() {
  8456. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8457. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8458. vue2Ddata[vueext].func();
  8459. }
  8460. );
  8461. }
  8462.  
  8463. function set2DViewSystem() {
  8464. // Initialise le système de vue 2D
  8465. // Recherche du point d'insertion
  8466. try {
  8467. var center = document.evaluate(
  8468. "//h2[@id='titre2']/following-sibling::center",
  8469. document, null, 9, null
  8470. ).singleNodeValue;
  8471. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8472. if (!center) center = document.evaluate(
  8473. "//h2[@id='titre2']/following-sibling::div",
  8474. document, null, 9, null
  8475. ).singleNodeValue;
  8476. } catch(e) {
  8477. avertissement("Erreur d'initialisation du système de vue 2D");
  8478. window.console.error(traceStack(e, 'set2DViewSystem'));
  8479. return;
  8480. }
  8481. // Récupération de la dernière vue utilisée
  8482. var vueext = MY_getValue('VUEEXT');
  8483. if(!vueext || !vue2Ddata[vueext]) {
  8484. // sinon, la vue Bricol'Trolls est employée par défaut
  8485. vueext = 'Bricol\' Vue';
  8486. }
  8487. try {
  8488. // Création du sélecteur de vue externe
  8489. selectVue2D = document.createElement('select');
  8490. selectVue2D.id = 'selectVue2D';
  8491. selectVue2D.className = 'SelectboxV2';
  8492. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  8493. for(var view in vue2Ddata) {
  8494. appendOption(selectVue2D, view, view);
  8495. }
  8496. selectVue2D.value = vueext;
  8497. selectVue2D.onchange = refresh2DViewButton;
  8498. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8499. var form = document.createElement('form');
  8500. form.id = 'viewForm';
  8501. // Insertion du système de vue
  8502. var table = document.createElement('table');
  8503. var tr = appendTr(table);
  8504. var td = appendTd(tr);
  8505. td.appendChild(selectVue2D);
  8506. td = appendTd(tr);
  8507. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8508. td.appendChild(form);
  8509. center.insertBefore(table,center.firstChild);
  8510. insertBr(center.childNodes[1]);
  8511. // Appelle le handler pour initialiser le bouton de submit
  8512. refresh2DViewButton();
  8513. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8514. } catch(e) {
  8515. avertissement("Erreur de traitement du système de vue 2D");
  8516. window.console.error(traceStack(e, 'set2DViewSystem'));
  8517. }
  8518. }
  8519.  
  8520. /* [functions] Tableau d'Infos */
  8521. function initialiseInfos() {
  8522. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8523. var
  8524. infoTab = document.getElementsByName('LimitViewForm')[0].
  8525. getElementsByTagName('table')[0],
  8526. tbody = infoTab.tBodies[0],
  8527. thead = infoTab.createTHead(),
  8528. tr = appendTr(thead,'mh_tdtitre'),
  8529. td = appendTdText(tr,'INFORMATIONS',true),
  8530. span = document.createElement('span');
  8531. // Récupération de la position du joueur
  8532. try {
  8533. var strPos = document.evaluate(
  8534. ".//li/b/text()[contains(.,'X = ')]",
  8535. infoTab, null, 9, null
  8536. ).singleNodeValue.nodeValue;
  8537. // ***INIT GLOBALE*** currentPosition
  8538. currentPosition = getNumbers(strPos);
  8539. debugMZ("retrievePosition(): "+currentPosition);
  8540. } catch(e) {
  8541. // Si on ne trouve pas le "X ="
  8542. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8543. }
  8544. // Récupération des portées (max et limitée) de la vue
  8545. try {
  8546. var
  8547. nodes = document.evaluate(
  8548. ".//li/b/text()[contains(.,'horizontalement') "+
  8549. "or contains(.,'verticalement')]",
  8550. infoTab, null, 7, null
  8551. ),
  8552. array = [];
  8553. for(var i=0 ; i<4 ; i++) {
  8554. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8555. }
  8556. // ***INIT GLOBALE*** porteeVue
  8557. porteeVue = array;
  8558. } catch(e) {
  8559. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8560. }
  8561.  
  8562. infoTab.id = 'infoTab'; // Pour scripts externes
  8563. tbody.id = 'corpsInfoTab';
  8564. tbody.rows[0].cells[0].colSpan = 2;
  8565. td.colSpan = 3;
  8566. td.onmouseover = function() {
  8567. this.style.cursor = 'pointer';
  8568. this.className = 'mh_tdpage';
  8569. };
  8570. td.onmouseout = function() {
  8571. this.className = 'mh_tdtitre';
  8572. };
  8573. td.onclick = function() {
  8574. toggleTableauInfos(false);
  8575. };
  8576. span.id = 'msgInfoTab';
  8577. span.style.display = 'none';
  8578. appendText(
  8579. span,
  8580. ' => Position : X = '+currentPosition[0]+
  8581. ', Y = '+currentPosition[1]+
  8582. ', N = '+currentPosition[2]+
  8583. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8584. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8585. true
  8586. );
  8587. td.appendChild(span);
  8588. tr = appendTr(tbody,'mh_tdpage');
  8589. td = appendTdText(tr,'EFFACER : ',true);
  8590. td.align = 'center';
  8591. td.className = 'mh_tdtitre';
  8592. td.width = 100;
  8593. td = appendTdCenter(tr,2);
  8594. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8595. checkBoxGG = appendCheckBoxSpan(
  8596. td,'delgg',filtreTresors," Les GG'"
  8597. ).firstChild;
  8598. checkBoxCompos = appendCheckBoxSpan(
  8599. td,'delcomp',filtreTresors,' Les Compos'
  8600. ).firstChild;
  8601. checkBoxBidouilles = appendCheckBoxSpan(
  8602. td,'delbid',filtreTresors,' Les Bidouilles'
  8603. ).firstChild;
  8604. checkBoxIntangibles = appendCheckBoxSpan(
  8605. td,'delint',filtreTrolls,' Les Intangibles'
  8606. ).firstChild;
  8607. checkBoxGowapsA = appendCheckBoxSpan(
  8608. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  8609. ).firstChild;
  8610. checkBoxGowapsS = appendCheckBoxSpan(
  8611. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  8612. ).firstChild;
  8613. checkBoxEngages = appendCheckBoxSpan(
  8614. td,'delengage',filtreMonstres,' Les Engagés'
  8615. ).firstChild;
  8616. checkBoxLevels = appendCheckBoxSpan(
  8617. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8618. ).firstChild;
  8619. checkBoxDiplo = appendCheckBoxSpan(
  8620. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8621. ).firstChild;
  8622. checkBoxTrou = appendCheckBoxSpan(
  8623. td,'deltrou',filtreLieux,' Les Trous'
  8624. ).firstChild;
  8625. checkBoxMythiques = appendCheckBoxSpan(
  8626. td,'delmyth',filtreMonstres,' Les Mythiques'
  8627. ).firstChild;
  8628. if(MY_getValue('NOINFOEM')!='true') {
  8629. checkBoxEM = appendCheckBoxSpan(
  8630. td,'delem',filtreMonstres,' Les Composants EM'
  8631. ).firstChild;
  8632. }
  8633. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8634. td,'deltres',filtreTresors,' Les Trésors non libres'
  8635. ).firstChild;
  8636. checkBoxTactique = appendCheckBoxSpan(
  8637. td,'deltactique',updateTactique,' Les Infos tactiques'
  8638. ).firstChild;
  8639. if(MY_getValue('INFOPLIE')) {
  8640. toggleTableauInfos(true);
  8641. }
  8642. }
  8643.  
  8644. function toggleTableauInfos(firstRun) {
  8645. var
  8646. msg = document.getElementById('msgInfoTab'),
  8647. corps = document.getElementById('corpsInfoTab'),
  8648. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8649. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8650. if(!firstRun) {
  8651. infoplie = !infoplie;
  8652. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8653. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8654. }
  8655. if(infoplie) {
  8656. msg.style.display = '';
  8657. corps.style.display = 'none';
  8658. } else {
  8659. msg.style.display = 'none';
  8660. corps.style.display = '';
  8661. }
  8662. }
  8663.  
  8664. /* [functions] Filtres */
  8665. function prepareFiltrage(ref,width) {
  8666. // = Initialise le filtre 'ref'
  8667. try {
  8668. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8669. } catch(e) {
  8670. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8671. return false;
  8672. }
  8673. if(width) { tdTitre.width = width; }
  8674. // Ajout du tr de Filtrage (masqué)
  8675. var tbody = tdTitre.parentNode.parentNode;
  8676. var tr = appendTr(tbody,'mh_tdpage');
  8677. tr.style.display = 'none';
  8678. tr.id = 'trFiltre'+ref;
  8679. var td = appendTd(tr);
  8680. td.colSpan = 5;
  8681. // Ajout du bouton de gestion de Filtrage
  8682. var tdBtn = insertTd(tdTitre.nextSibling);
  8683. tdBtn.id = 'tdInsert'+ref;
  8684. var btn = appendButton(tdBtn,'Filtrer');
  8685. btn.id = 'btnFiltre'+ref;
  8686. btn.onclick = function() {
  8687. debutFiltrage(ref)
  8688. };
  8689. return td;
  8690. }
  8691.  
  8692. function debutFiltrage(ref) {
  8693. // = Handler de début de filtrage (filtre 'ref')
  8694. document.getElementById('trFiltre'+ref).style.display = '';
  8695. var btn = document.getElementById('btnFiltre'+ref);
  8696. btn.value = 'Annuler Filtre';
  8697. btn.onclick = function() {
  8698. finFiltrage(ref);
  8699. };
  8700. }
  8701.  
  8702. function finFiltrage(ref) {
  8703. // = Handler de fin de filtrage (filtre 'ref')
  8704. /* On réassigne le bouton 'Filtrer' */
  8705. document.getElementById('trFiltre'+ref).style.display = 'none';
  8706. var btn = document.getElementById('btnFiltre'+ref);
  8707. btn.value = 'Filtrer';
  8708. btn.onclick = function() {
  8709. debutFiltrage(ref);
  8710. };
  8711. /* Réinitialisation filtres */
  8712. document.getElementById('str'+ref).value = '';
  8713. switch(ref) {
  8714. case 'Monstres':
  8715. document.getElementById('nivMinMonstres').value = 0;
  8716. document.getElementById('nivMaxMonstres').value = 0;
  8717. break;
  8718. case 'Trolls':
  8719. document.getElementById('strGuildes').value = '';
  8720. }
  8721. /* Nettoyage (=lance le filtre) */
  8722. // Ici this = MZ.global = sandBox de travail de MZ
  8723. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  8724. //this['filtre'+ref]();
  8725. switch (ref) {
  8726. case 'Monstres':
  8727. filtreMonstres();
  8728. break;
  8729. case 'Trolls':
  8730. filtreTrolls();
  8731. break;
  8732. case 'Tresors':
  8733. filtreTresors();
  8734. break;
  8735. case 'Lieux':
  8736. filtreLieux();
  8737. break;
  8738. default:
  8739. window.console.log('cas incongru dans finFiltrage : ' + ref);
  8740. break;
  8741. }
  8742. }
  8743.  
  8744. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  8745. var bouton = appendButton(td,nomBouton,onClick);
  8746. appendText(td,'\u00a0');
  8747. var textbox = appendTextbox(td,'text',id,15,30);
  8748. textbox.onkeypress = function(event) {
  8749. try {
  8750. if(event.keyCode==13) {
  8751. event.preventDefault();
  8752. bouton.click();
  8753. }
  8754. }
  8755. catch(e){
  8756. window.alert(e)
  8757. }
  8758. };
  8759. }
  8760.  
  8761. function ajoutFiltreMenu(tr,id,onChange) {
  8762. var select = document.createElement('select');
  8763. select.id = id;
  8764. select.onchange = onChange;
  8765. appendOption(select,0,'Aucun');
  8766. for(var i=1 ; i<=60 ; i++) {
  8767. appendOption(select,i,i);
  8768. }
  8769. tr.appendChild(select);
  8770. return select;
  8771. }
  8772.  
  8773. function ajoutDesFiltres() {
  8774. /* Monstres */
  8775. var td = prepareFiltrage('Monstres',120);
  8776. if(td) {
  8777. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  8778. appendText(td,'\u00a0\u00a0\u00a0');
  8779. appendText(td,'Niveau Min: ');
  8780. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  8781. appendText(td,'\u00a0');
  8782. appendText(td,'Niveau Max: ');
  8783. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  8784. }
  8785. /* Trõlls */
  8786. td = prepareFiltrage('Trolls',50);
  8787. if(td) {
  8788. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  8789. appendText(td,'\u00a0\u00a0\u00a0');
  8790. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  8791. }
  8792. /* Trésors */
  8793. td = prepareFiltrage('Tresors',55);
  8794. if(td) {
  8795. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  8796. }
  8797. /* Lieux */
  8798. td = prepareFiltrage('Lieux',40);
  8799. if(td) {
  8800. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  8801. }
  8802. }
  8803.  
  8804. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  8805.  
  8806. /* [functions] Affichage de la colonne des niveaux */
  8807. function insertLevelColumn() {
  8808. // Déclenché si bascule vers affichage des niveaux des mobs
  8809. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8810. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  8811. td.width = 25;
  8812. for(var i=1 ; i<=nbMonstres ; i++) {
  8813. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8814. td = insertTdText(getMonstreLevelNode(i), '-');
  8815. td.onclick = function() {
  8816. basculeCDM(
  8817. getMonstreNomByTR(this.parentNode),
  8818. getMonstreIDByTR(this.parentNode)
  8819. );
  8820. };
  8821. td.onmouseover = function() {
  8822. this.style.cursor = 'pointer';
  8823. this.className = 'mh_tdtitre';
  8824. };
  8825. td.onmouseout = function() {
  8826. if(this.parentNode.diploActive=='oui') {
  8827. this.className = '';
  8828. } else {
  8829. this.className = 'mh_tdpage';
  8830. }
  8831. };
  8832. td.style = 'font-weight:bold;text-align:center;';
  8833. if(isCDMsRetrieved) {
  8834. // Rappel des niveaux si mémorisés
  8835. td.innerHTML = listeLevels[i];
  8836. }
  8837. }
  8838. }
  8839.  
  8840. function toggleLevelColumn() {
  8841. // = Handler checkBox noLevel
  8842. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8843. insertLevelColumn();
  8844. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8845. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8846. for(var i=0 ; i<=nbMonstres ; i++) {
  8847. if(isCDMsRetrieved) {
  8848. // Mémorisation des niveaux pour rappel éventuel
  8849. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8850. }
  8851. // Suppression du td Niveau
  8852. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8853. }
  8854. }
  8855. }
  8856.  
  8857. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8858. function basculeCDM(nom,id) {
  8859. // = Bascule l'affichage des popups CdM
  8860. if(listeCDM[id]) {
  8861. if(!document.getElementById('popupCDM'+id)) {
  8862. afficherCDM(nom, id);
  8863. } else {
  8864. cacherPopupCDM('popupCDM'+id);
  8865. }
  8866. }
  8867. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8868. }
  8869.  
  8870. function cacherPopupCDM(titre) {
  8871. var popup = document.getElementById(titre);
  8872. popup.parentNode.removeChild(popup);
  8873. }
  8874.  
  8875. /* DEBUG: Section à mettre à jour */
  8876. var selectionFunction;
  8877.  
  8878. function startDrag(evt) {
  8879. winCurr = this.parentNode;
  8880. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8881. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8882. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8883. selectionFunction = document.body.style.MozUserSelect;
  8884. document.body.style.MozUserSelect = 'none';
  8885. winCurr.style.MozUserSelect = 'none';
  8886. return false;
  8887. }
  8888.  
  8889. function stopDrag(evt) {
  8890. winCurr.style.MozUserSelect = selectionFunction;
  8891. document.body.style.MozUserSelect = selectionFunction;
  8892. winCurr = null;
  8893. }
  8894.  
  8895. function drag(evt) {
  8896. if(winCurr==null) { return; }
  8897. evt = evt || window.event;
  8898. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8899. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8900. return false;
  8901. }
  8902. /* FIN DEBUG */
  8903. document.onmousemove = drag;
  8904.  
  8905. function afficherCDM(nom,id) {
  8906. // Crée la table de CdM du mob n° id
  8907. var donneesMonstre = listeCDM[id];
  8908. /* Début création table */
  8909. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8910. table.id = 'popupCDM'+id;
  8911. table.style =
  8912. 'position:fixed;'+
  8913. 'z-index:1;'+
  8914. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8915. 'left:'+(window.innerWidth-365)+'px;'+
  8916. 'width:300px;'+
  8917. 'height:200px;';
  8918. /* Ajout du titre avec gestion Drag & Drop */
  8919. var tr = table.firstChild;
  8920. tr.style.cursor = 'move';
  8921. tr.onmousedown = startDrag;
  8922. tr.onmouseup = stopDrag;
  8923. /* Ajout du bouton "Fermer" */
  8924. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8925. tr.onmouseover = function() {
  8926. this.style.cursor = 'pointer';
  8927. this.className = 'mh_tdpage';
  8928. };
  8929. tr.onmouseout = function() {
  8930. this.className = 'mh_tdtitre';
  8931. };
  8932. tr.idcdm = id;
  8933. tr.onclick = function() {
  8934. cacherPopupCDM('popupCDM'+this.idcdm);
  8935. this.className = 'mh_tdtitre';
  8936. };
  8937. td = appendTdText(tr,'Fermer',true);
  8938. td.colSpan = 2;
  8939. td.style = 'text-align:center;';
  8940. nbCDM++;
  8941. /* Fin création table & Affichage */
  8942. document.body.appendChild(table);
  8943. }
  8944.  
  8945. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8946. function initPopupVue() {
  8947. popup = document.createElement('div');
  8948. popup.id = 'popup';
  8949. popup.className = 'mh_textbox';
  8950. popup.style =
  8951. 'position: absolute;'+
  8952. 'border: 1px solid #000000;'+
  8953. 'visibility: hidden;'+
  8954. 'display: inline;'+
  8955. 'z-index: 3;'+
  8956. 'max-width: 400px;';
  8957. document.body.appendChild(popup);
  8958. }
  8959.  
  8960. /* [functions] Récupération / Computation des Infos Tactiques */
  8961. // TODO à revoir
  8962. function retireMarquage(nom) {
  8963. var i = nom.indexOf(']');
  8964. switch(i) {
  8965. case -1:
  8966. case nom.length-1:
  8967. return nom;
  8968. default:
  8969. return nom.slice(0,i+1);
  8970. }
  8971. }
  8972.  
  8973. function showPopupError(sHTML) {
  8974. window.console.log('[MZ] affichage PopupError ' + sHTML);
  8975. var divpopup = document.createElement('div');
  8976. divpopup.id = 'divpopup';
  8977. divpopup.style =
  8978. 'position: fixed;'+
  8979. 'border: 3px solid #000000;'+
  8980. 'top: 300px;left: 10px;'+
  8981. 'background-color: red;'+
  8982. 'color: white;'+
  8983. 'font-size: xx-large;'+
  8984. 'z-index: 200;';
  8985. divpopup.innerHTML = sHTML;
  8986. var divcroix = document.createElement('div');
  8987. divcroix.style =
  8988. 'position: absolute;'+
  8989. 'top: 0;right: 0;'+
  8990. 'color: inherit;'+
  8991. 'font-size: inherit;'+
  8992. 'cursor: pointer;'+
  8993. 'z-index: 201;';
  8994. divcroix.innerHTML = "X";
  8995. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8996. document.body.appendChild(divpopup);
  8997. divpopup.appendChild(divcroix);
  8998. }
  8999.  
  9000. function retrieveCDMs() {
  9001. // Récupère les CdM disponibles dans la BDD
  9002. // Lancé uniquement sur toggleLevelColumn
  9003. if(checkBoxLevels.checked) { return; }
  9004. var str = '';
  9005. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9006. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9007. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9008. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9009. for(var i=1 ; i<=cdmMax ; i++) {
  9010. var nomMonstre = retireMarquage(getMonstreNom(i));
  9011. if(nomMonstre.indexOf(']') != -1) {
  9012. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9013. }
  9014. // *** WARNING : PROXY RATIBUS ***
  9015. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9016. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9017. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9018. )+'&';
  9019. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9020. FF_XMLHttpRequest({
  9021. method: 'POST',
  9022. url: URL_MZinfoMonstre,
  9023. headers : {
  9024. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9025. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9026. 'Content-type':'application/x-www-form-urlencoded'
  9027. },
  9028. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9029. onload: function(responseDetails) {
  9030. try {
  9031. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9032. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9033. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9034. '" target="raistlin">Mountyzilla - https<br />'+
  9035. 'Tu dois accepter le certificat de Raistlin<br />'+
  9036. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9037. ' « Confirmer l\'exception de sécurité »</a>');
  9038. return;
  9039. }
  9040. var texte = responseDetails.responseText;
  9041. var lines = texte.split('\n');
  9042. if(lines.length==0) { return; }
  9043. var begin2, end2, index;
  9044. for(var j=0 ; j<lines.length ; j++) {
  9045. var infos = lines[j].split(';');
  9046. if(infos.length<4) { continue; }
  9047. var idMonstre=infos[0];
  9048. var isCDM = infos[1];
  9049. index = parseInt(infos[2]);
  9050. var level = infos[3];
  9051. infos = infos.slice(3);
  9052. if(begin2==null) { begin2 = index; }
  9053. end2 = index;
  9054. listeCDM[idMonstre] = infos;
  9055. if(isCDM==1) {
  9056. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9057. } else {
  9058. getMonstreLevelNode(index).innerHTML = level;
  9059. }
  9060. }
  9061. computeMission(begin2,end2);
  9062. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9063. } catch(e) {
  9064. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9065. }
  9066. }
  9067. });
  9068. str = '';
  9069. begin = i+1;
  9070. }
  9071. }
  9072. isCDMsRetrieved=true;
  9073. }
  9074.  
  9075. function computeMission(begin,end) {
  9076. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9077. computeVLC(begin,end);
  9078. if(!begin) begin=1;
  9079. if(!end) end=nbMonstres;
  9080. var str = MY_getValue(numTroll+'.MISSIONS');
  9081. if(!str) { return; }
  9082. var urlImg = URL_MZimg+'mission.png';
  9083. var obMissions = JSON.parse(str);
  9084. for(var i=end ; i>=begin ; i--) {
  9085. var mess = '';
  9086. for(var num in obMissions) {
  9087. var mobMission = false;
  9088. switch(obMissions[num].type) {
  9089. case 'Race':
  9090. var race = epure(obMissions[num].race.toLowerCase());
  9091. var nom = epure(getMonstreNom(i).toLowerCase());
  9092. if(nom.indexOf(race)!=-1) {
  9093. mobMission = true;
  9094. }
  9095. break;
  9096. case 'Niveau':
  9097. var donneesMonstre = listeCDM[getMonstreID(i)];
  9098. if(donneesMonstre) {
  9099. var nivMob = Number(donneesMonstre[0]);
  9100. var nivMimi = Number(obMissions[num].niveau),
  9101. mod = obMissions[num].mod;
  9102. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9103. || (isNaN(mod) && nivMob>=nivMimi)) {
  9104. mobMission = true;
  9105. }
  9106. }
  9107. break;
  9108. case 'Famille':
  9109. var donneesMonstre = listeCDM[getMonstreID(i)];
  9110. if(donneesMonstre) {
  9111. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  9112. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9113. if(familleMob.indexOf(familleMimi)!=-1) {
  9114. mobMission = true;
  9115. }
  9116. }
  9117. break;
  9118. case 'Pouvoir':
  9119. var donneesMonstre = listeCDM[getMonstreID(i)];
  9120. if(donneesMonstre) {
  9121. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9122. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9123. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9124. mobMission = true;
  9125. }
  9126. }
  9127. }
  9128. if(mobMission) {
  9129. mess += mess ? '\n\n' : '';
  9130. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9131. }
  9132. }
  9133. if(mess) {
  9134. var td = getMonstreNomNode(i);
  9135. appendText(td,' ');
  9136. td.appendChild(createImage(urlImg,mess));
  9137. }
  9138. }
  9139. }
  9140.  
  9141. function computeVLC(begin,end) {
  9142. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9143. computeTactique(begin,end);
  9144. if(!begin) begin=1;
  9145. if(!end) end=nbMonstres;
  9146. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9147. if(!cache)
  9148. return false;
  9149. var urlImg = URL_MZimg + "oeil.png";
  9150. for(var i = end; i >= begin;i--)
  9151. {
  9152. var id = getMonstreID(i);
  9153. var donneesMonstre = listeCDM[id];
  9154. if(donneesMonstre && donneesMonstre.length>12)
  9155. {
  9156. if(donneesMonstre[12]==1)
  9157. {
  9158. var td = getMonstreNomNode(i);
  9159. td.appendChild(document.createTextNode(" "));
  9160. td.appendChild(createImage(urlImg, "Voit le caché"));
  9161. }
  9162. }
  9163. }
  9164. }
  9165.  
  9166. function computeTactique(begin, end) {
  9167. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9168. try {
  9169. if(!begin) begin = 1;
  9170. if(!end) end = nbMonstres;
  9171. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9172. if(noTactique || !isProfilActif()) return;
  9173. for(var j=end ; j>=begin ; j--) {
  9174. var id = getMonstreID(j);
  9175. var nom = getMonstreNom(j);
  9176. var donneesMonstre = listeCDM[id];
  9177. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9178. var td = getMonstreNomNode(j);
  9179. appendText(td,' ');
  9180. td.appendChild(
  9181. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9182. );
  9183. }
  9184. }
  9185. }
  9186. catch(e) {
  9187. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  9188. }
  9189. filtreMonstres();
  9190. }
  9191.  
  9192. function updateTactique() {
  9193. // = Handler checkBox noTactique
  9194. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9195. if(!isCDMsRetrieved) return;
  9196. if(noTactique) {
  9197. for(var i=nbMonstres ; i>0 ; i--) {
  9198. var tr = getMonstreNomNode(i);
  9199. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9200. tr, null, 9, null).singleNodeValue;
  9201. if(img) {
  9202. img.parentNode.removeChild(img.previousSibling);
  9203. img.parentNode.removeChild(img);
  9204. }
  9205. }
  9206. }
  9207. else
  9208. computeTactique();
  9209. }
  9210.  
  9211. function filtreMonstres() {
  9212. // = Handler universel pour les fonctions liées aux monstres
  9213. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9214. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9215. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9216. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9217. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9218. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9219. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9220. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9221. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9222. // old/new : détermine s'il faut ou non nettoyer les tr
  9223. var oldNOEM = true, noEM = true;
  9224. if(MY_getValue('NOINFOEM')!='true') {
  9225. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9226. }
  9227. // Filtrage par nom
  9228. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9229. // Génère la liste des mobs engagés (si filtrés)
  9230. if(noEngages && !isEngagesComputed) {
  9231. for(var i=nbTrolls ; i>0 ; i--) {
  9232. var pos = getTrollPosition(i);
  9233. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9234. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9235. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9236. }
  9237. isEngagesComputed = true;
  9238. }
  9239. /*** FILTRAGE ***/
  9240. /* À computer :
  9241. * - EM (nom suffit)
  9242. * - Enchant (nom suffit)
  9243. * - Mission (nécessite CdM)
  9244. * - mob VlC (nécessite CdM)
  9245. * Sans computation :
  9246. * - Gowap ? engagé ?
  9247. */
  9248. for(var i=nbMonstres ; i>0 ; i--) {
  9249. var pos = getMonstrePosition(i);
  9250. var nom = getMonstreNom(i).toLowerCase();
  9251. if(noEM!=oldNOEM) {
  9252. if(noEM) {
  9253. // Si noEM passe de false à true, on nettoie les td "Nom"
  9254. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9255. var tr = getMonstreNomNode(i);
  9256. while(tr.childNodes.length>1) {
  9257. tr.removeChild(tr.childNodes[1]);
  9258. }
  9259. } else {
  9260. var tr = getMonstreNomNode(i);
  9261. var TypeMonstre=getEM(nom);
  9262. if(TypeMonstre!='') {
  9263. var infosCompo=compoMobEM(TypeMonstre);
  9264. if(infosCompo.length>0) {
  9265. tr.appendChild(document.createTextNode(' '));
  9266. tr.appendChild(createImage(urlImg, infosCompo));
  9267. }
  9268. }
  9269. }
  9270. }
  9271. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  9272. var texte = getInfoEnchantementFromMonstre(nom);
  9273. if(texte!='') {
  9274. var td = getMonstreNomNode(i);
  9275. td.appendChild(document.createTextNode(' '));
  9276. td.appendChild(createImage(urlEnchantImg, texte));
  9277. }
  9278. }
  9279. tr_monstres[i].style.display = (
  9280. noGowapsS &&
  9281. nom.indexOf('gowap sauvage')!=-1 &&
  9282. getMonstreDistance(i)>1
  9283. ) || (
  9284. noGowapsA &&
  9285. nom.indexOf('gowap apprivoisé')!=-1 &&
  9286. getMonstreDistance(i)>1
  9287. ) || (
  9288. noEngages &&
  9289. getMonstreDistance(i)!=0 &&
  9290. listeEngages[pos[0]] &&
  9291. listeEngages[pos[0]][pos[1]] &&
  9292. listeEngages[pos[0]][pos[1]][pos[2]]
  9293. ) || (
  9294. strMonstre!='' &&
  9295. nom.indexOf(strMonstre)==-1
  9296. ) || (
  9297. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  9298. getMonstreDistance(i)>1 &&
  9299. nom.toLowerCase().indexOf("kilamo")==-1
  9300. ) ? 'none' : '';
  9301. }
  9302. if(MY_getValue('NOINFOEM')!='true') {
  9303. if(noEM != oldNOEM) {
  9304. if(noEM && isCDMsRetrieved) computeMission();
  9305. }
  9306. oldNOEM = noEM;
  9307. }
  9308. needComputeEnchantement = false;
  9309. }
  9310.  
  9311.  
  9312. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  9313.  
  9314. function filtreTrolls() {
  9315. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  9316. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  9317. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  9318. for(var i=1 ; i<=nbTrolls ; i++) {
  9319. tr_trolls[i].style.display = (
  9320. noIntangibles &&
  9321. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  9322. ) || (
  9323. strTroll!='' &&
  9324. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  9325. ) || (
  9326. strGuilde!='' &&
  9327. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  9328. ) ? 'none' : '';
  9329. }
  9330. }
  9331.  
  9332. /* [functions] Bulle PX Trolls */
  9333. var bulle;
  9334.  
  9335. function initPXTroll() {
  9336. bulle = document.createElement('div');
  9337. bulle.id = 'bulle';
  9338. bulle.className = 'mh_textbox';
  9339. bulle.style =
  9340. 'position: absolute;'+
  9341. 'border: 1px solid #000000;'+
  9342. 'visibility: hidden;'+
  9343. 'display: inline;'+
  9344. 'z-index: 2;';
  9345. document.body.appendChild(bulle);
  9346.  
  9347. for(var i=nbTrolls ; i>0 ; i--) {
  9348. var td_niv = getTrollNivNode(i);
  9349. td_niv.onmouseover = showPXTroll;
  9350. td_niv.onmouseout = hidePXTroll;
  9351. }
  9352. }
  9353.  
  9354. function showPXTroll(evt) {
  9355. var lvl = this.firstChild.nodeValue;
  9356. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  9357. bulle.style.left = evt.pageX+15+'px';
  9358. bulle.style.top = evt.pageY+'px';
  9359. bulle.style.visibility = 'visible';
  9360. }
  9361.  
  9362. function hidePXTroll() {
  9363. bulle.style.visibility = 'hidden';
  9364. }
  9365.  
  9366. /* [functions] Envoi PX / MP */
  9367. function putBoutonPXMP() {
  9368. // Bouton d'initialisation du mode Envoi
  9369. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  9370. var td = document.getElementById('tdInsertTrolls');
  9371. if(!td) { return; }
  9372. td.width = 100;
  9373. td = insertTd(td.nextSibling);
  9374. td.style.verticalAlign = 'top';
  9375. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  9376. bouton.id = 'btnEnvoi';
  9377. }
  9378.  
  9379. function prepareEnvoi() {
  9380. // = 1er Handler du bouton d'envoi
  9381. /* Ajout de la colonne des CheckBoxes */
  9382. var td = insertTdText(getTrollNomNode(0),'');
  9383. td.width = 5;
  9384. for(var i=nbTrolls ; i>0 ; i--) {
  9385. td = insertTd(getTrollNomNode(i));
  9386. appendCheckBox(td,'envoi'+i);
  9387. }
  9388. /* Ajout du radio de choix PX ou MP */
  9389. var btnEnvoi = document.getElementById('btnEnvoi');
  9390. if(!btnEnvoi) { return; }
  9391. var tdEnvoi = btnEnvoi.parentNode;
  9392. appendText(tdEnvoi,' ');
  9393. var span = document.createElement('span');
  9394. span.style.whiteSpace = 'nowrap';
  9395. var radioElt = document.createElement('input');
  9396. radioElt.type = 'radio';
  9397. radioElt.name = 'envoiPXMP';
  9398. radioElt.id = 'radioPX';
  9399. span.appendChild(radioElt);
  9400. appendText(span,' des PX ');
  9401. radioElt = document.createElement('input');
  9402. radioElt.type = 'radio';
  9403. radioElt.name = 'envoiPXMP';
  9404. radioElt.checked = true;
  9405. span.appendChild(radioElt);
  9406. appendText(span,' un MP');
  9407. tdEnvoi.appendChild(span);
  9408. /* Insertion du bouton Annuler */
  9409. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  9410. /* Modification de l'effet du bouton Envoi */
  9411. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  9412. }
  9413.  
  9414. function annuleEnvoi() {
  9415. // = Handler bouton Annuler
  9416. /* Nettoyage du td du bouton Envoi */
  9417. var btnEnvoi = document.getElementById('btnEnvoi');
  9418. var tdEnvoi = btnEnvoi.parentNode;
  9419. while(tdEnvoi.firstChild) {
  9420. tdEnvoi.removeChild(tdEnvoi.firstChild);
  9421. }
  9422. /* Retour à l'effet de base du bouton Envoi */
  9423. btnEnvoi.onclick = prepareEnvoi;
  9424. tdEnvoi.appendChild(btnEnvoi);
  9425. /* Suppression CheckBoxes */
  9426. for(var i=nbTrolls ; i>=0 ; i--) {
  9427. var td = getTrollNomNode(i);
  9428. td.parentNode.removeChild(td);
  9429. }
  9430. }
  9431.  
  9432. function effectueEnvoi() {
  9433. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9434. var str='';
  9435. var errID = false;
  9436. for(var i=nbTrolls ; i>0 ; i--) {
  9437. var chb = document.getElementById('envoi'+i);
  9438. if(chb.checked) {
  9439. var idTroll = getTrollID(i);
  9440. if (idTroll == undefined) {
  9441. errID = true;
  9442. } else {
  9443. str += (str ? ',' : '') + idTroll;
  9444. }
  9445. }
  9446. }
  9447. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  9448. var PXchecked = document.getElementById('radioPX').checked;
  9449. if(PXchecked) {
  9450. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9451. } else {
  9452. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9453. }
  9454. }
  9455.  
  9456. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9457.  
  9458. function filtreTresors() {
  9459. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9460. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9461. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9462. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9463. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9464. if(noEngages && !isEngagesComputed) {
  9465. for(var i=nbTrolls ; i>0 ; i--) {
  9466. var pos = getTrollPosition(i);
  9467. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9468. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9469. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9470. }
  9471. isEngagesComputed = true;
  9472. }
  9473. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9474. for(var i=nbTresors ; i>0 ; i--) {
  9475. var nom = getTresorNom(i);
  9476. var pos = getTresorPosition(i);
  9477. tr_tresors[i].style.display = (
  9478. noGG &&
  9479. nom.indexOf('Gigots de Gob')!=-1
  9480. ) || (
  9481. noCompos &&
  9482. nom.indexOf('Composant')!=-1
  9483. ) || (
  9484. noEngages &&
  9485. listeEngages[pos[2]] &&
  9486. listeEngages[pos[2]][pos[1]] &&
  9487. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9488. getTresorDistance(i)>0
  9489. ) || (
  9490. strTresor!='' &&
  9491. nom.toLowerCase().indexOf(strTresor)==-1
  9492. ) || (
  9493. noBidouilles &&
  9494. nom.indexOf('Bidouille')!=-1
  9495. ) ? 'none' : '';
  9496. }
  9497. }
  9498.  
  9499.  
  9500. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9501.  
  9502. function filtreLieux() {
  9503. // += Handler checkbox trous
  9504. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9505. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9506. for(var i=nbLieux ; i>0 ; i--) {
  9507. tr_lieux[i].style.display = (
  9508. strLieu &&
  9509. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9510. ) || (
  9511. noTrou &&
  9512. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9513. getLieuDistance(i)>1
  9514. ) ? 'none' : '';
  9515. }
  9516. }
  9517.  
  9518.  
  9519. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9520.  
  9521. function refreshDiplo() {
  9522. MY_setValue(numTroll+'.diplo.off',
  9523. checkBoxDiplo.checked?'true':'false'
  9524. );
  9525. if(isDiploRaw) { computeDiplo(); }
  9526. appliqueDiplo();
  9527. }
  9528.  
  9529. function computeDiplo() {
  9530. // On extrait les données de couleur et on les stocke par id
  9531. // Ordre de préséance :
  9532. // source Guilde < source Perso
  9533. // guilde cible < troll cible
  9534. /* Diplo de Guilde */
  9535. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9536. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9537. if(diploGuilde && diploGuilde.isOn=='true') {
  9538. // Guilde perso
  9539. if(diploGuilde.guilde) {
  9540. Diplo.Guilde[diploGuilde.guilde.id] = {
  9541. couleur: diploGuilde.guilde.couleur,
  9542. titre: 'Ma Guilde'
  9543. };
  9544. }
  9545. // Guildes/Trolls A/E
  9546. for(var AE in {Amis:0,Ennemis:0}) {
  9547. for(var i=0 ; i<5 ; i++) {
  9548. if(diploGuilde[AE+i]) {
  9549. for(var type in {Guilde:0,Troll:0}) {
  9550. var liste = diploGuilde[AE+i][type].split(';');
  9551. for(var j=liste.length-2 ; j>=0 ; j--) {
  9552. Diplo[type][liste[j]] = {
  9553. couleur: diploGuilde[AE+i].couleur,
  9554. titre: diploGuilde[AE+i].titre
  9555. };
  9556. }
  9557. }
  9558. }
  9559. }
  9560. }
  9561. }
  9562. /* Diplo Perso */
  9563. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9564. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9565. if(diploPerso && diploPerso.isOn=='true') {
  9566. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9567. for(var id in diploPerso[type]) {
  9568. Diplo[type][id] = diploPerso[type][id];
  9569. }
  9570. }
  9571. }
  9572. if(diploPerso.mythiques) {
  9573. Diplo.mythiques = diploPerso.mythiques;
  9574. }
  9575. isDiploRaw = false;
  9576. }
  9577.  
  9578. function appliqueDiplo() {
  9579. var aAppliquer = Diplo;
  9580. if(checkBoxDiplo.checked) {
  9581. // Pour retour à l'affichage basique sur désactivation de la diplo
  9582. aAppliquer = {
  9583. Guilde: {},
  9584. Troll: {},
  9585. Monstre: {}
  9586. };
  9587. }
  9588. /* On applique "aAppliquer" */
  9589. // Diplo Trõlls
  9590. for(var i=nbTrolls ; i>0 ; i--) {
  9591. var idG = getTrollGuildeID(i);
  9592. var idT = getTrollID(i);
  9593. var tr = tr_trolls[i];
  9594. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9595. if(aAppliquer.Troll[idT]) {
  9596. tr.className = '';
  9597. var descr = aAppliquer.Troll[idT].titre;
  9598. if(descr) {
  9599. getTrollNomNode(i).title = descr
  9600. }
  9601. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9602. } else if(aAppliquer.Guilde[idG]) {
  9603. tr.className = '';
  9604. var descr = aAppliquer.Guilde[idG].titre;
  9605. if(descr) {
  9606. getTrollNomNode(i).title = descr
  9607. }
  9608. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9609. } else {
  9610. tr.className = 'mh_tdpage';
  9611. getTrollNomNode(i).title = '';
  9612. }
  9613. }
  9614. // Diplo Monstres
  9615. for(var i=nbMonstres ; i>0 ; i--) {
  9616. var id = getMonstreID(i);
  9617. var nom = getMonstreNom(i).toLowerCase();
  9618. if(aAppliquer.Monstre[id]) {
  9619. tr_monstres[i].className = '';
  9620. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  9621. tr_monstres[i].diploActive = 'oui';
  9622. var descr = aAppliquer.Monstre[id].titre;
  9623. if(descr) {
  9624. getMonstreNomNode(i).title = descr;
  9625. }
  9626. } else if(aAppliquer.mythiques &&
  9627. (nom.indexOf('liche')==0 ||
  9628. nom.indexOf('hydre')==0 ||
  9629. nom.indexOf('balrog')==0 ||
  9630. nom.indexOf('beholder')==0)) {
  9631. tr_monstres[i].className = '';
  9632. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  9633. tr_monstres[i].diploActive = 'oui';
  9634. getMonstreNomNode(i).title = 'Monstre Mythique';
  9635. } else {
  9636. tr_monstres[i].className = 'mh_tdpage';
  9637. tr_monstres[i].diploActive = '';
  9638. }
  9639. }
  9640. }
  9641.  
  9642.  
  9643. /*-[functions]---------------- Actions à distance ----------------------------*/
  9644.  
  9645. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  9646. var monN = parseInt(getPosition()[2]);
  9647. for(var type in keltypes) {
  9648. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  9649. for(var i=this['nb'+type] ; i>0 ; i--) {
  9650. var tr = this['tr_'+type.toLowerCase()][i];
  9651. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  9652. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  9653. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  9654. var sonN = getXxxPosition(type, i)[2];
  9655. var d = getXxxDistance(type, i);
  9656. if(sonN==monN && d>=dmin && d<=dmax) {
  9657. var iconeAction = document.evaluate(
  9658. "./descendant::img[@alt='"+alt+"']",
  9659. tr, null, 9, null
  9660. ).singleNodeValue;
  9661. if(iconeAction) {
  9662. if(iconeAction.title) {
  9663. iconeAction.title += "\n"+message;
  9664. } else {
  9665. iconeAction.title = message;
  9666. }
  9667. iconeAction.src = urlIcon;
  9668. } else {
  9669. var tdAction = tr.getElementsByTagName('td')[1];
  9670. var icon = document.createElement('img');
  9671. icon.src = urlIcon;
  9672. icon.height = 20;
  9673. icon.alt = alt;
  9674. icon.title = message;
  9675. tdAction.appendChild(icon);
  9676. }
  9677. }
  9678. }
  9679. }
  9680. }
  9681.  
  9682. function computeCharge() {
  9683. computeActionDistante(1,
  9684. getPortee__Vue(
  9685. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  9686. MY_getValue(numTroll+".caracs.regeneration")
  9687. ),
  9688. {'Monstres':1, 'Trolls':1},
  9689. 'Attaquer',
  9690. MHicons+'E_Metal09.png',
  9691. 'Cible à portée de Charge'
  9692. );
  9693. }
  9694.  
  9695. function computeProjo() {
  9696. computeActionDistante(0,
  9697. getPortee__Vue(
  9698. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9699. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9700. ),
  9701. {'Monstres':1, 'Trolls':1},
  9702. 'Attaquer',
  9703. MHicons+'S_Fire05.png',
  9704. 'Cible à portée de Projo'
  9705. );
  9706. }
  9707.  
  9708. function computeTelek() {
  9709. computeActionDistante(0,
  9710. Math.floor((
  9711. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9712. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9713. )/2),
  9714. {'Tresors':1},
  9715. 'Telek',
  9716. MHicons+'S_Magic04.png',
  9717. 'Trésor à portée de Télékinésie'
  9718. );
  9719. }
  9720.  
  9721. function computeLdP() {
  9722. computeActionDistante(0,
  9723. 2+Math.floor((
  9724. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9725. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9726. )/5),
  9727. {'Monstres':1, 'Trolls':1},
  9728. 'self',
  9729. MHicons+'P_Red01.png',
  9730. 'Cible à portée de Lancer de Potions'
  9731. );
  9732. }
  9733.  
  9734.  
  9735. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  9736.  
  9737. function putScriptExterne() {
  9738. var infoit = MY_getValue(numTroll+'.INFOSIT');
  9739. if(!infoit || infoit=='') return;
  9740.  
  9741. var nomit = infoit.slice(0,infoit.indexOf('$'));
  9742. if(nomit=='bricol') {
  9743. var data = infoit.split('$');
  9744. try {
  9745. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  9746. // appendNewScript(URL_bricol+data[1]
  9747. // +'/mz.php?login='+data[2]
  9748. // +'&password='+data[3]
  9749. // );
  9750. FF_XMLHttpRequest({
  9751. method: 'GET',
  9752. url: URL_bricol+data[1]
  9753. +'/mz_json.php?login='+data[2]
  9754. +'&password='+data[3],
  9755. onload: function(responseDetails) {
  9756. try {
  9757. if (responseDetails.status == 0) {
  9758. window.console.log('status=0 à l\'appel bricol\'troll');
  9759. if (isHTTPS) {
  9760. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  9761. } else {
  9762. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  9763. }
  9764. return;
  9765. }
  9766. var ratibusData;
  9767. try {
  9768. ratibusData = JSON.parse(responseDetails.responseText);
  9769. } catch(e) {}
  9770. if (ratibusData === undefined) {
  9771. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  9772. return;
  9773. }
  9774. if (ratibusData.error) {
  9775. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  9776. } else {
  9777. putInfosTrolls(ratibusData.data.trolls);
  9778. }
  9779. } catch(e) {
  9780. window.console.log(traceStack(e, 'retour bricol\'troll'));
  9781. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  9782. }
  9783. }
  9784. });
  9785. } catch(e) {
  9786. if (isHTTPS) {
  9787. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  9788. } else {
  9789. window.console.log(traceStack(e, 'appel bricol\'troll'));
  9790. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  9791. }
  9792. }
  9793. }
  9794. }
  9795.  
  9796. /* Le script mz.php de Ratibus renvoie :
  9797. + infosTrolls = new Array();
  9798. + infosTrolls[numdutroll] =
  9799. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  9800. + etc ...
  9801. + putInfosTrolls();
  9802. *
  9803. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  9804. * Roule 07/11/2016, on utilise mz_json qui envoie
  9805. {
  9806. "data": {
  9807. "trolls": {
  9808. "59424": {
  9809. "id": 59424,
  9810. "pv": xx,
  9811. "pv_max": xx,
  9812. "updated_at": "2016-10-31 07:28:40",
  9813. "dla": "2016-10-05 07:28:04",
  9814. "pa": 0
  9815. },
  9816. }
  9817. }
  9818. }
  9819. */
  9820.  
  9821. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  9822. function corrigeBricolTrolls(infosTrolls) {
  9823. for(var i in infosTrolls) {
  9824. var pv = infosTrolls[i][0];
  9825. var pvmax = infosTrolls[i][1];
  9826. var pvmem = MY_getValue(i+'.caracs.pv.max');
  9827. if(pvmem && pvmem>pvmax) {
  9828. infosTrolls[i][1] = pvmem;
  9829. pvmax = pvmem;
  9830. }
  9831. if(pv>pvmax) {
  9832. var newpvmax = 5*Math.ceil(pv/5);
  9833. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9834. infosTrolls[i][1] = newpvmax;
  9835. }
  9836. }
  9837. }
  9838.  
  9839. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9840. function addTdInfosTroll(infos, TR) {
  9841. /* cadre barre PV */
  9842. var tab = document.createElement('div');
  9843. /* ancienne méthode par img, à supprimer
  9844. tab.width = 100;
  9845. tab.style.width = 100;
  9846. tab.height = 10;
  9847. tab.style.background = '#FFFFFF';
  9848. tab.style.border = 1;
  9849. */
  9850. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9851. /* barre PV */
  9852. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9853. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9854. .vieContainer {
  9855. background-color: #CCC;
  9856. width: 50px;
  9857. height: 6px;
  9858. border: 1px solid #000;
  9859. text-align: left;
  9860. }
  9861. */
  9862. tab.style.width = '100px';
  9863. tab.style.height = '10px';
  9864. tab.style.border = '1px solid #000';
  9865. tab.style.textAlign = 'left';
  9866. var div2 = document.createElement('div');
  9867. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9868. var dateLimite = new Date();
  9869. dateLimite.setDate(dateLimite.getDate() - 7);
  9870. if (infos.oUpdatedAt < dateLimite) {
  9871. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9872. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9873. } else if (pourcentVie > 66) {
  9874. div2.style.backgroundColor = '#77EE77';
  9875. } else if (pourcentVie > 33) {
  9876. div2.style.backgroundColor = '#EEEE77';
  9877. } else {
  9878. div2.style.backgroundColor = '#FF0000';
  9879. }
  9880. div2.style.width = pourcentVie + '%';
  9881. div2.style.height = '10px';
  9882. tab.appendChild(div2);
  9883. /* ancienne méthode par img, à supprimer
  9884. var img = document.createElement('img');
  9885. img.src = '../Images/Interface/milieu.gif';
  9886. img.height = 10;
  9887. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9888. tab.appendChild(img);
  9889. */
  9890.  
  9891. var tdNom = TR.childNodes[3]
  9892. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  9893. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  9894.  
  9895. /* lien vers l'IT */
  9896. var lien = document.createElement('a');
  9897. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9898. lien.href = URL_bricol+nomit+'/index.php';
  9899. lien.target = '_blank';
  9900. lien.appendChild(tab);
  9901. var tdGuilde = TR.childNodes[6];
  9902. insertTdElement(tdGuilde,lien);
  9903. /* PAs dispos */
  9904. var span = document.createElement('span');
  9905. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9906. appendText(span, infos.pa +' PA' );
  9907. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9908. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9909. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9910. span.style.backgroundColor = 'B8EEB8';
  9911. }
  9912. insertTdElement(tdGuilde, span);
  9913. }
  9914.  
  9915. function putInfosTrolls(infosTrolls) {
  9916. try {
  9917. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9918. // supression des infos trop vieilles (un mois)
  9919. var IDs = Object.keys(infosTrolls);
  9920. var dateLimite = new Date();
  9921. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9922. for (var i = 0; i < IDs.length; i++) {
  9923. var idTroll = IDs[i];
  9924. var infos = infosTrolls[idTroll];
  9925. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9926. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9927. }
  9928. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9929. td.width = 40;
  9930. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9931. td.width = 105;
  9932.  
  9933. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9934. //corrigeBricolTrolls(infosTrolls);
  9935.  
  9936. for(i=nbTrolls ; i>0 ; i--) {
  9937. var infos = infosTrolls[getTrollID(i)];
  9938. if(infos && (!infos.bIgnore)) {
  9939. addTdInfosTroll(infos, tr_trolls[i]);
  9940. infos.done = true;
  9941. } else {
  9942. insertTd(tr_trolls[i].childNodes[6]);
  9943. insertTd(tr_trolls[i].childNodes[6]);
  9944. }
  9945. }
  9946. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9947. var str = MY_getValue(numTroll+'.INFOSIT');
  9948. if(!str) return;
  9949. var arr = str.split('$');
  9950. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9951.  
  9952. //window.console.log('nb Troll IT : ' + IDs.length);
  9953. var tBody = tr_trolls[0].parentNode;
  9954. if (tr_trolls[1] === undefined)
  9955. tBody = tr_trolls[0].parentNode;
  9956. else
  9957. tBody = tr_trolls[1].parentNode;
  9958. var pos = getPosition();
  9959. for (i = 0; i < IDs.length; i++) {
  9960. var idTroll = IDs[i];
  9961. infos = infosTrolls[idTroll];
  9962. if (infos.done) continue; // déjà vu
  9963. if (infos.bIgnore) continue; // trop vieux
  9964. if (idTroll == numTroll) continue; // pas nous-même
  9965. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9966. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9967. // trouver où insérer ce Troll
  9968. var next = undefined;
  9969. for(var j=0 ; j<tr_trolls.length ; j++) {
  9970. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9971. if (thisDist > distance) {
  9972. next = tr_trolls[j]
  9973. break;
  9974. }
  9975. }
  9976. var tr;
  9977. if (next !== undefined) {
  9978. tr = insertTr(next,'mh_tdpage')
  9979. } else {
  9980. tr = appendTr(tBody,'mh_tdpage');
  9981. }
  9982. tr.style.color = 'orange';
  9983. var td = appendTd(tr); // distance
  9984. appendText(td, distance);
  9985. td = appendTd(tr); // actions
  9986. td = appendTd(tr); // ID
  9987. appendText(td, idTroll);
  9988. td = appendTd(tr); // Nom
  9989. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9990. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9991. // info camou/invi transféré dans addTdInfosTroll
  9992. // if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9993. // if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9994. td = appendTd(tr); // Niveau
  9995. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9996. td.align = 'center';
  9997. td = appendTd(tr); // Race
  9998. if (infos.race) appendText(td, infos.race);
  9999. // PV et PA ajoutés par addTdInfosTroll
  10000. td = appendTd(tr); // Guilde
  10001. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10002. td = appendTd(tr); // X
  10003. td.align = 'center';
  10004. if (infos.x !== undefined) appendText(td, infos.x);
  10005. td = appendTd(tr); // Y
  10006. td.align = 'center';
  10007. if (infos.y !== undefined) appendText(td, infos.y);
  10008. td = appendTd(tr); // N
  10009. td.align = 'center';
  10010. if (infos.n !== undefined) appendText(td, infos.n);
  10011. addTdInfosTroll(infos, tr);
  10012. }
  10013. } catch(e) {
  10014. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  10015. }
  10016. }
  10017.  
  10018.  
  10019. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10020.  
  10021. function calculeDistance(maPos,posArr) {
  10022. return Math.max(
  10023. Math.abs(maPos[0]-posArr[0]),
  10024. Math.abs(maPos[1]-posArr[1]),
  10025. Math.abs(maPos[2]-posArr[2])
  10026. );
  10027. }
  10028.  
  10029. function inversionCoord() {
  10030. var maPos = getPosition();
  10031. var listeOffsets = {
  10032. 'monstres':checkBoxLevels.checked?4:3,
  10033. 'trolls':6,
  10034. };
  10035. for(var type in listeOffsets) {
  10036. var trList = this['tr_'+type];
  10037. var offset = listeOffsets[type];
  10038. for(var i=trList.length-1 ; i>0 ; i--) {
  10039. var oldX = parseInt(trList[i].cells[offset].textContent);
  10040. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10041. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10042. trList[i].cells[offset].innerHTML = oldY;
  10043. trList[i].cells[offset+1].innerHTML = oldX;
  10044. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10045. }
  10046. }
  10047. }
  10048.  
  10049.  
  10050. /* Partie principale */
  10051. function do_vue() {
  10052. for(var type in typesAFetcher) {
  10053. fetchData(type);
  10054. }
  10055.  
  10056. // roule' 11/03/2016
  10057. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10058. // je fais une recopie :(
  10059. tr_monstres = this['tr_monstres'];
  10060. tr_trolls = this['tr_trolls'];
  10061. tr_tresors = this['tr_tresors'];
  10062. tr_champignons = this['tr_champignons'];
  10063. tr_lieux = this['tr_lieux'];
  10064.  
  10065. nbMonstres = this['nbMonstres'];
  10066. nbTrolls = this['nbTrolls'];
  10067. nbTresors = this['nbTresors'];
  10068. nbChampignons = this['nbChampignons'];
  10069. nbLieux = this['nbLieux'];
  10070.  
  10071. try {
  10072. start_script(31);
  10073. initialiseInfos();
  10074. savePosition();
  10075.  
  10076. // Fonctionnalité "Têtalenvert" cachée, en test :
  10077. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10078. inversionCoord();
  10079. }
  10080. ajoutDesFiltres();
  10081. set2DViewSystem();
  10082. //putBoutonTroogle();
  10083. putBoutonPXMP();
  10084. synchroniseFiltres();
  10085. toggleLevelColumn();
  10086.  
  10087. refreshDiplo();
  10088. //400 ms
  10089. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10090. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10091. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10092. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10093. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10094. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10095. var noTresorsEngages =
  10096. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10097. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10098. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10099. filtreMonstres();
  10100. if(noIntangibles) {
  10101. filtreTrolls();
  10102. }
  10103. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10104. filtreTresors();
  10105. }
  10106. if(noTrou) {
  10107. filtreLieux();
  10108. }
  10109.  
  10110. initPopupVue();
  10111. initPXTroll();
  10112.  
  10113. if(getTalent("Projectile Magique")!=0) {
  10114. computeProjo();
  10115. }
  10116. if(getTalent("Charger")!=0) {
  10117. computeCharge();
  10118. }
  10119. if(getTalent("Télékinésie")!=0) {
  10120. computeTelek();
  10121. }
  10122. if(getTalent("Lancer de Potions")!=0) {
  10123. computeLdP();
  10124. }
  10125. putScriptExterne();
  10126. displayScriptTime();
  10127. } catch(e) {
  10128. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10129. window.console.error(traceStack(e, 'vue'));
  10130. }
  10131. }
  10132.  
  10133.  
  10134.  
  10135. /*******************************************************************************
  10136. * This file is part of Mountyzilla. *
  10137. * *
  10138. * Mountyzilla is free software; you can redistribute it and/or modify *
  10139. * it under the terms of the GNU General Public License as published by *
  10140. * the Free Software Foundation; either version 2 of the License, or *
  10141. * (at your option) any later version. *
  10142. * *
  10143. * Mountyzilla is distributed in the hope that it will be useful, *
  10144. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10145. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10146. * GNU General Public License for more details. *
  10147. * *
  10148. * You should have received a copy of the GNU General Public License *
  10149. * along with Mountyzilla; if not, write to the Free Software *
  10150. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10151. *******************************************************************************/
  10152.  
  10153. // x~x profil2
  10154.  
  10155. /*---------------------------- Variables globales ----------------------------*/
  10156.  
  10157. var
  10158. // Anatrolliseur
  10159. urlAnatrolliseur,
  10160. // Infobulles talents
  10161. hauteur = 50, bulleStyle = null,
  10162. // Caracteristiques
  10163. // Infos troll
  10164. race, niv, idtroll, datecrea,
  10165. idguilde, nomguilde,
  10166. // Etats du troll
  10167. fatigue, bmfatigue,
  10168.  
  10169. // Experience, Pi, ...
  10170. pxdistribuables, pxperso,
  10171. piutilisable, pitotal,
  10172. nbmeurtres, nbmorts,
  10173. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10174. NBjours,
  10175. // calcul des DLA suivantes
  10176. DLA, DLAsuiv, HeureServeur,
  10177. // details duree du tour (calcul pvdispo) :
  10178. dtb, pdm, bmt, adb, dpt,
  10179. //posale
  10180. posX, posY, posN,
  10181. // caracs physiques
  10182. vue, vuebp, vuebm, vuetotale,
  10183. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10184. reg, regbp, regbm, regmoy,
  10185. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10186. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10187. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10188. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10189. rm, rmbp, rmbm, rmtotale,
  10190. mm, mmbp, mmbm, mmtotale,
  10191.  
  10192. // Variables speciales Kastars
  10193. pvActuelKastar, minParPV, overDLA,
  10194. // id pour edition manuelle de lastDLA :
  10195. inJour, inMois, inAn, inHr, inMin, inSec,
  10196. // id pour auto-refresh lastDLA :
  10197. lastDLAZone, maxAMZone, cumulZone,
  10198. lastDLA, DLAaccel;
  10199.  
  10200.  
  10201. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10202.  
  10203. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10204. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10205. function getUniqueValueBySelector(selector, defaultValue){
  10206. var valNode = document.querySelector(selector);
  10207. if(valNode!=null){
  10208. if(valNode.hasChildNodes()) {
  10209. return valNode.childNodes[0].nodeValue;
  10210. }else{
  10211. return defaultValue;
  10212. }
  10213. } else{
  10214. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10215. return defaultValue;
  10216. }
  10217. }
  10218. function getUniqueStringValueBySelector(selector){
  10219. return getUniqueValueBySelector(selector,"");
  10220. }
  10221. function getUniqueIntValueBySelector(selector){
  10222. var ret = getUniqueValueBySelector(selector,0);
  10223. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10224. ret = 0;
  10225. }
  10226. return parseInt(ret);
  10227. }
  10228. function getUniqueFloatValueBySelector(selector){
  10229. var ret = getUniqueValueBySelector(selector,0.0);
  10230. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10231. ret = 0.0;
  10232. }
  10233. return parseFloat(ret);
  10234. }
  10235.  
  10236.  
  10237. function resiste(Ddeg,bm) {
  10238. // version naive mais compréhensible ^^
  10239. // DEBUG: à revoir
  10240. if(!bm) {
  10241. return 2*Math.floor(Ddeg/2);
  10242. }
  10243. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10244. }
  10245.  
  10246. function retourAZero(fatig) {
  10247. var fat = fatig, raz = 0;
  10248. while(fat>0) {
  10249. raz++;
  10250. fat = Math.floor(fat/1.25);
  10251. }
  10252. return raz;
  10253. }
  10254.  
  10255. function decumulPumPrem(bonus) {
  10256. switch(bonus) {
  10257. case 20: return 33;
  10258. case 33: return 41;
  10259. case 41: return 46;
  10260. case 46: return 49;
  10261. case 49: return 51;
  10262. default: return 20;
  10263. }
  10264. }
  10265.  
  10266. function coefDecumul(i) {
  10267. switch(i) {
  10268. case 2: return 0.67;
  10269. case 3: return 0.4;
  10270. case 4: return 0.25;
  10271. case 5: return 0.15;
  10272. default: return 0.1;
  10273. }
  10274. }
  10275.  
  10276. function dureeHM(dmin) {
  10277. var ret = "";
  10278. dmin = Math.floor(dmin);
  10279. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  10280. var mins = dmin%60;
  10281. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  10282. return (ret) ? ret : "-";
  10283. }
  10284.  
  10285. // extraction d'une durée
  10286. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  10287. // c'est protégé (rend 0 si l'élément est absent)
  10288. // Roule' 24/12/2016
  10289. function extractionDuree(selecteur) {
  10290. var s = getUniqueStringValueBySelector(selecteur);
  10291. if (!s) return 0;
  10292. var tabN = getNumbers(s);
  10293. if (tabN.length < 2) return 0;
  10294. return tabN[0] * 60 + tabN[1];
  10295. }
  10296.  
  10297. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  10298.  
  10299. function extractionDonnees() {
  10300. // Variables temporaires
  10301. var Nbrs = {};
  10302.  
  10303. // *********************
  10304. // Cadre "Description"
  10305. // *********************
  10306. race = getUniqueStringValueBySelector('#descr #race');
  10307. debugMZ("Race : " + race);
  10308. idtroll = getUniqueStringValueBySelector('#descr #id');
  10309. debugMZ("Id troll : " + idtroll);
  10310. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  10311. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  10312. datecrea = new Date(StringToDate(strDateCrea));
  10313. debugMZ("Date creation : " + datecrea);
  10314. // Guilde
  10315. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  10316. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  10317. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  10318.  
  10319. // *******************
  10320. // Cadre "Experience"
  10321. // *******************
  10322. // Niveau de troll
  10323. niv = getUniqueIntValueBySelector('#exp #niv');
  10324. nivTroll = niv;
  10325. debugMZ("Niveau : " + niv);
  10326. // PX
  10327. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  10328. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  10329. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  10330. // PI
  10331. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  10332. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  10333. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  10334. // Meutres/Morts
  10335. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  10336. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  10337. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  10338.  
  10339. // *********************
  10340. // Cadre "Tour de Jeu"
  10341. // *********************
  10342. // DLA
  10343. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  10344. DLA = new Date(StringToDate(Nbrs["dla"]));
  10345. debugMZ("DLA: " + DLA);
  10346. // DLA suivante
  10347. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  10348. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  10349. debugMZ("DLAsuiv: " + DLAsuiv);
  10350. // Duree normale de mon Tour
  10351. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  10352. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  10353. dtb = extractionDuree("#dla #tour");
  10354. debugMZ("Duree normale de mon Tour : " + dtb);
  10355. // Bonus/Malus sur la duree
  10356. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  10357. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  10358. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  10359. debugMZ("Bonus/Malus sur la duree : " + bmt);
  10360. // Augmentation due aux blessures
  10361. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  10362. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  10363. adb = extractionDuree("#dla #blessure");
  10364. debugMZ("Augmentation due aux blessures : " + adb);
  10365. // Poids de l'equipement
  10366. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  10367. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  10368. pdm = extractionDuree("#dla #poids");
  10369. debugMZ("Poids de l'equipement : " + pdm);
  10370. // Duree de mon prochain Tour
  10371. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  10372. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  10373. dpt = extractionDuree("#dla #duree>b");
  10374. debugMZ('Duree de mon prochain Tour : ' + dpt);
  10375.  
  10376. // ****************
  10377. // Cadre "Etats"
  10378. // ****************
  10379. // Position du troll :
  10380. posX = getUniqueIntValueBySelector('#pos #x');
  10381. posY = getUniqueIntValueBySelector('#pos #y');
  10382. posN = getUniqueIntValueBySelector('#pos #n');
  10383. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  10384. // PV actuel
  10385. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  10386. pvActuelKastar = pvcourant;
  10387. debugMZ("PV actuel : " + pvcourant)
  10388. // Fatigue
  10389. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  10390. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  10391. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  10392.  
  10393. // **************************
  10394. // Cadre "Caracteristiques"
  10395. // **************************
  10396. // Attaque
  10397. att = getUniqueIntValueBySelector('#carac #att');
  10398. attbp = getUniqueIntValueBySelector('#carac #att_p');
  10399. attbm = getUniqueIntValueBySelector('#carac #att_m');
  10400. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  10401. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  10402. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  10403. attmoy = 3.5*att + attbp + attbm;
  10404. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10405. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  10406. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  10407. // Esquive
  10408. esq = getUniqueIntValueBySelector('#carac #esq');
  10409. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  10410. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  10411. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  10412. esqmoy = 3.5*esq + esqbp+esqbm;
  10413. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  10414. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  10415. // Degat
  10416. deg = getUniqueIntValueBySelector('#carac #deg');
  10417. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  10418. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  10419. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  10420. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  10421. degmoy = 2*deg + degbp+degbm;
  10422. degmoycrit = 3*deg + degbp+degbm;
  10423. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10424. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  10425. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  10426. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  10427. // PV
  10428. pvbase = getUniqueIntValueBySelector('#carac #pv');
  10429. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  10430. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  10431. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  10432. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  10433. // Regeneration
  10434. reg = getUniqueIntValueBySelector('#carac #reg');
  10435. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  10436. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  10437. regmoy = 2 * reg + regbp + regbm; // D3
  10438. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  10439. // Armure
  10440. arm = getUniqueIntValueBySelector('#carac #arm');
  10441. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  10442. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  10443. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  10444. armmoy = 2*arm + armbp+armbm;
  10445. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  10446. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  10447. // TODO : D d'armure non active
  10448. // Vue
  10449. vue = getUniqueIntValueBySelector('#carac #vue');
  10450. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10451. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10452. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10453. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10454. // RM
  10455. rm = getUniqueIntValueBySelector('#carac #rm');
  10456. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10457. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10458. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10459. rmTroll = rmtotale;
  10460. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10461. // MM
  10462. mm = getUniqueIntValueBySelector('#carac #mm');
  10463. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10464. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10465. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10466. mmTroll = mmtotale;
  10467. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10468.  
  10469. // Heure Serveur
  10470. try {
  10471. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10472. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10473. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10474. } catch (e) {
  10475. window.console.warn(
  10476. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10477. );
  10478. HeureServeur = new Date();
  10479. }
  10480. debugMZ("HeureServeur: " + HeureServeur);
  10481.  
  10482. // ***INIT GLOBALE*** NBjours
  10483. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10484.  
  10485. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10486. var amelio_dtb = function(dtb) {
  10487. if(dtb>555) {
  10488. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10489. }
  10490. return 10+Math.ceil((555-dtb)/2.5);
  10491. },
  10492. amelio_pv = Math.floor(pvbase/10)-3,
  10493. amelio_vue = vue-3,
  10494. amelio_att = att-3,
  10495. amelio_esq = esq-3,
  10496. amelio_deg = deg-3,
  10497. amelio_reg = reg-1,
  10498. amelio_arm = arm-1;
  10499. if(race==="Darkling"){amelio_reg--; }
  10500. if(race==="Durakuir"){amelio_pv-- ; }
  10501. if(race==="Kastar") {amelio_deg--; }
  10502. if(race==="Skrim") {amelio_att--; }
  10503. if(race==="Tomawak") {amelio_vue--; }
  10504.  
  10505. urlAnatrolliseur = URL_AnatrolDispas
  10506. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10507. +"|r="+race.toLowerCase()
  10508. +"|dla="+amelio_dtb(dtb)
  10509. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10510. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10511. +"|att="+amelio_att+","+attbp+","+attbm
  10512. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10513. +"|deg="+amelio_deg+","+degbp+","+degbm
  10514. +"|reg="+amelio_reg+","+regbp+","+regbm
  10515. +"|arm="+amelio_arm+","+armbp+","+armbm
  10516. +"|mm="+mmtotale
  10517. +"|rm="+rmtotale+"|";
  10518. }
  10519.  
  10520. function saveProfil() {
  10521. MY_setValue(idtroll+'.caracs.attaque',att);
  10522. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10523. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10524. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10525. if(atttourD||atttourP||atttourM) {
  10526. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10527. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10528. }
  10529. MY_setValue(idtroll+'.caracs.esquive',esq);
  10530. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10531. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10532. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10533. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10534. MY_setValue(idtroll+'.caracs.degats',deg);
  10535. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10536. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10537. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10538. if(degtourP||degtourM){
  10539. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10540. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10541. }
  10542. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10543. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10544. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10545. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10546. MY_setValue(idtroll+'.caracs.vue',vue);
  10547. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10548. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10549. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10550. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10551. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10552. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10553. MY_setValue(idtroll+'.caracs.rm',rm);
  10554. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10555. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10556. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10557. MY_setValue(idtroll+'.caracs.mm',mm);
  10558. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10559. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10560. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10561. MY_setValue(idtroll+'.caracs.armure',arm);
  10562. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10563. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10564. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10565. MY_setValue(idtroll+'.position.X',posX);
  10566. MY_setValue(idtroll+'.position.Y',posY);
  10567. MY_setValue(idtroll+'.position.N',posN);
  10568. MY_setValue(idtroll+'.race',race);
  10569. MY_setValue(idtroll+'.niveau',niv);
  10570. MY_setValue(idtroll+'.idguilde',idguilde);
  10571. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10572. }
  10573.  
  10574.  
  10575. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10576.  
  10577. function setInfosCaracteristiques() {
  10578. // Modification de l'entete
  10579. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10580. thTotal.innerHTML+='|<i>Moyenne</i>';
  10581. thTotal.title="Moyenne (Moyenne ce tour)";
  10582.  
  10583. // Ajout des informations calculees
  10584. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10585. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10586. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10587.  
  10588. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10589. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10590. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10591.  
  10592. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10593. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10594. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10595.  
  10596. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10597. var tdRegTotal = trRegeneration.children[5];
  10598. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10599. // Temps recupere par reg (propale R')
  10600. var regmoyTemp = Math.max(0, regmoy);
  10601. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10602. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10603. if (sec != 0) {
  10604. regTitle += " " + sec + " sec";
  10605. }
  10606. trRegeneration.title = regTitle;
  10607.  
  10608. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  10609. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  10610. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  10611.  
  10612. var trRM=document.querySelector("table#caracs #rm").parentElement;
  10613. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  10614. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  10615.  
  10616.  
  10617. var trMM=document.querySelector("table#caracs #mm").parentElement;
  10618. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  10619. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  10620.  
  10621. var tdRefl=document.querySelector("#refl");
  10622. // TODO : prendre en compte bonus/malus D esq du tour ?
  10623. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  10624. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  10625. }
  10626.  
  10627. function setLienAnatrolliseur(){
  10628. var pTableAmelio = document.querySelector("#carac>div>p");
  10629. pTableAmelio.innerHTML+=" - ";
  10630. var aElt = document.createElement("a");
  10631. aElt.setAttribute("href",urlAnatrolliseur);
  10632. aElt.setAttribute("target","_blank");
  10633. aElt.className="AllLinks";
  10634. aElt.innerHTML="Anatrolliser";
  10635. pTableAmelio.appendChild(aElt);
  10636. }
  10637. function setInfoDescription() {
  10638. var txtDateCrea = (NBjours!=1) ?
  10639. " ("+NBjours+" jours dans le hall)" :
  10640. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  10641. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  10642. }
  10643.  
  10644. function setInfosEtatLieux() {
  10645. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  10646. '?search=position&orderBy=distance&posx='+
  10647. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  10648. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  10649. appendBr(tdPosition);
  10650. var aElt = document.createElement("a");
  10651. aElt.setAttribute("href",urlBricol);
  10652. aElt.setAttribute("target","_blank");
  10653. aElt.className="AllLinks";
  10654. aElt.innerHTML="Lieux à proximité";
  10655. tdPosition.appendChild(aElt);
  10656. }
  10657.  
  10658. function setInfosEtatPV() { // pour AM et Sacro
  10659. var
  10660. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  10661. sec = Math.floor(15000/pvtotal)%60,
  10662. lifebar = document.querySelector("#pos .barre-vie");
  10663. if(sec!=0) { txt += " "+sec+" sec"; }
  10664. if(lifebar) { lifebar.title = txt; }
  10665. if(pvcourant<=0) { return; }
  10666. // Difference PV p/r a equilibre de temps (propale R')
  10667. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  10668. // ***INIT GLOBALE*** pvdispo
  10669. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10670. var span = document.createElement("span");
  10671. span.title = txt;
  10672. span.style.fontStyle = "italic";
  10673. if(bmt+pdm>=0) {
  10674. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  10675. } else if(pvdispo>0) {
  10676. txt = "Vous pouvez encore perdre "+
  10677. Math.min(pvdispo,pvcourant)+
  10678. " PV sans malus de temps.";
  10679. } else if(pvdispo<0) {
  10680. txt = "Il vous manque "
  10681. +(-pvdispo)
  10682. +" PV pour ne plus avoir de malus de temps.";
  10683. } else {
  10684. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  10685. }
  10686. appendText(span,txt);
  10687. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  10688. }
  10689.  
  10690. // Complete le cadre "Experience"
  10691. function setInfosExp() {
  10692. var tdNiv = document.querySelector("#exp #niv");
  10693.  
  10694. // Calcul niveau monstre/troll min pour gain PX
  10695. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  10696. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  10697.  
  10698. // Calcul PX restant
  10699. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  10700. if (pxRestant >= 0) {
  10701. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  10702. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  10703. }
  10704.  
  10705. // Calul pi/jour
  10706. var
  10707. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  10708. tdPi = document.querySelector("#exp #pi").parentElement;
  10709. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  10710. tdPi.title = tdPiTotal.title;
  10711.  
  10712. // Rapports meurtres,morts
  10713. var tdKill = document.querySelector("#exp #kill");
  10714. tdKill.setAttribute("colspan", 1);
  10715. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  10716.  
  10717. var tdMort = document.querySelector("#exp #mort");
  10718. tdMort.setAttribute("colspan", 1);
  10719. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  10720.  
  10721. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  10722. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  10723. }
  10724.  
  10725.  
  10726. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  10727.  
  10728. function minParPVsac(fat,bm) {
  10729. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  10730. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  10731. var out = [];
  10732. out[0] = (fat>4) ?
  10733. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  10734. 30;
  10735. if(bm && bm>0) {
  10736. var totalfat=fat+bm;
  10737. out[1] = (totalfat>4) ?
  10738. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  10739. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  10740. }
  10741. return out;
  10742. }
  10743.  
  10744. function toInt(str) {
  10745. str = parseInt(str);
  10746. return (str) ? str : 0;
  10747. }
  10748.  
  10749. function saveLastDLA() {
  10750. // pour les calculs d'AM max
  10751. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  10752. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  10753. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  10754. lastDLA = new Date( StringToDate(str) );
  10755. MY_setValue(numTroll+'.DLA.ancienne',str);
  10756. lastDLAZone.innerHTML = '';
  10757. var b = document.createElement('b');
  10758. b.addEventListener('click',inputMode,false);
  10759. appendText(b,str);
  10760. lastDLAZone.appendChild(b);
  10761. refreshAccel();
  10762. }
  10763.  
  10764. function inputMode() {
  10765. // Edition manuelle lastDLA
  10766. var date;
  10767. if(lastDLA)
  10768. date = new Date( lastDLA );
  10769. else
  10770. date = new Date( DLAaccel );
  10771. lastDLAZone.innerHTML = '';
  10772. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  10773. appendText(lastDLAZone,'/');
  10774. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  10775. appendText(lastDLAZone,'/');
  10776. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  10777. appendText(lastDLAZone,' - ');
  10778. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  10779. appendText(lastDLAZone,':');
  10780. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  10781. appendText(lastDLAZone,':');
  10782. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  10783. appendText(lastDLAZone,' - ');
  10784. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  10785. }
  10786.  
  10787. function setAccel() {
  10788. var
  10789. BMfrais=false,
  10790. fat=fatigue, listeBmFat=[],
  10791. tr, th, insertPt;
  10792.  
  10793. // Creation ligne speciale pour AM dans le cadre "Etat"
  10794. tr = document.createElement('tr');
  10795. th = document.createElement('th');
  10796. appendText(th,'Fatigue et AM',true);
  10797. tr.appendChild(th);
  10798. insertPt = document.createElement('td');
  10799. tr.appendChild(insertPt);
  10800. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  10801.  
  10802. // Est-on en over-DLA ?
  10803. // ***INIT GLOBALE*** overDLA
  10804. overDLA = (HeureServeur>DLA.getTime()+3e5);
  10805. if(overDLA) {
  10806. fat=Math.floor(fatigue/1.25);
  10807. }
  10808.  
  10809. // Gestion des BM de fatigue
  10810. if(bmfatigue>0) {
  10811. // On tente de recuperer les BM de fatigue de la page des BM
  10812. if(MY_getValue(numTroll+'.bm.fatigue')) {
  10813. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  10814. BMmemoire.pop();
  10815. var tour = 0;
  10816. for(var i=0 ; i<BMmemoire.length ; i++) {
  10817. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  10818. while(tour<=parseInt(nbrs[0])) {
  10819. listeBmFat[tour]=parseInt(nbrs[1]);
  10820. tour++;
  10821. }
  10822. }
  10823. }
  10824. if(listeBmFat[0]==bmfatigue) {
  10825. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  10826. BMfrais = true;
  10827. MY_removeValue(numTroll+".bm.fatigue");
  10828. }
  10829. } else {
  10830. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  10831. BMfrais = true;
  10832. }
  10833. if(!BMfrais && bmfatigue>0) {
  10834. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  10835. if(bmfatigue==15) {
  10836. listeBmFat = [15,15,15];
  10837. } else {
  10838. listeBmFat = [30,30,15];
  10839. }
  10840. }
  10841. if(overDLA) {
  10842. // Si on est en over-DLA, on decale les bm d'un tour
  10843. listeBmFat.shift();
  10844. }
  10845. // Tableau des fatigues et accel futures
  10846. var
  10847. minppv = minParPVsac(fat,listeBmFat[0]),
  10848. table, tbody,
  10849. ligneTour, ligneFat, ligneMin,
  10850. col;
  10851. // ***INIT GLOBALE*** minParPV
  10852. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10853. if(fat>0 || listeBmFat[0]>0) {
  10854. table = document.createElement('table');
  10855. table.className = 'mh_tdborder';
  10856. table.border = 0;
  10857. table.cellSpacing = 1;
  10858. table.cellPadding = 1;
  10859. table.style.textAlign = "center";
  10860. tbody = document.createElement('tbody');
  10861. table.appendChild(tbody);
  10862. insertPt.appendChild(table);
  10863. ligneTour = appendTr(tbody,'mh_tdtitre');
  10864. ligneTour.style.fontWeight = "bold";
  10865. var td = appendTdText(ligneTour,'Tour :',true);
  10866. td.align = 'left';
  10867. ligneFat = appendTr(tbody,'mh_tdpage');
  10868. td = appendTdText(ligneFat,'Fatigue :',true);
  10869. td.className = 'mh_tdtitre';
  10870. td.align = 'left';
  10871. ligneMin = appendTr(tbody,'mh_tdpage');
  10872. td = appendTdText(ligneMin,'1 PV =',true);
  10873. td.className = 'mh_tdtitre';
  10874. td.align = 'left';
  10875. col=0;
  10876. while(col<9 && (fat>0 || listeBmFat[col])) {
  10877. if(col==0) {
  10878. if(overDLA) {
  10879. var i = document.createElement('i');
  10880. appendText(i,'A activer');
  10881. ligneTour.appendChild(i);
  10882. } else {
  10883. appendTdText(ligneTour,'En cours');
  10884. }
  10885. } else {
  10886. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10887. }
  10888. if(listeBmFat[col]) {
  10889. if(BMfrais || (!overDLA && col==0)) {
  10890. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10891. appendTdText(ligneMin,minppv[1]+'\'');
  10892. } else {
  10893. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10894. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10895. }
  10896. } else {
  10897. appendTdText(ligneFat,fat);
  10898. appendTdText(ligneMin,minppv[0]+'\'');
  10899. }
  10900. col++;
  10901. fat = Math.floor(fat / 1.25);
  10902. minppv = minParPVsac(fat,listeBmFat[col]);
  10903. }
  10904. if(fat>1 || (fat==1 && !overDLA)) {
  10905. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10906. appendTdText(ligneFat,'-');
  10907. appendTdText(ligneMin,'-');
  10908. }
  10909. col = (overDLA) ?
  10910. Math.max(retourAZero(fatigue)-1,col) :
  10911. Math.max(retourAZero(fatigue),col);
  10912. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10913. appendTdText(ligneFat,'0');
  10914. appendTdText(ligneMin,'30\'');
  10915. if(!BMfrais && bmfatigue) {
  10916. // si les BM n'ont pas ete rafraichis, on signale:
  10917. appendText(
  10918. insertPt,
  10919. '/!\\ Visitez la page des Bonus/Malus '+
  10920. 'pour mettre à jour votre fatigue. /!\\',
  10921. true
  10922. );
  10923. appendBr(insertPt);
  10924. }
  10925. appendBr(insertPt);
  10926. }
  10927. if(pvcourant<=0) {
  10928. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10929. return;
  10930. }
  10931. if(fatigue>30) {
  10932. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10933. return;
  10934. }
  10935. // Setup lastDLAZone
  10936. if(overDLA) {
  10937. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10938. DLAaccel = new Date( DLAsuiv );
  10939. lastDLA = new Date( DLA );
  10940. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10941. // ***INIT GLOBALE*** pvActuelKastar
  10942. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10943. appendText(
  10944. insertPt,
  10945. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10946. true
  10947. );
  10948. appendBr(insertPt);
  10949. } else {
  10950. DLAaccel = new Date( DLA );
  10951. pvActuelKastar = pvcourant;
  10952. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10953. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10954. } else {
  10955. lastDLA = false;
  10956. }
  10957. }
  10958. appendText(insertPt,'Dernière DLA enregistrée : ');
  10959. lastDLAZone = document.createElement('span');
  10960. lastDLAZone.style.cursor = 'pointer';
  10961. var b = document.createElement('b');
  10962. b.onclick = inputMode;
  10963. lastDLAZone.appendChild(b);
  10964. insertPt.appendChild(lastDLAZone);
  10965. if(lastDLA) {
  10966. appendText(b,DateToString(lastDLA));
  10967. } else {
  10968. appendText(b,'aucune');
  10969. }
  10970. appendBr(insertPt);
  10971. // Setup maxAMZone et cumulZone
  10972. appendText(insertPt,'Accélération maximale possible : ');
  10973. maxAMZone = document.createElement('b');
  10974. insertPt.appendChild(maxAMZone);
  10975. appendBr(insertPt);
  10976. cumulZone = document.createElement('span');
  10977. insertPt.appendChild(cumulZone);
  10978. refreshAccel();
  10979. }
  10980.  
  10981. function refreshAccel() {
  10982. var pvs, pvsmax;
  10983. // Acceleration pour cumul instantane
  10984. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10985. if(lastDLA) {
  10986. pvsmax = Math.min(
  10987. pvActuelKastar-1,
  10988. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10989. );
  10990. maxAMZone.innerHTML = pvsmax+" PV";
  10991. } else {
  10992. pvsmax = pvActuelKastar-1;
  10993. maxAMZone.innerHTML = "inconnue";
  10994. }
  10995. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10996. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10997. cumulZone.innerHTML = '';
  10998. if(pvs<=pvsmax) {
  10999. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11000. appendText(cumulZone,pvs+' PV', true);
  11001. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11002. if(pvs!=1) {
  11003. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11004. -(pvs-1)*60*minParPV;
  11005. appendText(
  11006. cumulZone,
  11007. ' ('+(pvs-1)+' PV dans '+
  11008. Math.floor(gainSec/60)+'min'+
  11009. addZero(gainSec%60)+'s)'
  11010. );
  11011. }
  11012. } else {
  11013. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11014. appendText(
  11015. cumulZone,
  11016. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11017. dureeHM(avantDLA/6e4)+
  11018. ' avant de réactiver.'
  11019. );
  11020. }
  11021. }
  11022.  
  11023.  
  11024. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11025.  
  11026. function traitementTalents() {
  11027. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11028. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11029. removeAllTalents();
  11030. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11031. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11032. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11033. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11034. }
  11035.  
  11036. function injecteInfosBulles(liste,fonction) {
  11037. var totalpc = 0;
  11038. // on parse la liste des talents du type 'fonction'
  11039. for(var i=0 ; i<liste.length ; i++) {
  11040. var
  11041. trTalent=liste[i],
  11042. node=trTalent.cells[1].querySelector('a'),
  11043. nomTalent=epure(trim(node.textContent)),
  11044. indiceTDniveaux=7,
  11045. indiceTDSousCompetence=2,
  11046. sousCompetences=undefined;
  11047. if(fonction=="competences"){
  11048. // un TD en plus pour des information complementaire liees a la comp
  11049. indiceTDniveaux++;
  11050. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11051. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11052. for (var j=0; j < sousCompetences.length; j++) {
  11053. sousCompetences[j] = sousCompetences[j].epure().trim();
  11054. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11055. }
  11056. }
  11057. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11058. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11059. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11060. totalpc += niveauxMaitrisesTalentArray[1];
  11061.  
  11062. // stockage des niveaux inferieurs du talent si presents
  11063. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11064. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11065. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11066. }
  11067. }
  11068. return totalpc;
  11069. }
  11070.  
  11071. function setInfos(node,nom,fonction,niveau) {
  11072. node.nom = nom;
  11073. node.fonction = fonction;
  11074. node.niveau = niveau;
  11075. node.onmouseover = setBulle;
  11076. node.onmouseout = cacherBulle;
  11077. }
  11078.  
  11079. var arrayModifAnatroll = {
  11080. 'Glue':'Glu',
  11081. 'PuM':'PuiM',
  11082. 'HE':'Hurlement',
  11083. //'Insultes':'Insu',
  11084. 'Pistage':'Pist',
  11085. 'PuC':'Planter'
  11086. }
  11087.  
  11088. function setTalent(nom,pc,niveau,sousCompetences) {
  11089. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11090. // (et pas les % dont osf) ne serait pas plus rentable
  11091. var nomEnBase = arrayTalents[epure(nom)];
  11092. if(!nomEnBase) { return; }
  11093. if(!niveau) { niveau = 1; }
  11094. switch(nomEnBase) {
  11095. case 'Insultes':
  11096. urlAnatrolliseur += 'Insu'+niveau+'|';
  11097. case 'IdT':
  11098. nomEnBase += niveau;
  11099. break;
  11100. case 'Golemo':
  11101. case 'Piege':
  11102. for (var i=0 ; i < sousCompetences.length ; i++) {
  11103. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11104. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11105. }
  11106. break;
  11107. case 'AP':
  11108. case 'Baroufle':
  11109. case 'CdB':
  11110. case 'CdM':
  11111. case 'Parer':
  11112. case 'Retraite':
  11113. case 'RB':
  11114. case 'SInterposer':
  11115. nomEnBase += niveau;
  11116. default:
  11117. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11118. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11119. }
  11120. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11121. }
  11122.  
  11123. function creerBulleVide() {
  11124. var table = document.createElement('table');
  11125. table.id = 'bulle';
  11126. table.className = 'mh_tdborder';
  11127. table.width = 300;
  11128. table.border = 0;
  11129. table.cellPadding = 5;
  11130. table.cellSpacing = 1;
  11131. table.style =
  11132. 'position:absolute;'
  11133. +'visibility:hidden;'
  11134. +'z-index:800;'
  11135. +'height:auto;';
  11136. var tr = appendTr(table,'mh_tdtitre');
  11137. appendTdText(tr,'Titre');
  11138. tr = appendTr(table,'mh_tdpage');
  11139. appendTdText(tr,'Contenu');
  11140. var aList = document.getElementsByTagName('a');
  11141. aList[aList.length-1].parentNode.appendChild(table);
  11142. }
  11143.  
  11144. function cacherBulle() {
  11145. if(bulleStyle)
  11146. bulleStyle.visibility = 'hidden';
  11147. }
  11148.  
  11149. function setBulle(evt) {
  11150. var nom = this.nom;
  11151. var fonction = this.fonction;
  11152. var niveau = parseInt(this.niveau);
  11153. var str='';
  11154. if(fonction=='competences'){
  11155. str=competences(nom,niveau);
  11156. } else if(fonction=='sortileges') {
  11157. str=sortileges(nom,true);
  11158. }
  11159. if(str=='') return;
  11160. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11161. var xfenetre, yfenetre, xpage, ypage, element = null;
  11162. var offset = 15;
  11163. var bulleWidth = 300;
  11164. if(!hauteur) hauteur = 50;
  11165. element = document.getElementById('bulle');
  11166. xfenetre = evt.clientX;
  11167. yfenetre = evt.clientY;
  11168. xpage = xfenetre;
  11169. ypage = yfenetre;
  11170. if(evt.pageX) xpage = evt.pageX;
  11171. if(evt.pageY) ypage = evt.pageY;
  11172. if(element) {
  11173. bulleStyle = element.style;
  11174. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11175. element.childNodes[1].firstChild.innerHTML = str;
  11176. }
  11177. if(bulleStyle) {
  11178. if(xfenetre>bulleWidth+offset)
  11179. xpage -= bulleWidth+offset;
  11180. else
  11181. xpage += offset;
  11182. if(yfenetre>hauteur+offset)
  11183. ypage -= hauteur + offset;
  11184. bulleStyle.width = bulleWidth;
  11185. bulleStyle.left = xpage + 'px';
  11186. bulleStyle.top = ypage + 'px';
  11187. bulleStyle.visibility = 'visible';
  11188. }
  11189. }
  11190.  
  11191.  
  11192. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11193.  
  11194. function competences(comp,niveau) {
  11195. var texte = '';
  11196. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11197. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11198. if(minParPV>1) texte += 's';
  11199. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11200. }
  11201. else if(comp.indexOf('Attaque Precise')!=-1) {
  11202. var pc, lastmax=0, espatt=0;
  11203. var notMaxedOut = false;
  11204. for(var i=niveau ; i>0 ; i--) {
  11205. pc = getTalent(comp,i);
  11206. if(lastmax!=0 && pc<=lastmax) continue;
  11207. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11208. attbp+attbm;
  11209. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11210. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11211. ' => <b>'+jetatt+'</b><br/>';
  11212. espatt += (pc-lastmax)*jetatt;
  11213. lastmax = pc;
  11214. if(i<niveau) notMaxedOut = true;
  11215. }
  11216. if(notMaxedOut) {
  11217. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11218. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11219. }
  11220. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11221. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11222. }
  11223. else if(comp.indexOf('Balayage')!=-1)
  11224. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11225. +' => <b>'+attmoy+'</b><br/>'
  11226. +'Effet : <b>Met à terre l\'adversaire</b>';
  11227. else if(comp.indexOf('Bidouille')!=-1)
  11228. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11229. +'de votre inventaire avec le texte de votre choix.';
  11230. else if(comp.indexOf('Baroufle')!=-1){
  11231. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11232. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11233. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11234. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11235. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11236. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11237. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11238. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11239. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11240. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11241. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11242. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11243. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11244. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11245. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11246. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11247. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11248. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11249. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11250. '</tbody></table>';
  11251. }
  11252. else if(comp.indexOf('Botte Secrete')!=-1){
  11253. texte = 'Attaque : <b>'
  11254. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11255. +' => <b>'
  11256. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  11257. +'</b><br/>Dégâts : <b>'
  11258. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  11259. +' => <b>'
  11260. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  11261. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  11262. +'</b>';
  11263. }
  11264. else if(comp.indexOf('Camouflage')!=-1) {
  11265. var camou = getTalent('Camouflage');
  11266. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  11267. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  11268. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  11269. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  11270. }
  11271. else if(comp.indexOf('Charger')!=-1) {
  11272. if(pvcourant<=0)
  11273. return '<i>On ne peut charger personne quand on est mort !</i>';
  11274. var portee = Math.min(
  11275. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  11276. vuetotale);
  11277. if(portee<1)
  11278. return '<b>Impossible de charger</b>';
  11279. else {
  11280. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11281. +' => <b>'+attmoy+'</b><br/>'
  11282. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11283. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  11284. +'<br/>Portée : <b>'+portee+'</b> case';
  11285. if(portee>1) texte += 's';
  11286. }
  11287. }
  11288. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  11289. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  11290. if(vuetotale>1) texte += 's';
  11291. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11292. if(vuetotale>2) texte += 's';
  11293. }
  11294. else if(comp.indexOf('Piege')!=-1) {
  11295. if(comp.indexOf('Glue')!=-1)
  11296. texte = 'Et si vous colliez vos adversaires au sol ?';
  11297. if(comp.indexOf('Feu')!=-1) {
  11298. if(texte){
  11299. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  11300. }
  11301. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  11302. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  11303. }
  11304. }
  11305. else if(comp.indexOf('Contre-Attaquer')!=-1){
  11306. texte = 'Attaque : <b>'
  11307. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11308. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11309. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11310. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11311. }
  11312. else if(comp.indexOf('Coup de Butoir')!=-1) {
  11313. var pc, lastmax=0, espdeg=0;
  11314. var notMaxedOut = false;
  11315. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11316. +' => <b>'+attmoy+'</b>';
  11317. for(var i=niveau ; i>0 ; i--) {
  11318. pc = getTalent(comp,i);
  11319. if(lastmax!=0 && pc<=lastmax) continue;
  11320. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  11321. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11322. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  11323. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  11324. espdeg += (pc-lastmax)*jetdeg;
  11325. lastmax = pc;
  11326. if(i<niveau) notMaxedOut = true;
  11327. }
  11328. if(notMaxedOut) {
  11329. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  11330. Math.floor(10*espdeg/lastmax)/10+'/'+
  11331. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  11332. }
  11333. }
  11334. else if(comp.indexOf('Course')!=-1)
  11335. texte = 'Déplacement gratuit : <b>'
  11336. +Math.floor(getTalent('Course')/2)
  11337. +' %</b> de chance';
  11338. else if(comp.indexOf('Deplacement Eclair')!=-1)
  11339. texte = 'Permet d\'économiser <b>1</b> PA '
  11340. +'par rapport au déplacement classique';
  11341. else if(comp.indexOf('Dressage')!=-1)
  11342. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  11343. +'ou un gnu sauvage.';
  11344. else if(comp.indexOf('Ecriture Magique')!=-1)
  11345. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  11346. +'la formule nécessite de réunir les composants de cette formule, '
  11347. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  11348. +'un champignon adéquat pour confectionner l\'encre.';
  11349. else if(comp.indexOf('Frenesie')!=-1) {
  11350. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11351. +' => <b>'+attmoy+'</b><br/>'
  11352. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11353. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11354. }
  11355. else if(comp.indexOf('Golem')!=-1)
  11356. texte = 'Animez votre golem en assemblant divers matériaux '
  11357. +'autour d\'un cerveau minéral.'
  11358. else if(comp.indexOf('Grattage')!=-1) {
  11359. texte = 'Permet de confectionner un Parchemin Vierge '
  11360. +'à partir de composants et de Gigots de Gob\'.';
  11361. }
  11362. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  11363. texte = 'Fait fuir un monstre si tout se passe bien.'
  11364. +'<br/>Lui donne de gros bonus sinon...';
  11365. else if(comp.indexOf('Identification des Champignons')!=-1) {
  11366. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11367. if(vuetotale>2) texte += 's';
  11368. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  11369. if(vuetotale>4) texte += 's';
  11370. }
  11371. else if(comp.indexOf('Insultes')!=-1)
  11372. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  11373. else if(comp.indexOf('interposer')!=-1)
  11374. texte = 'Jet de réflexe : <b>'
  11375. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  11376. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  11377. else if(comp.indexOf('Lancer de Potions') != -1)
  11378. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  11379. else if(comp.indexOf('Marquage')!=-1)
  11380. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  11381. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  11382. +'se trouver dans la même caverne que le monstre pour le marquer.';
  11383. else if(comp.indexOf('Melange Magique')!=-1)
  11384. texte = 'Cette Compétence permet de combiner deux Potions pour '
  11385. +'en réaliser une nouvelle dont l\'effet est la somme '
  11386. +'des effets des potions initiales.';
  11387. else if(comp.indexOf('Miner')!=-1)
  11388. texte = 'Portée horizontale (officieuse) : <b>'
  11389. +2*vuetotale+'</b> cases<br/>'
  11390. +'Portée verticale (officieuse) : <b>'
  11391. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11392. else if(comp.indexOf('Necromancie')!=-1)
  11393. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  11394. +'de faire "revivre" ce monstre.';
  11395. else if(comp.indexOf('Painthure de Guerre')!=-1)
  11396. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  11397. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  11398. +'pour s\'inspirer, et laissez parler votre créativité.'
  11399. else if(comp.indexOf('Parer')!=-1)
  11400. texte = 'Jet de parade : <b>'
  11401. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  11402. +' => <b>'
  11403. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11404. +'</b><hr><i>Equivalent esquive : <b>'
  11405. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  11406. +' => <b>'
  11407. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  11408. +'</b></i>';
  11409. else if(comp.indexOf('Pistage')!=-1)
  11410. texte = 'Portée horizontale : <b>'
  11411. +2*vuetotale+'</b> cases<br/>'
  11412. +'Portée verticale : <b>'
  11413. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11414. else if(comp.indexOf('Planter un Champignon')!=-1)
  11415. texte = 'Planter un Champignon est une compétence qui vous permet de '
  11416. +'créer des colonies d\'une variété donnée de champignon à partir de '
  11417. +'quelques exemplaires préalablement enterrés.';
  11418. else if(comp.indexOf('Regeneration Accrue')!=-1)
  11419. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  11420. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  11421. else if(comp.indexOf('Reparation')!=-1)
  11422. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  11423. +'et réparez vous-même votre matériel !';
  11424. else if(comp.indexOf('Retraite')!=-1)
  11425. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  11426. +'préférable de préparer un repli stratégique pour déconcerter '
  11427. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  11428. +'Quelle intelligence démoniaque.';
  11429. else if(comp.indexOf('Rotobaffe')!=-1) {
  11430. var Datt = att, vattbm = attbp+attbm;
  11431. var Ddeg = deg, vdegbm = degbp+degbm;
  11432. for(var i=1 ; i<niveau+2 ; i++) {
  11433. texte += '<b>Attaque n°'+i+' :</b><br/>'
  11434. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  11435. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  11436. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  11437. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  11438. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  11439. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  11440. if(i<niveau+1) texte += '<hr>';
  11441. }
  11442. }
  11443. else if(comp.indexOf('Shamaner')!=-1)
  11444. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  11445. +'des monstres en utilisant des champignons (de 1 à 3).';
  11446. else if(comp.indexOf('Tailler')!=-1){
  11447. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11448. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11449. }
  11450. return texte;
  11451. }
  11452.  
  11453. function decumul_buff(nom,str,buff) {
  11454. // Decumul des sorts de buff
  11455. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11456. var dec = buff, total = buff, i=1;
  11457. while(i<6) {
  11458. i++;
  11459. dec = Math.floor(coefDecumul(i)*buff);
  11460. if(dec<=1 || i==6) break;
  11461. total += dec;
  11462. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11463. +str+' +'+dec+' (+'+total+')</i>';
  11464. }
  11465. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11466. return ret;
  11467. }
  11468.  
  11469.  
  11470. function sortileges(sort,mainCall,pcA,pcD) {
  11471. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11472. var texte = '';
  11473. if (mainCall) {
  11474. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11475. pcA = (atttourP+atttourM);
  11476. pcD = (degtourP+degtourM);
  11477. }
  11478. if (sort.indexOf('Analyse Anatomique') != -1) {
  11479. texte = 'Portée horizontale : <b>'
  11480. + Math.floor(vuetotale / 2) + '</b> case';
  11481. if (vuetotale > 3){ texte += 's'; }
  11482. texte += '<br/>Portée verticale : <b>'
  11483. + Math.floor((vuetotale+1)/4)+'</b> case';
  11484. if (vuetotale > 7){ texte += 's'; }
  11485. }
  11486. else if (sort.indexOf('Armure Etheree') != -1){
  11487. texte = decumul_buff('AE', 'Armure magique', reg);
  11488. }
  11489. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11490. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11491. }
  11492. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11493. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11494. }
  11495. else if (sort.indexOf('Augmentation des Degats') != -1){
  11496. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11497. }
  11498. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11499. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11500. }
  11501. else if(sort.indexOf('Bulle Magique')!=-1){
  11502. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11503. }
  11504. else if(sort.indexOf('Explosion')!=-1){
  11505. texte = 'Dégâts : <b>'
  11506. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11507. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11508. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11509. }
  11510. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11511. if(pvcourant<=0)
  11512. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11513. texte = 'Portée horizontale : <b>'
  11514. +Math.min(1,vuetotale)+'</b> case<br/>'
  11515. +'Dégâts physiques : <b>-'
  11516. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11517. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11518. +'Dégâts magiques : <b>-'
  11519. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11520. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11521. }
  11522. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11523. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11524. }
  11525. else if(sort.indexOf('Glue')!=-1) {
  11526. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11527. if(vuetotale>2) texte += 's';
  11528. }
  11529. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11530. /* Frappe */
  11531. var modD = 0;
  11532. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11533. if(pcA!=0){
  11534. modD = parseInt(att*pcA/100);
  11535. texte += '<i>'+aff(modD)+'D6</i> ';
  11536. }
  11537. texte += aff(attbm)
  11538. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11539. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11540. if(pcD!=0) {
  11541. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11542. texte += '<i>'+aff(modD)+'D3</i> ';
  11543. }else
  11544. modD = 0;
  11545. texte += aff(degbm)+' => <b>'
  11546. +(2*(Math.floor(deg/2)+modD)+degbm)
  11547. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11548. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11549. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11550. +')</b>';
  11551. if(!mainCall) return texte;
  11552. /* Venins */
  11553. function addVenin(type,effet,duree) {
  11554. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11555. +' pendant <b>'+duree+'</b> tour';
  11556. if(duree>1) ret += 's';
  11557. var dred = Math.max(Math.floor(duree/2),1);
  11558. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11559. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11560. }
  11561. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11562. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11563. effet = Math.floor(1.5*effet);
  11564. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11565. }
  11566. else if(sort.indexOf('Hypnotisme')!=-1)
  11567. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11568. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11569. else if(sort.indexOf('Identification des tresors')!=-1)
  11570. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11571. +'d\'un trésor.';
  11572. else if(sort.indexOf('Invisibilite')!=-1)
  11573. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11574. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11575. +'fait disparaître l\'invisibilité.';
  11576. else if(sort.indexOf('Levitation')!=-1)
  11577. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11578. +'Comme les pièges ou les trous par exemple...';
  11579. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11580. var eps = 1,
  11581. pc = 20;
  11582. var str = 'PréM';
  11583. var newSort;
  11584. var sortAtt = [
  11585. 'Projectile Magique',
  11586. 'Rafale Psychique',
  11587. 'Siphon des Ames',
  11588. 'Vampirisme',
  11589. 'Griffe du Sorcier'
  11590. ];
  11591. if(sort.indexOf('Puissance')!=-1) {
  11592. eps = -1; str='PuM';
  11593. }
  11594. for(var i=1 ; i<4 ; i++) {
  11595. if(texte) { texte += '<hr>'; }
  11596. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11597. newSort = false;
  11598. for(var j=0 ; j<sortAtt.length ; j++) {
  11599. if(getTalent(sortAtt[j])) {
  11600. if(newSort) { texte += '<br/><br/>'; }
  11601. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  11602. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  11603. newSort = true;
  11604. }
  11605. }
  11606. pc = decumulPumPrem(pc);
  11607. }
  11608. }
  11609. else if(sort.indexOf('Projectile Magique')!=-1) {
  11610. var modD = 0;
  11611. var portee = getPortee__Profil(vuetotale);
  11612. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  11613. if(pcA!=0) {
  11614. modD = parseInt(vue*pcA/100);
  11615. texte += '<i>'+aff(modD)+'D6</i> ';
  11616. }
  11617. texte += aff(attbm)
  11618. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  11619. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  11620. if(pcD!=0) {
  11621. modD = parseInt(Math.floor(vue/2)+pcD);
  11622. texte += '<i>'+aff(modD)+'D3</i> ';
  11623. }else
  11624. modD = 0;
  11625. texte += aff(degbm)
  11626. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  11627. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  11628. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  11629. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  11630. if(!mainCall) return texte;
  11631. texte += '<br/>Portée : <b>'+portee+'</b> case';
  11632. if(portee>1) texte += 's';
  11633. }
  11634. else if(sort.indexOf('Projection')!=-1) {
  11635. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  11636. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  11637. +'Si le jet de résistance de la victime est réussi:<br/>'
  11638. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  11639. }
  11640. else if(sort.indexOf('Rafale Psychique')!=-1) {
  11641. var modD = 0;
  11642. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  11643. if(pcD!=0) {
  11644. modD = parseInt(deg*pcD/100);
  11645. texte += '<i>'+aff(modD)+'D3</i> ';
  11646. }
  11647. texte += aff(degbm)
  11648. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  11649. if(!mainCall) return texte;
  11650. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  11651. }
  11652. else if(sort.indexOf('Sacrifice')!=-1) {
  11653. if(pvcourant<=0)
  11654. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  11655.  
  11656. function perteSacro(sac) {
  11657. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  11658. }
  11659.  
  11660. var sac = Math.floor((pvcourant-1)/2);
  11661. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11662. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  11663. /* Sacros max et optimal sans malus (propale R') */
  11664. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11665. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  11666. if(sac>0)
  11667. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  11668. else
  11669. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  11670. /*if(sac>3) {
  11671. sac = 5*Math.floor((sac+1)/5)-1;
  11672. texte += '<br/>Soin optimal sans malus de temps : <b>'
  11673. +sac+'</b> PV'+perteSacro(sac);
  11674. }*/
  11675. }
  11676. else if(sort.indexOf('Siphon')!=-1) {
  11677. var modD = 0;
  11678. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11679. if(pcA!=0) {
  11680. modD = parseInt(att*pcA/100);
  11681. texte += '<i>'+aff(modD)+'D6</i> ';
  11682. }
  11683. texte += aff(attbm)
  11684. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  11685. +'Dégâts : <b>'+reg+'</b> D3 ';
  11686. if(pcD!=0) {
  11687. modD = parseInt(reg*pcD/100);
  11688. texte += '<i>'+aff(modD)+'D3</i> ';
  11689. }else
  11690. modD = 0;
  11691. texte += aff(degbm)
  11692. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  11693. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  11694. if(!mainCall) return texte;
  11695. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  11696. }
  11697. else if(sort.indexOf('Telekinesie')!=-1) {
  11698. texte = 'Portée horizontale :';
  11699. var vt = Math.floor(vuetotale/2)+2;
  11700. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  11701. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  11702. for(var i=0 ; i<5 ; i++) {
  11703. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  11704. if(vt>1) texte += 's';
  11705. vt=Math.max(0,vt-1);
  11706. }
  11707. }
  11708. else if(sort.indexOf('Teleportation')!=-1) {
  11709. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  11710. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  11711. var pmh = (20+vue+portee);
  11712. var pmv = 3+Math.floor(portee/3);
  11713. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  11714. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  11715. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  11716. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  11717. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  11718. }
  11719. else if(sort.indexOf('Vampirisme')!=-1) {
  11720. var modD = 0;
  11721. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  11722. if(pcA!=0) {
  11723. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  11724. texte += '<i>'+aff(modD)+'D6</i> ';
  11725. }
  11726. texte += aff(attbm)
  11727. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  11728. +'Dégâts : <b>'+deg+'</b> D3 ';
  11729. if(pcD!=0) {
  11730. modD = parseInt(deg*pcD/100);
  11731. texte += '<i>'+aff(modD)+'D3</i> ';
  11732. }else
  11733. modD = 0;
  11734. texte += aff(degbm)
  11735. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  11736. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  11737. }
  11738. else if(sort.indexOf('Vision Accrue')!=-1)
  11739. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  11740. else if(sort.indexOf('Vision lointaine')!=-1)
  11741. texte = 'En ciblant une zone située n\'importe où dans le '
  11742. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  11743. else if(sort.indexOf('Voir le Cache')!=-1)
  11744. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  11745. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  11746. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  11747. +getPortee__Profil(vuetotale)+'</b> cases';
  11748. else if(sort.indexOf('Vue Troublee')!=-1)
  11749. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11750. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  11751. return texte;
  11752. }
  11753.  
  11754.  
  11755. /*---------------------------------- Main ------------------------------------*/
  11756.  
  11757. function do_profil2()
  11758. {
  11759. try {
  11760. start_script(31);
  11761.  
  11762. extractionDonnees();
  11763. setInfosCaracteristiques();
  11764. setInfoDescription();
  11765. setInfosEtatLieux();
  11766. setInfosEtatPV();
  11767. setInfosExp();
  11768.  
  11769. creerBulleVide();
  11770. traitementTalents();
  11771. setLienAnatrolliseur();
  11772.  
  11773. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  11774. if(race=='Kastar'){ setAccel(); }
  11775. saveProfil();
  11776. displayScriptTime();
  11777. } catch(e) {
  11778. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  11779. window.console.error(traceStack(e, 'profil2'));
  11780. }
  11781. }
  11782.  
  11783. /*******************************************************************************
  11784. * This file is part of Mountyzilla. *
  11785. * *
  11786. * Mountyzilla is free software; you can redistribute it and/or modify *
  11787. * it under the terms of the GNU General Public License as published by *
  11788. * the Free Software Foundation; either version 2 of the License, or *
  11789. * (at your option) any later version. *
  11790. * *
  11791. * Mountyzilla is distributed in the hope that it will be useful, *
  11792. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11793. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11794. * GNU General Public License for more details. *
  11795. * *
  11796. * You should have received a copy of the GNU General Public License *
  11797. * along with Mountyzilla; if not, write to the Free Software *
  11798. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11799. *******************************************************************************/
  11800.  
  11801. // x~x script_principal
  11802.  
  11803. function isPage(url) {
  11804. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11805. }
  11806.  
  11807. // x~x md5.js
  11808. /*
  11809. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11810. * Digest Algorithm, as defined in RFC 1321.
  11811. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11812. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11813. * Distributed under the BSD License
  11814. * See http://pajhome.org.uk/crypt/md5 for more info.
  11815. */
  11816.  
  11817. /*
  11818. * Configurable variables. You may need to tweak these to be compatible with
  11819. * the server-side, but the defaults work in most cases.
  11820. */
  11821. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11822. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11823. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11824.  
  11825. /*
  11826. * These are the functions you'll usually want to call
  11827. * They take string arguments and return either hex or base-64 encoded strings
  11828. */
  11829. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11830. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11831. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11832. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11833. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11834. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11835.  
  11836. /*
  11837. * Perform a simple self-test to see if the VM is working
  11838. */
  11839. function md5_vm_test()
  11840. {
  11841. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11842. }
  11843.  
  11844. /*
  11845. * Calculate the MD5 of an array of little-endian words, and a bit length
  11846. */
  11847. function core_md5(x, len)
  11848. {
  11849. /* append padding */
  11850. x[len >> 5] |= 0x80 << ((len) % 32);
  11851. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11852.  
  11853. var a = 1732584193;
  11854. var b = -271733879;
  11855. var c = -1732584194;
  11856. var d = 271733878;
  11857.  
  11858. for(var i = 0; i < x.length; i += 16)
  11859. {
  11860. var olda = a;
  11861. var oldb = b;
  11862. var oldc = c;
  11863. var oldd = d;
  11864.  
  11865. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11866. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11867. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11868. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11869. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11870. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11871. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11872. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11873. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11874. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11875. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11876. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11877. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11878. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11879. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11880. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11881.  
  11882. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11883. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11884. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11885. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11886. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11887. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11888. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11889. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11890. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11891. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11892. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11893. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11894. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11895. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11896. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11897. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11898.  
  11899. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11900. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11901. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11902. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11903. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11904. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11905. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11906. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11907. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11908. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11909. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11910. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11911. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11912. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11913. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11914. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11915.  
  11916. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11917. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11918. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11919. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11920. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11921. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11922. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11923. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11924. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11925. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11926. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11927. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11928. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11929. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11930. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11931. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11932.  
  11933. a = safe_add(a, olda);
  11934. b = safe_add(b, oldb);
  11935. c = safe_add(c, oldc);
  11936. d = safe_add(d, oldd);
  11937. }
  11938. return Array(a, b, c, d);
  11939.  
  11940. }
  11941.  
  11942. /*
  11943. * These functions implement the four basic operations the algorithm uses.
  11944. */
  11945. function md5_cmn(q, a, b, x, s, t)
  11946. {
  11947. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11948. }
  11949. function md5_ff(a, b, c, d, x, s, t)
  11950. {
  11951. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11952. }
  11953. function md5_gg(a, b, c, d, x, s, t)
  11954. {
  11955. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11956. }
  11957. function md5_hh(a, b, c, d, x, s, t)
  11958. {
  11959. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11960. }
  11961. function md5_ii(a, b, c, d, x, s, t)
  11962. {
  11963. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11964. }
  11965.  
  11966. /*
  11967. * Calculate the HMAC-MD5, of a key and some data
  11968. */
  11969. function core_hmac_md5(key, data)
  11970. {
  11971. var bkey = str2binl(key);
  11972. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11973.  
  11974. var ipad = Array(16), opad = Array(16);
  11975. for(var i = 0; i < 16; i++)
  11976. {
  11977. ipad[i] = bkey[i] ^ 0x36363636;
  11978. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11979. }
  11980.  
  11981. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11982. return core_md5(opad.concat(hash), 512 + 128);
  11983. }
  11984.  
  11985. /*
  11986. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11987. * to work around bugs in some JS interpreters.
  11988. */
  11989. function safe_add(x, y)
  11990. {
  11991. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11992. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11993. return (msw << 16) | (lsw & 0xFFFF);
  11994. }
  11995.  
  11996. /*
  11997. * Bitwise rotate a 32-bit number to the left.
  11998. */
  11999. function bit_rol(num, cnt)
  12000. {
  12001. return (num << cnt) | (num >>> (32 - cnt));
  12002. }
  12003.  
  12004. /*
  12005. * Convert a string to an array of little-endian words
  12006. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  12007. */
  12008. function str2binl(str)
  12009. {
  12010. var bin = Array();
  12011. var mask = (1 << chrsz) - 1;
  12012. for(var i = 0; i < str.length * chrsz; i += chrsz)
  12013. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  12014. return bin;
  12015. }
  12016.  
  12017. /*
  12018. * Convert an array of little-endian words to a string
  12019. */
  12020. function binl2str(bin)
  12021. {
  12022. var str = "";
  12023. var mask = (1 << chrsz) - 1;
  12024. for(var i = 0; i < bin.length * 32; i += chrsz)
  12025. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12026. return str;
  12027. }
  12028.  
  12029. /*
  12030. * Convert an array of little-endian words to a hex string.
  12031. */
  12032. function binl2hex(binarray)
  12033. {
  12034. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12035. var str = "";
  12036. for(var i = 0; i < binarray.length * 4; i++)
  12037. {
  12038. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12039. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12040. }
  12041. return str;
  12042. }
  12043.  
  12044. /*
  12045. * Convert an array of little-endian words to a base-64 string
  12046. */
  12047. function binl2b64(binarray)
  12048. {
  12049. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12050. var str = "";
  12051. for(var i = 0; i < binarray.length * 4; i += 3)
  12052. {
  12053. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12054. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12055. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12056. for(var j = 0; j < 4; j++)
  12057. {
  12058. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12059. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12060. }
  12061. }
  12062. return str;
  12063. }
  12064.  
  12065. ///////////////////////////////////////////
  12066. // debug cartes capitan Roule 07/12/2016
  12067. ///////////////////////////////////
  12068. // essais : objet
  12069. // .mode : description
  12070. // .essais : tableau d'objets essai
  12071. // .mode : description
  12072. // .essais : tableau de cartes
  12073. // .noCarte : id de la carte
  12074. // .essais : tableau d'essais, [x, y, n, nb]
  12075. function AfficheEssais(essais, sMode) {
  12076. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12077. if (!eBigDiv) {
  12078. var insertPoint = document.getElementById('footer1');
  12079. eBigDiv = document.createElement('table');
  12080. eBigDiv.id = 'ListeEssaiCapitan';
  12081. insertBefore(insertPoint, document.createElement('p'));
  12082. insertTitle(insertPoint,'Capitan : Liste des essais');
  12083. insertBefore(insertPoint, eBigDiv);
  12084. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12085. }
  12086. if (!essais) {
  12087. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12088. return;
  12089. }
  12090. var carte;
  12091. for (carte in essais) {
  12092. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12093. }
  12094. if (carte === undefined) {
  12095. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12096. }
  12097. }
  12098.  
  12099. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12100. var tr = appendTr(eTable);
  12101. var td = appendTd(tr);
  12102. appendText(td, sMode, bBold);
  12103. td = appendTd(tr);
  12104. appendText(td, sCarte, bBold);
  12105. td = appendTd(tr);
  12106. appendText(td, sText, bBold);
  12107. }
  12108.  
  12109. function getEssaiV1_0() {
  12110. try {
  12111. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12112. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12113. var tabK, nK;
  12114. prefs.getChildList('', nK, tabK);
  12115. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12116. //window.console.log('getEssaiV1_0, ' + nK);
  12117. return;
  12118. //return r;
  12119. } catch (e) {
  12120. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12121. }
  12122. }
  12123.  
  12124. function getEssaiV1_1() {
  12125. var locSto = window.localStorage;
  12126. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12127. var r = [];
  12128. for (var i = 0; i < locSto.length; i++) {
  12129. var k = locSto.key(i);
  12130. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12131. var t = k.split(/\./);
  12132. if (t[0] !== 'capitan') continue;
  12133. if (t[2] !== 'essai') continue;
  12134. var carte = 'carte n°' + t[1];
  12135. if (r[carte]) r[carte]++;
  12136. else r[carte] = 1;
  12137. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12138. }
  12139. return r;
  12140. }
  12141.  
  12142. function showEssaiCartes() {
  12143. window.console.log('début showEssai Tout_MZ');
  12144. var essais = getEssaiV1_0();
  12145. AfficheEssais(essais, 'V1.0');
  12146. essais = getEssaiV1_1();
  12147. AfficheEssais(essais, 'V1.1');
  12148. window.console.log('fin showEssai Tout_MZ');
  12149. }
  12150.  
  12151. function testBoolLocalStorage() {
  12152. var b = true;
  12153. var key = 'MZ_essai_bool';
  12154. GM_setValue(key, b);
  12155. window.localStorage[key] = b;
  12156. var v = GM_getValue(key);
  12157. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12158. var v = window.localStorage.getItem(key);
  12159. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12160.  
  12161. var b = false;
  12162. GM_setValue(key, b);
  12163. window.localStorage[key] = b;
  12164. var v = GM_getValue(key);
  12165. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12166. var v = window.localStorage.getItem(key);
  12167. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12168.  
  12169. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12170. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12171. var y = GM_getValue('654654897894654654');
  12172. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12173. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12174. }
  12175.  
  12176. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12177. function export_trolligion() {
  12178. try {
  12179. var tabDl = document.getElementsByTagName('dl');
  12180. if ((!tabDl) || !tabDl[0]) {
  12181. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12182. return;
  12183. }
  12184. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12185. // nom : string
  12186. // rayonnement : entier
  12187. // grades : table d'objets (une occurence par grade)
  12188. // nom : string
  12189. // trolls : table d'objets (un par Trõll)
  12190. // id
  12191. // nom
  12192. // idguilde
  12193. // guilde
  12194. // race
  12195. // niveau
  12196. // ferveur
  12197. var currentDieu;
  12198. var currentGrade;
  12199. for (var iChild1 in tabDl[0].children) {
  12200. var eChild1 = tabDl[0].children[iChild1];
  12201. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12202. case 'dd': // Trõll
  12203. var oTroll = {};
  12204. var tabFigcaption = eChild1.getElementsByTagName('figcaption');
  12205. if ((!tabFigcaption) || !tabFigcaption[0]) {
  12206. window.console.log('[MZ ' + GM_info.script.version + '] ignore dd sans figcaption ' + eChild1.innerHTML);
  12207. break;
  12208. }
  12209. for (var iChild2 in tabFigcaption[0].childNodes) { // childNodes pour obtenir les éléments texte aussi
  12210. var eChild2 = tabFigcaption[0].childNodes[iChild2];
  12211. if (eChild2.nodeType === undefined) continue; // properties
  12212. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  12213. switch (eChild2.nodeType) {
  12214. case 1: //ELEMENT_NODE:
  12215. switch (eChild2.nodeName.toLowerCase()) {
  12216. case 'a':
  12217. var m;
  12218. if (!eChild2.href) {
  12219. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  12220. break;
  12221. }
  12222. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  12223. if (m) {
  12224. oTroll.id = parseInt(m[1]);
  12225. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  12226. break;
  12227. }
  12228. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  12229. if (m) {
  12230. var idGuilde = parseInt(m[1]);
  12231. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  12232. oTroll.idguilde = parseInt(m[1]);
  12233. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  12234. }
  12235. break;
  12236. }
  12237. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  12238. break;
  12239. case 'br': // ignore
  12240. case 'style': // ignore
  12241. break;
  12242. case 'div': // barre de vie
  12243. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  12244. eChild3 = eChild2.children[0];
  12245. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  12246. var eChild4 = eChild3.children[0];
  12247. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  12248. break;
  12249. }
  12250. }
  12251. // pas de break pour bénéficier du log ci-dessous
  12252. default:
  12253. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  12254. break;
  12255. }
  12256. break;
  12257. case 3: //TEXT_NODE:
  12258. var txt = eChild2.nodeValue.trim();
  12259. if (txt === '') break;
  12260. var m = txt.match(/(.*) *\((\d+)\)/);
  12261. if (m) {
  12262. oTroll.race = m[1].trim();
  12263. oTroll.niveau = parseInt(m[2]);
  12264. } else {
  12265. oTroll.race = txt;
  12266. }
  12267. break;
  12268. default: // ne devrait pas arriver
  12269. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  12270. break;
  12271. }
  12272. }
  12273. currentGrade.trolls.push(oTroll);
  12274. break;
  12275. case 'dt':
  12276. var tabH3 = eChild1.getElementsByTagName('h3');
  12277. if (tabH3 && tabH3[0]) { // changement de dieu
  12278. currentDieu = {
  12279. nom: tabH3[0].innerText || tabH3[0].textContent
  12280. , grades: []};
  12281. var txt = eChild1.innerText || eChild1.textContent;
  12282. var m = txt.match(/yon*ement *:* *(\d+)/);
  12283. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12284. currentGrade = undefined;
  12285. tabDieux.push(currentDieu);
  12286. break;
  12287. }
  12288. var tabH4 = eChild1.getElementsByTagName('h4');
  12289. if (tabH4 && tabH4[0]) { // changement de grade
  12290. var grade;
  12291. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12292. tabI = tabH4[0].getElementsByTagName('i');
  12293. if (tabI && tabI[0]) {
  12294. grade = tabI[0].innerText || tabI[0].textContent;
  12295. grade = grade.replace(/"/g, '');
  12296. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12297. if (m) grade += ' (' + m[1] + ')';
  12298. } else {
  12299. grade = txt.replace(/"/g, '');
  12300. }
  12301. currentGrade = {nom: grade, trolls: []};
  12302. currentDieu.grades.push(currentGrade);
  12303. break;
  12304. }
  12305. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12306. break;
  12307. default:
  12308. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12309. }
  12310. }
  12311.  
  12312. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12313. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12314. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12315. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12316. for (var iDieu in tabDieux) {
  12317. var oDieu = tabDieux[iDieu];
  12318. for (var iGrade in oDieu.grades) {
  12319. var oGrade = oDieu.grades[iGrade];
  12320. for (var iTroll in oGrade.trolls) {
  12321. var oTroll = oGrade.trolls[iTroll];
  12322. var t = [oDieu.nom, oDieu.rayonnement
  12323. , oGrade.nom
  12324. , oTroll.id, oTroll.nom
  12325. , oTroll.idguilde, oTroll.guilde
  12326. , oTroll.race, oTroll.niveau
  12327. , oTroll.ferveur];
  12328. for (var iParam in t) {
  12329. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12330. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12331. }
  12332. txt += t.join("\t") + "\n";
  12333. }
  12334. }
  12335. var t = [oDieu.nom, oDieu.rayonnement];
  12336. for (var iParam in t) {
  12337. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12338. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12339. }
  12340. txt2 += t.join("\t") + "\n";
  12341. }
  12342. txt += "\n" + txt2;
  12343. } catch (e) {
  12344. window.alert("Échec à l'extraction\n" + e);
  12345. }
  12346. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  12347. try {
  12348. if (copyTextToClipboard(txt)) {
  12349. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  12350. + "Collez dans Calc\n"
  12351. + "ou, au pire, dans EXCEL®");
  12352. } else {
  12353. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  12354. }
  12355. } catch(e) {
  12356. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  12357. }
  12358. }
  12359.  
  12360. function do_trolligion() {
  12361. var divpopup = document.createElement('div');
  12362. divpopup.id = 'MZ_divCopier';
  12363. divpopup.style.position = 'fixed';
  12364. divpopup.style.top = '2px';
  12365. divpopup.style.left = '2px;';
  12366. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  12367. divpopup.style.cursor = 'pointer';
  12368. divpopup.style.zIndex = 200;
  12369. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  12370. divpopup.onclick = export_trolligion;
  12371. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  12372. divpopup.appendChild(img);
  12373. document.body.appendChild(divpopup);
  12374. }
  12375.  
  12376. /*--------------------------------- Dispatch ---------------------------------*/
  12377.  
  12378. //chargerScriptDev("libs");
  12379. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  12380. //if (isDEV) testBoolLocalStorage();
  12381.  
  12382. // Détection de la page à traiter
  12383. if(isPage("Messagerie/ViewMessageBot")) {
  12384. do_cdmbot();
  12385. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  12386. do_cdmcomp();
  12387. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  12388. do_cdmcomp();
  12389. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  12390. do_cdmcomp();
  12391. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  12392. do_diplo();
  12393. } else if(isPage("MH_Play/Play_equipement")) {
  12394. do_equip();
  12395. } else if(isPage("MH_Play/Play_menu")) {
  12396. do_menu();
  12397. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  12398. do_option();
  12399. //showEssaiCartes();
  12400. } else if(isPage("View/PJView")) {
  12401. do_pjview();
  12402. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  12403. do_profil();
  12404. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  12405. do_tancompo();
  12406. } else if(isPage("MH_Play/Play_vue")) {
  12407. do_vue();
  12408. } else if(isPage("MH_Play/Play_news")) {
  12409. do_news();
  12410. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  12411. do_move();
  12412. } else if(isPage("MH_Missions/Mission_Etape")) {
  12413. do_mission();
  12414. } else if(isPage("View/MonsterView")) {
  12415. do_infomonstre();
  12416. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  12417. do_attaque();
  12418. } else if(isPage("MH_Play/Play_e_follo.php")) {
  12419. do_listegowap();
  12420. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  12421. do_lieuDescription();
  12422. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  12423. do_lieuTeleport();
  12424. } else if(isPage("MH_Follower/FO_Ordres")) {
  12425. do_ordresgowap();
  12426. } else if(isPage("MH_Follower/FO_Equipement")) {
  12427. do_equipgowap();
  12428. } else if(isPage("MH_Play/Play_mouche")) {
  12429. do_mouches();
  12430. } else if(isPage("MH_Play/Play_BM")) {
  12431. do_malus();
  12432. } else if(isPage("MH_Play/Play_evenement")) {
  12433. do_myevent();
  12434. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  12435. do_enchant();
  12436. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  12437. do_pre_enchant();
  12438. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  12439. do_actions();
  12440. } 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')) {
  12441. do_mission_liste();
  12442. } else if(isPage('MH_Play/Play_action')) {
  12443. do_actions();
  12444. } else if(isPage('MH_Play/Play_profil2')) {
  12445. do_profil2();
  12446. } else if(isPage('View/TrolligionView.php')) {
  12447. do_trolligion();
  12448. }
  12449. } catch(e) {
  12450. try {
  12451. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  12452. } catch(e2) {
  12453. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  12454. }
  12455. }