Tout_MZ

Client MountyZilla

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

  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.3
  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.3 04/04/2017",
  37. " Messages console en cas de cadre d'erreur",
  38. " Trolls de l'IT mais pas dans le vue en orange",
  39. "V1.2.17.2 20/03/2017",
  40. " Correction des PV restants",
  41. "V1.2.17.1 20/03/2017",
  42. " Blocage des PV restants en attendant résolution de bug",
  43. "V1.2.17 19/03/2017",
  44. " Refonte de l'envoi des CdM",
  45. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  46. "V1.2.16.4 08/03/2017",
  47. " correction ID de troll en envoi de PX/MP",
  48. "V1.2.16.3 27/02/2017",
  49. " correction bonus/malus FP",
  50. "V1.2.16.2 24/02/2017",
  51. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  52. "V1.2.16.1 21/02/2017",
  53. " corrige bug sur Fx 38.8 ESR",
  54. "V1.2.16 21/02/2017",
  55. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  56. " possibilité de masquer les Gowaps Sauvages dans la vue",
  57. " calcul des caractéristiques du siphon des âmes",
  58. "V1.2.15.2 02/02/2017",
  59. " adaptation décumul VlC (page des bonus/malus)",
  60. "V1.2.15.1 29/01/2017",
  61. " carte sur la page de description du lieu TP",
  62. "V1.2.15 25/01/2017",
  63. " mise en place des nouvelles cartes (suivants, TP)",
  64. "V1.2.14.3 25/01/2017",
  65. " résumé dans l'export des données Trõlligion",
  66. "V1.2.14.2 20/01/2017",
  67. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  68. "V1.2.14.1 20/01/2017",
  69. " réécriture filtrage des monstres par niveau dans la vue",
  70. " Changelog dans la page des news MZ",
  71. "V1.2.14 20/01/2017",
  72. " Ajout de l'export des données Trõlligion",
  73. "V1.2.13.7 10/01/2017",
  74. " Exclusion Bricoll'troll dans l'entête GM",
  75. "V1.2.13.6 08/01/2017",
  76. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  77. "V1.2.13.5 07/01/2017",
  78. " Correction bug qui se manisfestait sous LINUX",
  79. "V1.2.13.4 07/01/2017",
  80. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  81. "V1.2.13.3 07/01/2017",
  82. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  83. "V1.2.13.2 07/01/2017",
  84. " Correction missions, recherche troogle (familles et types de monstres)",
  85. "V1.2.13.1 06/01/2017",
  86. " Suppression oldSchoolProfile qui n'existe plus",
  87. " Ajout du 'refresh' du cadre de gauche",
  88. "V1.2.13 01/01/2017",
  89. " homogénéisation des messages d'erreur",
  90. " Ajout du lien Troogle sur les étapes de mission monstre",
  91. "V1.2.12.2 30/12/2016",
  92. " retour en mode normal (http si jeu en http)",
  93. "V1.2.12.1 27/12/2016",
  94. " Correction mode IP",
  95. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  96. "V1.2.12 24/12/2016",
  97. " Nettoyage des URL",
  98. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  99. " Interface bricoll'Troll en https",
  100. " Remise en marche des cartes des trajets des gowaps",
  101. "V1.2.11.5 à 7 20 & 21/12/2016",
  102. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  103. "V1.2.11.4 19/12/2016",
  104. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  105. "V1.2.11.3 19/12/2016",
  106. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  107. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  108. "V1.2.11.2 18/12/2016",
  109. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  110. "V1.2.11.1 17/12/2016",
  111. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  112. "V1.2.11 13/12/2016",
  113. " Passage sur BdD Raistlin \\o/",
  114. "V1.2.10.4 12/12/2016",
  115. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  116. "V1.2.10.3 09/12/2016",
  117. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  118. "V1.2.10.2 09/12/2016",
  119. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  120. "V1.2.10.1 08/12/2016",
  121. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  122. "V1.2.10 07/12/2016",
  123. " correction décumul des bonus/malus",
  124. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  125. "V1.2.9 16/11/2016",
  126. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  127. "V1.2.8 10/11/2016",
  128. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  129. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  130. "V1.2.7 07/11/2016",
  131. " remise en route de l'interface avec l'IT bricol'Troll",
  132. "V1.2.6 19/10/2016",
  133. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  134. " stockage idguilde et nomguilde",
  135. "V1.2.5 17/10/2016",
  136. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  137. " remise en route de la gestion des options avec intégration md5 dans ce script",
  138. "V1.2.4 14/10/2016",
  139. " utilisation du relai raistlin pour l'envoi des CdM",
  140. "V1.2.3 :",
  141. " suppression ancien profil",
  142. " nettoyage doublon sur getPortee",
  143. " adaptation portee TP basée sur les PI",
  144. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  145. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  146. "V1.2.1 :",
  147. " include des URLs MH alternatives",
  148. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  149. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  150. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  151. "V1.1 : regroupement en un gros paquet sale",
  152. ];
  153.  
  154. /**********************************************************
  155. À faire / propositions d'évolutions
  156.  
  157. breizhou13 20/12/2016
  158. envoyer les données à l'IT (Bricol'Trolls) aussi
  159. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  160. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  161. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  162. Akkila le boeuf le 26-03-2017 à 15:56
  163. - bouton pour rafraîchir les infos des trolls de son groupe
  164. - (ajout de Roule') ne pas afficher
  165. Roule'
  166. Réactiver les jubilaires
  167. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  168. Traces console à l'affichage des cadres d'info MZ
  169. (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)
  170. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  171. - voir l'intérêt de refaire fonctionner
  172. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  173. Prévision des DLA de monstre
  174. Niveau des monstres à la méthode Roule'
  175. Raistlin
  176. pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  177. **********************************************************/
  178.  
  179. /**********************************************************
  180. **** Début de zone à déplacer dans une bibli commune ******
  181. **********************************************************/
  182.  
  183. // URL de base serveur MZ
  184. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  185. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  186. //var URL_MZ = 'http://192.99.225.92/mz';
  187.  
  188. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  189. // à supprimer
  190. const newCarte = true;
  191. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  192.  
  193. // URLs externes redirection (pas de souci CORS)
  194. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  195. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  196. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  197. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  198. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  199. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  200. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  201. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  202. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  203.  
  204. // URLs de test HTTPS
  205. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  206. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  207.  
  208. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  209. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  210. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  211.  
  212. // x~x Libs
  213.  
  214. /* ancien TODO
  215. * - revoir la gestion des CdM --> nott armure magique
  216. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  217. * - vérfier la gestion des enchants
  218. */
  219.  
  220. // Roule 04/09/2016 switch extern URLs to https if available
  221. var isHTTPS = false;
  222. if (window.location.protocol.indexOf('https') === 0) {
  223. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  224. URL_bricol = URL_bricol_https;
  225. isHTTPS = true;
  226. }
  227.  
  228. // Roule 23/12/2016 mode dev
  229. var isDEV = false;
  230. if (window.localStorage.getItem('MZ_dev') || window.location.href.indexOf('rouletabille.mh.free.fr') > 0) {
  231. URL_MZ = URL_MZ.replace(/$/, 'dev');
  232. isDEV = true;
  233. }
  234.  
  235. // Images (pas de souci CORS)
  236. var URL_MZimg = URL_MZ + '/img/';
  237. // URLs externes ajax (CORS OK)
  238. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  239. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  240.  
  241. // liens externes détuits
  242. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  243. var MHicons = '/mountyhall/Images/Icones/';
  244. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  245. var MY_DEBUG = false;
  246.  
  247. if (GM_getValue === undefined) { // éviter le blocage si pas sous GM
  248. window.console.log('*** warning *** GM_getValue n\'est pas défini (c\'est normal en test de compilation)');
  249. var GM_getValue = function(key) {};
  250. var GM_setValue = function(key, val) {};
  251. var GM_deleteValue = function(key) {};
  252. }
  253.  
  254. /* Utilisation de la gestion de l'enregistrement des données de
  255. GreaseMonkey, avec partage entre scripts via le localStorage, par
  256. Vapulabehemot (82169) 07/02/2017 */
  257. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  258. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  259. function MY_getValue(key) {
  260. var v = window.localStorage.getItem(key);
  261. vGM = GM_getValue(key);
  262. if ((vGM == null)
  263. || (v != null && v != vGM)){
  264. GM_setValue(key, v);
  265. } else if (v == null && vGM != null) {
  266. v = vGM;
  267. window.localStorage[key] = vGM;
  268. }
  269. return v;
  270. }
  271. function MY_removeValue(key) {
  272. GM_deleteValue(key);
  273. window.localStorage.removeItem(key);
  274. }
  275. function MY_setValue(key, val) {
  276. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  277. val = 1;
  278. else if (val === false)
  279. val = 0;
  280. GM_setValue(key, val);
  281. window.localStorage[key] = val;
  282. }
  283.  
  284. /*---------------- mise à jour de variables globales utiles ------------------*/
  285. // utilisé pour accès bdd (un peu partout) :
  286. var numTroll = MY_getValue('NUM_TROLL');
  287. // utilisé dans vue pour PX :
  288. var nivTroll = MY_getValue('NIV_TROLL');
  289. // utilisés dans actions et vue (calculs SR) :
  290. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  291. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  292. var currentURL = window.location.href;
  293.  
  294. /*-[functions]------------ Fonctions durée de script -------------------------*/
  295. var date_debut = null;
  296.  
  297. function start_script(nbJours_exp) {
  298. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  299. if(date_debut) return;
  300. date_debut = new Date();
  301. // Créé la variable expdate si demandé
  302. if(nbJours_exp) {
  303. expdate = new Date();
  304. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  305. }
  306. }
  307.  
  308. function displayScriptTime() {
  309. var footerNode = document.getElementById('footer2');
  310. if(!footerNode) return;
  311. try{
  312. var node = document.evaluate(
  313. ".//text()[contains(.,'Page générée en')]/../br",
  314. footerNode,null,9,null).singleNodeValue;
  315. }
  316. catch(e){return;}
  317. insertText(node,
  318. ' - [Script exécuté en '
  319. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  320. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  321. }
  322.  
  323. function traceStack(e, sModule) {
  324. var version = '';
  325. if (GM_info && GM_info.script && GM_info.script.version)
  326. version = ' ' + GM_info.script.version;
  327. sRet = '[MZ' + version + ']'
  328. if (sModule) sRet += ' {' + sModule + '}';
  329. if (e.message) sRet += ' ' + e.message;
  330. if (e.stack) {
  331. var sStack = e.stack;
  332. // enlever les infos confidentielles
  333. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  334. }
  335. return sRet;
  336. }
  337.  
  338. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  339.  
  340. function debugMZ(str){
  341. if(MY_DEBUG){
  342. window.console.debug('[MY_DEBUG] '+str);
  343. if(typeof str === "object"){
  344. window.console.debug(str);
  345. }
  346. }
  347. }
  348.  
  349. function FF_XMLHttpRequest(MY_XHR_Ob) {
  350. var request = new XMLHttpRequest();
  351. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  352. for(var head in MY_XHR_Ob.headers) {
  353. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  354. }
  355. request.onreadystatechange = function() {
  356. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  357. if(request.readyState!=4) { return; }
  358. if(request.error) {
  359. if(MY_XHR_Ob.onerror) {
  360. MY_XHR_Ob.onerror(request);
  361. }
  362. }
  363. else if(MY_XHR_Ob.onload) {
  364. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  365. MY_XHR_Ob.onload(request);
  366. }
  367. };
  368. request.send(MY_XHR_Ob.data);
  369. }
  370.  
  371.  
  372. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  373.  
  374. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  375. function copyTextToClipboard(text) {
  376. var textArea = document.createElement("textarea");
  377.  
  378. //
  379. // *** This styling is an extra step which is likely not required. ***
  380. //
  381. // Why is it here? To ensure:
  382. // 1. the element is able to have focus and selection.
  383. // 2. if element was to flash render it has minimal visual impact.
  384. // 3. less flakyness with selection and copying which **might** occur if
  385. // the textarea element is not visible.
  386. //
  387. // The likelihood is the element won't even render, not even a flash,
  388. // so some of these are just precautions. However in IE the element
  389. // is visible whilst the popup box asking the user for permission for
  390. // the web page to copy to the clipboard.
  391. //
  392.  
  393. // Place in top-left corner of screen regardless of scroll position.
  394. textArea.style.position = 'fixed';
  395. textArea.style.top = 0;
  396. textArea.style.left = 0;
  397.  
  398. // Ensure it has a small width and height. Setting to 1px / 1em
  399. // doesn't work as this gives a negative w/h on some browsers.
  400. textArea.style.width = '2em';
  401. textArea.style.height = '2em';
  402.  
  403. // We don't need padding, reducing the size if it does flash render.
  404. textArea.style.padding = 0;
  405.  
  406. // Clean up any borders.
  407. textArea.style.border = 'none';
  408. textArea.style.outline = 'none';
  409. textArea.style.boxShadow = 'none';
  410.  
  411. // Avoid flash of white box if rendered for any reason.
  412. textArea.style.background = 'transparent';
  413.  
  414. textArea.value = text;
  415.  
  416. document.body.appendChild(textArea);
  417.  
  418. textArea.select();
  419.  
  420. var successful = document.execCommand('copy');
  421.  
  422. document.body.removeChild(textArea);
  423. return successful;
  424. }
  425.  
  426. function avertissement(txt,duree) {
  427. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  428. if(!duree) duree = 15000;
  429. var div = document.createElement('div');
  430. // On numérote les avertissements pour destruction sélective
  431. var num = document.getElementsByName('avertissement').length;
  432. div.num = num;
  433. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  434. div.setAttribute('name','avertissement');
  435. div.className = 'mh_textbox';
  436. div.style.position = 'fixed';
  437. div.style.top = (10+15*num)+'px';
  438. div.style.left = (10+5*num)+'px';
  439. div.style.border = '5px solid red';
  440. div.style.zIndex = 2+num;
  441. div.style.cursor = 'pointer';
  442. div.style.fontSize = 'large';
  443. div.innerHTML = txt;
  444. div.onclick=function(){ tueAvertissement(this.num) };
  445.  
  446. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  447. var divcroix = document.createElement('div');
  448. divcroix.style.position = 'absolute';
  449. divcroix.style.top = 0;
  450. divcroix.style.right = 0;
  451. divcroix.style.color = 'black';
  452. divcroix.style.fontSize = 'inherit';
  453. divcroix.style.cursor = 'pointer'
  454. divcroix.style.zIndex = 2+num;
  455. divcroix.innerHTML = "X";
  456. div.appendChild(divcroix);
  457.  
  458. document.body.appendChild(div);
  459. // Destruction automatique de l'avertissement après "un certain temps"
  460. window.setTimeout(function(){ tueAvertissement(num) },duree);
  461. }
  462.  
  463. function tueAvertissement(num) {
  464. var divs = document.getElementsByName('avertissement');
  465. if(divs.length==0) { return; }
  466. for(var i=0 ; i<divs.length ; i++) {
  467. if(divs[i].num==num) {
  468. divs[i].parentNode.removeChild(divs[i]);
  469. return;
  470. }
  471. }
  472. }
  473.  
  474.  
  475. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  476.  
  477. function insertBefore(next,el) {
  478. next.parentNode.insertBefore(el,next);
  479. }
  480.  
  481. function appendTr(tbody,clas) {
  482. var tr = document.createElement('tr');
  483. if(clas) tr.className = clas;
  484. tbody.appendChild(tr);
  485. return tr;
  486. }
  487.  
  488. function insertTr(next,clas) {
  489. var tr = document.createElement('tr');
  490. if(clas) tr.className = clas;
  491. insertBefore(next,tr);
  492. return tr;
  493. }
  494.  
  495. function appendTd(tr) {
  496. var td = document.createElement('td');
  497. if(tr) tr.appendChild(td);
  498. return td;
  499. }
  500.  
  501. function insertTd(next) {
  502. var td = document.createElement('td');
  503. insertBefore(next,td);
  504. return td;
  505. }
  506.  
  507. function appendTdCenter(tr,colspan) {
  508. var td = appendTd(tr);
  509. td.align = 'center'; // WARNING - Obsolete
  510. if(colspan) td.colSpan = colspan;
  511. return td;
  512. }
  513.  
  514. function insertTdElement(next,el) {
  515. var td = insertTd(next);
  516. if(el) td.appendChild(el);
  517. return td;
  518. }
  519.  
  520. function appendA(paren,href,cssClass,text) {
  521. var a = document.createElement('a');
  522. if (href) a.href = href;
  523. if (cssClass) a.className = cssClass;
  524. if (text) a.appendChild(document.createTextNode(text));
  525. paren.appendChild(a);
  526. }
  527.  
  528. function appendText(paren,text,bold) {
  529. if(bold) {
  530. var b = document.createElement('b');
  531. b.appendChild(document.createTextNode(text));
  532. paren.appendChild(b);
  533. }
  534. else
  535. paren.appendChild(document.createTextNode(text));
  536. }
  537.  
  538. function insertText(next,text,bold) {
  539. if(bold) {
  540. var b = document.createElement('b');
  541. appendText(b,text);
  542. insertBefore(next,b);
  543. }
  544. else
  545. insertBefore(next,document.createTextNode(text));
  546. }
  547.  
  548. function appendTdText(tr,text,bold) {
  549. var td = appendTd(tr);
  550. appendText(td,text,bold);
  551. return td;
  552. }
  553.  
  554. function insertTdText(next,text,bold) {
  555. var td = insertTd(next);
  556. appendText(td,text,bold);
  557. return td;
  558. }
  559.  
  560. function appendBr(paren) {
  561. paren.appendChild(document.createElement('br'));
  562. }
  563.  
  564. function insertBr(next) {
  565. insertBefore(next,document.createElement('br'));
  566. }
  567.  
  568. function appendLI(ul,text) {
  569. // uniquement utilisé dans les options (crédits)
  570. var li = document.createElement('li');
  571. appendText(li,text);
  572. ul.appendChild(li);
  573. return li;
  574. }
  575.  
  576. function appendTextbox(paren,type,nam,size,maxlength,value) {
  577. var input = document.createElement('input');
  578. input.className = 'TextboxV2';
  579. input.type = type;
  580. input.name = nam;
  581. input.id = nam;
  582. input.size = size;
  583. input.maxLength = maxlength;
  584. if(value) input.value = value;
  585. paren.appendChild(input);
  586. return input;
  587. }
  588.  
  589. function appendCheckBox(paren,nam,checked,onClick) {
  590. var input = document.createElement('input');
  591. input.type = 'checkbox';
  592. input.name = nam;
  593. input.id = nam;
  594. if(checked) input.checked = true;
  595. if(onClick) input.onclick = onClick;
  596. paren.appendChild(input);
  597. return input;
  598. }
  599.  
  600. function appendNobr(paren,id,delgg,text) {
  601. var nobr = document.createElement('nobr');
  602. appendCheckBox(nobr,id,null,delgg);
  603. appendText(nobr,text);
  604. paren.appendChild(nobr);
  605. appendText(paren,' ');
  606. return nobr;
  607. }
  608.  
  609. function appendCheckBoxSpan(paren,id,onClick,text) {
  610. var span = document.createElement('span');
  611. span.style.whiteSpace = 'nowrap';
  612. appendCheckBox(span,id,false,onClick);
  613. var label = document.createElement('label');
  614. appendText(label,text);
  615. label.htmlFor = id;
  616. label.style.marginLeft = '-5px';
  617. span.appendChild(label);
  618. span.style.marginRight = '3px';
  619. paren.appendChild(span);
  620. appendText(paren, ' ');
  621. return span;
  622. }
  623.  
  624. function appendOption(select,value,text) {
  625. var option = document.createElement('option');
  626. option.value = value;
  627. appendText(option,text);
  628. select.appendChild(option);
  629. return option;
  630. }
  631.  
  632. function appendHidden(form,nam,value) {
  633. var input = document.createElement('input');
  634. input.type = 'hidden';
  635. input.name = nam;
  636. input.id = nam;
  637. input.value = value;
  638. form.appendChild(input);
  639. }
  640.  
  641. function appendButton(paren,value,onClick) {
  642. var input = document.createElement('input');
  643. input.type = 'button';
  644. input.className = 'mh_form_submit';
  645. input.value = value;
  646. input.onmouseover = function(){this.style.cursor='pointer';};
  647. if(onClick) input.onclick = onClick;
  648. paren.appendChild(input);
  649. return input;
  650. }
  651.  
  652. function insertButton(next,value,onClick) {
  653. var input = document.createElement('input');
  654. input.type = 'button';
  655. input.className = 'mh_form_submit';
  656. input.value = value;
  657. input.onmouseover = function(){this.style.cursor='pointer';};
  658. input.onclick = onClick;
  659. insertBefore(next,input);
  660. return input;
  661. }
  662.  
  663. function appendSubmit(paren,value,onClick) {
  664. var input = document.createElement('input');
  665. input.type = 'submit';
  666. input.className = 'mh_form_submit';
  667. input.value = value;
  668. input.onmouseover = function(){this.style.cursor='pointer';};
  669. if(onClick) input.onclick = onClick;
  670. paren.appendChild(input);
  671. return input;
  672. }
  673.  
  674. function createImage(url,title) {
  675. var img = document.createElement('img');
  676. img.src = url;
  677. img.title = title;
  678. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  679. return img;
  680. }
  681.  
  682. function createAltImage(url,alt,title) {
  683. var img = document.createElement('img');
  684. img.src = url;
  685. img.alt = alt;
  686. if (title) img.title = title;
  687. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  688. return img;
  689. }
  690.  
  691. function createImageSpan(url,alt,title,text,bold) {
  692. var span = document.createElement('span');
  693. span.title = title;
  694. var img = document.createElement('img');
  695. img.src = url;
  696. img.alt = alt;
  697. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  698. span.appendChild(img);
  699. appendText(span,text,bold);
  700. return span;
  701. }
  702.  
  703. function createCase(titre,table,width) {
  704. if(!width) width=120;
  705. var tr = appendTr(table,'mh_tdpage');
  706. var td = appendTdText(tr,titre,true);
  707. td.className = 'mh_tdtitre';
  708. td.width = width;
  709. td = appendTdText(tr,'');
  710. td.className = 'mh_tdpage';
  711. return td;
  712. }
  713.  
  714. function getMyID(e) {
  715. var parent = e.parentNode;
  716. for(var i=0 ; i<parent.childNodes.length ; i++) {
  717. if(e==parent.childNodes[i])
  718. return i;
  719. }
  720. return -1;
  721. }
  722.  
  723. function insertAfter(elt,newElt) {
  724. var id = getMyID(elt);
  725. if(id==-1) return;
  726. if(id<elt.parentNode.childNodes.length-1)
  727. insertBefore(elt.nextSibling,newElt);
  728. else
  729. elt.parentNode.appendChild(newElt);
  730. }
  731.  
  732.  
  733. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  734.  
  735. function aff(nb) {
  736. return (nb>=0) ? '+'+nb : nb;
  737. }
  738.  
  739. function getNumber(str) {
  740. var nbr = str.match(/\d+/);
  741. return nbr ? Number(nbr[0]) : Number.NaN;
  742. }
  743.  
  744. function getNumbers(str) {
  745. var nbrs = str.match(/-?\d+/g);
  746. if (!nbrs) return [];
  747. for(var i=0 ; i<nbrs.length ; i++)
  748. nbrs[i] = Number(nbrs[i]);
  749. return nbrs;
  750. }
  751.  
  752. function trim(str) {
  753. return str.replace(/(^\s*)|(\s*$)/g,'');
  754. }
  755.  
  756. String.prototype.trim = function() {
  757. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  758. }
  759.  
  760. function epure(texte) {
  761. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  762. .replace(/[ç]/g,'c')
  763. .replace(/[éêèë]/g,'e')
  764. .replace(/[ïî]/g,'i')
  765. .replace(/[ôöõ]/g,'o')
  766. .replace(/[ùûü]/g,'u');
  767. }
  768.  
  769. String.prototype.epure = function () {
  770. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  771. .replace(/[ç]/g,'c')
  772. .replace(/[éêèë]/g,'e')
  773. .replace(/[ïî]/g,'i')
  774. .replace(/[ôöõ]/g,'o')
  775. .replace(/[ùûü]/g,'u');
  776. }
  777.  
  778. function bbcode(texte) {
  779. return texte.replace(/&/g,'&amp;')
  780. .replace(/"/g,'&quot;')
  781. .replace(/</g,'&lt;')
  782. .replace(/>/g,'&gt;')
  783. .replace(/'/g,'&#146;')
  784. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  785. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  786. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  787. }
  788.  
  789.  
  790. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  791.  
  792. function addZero(i) {
  793. return (i<10) ? '0'+i : i;
  794. }
  795.  
  796. function DateToString(date) {
  797. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  798. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  799. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  800. }
  801.  
  802. function StringToDate(str) {
  803. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  804. }
  805.  
  806. // fonctionne aussi avec datetime
  807. function SQLDateToFrench(str) {
  808. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  809. }
  810.  
  811. // ... et ajoute un "à" du plus bel effet
  812. function SQLDateToFrenchTime(str) {
  813. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  814. }
  815.  
  816. // SQLDate vers objet date Javascript
  817. function SQLDateToObject(str) {
  818. var t = str.split(/[- :]/);
  819. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  820. }
  821.  
  822. var mz_ie = (window.attachEvent)? true:false;
  823. if ("function" !== typeof addEvent) {
  824. if (mz_ie) {
  825. function addEvent(obj, typ, fn, sens) {
  826. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  827. obj["e"+typ+fn]( window.event );
  828. }
  829. obj.attachEvent("on"+typ, obj[typ+fn] );
  830. }
  831. }
  832. else {
  833. function addEvent(obj, typ, fn, sens) {
  834. obj.addEventListener(typ, fn, sens);
  835. }
  836. }
  837. }
  838.  
  839. /**********************
  840. * glissière en mode objet
  841. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  842. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  843. *
  844. * Usage:
  845. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  846. * ref : utilisé pour diversifier les IDs HTML
  847. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  848. * target : peut être de 3 types
  849. * - élément HTML : l'élément HTML à zoomer
  850. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  851. * - function : callback quand le curseur bouge
  852. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  853. * dans le mode dynamique, la callback est appelée sur mouseMove
  854. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  855. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  856. * autres méthodes
  857. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  858. **********************/
  859.  
  860. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  861. try {
  862. var mouseDown = false;
  863. var div_gliss = document.createElement("div"); // la DIV mère
  864. div_gliss.id = "MZ_gliss_"+ref;
  865. var div_label = document.createElement("span"); // le label
  866. div_label.innerHTML = labelHTML;
  867. div_gliss.appendChild(div_label);
  868. div_gliss.className = "choix_zoom";
  869. var dessin = document.createElement("canvas"); // le dessin lui-même
  870. dessin.id = "MZ_gliss_dessin_"+ref;
  871. dessin.style.cursor = "pointer";
  872. dessin.width = 104;
  873. dessin.height = 12;
  874. dessin.style.marginLeft = '2px';
  875. dessin.style.marginRight = '2px';
  876. div_gliss.appendChild(dessin);
  877. var pourcent = document.createElement("span"); // le pourcentage
  878. pourcent.id = "MZ_gliss_pourcent_"+ref;
  879. var pourcent_text = document.createTextNode('');
  880. var previousVal;
  881. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  882.  
  883. // alignement vertical
  884. dessin.style.verticalAlign = 'middle';
  885. div_label.style.verticalAlign = 'middle';
  886. pourcent.style.verticalAlign = 'middle';
  887.  
  888. pourcent.appendChild(pourcent_text);
  889. div_gliss.appendChild(pourcent);
  890.  
  891. var bulle_pourcent = document.createElement("div"); // la bulle
  892. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  893. bulle_pourcent.style.display = 'block';
  894. bulle_pourcent.style.visibility = 'hidden';
  895. bulle_pourcent.style.position = 'absolute';
  896. bulle_pourcent.style.zIndex = 3500;
  897. bulle_pourcent.style.border = '1px solid #a1927f';
  898. var bulle_pourcent_text = document.createTextNode('');
  899. bulle_pourcent.appendChild(bulle_pourcent_text);
  900. document.body.appendChild(bulle_pourcent);
  901.  
  902. this.getElt = function() {return div_gliss;};
  903.  
  904. ////////////////////////////////////
  905. // dessine et redessine le curseur
  906. ////////////////////////////////////
  907. var dessine_glissiere = function(val) {
  908. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  909. var ctx = dessin.getContext('2d');
  910. ctx.clearRect(0, 0,104, 12);
  911. ctx.fillStyle = "rgb(0,0,0)";
  912. ctx.fillRect(0,0,2,12);
  913. ctx.fillRect(102,0,2,12);
  914. ctx.fillRect(0,5,104,2);
  915.  
  916. ctx.fillStyle = "rgb(80,80,80)";
  917. ctx.fillRect(pos_0_100,0,5,12);
  918. ctx.fillStyle = "rgb(200,200,200)";
  919. ctx.fillRect(pos_0_100+1,1,3,10);
  920. pourcent_text.nodeValue = val+'%';
  921. previousVal = parseInt(val);
  922. };
  923.  
  924. ////////////////////////////////////
  925. // action sur mousedown et mousemove
  926. // stocker la nouvelle valeur
  927. // redessiner
  928. // afficher la nouvelle valeur
  929. // action selon ce qui a été demandé
  930. ////////////////////////////////////
  931. var doCallback_glissiere = function (evt) {
  932. try {
  933. if (evt.type === 'mousedown') mouseDown = true;
  934. if (evt.offsetX) {
  935. var xsouris = evt.offsetX;
  936. var xpos = evt.clientX;
  937. var ypos = evt.clientY + document.body.scrollTop;
  938. }
  939. else {
  940. var xsouris = evt.layerX;
  941. var xpos = evt.pageX;
  942. var ypos = evt.pageY;
  943. }
  944. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  945. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  946. // afficher la nouvelle valeur dans la bulle
  947. bulle_pourcent_text.nodeValue = val + '%';
  948. bulle_pourcent.style.top = (ypos+3)+'px';
  949. bulle_pourcent.style.left = (xpos+16)+'px';
  950. if (evt.buttons === undefined) {
  951. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  952. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  953. } else {
  954. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  955. }
  956. // stocker la nouvelle valeur
  957. MY_setValue("MZ_glissiere_" + ref, val);
  958. // redessiner la glissière avec le curseur où il faut
  959. dessine_glissiere(val);
  960. // action selon ce qui a été demandé
  961. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  962. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  963. if (typeof paramTarget === 'object') {
  964. var elt = paramTarget;
  965. } else if (typeof paramTarget === 'string') {
  966. var elt = document.getElementById(paramTarget);
  967. } else if (typeof paramTarget === 'function') {
  968. paramTarget(val);
  969. return;
  970. }
  971. if (elt.setZoom != undefined) elt.setZoom(val);
  972. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  973. };
  974.  
  975. ////////////////////////////////////
  976. // event mousedown et mousemove : redessiner et callback
  977. ////////////////////////////////////
  978. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  979. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  980. ////////////////////////////////////
  981. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  982. ////////////////////////////////////
  983. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  984. ////////////////////////////////////
  985. // event mouseout & mouseover : afficher/cacher la bulle
  986. ////////////////////////////////////
  987. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  988. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  989.  
  990. ////////////////////////////////////
  991. // dessiner la première fois
  992. ////////////////////////////////////
  993. var val_init = MY_getValue("MZ_glissiere_" + ref);
  994. if (val_init === undefined) val_init = valDef;
  995. dessine_glissiere(val_init);
  996. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  997. }
  998.  
  999. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1000. // reçoit 2 objets avec des propriétés x et y
  1001. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1002. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1003. var deltaX = locArrivee.x - locDepart.x;
  1004. if (deltaX == 0) return; // pas de point intermédiaire
  1005. var deltaY = locArrivee.y - locDepart.y;
  1006. if (deltaY == 0) return; // pas de point intermédiaire
  1007. var absDeltaX = Math.abs(deltaX);
  1008. var absDeltaY = Math.abs(deltaY);
  1009. if (absDeltaX > absDeltaY) {
  1010. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1011. } else if (absDeltaY > absDeltaX) {
  1012. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1013. } else {
  1014. return; // égalité, pas de point intermédiaire
  1015. }
  1016. }
  1017.  
  1018. /**********************
  1019. * carte en mode objet
  1020. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1021. *
  1022. * Usage:
  1023. * carte = new carte_MZ(ref, tabDepl);
  1024. * ref : utilisé pour diversifier les IDs HTML
  1025. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1026. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1027. * autres méthodes
  1028. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1029. **********************/
  1030.  
  1031. function carte_MZ(ref, tabDepl) {
  1032. try {
  1033. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1034. div1_carte.id = "MZ_carte_"+ref;
  1035. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1036. div1_carte.style.backgroundImage = 'none';
  1037. div1_carte.style.backgroundColor = 'transparent';
  1038. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1039. div2_carte.className = "carte_MZ";
  1040. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1041. var dessin = document.createElement("canvas"); // le dessin lui-même
  1042. dessin.id = "MZ_carte_dessin_"+ref;
  1043. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1044. div1_carte.appendChild(div2_carte);
  1045. div2_carte.appendChild(dessin);
  1046.  
  1047. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1048. , [-66.5, -37.5, 2, 1.5, -69]
  1049. , [-63.5, 8.5, 2, 1.5, -69]
  1050. , [-59.5, -32.5, 2, 1.5, -69]
  1051. , [-52, 57, 0.25, 0.8, -59]
  1052. , [-50.5, -22.5, 2, 1.5, -69]
  1053. , [-35.5, -51.5, 2, 1.5, -69]
  1054. , [-34.5, 14.5, 2, 1.5, -69]
  1055. , [-34.5, 64.5, 2, 1.5, -69]
  1056. , [-11.5, 72.5, 2, 1.5, -69]
  1057. , [5.5, -49.5, 2, 1.5, -69]
  1058. , [5.5, 31.5, 2, 1.5, -69]
  1059. , [10.5, 63.5, 2, 1.5, -69]
  1060. , [12, -15, 0.25, 0.8, -59]
  1061. , [21.5, 35.5, 2, 1.5, -69]
  1062. , [30, -52, 0.25, 0.8, -59]
  1063. , [46.5, 51.5, 2, 1.5, -69]
  1064. , [48, -39, 0.25, 0.8, -59]
  1065. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1066. , [56.5, 23.5, 75, 8.7, -99]
  1067. , [64, 70, 0.25, 0.8, -59]
  1068. , [74.5, 31.5, 2, 1.5, -69]];
  1069.  
  1070. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1071. var couleur_cible = 'rgba(0,0,0,0.5)';
  1072. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1073. var couleur_trou = 'rgb(200,0,0)';
  1074.  
  1075. var coord_x = function(val) {
  1076. return decalh+coeff*(val+100);
  1077. };
  1078. var coord_y = function(val) {
  1079. return decalv+coeff*(100-val);
  1080. };
  1081.  
  1082. var ctx = dessin.getContext('2d');
  1083. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1084. if (coeff) coeff /= 50;
  1085. else coeff = 2;
  1086. var decalv=30, decalh=30;
  1087.  
  1088. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1089. //var res = false
  1090. var x0 = pos0.x;
  1091. var y0 = pos0.x;
  1092. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1093. var px = Math.sign(pos1.x - pos0.x);
  1094. var py = Math.sign(pos1.y - pos0.y);
  1095. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1096. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1097.  
  1098. for(var k in position_trous_MZ) {
  1099. a = parseFloat(px*px+py*py);
  1100. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1101. 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]);
  1102. delta = b*b-a*c
  1103. if(delta >= 0) {
  1104. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1105. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1106. if(t0 <= tmax && t1 >= 0) {
  1107. // 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
  1108. //res = true;
  1109. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1110. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1111. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1112. // Roule : pas utile pour nous
  1113. //res = true;
  1114. //chute.push([x0+l*px, y0+l*py]);
  1115. return true;
  1116. }
  1117. }
  1118. }
  1119. }
  1120. //return res;
  1121. return false;
  1122. };
  1123.  
  1124. var dessine_carte = function () {
  1125. dessin.width = 200*coeff+2*decalh;
  1126. dessin.height = 200*coeff+2*decalv;
  1127.  
  1128. //repere
  1129. ctx.beginPath();
  1130. ctx.moveTo(coord_x(0), coord_y(100));
  1131. ctx.lineTo(coord_x(0), coord_y(-100));
  1132. ctx.moveTo(coord_x(-100), coord_y(0));
  1133. ctx.lineTo(coord_x(100), coord_y(0));
  1134. ctx.stroke();
  1135. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1136.  
  1137. //trous
  1138. ctx.fillStyle = couleur_trou;
  1139. for(var i in position_trous_MZ) {
  1140. ctx.beginPath();
  1141. 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);
  1142. ctx.fill();
  1143. }
  1144. // trajets
  1145. ctx.lineCap = "round";
  1146. ctx.lineJoin = "round";
  1147. for (var iSuivant in tabDepl) {
  1148. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1149. var tabDeplOneSuivant = tabDepl[iSuivant];
  1150. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1151. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1152. // La "cible" au départ
  1153. var typeDepart = tabDeplOneSuivant[0].typ;
  1154. switch (typeDepart) {
  1155. case 'tp':
  1156. ctx.beginPath();
  1157. ctx.lineWidth = 2;
  1158. ctx.strokeStyle = couleur_cible;
  1159. ctx.fillStyle = couleur_cible;
  1160. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1161. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1162. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1163. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1164. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1165. ctx.moveTo(x0 + coeff * 3, y0);
  1166. ctx.lineTo(x0 - coeff * 3, y0);
  1167. ctx.moveTo(x0, y0 + coeff * 3);
  1168. ctx.lineTo(x0, y0 - coeff * 3);
  1169. ctx.stroke();
  1170. break;
  1171. default:
  1172. ctx.beginPath();
  1173. ctx.lineWidth = 1;
  1174. ctx.strokeStyle = couleur_cible;
  1175. ctx.fillStyle = couleur_cible;
  1176. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1177. ctx.moveTo(x0 + coeff * 4, y0);
  1178. ctx.lineTo(x0 - coeff * 4, y0);
  1179. ctx.moveTo(x0, y0 + coeff * 4);
  1180. ctx.lineTo(x0, y0 - coeff * 4);
  1181. ctx.stroke();
  1182. break;
  1183. }
  1184. // les segments
  1185. var nb_pts = tabDeplOneSuivant.length;
  1186. var pointPrecedent = tabDeplOneSuivant[0];
  1187. for (var i=1; i<nb_pts; i++) {
  1188. ctx.beginPath();
  1189. ctx.lineWidth = coeff;
  1190. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1191. ctx.strokeStyle = couleur_depl_normal;
  1192. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1193. if (pointIntermediaire === undefined) {
  1194. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1195. ctx.strokeStyle = couleur_depl_collision_trou;
  1196. else
  1197. ctx.strokeStyle = couleur_depl_normal;
  1198. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1199. } else {
  1200. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1201. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1202. ctx.strokeStyle = couleur_depl_collision_trou;
  1203. else
  1204. ctx.strokeStyle = couleur_depl_normal;
  1205. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1206. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1207. }
  1208. pointPrecedent = tabDeplOneSuivant[i];
  1209. ctx.stroke();
  1210. }
  1211. // Les points à chaque étape
  1212. ctx.fillStyle = couleur_depl_normal;
  1213. for (var i=1; i<nb_pts; i++) {
  1214. ctx.beginPath();
  1215. var x = coord_x(tabDeplOneSuivant[i].x);
  1216. var y = coord_y(tabDeplOneSuivant[i].y);
  1217. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1218. ctx.fill();
  1219. }
  1220. }
  1221. }
  1222.  
  1223. this.setZoom = function (val) {
  1224. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1225. coeff = val / 50;
  1226. dessine_carte();
  1227. }
  1228.  
  1229. // glissiere
  1230. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1231. var eGliss = gliss.getElt();
  1232. eGliss.style.position = 'absolute';
  1233. eGliss.style.top = (coeff * 2) + 'px';
  1234. eGliss.style.left = decalh + 'px';
  1235. dessin.style.position = 'relative';
  1236. div2_carte.style.position = 'relative';
  1237. eGliss.style.zIndex = 9000;
  1238. div2_carte.appendChild(eGliss);
  1239.  
  1240. // affichage au survol de la souris
  1241. var bulle = document.createElement('div');
  1242. bulle.style.visibility = 'hidden';
  1243. bulle.style.position = 'absolute';
  1244. bulle.style.zIndex = 3100;
  1245. bulle.style.border = 'solid 1px #a1927f';
  1246. bulle.className = 'mh_tdpage';
  1247. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1248. var bulleHaut = document.createElement('div');
  1249. bulleHaut.style.display = 'block';
  1250. bulleHaut.style.paddingRight = '3px';
  1251. bulleHaut.className = 'mh_tdtitre';
  1252. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1253. bulle.appendChild(bulleHaut);
  1254. var bulleBas = document.createElement('div');
  1255. bulleBas.style.display = 'block';
  1256. bulleBas.style.whiteSpace = "nowrap";
  1257. bulleBas.style.paddingRight = '3px';
  1258.  
  1259. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1260. bulle.appendChild(bulleBas);
  1261. div2_carte.appendChild(bulle);
  1262. var affichePosition = function(evt) {
  1263. if (evt.offsetX) {
  1264. var xsouris = evt.offsetX;
  1265. var ysouris = evt.offsetY;
  1266. var xpos = evt.clientX;
  1267. var ypos = evt.clientY + document.body.scrollTop;
  1268. }
  1269. else {
  1270. var xsouris = evt.layerX;
  1271. var ysouris = evt.layerY;
  1272. var xpos = evt.pageX;
  1273. var ypos = evt.pageY;
  1274. }
  1275. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1276. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1277. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1278. var tabHTMLbas = [];
  1279. // message pour les trous
  1280. for (var i in position_trous_MZ) {
  1281. var ceTrou = position_trous_MZ[i];
  1282. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1283. if(dist <= 0) {
  1284. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1285. break;
  1286. }
  1287. }
  1288. // messages pour les suivants
  1289. for (var i in tabDepl) {
  1290. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1291. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1292. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1293. }
  1294. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1295. bulle.style.top = (ysouris+8) + 'px';
  1296. bulle.style.left = (xsouris+16) + 'px';
  1297. };
  1298. addEvent(dessin, "mousemove", affichePosition, true);
  1299. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1300. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1301.  
  1302. // dessin initial
  1303. dessine_carte();
  1304.  
  1305. this.getElt = function() {return div1_carte;};
  1306.  
  1307. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1308. }
  1309.  
  1310.  
  1311. /**********************************************************
  1312. **** Fin de zone à déplacer dans une bibli commune ********
  1313. **********************************************************/
  1314.  
  1315. /* DEBUG: NETTOYAGE TAGS */
  1316. if(MY_getValue(numTroll+'.TAGSURL')) {
  1317. MY_removeValue(numTroll+'.TAGSURL');
  1318. }
  1319.  
  1320. // Alerte si mode dev
  1321. if (isDEV) {
  1322. var divpopup = document.createElement('div');
  1323. divpopup.id = 'divDEV';
  1324. divpopup.style =
  1325. 'position: fixed;'+
  1326. 'border: 15px solid red;'+
  1327. 'top: 10px;right: 10px;'+
  1328. 'background-color: white;'+
  1329. 'color: black;'+
  1330. 'font-size: large;'+
  1331. 'padding: 5px'+
  1332. 'z-index: 200;';
  1333. appendText(divpopup, '[MZ] Mode DEV');
  1334. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1335. document.body.appendChild(divpopup);
  1336. }
  1337.  
  1338. /*---------- regroupement des getPortee() ------------------------------------*/
  1339. // issu des script profil et profil2
  1340. function getPortee__Profil(param) {
  1341. param = Math.max(0,Number(param));
  1342. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1343. // ça devrait être floor, +10.25, -2.5
  1344. }
  1345.  
  1346. // issu du script vue
  1347. function getPortee__Vue(param) {
  1348. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1349. }
  1350.  
  1351.  
  1352. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1353.  
  1354. function getPXKill(niv) {
  1355. return Math.max(0,10+3*niv-2*nivTroll);
  1356. }
  1357.  
  1358. function getPXDeath(niv) {
  1359. return Math.max(0,10+3*nivTroll-2*niv);
  1360. }
  1361.  
  1362. function analysePX(niv) {
  1363. niv = niv+'';
  1364. var i = niv.indexOf('+');
  1365. if(i!=-1) // si niv = 'XX+' ??
  1366. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1367. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1368. if(i!=-1) {
  1369. var max = getPXKill(niv.slice(i+2));
  1370. if(max==0)
  1371. return ' --> <b>0</b> PX';
  1372. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1373. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1374. }
  1375. i = niv.indexOf('='); // ???
  1376. if(i!=-1) {
  1377. var max = getPXKill(niv.slice(i+1));
  1378. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1379. }
  1380. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1381. }
  1382.  
  1383. function analysePXTroll(niv) {
  1384. var str = analysePX(niv);
  1385. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1386. return str;
  1387. }
  1388.  
  1389.  
  1390. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1391. // Refonte totale du code de Zorya
  1392.  
  1393. // Elements à implémenter en dur dans MZ2.0
  1394. var numQualite = {
  1395. 'Très Mauvaise':1,
  1396. 'Mauvaise':2,
  1397. 'Moyenne':3,
  1398. 'Bonne':4,
  1399. 'Très Bonne':5
  1400. };
  1401.  
  1402. var qualiteNum = [
  1403. '_dummy_',
  1404. 'Très Mauvaise',
  1405. 'Mauvaise',
  1406. 'Moyenne',
  1407. 'Bonne',
  1408. 'Très Bonne'
  1409. ];
  1410.  
  1411. var nival = {
  1412. 'Abishaii Bleu':19,
  1413. 'Abishaii Noir':10,
  1414. 'Abishaii Rouge':23,
  1415. 'Abishaii Vert':15,
  1416. 'Ame-en-peine':8,
  1417. 'Amibe Geante':9,
  1418. 'Anaconda des Catacombes':8,
  1419. 'Ankheg':10,
  1420. 'Anoploure Purpurin':36,
  1421. 'Araignee Geante':2,
  1422. 'Ashashin':35,
  1423. 'Balrog':50,
  1424. 'Banshee':16,
  1425. 'Barghest':36,
  1426. 'Basilisk':11,
  1427. 'Behemoth':34,
  1428. 'Behir':14,
  1429. 'Beholder':50,
  1430. 'Boggart':3,
  1431. 'Bondin':9,
  1432. "Bouj'Dla Placide":37,
  1433. "Bouj'Dla":19,
  1434. 'Bulette':19,
  1435. 'Caillouteux':1,
  1436. 'Capitan':35,
  1437. 'Carnosaure':25,
  1438. 'Champi-Glouton':3,
  1439. 'Chauve-Souris Geante':4,
  1440. 'Cheval a Dents de Sabre':23,
  1441. 'Chevalier du Chaos':20,
  1442. 'Chimere':13,
  1443. 'Chonchon':24,
  1444. 'Coccicruelle':22,
  1445. 'Cockatrice':5,
  1446. 'Crasc Medius':17,
  1447. 'Crasc Maexus':25,
  1448. 'Crasc':10,
  1449. 'Croquemitaine':6,
  1450. 'Cube Gelatineux':32,
  1451. 'Daemonite':27,
  1452. 'Diablotin':5,
  1453. 'Dindon du Chaos':1,
  1454. 'Djinn':29,
  1455. 'Ectoplasme':18,
  1456. 'Effrit':27,
  1457. "Elementaire d'Air":23,
  1458. "Elementaire d'Eau":17,
  1459. 'Elementaire de Feu':21,
  1460. 'Elementaire de Terre':21,
  1461. 'Elementaire du Chaos':26,
  1462. 'Erinyes':7,
  1463. 'Esprit-Follet':16,
  1464. 'Essaim Craterien':30,
  1465. 'Essaim Sanguinaire':25,
  1466. 'Ettin':8,
  1467. 'Familier':1,
  1468. 'Fantome':24,
  1469. 'Feu Follet':20,
  1470. 'Flagelleur Mental':33,
  1471. 'Foudroyeur':38,
  1472. 'Fumeux':22,
  1473. 'Fungus Geant':9,
  1474. 'Fungus Violet':4,
  1475. 'Furgolin':10,
  1476. 'Gargouille':3,
  1477. 'Geant de Pierre':13,
  1478. 'Geant des Gouffres':22,
  1479. "Geck'oo Majestueux":40,
  1480. "Geck'oo":15,
  1481. 'Glouton':20,
  1482. 'Gnoll':5,
  1483. 'Gnu Domestique':1,
  1484. 'Gnu Sauvage':1,
  1485. 'Goblin':4,
  1486. 'Goblours':4,
  1487. "Golem d'Argile":15,
  1488. 'Golem de cuir':1,
  1489. 'Golem de Chair':8,
  1490. 'Golem de Fer':31,
  1491. 'Golem de mithril':1,
  1492. 'Golem de metal':1,
  1493. 'Golem de papier':1,
  1494. 'Golem de Pierre':23,
  1495. 'Gorgone':11,
  1496. 'Goule':4,
  1497. 'Gowap Apprivoise':1,
  1498. 'Gowap Sauvage':1,
  1499. 'Gremlins':3,
  1500. 'Gritche':39,
  1501. 'Grouilleux':4,
  1502. 'Grylle':31,
  1503. 'Harpie':4,
  1504. 'Hellrot':18,
  1505. 'Homme-Lezard':4,
  1506. 'Hurleur':8,
  1507. 'Hydre':50,
  1508. 'Incube':13,
  1509. 'Kobold':2,
  1510. 'Labeilleux':26,
  1511. 'Lezard Geant':5,
  1512. 'Liche':50,
  1513. 'Limace Geante':10,
  1514. 'Loup-Garou':8,
  1515. 'Lutin':4,
  1516. 'Mante Fulcreuse':30,
  1517. 'Manticore':9,
  1518. 'Marilith':33,
  1519. 'Meduse':6,
  1520. 'Megacephale':38,
  1521. 'Mille-Pattes Geant':14,
  1522. 'Mimique':6,
  1523. 'Minotaure':7,
  1524. 'Molosse Satanique':8,
  1525. 'Momie':4,
  1526. 'Monstre Rouilleur':3,
  1527. "Mouch'oo Domestique":14,
  1528. "Mouch'oo Majestueux Sauvage":33,
  1529. "Mouch'oo Sauvage":14,
  1530. 'Na-Haniym-Heee':0,
  1531. 'Necrochore':37,
  1532. 'Necromant':39,
  1533. 'Necrophage':8,
  1534. 'Naga':10,
  1535. 'Nuee de Vermine':13,
  1536. "Nuage d'Insectes":7,
  1537. 'Ogre':7,
  1538. 'Ombre de Roches':13,
  1539. 'Ombre':2,
  1540. 'Orque':3,
  1541. 'Ours-Garou':18,
  1542. 'Palefroi Infernal':29,
  1543. 'Phoenix':32,
  1544. 'Pititabeille':0,
  1545. 'Plante Carnivore':4,
  1546. 'Pseudo-Dragon':5,
  1547. 'Rat Geant':2,
  1548. 'Rat-Garou':3,
  1549. 'Rocketeux':5,
  1550. 'Sagouin':3,
  1551. 'Scarabee Geant':4,
  1552. 'Scorpion Geant':10,
  1553. 'Shai':28,
  1554. 'Sirene':8,
  1555. 'Slaad':5,
  1556. 'Sorciere':17,
  1557. 'Spectre':14,
  1558. 'Sphinx':30,
  1559. 'Squelette':1,
  1560. 'Strige':2,
  1561. 'Succube':13,
  1562. 'Tertre Errant':20,
  1563. 'Thri-kreen':10,
  1564. 'Tigre-Garou':12,
  1565. 'Titan':26,
  1566. 'Trancheur':35,
  1567. 'Tubercule Tueur':14,
  1568. 'Tutoki':4,
  1569. 'Vampire':29,
  1570. 'Ver Carnivore Geant':12,
  1571. 'Ver Carnivore':11,
  1572. 'Veskan Du Chaos':14,
  1573. 'Vouivre':33,
  1574. 'Worg':5,
  1575. 'Xorn':14,
  1576. 'Yeti':8,
  1577. 'Yuan-ti':15,
  1578. 'Zombie':2
  1579. }
  1580.  
  1581. var tabEM = {
  1582. //Monstre: [Compo exact, Sort, Position, Localisation]
  1583. // AA
  1584. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1585. // AE
  1586. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1587. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1588. // AdA
  1589. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1590. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1591. // AdE
  1592. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1593. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1594. // AdD
  1595. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1596. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1597. // BAM
  1598. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1599. // BuM
  1600. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1601. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1602. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1603. // Explo
  1604. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1605. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1606. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1607. // FP
  1608. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1609. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1610. // FA
  1611. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1612. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1613. // Glue
  1614. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1615. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1616. // GdS
  1617. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1618. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1619. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1620. // Invi
  1621. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1622. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1623. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1624. // Lévitation
  1625. // ???
  1626. // PréM :
  1627. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1628. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1629. // Proj
  1630. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1631. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1632. // PuM :
  1633. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1634. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1635. // Sacro
  1636. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1637. // Télék
  1638. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1639. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1640. // TP
  1641. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1642. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1643. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1644. // VA
  1645. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1646. // VL
  1647. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1648. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1649. // VlC
  1650. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1651. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1652. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1653. // VT
  1654. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1655. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1656. // Variables
  1657. 'Rat':["d'un"],
  1658. 'Rat Géant':["d'un"],
  1659. 'Dindon':["d'un"],
  1660. 'Goblin':["d'un"],
  1661. 'Limace':["d'une"],
  1662. 'Limace Géante':["d'une"],
  1663. 'Ver':["d'un"],
  1664. 'Ver Carnivore':["d'un"],
  1665. 'Ver Carnivore Géant':["d'un"],
  1666. 'Fungus':["d'un"],
  1667. 'Vouivre':["d'une"],
  1668. 'Gnu':["d'un"],
  1669. 'Scarabée':["d'un"]
  1670. };
  1671.  
  1672. var mundiChampi = {
  1673. 'Préscientus Reguis':'du Phoenix',
  1674. 'Amanite Trolloïde':'de la Mouche',
  1675. 'Girolle Sanglante':'du Dindon',
  1676. 'Horreur Des Prés':'du Gobelin',
  1677. 'Bolet Péteur':'du Démon',
  1678. 'Pied Jaune':'de la Limace',
  1679. 'Agaric Sous-Terrain':'du Rat',
  1680. 'Suinte Cadavre':"de l'Hydre",
  1681. 'Cèpe Lumineux':'du Ver',
  1682. 'Fungus Rampant':'du Fungus',
  1683. 'Nez Noir':'de la Vouivre',
  1684. 'Pleurote Pleureuse':'du Gnu',
  1685. 'Phytomassus Xilénique':'du Scarabée'
  1686. };
  1687.  
  1688. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1689. appendText(node,' ');
  1690. var urlImg = URL_MZimg
  1691. +'Competences/melangeMagique.png';
  1692. var text = ' [-'+(niv+effetQ)+' %]';
  1693. var str = '';
  1694. switch(mob[0]) {
  1695. case 'A':
  1696. case 'E':
  1697. case 'I':
  1698. case 'O':
  1699. case 'U':
  1700. str = "Compo d'";
  1701. break;
  1702. default:
  1703. str = 'Compo de ';
  1704. }
  1705. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1706. var span = createImageSpan(urlImg,'MM:',title,text);
  1707. node.appendChild(span);
  1708. }
  1709. function addInfoEM(node,mob,compo,qualite,localisation) {
  1710. if(!tabEM[mob]) return;
  1711. var title = 'Composant variable', texte = 'Variable';
  1712. var bold = false;
  1713. if(tabEM[mob].length>1) {
  1714. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1715. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1716. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1717. if(pc<-20) return;
  1718. if(pc>=0) bold = true;
  1719. texte = aff(pc)+'%';
  1720. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1721. }
  1722. var urlImg = URL_MZimg
  1723. +'Competences/ecritureMagique.png';
  1724. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1725. node.appendChild(span);
  1726. }
  1727.  
  1728. function insererInfosEM(tbody) {
  1729. // lancé par equip, equipgowap
  1730. var trCompos = document.evaluate(
  1731. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1732. tbody,null,7,null);
  1733. var strCompos = '';
  1734. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1735. var node = trCompos.snapshotItem(i).childNodes[7];
  1736. var str = node.firstChild.textContent;
  1737. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1738. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1739. // Si non-EM on stoppe le traitement
  1740. if(!tabEM[mob]) continue;
  1741. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1742. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1743. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1744. addInfoEM(node,mob,compo,qualite,localisation);
  1745. }
  1746. }
  1747.  
  1748. function getQualite(qualite) {
  1749. var nb = numQualite[qualite];
  1750. return nb ? nb-1 : -1;
  1751. }
  1752.  
  1753. function getEM(nom) {
  1754. if(nom.indexOf('[')!=-1)
  1755. nom = trim(nom.substring(0,nom.indexOf('[')));
  1756. if(tabEM[nom]) return nom;
  1757. return '';
  1758. }
  1759.  
  1760. // DEBUG ex-fonction composantEM
  1761. function compoMobEM(mob) {
  1762. if(!tabEM[mob]) return '';
  1763. if(tabEM[mob].length==1)
  1764. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1765. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1766. +") pour l'écriture de "+tabEM[mob][1];
  1767. }
  1768.  
  1769. // DEBUG ex-fonction compoEM
  1770. function titreCompoEM(mob,compo,localisation,qualite) {
  1771. if(!tabEM[mob]) return '';
  1772. if(tabEM[mob].length==1) return 'Composant variable';
  1773. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1774. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1775. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1776. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1777. return '';
  1778. }
  1779.  
  1780. // DEBUG - rétrocompatibilité
  1781. function compoEM(mob) {
  1782. // appelé dans libs, vue
  1783. return compoMobEM(mob);
  1784. }
  1785. function composantEM(mob,compo,localisation,qualite) {
  1786. // appelé dans libs, tancompo
  1787. return titreCompoEM(mob,compo,localisation,qualite);
  1788. }
  1789. //
  1790.  
  1791.  
  1792. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1793.  
  1794. arrayTalents = {
  1795. /* Compétences */
  1796. 'Acceleration du Metabolisme':'AM',
  1797. 'Attaque Precise':'AP',
  1798. 'Balayage':'Balayage',
  1799. //'Balluchonnage':'Ballu',
  1800. 'Baroufle':'Baroufle',
  1801. 'Bidouille':'Bidouille',
  1802. 'Botte Secrete':'BS',
  1803. 'Camouflage':'Camou',
  1804. 'Charger':'Charger',
  1805. 'Connaissance des Monstres':'CdM',
  1806. 'Construire un Piege':'Piege',
  1807. 'Piege a Feu':'PiegeFeu',
  1808. 'Piege a Glue':'PiegeGlue',
  1809. 'Contre-Attaquer':'CA',
  1810. 'Coup de Butoir':'CdB',
  1811. 'Course':'Course',
  1812. 'Deplacement Eclair':'DE',
  1813. 'Dressage':'Dressage',
  1814. 'Ecriture Magique':'EM',
  1815. 'Frenesie':'Frenesie',
  1816. 'Golemologie':'Golemo',
  1817. 'Golem de cuir':'GolemCuir',
  1818. 'Golem de metal':'GolemMetal',
  1819. 'Golem de mithril':'GolemMithril',
  1820. 'Golem de papier':'GolemPapier',
  1821. 'Grattage':'Grattage',
  1822. 'Hurlement Effrayant':'HE',
  1823. 'Identification des Champignons':'IdC',
  1824. 'Insultes':'Insultes',
  1825. 'Lancer de Potions':'LdP',
  1826. 'Marquage':'Marquage',
  1827. 'Melange Magique':'Melange',
  1828. 'Miner':'Miner',
  1829. 'Necromancie':'Necro',
  1830. 'Painthure de Guerre':'PG',
  1831. 'Parer':'Parer',
  1832. 'Pistage':'Pistage',
  1833. 'Planter un Champignon':'PuC',
  1834. 'Regeneration Accrue':'RA',
  1835. 'Reparation':'Reparation',
  1836. 'Retraite':'Retraite',
  1837. 'Rotobaffe':'RB',
  1838. 'Shamaner':'Shamaner',
  1839. "S'interposer":'SInterposer',
  1840. 'Tailler':'Tailler',
  1841. //'Vol':'Vol',
  1842. /* Sortilèges */
  1843. 'Analyse Anatomique':'AA',
  1844. 'Armure Etheree':'AE',
  1845. 'Augmentation de l´Attaque':'AdA',
  1846. 'Augmentation de l´Esquive':'AdE',
  1847. 'Augmentation des Degats':'AdD',
  1848. 'Bulle Anti-Magie':'BAM',
  1849. 'Bulle Magique':'BuM',
  1850. 'Explosion':'Explo',
  1851. 'Faiblesse Passagere':'FP',
  1852. 'Flash Aveuglant':'FA',
  1853. 'Glue':'Glue',
  1854. 'Griffe du Sorcier':'GdS',
  1855. 'Hypnotisme':'Hypno',
  1856. 'Identification des tresors':'IdT',
  1857. 'Invisibilite':'Invi',
  1858. 'Levitation':'Levitation',
  1859. 'Precision Magique':'PreM',
  1860. 'Projectile Magique':'Projo',
  1861. 'Projection':'Proj',
  1862. 'Puissance Magique':'PuM',
  1863. 'Rafale Psychique':'Rafale',
  1864. 'Sacrifice':'Sacro',
  1865. 'Siphon des ames':'Siphon',
  1866. 'Telekinesie':'Telek',
  1867. 'Teleportation':'TP',
  1868. 'Vampirisme':'Vampi',
  1869. 'Vision Accrue':'VA',
  1870. 'Vision lointaine':'VL',
  1871. 'Voir le Cache':'VlC',
  1872. 'Vue Troublee':'VT'
  1873. //'':''
  1874. }
  1875.  
  1876. // DEBUG - Pour rétrocompatibilité
  1877. function getSortComp(nom,niveau) {
  1878. return getTalent(nom,niveau);
  1879. }
  1880. //
  1881.  
  1882. function getTalent(nom,niveau) {
  1883. var nomEnBase = arrayTalents[epure(nom)];
  1884. if(!nomEnBase) return 0;
  1885. if(!niveau) var niveau = '';
  1886. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1887. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1888. return 0;
  1889. }
  1890.  
  1891. function removeAllTalents() {
  1892. for(var talent in arrayTalents) {
  1893. var nomEnBase = arrayTalents[talent];
  1894. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1895. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1896. continue;
  1897. }
  1898. var niveau = 1;
  1899. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1900. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1901. niveau++;
  1902. }
  1903. }
  1904. }
  1905.  
  1906. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1907. var att = MY_getValue(numTroll+'.caracs.attaque');
  1908. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1909. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1910. var mm = MY_getValue(numTroll+'.caracs.mm');
  1911. var deg = MY_getValue(numTroll+'.caracs.degats');
  1912. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1913. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1914. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1915. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1916. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1917. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1918. return false;
  1919. return true;
  1920. }
  1921.  
  1922.  
  1923. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1924.  
  1925. function getPVsRestants(pv,bless,vue) {
  1926. bless = Number(bless.match(/\d+/)[0]);
  1927. if(bless==0) return null;
  1928. var pvminmax = pv.match(/\d+/g);
  1929. if(bless==95) {
  1930. var pvb = 1;
  1931. var pvh = Math.floor( pvminmax[1]/20 );
  1932. }
  1933. else if(bless==5) {
  1934. var pvb = Math.floor( pvminmax[0]*19/20 );
  1935. var pvh = pvminmax[1];
  1936. }
  1937. else {
  1938. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1939. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1940. }
  1941. return vue ? ' ('+pvb+'-'+pvh+')' :
  1942. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1943. }
  1944.  
  1945. function insertButtonCdm(nextName,onClick,texte) {
  1946. if(texte==null) texte = 'Participer au bestiaire';
  1947. var nextNode = document.getElementsByName(nextName)[0];
  1948.  
  1949. var espace = document.createTextNode('\t');
  1950. insertBefore(nextNode,espace);
  1951.  
  1952. var button = document.createElement('input');
  1953. button.type = 'button';
  1954. button.className = 'mh_form_submit';
  1955. button.value = texte;
  1956. button.onmouseover = function(){this.style.cursor='pointer';};
  1957. if(onClick) button.onclick = onClick;
  1958. insertBefore(espace,button);
  1959. return button;
  1960. }
  1961.  
  1962. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1963. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1964. 'Capacité spéciale','Résistance Magique','Autres'];
  1965.  
  1966. function createImageTactique(url,id,nom) {
  1967. var img = document.createElement('img');
  1968. img.src = url;
  1969. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1970. img.id = id;
  1971. img.nom = nom;
  1972. img.onmouseover = showPopupTactique;
  1973. img.onmouseout = hidePopup;
  1974. return img;
  1975. }
  1976.  
  1977. function createCDMTable(id,nom,donneesMonstre) {
  1978. try {
  1979. var urlImg = URL_MZimg;
  1980. var table = document.createElement('table');
  1981. var profilActif = isProfilActif();
  1982. table.className = 'mh_tdborder';
  1983. table.border = 0;
  1984. table.cellSpacing = 1;
  1985. table.cellPadding = 4;
  1986. var thead = document.createElement('thead');
  1987. var tr = appendTr(thead,'mh_tdtitre');
  1988. var td = appendTdText(tr,
  1989. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  1990. true
  1991. );
  1992. td.colSpan = 2;
  1993. table.appendChild(thead);
  1994. var tbody = document.createElement('tbody');
  1995. table.appendChild(tbody);
  1996. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  1997. createCase(listeTitres[i],tbody,80);
  1998. }
  1999. var TypeMonstre = getEM(nom);
  2000. var infosCompo='';
  2001. if(TypeMonstre!='') {
  2002. infosCompo = compoEM(TypeMonstre);
  2003. }
  2004. var nodes = tbody.childNodes;
  2005. nodes[0].childNodes[1].innerHTML =
  2006. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2007. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2008. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2009. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2010. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2011. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2012. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2013. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2014. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2015. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2016. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2017. td = createCase(listeTitres[10],tbody);
  2018. td.innerHTML = bbcode(donneesMonstre[10]);
  2019. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2020. td.appendChild(document.createTextNode(" "));
  2021. if(donneesMonstre[16] == "De zone")
  2022. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2023. else if(donneesMonstre[16] == "Automatique")
  2024. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2025. else if(donneesMonstre[16] == "Au toucher")
  2026. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2027. }
  2028. }
  2029. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2030. {
  2031. td = createCase(listeTitres[11],tbody);
  2032. td.innerHTML = bbcode(donneesMonstre[9]);
  2033. // seuil de résistance du monstre
  2034. var lb = td.getElementsByTagName('b');
  2035. if(lb.length == 1) {
  2036. var mrm = lb[0].firstChild.nodeValue * 1;
  2037. var v = (mrm / mmTroll);
  2038. lb[0].firstChild.nodeValue += " ("
  2039. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2040. }
  2041. }
  2042. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2043. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2044. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2045. {
  2046. td = createCase(listeTitres[12],tbody);
  2047. if(donneesMonstre[12]==1)
  2048. {
  2049. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2050. }
  2051. if(donneesMonstre[13]==1)
  2052. {
  2053. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2054. }
  2055. else if(donneesMonstre[13]==0)
  2056. {
  2057. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2058. }
  2059. if(donneesMonstre[14]==1)
  2060. {
  2061. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2062. }
  2063. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2064. {
  2065. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2066. }
  2067. else if(donneesMonstre[14]>6)
  2068. {
  2069. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2070. }
  2071. if(donneesMonstre[15]=="Lente")
  2072. {
  2073. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2074. }
  2075. else if(donneesMonstre[15]=="Normale")
  2076. {
  2077. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2078. }
  2079. else if(donneesMonstre[15]=="Rapide")
  2080. {
  2081. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2082. }
  2083. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2084. {
  2085. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2086. }
  2087. if(infosCompo.length>0)
  2088. {
  2089. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2090. }
  2091. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2092. {
  2093. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2094. }
  2095. }
  2096. // pourcentage de blessure
  2097. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2098. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2099. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2100. if(pvs)
  2101. lb[0].firstChild.nodeValue += pvs;
  2102. }
  2103. return table;
  2104. }
  2105. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2106. }
  2107.  
  2108.  
  2109. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2110.  
  2111. var listeMonstreEnchantement = null,
  2112. listeEquipementEnchantement = null,
  2113. listeInfoEnchantement = null;
  2114.  
  2115. function computeCompoEnchantement()
  2116. {
  2117. listeMonstreEnchantement = new Array();
  2118. listeInfoEnchantement = new Array();
  2119. listeEquipementEnchantement = new Array();
  2120. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2121. for(var i=0;i<liste.length;i++)
  2122. {
  2123. var idEquipement = liste[i]*1;
  2124. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2125. continue;
  2126. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2127. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2128. var texteGlobal='';
  2129. for(var j=0;j<3;j++)
  2130. {
  2131. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  2132. listeMonstreEnchantement[infoComposant[2]] = 1;
  2133. var array = new Array();
  2134. array[0]=infoComposant[0].replace("Ril","Œil");
  2135. array[1]=infoComposant[1];
  2136. array[2]=infoComposant[2];
  2137. array[3]=getQualite(infoComposant[3]);
  2138. var texte = infoComposant[4].replace("Ril","Œil");
  2139. for(var k=5;k<infoComposant.length;k++)
  2140. {
  2141. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2142. }
  2143. texteGlobal+=texte+'\n';
  2144. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2145. array[4]=texte;
  2146. listeInfoEnchantement.push(array);
  2147. }
  2148. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2149. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2150. }
  2151. }
  2152.  
  2153. function isEnchant(nom) {
  2154. var monstreEnchant = '';
  2155. for(j in listeInfoEnchantement) {
  2156. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2157. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2158. monstreEnchant=monstre;
  2159. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2160. }
  2161. }
  2162. return trim(monstreEnchant);
  2163. }
  2164.  
  2165. function getInfoEnchantementFromMonstre(nom)
  2166. {
  2167. try
  2168. {
  2169. if(!listeMonstreEnchantement)
  2170. {
  2171. computeCompoEnchantement();
  2172. }
  2173. var infosEnchant = '';
  2174. for(j in listeInfoEnchantement) {
  2175. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2176. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2177. if(infosEnchant=='')
  2178. infosEnchant=listeInfoEnchantement[j][4];
  2179. else
  2180. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2181. }
  2182. }
  2183. return trim(infosEnchant);
  2184. }
  2185. catch(e)
  2186. {
  2187. window.alert(e);
  2188. }
  2189. }
  2190.  
  2191. function composantEnchant(Monstre,composant,localisation,qualite) {
  2192. var compo='';
  2193. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2194. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2195. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2196. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2197. listeInfoEnchantement[i][3]<=qualite
  2198. ) {
  2199. return listeInfoEnchantement[i][4];
  2200. }
  2201. }
  2202. return compo;
  2203. }
  2204.  
  2205. function insertEnchantInfos(tbody) {
  2206. try
  2207. {
  2208. if(!listeMonstreEnchantement)
  2209. computeCompoEnchantement();
  2210. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2211. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2212. if(nodes.snapshotLength == 0)
  2213. return false;
  2214. var urlImg = URL_MZimg + 'enchant.png';
  2215. for(var i = 0; i < nodes.snapshotLength; i++) {
  2216. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2217. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2218. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2219. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2220. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2221. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2222. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2223. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2224. if(isEnchant(nomMonstre).length>0)
  2225. {
  2226. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2227. if(infos.length>0)
  2228. {
  2229. if(link.parentNode == link.nextSibling.parentNode)
  2230. {
  2231. var tmp = link.nextSibling;
  2232. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2233. }
  2234. else
  2235. {
  2236. link.parentNode.appendChild(createImage(urlImg,infos));
  2237. }
  2238. }
  2239. }
  2240. }
  2241. }
  2242. catch(e)
  2243. {
  2244. window.alert(e);
  2245. }
  2246. }
  2247.  
  2248. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2249. {
  2250. try
  2251. {
  2252. if(!listeMonstreEnchantement)
  2253. computeCompoEnchantement();
  2254. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2255. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2256. if(nodes.snapshotLength == 0)
  2257. return false;
  2258. var urlImg = URL_MZimg + 'enchant.png';
  2259. for(var i = 0; i < nodes.snapshotLength; i++)
  2260. {
  2261. var link = nodes.snapshotItem(i);
  2262. var idEquipement = link.getAttribute('href');
  2263. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2264. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2265. var nomEquipement = trim(link.firstChild.nodeValue);
  2266. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2267. if(!enchanteur || enchanteur == '')
  2268. continue;
  2269. var infos = listeEquipementEnchantement[idEquipement];
  2270. infos=formateTexte(infos);
  2271. if(infos.length>0)
  2272. {
  2273. if(link.parentNode == link.nextSibling.parentNode)
  2274. {
  2275. var tmp = link.nextSibling;
  2276. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2277. }
  2278. else
  2279. {
  2280. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2281. }
  2282. }
  2283. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2284. }
  2285. }
  2286. catch(e)
  2287. {
  2288. window.alert(e);
  2289. }
  2290. }
  2291.  
  2292. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2293.  
  2294.  
  2295. // Les % de toucher
  2296. var c = new Array();
  2297.  
  2298. // coefficients binomiaux
  2299. function cnp(n,k)
  2300. {
  2301. if(c[n] != null && c[n][k] != null)
  2302. return c[n][k];
  2303. if(c[n] == null)
  2304. c[n] = new Array();
  2305. if(k==0)
  2306. {
  2307. c[n][k] = 1;
  2308. return 1;
  2309. }
  2310. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2311. c[n][k] = result;
  2312. // Roule debug
  2313. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2314. return result;
  2315. }
  2316.  
  2317. // by Dab, à comparer
  2318. function binom(n,p) {
  2319. if(p<0 || p>n) return 0;
  2320. if(c[n])
  2321. if(c[n][p]) return c[n][p];
  2322. else {
  2323. c[n]=[1];
  2324. c[n][n]=1;
  2325. if(p==0 || p==n) return 1;
  2326. }
  2327. if(2*p>n)
  2328. c[n][p]=binom(n,n-p);
  2329. else
  2330. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2331. return c[n][p];
  2332. }
  2333.  
  2334. var coeff = new Array();
  2335.  
  2336. function coef(n,p)
  2337. {
  2338. if(n==0 && p==0)
  2339. return 1;
  2340. if(p>n*3.5)
  2341. p = 7*n-p
  2342. // roule désactive cache
  2343. if(coeff[n] != null && coeff[n][p] !=null)
  2344. return coeff[n][p];
  2345. if(coeff[n] == null)
  2346. coeff[n] = new Array();
  2347. var kmax = Math.floor((p-n)/6);
  2348. var x=0;
  2349. for(var k=0;k<=kmax;k++)
  2350. {
  2351. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2352. }
  2353. coeff[n][p] = x;
  2354. // Roule debug
  2355. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2356. return x;
  2357. }
  2358.  
  2359. function chanceEsquiveParfaite(a,d,ba,bd)
  2360. {
  2361. var win = 0;
  2362. var los = 0;
  2363. if(ba==null)
  2364. ba=0;
  2365. if(bd==null)
  2366. bd=0;
  2367. /* if(6*a+ba<2*(d+bd))
  2368. return 100;
  2369. if(a+ba>2*(6*d+bd))
  2370. return 0;*/
  2371. for(var ds=d;ds<=6*d;ds++)
  2372. {
  2373. var cd = coef(d,ds);
  2374. for(var as=a;as<=6*a;as++)
  2375. {
  2376. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2377. win += cd * coef(a,as);
  2378. else
  2379. los += cd * coef(a,as);
  2380. }
  2381. }
  2382. // roule debug
  2383. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2384. return Math.round(100*win/(win+los));
  2385. }
  2386.  
  2387. function chanceTouche(a,d,ba,bd)
  2388. {
  2389. var win = 0;
  2390. var los = 0;
  2391. if(ba==null)
  2392. ba=0;
  2393. if(bd==null)
  2394. bd=0;
  2395. if(a+ba>6*d+bd)
  2396. return 100;
  2397. if(6*a+ba<d+bd)
  2398. return 0;
  2399. for(var ds=d;ds<=6*d;ds++)
  2400. {
  2401. var cd = coef(d,ds);
  2402. for(var as=a;as<=6*a;as++)
  2403. {
  2404. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2405. win += cd * coef(a,as);
  2406. else
  2407. los += cd * coef(a,as);
  2408. }
  2409. }
  2410. return Math.round(100*win/(win+los));
  2411. }
  2412.  
  2413. function chanceCritique(a,d,ba,bd)
  2414. {
  2415. var win = 0;
  2416. var los = 0;
  2417. if(ba==null)
  2418. ba=0;
  2419. if(bd==null)
  2420. bd=0;
  2421. if(a+ba>2*(6*d+bd))
  2422. return 100;
  2423. if(6*a+ba<2*(d+bd))
  2424. return 0;
  2425. for(var ds=d;ds<=6*d;ds++)
  2426. {
  2427. var cd = coef(d,ds);
  2428. for(var as=a;as<=6*a;as++)
  2429. {
  2430. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2431. win += cd * coef(a,as);
  2432. else
  2433. los += cd * coef(a,as);
  2434. }
  2435. }
  2436. return Math.round(100*win/(win+los));
  2437. }
  2438.  
  2439. /***********************************************
  2440. Analyse tactique
  2441. ***********************************************/
  2442.  
  2443. function getTexteAnalyse(modificateur,chiffre)
  2444. {
  2445. if(chiffre==0)
  2446. return chiffre;
  2447. return modificateur+chiffre;
  2448. }
  2449.  
  2450. // rend le HTML pour le tableau de la "calculette"
  2451. function getAnalyseTactique(id,nom)
  2452. {
  2453. var donneesMonstre = listeCDM[id];
  2454. var needAutres=false;
  2455. var i;
  2456. if(donneesMonstre == null)
  2457. return;
  2458. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2459. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2460. if(array==null)
  2461. return "";
  2462. 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>";
  2463. for(i=0;i<array.length;i++)
  2464. {
  2465. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2466. {
  2467. needAutres=true;
  2468. break;
  2469. }
  2470. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2471. 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>";
  2472. else if(i==0) // attaque du monstre sur le Trõll => italique
  2473. 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>";
  2474. else // autre, pas de décoration
  2475. 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>";
  2476. }
  2477. if(needAutres)
  2478. {
  2479. if(i==array.length-1)
  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. else if(i==1)
  2482. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2483. else
  2484. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2485. }
  2486. return str+"</table>";
  2487. }
  2488.  
  2489. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2490. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2491. function analyseTactique(donneesMonstre,nom) {
  2492. try
  2493. {
  2494. var listeAttaques = [];
  2495. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2496. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2497. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2498. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2499. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2500. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2501. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2502. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2503. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2504. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2505. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2506. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2507. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2508. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2509. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2510. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2511. var modificateurEsquive = '';
  2512. var modificateurArmure = '';
  2513. var modificateurMagie = '';
  2514. var modificateurEsquiveM = '';
  2515. var modificateurArmureM = '';
  2516. var pasDeSR=false;
  2517. var esqM,attM,armM,degM;
  2518. 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)
  2519. return null;
  2520. var td = document.createElement('td')
  2521. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2522. var esqM = 0;
  2523. try
  2524. {
  2525. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2526. }
  2527. catch(e)
  2528. {
  2529. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2530. modificateurEsquive = '<';
  2531. modificateurArmure = '<';
  2532. modificateurMagie = '<';
  2533. }
  2534. td.innerHTML = bbcode(donneesMonstre[3]);
  2535. var attM = 0;
  2536. try
  2537. {
  2538. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2539. }
  2540. catch(e)
  2541. {
  2542. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2543. modificateurEsquiveM = '>';
  2544. modificateurArmureM = '>';
  2545. }
  2546. td.innerHTML = bbcode(donneesMonstre[5]);
  2547. var degM = 0;
  2548. try
  2549. {
  2550. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2551. }
  2552. catch(e)
  2553. {
  2554. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2555. modificateurArmureM = '>';
  2556. }
  2557. td.innerHTML = bbcode(donneesMonstre[7]);
  2558. var armM = 0;
  2559. try
  2560. {
  2561. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2562. }
  2563. catch(e)
  2564. {
  2565. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2566. modificateurArmure = '<';
  2567. }
  2568. var coeffSeuil = 0.95;
  2569. try
  2570. {
  2571. td.innerHTML = bbcode(donneesMonstre[9]);
  2572. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2573. var v = (rm / mm);
  2574. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2575. coeffSeuil = (200-seuil)/200;
  2576. }
  2577. catch(e)
  2578. {
  2579. modificateurMagie = '<';
  2580. pasDeSR = true;
  2581. }
  2582. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2583. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2584. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2585. // roule debug
  2586. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2587. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2588. 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);
  2589. //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);
  2590. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2591. if(getSortComp("Vampirisme")>0)
  2592. {
  2593. var pour = getSortComp("Vampirisme");
  2594. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2595. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2596. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2597. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2598. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2599. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2600. }
  2601. if(getSortComp("Siphon des âmes")>0)
  2602. {
  2603. var pour = getSortComp("Siphon des âmes");
  2604. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2605. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2606. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2607. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2608. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2609. }
  2610. if(getSortComp("Botte Secrète")>0)
  2611. {
  2612. var pour = getSortComp("Botte Secrète");
  2613. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2614. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2615. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2616. 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;
  2617. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2618. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2619. }
  2620. if(getSortComp("Rafale Psychique")>0)
  2621. {
  2622. var pour = getSortComp("Rafale Psychique");
  2623. chanceDEsquiveParfaite = 0;
  2624. chanceDeTouche = Math.round(100*pour/100);
  2625. chanceDeCritique = Math.round(0*pour/100);
  2626. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2627. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2628. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2629. }
  2630. if(getSortComp("Explosion")>0)
  2631. {
  2632. var pour = getSortComp("Explosion");
  2633. chanceDEsquiveParfaite = 0;
  2634. chanceDeTouche = Math.round(100*pour/100);
  2635. chanceDeCritique = Math.round(0*pour/100);
  2636. 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;
  2637. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2638. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2639. }
  2640. if(getSortComp("Projectile Magique")>0)
  2641. {
  2642. var pour = getSortComp("Projectile Magique");
  2643. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2644. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2645. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2646. 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;
  2647. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2648. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2649. }
  2650. if(getSortComp("Frénésie")>0)
  2651. {
  2652. var pour = getSortComp("Frénésie");
  2653. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2654. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2655. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2656. 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;
  2657. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2658. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2659. }
  2660. if(getSortComp("Charger")>0)
  2661. {
  2662. var pour = getSortComp("Charger");
  2663. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2664. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2665. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2666. 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;
  2667. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2668. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2669. }
  2670. if(getSortComp("Griffe du Sorcier")>0)
  2671. {
  2672. var pour = getSortComp("Griffe du Sorcier");
  2673. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2674. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2675. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2676. 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;
  2677. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2678. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2679. }
  2680. if(getSortComp("Attaque Précise",1)>0)
  2681. {
  2682. var niveau = 5;
  2683. var oldPour = 0;
  2684. var chanceDEsquiveParfaite = 0;
  2685. var chanceDeTouche = 0;
  2686. var chanceDeCritique = 0;
  2687. degats = 0;
  2688. while(niveau>0)
  2689. {
  2690. var pour = getSortComp("Attaque Précise",niveau);
  2691. if(pour>oldPour)
  2692. {
  2693. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2694. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2695. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2696. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2697. chanceDeTouche += chanceDeToucheNiveau;
  2698. chanceDeCritique += chanceDeCritiqueNiveau;
  2699. 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);
  2700. oldPour = pour;
  2701. }
  2702. niveau--;
  2703. }
  2704. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2705. 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));
  2706. }
  2707. if(getSortComp("Coup de Butoir",1)>0)
  2708. {
  2709. var niveau = 5;
  2710. var oldPour =0;
  2711. var chanceDEsquiveParfaite = 0;
  2712. var chanceDeTouche=0;
  2713. var chanceDeCritique=0;
  2714. degats=0;
  2715. while(niveau>0)
  2716. {
  2717. var pour = getSortComp("Coup de Butoir",niveau);
  2718. if(pour>oldPour)
  2719. {
  2720. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2721. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2722. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2723. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2724. chanceDeTouche += chanceDeToucheNiveau;
  2725. chanceDeCritique += chanceDeCritiqueNiveau;
  2726. 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);
  2727. oldPour = pour;
  2728. }
  2729. niveau--;
  2730. }
  2731. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2732. 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));
  2733. }
  2734. 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;});
  2735. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2736. {
  2737. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2738. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2739. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2740. }
  2741. else
  2742. {
  2743. chanceDEsquiveParfaite = 0;
  2744. chanceDeTouche = 100;
  2745. chanceDeCritique = 0;
  2746. }
  2747. 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;
  2748.  
  2749. 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));
  2750. return listeAttaques;
  2751. }
  2752. catch(e) { window.alert(e);}
  2753. }
  2754.  
  2755. // x~~x marque pour s'y retrouver sous l'éditeur
  2756.  
  2757. /*
  2758. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2759. * published under GNU License v2.
  2760. *
  2761. * Patch :
  2762. * gestion des missions terminées
  2763. */
  2764. // x~x mission_liste
  2765.  
  2766. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2767. try {
  2768. var titresMimis = document.evaluate(
  2769. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2770. document, null, 7, null
  2771. );
  2772. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2773. } catch(e) {
  2774. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2775. return;
  2776. }
  2777. var enCours = {};
  2778. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2779. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2780. enCours[num] = true;
  2781. }
  2782. for(var numMimi in obMissions) {
  2783. if(!enCours[numMimi]) {
  2784. delete obMissions[numMimi];
  2785. }
  2786. }
  2787. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2788. }
  2789.  
  2790. function do_mission_liste() {
  2791. checkLesMimis();
  2792. }
  2793.  
  2794. /*******************************************************************************
  2795. * This file is part of Mountyzilla. *
  2796. * *
  2797. * Mountyzilla is free software; you can redistribute it and/or modify *
  2798. * it under the terms of the GNU General Public License as published by *
  2799. * the Free Software Foundation; either version 2 of the License, or *
  2800. * (at your option) any later version. *
  2801. * *
  2802. * Mountyzilla is distributed in the hope that it will be useful, *
  2803. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2804. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2805. * GNU General Public License for more details. *
  2806. * *
  2807. * You should have received a copy of the GNU General Public License *
  2808. * along with Mountyzilla; if not, write to the Free Software *
  2809. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2810. *******************************************************************************/
  2811.  
  2812. // x~x actions
  2813.  
  2814. /* TODO
  2815. * getLvl pour Explo, Rotobaffe et cie
  2816. */
  2817.  
  2818.  
  2819.  
  2820. /* Page de combat */
  2821.  
  2822. function getLevel() {
  2823. var divList = document.getElementsByTagName('div');
  2824. if(divList.length <= 2)
  2825. return;
  2826. // On essaie de voir si cette action était une attaque
  2827. var pList = document.getElementsByTagName('p');
  2828. var nomM = '';
  2829. // Modification pour Frénésie by TetDure
  2830. var numAtt = 0;
  2831. for (var i = 0; i < pList.length; i++) {
  2832. if(pList[i].firstChild) {
  2833. nomM = pList[i].firstChild.nodeValue;
  2834. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2835. numAtt++;
  2836. }
  2837. }
  2838. if(nomM == '')
  2839. return;
  2840. // Si c'est une attaque normale, un seul PX
  2841. var comPX = 1;
  2842. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2843. comPX++;
  2844.  
  2845. // Extraction des infos du monstre attaqué
  2846. var idM;
  2847. var male;
  2848. if(nomM.slice(20, 21) == 'e') {
  2849. male = false;
  2850. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2851. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2852. }
  2853. else {
  2854. male = true;
  2855. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2856. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2857. }
  2858. if(idM == '')
  2859. return;
  2860. var bList = document.getElementsByTagName('b');
  2861. var niveau = '';
  2862. for (var i = 0; i < bList.length; i++) {
  2863. var b = bList[i];
  2864. if(b.childNodes[0].nodeValue != "TUÉ")
  2865. continue;
  2866. var nbPX = "";
  2867. for (i++; i < bList.length; i++) {
  2868. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2869. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2870. return;
  2871. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2872. nbPX = bList[i].childNodes[0].nodeValue;
  2873. break;
  2874. }
  2875. }
  2876. if(nbPX == '')
  2877. return;
  2878. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2879. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2880. if(!nbPX)
  2881. nbPX = 0;
  2882. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2883. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2884. if(comPX > nbPX) {
  2885. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2886. niveau = "";
  2887. } else if(Math.floor(niveau) == niveau) {
  2888. chaine += niveau + ".";
  2889. } else {
  2890. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2891. niveau = "";
  2892. }
  2893. insertBr(b.nextSibling.nextSibling.nextSibling);
  2894. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2895. }
  2896.  
  2897. if(niveau != '') {
  2898. var button = insertButtonCdm('as_Action');
  2899. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2900. + escape(nomM) + "&niveau=" + escape(niveau)
  2901. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2902. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2903. }
  2904. }
  2905.  
  2906.  
  2907. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2908.  
  2909. function insertInfoMagie(node, intitule, magie) {
  2910. if(node.nextSibling) {
  2911. node = node.nextSibling;
  2912. insertBr(node);
  2913. insertText(node, intitule);
  2914. insertText(node, magie, true);
  2915. } else {
  2916. node = node.parentNode;
  2917. appendBr(node);
  2918. appendText(node, intitule);
  2919. appendText(node, magie, true);
  2920. }
  2921. }
  2922.  
  2923. function getMM(sr) {
  2924. if(rmTroll<=0) {
  2925. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2926. }
  2927. sr = Number(sr.match(/\d+/)[0]);
  2928. if(sr==10) {
  2929. return '\u2265 '+5*rmTroll;
  2930. }
  2931. if(sr<=50) {
  2932. return Math.round(50*rmTroll/sr);
  2933. }
  2934. if(sr<90) {
  2935. return Math.round((100-sr)*rmTroll/50);
  2936. }
  2937. return '\u2264 '+Math.round(rmTroll/5);
  2938. }
  2939.  
  2940. function traiteMM() {
  2941. var node = document.evaluate(
  2942. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2943. document, null, 9, null).singleNodeValue;
  2944. if(node) {
  2945. var mm = getMM(node.nodeValue);
  2946. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2947. } else {
  2948. var node = document.evaluate(
  2949. "//p/text()[contains(., 'Seuil de Résistance')]",
  2950. document, null, 9, null).singleNodeValue;
  2951. if(!node) {
  2952. return;
  2953. }
  2954. var mm = getMM(node.nodeValue);
  2955. node = node.nextSibling.nextSibling;
  2956. }
  2957. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2958. }
  2959.  
  2960. function getRM(sr) {
  2961. if(mmTroll<=0) {
  2962. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2963. }
  2964. sr = Number(sr.match(/\d+/)[0]);
  2965. if(sr==10) {
  2966. return '\u2264 '+Math.round(mmTroll/5);
  2967. }
  2968. if(sr<=50) {
  2969. return Math.round(sr*mmTroll/50);
  2970. }
  2971. if(sr<90) {
  2972. return Math.round(50*mmTroll/(100-sr));
  2973. }
  2974. return '\u2265 '+5*mmTroll;
  2975. }
  2976.  
  2977. function traiteRM() {
  2978. var nodes = document.evaluate(
  2979. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2980. document, null, 7, null);
  2981. if(nodes.snapshotLength==0) {
  2982. return;
  2983. }
  2984. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  2985. var node = nodes.snapshotItem(i);
  2986. var rm = getRM(node.nodeValue);
  2987. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2988. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  2989. }
  2990. }
  2991.  
  2992.  
  2993. /* Fonction stats IdT par Raistlin */
  2994. /*function getIdt() {
  2995. if(MY_getValue("SEND_IDT") == "non")
  2996. return false;
  2997. var regExpBeginning = /^\s+/;
  2998. var regExpEnd = /\s+$/;
  2999.  
  3000. var nomIdt = document.evaluate(
  3001. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3002. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3003. if(!nomIdt)
  3004. return false;
  3005.  
  3006. var caracIdt;
  3007. if(nomIdt.indexOf("Malédiction !") != -1) {
  3008. caracIdt = "";
  3009. nomIdt = "Mission maudite";
  3010. } else {
  3011. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3012. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3013. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3014. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3015. }
  3016. FF_XMLHttpRequest({
  3017. method: 'GET',
  3018. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3019. headers : {
  3020. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3021. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3022. }
  3023. });
  3024. return true;
  3025. }*/
  3026.  
  3027.  
  3028. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3029.  
  3030. function confirmeDecalage() {
  3031. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3032. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3033. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3034. var newDLA = new Date( oldDLA );
  3035. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3036. return window.confirm(
  3037. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3038. +'\nConfirmez-vous ce décalage ?'
  3039. );
  3040. }
  3041.  
  3042. function newsubmitDLA(evt) {
  3043. evt.stopPropagation();
  3044. evt.preventDefault();
  3045. if(confirmeDecalage()) {
  3046. this.submit();
  3047. }
  3048. }
  3049.  
  3050. function changeActionDecalage() {
  3051. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3052. return;
  3053. }
  3054. try {
  3055. // On récupère le contenu du script JS MH de calcul du décalage
  3056. var scriptTxt = document.evaluate(
  3057. ".//script[ not(@src) ]",
  3058. document, null, 9, null
  3059. ).singleNodeValue.textContent;
  3060. // On en extrait la DLA courante
  3061. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3062. scriptTxt = scriptTxt.split('\n')[0];
  3063. var nbs = scriptTxt.match(/\d+/g);
  3064. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3065. } catch(e) {
  3066. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3067. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3068. return;
  3069. }
  3070. var form = document.getElementsByName('ActionForm')[0];
  3071. if(form) {
  3072. form.addEventListener('submit', newsubmitDLA, true);
  3073. } else {
  3074. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3075. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3076. }
  3077. }
  3078.  
  3079. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3080.  
  3081. function prochainMundi() {
  3082. try {
  3083. var node = document.evaluate(
  3084. "//div[@class='dateAction']/b",
  3085. document, null, 9, null
  3086. ).singleNodeValue;
  3087. } catch(e) {
  3088. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3089. return;
  3090. }
  3091. if(!node) { return; }
  3092.  
  3093. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3094. var jour = longueurMois+1-getNumber(node.textContent);
  3095. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3096. var txt = '[Prochain Mundidey ';
  3097. if(jour>1) {
  3098. txt += 'dans '+jour+' jours]';
  3099. } else {
  3100. txt += 'demain]';
  3101. }
  3102. insertText(node.parentNode.nextSibling,txt,true);
  3103. }
  3104.  
  3105.  
  3106. /* Fonction principale */
  3107.  
  3108. function dispatch() {
  3109. if(isPage('MH_Play/Play_action')) {
  3110. prochainMundi();
  3111. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3112. var oldDLA;
  3113. changeActionDecalage();
  3114. } else if(isPage('MH_Play/Actions')) {
  3115. if(document.evaluate(
  3116. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3117. document, null, 2, null
  3118. ).stringValue) {
  3119. traiteMM();
  3120. } else if(document.evaluate(
  3121. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3122. document, null, 2, null
  3123. ).stringValue) {
  3124. //getIdt();
  3125. traiteRM();
  3126. } /*else {
  3127. // Est censé se lancer sur quoi *précisément* ?
  3128. traiteRM();
  3129. getLevel();
  3130. }*/
  3131. } else {
  3132. /* Traitement des messages du bot */
  3133. var messageTitle = document.evaluate(
  3134. "//form/table/tbody/tr[1]/td[1]/"
  3135. +"descendant::text()[contains(.,'[MountyHall]')]",
  3136. document, null, 2, null
  3137. ).stringValue;
  3138. if(messageTitle.indexOf('Attaquant') != -1 &&
  3139. messageTitle.indexOf('sur') != -1) {
  3140. getLevel();
  3141. traiteRM();
  3142. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3143. messageTitle.indexOf('Défenseur') != -1) {
  3144. traiteMM();
  3145. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3146. // à replacer avec Attaque après révision getLvl :
  3147. messageTitle.indexOf('Explosion') != -1 ||
  3148. messageTitle.indexOf('Insulte') != -1) {
  3149. traiteRM();
  3150. }
  3151. }
  3152. }
  3153.  
  3154. function do_actions() {
  3155. start_script(31);
  3156. dispatch();
  3157. displayScriptTime();
  3158. }
  3159.  
  3160. /*********************************************************************************
  3161. * This file is part of Mountyzilla. *
  3162. * *
  3163. * Mountyzilla is free software; you can redistribute it and/or modify *
  3164. * it under the terms of the GNU General Public License as published by *
  3165. * the Free Software Foundation; either version 2 of the License, or *
  3166. * (at your option) any later version. *
  3167. * *
  3168. * Mountyzilla is distributed in the hope that it will be useful, *
  3169. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3170. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3171. * GNU General Public License for more details. *
  3172. * *
  3173. * You should have received a copy of the GNU General Public License *
  3174. * along with Mountyzilla; if not, write to the Free Software *
  3175. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3176. *********************************************************************************/
  3177.  
  3178. // x~x pre-enchant
  3179.  
  3180. /* 2013-08-19 : correction auto syntaxe alert */
  3181.  
  3182. var combobox=null;
  3183.  
  3184. function changeObject()
  3185. {
  3186. if(!combobox)
  3187. return ;
  3188. var id = combobox.options[combobox.selectedIndex].value;
  3189. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3190. if(!id || id=="")
  3191. {
  3192. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3193. return;
  3194. }
  3195. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3196. }
  3197.  
  3198. function treatePreEnchantement() {
  3199. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3200. if(!input || input.getAttribute("type")=="hidden")
  3201. {
  3202. return false;
  3203. }
  3204. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3205. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3206. if(!combobox)
  3207. {
  3208. return true;
  3209. }
  3210. combobox.addEventListener('change', changeObject, true);
  3211. return true;
  3212. }
  3213.  
  3214. function treateEnchantement() {
  3215. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3216. if(!input || input.getAttribute("type")!="hidden")
  3217. {
  3218. return false;
  3219. }
  3220. var idEquipement = input.getAttribute("value");
  3221. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3222. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3223. if(enchanteur && enchanteur != null)
  3224. return true;
  3225. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3226. if(!input || input.getAttribute("type")!="hidden")
  3227. {
  3228. return false;
  3229. }
  3230. var idEnchanteur = input.getAttribute("value");
  3231. var nodes = document.evaluate(
  3232. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3233. if (nodes.snapshotLength != 3)
  3234. return;
  3235. for(var i=0;i<3;i++)
  3236. {
  3237. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3238. texte = texte.replace(" d'une "," d'un ");
  3239. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3240. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3241. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3242. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3243. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3244. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3245. }
  3246. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3247. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3248. var liste = MY_getValue(numTroll+".enchantement.liste");
  3249. if(!liste || liste=="")
  3250. {
  3251. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3252. }
  3253. else
  3254. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3255. }
  3256.  
  3257. function do_pre_enchant() {
  3258. start_script(60);
  3259. if(!treatePreEnchantement())
  3260. treateEnchantement();
  3261. displayScriptTime();
  3262. }
  3263.  
  3264. /*********************************************************************************
  3265. * This file is part of Mountyzilla. *
  3266. * *
  3267. * Mountyzilla is free software; you can redistribute it and/or modify *
  3268. * it under the terms of the GNU General Public License as published by *
  3269. * the Free Software Foundation; either version 2 of the License, or *
  3270. * (at your option) any later version. *
  3271. * *
  3272. * Mountyzilla is distributed in the hope that it will be useful, *
  3273. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3274. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3275. * GNU General Public License for more details. *
  3276. * *
  3277. * You should have received a copy of the GNU General Public License *
  3278. * along with Mountyzilla; if not, write to the Free Software *
  3279. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3280. *********************************************************************************/
  3281.  
  3282. // x~x enchant
  3283.  
  3284. /* 2013-08-19 : correction auto syntaxe alert */
  3285.  
  3286. function treateEnchantement() {
  3287. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3288. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3289. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3290. return;
  3291. var tab = infoEquipement.split(";");
  3292. if(tab.length<2)
  3293. return;
  3294. var idEquipement = tab[0];
  3295. var nomEquipement = tab[1];
  3296. for(var i=2;i<tab.length;i++)
  3297. nomEquipement += ";"+tab[i];
  3298. var nodes = document.evaluate(
  3299. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3300. if (nodes.snapshotLength != 3)
  3301. return;
  3302. for(var i=0;i<3;i++)
  3303. {
  3304. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3305. texte = texte.replace(" d'une "," d'un ");
  3306. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3307. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3308. monstre = monstre.replace(/ Géante?/,"");
  3309. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3310. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3311. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3312. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3313. }
  3314. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3315. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3316. var liste = MY_getValue(numTroll+".enchantement.liste");
  3317. if(!liste || liste=="")
  3318. {
  3319. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3320. }
  3321. else
  3322. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3323. }
  3324.  
  3325. function do_enchant() {
  3326. start_script(60);
  3327.  
  3328. treateEnchantement();
  3329. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3330. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3331. displayScriptTime();
  3332. }
  3333.  
  3334. /*********************************************************************************
  3335. * This file is part of Mountyzilla. *
  3336. * *
  3337. * Mountyzilla is free software; you can redistribute it and/or modify *
  3338. * it under the terms of the GNU General Public License as published by *
  3339. * the Free Software Foundation; either version 2 of the License, or *
  3340. * (at your option) any later version. *
  3341. * *
  3342. * Mountyzilla is distributed in the hope that it will be useful, *
  3343. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3344. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3345. * GNU General Public License for more details. *
  3346. * *
  3347. * You should have received a copy of the GNU General Public License *
  3348. * along with Mountyzilla; if not, write to the Free Software *
  3349. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3350. *********************************************************************************/
  3351.  
  3352. // x~x myevent
  3353.  
  3354. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3355. function do_myevent() {
  3356. }
  3357.  
  3358. /*********************************************************************************
  3359. * This file is part of Mountyzilla. *
  3360. * *
  3361. * Mountyzilla is free software; you can redistribute it and/or modify *
  3362. * it under the terms of the GNU General Public License as published by *
  3363. * the Free Software Foundation; either version 2 of the License, or *
  3364. * (at your option) any later version. *
  3365. * *
  3366. * Mountyzilla is distributed in the hope that it will be useful, *
  3367. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3368. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3369. * GNU General Public License for more details. *
  3370. * *
  3371. * You should have received a copy of the GNU General Public License *
  3372. * along with Mountyzilla; if not, write to the Free Software *
  3373. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3374. *********************************************************************************/
  3375.  
  3376. // x~x malus
  3377.  
  3378. /* v1.4 - 2014-01-06
  3379. * - Gestion des sorts double composante
  3380. * v1.4.1 - 2014-01-22
  3381. * - Correction décumul
  3382. * TODO
  3383. * - Identifier la position de "PV" dans l'ordre MH
  3384. */
  3385.  
  3386. var listeBM;
  3387.  
  3388.  
  3389. /* [functions] Utilitaires */
  3390.  
  3391. function decumul(bmt,nbr) {
  3392. var bmr;
  3393. if(!nbr || nbr<2) bmr = bmt;
  3394. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3395. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3396. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3397. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3398. else bmr = parseInt(0.1*bmt);
  3399. if(bmt<0) return Math.min(-1,bmr);
  3400. return Math.max(1,bmr);
  3401. }
  3402.  
  3403. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3404. // Roule 23/11/2016 ajout PV
  3405. switch( a ) {
  3406. case 'ATT':
  3407. return -1;
  3408. case 'ESQ':
  3409. if(b=='ATT') return 1;
  3410. return -1;
  3411. case 'DEG':
  3412. switch( b ) {
  3413. case 'ATT':
  3414. case 'ESQ':
  3415. return 1;
  3416. default:
  3417. return -1;
  3418. }
  3419. case 'REG':
  3420. switch( b ) {
  3421. case 'ATT':
  3422. case 'ESQ':
  3423. case 'DEG':
  3424. return 1;
  3425. default:
  3426. return -1;
  3427. }
  3428. case 'Vue':
  3429. switch( b ) {
  3430. case 'ATT':
  3431. case 'ESQ':
  3432. case 'DEG':
  3433. case 'REG':
  3434. return 1;
  3435. default:
  3436. return -1;
  3437. }
  3438. case 'TOUR':
  3439. switch( b ) {
  3440. case 'ATT':
  3441. case 'ESQ':
  3442. case 'DEG':
  3443. case 'REG':
  3444. case 'Vue':
  3445. return 1;
  3446. default:
  3447. return -1;
  3448. }
  3449. case 'PV':
  3450. switch( b ) {
  3451. case 'ATT':
  3452. case 'ESQ':
  3453. case 'DEG':
  3454. case 'REG':
  3455. case 'Vue':
  3456. case 'TOUR':
  3457. return 1;
  3458. default:
  3459. return -1;
  3460. }
  3461. case 'Armure':
  3462. switch( b ) {
  3463. case 'ATT':
  3464. case 'ESQ':
  3465. case 'DEG':
  3466. case 'REG':
  3467. case 'Vue':
  3468. case 'TOUR':
  3469. case 'PV':
  3470. return 1;
  3471. default:
  3472. return -1;
  3473. }
  3474. case 'RM':
  3475. switch( b ) {
  3476. case 'ATT':
  3477. case 'ESQ':
  3478. case 'DEG':
  3479. case 'REG':
  3480. case 'Vue':
  3481. case 'TOUR':
  3482. case 'PV':
  3483. case 'Armure':
  3484. return 1;
  3485. default:
  3486. return -1;
  3487. }
  3488. case 'MM':
  3489. switch( b ) {
  3490. case 'ATT':
  3491. case 'ESQ':
  3492. case 'DEG':
  3493. case 'REG':
  3494. case 'Vue':
  3495. case 'TOUR':
  3496. case 'PV':
  3497. case 'Armure':
  3498. case 'RM':
  3499. return 1;
  3500. default:
  3501. return -1;
  3502. }
  3503. case 'Concentration':
  3504. switch( b ) {
  3505. case 'ATT':
  3506. case 'ESQ':
  3507. case 'DEG':
  3508. case 'REG':
  3509. case 'Vue':
  3510. case 'TOUR':
  3511. case 'PV':
  3512. case 'Armure':
  3513. case 'RM':
  3514. case 'MM':
  3515. return 1;
  3516. default:
  3517. return -1;
  3518. }
  3519. case 'Fatigue':
  3520. switch( b ) {
  3521. case 'ATT':
  3522. case 'ESQ':
  3523. case 'DEG':
  3524. case 'REG':
  3525. case 'Vue':
  3526. case 'TOUR':
  3527. case 'PV':
  3528. case 'Armure':
  3529. case 'RM':
  3530. case 'MM':
  3531. case 'Concentration':
  3532. return 1;
  3533. default:
  3534. return -1;
  3535. }
  3536. case "Dés d'attaque":
  3537. switch( b ) {
  3538. case 'ATT':
  3539. case 'ESQ':
  3540. case 'DEG':
  3541. case 'REG':
  3542. case 'Vue':
  3543. case 'TOUR':
  3544. case 'PV':
  3545. case 'Armure':
  3546. case 'RM':
  3547. case 'MM':
  3548. case 'Concentration':
  3549. case 'Fatigue':
  3550. return 1;
  3551. default:
  3552. return -1;
  3553. }
  3554. case 'Dés de dégâts':
  3555. switch( b ) {
  3556. case 'ATT':
  3557. case 'ESQ':
  3558. case 'DEG':
  3559. case 'REG':
  3560. case 'Vue':
  3561. case 'TOUR':
  3562. case 'PV':
  3563. case 'Armure':
  3564. case 'RM':
  3565. case 'MM':
  3566. case 'Concentration':
  3567. case 'Fatigue':
  3568. case "Dés d'attaque":
  3569. return 1;
  3570. default:
  3571. return -1;
  3572. }
  3573. default :
  3574. switch( b ) {
  3575. case 'ATT':
  3576. case 'ESQ':
  3577. case 'DEG':
  3578. case 'REG':
  3579. case 'Vue':
  3580. case 'TOUR':
  3581. case 'PV':
  3582. case 'Armure':
  3583. case 'RM':
  3584. case 'MM':
  3585. case 'Concentration':
  3586. case 'Fatigue':
  3587. case "Dés d'attaque":
  3588. case 'Dés de dégâts':
  3589. return 1;
  3590. default:
  3591. return -1;
  3592. }
  3593. }
  3594. }
  3595.  
  3596.  
  3597. /* [functions] Fonctions hide / display */
  3598.  
  3599. function toggleDetailsBM() {
  3600. if(MY_getValue('BMDETAIL')!='false') {
  3601. MY_setValue('BMDETAIL','false');
  3602. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3603. for(var i=0 ; i<trlist.length ; i++)
  3604. trlist[i].style.display = 'none';
  3605. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3606. for(var i=0 ; i<trlist.length ; i++)
  3607. trlist[i].style = '';
  3608. }
  3609. else {
  3610. MY_setValue('BMDETAIL','true');
  3611. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3612. for(var i=0 ; i<trlist.length ; i++)
  3613. trlist[i].style.display = 'none';
  3614. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3615. for(var i=0 ; i<trlist.length ; i++)
  3616. trlist[i].style = '';
  3617. }
  3618. }
  3619.  
  3620. function toggleBMList() {
  3621. if(MY_getValue('BMHIDELIST')=='true') {
  3622. MY_setValue('BMHIDELIST','false');
  3623. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3624. listeBM.snapshotItem(i).style = '';
  3625. document.getElementsByTagName('thead')[0].style = '';
  3626. document.getElementById('trhelp').style = '';
  3627. }
  3628. else {
  3629. MY_setValue('BMHIDELIST','true');
  3630. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3631. listeBM.snapshotItem(i).style.display = 'none';
  3632. document.getElementsByTagName('thead')[0].style.display = 'none';
  3633. document.getElementById('trhelp').style.display = 'none';
  3634. }
  3635. }
  3636.  
  3637. function setDisplayBM() {
  3638. if(!listeBM) return;
  3639. var titre = document.getElementById('titre2');
  3640. if(titre) {
  3641. titre.style.cursor = 'pointer';
  3642. titre.onclick = toggleBMList;
  3643. }
  3644. var tfoot = document.getElementsByTagName('tfoot')[0];
  3645. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3646. tfoot, null, 9, null).singleNodeValue;
  3647. tr.id = 'trhelp';
  3648. if(MY_getValue('BMHIDELIST')=='true') {
  3649. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3650. listeBM.snapshotItem(i).style.display = 'none';
  3651. document.getElementsByTagName('thead')[0].style.display = 'none';
  3652. tr.style.display = 'none';
  3653. }
  3654. }
  3655.  
  3656.  
  3657. /* [functions] Fonction principale */
  3658.  
  3659. function traiteMalus() {
  3660. var mainTab = document.getElementsByTagName('table')[0];
  3661. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3662. if(listeBM.snapshotLength==0) return;
  3663. /* Suppression des BM de fatigue stockés */
  3664. if(MY_getValue(numTroll+'.bm.fatigue'))
  3665. MY_removeValue(numTroll+'.bm.fatigue');
  3666. /* Extraction des données */
  3667. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3668. var nb = 0;
  3669. while(nb<listeBM.snapshotLength) {
  3670. tr = listeBM.snapshotItem(nb); nb++;
  3671. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3672. var phymag = tr.childNodes[9].textContent;
  3673. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3674. var type = tr.childNodes[3].textContent, nom;
  3675. // si c'est un type à décumul
  3676. /*
  3677. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3678. switch(type) {
  3679. case 'Potion':
  3680. case 'Parchemin':
  3681. case 'Sortilège':
  3682. case 'Capacité Spéciale':
  3683. nom = tr.childNodes[1].textContent+phymag;
  3684. break;
  3685. default:
  3686. nom = 'pasdedecumul';
  3687. }
  3688. */
  3689. nom = tr.childNodes[1].textContent+phymag;
  3690. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3691. nom = 'pasdedecumul';
  3692. uniListe[nb] = {
  3693. 'duree':duree,
  3694. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3695. 'caracs':{}
  3696. }
  3697. for(var i=0 ; i<effetsT.length ; i++) {
  3698. if(effetsT[i].indexOf(':')==-1) continue;
  3699. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3700. // nom = 'pasdedecumul' si pas de décumul
  3701. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3702. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3703. uniListe[nb]['type'] = phymag;
  3704. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3705. var tmatch = effetsT[i].match(/(-?\d+)(\\(-?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3706. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3707. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3708. uniListe[nb]['caracs'][carac] = bm;
  3709. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3710. listeDurees[duree] = true;
  3711. }
  3712. } // fin boucle sur les lignes de bonus/malus
  3713. /* Gestion des décumuls et cumuls des durées */
  3714. var toursGeres = [];
  3715. for(var d in listeDurees) toursGeres.push(d);
  3716. toursGeres.sort( function (a,b){return b-a;} );
  3717. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3718. // pour sauvegarder les bm de fatigue
  3719. var strfat = '';
  3720. // Pour affichage & adpatation à footable.js (statique)
  3721. var thead = document.getElementsByTagName('thead')[0];
  3722. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3723. thead, null, 7, null).snapshotLength;
  3724. var tfoot = document.getElementsByTagName('tfoot')[0];
  3725. for(var i=0 ; i<toursGeres.length ; i++) {
  3726. var tour = toursGeres[i];
  3727. var effetsCeTour = {}; decumulsCeTour = {};
  3728. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3729. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3730. continue;
  3731. var nom = uniListe[nb]['nom'];
  3732. if(nom!='pasdedecumul') {
  3733. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3734. decumulsCeTour[nom]++;
  3735. }
  3736. for(var carac in uniListe[nb]['caracs']) {
  3737. var bm = uniListe[nb]['caracs'][carac];
  3738. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3739. var type = uniListe[nb]['type'];
  3740. if(!effetsCeTour[carac])
  3741. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3742. var thisBm;
  3743. if(nom=='pasdedecumul')
  3744. thisBm = bm;
  3745. else
  3746. thisBm = decumul(bm,decumulsCeTour[nom]);
  3747. effetsCeTour[carac][type] += thisBm;
  3748. 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]);
  3749. } else {
  3750. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3751. var thisBm;
  3752. if(nom=='pasdedecumul' || carac=='Fatigue')
  3753. thisBm = bm;
  3754. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3755. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3756. else
  3757. thisBm = decumul(bm,decumulsCeTour[nom]);
  3758. effetsCeTour[carac] += thisBm;
  3759. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3760. }
  3761. } // fin boucle sur les caractéristiques
  3762. } // fin boucle sur les bonus/malus
  3763. /* Création du bilan du tour */
  3764. var texteD = '', texteS = '';
  3765. var caracGerees = [];
  3766. for(var k in effetsCeTour) caracGerees.push(k);
  3767. caracGerees.sort( triecaracs );
  3768. for(var j=0 ; j<caracGerees.length ; j++) {
  3769. var carac = caracGerees[j], str = '';
  3770. switch( carac ) {
  3771. case 'ATT':
  3772. case 'DEG':
  3773. case 'Armure':
  3774. var phy = effetsCeTour[carac]['Physique'];
  3775. var mag = effetsCeTour[carac]['Magie'];
  3776. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3777. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3778. break;
  3779. case 'TOUR':
  3780. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3781. break;
  3782. case 'Fatigue':
  3783. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3784. case 'PV':
  3785. case 'ESQ':
  3786. case 'REG':
  3787. case 'Vue':
  3788. case 'Voir le Caché':
  3789. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3790. break;
  3791. default:
  3792. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3793. }
  3794. if(str) {
  3795. texteD += str;
  3796. texteS += str;
  3797. }
  3798. } // fin boucle sur les caractéristiques
  3799. /* Affichage */
  3800. // Si rien à afficher on passe
  3801. if(!texteD) continue;
  3802. // Si BMM+BMP=0
  3803. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3804. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3805. if(MY_getValue('BMDETAIL')=='false')
  3806. tr.style.display = 'none';
  3807. var td = appendTdText(tr,texteD.substring(3));
  3808. td.colSpan = 5-nbHidden;
  3809. var txttour = toursGeres[i]+' Tour';
  3810. if(toursGeres[i]>1) txttour += 's';
  3811. appendTdText(tr,txttour);
  3812. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3813. if(MY_getValue('BMDETAIL')!='false')
  3814. tr.style.display = 'none';
  3815. td = appendTdText(tr,texteS);
  3816. td.colSpan = 5-nbHidden;
  3817. appendTdText(tr,txttour);
  3818. } // fin boucle sur les tours générés
  3819. /* mise en place toggleDetails */
  3820. tfoot.style.cursor = 'pointer';
  3821. tfoot.onclick = toggleDetailsBM;
  3822. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3823. if(strfat)
  3824. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3825. }
  3826.  
  3827. function do_malus() {
  3828. try {
  3829. start_script();
  3830. traiteMalus();
  3831. setDisplayBM();
  3832. displayScriptTime();
  3833. }
  3834. catch(e) {window.alert(e)};
  3835. }
  3836.  
  3837. /*******************************************************************************
  3838. * This file is part of Mountyzilla. *
  3839. * *
  3840. * Mountyzilla is free software; you can redistribute it and/or modify *
  3841. * it under the terms of the GNU General Public License as published by *
  3842. * the Free Software Foundation; either version 2 of the License, or *
  3843. * (at your option) any later version. *
  3844. * *
  3845. * Mountyzilla is distributed in the hope that it will be useful, *
  3846. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3847. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3848. * GNU General Public License for more details. *
  3849. * *
  3850. * You should have received a copy of the GNU General Public License *
  3851. * along with Mountyzilla; if not, write to the Free Software *
  3852. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3853. *******************************************************************************/
  3854.  
  3855. // x~x mouches
  3856.  
  3857. var mainTab, tr_mouches;
  3858.  
  3859. function initialiseMouches() {
  3860. // Lanceur global
  3861. try {
  3862. mainTab = document.getElementById('mouches');
  3863. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3864. } catch(e) {
  3865. avertissement('Erreur MZ:<br />Consulter la console.');
  3866. window.console.error(traceStack(e, 'mouches'));
  3867. return;
  3868. }
  3869. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3870. setDisplayMouches();
  3871. traiteMouches();
  3872. }
  3873.  
  3874. function setDisplayMouches() {
  3875. // Initialise l'affichage / l'effacement du détail des mouches
  3876. var titre = document.getElementById('titre2');
  3877. if(titre) {
  3878. titre.style.cursor = 'pointer';
  3879. titre.onclick = toggleMouches;
  3880. }
  3881. var tfoot = document.getElementsByTagName('tfoot')[0];
  3882. if(tfoot) {
  3883. tfoot.style.cursor = 'pointer';
  3884. tfoot.onclick = toggleMouches;
  3885. }
  3886. if(MY_getValue('HIDEMOUCHES')=='true') {
  3887. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3888. tr_mouches.snapshotItem(i).style.display = 'none';
  3889. }
  3890. document.getElementsByTagName('thead')[0].style.display = 'none';
  3891. }
  3892. }
  3893.  
  3894. function toggleMouches() {
  3895. // Handler pour afficher / masquer les détasil
  3896. if(MY_getValue('HIDEMOUCHES')=='true') {
  3897. MY_setValue('HIDEMOUCHES','false');
  3898. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3899. tr_mouches.snapshotItem(i).style.display = '';
  3900. }
  3901. document.getElementsByTagName('thead')[0].style.display = '';
  3902. } else {
  3903. MY_setValue('HIDEMOUCHES','true');
  3904. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3905. tr_mouches.snapshotItem(i).style.display = 'none';
  3906. }
  3907. document.getElementsByTagName('thead')[0].style.display = 'none';
  3908. }
  3909. }
  3910.  
  3911. function traiteMouches() {
  3912. // Traitement complet: présence et effets des mouches
  3913. var listeTypes = {}, effetsActifs = {};
  3914. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3915. var tr = tr_mouches.snapshotItem(i);
  3916. // La mouche est-elle présente?
  3917. var etat = document.evaluate(
  3918. './img',
  3919. tr.cells[6], null, 9, null
  3920. ).singleNodeValue.alt;
  3921. if(etat!='La Mouche est là') { continue; }
  3922. // Extraction du type de mouche
  3923. var type = trim(tr.cells[3].textContent);
  3924. if(!listeTypes[type]) {
  3925. listeTypes[type] = 1;
  3926. } else {
  3927. listeTypes[type]++;
  3928. }
  3929. // La mouche a-t-elle un effet?
  3930. var effet = trim(tr.cells[2].textContent);
  3931. if(etat!='La Mouche est là' || !effet) { continue; }
  3932. // Si oui, extraction des effets (multiples pour pogées)
  3933. var caracs = effet.split(' | ');
  3934. for(var j=0 ; j<caracs.length ; j++) {
  3935. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3936. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3937. if(effetsActifs[carac]===void(0)) {
  3938. effetsActifs[carac] = valeur;
  3939. } else {
  3940. effetsActifs[carac] += valeur;
  3941. }
  3942. }
  3943. }
  3944. // Extraction Effet total et affichage des différences à la normale
  3945. var tfoot = document.getElementsByTagName('tfoot')[0];
  3946. if(!tfoot) { return; }
  3947. var nodeTotal = document.evaluate(
  3948. ".//b[contains(./text(),'Effet total')]",
  3949. tfoot, null, 9, null
  3950. ).singleNodeValue.nextSibling;
  3951. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3952. var texte = ' ';
  3953. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3954. if(texte.length>1) { texte += ' | '; }
  3955. var carac = trim(
  3956. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3957. );
  3958. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3959. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3960. texte += effetsTheoriques[i];
  3961. } else {
  3962. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3963. if(carac=='TOUR') { texte += ' min'; }
  3964. texte += '</b>';
  3965. }
  3966. }
  3967. var span = document.createElement('span');
  3968. span.innerHTML = texte;
  3969. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3970. // Affichage des différences du nombre de mouches de chaque type
  3971. var mouchesParType = document.evaluate(
  3972. "./tr/td/ul/li/text()",
  3973. tfoot, null, 7, null
  3974. );
  3975. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3976. var node = mouchesParType.snapshotItem(i);
  3977. var mots = node.nodeValue.split(' ');
  3978. var type = mots.pop();
  3979. if(!listeTypes[type]) {
  3980. node.nodeValue += ' (0 présente)';
  3981. } else if(mots[0]!=listeTypes[type]) {
  3982. if(listeTypes[type]==1) {
  3983. node.nodeValue += ' (1 présente)';
  3984. } else {
  3985. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  3986. }
  3987. }
  3988. }
  3989. }
  3990.  
  3991. function do_mouches() {
  3992. start_script();
  3993. initialiseMouches();
  3994. displayScriptTime();
  3995. }
  3996.  
  3997. /*********************************************************************************
  3998. * This file is part of Mountyzilla. *
  3999. * *
  4000. * Mountyzilla is free software; you can redistribute it and/or modify *
  4001. * it under the terms of the GNU General Public License as published by *
  4002. * the Free Software Foundation; either version 2 of the License, or *
  4003. * (at your option) any later version. *
  4004. * *
  4005. * Mountyzilla is distributed in the hope that it will be useful, *
  4006. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4007. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4008. * GNU General Public License for more details. *
  4009. * *
  4010. * You should have received a copy of the GNU General Public License *
  4011. * along with Mountyzilla; if not, write to the Free Software *
  4012. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4013. *********************************************************************************/
  4014.  
  4015. // x~x equipgowap
  4016.  
  4017. var popup;
  4018.  
  4019. function initPopupEquipgowap() {
  4020. popup = document.createElement('div');
  4021. popup.setAttribute('id', 'popup');
  4022. popup.setAttribute('class', 'mh_textbox');
  4023. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4024. 'display: inline; z-index: 3; max-width: 400px;');
  4025. document.body.appendChild(popup);
  4026. }
  4027.  
  4028. function showPopupEquipgowap(evt) {
  4029. var texte = this.getAttribute("texteinfo");
  4030. popup.innerHTML = texte;
  4031. popup.style.left = evt.pageX + 15 + 'px';
  4032. popup.style.top = evt.pageY + 'px';
  4033. popup.style.visibility = "visible";
  4034. }
  4035.  
  4036. function hidePopup() {
  4037. popup.style.visibility = "hidden";
  4038. }
  4039.  
  4040. function createPopupImage(url, text)
  4041. {
  4042. var img = document.createElement('img');
  4043. img.setAttribute('src',url);
  4044. img.setAttribute('align','ABSMIDDLE');
  4045. img.setAttribute("texteinfo",text);
  4046. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4047. img.addEventListener("mouseout", hidePopup,true);
  4048. return img;
  4049. }
  4050.  
  4051. function formateTexte(texte)
  4052. {
  4053. texte = texte.replace(/\n/g,"<br/>");
  4054. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4055. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4056. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4057. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4058. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4059. return texte;
  4060. }
  4061.  
  4062.  
  4063. function treateGowaps() {
  4064. //On récupère les gowaps possédants des composants
  4065. var tbodys = document.evaluate(
  4066. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4067. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4068. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4069. var tbody = tbodys.snapshotItem(j);
  4070. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4071. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4072. if(MY_getValue("NOINFOEM") != "true")
  4073. insertEMInfos(tbody);
  4074. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4075. insertEnchantInfos(tbody);
  4076. }
  4077. }
  4078.  
  4079. function treateChampi() {
  4080. if(MY_getValue("NOINFOEM") == "true")
  4081. return false;
  4082. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4083. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4084. if (nodes.snapshotLength == 0)
  4085. return false;
  4086.  
  4087. for (var i = 0; i < nodes.snapshotLength; i++) {
  4088. var node = nodes.snapshotItem(i);
  4089. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4090. if(texte.indexOf("*")!=-1)
  4091. texte = texte.substring(0,texte.lastIndexOf(" "));
  4092. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4093. if(moisChampi[nomChampi])
  4094. {
  4095. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4096. }
  4097. }
  4098. }
  4099.  
  4100. function do_equipgowap() {
  4101. start_script();
  4102.  
  4103. treateGowaps();
  4104. treateChampi();
  4105. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4106. {
  4107. initPopupEquipgowap();
  4108. computeEnchantementEquipement(createPopupImage,formateTexte);
  4109. }
  4110.  
  4111. displayScriptTime();
  4112. }
  4113.  
  4114. /*********************************************************************************
  4115. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4116. *********************************************************************************/
  4117.  
  4118. // x~x ordresgowap
  4119.  
  4120. // version Roule' janvier 2017
  4121. function MZ_setCarteUnGogoHTML5() {
  4122. // fabriquer la liste des positions successives
  4123. var listeDepl = []; // ce sera un tableau d'objets
  4124. // position courrante
  4125. var eTitle = document.getElementById('titre2');
  4126. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4127. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4128. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4129. , y: parseInt(tabPos[1])
  4130. , n: parseInt(tabPos[2])
  4131. , nom: tabNomID[2]
  4132. , id: tabNomID[1]});
  4133. // déplacements
  4134. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4135. for(var i=0 ; i<lignes.length ; i++) {
  4136. if(lignes[i].className == 'mh_tdpage_fo') {
  4137. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4138. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4139. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4140. }
  4141. }
  4142. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4143. }
  4144.  
  4145. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4146. function MZ_showCarteBottom(listeSuiv) {
  4147. // générer la carte
  4148. var carte = new carte_MZ('cartegogo', listeSuiv);
  4149. // positionner la carte
  4150. var eCarte = carte.getElt();
  4151. eCarte.style.textAlign = 'left';
  4152. eCarte.style.marginTop = '2px';
  4153. var footer = document.getElementById('footer1');
  4154. // Lieu_Teleport.php n'a pas de footer1 :(
  4155. if (!footer) footer = document.getElementById('footer2');
  4156. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4157. else document.body.appendChild(eCarte);
  4158. }
  4159.  
  4160. function MZ_setCarteTousGogoHTML5() {
  4161. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4162. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4163. var suivants = [];
  4164. for (var i=0;i<ligne.length;i++) {
  4165. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4166. var cas = ligne[i].getElementsByTagName("td")[0];
  4167. //if (cas.className == "mh_tdtitre") {
  4168. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4169. var oGogo = {};
  4170. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4171. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4172. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4173. oGogo.x = parseInt(point[1]);
  4174. oGogo.y = parseInt(point[2]);
  4175. oGogo.n = parseInt(point[3]);
  4176. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4177. }
  4178. }
  4179. if (suivants.length == 0) return;
  4180. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4181. }
  4182.  
  4183. function MZ_setCarteTP() {
  4184. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4185. 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);
  4186. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4187. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4188. }
  4189.  
  4190. /* v0.2 by Dab - 2013-08-31
  4191. * - correction acquisition posale initiale
  4192. * - correction tare et affichage mire
  4193. */
  4194.  
  4195. function setCarteGogo() {
  4196. try {
  4197. //var pars = document.getElementsByTagName('p');
  4198. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4199. var eTitle = document.getElementById('titre2');
  4200. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4201. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4202. var serv_img_cible = URL_MZimg + "rep.png";
  4203.  
  4204. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4205. //var lignes = pars[0].getElementsByTagName('tr');
  4206. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4207. var nbpt = 0;
  4208. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4209. for(var i=0 ; i<lignes.length ; i++) {
  4210. if(lignes[i].className == 'mh_tdpage_fo') {
  4211. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4212. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4213. if(point) {
  4214. nbpt++;
  4215. trajet += point[1]+','+point[2]+','+point[3]+',';
  4216. }
  4217. }
  4218. }
  4219. }
  4220. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4221. 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'/>";
  4222. var base = [-229,-5];
  4223. if (nbpt>0) {
  4224. base = [-684,-5];
  4225. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4226. }
  4227. 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;'/>";
  4228.  
  4229. 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>';
  4230.  
  4231. var nvspan = document.createElement('div');
  4232. nvspan.align = 'center';
  4233. nvspan.id = 'mz_mapdiv';
  4234. nvspan.valign = 'top';
  4235. nvspan.innerHTML = nvdiv;
  4236. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4237. var footer = document.getElementById('footer1');
  4238. footer.parentNode.insertBefore(nvspan,footer);
  4239. }
  4240.  
  4241. function testeGlissiere() {
  4242. try {
  4243. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4244. var footer = document.getElementById('footer1');
  4245. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4246. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4247. }
  4248.  
  4249. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4250. if (x0 !== undefined) {
  4251. // ouais, récursif une fois
  4252. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4253. if (PtInterm === undefined)
  4254. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4255. else
  4256. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4257. return;
  4258. }
  4259. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4260. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4261. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4262. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4263. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4264. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4265. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4266. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4267. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4268. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4269. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4270. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4271. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4272. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4273. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4274. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4275. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4276. }
  4277.  
  4278. function do_ordresgowap() {
  4279. if (newCarte) {
  4280. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4281. //testeGlissiere();
  4282. //MZ_testsUnitairesCalculIntermediaire();
  4283. } else {
  4284. setCarteGogo(); // Via script des trouillots
  4285. }
  4286. }
  4287.  
  4288. function do_listegowap() {
  4289. if (!newCarte) return;
  4290. MZ_setCarteTousGogoHTML5();
  4291. }
  4292.  
  4293. function do_lieuDescription() {
  4294. if (!newCarte) return;
  4295. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4296. MZ_setCarteTP();
  4297. }
  4298.  
  4299. function do_lieuTeleport() {
  4300. changeButtonValidate();
  4301. if (!newCarte) return;
  4302. MZ_setCarteTP();
  4303. }
  4304.  
  4305. /*********************************************************************************
  4306. * This file is part of Mountyzilla. *
  4307. * *
  4308. * Mountyzilla is free software; you can redistribute it and/or modify *
  4309. * it under the terms of the GNU General Public License as published by *
  4310. * the Free Software Foundation; either version 2 of the License, or *
  4311. * (at your option) any later version. *
  4312. * *
  4313. * Mountyzilla is distributed in the hope that it will be useful, *
  4314. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4315. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4316. * GNU General Public License for more details. *
  4317. * *
  4318. * You should have received a copy of the GNU General Public License *
  4319. * along with Mountyzilla; if not, write to the Free Software *
  4320. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4321. *********************************************************************************/
  4322.  
  4323. // x~x attaque
  4324.  
  4325. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4326.  
  4327. function do_attaque() {
  4328. }
  4329.  
  4330. /*******************************************************************************
  4331. * This file is part of Mountyzilla. *
  4332. * *
  4333. * Mountyzilla is free software; you can redistribute it and/or modify *
  4334. * it under the terms of the GNU General Public License as published by *
  4335. * the Free Software Foundation; either version 2 of the License, or *
  4336. * (at your option) any later version. *
  4337. * *
  4338. * Mountyzilla is distributed in the hope that it will be useful, *
  4339. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4340. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4341. * GNU General Public License for more details. *
  4342. * *
  4343. * You should have received a copy of the GNU General Public License *
  4344. * along with Mountyzilla; if not, write to the Free Software *
  4345. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4346. *******************************************************************************/
  4347.  
  4348. // x~x infomonstre
  4349.  
  4350. // DEBUG
  4351. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4352. // À corriger, évidemment.
  4353. var listeCDM = {};
  4354. var nomMonstre='';
  4355. var idMonstre=-1;
  4356. var tbody;
  4357. var popup;
  4358.  
  4359. function traiteMonstre() {
  4360. try {
  4361. var nodeTitre = document.evaluate(
  4362. "//div[@class='titre2' and contains(text(),'(')]",
  4363. document, null, 9, null
  4364. ).singleNodeValue;
  4365. var texte = nodeTitre.firstChild.nodeValue;
  4366. } catch(e) {
  4367. window.console.log(traceStack(e, 'traiteMonstre'));
  4368. return;
  4369. }
  4370. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4371. if(nomMonstre.indexOf(']')!=-1) {
  4372. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4373. }
  4374. idMonstre = texte.match(/\d+/)[0];
  4375. FF_XMLHttpRequest({
  4376. method: 'GET',
  4377. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4378. +MY_getValue('CDMID')
  4379. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4380. headers : {
  4381. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4382. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4383. },
  4384. onload: function(responseDetails) {
  4385. try {
  4386. var texte = responseDetails.responseText;
  4387. var lines = texte.split("\n");
  4388. if(lines.length>=1) {
  4389. var infos = lines[0].split(";");
  4390. if(infos.length<4) { return; }
  4391. var idMonstre = infos[0];
  4392. infos=infos.slice(3);
  4393. listeCDM[idMonstre]=infos;
  4394. computeMissionInfomonstre();
  4395. }
  4396. } catch(e) {
  4397. window.alert(e);
  4398. }
  4399. }
  4400. });
  4401. }
  4402.  
  4403. function initPopupInfomonstre() {
  4404. // Initialise le popup tactique (calculs att/deg)
  4405. popup = document.createElement('div');
  4406. popup.id = 'popup';
  4407. popup.className = 'mh_textbox';
  4408. popup.style =
  4409. 'position: absolute;'+
  4410. 'border: 1px solid #000000;'+
  4411. 'visibility: hidden;'+
  4412. 'display: inline;'+
  4413. 'z-index: 3;'+
  4414. 'max-width: 400px;';
  4415. document.body.appendChild(popup);
  4416. }
  4417.  
  4418. function showPopupTactique(evt) {
  4419. try {
  4420. var id = this.id;
  4421. var nom = this.nom;
  4422. var texte = getAnalyseTactique(id,nom);
  4423. if(texte=='') { return; }
  4424. popup.innerHTML = texte;
  4425. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4426. if(isPage("View/MonsterView")) {
  4427. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4428. } else {
  4429. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4430. }
  4431. popup.style.top = evt.pageY+15+'px';
  4432. popup.style.visibility = 'visible';
  4433. } catch(e) {
  4434. window.alert(e);
  4435. }
  4436. }
  4437.  
  4438. // roule 16/03/2016, existe déjà ailleurs
  4439. // function hidePopup() {
  4440. // popup.style.visibility = 'hidden';
  4441. // }
  4442.  
  4443. function toggleTableau() {
  4444. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4445. }
  4446.  
  4447. function computeMissionInfomonstre() {
  4448. // C'est quoi ce titre de fonction ? (O_o)
  4449. try {
  4450. var nodeInsert = document.evaluate(
  4451. "//div[@class = 'titre3']",
  4452. document, null, 9, null
  4453. ).singleNodeValue;
  4454. } catch(e) {
  4455. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4456. return;
  4457. }
  4458. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4459. table.align = 'center';
  4460. tbody = table.childNodes[1];
  4461. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4462. table.firstChild.firstChild.onmouseover = function() {
  4463. this.style.cursor = 'pointer';
  4464. this.className = 'mh_tdpage';
  4465. };
  4466. table.firstChild.firstChild.onmouseout = function() {
  4467. this.className = 'mh_tdtitre';
  4468. };
  4469. tbody.style.display = 'none';
  4470. table.style.width = '350px';
  4471. insertBefore(nodeInsert,table);
  4472. }
  4473.  
  4474. function do_infomonstre() {
  4475. start_script();
  4476. try {
  4477. initPopupInfomonstre();
  4478. traiteMonstre();
  4479. } catch(e) {
  4480. window.alert('Erreur infoMonstre:\n'+e);
  4481. }
  4482. displayScriptTime();
  4483. }
  4484.  
  4485. /*******************************************************************************
  4486. * This file is part of Mountyzilla. *
  4487. * *
  4488. * Mountyzilla is free software; you can redistribute it and/or modify *
  4489. * it under the terms of the GNU General Public License as published by *
  4490. * the Free Software Foundation; either version 2 of the License, or *
  4491. * (at your option) any later version. *
  4492. * *
  4493. * Mountyzilla is distributed in the hope that it will be useful, *
  4494. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4495. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4496. * GNU General Public License for more details. *
  4497. * *
  4498. * You should have received a copy of the GNU General Public License *
  4499. * along with Mountyzilla; if not, write to the Free Software *
  4500. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4501. *******************************************************************************/
  4502.  
  4503. // x~x mission
  4504.  
  4505. /* TODO
  4506. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4507. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4508. *
  4509. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4510. */
  4511.  
  4512. function saveMission(num,obEtape) {
  4513. var obMissions = {};
  4514. if(MY_getValue(numTroll+'.MISSIONS')) {
  4515. try {
  4516. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4517. } catch(e) {
  4518. window.console.error(traceStack(e, 'Mission parsage'));
  4519. return;
  4520. }
  4521. }
  4522. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4523. if(obEtape) {
  4524. obMissions[num] = obEtape;
  4525. } else if(obMissions[num]) {
  4526. delete obMissions[num];
  4527. }
  4528. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4529. }
  4530.  
  4531. function addtroogle(tdLibelle, sRestrict) {
  4532. var img = document.createElement('img');
  4533. img.src = URL_MZimg + 'troogle.ico';
  4534. img.alt = 'Troogle logo';
  4535. var a = document.createElement('a');
  4536. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4537. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4538. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4539. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4540. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4541. a.href = url;
  4542. a.title = 'Chercher sur Troogle';
  4543. a.target = 'troogle';
  4544. a.appendChild(img);
  4545. tdLibelle.appendChild(a);
  4546. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4547. }
  4548.  
  4549. function traiteMission() {
  4550. try {
  4551. var titreMission = document.getElementsByClassName('titre2')[0];
  4552. var numMission = titreMission.textContent.match(/\d+/)[0];
  4553. var missionForm = document.getElementsByName('ActionForm')[0];
  4554. var tdLibelle = document.evaluate(
  4555. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4556. missionForm, null, 9, null).singleNodeValue;
  4557. } catch(e) {
  4558. window.console.error(traceStack(e, 'récupération mission'));
  4559. return;
  4560. }
  4561. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4562. try {
  4563. if(!tdLibelle) {
  4564. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4565. debugMZ('traiteMission, la mission semble terminée');
  4566. saveMission(numMission,false);
  4567. return;
  4568. }
  4569.  
  4570. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4571. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4572. // debug Roule'
  4573. if (MY_DEBUG) {
  4574. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4575. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4576. }
  4577. if(libelle.indexOf('niveau égal à')!=-1) {
  4578. var nbKills = 1, niveau, mod;
  4579. // exemples :
  4580. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4581. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4582. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4583. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4584. if (tdLibelle.childNodes.length == 1) {
  4585. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4586. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4587. if (m) {
  4588. niveau = Number(m[1]);
  4589. mod = 'plus'
  4590. } else {
  4591. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4592. if (m) {
  4593. niveau = Number(m[1]);
  4594. mod = Number(m[2]);
  4595. } else {
  4596. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4597. return;
  4598. }
  4599. }
  4600. } else {
  4601. // ancienne méthode (multi childnode)
  4602. // à supprimer un jour peut-être
  4603. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4604. // Étape de kill multiple de niveau donné
  4605. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4606. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4607. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4608. niveau = Number(mod[0]);
  4609. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4610. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4611. } else {
  4612. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4613. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4614. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4615. mod = mod ? Number(mod[0]) : 'plus';
  4616. }
  4617. } else {
  4618. // Étape de kill unique de niveau donné
  4619. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4620. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4621. mod = mod ? Number(mod[0]) : 'plus';
  4622. }
  4623. }
  4624. // debug Roule'
  4625. if (MY_DEBUG) {
  4626. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4627. }
  4628. saveMission(numMission,{
  4629. type: 'Niveau',
  4630. niveau: niveau,
  4631. mod: mod,
  4632. mundidey: siMundidey,
  4633. libelle: libelle
  4634. });
  4635. if (mod == 'plus')
  4636. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4637. else
  4638. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4639. } else if(libelle.indexOf('de la race')!=-1) {
  4640. var nbKills = 1, race;
  4641. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4642. // Étape de kill multiple de race donnée
  4643. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4644. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4645. } else {
  4646. // Étape de kill unique de race donnée
  4647. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4648. }
  4649. race = race.replace(/\"/g,'');
  4650. saveMission(numMission,{
  4651. type: 'Race',
  4652. race: race,
  4653. mundidey: siMundidey,
  4654. libelle: libelle
  4655. });
  4656. addtroogle(tdLibelle, '@monstre ' + race);
  4657. } else if(libelle.indexOf('de la famille')!=-1) {
  4658. var nbKills = 1, famille;
  4659. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4660. // Étape de kill multiple de famille donnée
  4661. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4662. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4663. } else {
  4664. // Étape de kill unique de famille donnée
  4665. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4666. }
  4667. famille = famille.replace(/\"/g,'');
  4668. saveMission(numMission,{
  4669. type: 'Famille',
  4670. famille: famille,
  4671. mundidey: siMundidey,
  4672. libelle: libelle
  4673. });
  4674. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4675. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4676. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4677. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4678. debugMZ('traiteMission étape capacité spéciale');
  4679. saveMission(numMission,{
  4680. type: 'Pouvoir',
  4681. pouvoir: pouvoir,
  4682. libelle: libelle
  4683. });
  4684. } else {
  4685. debugMZ('traiteMission étape pas pour troogle');
  4686. saveMission(numMission,false);
  4687. }
  4688. } catch(e) {
  4689. window.console.error(traceStack(e, 'récupération étape mission'));
  4690. return;
  4691. }
  4692. }
  4693.  
  4694. function do_mission() {
  4695. start_script(60);
  4696.  
  4697. traiteMission();
  4698.  
  4699. displayScriptTime();
  4700. }
  4701.  
  4702. /*******************************************************************************
  4703. * This file is part of Mountyzilla. *
  4704. * *
  4705. * Mountyzilla is free software; you can redistribute it and/or modify *
  4706. * it under the terms of the GNU General Public License as published by *
  4707. * the Free Software Foundation; either version 2 of the License, or *
  4708. * (at your option) any later version. *
  4709. * *
  4710. * Mountyzilla is distributed in the hope that it will be useful, *
  4711. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4712. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4713. * GNU General Public License for more details. *
  4714. * *
  4715. * You should have received a copy of the GNU General Public License *
  4716. * along with Mountyzilla; if not, write to the Free Software *
  4717. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4718. *******************************************************************************/
  4719.  
  4720. // x~x move
  4721.  
  4722. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4723.  
  4724. var petitsTrous = {
  4725. '-52;57': true,
  4726. '55;70': true,
  4727. '64;70': true,
  4728. '12;-15': true,
  4729. '30;-52': true,
  4730. '48;-39': true
  4731. };
  4732.  
  4733. var grosTrous = {
  4734. '-35;65': true,
  4735. '-13;73': true,
  4736. '-64;9': true,
  4737. '-35;15': true,
  4738. '5;32': true,
  4739. '10;64': true,
  4740. '21;36': true,
  4741. '46;52': true,
  4742. '74;32': true,
  4743. '-71;-7': true,
  4744. '-67;-37': true,
  4745. '-60;-32': true,
  4746. '-51;-22': true,
  4747. '-36;-51': true,
  4748. '5;-49': true
  4749. };
  4750.  
  4751. var centreCarmine_X = 56.5;
  4752. var centreCarmine_Y = 23.5;
  4753. var rayonCarmine = 8.7;
  4754.  
  4755. function isTrou(x,y,n) {
  4756. if(petitsTrous[x+';'+y]) {
  4757. return n<0 && n>-60;
  4758. }
  4759. if(grosTrous[x+';'+y]
  4760. || grosTrous[x-1+';'+y]
  4761. || grosTrous[x+';'+y+1]
  4762. || grosTrous[x-1+';'+y+1]) {
  4763. return n<0 && n>-70;
  4764. }
  4765. if(Math.sqrt(
  4766. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4767. )<=rayonCarmine) {
  4768. return n<0 && n>-100;
  4769. }
  4770. return false;
  4771. }
  4772.  
  4773. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4774.  
  4775. function validateDestination() {
  4776. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4777. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4778. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4779. var form = document.getElementsByName('ActionForm')[0];
  4780. if(form) {
  4781. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4782. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4783. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4784. }
  4785. }
  4786. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4787. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4788. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4789. }
  4790. }
  4791. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4792. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4793. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4794. }
  4795. }
  4796. if(isTrou(x,y,n)) {
  4797. return window.confirm(
  4798. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4799. +'Vous allez tomber dans un trou de météorite.\n'
  4800. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4801. );
  4802. }
  4803. }
  4804. return true;
  4805. }
  4806.  
  4807. function newsubmitDE(event) {
  4808. event.stopPropagation();
  4809. event.preventDefault();
  4810. if(validateDestination()) {
  4811. this.submit();
  4812. }
  4813. }
  4814.  
  4815. function changeValidation() {
  4816. var form = document.getElementsByName('ActionForm')[0];
  4817. if(form) {
  4818. form.addEventListener('submit', newsubmitDE, true);
  4819. }
  4820. }
  4821.  
  4822.  
  4823. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4824.  
  4825. function validateTPDestination() {
  4826. try {
  4827. var text = document.getElementsByTagName('B')[0];
  4828. var a = text.firstChild.nodeValue.split('|');
  4829. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4830. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4831. var pos_n = a[2].substring(5, a[2].length) * 1;
  4832.  
  4833. var nbtrous = 0;
  4834. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4835. for(var x=0 ; x<=2 ; x++) {
  4836. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4837. for(var y=0 ; y<=2 ; y++) {
  4838. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4839. for(var n = 0 ; n <= 1 ; n++) {
  4840. if(isTrou(
  4841. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4842. )) {
  4843. nbtrous++;
  4844. }
  4845. }
  4846. }
  4847. }
  4848. }
  4849. }
  4850. }
  4851. if(nbtrous>0 && nbtrous<72) {
  4852. return window.confirm(
  4853. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4854. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4855. +'% de risque de tomber dans un trou de météorite.\n'
  4856. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4857. );
  4858. }
  4859. else if(nbtrous>=72) {
  4860. return window.confirm(
  4861. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4862. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4863. +'% de risque de tomber dans un trou de météorite !\n'
  4864. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4865. );
  4866. }
  4867. return true;
  4868. }
  4869. catch(e) {
  4870. window.alert(e)
  4871. }
  4872. }
  4873.  
  4874. function newsubmitTP(event) {
  4875. event.stopPropagation();
  4876. event.preventDefault();
  4877. if(validateTPDestination()) {
  4878. this.submit();
  4879. }
  4880. }
  4881.  
  4882. function changeButtonValidate() {
  4883. var form = document.getElementsByName('Formulaire')[0];
  4884. if(form) {
  4885. if(!form.getAttribute('onsubmit')) {
  4886. form.setAttribute('onsubmit','return true;');
  4887. }
  4888. form.addEventListener('submit', newsubmitTP, true);
  4889. }
  4890. }
  4891.  
  4892.  
  4893. /*-[functions]---------------- Partie Principale -----------------------------*/
  4894.  
  4895. function do_move() {
  4896. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  4897. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4898. changeValidation();
  4899. //}
  4900. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4901. // changeButtonValidate();
  4902. //}
  4903. }
  4904.  
  4905. /*******************************************************************************
  4906. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4907. * Mountyzilla is free software; provided under the GNU General Public License *
  4908. *******************************************************************************/
  4909.  
  4910. // x~x news
  4911.  
  4912. // Nombre de news à afficher & nb max de caractères par news:
  4913. const nbItems = 5;
  4914. const maxCarDescription = 300;
  4915.  
  4916. /*-[functions]------------------- Utilitaires --------------------------------*/
  4917.  
  4918. // Ne semble avoir strictement aucun effet:
  4919. String.prototype.epureDescription = function() {
  4920. return this.replace(/\\(.)/g,"$1");
  4921. }
  4922.  
  4923. function appendTitledTable(node,titre,description) {
  4924. // Crée les tables contenant les infos (avec titre)
  4925. var table = document.createElement('table');
  4926. table.border = 0;
  4927. table.className = 'mh_tdborder';
  4928. table.cellSpacing = 1;
  4929. table.cellPadding = 1;
  4930. table.style.maxWidth = '98%';
  4931. table.style.marginLeft = 'auto';
  4932. table.style.marginRight = 'auto';
  4933. var tbody = document.createElement('tbody');
  4934. table.appendChild(tbody);
  4935. var tr = appendTr(tbody,'mh_tdtitre');
  4936. var td = appendTdCenter(tr,2);
  4937. var span = document.createElement('span');
  4938. appendText(span,titre,true);
  4939. if(description) {
  4940. span.title = description;
  4941. }
  4942. td.appendChild(span);
  4943. node.appendChild(table);
  4944. return tbody;
  4945. }
  4946.  
  4947. function testCertif(paramURL, callbackOnError) {
  4948. try {
  4949. FF_XMLHttpRequest({
  4950. method: 'GET',
  4951. url: paramURL,
  4952. onload: function(responseDetails) {
  4953. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4954. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4955. }
  4956. });
  4957. } catch(e) {
  4958. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4959. callbackOnError();
  4960. }
  4961. }
  4962.  
  4963. function createOrGetGrandCadre() {
  4964. var grandCadre = document.getElementById('grandCadre');
  4965. if (grandCadre) return grandCadre;
  4966. try {
  4967. var rappels = document.evaluate(
  4968. "//p[contains(a/text(),'messagerie')]",
  4969. document, null, 9, null).singleNodeValue;
  4970. }
  4971. catch(e) {
  4972. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4973. grandCadre = document.createElement('div');
  4974. return grandCadre;
  4975. }
  4976. grandCadre = document.createElement('div');
  4977. grandCadre.id = 'grandCadre';
  4978. var sousCadre = document.createElement('div');
  4979. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4980. sousCadre.style.textAlign = 'center';
  4981. sousCadre.style.fontSize = 'xx-large';
  4982. grandCadre.appendChild(sousCadre);
  4983.  
  4984. grandCadre.style.border = 'solid 5px red';
  4985. grandCadre.style.width = 'auto';
  4986. insertBefore(rappels,grandCadre);
  4987. return grandCadre;
  4988. }
  4989.  
  4990. function showHttpsErrorCadre1() {
  4991. window.console.log('[MZ] showHttpsErrorCadre1');
  4992. var grandCadre = createOrGetGrandCadre();
  4993. var sousCadre = document.createElement('div');
  4994. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  4995. + '<br />Cela empêchera Moutyzilla de fonctionner'
  4996. + '<br /><a style="color:blue;font-size: inherits;" href="'
  4997. + URL_CertifRaistlin1
  4998. + '" target="raistlin">clique ici</a>'
  4999. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5000. + ' « Confirmer l\'exception de sécurité »'
  5001. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5002. sousCadre.style.width = 'auto';
  5003. sousCadre.style.fontSize = 'large';
  5004. sousCadre.style.border = 'solid 1px black';
  5005. sousCadre.style.backgroundColor = 'red';
  5006. grandCadre.appendChild(sousCadre);
  5007. }
  5008.  
  5009. function showHttpsErrorCadre2() {
  5010. window.console.log('[MZ] showHttpsErrorCadre2');
  5011. var grandCadre = createOrGetGrandCadre();
  5012. var sousCadre = document.createElement('div');
  5013. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5014. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5015. + '<a style="color:blue;font-size: inherits;" href="'
  5016. + URL_CertifRaistlin2
  5017. + '" target="raistlin">clique ici</a>'
  5018. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5019. + ' « Confirmer l\'exception de sécurité »'
  5020. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5021. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5022. sousCadre.style.width = 'auto';
  5023. sousCadre.style.fontSize = 'large';
  5024. sousCadre.style.border = 'solid 1px black';
  5025. sousCadre.style.backgroundColor = 'red';
  5026. grandCadre.appendChild(sousCadre);
  5027. }
  5028.  
  5029. function showHttpsErrorContenuMixte() {
  5030. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5031. var grandCadre = createOrGetGrandCadre();
  5032. var sousCadre = document.createElement('div');
  5033. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5034. + '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)'
  5035. + '<ul>'
  5036. + '<li>Interface Bricol\'Troll</li>'
  5037. + '<li>Nouveautés de Mountyzilla</li>'
  5038. + '</ul>'
  5039. + '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 />'
  5040. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5041. sousCadre.style.width = 'auto';
  5042. sousCadre.style.fontSize = 'large';
  5043. sousCadre.style.border = 'solid 1px black';
  5044. grandCadre.appendChild(sousCadre);
  5045. }
  5046.  
  5047. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5048.  
  5049. function traiterJubilaires() {
  5050. // à faire
  5051. }
  5052.  
  5053. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5054. try {
  5055. FF_XMLHttpRequest({
  5056. method: 'GET',
  5057. url: URL_anniv,
  5058. headers: {
  5059. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5060. 'Accept': 'application/xml,text/xml',
  5061. },
  5062. onload: function(responseDetails) {
  5063. if ((responseDetails.status == 0) && isHTTPS) {
  5064. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5065. showHttpsErrorContenuMixte();
  5066. return;
  5067. }
  5068. var listeTrolls = responseDetails.responseText.split('\n');
  5069. if(!listeTrolls || listeTrolls.length==0) {
  5070. return;
  5071. }
  5072. afficherJubilaires(listeTrolls);
  5073. },
  5074. });
  5075. }
  5076. catch(e) {
  5077. if (isHTTPS) {
  5078. window.console.log(traceStack(e, 'appel jubilaires'));
  5079. showHttpsErrorContenuMixte();
  5080. } else {
  5081. window.alert('Erreur Jubilaires:\n'+e);
  5082. }
  5083. }
  5084. }
  5085.  
  5086. function afficherJubilaires(listeTrolls) {
  5087. try {
  5088. var rappels = document.evaluate(
  5089. "//p[contains(a/text(),'messagerie')]",
  5090. document, null, 9, null).singleNodeValue;
  5091. }
  5092. catch(e) {
  5093. return;
  5094. }
  5095. var p = document.createElement('p');
  5096. var tbody = appendTitledTable(p,
  5097. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5098. 'Envoyez leur un message ou un cadeau !'
  5099. );
  5100. tr = appendTr(tbody,'mh_tdpage');
  5101. td = appendTdCenter(tr);
  5102. var small = document.createElement('small');
  5103. td.appendChild(small);
  5104. var first = true;
  5105. for(var i=0 ; i<listeTrolls.length ; i++) {
  5106. var infos = listeTrolls[i].split(';');
  5107. if(infos.length!=3 || infos[2]==='0') {
  5108. continue;
  5109. }
  5110. if(first) {
  5111. first = false;
  5112. }
  5113. else {
  5114. appendText(small,', ');
  5115. }
  5116. var a = document.createElement('a');
  5117. a.href = 'javascript:EPV('+infos[0]+')';
  5118. appendText(a,infos[1]);
  5119. small.appendChild(a);
  5120. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5121. }
  5122. insertBefore(rappels,p);
  5123. }
  5124.  
  5125.  
  5126. /*-[functions]--------------------- News MZ ----------------------------------*/
  5127.  
  5128. function traiterNouvelles() {
  5129. var news = new Array;
  5130. 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 ;).']);
  5131. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5132. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5133. 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']);
  5134. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5135. afficherNouvelles(news);
  5136. }
  5137.  
  5138. function afficherNouvelles(items) {
  5139. var footer = document.getElementById('footer1');
  5140. if(!footer) {
  5141. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5142. return;
  5143. }
  5144. var p = document.createElement('p');
  5145. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5146. var div = document.createElement('div');
  5147. div.style.position = 'absolute';
  5148. div.style.right = 0;
  5149. div.style.top = 0;
  5150. div.style.paddingRight = '3px';
  5151. div.style.whiteSpace = 'nowrap';
  5152. appendText(div, '(version ' + GM_info.script.version + ')');
  5153. tbody.rows[0].cells[0].style.position = 'relative';
  5154. tbody.rows[0].cells[0].appendChild(div);
  5155. for(var i=0 ; i<items.length ; i++) {
  5156. var tr = appendTr(tbody,'mh_tdpage');
  5157. var td = appendTdCenter(tr);
  5158. td.style.verticalAlign = 'top'; // semble sans effet
  5159. appendText(td,items[i][0],true);
  5160. td = appendTd(tr);
  5161. td.innerHTML = items[i][1];
  5162. }
  5163. insertBefore(footer,p);
  5164.  
  5165. // changelog
  5166. var p = document.createElement('p');
  5167. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5168. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5169. tbody.rows[0].cells[0].onclick = function() {
  5170. try {
  5171. tbody.rows[0].cells[0].onclick = undefined;
  5172. tbody.rows[0].cells[0].style.cursor = '';
  5173. var tr = appendTr(tbody,'mh_tdpage');
  5174. var td = appendTd(tr);
  5175. td.colSpan = 2;
  5176. var pre = document.createElement('pre');
  5177. appendText(pre,MZ_changeLog.join("\n"));
  5178. td.appendChild(pre);
  5179. } catch (e) {
  5180. window.console.log('[MZ] affichage changeLog', e);
  5181. }
  5182. };
  5183. insertBefore(footer,p);
  5184.  
  5185. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5186. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5187. if (isHTTPS) {
  5188. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5189. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5190. } else {
  5191. window.console.log('[MZ test] début switch to https');
  5192. window.sessionStorage.setItem('xxx', "test session trans https");
  5193. window.parent.xxx = "autre test";
  5194. var url = document.location.href;
  5195. window.console.log('[MZ test] url=' + url);
  5196. url = url.replace(/http:\/\//i, 'https://')
  5197. window.console.log('[MZ test] switched url=' + url);
  5198. document.location.href = url;
  5199. }
  5200. }
  5201. if (false) { // version par utilisation d'un IFrame en https
  5202. if (isHTTPS) {
  5203. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5204. //window.console.log('[MZ test] window.name=' + window.name);
  5205. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5206. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5207. var txt = window.name;
  5208. var tabtxt = txt.split(/µ/);
  5209. for (var i = 0; i < tabtxt.length; i++) {
  5210. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5211. }
  5212. } else {
  5213. var txt = '';
  5214. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5215. var k = localStorage.key(i);
  5216. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5217. txt += k + "£" + localStorage.getItem(k) + "µ";
  5218. }
  5219. var iframe = document.createElement('iframe');
  5220. var url = document.location.href;
  5221. //window.console.log('[MZ test] url=' + url);
  5222. url = url.replace(/http:\/\//i, 'https://')
  5223. //window.console.log('[MZ test] switched url=' + url);
  5224. //iframe.xxx = "truc en plume";
  5225. iframe.name = txt;
  5226. //window.xxx = "machin";
  5227. iframe.src = url;
  5228. //iframe.document.xxx = "truc en plume";
  5229. document.body.appendChild(iframe);
  5230. iframe.style.display = 'none';
  5231. }
  5232. }
  5233. }
  5234. }
  5235.  
  5236.  
  5237. /*---------------------------------- Main ------------------------------------*/
  5238.  
  5239. function do_news() {
  5240. start_script();
  5241.  
  5242. traiterJubilaires();
  5243. traiterNouvelles();
  5244.  
  5245. if (isHTTPS) {
  5246. // test si les certificats raistlin ont été acceptés
  5247. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5248. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5249. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5250. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5251. }
  5252. }
  5253.  
  5254. displayScriptTime();
  5255. }
  5256.  
  5257. /*********************************************************************************
  5258. * This file is part of Mountyzilla. *
  5259. * *
  5260. * Mountyzilla is free software; you can redistribute it and/or modify *
  5261. * it under the terms of the GNU General Public License as published by *
  5262. * the Free Software Foundation; either version 2 of the License, or *
  5263. * (at your option) any later version. *
  5264. * *
  5265. * Mountyzilla is distributed in the hope that it will be useful, *
  5266. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5267. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5268. * GNU General Public License for more details. *
  5269. * *
  5270. * You should have received a copy of the GNU General Public License *
  5271. * along with Mountyzilla; if not, write to the Free Software *
  5272. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5273. *********************************************************************************/
  5274.  
  5275. // x~x tabcompo
  5276.  
  5277. var popup;
  5278.  
  5279. function initPopupTabcompo() {
  5280. popup = document.createElement('div');
  5281. popup.setAttribute('id', 'popup');
  5282. popup.setAttribute('class', 'mh_textbox');
  5283. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5284. + 'display: inline; z-index: 3; max-width: 400px;');
  5285. document.body.appendChild(popup);
  5286. }
  5287.  
  5288. function showPopup(evt) {
  5289. var texte = this.getAttribute("texteinfo");
  5290. popup.innerHTML = texte;
  5291. popup.style.left = evt.pageX + 15 + 'px';
  5292. popup.style.top = evt.pageY + 'px';
  5293. popup.style.visibility = "visible";
  5294. }
  5295.  
  5296. // roule 16/03/2016, existe déjà ailleurs
  5297. // function hidePopup() {
  5298. // popup.style.visibility = 'hidden';
  5299. // }
  5300.  
  5301. function createPopupImage(url, text)
  5302. {
  5303. var img = document.createElement('img');
  5304. img.setAttribute('src',url);
  5305. img.setAttribute('align','ABSMIDDLE');
  5306. img.setAttribute("texteinfo",text);
  5307. img.addEventListener("mouseover", showPopup,true);
  5308. img.addEventListener("mouseout", hidePopup,true);
  5309. return img;
  5310. }
  5311.  
  5312. function formateTexte(texte)
  5313. {
  5314. texte = texte.replace(/\n/g,"<br/>");
  5315. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5316. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5317. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5318. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5319. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5320. return texte;
  5321. }
  5322.  
  5323. function arrondi(x) {
  5324. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5325. }
  5326.  
  5327. function traiteMinerai() {
  5328. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5329. try {
  5330. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5331. +" and contains(./tr/th/text(),'Minerai')]",
  5332. document, null, 9, null).singleNodeValue;
  5333. node = node.nextSibling.nextSibling;
  5334. }
  5335. catch(e) {return;}
  5336. var trlist = document.evaluate('./tr', node, null, 7, null);
  5337. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5338. var node = trlist.snapshotItem(i);
  5339. var nature = node.childNodes[5].textContent;
  5340. var caracs = node.childNodes[7].textContent;
  5341. var taille = caracs.match(/\d+/)[0];
  5342. var coef = 1;
  5343. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5344. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5345. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5346. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5347. if (nature.indexOf('Mithril')!=-1) {
  5348. coef = 0.2*coef;
  5349. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5350. }
  5351. else {
  5352. coef = 0.75*coef+1.25;
  5353. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5354. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5355. }
  5356. }
  5357. }
  5358.  
  5359. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5360. function treateComposants() {
  5361. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5362. //On récupère les composants
  5363. var nodes = document.evaluate(
  5364. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5365. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5366. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5367. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5368. if (nodes.snapshotLength == 0) {
  5369. //window.console.log('[MZ] treateComposants DOWN');
  5370. return;
  5371. }
  5372. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5373.  
  5374. var texte = "";
  5375. for (var i = 0; i < nodes.snapshotLength; i++) {
  5376. var n1 = nodes.snapshotItem(i).childNodes[1];
  5377. var n3 = nodes.snapshotItem(i).childNodes[3];
  5378. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5379. var prix = n3.childNodes[0].nodeValue;
  5380. if (!prix)
  5381. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5382. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5383. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5384. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5385. + prix.replace(/\n/g, '') + "\n";
  5386. }
  5387.  
  5388. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5389. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5390. var id_taniere = c.snapshotItem(0).nodeValue;
  5391. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5392.  
  5393. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5394. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5395. if (form)
  5396. {
  5397. if(document.getElementsByTagName('form').length>0)
  5398. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5399. else
  5400. {
  5401. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5402. insertBefore(thisP, form);
  5403. }
  5404. }
  5405. }
  5406.  
  5407. function treateAllComposants() {
  5408. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5409. //On récupère les composants
  5410. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5411. document, null, 0, null ).numberValue;
  5412. var c = (categ == 0 ? 3 : 4);
  5413. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5414. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5415. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5416. + "td["+c+"]/text()[1] = '\240-\240' "
  5417. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5418. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5419. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5420. + "and td[1]/img/@alt = 'Identifié']",
  5421. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5422. if (nodes.snapshotLength == 0) {
  5423. // window.alert('treateAllComposants DOWN');
  5424. return;
  5425. }
  5426.  
  5427. var texte = "";
  5428. for (var i = 0; i < nodes.snapshotLength; i++) {
  5429. var n1 = nodes.snapshotItem(i).childNodes[1];
  5430. var n3 = nodes.snapshotItem(i).childNodes[3];
  5431. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5432. var prix = n3.childNodes[0].nodeValue;
  5433. if (!prix)
  5434. {
  5435. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5436. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5437. }
  5438. else
  5439. {
  5440. prix= prix.replace(/[\240 ]/g, "");
  5441. if(prix=="-")
  5442. prix=null;
  5443. }
  5444. if(prix)
  5445. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5446. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5447. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5448. + prix.replace(/\n/g, '') + "\n";
  5449. else
  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, '') + ";pas défini\n";
  5453. }
  5454.  
  5455. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5456. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5457. var id_taniere = c.snapshotItem(0).nodeValue;
  5458. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5459.  
  5460. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5461. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5462. if (form)
  5463. {
  5464. if(document.getElementsByTagName('form').length>0)
  5465. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5466. else
  5467. {
  5468. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5469. insertBefore(thisP, form);
  5470. }
  5471. }
  5472. }
  5473.  
  5474. function treateEM()
  5475. {
  5476. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5477. if(currentURL.indexOf("as_type=Compo")==-1)
  5478. return false;
  5479. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5480. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5481. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5482. if (nodes.snapshotLength == 0)
  5483. return false;
  5484. for (var i = 0; i < nodes.snapshotLength; i++) {
  5485. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5486. var link = desc[2].firstChild ;
  5487. var nomCompoTotal = desc[2].textContent ;
  5488. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5489. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5490. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5491. var locqual = desc[3].textContent ;
  5492. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5493. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5494. if(isEM(nomMonstre).length>0)
  5495. {
  5496. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5497. if(infos.length>0)
  5498. {
  5499. var shortDescr = "Variable";
  5500. var bold = 0;
  5501. if(infos != "Composant variable")
  5502. {
  5503. shortDescr = infos.substring(0,infos.indexOf(" "));
  5504. if(parseInt(shortDescr)>=0)
  5505. bold=1;
  5506. }
  5507. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5508. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5509. }
  5510. }
  5511. }
  5512. }
  5513.  
  5514. function treateChampi() {
  5515. if (currentURL.indexOf('as_type=Champi')==-1)
  5516. return false;
  5517. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5518. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5519. if (nodes.snapshotLength == 0)
  5520. return false;
  5521.  
  5522. for (var i = 0; i < nodes.snapshotLength; i++) {
  5523. var node = nodes.snapshotItem(i);
  5524. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5525. if (moisChampi[nomChampi])
  5526. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5527. }
  5528. }
  5529.  
  5530. function treateEnchant()
  5531. {
  5532. if(currentURL.indexOf("as_type=Compo")==-1)
  5533. return false;
  5534. try
  5535. {
  5536. if(!listeMonstreEnchantement)
  5537. computeCompoEnchantement();
  5538. var nodes = document.evaluate(
  5539. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5540. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5541. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5542. if (nodes.snapshotLength == 0)
  5543. return false;
  5544. var urlImg = URL_MZimg + "enchant.png";
  5545. for (var i = 0; i < nodes.snapshotLength; i++) {
  5546. var link = nodes.snapshotItem(i);
  5547. var nomCompoTotal = link.firstChild.nodeValue;
  5548. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5549. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5550. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5551. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5552. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5553. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5554. if(isEnchant(nomMonstre).length>0)
  5555. {
  5556. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5557. if(infos.length>0)
  5558. {
  5559. link.parentNode.appendChild(createImage(urlImg,infos));
  5560. }
  5561. }
  5562. }
  5563. }
  5564. catch(e)
  5565. {
  5566. window.alert(e);
  5567. }
  5568. }
  5569.  
  5570. function treateEquipEnchant()
  5571. {
  5572. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5573. return false;
  5574. initPopupTabcompo();
  5575. computeEnchantementEquipement(createPopupImage,formateTexte);
  5576. }
  5577.  
  5578. function do_tancompo() {
  5579. start_script();
  5580.  
  5581. treateAllComposants();
  5582. treateComposants();
  5583. traiteMinerai();
  5584. if (MY_getValue('NOINFOEM')!='true') {
  5585. treateChampi();
  5586. treateEM();
  5587. }
  5588. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5589. treateEnchant();
  5590. treateEquipEnchant();
  5591. }
  5592.  
  5593. displayScriptTime();
  5594. }
  5595.  
  5596. /*******************************************************************************
  5597. * This file is part of Mountyzilla. *
  5598. * *
  5599. * Mountyzilla is free software; you can redistribute it and/or modify *
  5600. * it under the terms of the GNU General Public License as published by *
  5601. * the Free Software Foundation; either version 2 of the License, or *
  5602. * (at your option) any later version. *
  5603. * *
  5604. * Mountyzilla is distributed in the hope that it will be useful, *
  5605. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5606. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5607. * GNU General Public License for more details. *
  5608. * *
  5609. * You should have received a copy of the GNU General Public License *
  5610. * along with Mountyzilla; if not, write to the Free Software *
  5611. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5612. *******************************************************************************/
  5613.  
  5614. // x~x pjview
  5615.  
  5616. /* TODO
  5617. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5618. */
  5619.  
  5620. // Bulle d'infos
  5621. var DivInfo;
  5622. // Booléen stockant l'état de freezing de la bulle
  5623. var freezed = false;
  5624.  
  5625. // liste du matos
  5626. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5627. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5628. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5629. var mh_caracs = {
  5630. 'anneau de protection':
  5631. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5632. "armure d'anneaux":
  5633. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5634. 'armure de bois':
  5635. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5636. 'armure de cuir':
  5637. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5638. 'armure de peaux':
  5639. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5640. 'armure de pierre':
  5641. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5642. 'armure de plates':
  5643. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5644. 'baton lesté':
  5645. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5646. 'bâtons de parade':
  5647. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5648. 'bottes':
  5649. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5650. 'bouclier à pointes':
  5651. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5652. 'boulet et chaîne':
  5653. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5654. 'cagoule':
  5655. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5656. 'casque à cornes':
  5657. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5658. 'casque à pointes':
  5659. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5660. 'casque en cuir':
  5661. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5662. 'casque en métal':
  5663. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5664. 'chaîne cloutée':
  5665. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5666. 'chapeau pointu':
  5667. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5668. 'collier de dents':
  5669. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5670. 'collier de pierre':
  5671. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5672. 'collier à pointes':
  5673. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5674. 'cotte de mailles':
  5675. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5676. 'couronne de cristal':
  5677. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5678. "couronne d'obsidienne":
  5679. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5680. "coutelas d'obsidienne":
  5681. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5682. 'coutelas en os':
  5683. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5684. 'crochet':
  5685. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5686. 'cuir bouilli':
  5687. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5688. "cuirasse d'ossements":
  5689. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5690. "cuirasse d'écailles":
  5691. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5692. 'culotte en cuir':
  5693. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5694. 'dague':
  5695. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5696. 'epée courte':
  5697. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5698. 'epée longue':
  5699. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5700. 'espadon':
  5701. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5702. 'fouet':
  5703. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5704. 'fourrures':
  5705. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5706. 'gantelet':
  5707. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5708. 'gorgeron en cuir':
  5709. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5710. 'gorgeron en métal':
  5711. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5712. 'gourdin':
  5713. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5714. 'gourdin clouté':
  5715. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5716. 'grimoire':
  5717. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5718. "gros'porte":
  5719. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5720. 'grosse racine':
  5721. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5722. 'grosse stalagmite':
  5723. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5724. 'hache de bataille':
  5725. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5726. 'hache de guerre en os':
  5727. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5728. 'hache de guerre en pierre':
  5729. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5730. "hache à deux mains d'obsidienne":
  5731. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5732. 'hallebarde':
  5733. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5734. "haubert d'écailles":
  5735. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5736. 'haubert de mailles':
  5737. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5738. 'heaume':
  5739. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5740. 'jambières en cuir':
  5741. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5742. 'jambières en fourrure':
  5743. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5744. 'jambières en maille':
  5745. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5746. 'jambières en métal':
  5747. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5748. 'jambières en os':
  5749. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5750. "lame d'obsidienne":
  5751. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5752. 'lame en os':
  5753. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5754. 'lame en pierre':
  5755. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5756. 'lorgnons':
  5757. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5758. 'machette':
  5759. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5760. "masse d'arme":
  5761. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5762. 'pagne de mailles':
  5763. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5764. 'pagne en cuir':
  5765. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5766. 'robe de mage':
  5767. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5768. 'rondache en bois':
  5769. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5770. 'rondache en métal':
  5771. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5772. 'sandales':
  5773. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5774. 'souliers dorés':
  5775. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5776. "talisman d'obsidienne":
  5777. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5778. 'talisman de pierre':
  5779. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5780. 'targe':
  5781. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5782. 'torche':
  5783. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5784. 'torque de pierre':
  5785. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5786. 'tunique':
  5787. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5788. "tunique d'écailles":
  5789. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5790. 'turban':
  5791. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5792. }
  5793.  
  5794. // liste des templates
  5795. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5796. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5797. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5798. var mh_templates = {
  5799. 'de Feu':
  5800. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5801. 'de Résistance':
  5802. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5803. "de l'Aigle":
  5804. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5805. 'de la Salamandre':
  5806. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5807. 'des Cyclopes':
  5808. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5809. 'des Enragés':
  5810. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5811. 'des Tortues':
  5812. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5813. 'des Vampires':
  5814. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5815. 'du Glacier':
  5816. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5817. 'du Rat':
  5818. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5819. 'du Roc':
  5820. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5821. 'du Temps':
  5822. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5823. 'du Vent':
  5824. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5825. 'en Mithril':
  5826. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5827. 'des Anciens':
  5828. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5829. 'des Champions':
  5830. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5831. 'des Duellistes':
  5832. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5833. 'de la Terre':
  5834. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5835. "de l'Orage":
  5836. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5837. "de l'Ours":
  5838. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5839. 'des Béhémoths':
  5840. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5841. 'des Mages':
  5842. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5843. 'du Pic':
  5844. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5845. 'du Sable':
  5846. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5847. 'acéré':
  5848. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5849. 'acérée':
  5850. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5851. 'équilibré':
  5852. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5853. 'équilibrée':
  5854. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5855. 'léger':
  5856. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5857. 'légère':
  5858. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5859. 'renforcé':
  5860. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5861. 'renforcée':
  5862. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5863. 'robuste':
  5864. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5865. }
  5866.  
  5867. function clone(arr) {
  5868. // Clonage rapide
  5869. return arr.slice(0);
  5870. }
  5871.  
  5872. function addArray(arr1,arr2) {
  5873. // Somme matricielle
  5874. var res = clone(arr1);
  5875. for(i=res.length-1 ; i>=0 ; i--) {
  5876. res[i] += arr2[i];
  5877. }
  5878. return res;
  5879. }
  5880.  
  5881. function getTemplates(nomItem) {
  5882. // Déstructure le nom de l'item en array [nom, template1, ...]
  5883. var tempFound = true;
  5884. var str = nomItem.trim();
  5885. var arr = [];
  5886. while(tempFound) {
  5887. tempFound = false;
  5888. for(var temp in mh_templates) {
  5889. // on teste la fin du nom contre chaque template
  5890. if(str.slice(-temp.length)!=temp) { continue; }
  5891. tempFound = true;
  5892. str = str.slice(0,-temp.length-1);
  5893. arr.unshift(temp);
  5894. if(str.slice(-3)==' et') {
  5895. str = str.slice(0,-3);
  5896. }
  5897. }
  5898. }
  5899. arr.unshift(str);
  5900. return arr;
  5901. }
  5902.  
  5903. function addMithril(arrayCaracs,typeItem) {
  5904. // Ajoute l'effet du Mithril sur les caracs
  5905. if(typeItem=='arme') {
  5906. if(arrayCaracs[0]<0) {
  5907. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5908. }
  5909. }
  5910. else {
  5911. if(arrayCaracs[4]<0) {
  5912. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5913. }
  5914. }
  5915. arrayCaracs[15] /= 2;
  5916. arrayCaracs[16] /= 2;
  5917. return arrayCaracs;
  5918. }
  5919.  
  5920. function addRenfort(arrayCaracs,template) {
  5921. // Ajoute l'effet des pseudo-templates sur les caracs
  5922. // S'applique APRÈS le mithril
  5923. // WARNING - Cette formule n'a rien d'officiel, gare !
  5924. var coef = 0;
  5925. if(/^lég[e,è]re?$/.test(template)) {
  5926. coef = -1;
  5927. }
  5928. else if(/^renforcée?$/.test(template)
  5929. || template==='robuste') {
  5930. coef = 1;
  5931. }
  5932. if(coef) {
  5933. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5934. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5935. }
  5936. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5937. return arrayCaracs;
  5938. }
  5939.  
  5940. function getCaracs(item) {
  5941. // Calcule les caractéristiques de l'item
  5942. var templates = getTemplates(item);
  5943. if(!mh_caracs[templates[0]]) {
  5944. // Si l'item est inconnu
  5945. return [];
  5946. }
  5947. var caracs = clone(mh_caracs[templates[0]]);
  5948. var typeItem = caracs[0];
  5949. caracs.shift();
  5950. templates.shift();
  5951. if(templates[templates.length-1]=='en Mithril') {
  5952. caracs = addMithril(caracs,typeItem);
  5953. templates.pop();
  5954. }
  5955. if(/^acérée?$/.test(templates[0])
  5956. || /^équilibrée?$/.test(templates[0])
  5957. || /^lég[e,è]re?$/.test(templates[0])
  5958. || /^renforcée?$/.test(templates[0])
  5959. || templates[0]=='robuste') {
  5960. caracs = addRenfort(caracs,templates[0]);
  5961. templates.shift();
  5962. }
  5963. for(var i=templates.length-1 ; i>=0 ; i--) {
  5964. caracs = addArray(caracs,mh_templates[templates[i]]);
  5965. }
  5966. return caracs;
  5967. }
  5968.  
  5969. function getLine(tab) {
  5970. // Préparation de la ligne à afficher lors d'un mouseover
  5971. var str = '';
  5972. if(tab[0]!=0 || tab[1]!=0) {
  5973. str += '<b>Att : </b>'+aff(tab[0]);
  5974. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5975. str += ' | ';
  5976. }
  5977. if(tab[4]!=0) {
  5978. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5979. }
  5980. if(tab[2]!=0 || tab[3]!=0) {
  5981. str += '<b>Deg : </b>'+aff(tab[2]);
  5982. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  5983. str += ' | ';
  5984. }
  5985. if(tab[8]!=0) {
  5986. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  5987. }
  5988. if(tab[7]!=0) {
  5989. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  5990. }
  5991. if(tab[5]!=0 || tab[6]!=0) {
  5992. str += '<b>Arm : </b>'+aff(tab[5]);
  5993. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  5994. str += ' | ';
  5995. }
  5996. if(tab[9]!=0 || tab[10]!=0) {
  5997. str += '<b>RM : </b>'+aff(tab[9])+'%';
  5998. if(tab[9]!=tab[10]) {
  5999. str += '/'+aff(tab[10])+'%';
  6000. }
  6001. str += ' | ';
  6002. }
  6003. if(tab[11]!=0 || tab[12]!=0) {
  6004. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6005. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6006. str += ' | ';
  6007. }
  6008. if(tab[13]!=0) {
  6009. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6010. }
  6011. if(tab[14]!=0) {
  6012. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6013. }
  6014. str += '<b>Poids : </b>'+tab[15]+' min';
  6015. if(tab[15]!=tab[16]) {
  6016. str += ' / '+tab[16]+' min';
  6017. }
  6018. return str;
  6019. }
  6020.  
  6021. function toolTipInit() {
  6022. DivInfo = document.createElement('div');
  6023. DivInfo.id = 'infosVue';
  6024. DivInfo.className = 'mh_textbox';
  6025. DivInfo.style =
  6026. 'position: absolute;'
  6027. +'border: 1px solid #000000;'
  6028. +'visibility:hidden;'
  6029. +'display:inline;'
  6030. +'z-index:99;';
  6031. document.body.appendChild(DivInfo);
  6032. document.onmousemove = getXY;
  6033. document.onclick = changeFreezeStatus;
  6034. }
  6035.  
  6036. function getXY(evt) {
  6037. if(!freezed && DivInfo.style.visibility=='visible') {
  6038. DivInfo.style.left = evt.pageX+'px';
  6039. DivInfo.style.top = evt.pageY+10+'px';
  6040. }
  6041. }
  6042.  
  6043. function changeFreezeStatus() {
  6044. if(DivInfo.style.visibility=='visible') {
  6045. freezed = !freezed;
  6046. if(!freezed) { hideInfos(); }
  6047. }
  6048. }
  6049.  
  6050. function showInfos() {
  6051. if(freezed) { return; }
  6052. var currentInfos = this.infos;
  6053. DivInfo.innerHTML = currentInfos;
  6054. DivInfo.style.visibility = 'visible';
  6055. }
  6056.  
  6057. function hideInfos() {
  6058. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6059. }
  6060.  
  6061. function treateEquipement() {
  6062. // Extrait les données du matos et réinjecte les infos déduites
  6063. if(MY_getValue('INFOCARAC')=='false') { return; }
  6064. var faireLigne = false;
  6065. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6066. var nodes = document.evaluate(
  6067. "//td/b[text()='Equipement Utilisé']/../../"
  6068. +"td[2]/img[contains(@src,bullet)]",
  6069. document, null, 7, null);
  6070. if(nodes.snapshotLength>0) {
  6071. // Si CSS de base
  6072. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6073. var node = nodes.snapshotItem(i);
  6074. var next = node.nextSibling;
  6075. var nnext = next.nextSibling;
  6076. var nom = next.nodeValue.toLowerCase();
  6077. if(nnext.childNodes.length==1) {
  6078. nom += nnext.firstChild.nodeValue;
  6079. }
  6080. nom = nom.trim();
  6081. // gestion winpostrophe
  6082. var c = String.fromCharCode(180);
  6083. while(nom.indexOf(c)!=-1) {
  6084. nom = nom.replace(c,"'");
  6085. }
  6086. var arr = getCaracs(nom);
  6087. if(arr.length>0) {
  6088. faireLigne = true;
  6089. caracs = addArray(caracs,arr);
  6090. var span = document.createElement('span');
  6091. span.appendChild(next);
  6092. span.appendChild(nnext);
  6093. span.infos = getLine(arr);
  6094. span.onmouseover = showInfos;
  6095. span.onmouseout = hideInfos;
  6096. insertBefore(node.nextSibling,span);
  6097. }
  6098. }
  6099. if(faireLigne) {
  6100. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6101. document, null, 9, null).singleNodeValue;
  6102. node.infos = getLine(caracs);
  6103. node.onmouseover = showInfos;
  6104. node.onmouseout = hideInfos;
  6105. }
  6106. }
  6107. else {
  6108. // Si CSS avancée
  6109. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6110. document, null, 7, null);
  6111. if(nodes.snapshotLength>0) {
  6112. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6113. var node = nodes.snapshotItem(i);
  6114. var nom = node.firstChild.nodeValue.toLowerCase();
  6115. if(node.childNodes.length>1) {
  6116. nom += node.childNodes[1].firstChild.nodeValue;
  6117. }
  6118. nom = nom.trim();
  6119. // gestion winpostrophe
  6120. var c = String.fromCharCode(180);
  6121. while(nom.indexOf(c)!=-1) {
  6122. nom = nom.replace(c,"'");
  6123. }
  6124. var arr = getCaracs(nom);
  6125. if(arr.length!=0) {
  6126. caracs = addArray(caracs,arr);
  6127. node.infos = getLine(arr);
  6128. node.onmouseover = showInfos;
  6129. node.onmouseout = hideInfos;
  6130. }
  6131. }
  6132. var nodes = document.evaluate("//dt[@class='equipement']",
  6133. document, null, 7, null);
  6134. var node = nodes.snapshotItem(0);
  6135. node.infos = getLine(caracs);
  6136. node.onmouseover = showInfos;
  6137. node.onmouseout = hideInfos;
  6138. }
  6139. }
  6140. }
  6141.  
  6142. function do_pjview() {
  6143. treateEquipement();
  6144. toolTipInit();
  6145. }
  6146.  
  6147. /*******************************************************************************
  6148. * This file is part of Mountyzilla. *
  6149. * *
  6150. * Mountyzilla is free software; you can redistribute it and/or modify *
  6151. * it under the terms of the GNU General Public License as published by *
  6152. * the Free Software Foundation; either version 2 of the License, or *
  6153. * (at your option) any later version. *
  6154. * *
  6155. * Mountyzilla is distributed in the hope that it will be useful, *
  6156. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6157. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6158. * GNU General Public License for more details. *
  6159. * *
  6160. * You should have received a copy of the GNU General Public License *
  6161. * along with Mountyzilla; if not, write to the Free Software *
  6162. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6163. *******************************************************************************/
  6164.  
  6165. // x~x option
  6166.  
  6167. /* TODO
  6168. * Passer le HTML injecté aux conventions HTML5
  6169. */
  6170.  
  6171.  
  6172. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6173.  
  6174. function saveITData() {
  6175. var IT = document.getElementById('itSelect').value;
  6176. if(IT=='bricol') {
  6177. var system = document.getElementById('urlbricol').value;
  6178. var login = document.getElementById('loginbricol').value;
  6179. var pass = document.getElementById('passbricol').value;
  6180. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6181. if(system && login) {
  6182. if (pass) {
  6183. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6184. MY_setValue(numTroll+'.INFOSIT', v);
  6185. //window.console.log('v=' + v);
  6186. } else {
  6187. // vérif que rien n'a changé
  6188. var str = MY_getValue(numTroll+'.INFOSIT');
  6189. if(str) {
  6190. var arr = str.split('$');
  6191. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6192. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  6193. }
  6194. }
  6195. }
  6196. }
  6197. }
  6198. else {
  6199. MY_removeValue(numTroll+'.INFOSIT');
  6200. }
  6201. }
  6202.  
  6203. function saveLinks() {
  6204. var numLinks = document.getElementById('linksBody').childNodes.length;
  6205. var data=[ [] ];
  6206. /* Récupération et tri des liens */
  6207. for(var i=1 ; i<=numLinks ; i++) {
  6208. MY_removeValue('URL'+i);
  6209. MY_removeValue('URL'+i+'.nom');
  6210. MY_removeValue('URL'+i+'.ico');
  6211. var url = document.getElementById('url'+i).value;
  6212. var nom = document.getElementById('nom'+i).value;
  6213. var ico = document.getElementById('ico'+i).value;
  6214. if(url && (nom || ico) ) {
  6215. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6216. }
  6217. }
  6218. /* Sauvegarde */
  6219. for(var i=1 ; i<data.length ; i++) {
  6220. MY_setValue('URL'+i,data[i][0]);
  6221. MY_setValue('URL'+i+'.nom',data[i][1]);
  6222. MY_setValue('URL'+i+'.ico',data[i][2]);
  6223. }
  6224. }
  6225.  
  6226. function saveAll() {
  6227. var urlIco = document.getElementById('icoMenuIco').value;
  6228. if(urlIco) {
  6229. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6230. }
  6231. else {
  6232. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6233. document.getElementById('icoMenuIco').value = '';
  6234. }
  6235. saveLinks();
  6236. refreshLinks();
  6237. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6238. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6239. if(maxcdm) {
  6240. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6241. }
  6242. else {
  6243. MY_removeValue(numTroll+'.MAXCDM');
  6244. document.getElementById('maxcdm').value = '';
  6245. }
  6246.  
  6247. MY_setValue('NOINFOEM',
  6248. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6249. // Pourquoi Tilk stockait-il tout en str ?
  6250. // -> parce que les booléens c'est foireux (vérifié)
  6251. MY_setValue(numTroll+'.USECSS',
  6252. document.getElementById('usecss').checked ? 'true':'false');
  6253. MY_setValue('INFOCARAC',
  6254. document.getElementById('infocarac').checked ? 'true' : 'false');
  6255. //MY_setValue(numTroll+'.SEND_IDT',
  6256. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6257. // Fonctionnalité désactivée
  6258.  
  6259. MY_setValue(numTroll+'.AUTOCDM',
  6260. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6261. MY_setValue('VUECARAC',
  6262. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6263. MY_setValue('CONFIRMEDECALAGE',
  6264. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6265.  
  6266. saveITData();
  6267. var bouton = document.getElementById('saveAll');
  6268. bouton.value = (bouton.value=='Sauvegardé !') ?
  6269. 'Re-sauvegardé !' : 'Sauvegardé !';
  6270. }
  6271.  
  6272.  
  6273. /*-[functions]----------------- EventListeners -------------------------------*/
  6274.  
  6275. function onChangeIT() {
  6276. var IT = document.getElementById('itSelect').value;
  6277. var itBody = document.getElementById('itBody');
  6278. itBody.innerHTML = '';
  6279. if(IT=='bricol') {
  6280. var tr = appendTr(itBody,'mh_tdpage')
  6281. var td = appendTd(tr);
  6282. var str = MY_getValue(numTroll+'.INFOSIT');
  6283. //window.console.log('onChangeIT str=' + str);
  6284. if(str) {
  6285. var arr = str.split('$');
  6286. var system = arr[1];
  6287. var login = arr[2];
  6288. var affhv = arr[4];
  6289. }
  6290. appendText(td,'Nom du système : ');
  6291. appendTextbox(td,'text','urlbricol',20,50,system);
  6292. td = appendTd(tr);
  6293. appendText(td,'Login du compte : ');
  6294. appendTextbox(td,'text','loginbricol',20,50,login);
  6295. td = appendTd(tr);
  6296. appendText(td,'Mot de passe du compte : ');
  6297. appendTextbox(td,'password','passbricol',20,50);
  6298. td = appendTd(tr);
  6299. appendText(td,'Affichage des Trõlls hors vue : ');
  6300. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  6301. appendCheckBox(td,'affhvbricol', (affhv>0));
  6302. }
  6303. }
  6304.  
  6305. function refreshLinks() {
  6306. document.getElementById('linksBody').innerHTML = '';
  6307. var anotherURL = MY_getValue('URL1');
  6308. if(!anotherURL) { addLinkField(); }
  6309. var i=1;
  6310. while(anotherURL && i<99) {
  6311. addLinkField(i,anotherURL,
  6312. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6313. i++;
  6314. anotherURL = MY_getValue('URL'+i);
  6315. }
  6316. }
  6317.  
  6318. function addLinkField(i,url,nom,ico) {
  6319. var linksBody = document.getElementById('linksBody');
  6320. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6321. var tr = appendTr(linksBody);
  6322. var td = appendTdCenter(tr);
  6323. appendText(td,'Lien '+i+' : ');
  6324. appendTextbox(td,'text','url'+i,40,150,url);
  6325. td = appendTdCenter(tr);
  6326. appendText(td,'Nom : ');
  6327. appendTextbox(td,'text','nom'+i,20,150,nom);
  6328. td = appendTdCenter(tr);
  6329. appendText(td,'Icône : ');
  6330. appendTextbox(td,'text','ico'+i,40,150,ico);
  6331. }
  6332.  
  6333. function removeLinkField() {
  6334. var linksBody = document.getElementById('linksBody');
  6335. var i = linksBody.childNodes.length;
  6336. MY_removeValue('URL'+i);
  6337. MY_removeValue('URL'+i+'.nom');
  6338. MY_removeValue('URL'+i+'.ico');
  6339. linksBody.removeChild(linksBody.lastChild);
  6340. if(linksBody.childNodes.length==0) { addLinkField(); }
  6341. }
  6342.  
  6343. function resetMainIco() {
  6344. document.getElementById('icoMenuIco').value=
  6345. URL_MZimg + 'mz_logo_small.png';
  6346. }
  6347.  
  6348.  
  6349. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6350.  
  6351. function insertTitle(next,txt) {
  6352. var div = document.createElement('div');
  6353. div.className = 'titre2';
  6354. appendText(div,txt);
  6355. insertBefore(next,div);
  6356. return div;
  6357. }
  6358.  
  6359. function insertMainTable(next) {
  6360. var table = document.createElement('table');
  6361. table.width = '98%';
  6362. table.border = 0;
  6363. table.align = 'center';
  6364. table.cellPadding = 2;
  6365. table.cellSpacing = 1;
  6366. table.className = 'mh_tdborder';
  6367. var tbody = document.createElement('tbody');
  6368. table.appendChild(tbody);
  6369. insertBefore(next,table);
  6370. return tbody;
  6371. }
  6372.  
  6373. function appendSubTable(node) {
  6374. var table = document.createElement('table');
  6375. table.width = '100%';
  6376. var tbody = document.createElement('tbody');
  6377. table.appendChild(tbody);
  6378. node.appendChild(table);
  6379. return tbody;
  6380. }
  6381.  
  6382. function insertOptionTable(insertPt) {
  6383. var mainBody = insertMainTable(insertPt);
  6384. /* Liens dans le Menu */
  6385. var tr = appendTr(mainBody,'mh_tdtitre');
  6386. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6387. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6388. appendText(td,'Icône du Menu: ');
  6389. var url = MY_getValue(numTroll+'.ICOMENU');
  6390. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6391. url = URL_MZimg + 'mz_logo_small.png';
  6392. }
  6393. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6394. appendButton(td,'Réinitialiser',resetMainIco);
  6395. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6396. var tbody = appendSubTable(td);
  6397. tbody.id = 'linksBody';
  6398. refreshLinks();
  6399. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6400. appendButton(td,'Ajouter',addLinkField);
  6401. appendButton(td,'Supprimer',removeLinkField);
  6402. /* Options de la Vue : vue externe, nb de CdM, etc */
  6403. tr = appendTr(mainBody,'mh_tdtitre');
  6404. appendTdText(tr,'Options de la Vue :',true);
  6405. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6406. tbody = appendSubTable(td);
  6407. tr = appendTr(tbody);
  6408. td = appendTdText(tr,'Vue externe : ');
  6409. var select = document.createElement('select');
  6410. select.id = 'vueext';
  6411. td.appendChild(select);
  6412. var listeVues2D = [
  6413. 'Bricol\' Vue',
  6414. 'Vue du CCM',
  6415. 'Vue Gloumfs 2D',
  6416. 'Vue Gloumfs 3D',
  6417. 'Grouky Vue!'
  6418. ];
  6419. for(var i=0 ; i<listeVues2D.length ; i++) {
  6420. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6421. }
  6422. if(MY_getValue('VUEEXT')) {
  6423. select.value = MY_getValue('VUEEXT');
  6424. }
  6425. td = appendTd(tr);
  6426. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6427. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6428. tr = appendTr(tbody);
  6429. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6430. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6431. td = appendTd(tr);
  6432. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6433. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6434. /* Interface Tactique */
  6435. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6436. appendText(td,'Interface Tactique : ',true);
  6437. select = document.createElement('select');
  6438. select.id = 'itSelect';
  6439. appendOption(select,'none','Aucune');
  6440. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6441. // seule interface supportée !
  6442. td.appendChild(select);
  6443. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6444. tbody = appendSubTable(td);
  6445. tbody.id = 'itBody';
  6446. select.onchange = onChangeIT;
  6447. var str = MY_getValue(numTroll+'.INFOSIT');
  6448. if(str) {
  6449. select.value = str.slice(0,str.indexOf('$'));
  6450. onChangeIT();
  6451. }
  6452. /* Options diverses */
  6453. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6454. appendText(td,'Options diverses :',true);
  6455. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6456. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6457. appendText(td,
  6458. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6459. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6460. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6461. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6462. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6463. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6464. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6465. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6466. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6467. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6468. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6469. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6470. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6471. /* Bouton SaveAll */
  6472. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6473. input = appendButton(td,'Sauvegarder',saveAll);
  6474. input.id = 'saveAll';
  6475. }
  6476.  
  6477. function insertCreditsTable(insertPt) {
  6478. var tbody = insertMainTable(insertPt);
  6479. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6480. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6481. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6482.  
  6483. var ul = document.createElement('ul');
  6484. td.appendChild(ul);
  6485. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6486. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6487. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6488. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6489. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6490. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6491. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6492. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6493. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6494. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6495. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6496. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6497. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6498. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6499. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6500. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6501. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6502. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6503. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6504. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6505. }
  6506.  
  6507.  
  6508. /* [functions] Obsolètes */
  6509. function deleteEnchantement()
  6510. {
  6511. try
  6512. {
  6513. var idEquipement = this.getAttribute('name');
  6514. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6515. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6516. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6517. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6518. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6519. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6520. var string = "";
  6521. for(var i=0;i<listeEquipement.length;i++)
  6522. {
  6523. if(listeEquipement[i]!=idEquipement)
  6524. if(string=="")
  6525. string = listeEquipement[i];
  6526. else
  6527. string += ";"+listeEquipement[i];
  6528. }
  6529. if(string=="")
  6530. {
  6531. MY_removeValue(numTroll+".enchantement.liste");
  6532. var table = this.parentNode.parentNode.parentNode.parentNode;
  6533. var parent = table.parentNode;
  6534. for(var i=0;i<parent.childNodes.length;i++)
  6535. {
  6536. if(parent.childNodes[i]==table)
  6537. {
  6538. parent.removeChild(parent.childNodes[i-1]);
  6539. parent.removeChild(parent.childNodes[i-1]);
  6540. parent.removeChild(parent.childNodes[i-1]);
  6541. break;
  6542. }
  6543. }
  6544. }
  6545. else
  6546. {
  6547. MY_getValue(numTroll+".enchantement.liste",string);
  6548. this.parentNode.parentNode.parentNode
  6549. .removeChild(this.parentNode.parentNode);
  6550. }
  6551. }
  6552. catch(e)
  6553. {
  6554. window.alert(e);
  6555. }
  6556. }
  6557. /* [functions] fin Obsolètes */
  6558.  
  6559. /*-[functions]---------------- Partie principale -----------------------------*/
  6560.  
  6561. function do_option() {
  6562. start_script(712);
  6563. var insertPoint = document.getElementById('footer1');
  6564. insertBefore(insertPoint,document.createElement('p'));
  6565. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  6566. ti.onclick = function (e) {
  6567. var evt = e || window.event;
  6568. if (!evt.shiftKey) return;
  6569. var txt = '';
  6570. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6571. var k = localStorage.key(i);
  6572. if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6573. txt += k + "\t" + localStorage.getItem(k) + "\n";
  6574. }
  6575. copyTextToClipboard(txt);
  6576. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  6577. }
  6578. ti.title = 'Version ' + GM_info.script.version;
  6579. insertOptionTable(insertPoint);
  6580. /* insertion enchantements ici
  6581. if(...)
  6582. insertEnchantementTable();
  6583. */
  6584. insertBefore(insertPoint,document.createElement('p'));
  6585. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6586. ti.onclick = function (e) {
  6587. var evt = e || window.event;
  6588. if (!evt.shiftKey) return;
  6589. var oldDev = MY_getValue('MZ_dev');
  6590. if (oldDev) {
  6591. MY_removeValue('MZ_dev');
  6592. } else {
  6593. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6594. MY_setValue('MZ_dev', 1);
  6595. }
  6596. document.location.href = document.location.href;
  6597. }
  6598. insertCreditsTable(insertPoint);
  6599. insertBefore(insertPoint,document.createElement('p'));
  6600.  
  6601. /* [zone] Obsolète ?? */
  6602. if(MY_getValue(numTroll+".enchantement.liste")
  6603. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6604. {
  6605. insertTitle(insertPoint, 'Les Enchantements en cours');
  6606. table = document.createElement('table');
  6607. table.setAttribute('width', '98%');
  6608. table.setAttribute('border', '0');
  6609. table.setAttribute('align', 'center');
  6610. table.setAttribute('cellpadding', '2');
  6611. table.setAttribute('cellspacing', '1');
  6612. table.setAttribute('class', 'mh_tdborder');
  6613.  
  6614. tbody = document.createElement('tbody');
  6615. table.appendChild(tbody);
  6616. tr = appendTr(tbody, 'mh_tdtitre');
  6617. appendTdText(tr, 'Equipement',1);
  6618. appendTdText(tr, 'Composants',1);
  6619. appendTdText(tr, 'Enchanteur',1);
  6620. appendTdText(tr, 'Action',1);
  6621. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6622. for(var i=0;i<listeEquipement.length;i++)
  6623. {
  6624. try
  6625. {
  6626. var idEquipement = listeEquipement[i];
  6627. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6628. +idEquipement+".objet");
  6629. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6630. +idEquipement+".enchanteur").split(";");
  6631. var ul = document.createElement('UL');
  6632. for(var j=0;j<3;j++)
  6633. {
  6634. var infoComposant = MY_getValue(numTroll+".enchantement."
  6635. +idEquipement+".composant."+j).split(";");
  6636. var texte = infoComposant[4].replace("Ril ","Œil ");
  6637. for(var k=5;k<infoComposant.length;k++)
  6638. {
  6639. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6640. }
  6641. li = appendLI(ul,texte);
  6642. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6643. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6644. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6645. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6646. string+= '<input type="hidden" name="q" value="min" />';
  6647. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6648. 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>';
  6649.  
  6650. string+= '</form>';
  6651. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6652. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6653. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6654. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6655. li.innerHTML += string;
  6656. }
  6657. tr = appendTr(tbody, 'mh_tdpage');
  6658. td = appendTdText(tr, nomEquipement);
  6659. td.setAttribute('valign', 'center');
  6660. td = document.createElement('td');
  6661. td.appendChild(ul);
  6662. tr.appendChild(td);
  6663. td.setAttribute('valign', 'center');
  6664. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6665. td.setAttribute('valign', 'center');
  6666. td = document.createElement('td');
  6667. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6668. input.setAttribute('name', idEquipement);
  6669. tr.appendChild(td);
  6670. td.setAttribute('valign', 'center');
  6671. }
  6672. catch(e)
  6673. {
  6674. }
  6675. }
  6676. insertBefore(insertPoint, table);
  6677. insertBefore(insertPoint, document.createElement('p'));
  6678. }
  6679. /* [zone] fin Obsolète ?? */
  6680.  
  6681.  
  6682. displayScriptTime();
  6683. }
  6684.  
  6685. /*******************************************************************************
  6686. * This file is part of Mountyzilla. *
  6687. * *
  6688. * Mountyzilla is free software; you can redistribute it and/or modify *
  6689. * it under the terms of the GNU General Public License as published by *
  6690. * the Free Software Foundation; either version 2 of the License, or *
  6691. * (at your option) any later version. *
  6692. * *
  6693. * Mountyzilla is distributed in the hope that it will be useful, *
  6694. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6695. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6696. * GNU General Public License for more details. *
  6697. * *
  6698. * You should have received a copy of the GNU General Public License *
  6699. * along with Mountyzilla; if not, write to the Free Software *
  6700. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6701. *******************************************************************************/
  6702.  
  6703. // x~x equip
  6704.  
  6705. /**
  6706. * 2014-02-08 - v2.0a (from scratch)
  6707. * 2014-02-18 - v2.0a0
  6708. * - ajout calcul Carats / UM des minerais + totaux
  6709. * 2014-03-06 - v2.0a1
  6710. * - retour Infos EM des Champis
  6711. * TODO
  6712. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6713. */
  6714.  
  6715. function traiteChampis() {
  6716. try{
  6717. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6718. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6719. }
  6720. catch(e){return;}
  6721. if(trlist.length<=0) return;
  6722. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6723. var node = trlist.snapshotItem(i).childNodes[7];
  6724. var str = node.textContent.trim();
  6725. var type = str.slice(0,str.lastIndexOf(' '));
  6726. var mundi = mundiChampi[type];
  6727. if(!mundi) continue;
  6728. var urlImg = URL_MZimg
  6729. +'Competences/ecritureMagique.png';
  6730. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6731. appendText(node,' ');
  6732. node.appendChild(img);
  6733. }
  6734. }
  6735.  
  6736. function traiteCompos() {
  6737. try {
  6738. var tr = document.getElementById('mh_objet_hidden_Composant');
  6739. var tbody = document.evaluate("./td/table/tbody",
  6740. tr, null, 9, null).singleNodeValue;
  6741. }
  6742. catch(e) {return;}
  6743. insererInfosEM(tbody);
  6744. }
  6745.  
  6746. function traiteMinerai() {
  6747. try{
  6748. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6749. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6750. }
  6751. catch(e){return;}
  6752. if(trlist.length<=0) return;
  6753. var totaux = {};
  6754. var str;
  6755. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6756. var node = trlist.snapshotItem(i);
  6757. var nature = node.childNodes[7].textContent,
  6758. caracs = node.childNodes[9].textContent;
  6759. var taille = Number(caracs.match(/\d+/)[0]);
  6760. var coef = 1;
  6761. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6762. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6763. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6764. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6765. if(nature.indexOf('Mithril')!=-1) {
  6766. coef = 0.2*coef;
  6767. str = ' | UM: ';
  6768. }
  6769. else {
  6770. coef = 0.75*coef+1.25;
  6771. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6772. str = ' | Carats: ';
  6773. }
  6774. var carats = Math.round(taille*coef)
  6775. appendText(node.childNodes[9], str+carats );
  6776. if(!totaux[nature]) {
  6777. totaux[nature] = [taille,carats];
  6778. }
  6779. else {
  6780. totaux[nature][0] += taille;
  6781. totaux[nature][1] += carats;
  6782. }
  6783. }
  6784. str = 'Total : ';
  6785. for(var nature in totaux) {
  6786. if(str.length>8) str += ', ';
  6787. if(nature.indexOf('Mithril')!=-1) {
  6788. str += nature+totaux[nature][1]+' UM';
  6789. }
  6790. else {
  6791. str += nature+totaux[nature][0]+'U/'
  6792. +totaux[nature][1]+'c';
  6793. }
  6794. }
  6795. /*var node = document.getElementById('mh_plus_Minerai');
  6796. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6797. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6798. if(!titre) return;*/
  6799. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6800. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6801. td.colSpan = 7;
  6802. }
  6803.  
  6804. function do_equip() {
  6805. start_script();
  6806.  
  6807. traiteChampis();
  6808. traiteCompos();
  6809. traiteMinerai();
  6810.  
  6811. displayScriptTime();
  6812. }
  6813.  
  6814. /*******************************************************************************
  6815. * This file is part of Mountyzilla. *
  6816. * *
  6817. * Mountyzilla is free software; you can redistribute it and/or modify *
  6818. * it under the terms of the GNU General Public License as published by *
  6819. * the Free Software Foundation; either version 2 of the License, or *
  6820. * (at your option) any later version. *
  6821. * *
  6822. * Mountyzilla is distributed in the hope that it will be useful, *
  6823. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6824. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6825. * GNU General Public License for more details. *
  6826. * *
  6827. * You should have received a copy of the GNU General Public License *
  6828. * along with Mountyzilla; if not, write to the Free Software *
  6829. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6830. *******************************************************************************/
  6831.  
  6832. // x~x diplo
  6833.  
  6834. /*
  6835. TODO:
  6836. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6837. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6838. V Étape 3: Ajout de la diplo perso
  6839. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6840. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6841. Options Globales:
  6842. Actuelles:
  6843. numTroll.USECSS,
  6844. numTroll.NODIPLO
  6845. NOMYTH
  6846. Nouvelles:
  6847. TODO numTroll.USECSS
  6848. numTroll.diplo.off (remplace NODIPLO)
  6849. numTroll.diplo.guilde
  6850. numTroll.diplo.perso
  6851. Structure de diplo.guilde:
  6852. isOn: 'true' ou 'false'
  6853. isDetailOn: 'true' ou 'false'
  6854. guilde
  6855. > id
  6856. > couleur
  6857. AllAmis,AllEnnemis: couleur
  6858. Amis0,...,Ennemis5
  6859. > Troll: idTroll1;...;
  6860. > Guilde: idGuilde1;...;
  6861. > titre
  6862. > couleur
  6863. Structure de diplo.perso:
  6864. isOn: 'true' ou 'false'
  6865. mythiques: couleur
  6866. Troll,Guilde,Monstre:
  6867. > id
  6868. > couleur
  6869. > description
  6870. */
  6871.  
  6872. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6873.  
  6874. function couleurAleatoire() {
  6875. var alph = '0123456789ABCDEF'.split('');
  6876. var clr = '#';
  6877. for (var i=0; i<6; i++) {
  6878. clr+=alph[ Math.floor(16*Math.random()) ];
  6879. }
  6880. return clr;
  6881. }
  6882.  
  6883. function isCouleur(str) {
  6884. return /^#[0-9A-F]{6}$/i.test(str);
  6885. }
  6886.  
  6887. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6888.  
  6889. function appendChoixCouleur(node,id) {
  6890. var span = document.createElement('span');
  6891. span.id = 'span'+id;
  6892. if(isDetailOn) {
  6893. span.style.display = 'none';
  6894. }
  6895. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6896. if(diploGuilde[id]) {
  6897. couleur = diploGuilde[id];
  6898. }
  6899. appendText(span,' - Couleur HTML: ');
  6900. var input = appendTextbox(span,'text',id,7,7,couleur);
  6901. input.onkeyup = previewCouleur;
  6902. input.onchange = previewCouleur;
  6903. input.onkeyup();
  6904. node.appendChild(span);
  6905. }
  6906.  
  6907. function insertChoixCouleur(node,id) {
  6908. var span = document.createElement('span');
  6909. span.id = 'span'+id;
  6910. // La couleur détaillée passera à une valeur aléatoire
  6911. // si toggle vers isDetailOn
  6912. var couleur = couleurAleatoire();
  6913. if(!isDetailOn) {
  6914. span.style.display = 'none';
  6915. } else if(diploGuilde[id]) {
  6916. couleur = diploGuilde[id].couleur;
  6917. }
  6918. appendText(span,' - Couleur HTML: ');
  6919. var input = appendTextbox(span,'text',id,7,7,couleur);
  6920. input.onkeyup = previewCouleur;
  6921. input.onchange = previewCouleur;
  6922. input.onkeyup();
  6923. insertBefore(node,span);
  6924. }
  6925.  
  6926. function setChoixCouleurs() {
  6927. try {
  6928. var form = document.getElementsByName('ActionForm')[0];
  6929. var nodesAE = document.evaluate(
  6930. "./table/tbody/tr/td[@class='mh_tdtitre']",
  6931. form, null, 7, null
  6932. );
  6933. var nodes = document.evaluate(
  6934. "./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6935. form, null, 7, null
  6936. );
  6937. } catch(e) {
  6938. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6939. return false;
  6940. };
  6941. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6942. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6943. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6944. for(var i=0 ; i<5 ; i++) {
  6945. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6946. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6947. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6948. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6949. }
  6950. return true;
  6951. }
  6952.  
  6953. function fetchDiploGuilde() {
  6954. try {
  6955. for(var AE in {Amis:0,Ennemis:0}) {
  6956. for(var i=0 ; i<5 ; i++) {
  6957. /* Récup des A/E de rang i */
  6958. var td = document.getElementById('td'+AE+i);
  6959. var ligne = td.getElementsByTagName('table')[0].rows;
  6960. var titre = trim(td.firstChild.textContent);
  6961. // On laisse la gestion des couleurs à setChoixCouleurs:
  6962. var couleur = document.getElementById(AE+i).value;
  6963. diploGuilde[AE+i] = {
  6964. Troll:'',
  6965. Guilde:'',
  6966. titre: titre,
  6967. couleur: couleur
  6968. };
  6969. for(var j=1 ; j<ligne.length ; j++) {
  6970. var str = trim(ligne[j].cells[0].textContent);
  6971. var idx = str.lastIndexOf('(');
  6972. var num = str.slice(idx+1,-1);
  6973. var type = trim(ligne[j].cells[1].textContent);
  6974. diploGuilde[AE+i][type] += num+';';
  6975. }
  6976. }
  6977. }
  6978. } catch(e) {
  6979. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  6980. return false;
  6981. }
  6982. return true;
  6983. }
  6984.  
  6985.  
  6986. /*-[functions]--------------------- Handlers ---------------------------------*/
  6987.  
  6988. function toggleDetails() {
  6989. isDetailOn = !isDetailOn;
  6990. for(var AE in {Amis:0,Ennemis:0}) {
  6991. document.getElementById('spanAll'+AE).style.display =
  6992. (isDetailOn?'none':'');
  6993. for(var i=0 ; i<5 ; i++) {
  6994. document.getElementById('span'+AE+i).style.display =
  6995. (isDetailOn?'':'none');
  6996. }
  6997. }
  6998. }
  6999.  
  7000. function toggleMythiques() {
  7001. isMythiquesOn = !isMythiquesOn;
  7002. document.getElementById('spanMythiques').style.display =
  7003. (isMythiquesOn?'':'none');
  7004. }
  7005.  
  7006. function previewCouleur() {
  7007. var value = this.value;
  7008. if(isCouleur(value)) {
  7009. this.style.backgroundColor = value;
  7010. this.title = '';
  7011. } else {
  7012. this.style.backgroundColor = '';
  7013. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7014. }
  7015. }
  7016.  
  7017. function appendMenuType(node,duType) {
  7018. var select = document.createElement('select');
  7019. select.className = 'SelectboxV2';
  7020. var type = ['Guilde','Troll','Monstre'];
  7021. for(var i=0 ; i<3 ; i++) {
  7022. appendOption(select,type[i],type[i]);
  7023. if(type[i]==duType) { select.selectedIndex=i; }
  7024. }
  7025. node.appendChild(select);
  7026. }
  7027.  
  7028. function ajouteChamp(type,num,couleur,descr) {
  7029. var champs = document.getElementById('diploPerso');
  7030. var nb = champs.rows.length;
  7031. var tr = champs.insertRow(-1);
  7032. var td = appendTd(tr);
  7033. appendMenuType(td,type);
  7034. td = appendTd(tr);
  7035. appendText(td,' n°');
  7036. appendTextbox(td,'text','num'+nb,6,15,num);
  7037. td = appendTd(tr);
  7038. appendText(td,' couleur HTML:');
  7039. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7040. input.onkeyup = previewCouleur;
  7041. input.onchange = previewCouleur;
  7042. input.onkeyup();
  7043. td = appendTd(tr);
  7044. appendText(td,' Description:');
  7045. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7046. td = appendTd(tr);
  7047. var span = document.createElement('span');
  7048. appendText(span,'[ok!]',true);
  7049. span.style.visibility = 'hidden';
  7050. td.appendChild(span);
  7051. td = appendTd(tr);
  7052. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7053. }
  7054.  
  7055. function retireCeChamp() {
  7056. var thisTr = this.parentNode.parentNode;
  7057. thisTr.parentNode.removeChild(thisTr);
  7058. var champs = document.getElementById('diploPerso');
  7059. if(champs.rows.length==0) { ajouteChamp(); }
  7060. }
  7061.  
  7062. function valideChamp(champ) {
  7063. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7064. isCouleur(champ.cells[2].childNodes[1].value);
  7065. if(isValide) {
  7066. champ.cells[4].firstChild.style.visibility = 'visible';
  7067. } else {
  7068. champ.cells[4].firstChild.style.visibility = 'hidden';
  7069. }
  7070. return isValide;
  7071. }
  7072.  
  7073. function sauvegarderTout() {
  7074. /* Diplo de guilde */
  7075. diploGuilde.isOn =
  7076. document.getElementById('isGuildeOn').checked?'true':'false';
  7077. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7078. var numGuilde = Number(document.getElementById('numGuilde').value);
  7079. var couleur = document.getElementById('couleurGuilde').value;
  7080. if(numGuilde) {
  7081. diploGuilde.guilde = {
  7082. id: numGuilde,
  7083. couleur: couleur
  7084. };
  7085. } else {
  7086. delete diploGuilde.guilde;
  7087. }
  7088. for(var AE in {Amis:0,Ennemis:0}) {
  7089. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7090. for(var i=0 ; i<5 ; i++) {
  7091. if(isDetailOn) {
  7092. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7093. } else {
  7094. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7095. }
  7096. }
  7097. }
  7098. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7099. /* Diplo personnelle (ex-fonction saveChamps) */
  7100. var champs = document.getElementById('diploPerso');
  7101. diploPerso = {
  7102. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7103. Guilde: {},
  7104. Troll: {},
  7105. Monstre: {}
  7106. };
  7107. if(isMythiquesOn &&
  7108. isCouleur(document.getElementById('couleurMythiques').value)) {
  7109. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7110. }
  7111. for(var i=0 ; i<champs.rows.length ; i++) {
  7112. if(valideChamp(champs.rows[i])) {
  7113. var type = champs.rows[i].cells[0].firstChild.value;
  7114. var num = champs.rows[i].cells[1].childNodes[1].value;
  7115. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7116. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7117. diploPerso[type][num] = {
  7118. couleur: couleur
  7119. };
  7120. if(descr) {
  7121. diploPerso[type][num].titre = descr;
  7122. }
  7123. }
  7124. }
  7125. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7126.  
  7127. avertissement('Données sauvegardées');
  7128. }
  7129.  
  7130.  
  7131. /*-[functions]------------- Modifications de la page -------------------------*/
  7132.  
  7133. function creeTablePrincipale() {
  7134. var insertPt = document.getElementById('insertPt');
  7135. /* Titre + bouton de Sauvegarde */
  7136. var tr = insertTr(insertPt,'mh_tdtitre');
  7137. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7138. appendButton(td,'Sauvegarder',sauvegarderTout);
  7139. /* Options fixes */
  7140. tr = insertTr(insertPt,'mh_tdpage');
  7141. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7142. appendBr(td);
  7143. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7144. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7145. appendBr(td);
  7146. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7147. appendText(td,'Utiliser des couleurs détaillées (10)');
  7148. /* Diplo personnelle */
  7149. tr = insertTr(insertPt,'mh_tdpage');
  7150. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7151. appendBr(td);
  7152. // Diplo Mythiques
  7153. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7154. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7155. var span = document.createElement('span');
  7156. span.id = 'spanMythiques';
  7157. if(!isMythiquesOn) {
  7158. span.style.display = 'none';
  7159. }
  7160. var couleur = '#FFAAAA';
  7161. if(diploPerso.mythiques) {
  7162. couleur = diploPerso.mythiques;
  7163. }
  7164. appendText(span,' - couleur HTML:');
  7165. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7166. input.onkeyup = previewCouleur;
  7167. input.onchange = previewCouleur;
  7168. input.onkeyup();
  7169. td.appendChild(span);
  7170. appendBr(td);
  7171. // Diplo éditable
  7172. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7173. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7174. appendBr(td);
  7175. var table = document.createElement('table');
  7176. table.id = 'diploPerso'
  7177. td.appendChild(table);
  7178. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7179. for(var num in diploPerso[type]) {
  7180. ajouteChamp(
  7181. type,
  7182. num,
  7183. diploPerso[type][num].couleur,
  7184. diploPerso[type][num].titre
  7185. );
  7186. }
  7187. }
  7188. if(table.rows.length==0) {
  7189. ajouteChamp();
  7190. }
  7191. appendButton(td,'Ajouter',ajouteChamp)
  7192. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7193. appendText(td,' ');
  7194. appendButton(td,
  7195. 'Exemples de couleur',
  7196. function() {
  7197. var fenetre = window.open(
  7198. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7199. 'Divers',
  7200. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7201. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7202. );
  7203. fenetre.focus();
  7204. }
  7205. );
  7206. /* Couleur de Guilde */
  7207. tr = insertTr(insertPt,'mh_tdtitre');
  7208. td = appendTdText(tr,'GUILDE',true);
  7209. appendText(td,' - n°');
  7210. appendTextbox(td,'text','numGuilde',5,10,
  7211. diploGuilde.guilde && diploGuilde.guilde.id ?
  7212. diploGuilde.guilde.id : ''
  7213. );
  7214. appendText(td,' - Couleur HTML: ');
  7215. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7216. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7217. diploGuilde.guilde.couleur : '#BBBBFF'
  7218. );
  7219. input.onkeyup = previewCouleur;
  7220. input.onchange = previewCouleur;
  7221. input.onkeyup();
  7222. }
  7223.  
  7224.  
  7225. /*-[functions]----------------------- Main -----------------------------------*/
  7226.  
  7227. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  7228. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  7229. var isDetailOn = diploGuilde.isDetailOn=='true';
  7230. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  7231. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  7232. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7233.  
  7234. function do_diplo() {
  7235. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7236. creeTablePrincipale();
  7237. }
  7238. }
  7239.  
  7240. /*******************************************************************************
  7241. * This file is part of Mountyzilla. *
  7242. * *
  7243. * Mountyzilla is free software; you can redistribute it and/or modify *
  7244. * it under the terms of the GNU General Public License as published by *
  7245. * the Free Software Foundation; either version 2 of the License, or *
  7246. * (at your option) any later version. *
  7247. * *
  7248. * Mountyzilla is distributed in the hope that it will be useful, *
  7249. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7250. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7251. * GNU General Public License for more details. *
  7252. * *
  7253. * You should have received a copy of the GNU General Public License *
  7254. * along with Mountyzilla; if not, write to the Free Software *
  7255. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7256. *******************************************************************************/
  7257.  
  7258. // x~x cdmcomp
  7259.  
  7260. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7261.  
  7262. function getNonNegInts(str) {
  7263. var nbrs = str.match(/\d+/g);
  7264. for(var i=0 ; i<nbrs.length ; i++) {
  7265. nbrs[i] = Number(nbrs[i]);
  7266. }
  7267. return nbrs;
  7268. }
  7269.  
  7270. function traiteCdMcomp() {
  7271. try {
  7272. var msgEffet = document.getElementById('msgEffet');
  7273. } catch(e) {
  7274. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7275. return;
  7276. }
  7277.  
  7278. // Teste si ce message du bot est un message de CdM
  7279. if(!document.evaluate(
  7280. "./p/text()[contains(.,'fait partie')]",
  7281. msgEffet, null, 9, null
  7282. ).singleNodeValue) {
  7283. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7284. return;
  7285. }
  7286. // Début de récupération de la CdM
  7287. /*
  7288. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7289. zone à supprimer
  7290. traitement Armure Physique/Magique reporté en php
  7291.  
  7292. cdm = document.evaluate(
  7293. "./p/text()[contains(.,'fait partie')]",
  7294. msgEffet, null, 9, null
  7295. ).singleNodeValue.nodeValue+'\n';
  7296. var tbody = document.evaluate(
  7297. "descendant::table/tbody",
  7298. msgEffet, null, 9, null
  7299. ).singleNodeValue;
  7300. var nomStat = document.evaluate(
  7301. "./tr/td[1]/b/text()",
  7302. tbody, null, 7, null
  7303. );
  7304. var valStat = document.evaluate(
  7305. "./tr/td[2]/descendant::text()",
  7306. tbody, null, 7, null
  7307. );
  7308. var i=0;
  7309. while(i<nomStat.snapshotLength) {
  7310. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7311. cdm += 'Armure : ';
  7312. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7313. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7314. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7315. armp = [0,armp[0]];
  7316. }
  7317. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7318. armm = [0,armm[0]];
  7319. }
  7320. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7321. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7322. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7323. } else {
  7324. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7325. }
  7326. cdm += ')\n';
  7327. i++;
  7328. } else {
  7329. cdm += nomStat.snapshotItem(i).nodeValue+
  7330. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7331. }
  7332. i++;
  7333. }
  7334. */
  7335. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7336. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7337.  
  7338. // envoi au serveur (PHP) d'un objet avec
  7339. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7340. // tstamp: l'horodatage
  7341. var tabCdM = new Array();
  7342. var etimestamp = document.getElementById('hserveur');
  7343. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7344. var txtBlessure;
  7345. var txtPv;
  7346. for (var eHTML of msgEffet.childNodes) {
  7347. switch (eHTML.nodeName) {
  7348. case '#text':
  7349. var s = eHTML.nodeValue.trim();
  7350. if (s != '') tabCdM.push(s);
  7351. break;
  7352. case 'P':
  7353. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7354. s = s.trim();
  7355. if (s != '') tabCdM.push(s);
  7356. break;
  7357. case 'TABLE':
  7358. var s = 'table';
  7359. for (var eTr of eHTML.rows) {
  7360. var tabTd = new Array();
  7361. for (var eTd of eTr.cells) {
  7362. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7363. s = s.trim();
  7364. tabTd.push(s);
  7365. }
  7366. if (tabTd.length >= 2) {
  7367. if (tabTd[0].match(/Blessure/i)) {
  7368. txtBlessure = tabTd[1]
  7369. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  7370. txtPv = tabTd[1]
  7371. }
  7372. }
  7373. tabCdM.push(tabTd);
  7374. }
  7375. break;
  7376. default:
  7377. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  7378. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7379. if (s != '') tabCdM.push(s);
  7380. break;
  7381. }
  7382. }
  7383. var oData = {};
  7384. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  7385. oData.idTroll = numTroll;
  7386. oData.tabCdM = tabCdM;
  7387. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  7388.  
  7389. // envoi d'une CdM issue de compte-rendu de compétence
  7390. // fonction définie ici pour avoir vue sur la variable tabCdM
  7391. var sendInfoCDM = function () {
  7392. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7393. var buttonCDM = this;
  7394. var texte = '';
  7395. FF_XMLHttpRequest({
  7396. method: 'POST',
  7397. url: URL_pageDispatcherV2,
  7398. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7399. headers : {
  7400. /* inutile, à supprimer
  7401. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7402. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7403. */
  7404. 'Content-type':'application/x-www-form-urlencoded',
  7405. },
  7406. onload: function(responseDetails) {
  7407. texte = responseDetails.responseText;
  7408. buttonCDM.value = texte;
  7409. if (!isDEV) buttonCDM.disabled = true;
  7410. }
  7411. });
  7412. }
  7413.  
  7414. // Envoi auto ou insertion bouton envoi (suivant option)
  7415. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7416. sendInfoCDM();
  7417. var p = document.createElement('p');
  7418. p.style.color = 'green';
  7419. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7420. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7421. } else {
  7422. insertButtonCdm('as_Action', sendInfoCDM);
  7423. }
  7424.  
  7425. // Insertion de l'estimation des PV restants
  7426. /*
  7427. var pv = valStat.snapshotItem(1).nodeValue;
  7428. if(pv.indexOf("entre")==-1) {
  7429. return;
  7430. }
  7431. var trPv = document.evaluate(
  7432. "//tr[contains(td/b/text(),'Points de Vie')]",
  7433. msgEffet, null, 9, null).singleNodeValue;
  7434. tdPv = trPv.cells[1];
  7435. txtPv = tdPv.innerText || tdPv.textContent;
  7436. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  7437. if(0) { //pv) { // bloqué en attendant correction
  7438. */
  7439. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  7440. if (txtBlessure !== undefined && txtPv !== undefined) {
  7441. var pv = getPVsRestants(txtPv,txtBlessure);
  7442. if (MY_DEBUG) window.console.log('pv=' + pv);
  7443. if (pv) { // pv null si le monstre n'est pas blessé
  7444. var trBless = document.evaluate(
  7445. "//tr[contains(td/b/text(),'Blessure')]",
  7446. msgEffet, null, 9, null).singleNodeValue;
  7447. var tr = document.createElement('tr');
  7448. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  7449. appendTr(trBless);
  7450. appendTdText(tr, pv[0], true);
  7451. appendTdText(tr, pv[1], true);
  7452. }
  7453. }
  7454. }
  7455.  
  7456. function do_cdmcomp() {
  7457. start_script(31);
  7458. traiteCdMcomp();
  7459. displayScriptTime();
  7460. }
  7461.  
  7462. /*********************************************************************************
  7463. * This file is part of Mountyzilla. *
  7464. * *
  7465. * Mountyzilla is free software; you can redistribute it and/or modify *
  7466. * it under the terms of the GNU General Public License as published by *
  7467. * the Free Software Foundation; either version 2 of the License, or *
  7468. * (at your option) any later version. *
  7469. * *
  7470. * Mountyzilla is distributed in the hope that it will be useful, *
  7471. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7472. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7473. * GNU General Public License for more details. *
  7474. * *
  7475. * You should have received a copy of the GNU General Public License *
  7476. * along with Mountyzilla; if not, write to the Free Software *
  7477. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7478. *********************************************************************************/
  7479.  
  7480. // x~x cmdbot
  7481.  
  7482. /* v0.2 by Dab - 2013-08-20
  7483. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7484. */
  7485.  
  7486. var buttonCDM;
  7487.  
  7488. /*******************************************************************************************
  7489. CDM :
  7490. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7491.  
  7492. Il ne vous est pas possible d'améliorer cette compétence.
  7493.  
  7494. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7495. Niveau : Inimaginable (entre 49 et 51)
  7496. Points de Vie : Surtrollesque (entre 450 et 470)
  7497. Blessure (Approximatif) : 0 %
  7498. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7499. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7500. Dés de Dégat : Très Fort (entre 18 et 20)
  7501. Dés de Régénération : Excellent (égal à 13)
  7502. Armure Physique : Moyen (entre 10 et 12)
  7503. Armure Magique : Faible (inférieur à 6)
  7504. Vue : Moyen (entre 9 et 11)
  7505. Maitrise Magique : Inimaginable (supérieur à 6000)
  7506. Résistance Magique : Inimaginable (supérieur à 6000)
  7507. Nombre d'attaques : 1
  7508. Vitesse de Déplacement : Normale
  7509. Voir le Caché : Oui
  7510. Attaque à distance : Non
  7511. Attaque magique : Oui
  7512. Vole : Non
  7513. Sang froid : Inexistant
  7514. DLA : Milieu
  7515. Durée Tour : Remarquable (entre 9 et 11)
  7516. Chargement : Vide
  7517. Bonus Malus : Aucun
  7518.  
  7519. Vous avez également gagné 1 PX pour la réussite.
  7520. *******************************************************************************************
  7521. BOT :
  7522. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7523.  
  7524. Le Monstre ciblé fait partie des : Mort-Vivant
  7525.  
  7526. Niveau : Incroyable (entre 36 et 38)
  7527. *******************************************************************************************/
  7528.  
  7529. function getNNInt(str) {
  7530. var nbrs = str.match(/\d+/g);
  7531. for (var i=0 ; i<nbrs.length ; i++)
  7532. nbrs[i] = parseInt(nbrs[i]);
  7533. return nbrs;
  7534. }
  7535.  
  7536. // envoi d'une CdM issue d'un message du BOT
  7537. function sendCDM() {
  7538. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  7539. document, null, 9, null).singleNodeValue;
  7540. /* ancienne version à supprimer
  7541. cdm = td.innerHTML;
  7542. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7543. "$3$4 ($1 - N°$2)<br>");
  7544. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7545. 'Blessure : XX % (approximativement)');
  7546. // Supprime la décomposition P/M de l'Armure
  7547. var bgn = cdm.indexOf('Armure Physique');
  7548. if (bgn!=-1) {
  7549. var end = cdm.indexOf('Vue')-2;
  7550. var lines = cdm.substring(bgn,end).split('<br>');
  7551. var armp = getNNInt(lines[0]);
  7552. var armm = getNNInt(lines[1]);
  7553. if (lines[0].indexOf('(inf')!=-1)
  7554. armp = [0,armp[0]];
  7555. if (lines[1].indexOf('(inf')!=-1)
  7556. armm = [0,armm[0]];
  7557. var insrt = 'Armure : ';
  7558. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7559. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7560. else
  7561. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7562. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7563. }
  7564. cdm = cdm.replace(/<br>/g,'\n');
  7565. */
  7566.  
  7567. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  7568. //window.console.log(tdTxt);
  7569. var oData = {};
  7570. oData.tabCdM = tdTxt.split(/\n/);
  7571. // nettoyage entête : enlève le premier élément tant que
  7572. // - suite de *
  7573. // - "MOUNTYHALL - La Terre des Trõlls"
  7574. // - ligne vide (la première expression régulière matche les lignes vides)
  7575. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  7576. // 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
  7577. var iLigneNonVide;
  7578. for (var i = 0; i < oData.tabCdM.length; i++) {
  7579. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  7580. if (iLigneNonVide === undefined)
  7581. oData.tabCdM.splice(i);
  7582. else
  7583. oData.tabCdM.splice(iLigneNonVide+1);
  7584. break;
  7585. }
  7586. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  7587. }
  7588. //window.console.log(JSON.stringify(oData));
  7589.  
  7590. FF_XMLHttpRequest({
  7591. method: 'POST',
  7592. url: URL_pageDispatcherV2,
  7593. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7594. headers : {
  7595. /* inutile, à supprimer
  7596. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7597. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7598. */
  7599. 'Content-type':'application/x-www-form-urlencoded',
  7600. },
  7601. onload: function(responseDetails) {
  7602. buttonCDM.value=responseDetails.responseText;
  7603. buttonCDM.disabled = true;
  7604. }
  7605. });
  7606. }
  7607.  
  7608. function traiteCdMmsg() {
  7609. // Teste si ce message du bot est un message de CdM
  7610. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7611. document, null, 9, null).singleNodeValue;
  7612. if (!td) return false;
  7613. cdm = td.innerHTML;
  7614. // Insertion de l'estimation des PV restants
  7615. var des = cdm.indexOf('Dés');
  7616. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7617. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7618. if(pv)
  7619. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7620.  
  7621. // Insertion bouton envoi + espace
  7622. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7623. }
  7624.  
  7625. /*function traitePouvoir() {
  7626. // Teste si ce message du bot est un message de CdM
  7627. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7628. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7629. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7630. if (!td)
  7631. return false;
  7632. var infos = td.innerHTML;
  7633. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7634. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7635. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7636. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7637. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7638. var effetPouvoir="";
  7639. var full=false;
  7640. if(infos.indexOf("REDUIT")!=-1) {
  7641. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7642. }
  7643. else {
  7644. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7645. full=true;
  7646. }
  7647. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7648. // On insère le bouton et un espace
  7649. //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));
  7650. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7651. if(!MY_getValue('AUTOSENDPOUV'))
  7652. {
  7653. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7654. button.setAttribute("onClick", "window.open('" + url
  7655. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7656. + "this.value='Merci de votre participation'; this.disabled = true;");
  7657. }
  7658. else
  7659. {
  7660. FF_XMLHttpRequest({
  7661. method: 'GET',
  7662. url: url,
  7663. headers : {
  7664. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7665. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7666. }});
  7667. }
  7668. }*/
  7669.  
  7670. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7671. traiteCdMmsg();
  7672. }
  7673. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7674.  
  7675. /*******************************************************************************
  7676. * This file is part of Mountyzilla. *
  7677. * *
  7678. * Mountyzilla is free software; you can redistribute it and/or modify *
  7679. * it under the terms of the GNU General Public License as published by *
  7680. * the Free Software Foundation; either version 2 of the License, or *
  7681. * (at your option) any later version. *
  7682. * *
  7683. * Mountyzilla is distributed in the hope that it will be useful, *
  7684. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7685. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7686. * GNU General Public License for more details. *
  7687. * *
  7688. * You should have received a copy of the GNU General Public License *
  7689. * along with Mountyzilla; if not, write to the Free Software *
  7690. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7691. *******************************************************************************/
  7692.  
  7693. // x~x menu
  7694. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7695.  
  7696. var menuRac, mainIco;
  7697.  
  7698. // met à jour les carac sauvegardées (position, DLA, etc.)
  7699. function updateData() {
  7700. var inputs = document.getElementsByTagName('input');
  7701. var divs = document.getElementsByTagName('div');
  7702.  
  7703. //window.console.log('inputs=' + JSON.stringify(inputs));
  7704. if (inputs && inputs.length > 0) {
  7705. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  7706. numTroll = inputs[0].value;
  7707. MY_setValue('NUM_TROLL', numTroll);
  7708. MY_setValue('NIV_TROLL',inputs[1].value);
  7709. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7710. MY_setValue(numTroll+'.caracs.rm',0);
  7711. // assure l'init des 4 var de libs
  7712. }
  7713. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7714. } else {
  7715. // onclick="EnterPJView(91305,750,550)"
  7716. var tabA = document.getElementsByTagName('a');
  7717. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  7718. var s = tabA[0].onclick.toString();;
  7719. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  7720. var m = s.match(/\((\d+) *,/);
  7721. //window.console.log('m=' + JSON.stringify(m));
  7722. numTroll = parseInt(m[1]);
  7723. MY_setValue('NUM_TROLL', numTroll);
  7724. }
  7725. }
  7726.  
  7727. var DLA = new Date(
  7728. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  7729. );
  7730. if(MY_getValue(numTroll+'.DLA.encours')) {
  7731. var DLAstockee = new Date(
  7732. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  7733. );
  7734. if(DLA>DLAstockee) {
  7735. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  7736. // Pose un pb en cas de décalage de DLA
  7737. }
  7738. }
  7739. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  7740.  
  7741. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  7742. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  7743. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  7744. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  7745. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  7746. }
  7747.  
  7748. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7749. function initRaccourcis() {
  7750. var anotherURL = MY_getValue('URL1');
  7751. if(!anotherURL) { return; }
  7752. /* Création de l'icône faisant apparaître le menu */
  7753. mainIco = document.createElement('img');
  7754. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  7755. if(!urlIco) {
  7756. urlIco =
  7757. URL_MZimg + 'mz_logo_small.png';
  7758. }
  7759. mainIco.src = urlIco;
  7760. mainIco.alt = 'MZ';
  7761. mainIco.style = 'position:fixed; top:0px; left:0px';
  7762. mainIco.onmouseover = afficheMenu;
  7763. document.body.appendChild(mainIco);
  7764. /* Création du menu des Raccourcis */
  7765. menuRac = document.createElement('div');
  7766. menuRac.className = 'mh_textbox';
  7767. menuRac.style =
  7768. 'position:fixed; top:10px; left:10px;'+
  7769. 'max-width:190px;'+
  7770. 'border-radius: 4px; padding: 4px;'+
  7771. 'z-index: 500;'+
  7772. 'visibility: hidden;';
  7773. document.body.appendChild(menuRac);
  7774. document.addEventListener('mousemove',cacheMenu,false);
  7775. var i=1;
  7776. while(anotherURL) {
  7777. var a = document.createElement('a');
  7778. var url = MY_getValue('URL'+i);
  7779. var nom = MY_getValue('URL'+i+'.nom');
  7780. var ico = MY_getValue('URL'+i+'.ico');
  7781. a.href = url;
  7782. a.target = '_blank';
  7783. if(ico) {
  7784. var txt = nom ? nom : '';
  7785. var img = createImage(ico,txt);
  7786. a.appendChild(img);
  7787. }
  7788. else {
  7789. appendText(a,'['+nom+']');
  7790. }
  7791. menuRac.appendChild(a);
  7792. appendBr(menuRac);
  7793. i++;
  7794. anotherURL = MY_getValue('URL'+i);
  7795. }
  7796. }
  7797.  
  7798. function afficheMenu() {
  7799. menuRac.style.visibility = 'visible';
  7800. }
  7801.  
  7802. function cacheMenu(e) {
  7803. if(menuRac.style.visibility=='hidden') { return; }
  7804. // Position souris
  7805. var ptX = e.clientX;
  7806. var ptY = e.clientY;
  7807. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7808. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7809. var menuRect = menuRac.getBoundingClientRect();
  7810. var icoRect = mainIco.getBoundingClientRect();
  7811. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7812. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7813. menuRac.style.visibility = 'hidden';
  7814. }
  7815. }
  7816.  
  7817. // ajout de l'icône, branchée sur un refresh
  7818. function initUpdateCoordGauche() {
  7819. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7820. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7821. var img = document.createElement('img');
  7822. img.src = URL_MZimg + 'recycl.png'
  7823. img.onclick = function(evt) {
  7824. document.location.href = document.location.href;
  7825. };
  7826. img.title = 'Mise à jour de la localisation';
  7827. img.style.cursor = 'pointer';
  7828. img.style.position = 'absolute';
  7829. img.style.bottom = 0;
  7830. img.style.left = 0;
  7831. div.appendChild(img);
  7832. }
  7833.  
  7834. function do_menu() {
  7835. // met à jour les carac sauvegardées (position, DLA, etc.)
  7836. updateData();
  7837. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7838. initRaccourcis();
  7839. // Ajout bouton de mise à jour coordonnées
  7840. initUpdateCoordGauche();
  7841. }
  7842.  
  7843. /*******************************************************************************
  7844. * This file is part of Mountyzilla. *
  7845. * *
  7846. * Mountyzilla is free software; you can redistribute it and/or modify *
  7847. * it under the terms of the GNU General Public License as published by *
  7848. * the Free Software Foundation; either version 2 of the License, or *
  7849. * (at your option) any later version. *
  7850. * *
  7851. * Mountyzilla is distributed in the hope that it will be useful, *
  7852. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7853. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7854. * GNU General Public License for more details. *
  7855. * *
  7856. * You should have received a copy of the GNU General Public License *
  7857. * along with Mountyzilla; if not, write to the Free Software *
  7858. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7859. *******************************************************************************/
  7860.  
  7861. // x~x vue
  7862.  
  7863. /* TODO
  7864. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7865. * prévoir fix ("delete infos")
  7866. */
  7867.  
  7868. /*--------------------------- Variables Globales -----------------------------*/
  7869.  
  7870. // Infos remplies par des scripts extérieurs
  7871. var listeCDM = [], listeLevels = [];
  7872.  
  7873. // Position actuelle
  7874. var currentPosition=[0,0,0];
  7875.  
  7876. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7877. var porteeVue=[0,0,0,0];
  7878.  
  7879. // Fenêtres déplaçables
  7880. var winCurr = null;
  7881. var offsetX, offsetY;
  7882.  
  7883. // Diplomatie
  7884. var Diplo = {
  7885. Guilde: {},
  7886. Troll: {},
  7887. Monstre: {}
  7888. // .mythiques: uniquement si option activée
  7889. };
  7890. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7891.  
  7892. // Infos tactiques
  7893. var popup;
  7894.  
  7895. // Gère l'affichage en cascade des popups de CdM
  7896. var nbCDM = 0;
  7897.  
  7898. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7899.  
  7900. // Utilisé pour supprimer les monstres "engagés"
  7901. var listeEngages = {};
  7902. var isEngagesComputed = false;
  7903. var cursorOnLink = false; // DEBUG: wtf ?
  7904.  
  7905. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7906. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7907.  
  7908. // Checkboxes de filtrage
  7909. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7910. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7911. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  7912. comboBoxNiveauMin, comboBoxNiveauMax;
  7913.  
  7914. /* Acquisition & Stockage des données de DB */
  7915. const typesAFetcher = {
  7916. 'monstres':1,
  7917. 'trolls':1,
  7918. 'tresors':1,
  7919. 'champignons':1,
  7920. 'lieux':1
  7921. }
  7922. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7923. tr_champignons = {}, tr_lieux = {};
  7924. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7925. nbChampignons = 0, nbLieux = 0;
  7926.  
  7927. function fetchData(type) {
  7928. try {
  7929. var node = document.getElementById('mh_vue_hidden_'+type);
  7930. // this = MZ.global = sandBox de travail de MZ
  7931. // On définit donc des variables MZ-globales
  7932. this['tr_'+type] = node.getElementsByTagName('tr');
  7933. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7934. } catch(e) {
  7935. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7936. }
  7937. }
  7938.  
  7939.  
  7940. /*---------------------------------- DEBUG -----------------------------------*/
  7941. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7942. var x_monstres = tr_monstres;
  7943. var x_trolls = tr_trolls;
  7944. var x_tresors = tr_tresors;
  7945. var x_champis = tr_champignons;
  7946. var x_lieux = tr_lieux;
  7947. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7948.  
  7949.  
  7950. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7951.  
  7952. function positionToString(arr) {
  7953. return arr.join(';');
  7954. }
  7955.  
  7956. function savePosition() {
  7957. // Stocke la position (à jour) de la vue pour les autres scripts
  7958. // DEBUG: Lesquels et pourquoi?
  7959. var pos = getPosition();
  7960. MY_setValue(numTroll+'.position.X',pos[0]);
  7961. MY_setValue(numTroll+'.position.Y',pos[1]);
  7962. MY_setValue(numTroll+'.position.N',pos[2]);
  7963. }
  7964.  
  7965.  
  7966. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7967. /* INFOS :
  7968. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7969. * sont identifiables via leur Name
  7970. * les tables-listings sont identifiables via l'ID du tr conteneur
  7971. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7972. */
  7973.  
  7974. /* [functions] Récup données Utilisateur */
  7975. function getPosition() {
  7976. // Pour rétrocompatibilité
  7977. return currentPosition;
  7978. }
  7979.  
  7980. function getPorteVue() {
  7981. // Pour rétrocompatibilité
  7982. return porteeVue;
  7983. }
  7984.  
  7985. function getVue() {
  7986. // Retourne [vueHpure, vueVpure]
  7987. var vues = getPorteVue();
  7988. return [ vues[0], vues[1] ];
  7989. }
  7990.  
  7991. // Roule 11/03/2016
  7992. /* [functions] Récup données monstres, trolls, etc. */
  7993. function getXxxDistance(xxx, i) {
  7994. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  7995. }
  7996. function getXxxPosition(xxx, i) {
  7997. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  7998. var l = tds.length;
  7999. return [
  8000. parseInt(tds[l-3].textContent),
  8001. parseInt(tds[l-2].textContent),
  8002. parseInt(tds[l-1].textContent)
  8003. ];
  8004. }
  8005.  
  8006.  
  8007. /* [functions] Récup données monstres */
  8008. function getMonstreDistance(i) {
  8009. return parseInt(tr_monstres[i].cells[0].textContent);
  8010. }
  8011.  
  8012. function getMonstreID(i) {
  8013. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8014. }
  8015.  
  8016. function getMonstreIDByTR(tr) {
  8017. return tr.cells[2].firstChild.nodeValue;
  8018. }
  8019.  
  8020. function getMonstreLevelNode(i) {
  8021. return tr_monstres[i].cells[3];
  8022. }
  8023.  
  8024. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8025. // function getMonstreLevel(i) {
  8026. // if(!isCDMsRetrieved) return -1;
  8027. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8028. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8029. // }
  8030.  
  8031. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8032. if(!isCDMsRetrieved) return false;
  8033. var donneesMonstre = listeCDM[getMonstreID(i)];
  8034. if (!donneesMonstre) return false;
  8035. var nivTxt = donneesMonstre[0];
  8036. // calcul min/max du monstre
  8037. var monstreMin, monstreMax, iPos;
  8038. if (nivTxt.substring(0, 2) == '<=') {
  8039. monstreMin = 0;
  8040. monstreMax = parseInt(nivTxt.substring(2, 99));
  8041. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8042. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8043. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8044. } else {
  8045. monstreMin = monstreMax = parseInt(nivTxt);
  8046. }
  8047. if (limitMin > 0 && monstreMax < limitMin) return true;
  8048. if (limitMax > 0 && monstreMin > limitMax) return true;
  8049. return false;
  8050. }
  8051.  
  8052. function getMonstreNomNode(i) {
  8053. try {
  8054. var td = document.evaluate(
  8055. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8056. tr_monstres[i], null, 9, null
  8057. ).singleNodeValue;
  8058. return td;
  8059. } catch(e) {
  8060. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8061. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8062. }
  8063. }
  8064.  
  8065. function getMonstreNom(i) {
  8066. return getMonstreNomByTR(tr_monstres[i]);
  8067. }
  8068.  
  8069. function getMonstreNomByTR(tr) {
  8070. try {
  8071. var nom = document.evaluate(
  8072. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8073. tr, null, 2, null
  8074. ).stringValue;
  8075. return nom;
  8076. } catch(e) {
  8077. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8078. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8079. }
  8080. }
  8081.  
  8082. function getMonstrePosition(i) {
  8083. var tds = tr_monstres[i].childNodes;
  8084. var l = tds.length;
  8085. return [
  8086. parseInt(tds[l-3].textContent),
  8087. parseInt(tds[l-2].textContent),
  8088. parseInt(tds[l-1].textContent)
  8089. ];
  8090. }
  8091.  
  8092. function appendMonstres(txt) {
  8093. for(var i=1; i<=nbMonstres ; i++)
  8094. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8095. return txt;
  8096. }
  8097.  
  8098. function getMonstres() {
  8099. var vue = getVue();
  8100. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8101. }
  8102.  
  8103. function bddMonstres(start,stop) {
  8104. if(!start) { var start = 1; }
  8105. if(!stop) { var stop = nbMonstres; }
  8106. stop = Math.min(nbMonstres,stop);
  8107. var txt='';
  8108. for(var i=start ; i<=stop ; i++) {
  8109. txt += getMonstreID(i)+';'+
  8110. getMonstreNom(i)+';'+
  8111. positionToString(getMonstrePosition(i))+'\n';
  8112. }
  8113. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8114. }
  8115.  
  8116. /* [functions] Récup données Trolls */
  8117. function getTrollDistance(i) {
  8118. return parseInt(tr_trolls[i].cells[0].textContent);
  8119. }
  8120.  
  8121. var MZ_cache_col_TrollID;
  8122. function getTrollID(i) {
  8123. // 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
  8124. if (MZ_cache_col_TrollID === undefined) {
  8125. if (tr_trolls[0].cells[1].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8126. MZ_cache_col_TrollID = 1;
  8127. } else if (tr_trolls[0].cells[2].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8128. MZ_cache_col_TrollID = 2;
  8129. } else {
  8130. 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);
  8131. MZ_cache_col_TrollID = 2;
  8132. }
  8133. }
  8134. // Roule 08/03/2017 protection
  8135. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8136. if (isNaN(iTroll)) return;
  8137. if (iTroll == 0) return;
  8138. return iTroll;
  8139. }
  8140.  
  8141. function getTrollNomNode(i) {
  8142. var isEnvoiOn =
  8143. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  8144. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  8145. }
  8146.  
  8147. function getTrollNivNode(i) {
  8148. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  8149. return tr_trolls[i].cells[4];
  8150. }
  8151.  
  8152. function getTrollGuilde(i) {
  8153. return trim(tr_trolls[i].cells[6].textContent);
  8154. }
  8155.  
  8156. function getTrollGuildeID(i) {
  8157. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  8158. var href;
  8159. try {
  8160. 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"
  8161. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  8162. } catch(e) { // debug pb remonté par Marsak
  8163. window.console.error(traceStack(e, 'getTrollGuildeID')
  8164. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  8165. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8166. return -1;
  8167. }
  8168. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8169. }
  8170. return -1;
  8171. }
  8172.  
  8173. function getTrollPosition(i) {
  8174. var tds = tr_trolls[i].childNodes;
  8175. var l = tds.length;
  8176. return [
  8177. parseInt(tds[l-3].textContent),
  8178. parseInt(tds[l-2].textContent),
  8179. parseInt(tds[l-1].textContent)
  8180. ];
  8181. }
  8182.  
  8183. function bddTrolls() {
  8184. var txt='#DEBUT TROLLS\n'+
  8185. numTroll+';'+positionToString(getPosition())+'\n';
  8186. for(var i=1 ; i<=nbTrolls ; i++) {
  8187. txt += getTrollID(i)+';'+
  8188. positionToString(getTrollPosition(i))+'\n';
  8189. }
  8190. return txt+'#FIN TROLLS';
  8191. }
  8192.  
  8193. /* [functions] Récup données Trésors */
  8194. function getTresorDistance(i) {
  8195. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8196. }
  8197.  
  8198. function getTresorID(i) {
  8199. return trim(tr_tresors[i].cells[2].textContent);
  8200. }
  8201.  
  8202. function getTresorNom(i) {
  8203. // Utilisation de textContent pour régler le "bug de Pollux"
  8204. return trim(tr_tresors[i].cells[3].textContent);
  8205. }
  8206.  
  8207. function getTresorPosition(i) {
  8208. var tds = tr_tresors[i].childNodes;
  8209. var l = tds.length;
  8210. return [
  8211. parseInt(tds[l-3].textContent),
  8212. parseInt(tds[l-2].textContent),
  8213. parseInt(tds[l-1].textContent),
  8214. ];
  8215. }
  8216.  
  8217. function bddTresors(dmin,start,stop) {
  8218. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8219. if(!dmin) { var dmin = 0; }
  8220. if(!start) { var start = 1; }
  8221. if(!stop) { var stop = nbTresors; }
  8222. stop = Math.min(nbTresors,stop);
  8223. var txt='';
  8224. for(var i=start ; i<=stop ; i++) {
  8225. if(getTresorDistance(i)>=dmin) {
  8226. txt += getTresorID(i)+';'+
  8227. getTresorNom(i)+';'+
  8228. positionToString(getTresorPosition(i))+'\n';
  8229. }
  8230. }
  8231. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8232. }
  8233.  
  8234. /* [functions] Récup données Champignons */
  8235. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8236. function getChampignonNom(i) {
  8237. return trim(tr_champignons[i].cells[2].textContent);
  8238. }
  8239.  
  8240. function getChampignonPosition(i) {
  8241. var tds = tr_champignons[i].childNodes;
  8242. var l = tds.length;
  8243. return [
  8244. parseInt(tds[l-3].textContent),
  8245. parseInt(tds[l-2].textContent),
  8246. parseInt(tds[l-1].textContent)
  8247. ];
  8248. }
  8249.  
  8250. function bddChampignons() {
  8251. var txt='';
  8252. for(var i=1 ; i<=nbChampignons ; i++) {
  8253. txt += ';'+ // Les champis n'ont pas de Référence
  8254. getChampignonNom(i)+';'+
  8255. positionToString(getChampignonPosition(i))+'\n';
  8256. }
  8257. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8258. }
  8259.  
  8260. /* [functions] Récup données Lieux */
  8261. function getLieuDistance(i) {
  8262. return parseInt(tr_lieux[i].cells[0].textContent);
  8263. }
  8264.  
  8265. function getLieuID(i) {
  8266. return parseInt(tr_lieux[i].cells[2].textContent);
  8267. }
  8268.  
  8269. function getLieuNom(i) {
  8270. // Conversion ASCII pour éviter les bugs des Vues externes
  8271. return trim(tr_lieux[i].cells[3].textContent);
  8272. }
  8273.  
  8274. function getLieuPosition(i) {
  8275. var tds = tr_lieux[i].childNodes;
  8276. var l = tds.length;
  8277. return [
  8278. parseInt(tds[l-3].textContent),
  8279. parseInt(tds[l-2].textContent),
  8280. parseInt(tds[l-1].textContent)
  8281. ];
  8282. }
  8283.  
  8284. function appendLieux(txt) {
  8285. for(var i = 1; i < nbLieux+1; i++) {
  8286. var tds = x_lieux[i].childNodes;
  8287. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8288. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8289. }
  8290. return txt;
  8291. }
  8292.  
  8293. function getLieux() {
  8294. var vue = getVue();
  8295. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8296. }
  8297.  
  8298. function bddLieux(start,stop) {
  8299. if(!start) { var start = 1; }
  8300. if(!stop) { var stop = nbLieux; }
  8301. stop = Math.min(nbLieux,stop);
  8302. var txt='';
  8303. for(var i=start ; i<=stop ; i++) {
  8304. txt += getLieuID(i)+';'+
  8305. epure(getLieuNom(i))+';'+
  8306. positionToString(getLieuPosition(i))+'\n';
  8307. }
  8308. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8309. }
  8310.  
  8311.  
  8312. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8313.  
  8314. function saveCheckBox(chkbo, pref) {
  8315. // Enregistre et retourne l'état d'une CheckBox
  8316. var etat = chkbo.checked;
  8317. MY_setValue(pref, etat ? 'true' : 'false' );
  8318. return etat;
  8319. }
  8320.  
  8321. function recallCheckBox(chkbox, pref) {
  8322. // Restitue l'état d'une CheckBox
  8323. chkbox.checked = (MY_getValue(pref)=='true');
  8324. }
  8325.  
  8326. function saveComboBox(cbb, pref) {
  8327. // Enregistre et retourne l'état d'une ComboBox
  8328. var etat = cbb.selectedIndex;
  8329. MY_setValue(pref, etat);
  8330. return etat;
  8331. }
  8332.  
  8333. function recallComboBox(cbb, pref) {
  8334. // Restitue l'état d'une ComboBox
  8335. var nb = MY_getValue(pref);
  8336. if(nb) cbb.value = nb;
  8337. return nb;
  8338. }
  8339.  
  8340. function synchroniseFiltres() {
  8341. // Récupération de toutes les options de la vue
  8342. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8343. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8344. if(numBool) {
  8345. debutFiltrage('Monstres');
  8346. }
  8347. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8348. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8349. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8350. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8351. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8352. recallCheckBox(checkBoxIntangibles,'NOINT');
  8353. recallCheckBox(checkBoxGG,'NOGG');
  8354. recallCheckBox(checkBoxCompos,'NOCOMP');
  8355. recallCheckBox(checkBoxBidouilles,'NOBID');
  8356. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8357. recallCheckBox(checkBoxTrou,'NOTROU');
  8358. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8359. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8360. if(MY_getValue('NOINFOEM')!='true')
  8361. recallCheckBox(checkBoxEM,'NOEM');
  8362. }
  8363.  
  8364.  
  8365. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  8366.  
  8367. function getVueScript() {
  8368. try {
  8369. var txt = bddTrolls()+
  8370. bddMonstres()+
  8371. bddChampignons()+
  8372. bddTresors()+
  8373. bddLieux()+
  8374. '#DEBUT ORIGINE\n'+
  8375. getPorteVue()[2]+';'+positionToString(getPosition())+
  8376. '\n#FIN ORIGINE\n';
  8377. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  8378. return txt;
  8379. } catch(e) {
  8380. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  8381. window.console.error(traceStack(e, 'getVueScript'))
  8382. }
  8383. }
  8384.  
  8385. /* [functions] Menu Vue 2D */
  8386. var vue2Ddata = {
  8387. 'Bricol\' Vue': {
  8388. url: URL_bricol_mountyhall + 'vue_form.php',
  8389. paramid: 'vue',
  8390. func: getVueScript,
  8391. extra_params: {
  8392. 'mode': 'vue_SP_Vue2',
  8393. 'screen_width': window.screen.width
  8394. }
  8395. },
  8396. 'Vue du CCM': {
  8397. url: URL_vue_CCM,
  8398. paramid: 'vue',
  8399. func: getVueScript,
  8400. extra_params: {
  8401. 'id': numTroll+';'+positionToString(getPosition())
  8402. }
  8403. },
  8404. 'Vue Gloumfs 2D': {
  8405. url: URL_vue_Gloumfs2D,
  8406. paramid: 'vue_mountyzilla',
  8407. func: getVueScript,
  8408. extra_params: {}
  8409. },
  8410. 'Vue Gloumfs 3D': {
  8411. url: URL_vue_Gloumfs3D,
  8412. paramid: 'vue_mountyzilla',
  8413. func: getVueScript,
  8414. extra_params: {}
  8415. },
  8416. 'Grouky Vue!': {
  8417. url: URL_vue_Grouky,
  8418. paramid: 'vue',
  8419. func: getVueScript,
  8420. extra_params: {
  8421. 'type_vue': 'V5b1'
  8422. }
  8423. },
  8424. /*'DEBUG': {
  8425. url: 'http://weblocal/testeur.php',
  8426. paramid: 'vue',
  8427. func: getVueScript,
  8428. extra_params: {}
  8429. }*/
  8430. };
  8431.  
  8432. function refresh2DViewButton() {
  8433. // = EventListener menu+bouton vue 2D
  8434. var vueext = document.getElementById('selectVue2D').value;
  8435. MY_setValue('VUEEXT',vueext);
  8436. var form = document.getElementById('viewForm');
  8437. form.innerHTML = '';
  8438. form.method = 'post';
  8439. form.action = vue2Ddata[vueext].url;
  8440. form.target = '_blank';
  8441. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8442. for(var key in vue2Ddata[vueext].extra_params) {
  8443. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8444. }
  8445. appendSubmit(form, 'Voir',
  8446. function() {
  8447. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8448. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8449. vue2Ddata[vueext].func();
  8450. }
  8451. );
  8452. }
  8453.  
  8454. function set2DViewSystem() {
  8455. // Initialise le système de vue 2D
  8456. // Recherche du point d'insertion
  8457. try {
  8458. var center = document.evaluate(
  8459. "//h2[@id='titre2']/following-sibling::center",
  8460. document, null, 9, null
  8461. ).singleNodeValue;
  8462. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8463. if (!center) center = document.evaluate(
  8464. "//h2[@id='titre2']/following-sibling::div",
  8465. document, null, 9, null
  8466. ).singleNodeValue;
  8467. } catch(e) {
  8468. avertissement("Erreur d'initialisation du système de vue 2D");
  8469. window.console.error(traceStack(e, 'set2DViewSystem'));
  8470. return;
  8471. }
  8472. // Récupération de la dernière vue utilisée
  8473. var vueext = MY_getValue('VUEEXT');
  8474. if(!vueext || !vue2Ddata[vueext]) {
  8475. // sinon, la vue Bricol'Trolls est employée par défaut
  8476. vueext = 'Bricol\' Vue';
  8477. }
  8478. try {
  8479. // Création du sélecteur de vue externe
  8480. selectVue2D = document.createElement('select');
  8481. selectVue2D.id = 'selectVue2D';
  8482. selectVue2D.className = 'SelectboxV2';
  8483. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  8484. for(var view in vue2Ddata) {
  8485. appendOption(selectVue2D, view, view);
  8486. }
  8487. selectVue2D.value = vueext;
  8488. selectVue2D.onchange = refresh2DViewButton;
  8489. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8490. var form = document.createElement('form');
  8491. form.id = 'viewForm';
  8492. // Insertion du système de vue
  8493. var table = document.createElement('table');
  8494. var tr = appendTr(table);
  8495. var td = appendTd(tr);
  8496. td.appendChild(selectVue2D);
  8497. td = appendTd(tr);
  8498. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8499. td.appendChild(form);
  8500. center.insertBefore(table,center.firstChild);
  8501. insertBr(center.childNodes[1]);
  8502. // Appelle le handler pour initialiser le bouton de submit
  8503. refresh2DViewButton();
  8504. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8505. } catch(e) {
  8506. avertissement("Erreur de traitement du système de vue 2D");
  8507. window.console.error(traceStack(e, 'set2DViewSystem'));
  8508. }
  8509. }
  8510.  
  8511. /* [functions] Tableau d'Infos */
  8512. function initialiseInfos() {
  8513. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8514. var
  8515. infoTab = document.getElementsByName('LimitViewForm')[0].
  8516. getElementsByTagName('table')[0],
  8517. tbody = infoTab.tBodies[0],
  8518. thead = infoTab.createTHead(),
  8519. tr = appendTr(thead,'mh_tdtitre'),
  8520. td = appendTdText(tr,'INFORMATIONS',true),
  8521. span = document.createElement('span');
  8522. // Récupération de la position du joueur
  8523. try {
  8524. var strPos = document.evaluate(
  8525. ".//li/b/text()[contains(.,'X = ')]",
  8526. infoTab, null, 9, null
  8527. ).singleNodeValue.nodeValue;
  8528. // ***INIT GLOBALE*** currentPosition
  8529. currentPosition = getNumbers(strPos);
  8530. debugMZ("retrievePosition(): "+currentPosition);
  8531. } catch(e) {
  8532. // Si on ne trouve pas le "X ="
  8533. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8534. }
  8535. // Récupération des portées (max et limitée) de la vue
  8536. try {
  8537. var
  8538. nodes = document.evaluate(
  8539. ".//li/b/text()[contains(.,'horizontalement') "+
  8540. "or contains(.,'verticalement')]",
  8541. infoTab, null, 7, null
  8542. ),
  8543. array = [];
  8544. for(var i=0 ; i<4 ; i++) {
  8545. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8546. }
  8547. // ***INIT GLOBALE*** porteeVue
  8548. porteeVue = array;
  8549. } catch(e) {
  8550. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8551. }
  8552.  
  8553. infoTab.id = 'infoTab'; // Pour scripts externes
  8554. tbody.id = 'corpsInfoTab';
  8555. tbody.rows[0].cells[0].colSpan = 2;
  8556. td.colSpan = 3;
  8557. td.onmouseover = function() {
  8558. this.style.cursor = 'pointer';
  8559. this.className = 'mh_tdpage';
  8560. };
  8561. td.onmouseout = function() {
  8562. this.className = 'mh_tdtitre';
  8563. };
  8564. td.onclick = function() {
  8565. toggleTableauInfos(false);
  8566. };
  8567. span.id = 'msgInfoTab';
  8568. span.style.display = 'none';
  8569. appendText(
  8570. span,
  8571. ' => Position : X = '+currentPosition[0]+
  8572. ', Y = '+currentPosition[1]+
  8573. ', N = '+currentPosition[2]+
  8574. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8575. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8576. true
  8577. );
  8578. td.appendChild(span);
  8579. tr = appendTr(tbody,'mh_tdpage');
  8580. td = appendTdText(tr,'EFFACER : ',true);
  8581. td.align = 'center';
  8582. td.className = 'mh_tdtitre';
  8583. td.width = 100;
  8584. td = appendTdCenter(tr,2);
  8585. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8586. checkBoxGG = appendCheckBoxSpan(
  8587. td,'delgg',filtreTresors," Les GG'"
  8588. ).firstChild;
  8589. checkBoxCompos = appendCheckBoxSpan(
  8590. td,'delcomp',filtreTresors,' Les Compos'
  8591. ).firstChild;
  8592. checkBoxBidouilles = appendCheckBoxSpan(
  8593. td,'delbid',filtreTresors,' Les Bidouilles'
  8594. ).firstChild;
  8595. checkBoxIntangibles = appendCheckBoxSpan(
  8596. td,'delint',filtreTrolls,' Les Intangibles'
  8597. ).firstChild;
  8598. checkBoxGowapsA = appendCheckBoxSpan(
  8599. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  8600. ).firstChild;
  8601. checkBoxGowapsS = appendCheckBoxSpan(
  8602. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  8603. ).firstChild;
  8604. checkBoxEngages = appendCheckBoxSpan(
  8605. td,'delengage',filtreMonstres,' Les Engagés'
  8606. ).firstChild;
  8607. checkBoxLevels = appendCheckBoxSpan(
  8608. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8609. ).firstChild;
  8610. checkBoxDiplo = appendCheckBoxSpan(
  8611. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8612. ).firstChild;
  8613. checkBoxTrou = appendCheckBoxSpan(
  8614. td,'deltrou',filtreLieux,' Les Trous'
  8615. ).firstChild;
  8616. checkBoxMythiques = appendCheckBoxSpan(
  8617. td,'delmyth',filtreMonstres,' Les Mythiques'
  8618. ).firstChild;
  8619. if(MY_getValue('NOINFOEM')!='true') {
  8620. checkBoxEM = appendCheckBoxSpan(
  8621. td,'delem',filtreMonstres,' Les Composants EM'
  8622. ).firstChild;
  8623. }
  8624. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8625. td,'deltres',filtreTresors,' Les Trésors non libres'
  8626. ).firstChild;
  8627. checkBoxTactique = appendCheckBoxSpan(
  8628. td,'deltactique',updateTactique,' Les Infos tactiques'
  8629. ).firstChild;
  8630. if(MY_getValue('INFOPLIE')) {
  8631. toggleTableauInfos(true);
  8632. }
  8633. }
  8634.  
  8635. function toggleTableauInfos(firstRun) {
  8636. var
  8637. msg = document.getElementById('msgInfoTab'),
  8638. corps = document.getElementById('corpsInfoTab'),
  8639. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8640. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8641. if(!firstRun) {
  8642. infoplie = !infoplie;
  8643. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8644. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8645. }
  8646. if(infoplie) {
  8647. msg.style.display = '';
  8648. corps.style.display = 'none';
  8649. } else {
  8650. msg.style.display = 'none';
  8651. corps.style.display = '';
  8652. }
  8653. }
  8654.  
  8655. /* [functions] Filtres */
  8656. function prepareFiltrage(ref,width) {
  8657. // = Initialise le filtre 'ref'
  8658. try {
  8659. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8660. } catch(e) {
  8661. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8662. return false;
  8663. }
  8664. if(width) { tdTitre.width = width; }
  8665. // Ajout du tr de Filtrage (masqué)
  8666. var tbody = tdTitre.parentNode.parentNode;
  8667. var tr = appendTr(tbody,'mh_tdpage');
  8668. tr.style.display = 'none';
  8669. tr.id = 'trFiltre'+ref;
  8670. var td = appendTd(tr);
  8671. td.colSpan = 5;
  8672. // Ajout du bouton de gestion de Filtrage
  8673. var tdBtn = insertTd(tdTitre.nextSibling);
  8674. tdBtn.id = 'tdInsert'+ref;
  8675. var btn = appendButton(tdBtn,'Filtrer');
  8676. btn.id = 'btnFiltre'+ref;
  8677. btn.onclick = function() {
  8678. debutFiltrage(ref)
  8679. };
  8680. return td;
  8681. }
  8682.  
  8683. function debutFiltrage(ref) {
  8684. // = Handler de début de filtrage (filtre 'ref')
  8685. document.getElementById('trFiltre'+ref).style.display = '';
  8686. var btn = document.getElementById('btnFiltre'+ref);
  8687. btn.value = 'Annuler Filtre';
  8688. btn.onclick = function() {
  8689. finFiltrage(ref);
  8690. };
  8691. }
  8692.  
  8693. function finFiltrage(ref) {
  8694. // = Handler de fin de filtrage (filtre 'ref')
  8695. /* On réassigne le bouton 'Filtrer' */
  8696. document.getElementById('trFiltre'+ref).style.display = 'none';
  8697. var btn = document.getElementById('btnFiltre'+ref);
  8698. btn.value = 'Filtrer';
  8699. btn.onclick = function() {
  8700. debutFiltrage(ref);
  8701. };
  8702. /* Réinitialisation filtres */
  8703. document.getElementById('str'+ref).value = '';
  8704. switch(ref) {
  8705. case 'Monstres':
  8706. document.getElementById('nivMinMonstres').value = 0;
  8707. document.getElementById('nivMaxMonstres').value = 0;
  8708. break;
  8709. case 'Trolls':
  8710. document.getElementById('strGuildes').value = '';
  8711. }
  8712. /* Nettoyage (=lance le filtre) */
  8713. // Ici this = MZ.global = sandBox de travail de MZ
  8714. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  8715. //this['filtre'+ref]();
  8716. switch (ref) {
  8717. case 'Monstres':
  8718. filtreMonstres();
  8719. break;
  8720. case 'Trolls':
  8721. filtreTrolls();
  8722. break;
  8723. case 'Tresors':
  8724. filtreTresors();
  8725. break;
  8726. case 'Lieux':
  8727. filtreLieux();
  8728. break;
  8729. default:
  8730. window.console.log('cas incongru dans finFiltrage : ' + ref);
  8731. break;
  8732. }
  8733. }
  8734.  
  8735. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  8736. var bouton = appendButton(td,nomBouton,onClick);
  8737. appendText(td,'\u00a0');
  8738. var textbox = appendTextbox(td,'text',id,15,30);
  8739. textbox.onkeypress = function(event) {
  8740. try {
  8741. if(event.keyCode==13) {
  8742. event.preventDefault();
  8743. bouton.click();
  8744. }
  8745. }
  8746. catch(e){
  8747. window.alert(e)
  8748. }
  8749. };
  8750. }
  8751.  
  8752. function ajoutFiltreMenu(tr,id,onChange) {
  8753. var select = document.createElement('select');
  8754. select.id = id;
  8755. select.onchange = onChange;
  8756. appendOption(select,0,'Aucun');
  8757. for(var i=1 ; i<=60 ; i++) {
  8758. appendOption(select,i,i);
  8759. }
  8760. tr.appendChild(select);
  8761. return select;
  8762. }
  8763.  
  8764. function ajoutDesFiltres() {
  8765. /* Monstres */
  8766. var td = prepareFiltrage('Monstres',120);
  8767. if(td) {
  8768. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  8769. appendText(td,'\u00a0\u00a0\u00a0');
  8770. appendText(td,'Niveau Min: ');
  8771. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  8772. appendText(td,'\u00a0');
  8773. appendText(td,'Niveau Max: ');
  8774. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  8775. }
  8776. /* Trõlls */
  8777. td = prepareFiltrage('Trolls',50);
  8778. if(td) {
  8779. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  8780. appendText(td,'\u00a0\u00a0\u00a0');
  8781. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  8782. }
  8783. /* Trésors */
  8784. td = prepareFiltrage('Tresors',55);
  8785. if(td) {
  8786. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  8787. }
  8788. /* Lieux */
  8789. td = prepareFiltrage('Lieux',40);
  8790. if(td) {
  8791. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  8792. }
  8793. }
  8794.  
  8795. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  8796.  
  8797. /* [functions] Affichage de la colonne des niveaux */
  8798. function insertLevelColumn() {
  8799. // Déclenché si bascule vers affichage des niveaux des mobs
  8800. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8801. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  8802. td.width = 25;
  8803. for(var i=1 ; i<=nbMonstres ; i++) {
  8804. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8805. td = insertTdText(getMonstreLevelNode(i), '-');
  8806. td.onclick = function() {
  8807. basculeCDM(
  8808. getMonstreNomByTR(this.parentNode),
  8809. getMonstreIDByTR(this.parentNode)
  8810. );
  8811. };
  8812. td.onmouseover = function() {
  8813. this.style.cursor = 'pointer';
  8814. this.className = 'mh_tdtitre';
  8815. };
  8816. td.onmouseout = function() {
  8817. if(this.parentNode.diploActive=='oui') {
  8818. this.className = '';
  8819. } else {
  8820. this.className = 'mh_tdpage';
  8821. }
  8822. };
  8823. td.style = 'font-weight:bold;text-align:center;';
  8824. if(isCDMsRetrieved) {
  8825. // Rappel des niveaux si mémorisés
  8826. td.innerHTML = listeLevels[i];
  8827. }
  8828. }
  8829. }
  8830.  
  8831. function toggleLevelColumn() {
  8832. // = Handler checkBox noLevel
  8833. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8834. insertLevelColumn();
  8835. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8836. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8837. for(var i=0 ; i<=nbMonstres ; i++) {
  8838. if(isCDMsRetrieved) {
  8839. // Mémorisation des niveaux pour rappel éventuel
  8840. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8841. }
  8842. // Suppression du td Niveau
  8843. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8844. }
  8845. }
  8846. }
  8847.  
  8848. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8849. function basculeCDM(nom,id) {
  8850. // = Bascule l'affichage des popups CdM
  8851. if(listeCDM[id]) {
  8852. if(!document.getElementById('popupCDM'+id)) {
  8853. afficherCDM(nom, id);
  8854. } else {
  8855. cacherPopupCDM('popupCDM'+id);
  8856. }
  8857. }
  8858. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8859. }
  8860.  
  8861. function cacherPopupCDM(titre) {
  8862. var popup = document.getElementById(titre);
  8863. popup.parentNode.removeChild(popup);
  8864. }
  8865.  
  8866. /* DEBUG: Section à mettre à jour */
  8867. var selectionFunction;
  8868.  
  8869. function startDrag(evt) {
  8870. winCurr = this.parentNode;
  8871. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8872. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8873. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8874. selectionFunction = document.body.style.MozUserSelect;
  8875. document.body.style.MozUserSelect = 'none';
  8876. winCurr.style.MozUserSelect = 'none';
  8877. return false;
  8878. }
  8879.  
  8880. function stopDrag(evt) {
  8881. winCurr.style.MozUserSelect = selectionFunction;
  8882. document.body.style.MozUserSelect = selectionFunction;
  8883. winCurr = null;
  8884. }
  8885.  
  8886. function drag(evt) {
  8887. if(winCurr==null) { return; }
  8888. evt = evt || window.event;
  8889. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8890. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8891. return false;
  8892. }
  8893. /* FIN DEBUG */
  8894. document.onmousemove = drag;
  8895.  
  8896. function afficherCDM(nom,id) {
  8897. // Crée la table de CdM du mob n° id
  8898. var donneesMonstre = listeCDM[id];
  8899. /* Début création table */
  8900. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8901. table.id = 'popupCDM'+id;
  8902. table.style =
  8903. 'position:fixed;'+
  8904. 'z-index:1;'+
  8905. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8906. 'left:'+(window.innerWidth-365)+'px;'+
  8907. 'width:300px;'+
  8908. 'height:200px;';
  8909. /* Ajout du titre avec gestion Drag & Drop */
  8910. var tr = table.firstChild;
  8911. tr.style.cursor = 'move';
  8912. tr.onmousedown = startDrag;
  8913. tr.onmouseup = stopDrag;
  8914. /* Ajout du bouton "Fermer" */
  8915. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8916. tr.onmouseover = function() {
  8917. this.style.cursor = 'pointer';
  8918. this.className = 'mh_tdpage';
  8919. };
  8920. tr.onmouseout = function() {
  8921. this.className = 'mh_tdtitre';
  8922. };
  8923. tr.idcdm = id;
  8924. tr.onclick = function() {
  8925. cacherPopupCDM('popupCDM'+this.idcdm);
  8926. this.className = 'mh_tdtitre';
  8927. };
  8928. td = appendTdText(tr,'Fermer',true);
  8929. td.colSpan = 2;
  8930. td.style = 'text-align:center;';
  8931. nbCDM++;
  8932. /* Fin création table & Affichage */
  8933. document.body.appendChild(table);
  8934. }
  8935.  
  8936. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8937. function initPopupVue() {
  8938. popup = document.createElement('div');
  8939. popup.id = 'popup';
  8940. popup.className = 'mh_textbox';
  8941. popup.style =
  8942. 'position: absolute;'+
  8943. 'border: 1px solid #000000;'+
  8944. 'visibility: hidden;'+
  8945. 'display: inline;'+
  8946. 'z-index: 3;'+
  8947. 'max-width: 400px;';
  8948. document.body.appendChild(popup);
  8949. }
  8950.  
  8951. /* [functions] Récupération / Computation des Infos Tactiques */
  8952. // TODO à revoir
  8953. function retireMarquage(nom) {
  8954. var i = nom.indexOf(']');
  8955. switch(i) {
  8956. case -1:
  8957. case nom.length-1:
  8958. return nom;
  8959. default:
  8960. return nom.slice(0,i+1);
  8961. }
  8962. }
  8963.  
  8964. function showPopupError(sHTML) {
  8965. window.console.log('[MZ] affichage PopupError ' + sHTML);
  8966. var divpopup = document.createElement('div');
  8967. divpopup.id = 'divpopup';
  8968. divpopup.style =
  8969. 'position: fixed;'+
  8970. 'border: 3px solid #000000;'+
  8971. 'top: 300px;left: 10px;'+
  8972. 'background-color: red;'+
  8973. 'color: white;'+
  8974. 'font-size: xx-large;'+
  8975. 'z-index: 200;';
  8976. divpopup.innerHTML = sHTML;
  8977. var divcroix = document.createElement('div');
  8978. divcroix.style =
  8979. 'position: absolute;'+
  8980. 'top: 0;right: 0;'+
  8981. 'color: inherit;'+
  8982. 'font-size: inherit;'+
  8983. 'cursor: pointer;'+
  8984. 'z-index: 201;';
  8985. divcroix.innerHTML = "X";
  8986. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  8987. document.body.appendChild(divpopup);
  8988. divpopup.appendChild(divcroix);
  8989. }
  8990.  
  8991. function retrieveCDMs() {
  8992. // Récupère les CdM disponibles dans la BDD
  8993. // Lancé uniquement sur toggleLevelColumn
  8994. if(checkBoxLevels.checked) { return; }
  8995. var str = '';
  8996. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  8997. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  8998. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  8999. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9000. for(var i=1 ; i<=cdmMax ; i++) {
  9001. var nomMonstre = retireMarquage(getMonstreNom(i));
  9002. if(nomMonstre.indexOf(']') != -1) {
  9003. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9004. }
  9005. // *** WARNING : PROXY RATIBUS ***
  9006. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9007. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9008. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9009. )+'&';
  9010. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9011. FF_XMLHttpRequest({
  9012. method: 'POST',
  9013. url: URL_MZinfoMonstre,
  9014. headers : {
  9015. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9016. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9017. 'Content-type':'application/x-www-form-urlencoded'
  9018. },
  9019. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9020. onload: function(responseDetails) {
  9021. try {
  9022. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9023. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9024. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9025. '" target="raistlin">Mountyzilla - https<br />'+
  9026. 'Tu dois accepter le certificat de Raistlin<br />'+
  9027. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9028. ' « Confirmer l\'exception de sécurité »</a>');
  9029. return;
  9030. }
  9031. var texte = responseDetails.responseText;
  9032. var lines = texte.split('\n');
  9033. if(lines.length==0) { return; }
  9034. var begin2, end2, index;
  9035. for(var j=0 ; j<lines.length ; j++) {
  9036. var infos = lines[j].split(';');
  9037. if(infos.length<4) { continue; }
  9038. var idMonstre=infos[0];
  9039. var isCDM = infos[1];
  9040. index = parseInt(infos[2]);
  9041. var level = infos[3];
  9042. infos = infos.slice(3);
  9043. if(begin2==null) { begin2 = index; }
  9044. end2 = index;
  9045. listeCDM[idMonstre] = infos;
  9046. if(isCDM==1) {
  9047. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9048. } else {
  9049. getMonstreLevelNode(index).innerHTML = level;
  9050. }
  9051. }
  9052. computeMission(begin2,end2);
  9053. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9054. } catch(e) {
  9055. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9056. }
  9057. }
  9058. });
  9059. str = '';
  9060. begin = i+1;
  9061. }
  9062. }
  9063. isCDMsRetrieved=true;
  9064. }
  9065.  
  9066. function computeMission(begin,end) {
  9067. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9068. computeVLC(begin,end);
  9069. if(!begin) begin=1;
  9070. if(!end) end=nbMonstres;
  9071. var str = MY_getValue(numTroll+'.MISSIONS');
  9072. if(!str) { return; }
  9073. var urlImg = URL_MZimg+'mission.png';
  9074. var obMissions = JSON.parse(str);
  9075. for(var i=end ; i>=begin ; i--) {
  9076. var mess = '';
  9077. for(var num in obMissions) {
  9078. var mobMission = false;
  9079. switch(obMissions[num].type) {
  9080. case 'Race':
  9081. var race = epure(obMissions[num].race.toLowerCase());
  9082. var nom = epure(getMonstreNom(i).toLowerCase());
  9083. if(nom.indexOf(race)!=-1) {
  9084. mobMission = true;
  9085. }
  9086. break;
  9087. case 'Niveau':
  9088. var donneesMonstre = listeCDM[getMonstreID(i)];
  9089. if(donneesMonstre) {
  9090. var nivMob = Number(donneesMonstre[0]);
  9091. var nivMimi = Number(obMissions[num].niveau),
  9092. mod = obMissions[num].mod;
  9093. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9094. || (isNaN(mod) && nivMob>=nivMimi)) {
  9095. mobMission = true;
  9096. }
  9097. }
  9098. break;
  9099. case 'Famille':
  9100. var donneesMonstre = listeCDM[getMonstreID(i)];
  9101. if(donneesMonstre) {
  9102. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  9103. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9104. if(familleMob.indexOf(familleMimi)!=-1) {
  9105. mobMission = true;
  9106. }
  9107. }
  9108. break;
  9109. case 'Pouvoir':
  9110. var donneesMonstre = listeCDM[getMonstreID(i)];
  9111. if(donneesMonstre) {
  9112. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9113. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9114. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9115. mobMission = true;
  9116. }
  9117. }
  9118. }
  9119. if(mobMission) {
  9120. mess += mess ? '\n\n' : '';
  9121. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9122. }
  9123. }
  9124. if(mess) {
  9125. var td = getMonstreNomNode(i);
  9126. appendText(td,' ');
  9127. td.appendChild(createImage(urlImg,mess));
  9128. }
  9129. }
  9130. }
  9131.  
  9132. function computeVLC(begin,end) {
  9133. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9134. computeTactique(begin,end);
  9135. if(!begin) begin=1;
  9136. if(!end) end=nbMonstres;
  9137. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9138. if(!cache)
  9139. return false;
  9140. var urlImg = URL_MZimg + "oeil.png";
  9141. for(var i = end; i >= begin;i--)
  9142. {
  9143. var id = getMonstreID(i);
  9144. var donneesMonstre = listeCDM[id];
  9145. if(donneesMonstre && donneesMonstre.length>12)
  9146. {
  9147. if(donneesMonstre[12]==1)
  9148. {
  9149. var td = getMonstreNomNode(i);
  9150. td.appendChild(document.createTextNode(" "));
  9151. td.appendChild(createImage(urlImg, "Voit le caché"));
  9152. }
  9153. }
  9154. }
  9155. }
  9156.  
  9157. function computeTactique(begin, end) {
  9158. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9159. try {
  9160. if(!begin) begin = 1;
  9161. if(!end) end = nbMonstres;
  9162. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9163. if(noTactique || !isProfilActif()) return;
  9164. for(var j=end ; j>=begin ; j--) {
  9165. var id = getMonstreID(j);
  9166. var nom = getMonstreNom(j);
  9167. var donneesMonstre = listeCDM[id];
  9168. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9169. var td = getMonstreNomNode(j);
  9170. appendText(td,' ');
  9171. td.appendChild(
  9172. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9173. );
  9174. }
  9175. }
  9176. }
  9177. catch(e) {
  9178. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  9179. }
  9180. filtreMonstres();
  9181. }
  9182.  
  9183. function updateTactique() {
  9184. // = Handler checkBox noTactique
  9185. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9186. if(!isCDMsRetrieved) return;
  9187. if(noTactique) {
  9188. for(var i=nbMonstres ; i>0 ; i--) {
  9189. var tr = getMonstreNomNode(i);
  9190. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9191. tr, null, 9, null).singleNodeValue;
  9192. if(img) {
  9193. img.parentNode.removeChild(img.previousSibling);
  9194. img.parentNode.removeChild(img);
  9195. }
  9196. }
  9197. }
  9198. else
  9199. computeTactique();
  9200. }
  9201.  
  9202. function filtreMonstres() {
  9203. // = Handler universel pour les fonctions liées aux monstres
  9204. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9205. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9206. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9207. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9208. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9209. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9210. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9211. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9212. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9213. // old/new : détermine s'il faut ou non nettoyer les tr
  9214. var oldNOEM = true, noEM = true;
  9215. if(MY_getValue('NOINFOEM')!='true') {
  9216. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9217. }
  9218. // Filtrage par nom
  9219. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9220. // Génère la liste des mobs engagés (si filtrés)
  9221. if(noEngages && !isEngagesComputed) {
  9222. for(var i=nbTrolls ; i>0 ; i--) {
  9223. var pos = getTrollPosition(i);
  9224. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9225. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9226. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9227. }
  9228. isEngagesComputed = true;
  9229. }
  9230. /*** FILTRAGE ***/
  9231. /* À computer :
  9232. * - EM (nom suffit)
  9233. * - Enchant (nom suffit)
  9234. * - Mission (nécessite CdM)
  9235. * - mob VlC (nécessite CdM)
  9236. * Sans computation :
  9237. * - Gowap ? engagé ?
  9238. */
  9239. for(var i=nbMonstres ; i>0 ; i--) {
  9240. var pos = getMonstrePosition(i);
  9241. var nom = getMonstreNom(i).toLowerCase();
  9242. if(noEM!=oldNOEM) {
  9243. if(noEM) {
  9244. // Si noEM passe de false à true, on nettoie les td "Nom"
  9245. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9246. var tr = getMonstreNomNode(i);
  9247. while(tr.childNodes.length>1) {
  9248. tr.removeChild(tr.childNodes[1]);
  9249. }
  9250. } else {
  9251. var tr = getMonstreNomNode(i);
  9252. var TypeMonstre=getEM(nom);
  9253. if(TypeMonstre!='') {
  9254. var infosCompo=compoMobEM(TypeMonstre);
  9255. if(infosCompo.length>0) {
  9256. tr.appendChild(document.createTextNode(' '));
  9257. tr.appendChild(createImage(urlImg, infosCompo));
  9258. }
  9259. }
  9260. }
  9261. }
  9262. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  9263. var texte = getInfoEnchantementFromMonstre(nom);
  9264. if(texte!='') {
  9265. var td = getMonstreNomNode(i);
  9266. td.appendChild(document.createTextNode(' '));
  9267. td.appendChild(createImage(urlEnchantImg, texte));
  9268. }
  9269. }
  9270. tr_monstres[i].style.display = (
  9271. noGowapsS &&
  9272. nom.indexOf('gowap sauvage')!=-1 &&
  9273. getMonstreDistance(i)>1
  9274. ) || (
  9275. noGowapsA &&
  9276. nom.indexOf('gowap apprivoisé')!=-1 &&
  9277. getMonstreDistance(i)>1
  9278. ) || (
  9279. noEngages &&
  9280. getMonstreDistance(i)!=0 &&
  9281. listeEngages[pos[0]] &&
  9282. listeEngages[pos[0]][pos[1]] &&
  9283. listeEngages[pos[0]][pos[1]][pos[2]]
  9284. ) || (
  9285. strMonstre!='' &&
  9286. nom.indexOf(strMonstre)==-1
  9287. ) || (
  9288. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  9289. getMonstreDistance(i)>1 &&
  9290. nom.toLowerCase().indexOf("kilamo")==-1
  9291. ) ? 'none' : '';
  9292. }
  9293. if(MY_getValue('NOINFOEM')!='true') {
  9294. if(noEM != oldNOEM) {
  9295. if(noEM && isCDMsRetrieved) computeMission();
  9296. }
  9297. oldNOEM = noEM;
  9298. }
  9299. needComputeEnchantement = false;
  9300. }
  9301.  
  9302.  
  9303. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  9304.  
  9305. function filtreTrolls() {
  9306. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  9307. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  9308. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  9309. for(var i=1 ; i<=nbTrolls ; i++) {
  9310. tr_trolls[i].style.display = (
  9311. noIntangibles &&
  9312. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  9313. ) || (
  9314. strTroll!='' &&
  9315. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  9316. ) || (
  9317. strGuilde!='' &&
  9318. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  9319. ) ? 'none' : '';
  9320. }
  9321. }
  9322.  
  9323. /* [functions] Bulle PX Trolls */
  9324. var bulle;
  9325.  
  9326. function initPXTroll() {
  9327. bulle = document.createElement('div');
  9328. bulle.id = 'bulle';
  9329. bulle.className = 'mh_textbox';
  9330. bulle.style =
  9331. 'position: absolute;'+
  9332. 'border: 1px solid #000000;'+
  9333. 'visibility: hidden;'+
  9334. 'display: inline;'+
  9335. 'z-index: 2;';
  9336. document.body.appendChild(bulle);
  9337.  
  9338. for(var i=nbTrolls ; i>0 ; i--) {
  9339. var td_niv = getTrollNivNode(i);
  9340. td_niv.onmouseover = showPXTroll;
  9341. td_niv.onmouseout = hidePXTroll;
  9342. }
  9343. }
  9344.  
  9345. function showPXTroll(evt) {
  9346. var lvl = this.firstChild.nodeValue;
  9347. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  9348. bulle.style.left = evt.pageX+15+'px';
  9349. bulle.style.top = evt.pageY+'px';
  9350. bulle.style.visibility = 'visible';
  9351. }
  9352.  
  9353. function hidePXTroll() {
  9354. bulle.style.visibility = 'hidden';
  9355. }
  9356.  
  9357. /* [functions] Envoi PX / MP */
  9358. function putBoutonPXMP() {
  9359. // Bouton d'initialisation du mode Envoi
  9360. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  9361. var td = document.getElementById('tdInsertTrolls');
  9362. if(!td) { return; }
  9363. td.width = 100;
  9364. td = insertTd(td.nextSibling);
  9365. td.style.verticalAlign = 'top';
  9366. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  9367. bouton.id = 'btnEnvoi';
  9368. }
  9369.  
  9370. function prepareEnvoi() {
  9371. // = 1er Handler du bouton d'envoi
  9372. /* Ajout de la colonne des CheckBoxes */
  9373. var td = insertTdText(getTrollNomNode(0),'');
  9374. td.width = 5;
  9375. for(var i=nbTrolls ; i>0 ; i--) {
  9376. td = insertTd(getTrollNomNode(i));
  9377. appendCheckBox(td,'envoi'+i);
  9378. }
  9379. /* Ajout du radio de choix PX ou MP */
  9380. var btnEnvoi = document.getElementById('btnEnvoi');
  9381. if(!btnEnvoi) { return; }
  9382. var tdEnvoi = btnEnvoi.parentNode;
  9383. appendText(tdEnvoi,' ');
  9384. var span = document.createElement('span');
  9385. span.style.whiteSpace = 'nowrap';
  9386. var radioElt = document.createElement('input');
  9387. radioElt.type = 'radio';
  9388. radioElt.name = 'envoiPXMP';
  9389. radioElt.id = 'radioPX';
  9390. span.appendChild(radioElt);
  9391. appendText(span,' des PX ');
  9392. radioElt = document.createElement('input');
  9393. radioElt.type = 'radio';
  9394. radioElt.name = 'envoiPXMP';
  9395. radioElt.checked = true;
  9396. span.appendChild(radioElt);
  9397. appendText(span,' un MP');
  9398. tdEnvoi.appendChild(span);
  9399. /* Insertion du bouton Annuler */
  9400. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  9401. /* Modification de l'effet du bouton Envoi */
  9402. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  9403. }
  9404.  
  9405. function annuleEnvoi() {
  9406. // = Handler bouton Annuler
  9407. /* Nettoyage du td du bouton Envoi */
  9408. var btnEnvoi = document.getElementById('btnEnvoi');
  9409. var tdEnvoi = btnEnvoi.parentNode;
  9410. while(tdEnvoi.firstChild) {
  9411. tdEnvoi.removeChild(tdEnvoi.firstChild);
  9412. }
  9413. /* Retour à l'effet de base du bouton Envoi */
  9414. btnEnvoi.onclick = prepareEnvoi;
  9415. tdEnvoi.appendChild(btnEnvoi);
  9416. /* Suppression CheckBoxes */
  9417. for(var i=nbTrolls ; i>=0 ; i--) {
  9418. var td = getTrollNomNode(i);
  9419. td.parentNode.removeChild(td);
  9420. }
  9421. }
  9422.  
  9423. function effectueEnvoi() {
  9424. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9425. var str='';
  9426. var errID = false;
  9427. for(var i=nbTrolls ; i>0 ; i--) {
  9428. var chb = document.getElementById('envoi'+i);
  9429. if(chb.checked) {
  9430. var idTroll = getTrollID(i);
  9431. if (idTroll == undefined) {
  9432. errID = true;
  9433. } else {
  9434. str += (str ? ',' : '') + idTroll;
  9435. }
  9436. }
  9437. }
  9438. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  9439. var PXchecked = document.getElementById('radioPX').checked;
  9440. if(PXchecked) {
  9441. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9442. } else {
  9443. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9444. }
  9445. }
  9446.  
  9447. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9448.  
  9449. function filtreTresors() {
  9450. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9451. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9452. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9453. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9454. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9455. if(noEngages && !isEngagesComputed) {
  9456. for(var i=nbTrolls ; i>0 ; i--) {
  9457. var pos = getTrollPosition(i);
  9458. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9459. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9460. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9461. }
  9462. isEngagesComputed = true;
  9463. }
  9464. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9465. for(var i=nbTresors ; i>0 ; i--) {
  9466. var nom = getTresorNom(i);
  9467. var pos = getTresorPosition(i);
  9468. tr_tresors[i].style.display = (
  9469. noGG &&
  9470. nom.indexOf('Gigots de Gob')!=-1
  9471. ) || (
  9472. noCompos &&
  9473. nom.indexOf('Composant')!=-1
  9474. ) || (
  9475. noEngages &&
  9476. listeEngages[pos[2]] &&
  9477. listeEngages[pos[2]][pos[1]] &&
  9478. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9479. getTresorDistance(i)>0
  9480. ) || (
  9481. strTresor!='' &&
  9482. nom.toLowerCase().indexOf(strTresor)==-1
  9483. ) || (
  9484. noBidouilles &&
  9485. nom.indexOf('Bidouille')!=-1
  9486. ) ? 'none' : '';
  9487. }
  9488. }
  9489.  
  9490.  
  9491. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9492.  
  9493. function filtreLieux() {
  9494. // += Handler checkbox trous
  9495. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9496. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9497. for(var i=nbLieux ; i>0 ; i--) {
  9498. tr_lieux[i].style.display = (
  9499. strLieu &&
  9500. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9501. ) || (
  9502. noTrou &&
  9503. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9504. getLieuDistance(i)>1
  9505. ) ? 'none' : '';
  9506. }
  9507. }
  9508.  
  9509.  
  9510. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9511.  
  9512. function refreshDiplo() {
  9513. MY_setValue(numTroll+'.diplo.off',
  9514. checkBoxDiplo.checked?'true':'false'
  9515. );
  9516. if(isDiploRaw) { computeDiplo(); }
  9517. appliqueDiplo();
  9518. }
  9519.  
  9520. function computeDiplo() {
  9521. // On extrait les données de couleur et on les stocke par id
  9522. // Ordre de préséance :
  9523. // source Guilde < source Perso
  9524. // guilde cible < troll cible
  9525. /* Diplo de Guilde */
  9526. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9527. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9528. if(diploGuilde && diploGuilde.isOn=='true') {
  9529. // Guilde perso
  9530. if(diploGuilde.guilde) {
  9531. Diplo.Guilde[diploGuilde.guilde.id] = {
  9532. couleur: diploGuilde.guilde.couleur,
  9533. titre: 'Ma Guilde'
  9534. };
  9535. }
  9536. // Guildes/Trolls A/E
  9537. for(var AE in {Amis:0,Ennemis:0}) {
  9538. for(var i=0 ; i<5 ; i++) {
  9539. if(diploGuilde[AE+i]) {
  9540. for(var type in {Guilde:0,Troll:0}) {
  9541. var liste = diploGuilde[AE+i][type].split(';');
  9542. for(var j=liste.length-2 ; j>=0 ; j--) {
  9543. Diplo[type][liste[j]] = {
  9544. couleur: diploGuilde[AE+i].couleur,
  9545. titre: diploGuilde[AE+i].titre
  9546. };
  9547. }
  9548. }
  9549. }
  9550. }
  9551. }
  9552. }
  9553. /* Diplo Perso */
  9554. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9555. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9556. if(diploPerso && diploPerso.isOn=='true') {
  9557. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9558. for(var id in diploPerso[type]) {
  9559. Diplo[type][id] = diploPerso[type][id];
  9560. }
  9561. }
  9562. }
  9563. if(diploPerso.mythiques) {
  9564. Diplo.mythiques = diploPerso.mythiques;
  9565. }
  9566. isDiploRaw = false;
  9567. }
  9568.  
  9569. function appliqueDiplo() {
  9570. var aAppliquer = Diplo;
  9571. if(checkBoxDiplo.checked) {
  9572. // Pour retour à l'affichage basique sur désactivation de la diplo
  9573. aAppliquer = {
  9574. Guilde: {},
  9575. Troll: {},
  9576. Monstre: {}
  9577. };
  9578. }
  9579. /* On applique "aAppliquer" */
  9580. // Diplo Trõlls
  9581. for(var i=nbTrolls ; i>0 ; i--) {
  9582. var idG = getTrollGuildeID(i);
  9583. var idT = getTrollID(i);
  9584. var tr = tr_trolls[i];
  9585. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9586. if(aAppliquer.Troll[idT]) {
  9587. tr.className = '';
  9588. var descr = aAppliquer.Troll[idT].titre;
  9589. if(descr) {
  9590. getTrollNomNode(i).title = descr
  9591. }
  9592. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9593. } else if(aAppliquer.Guilde[idG]) {
  9594. tr.className = '';
  9595. var descr = aAppliquer.Guilde[idG].titre;
  9596. if(descr) {
  9597. getTrollNomNode(i).title = descr
  9598. }
  9599. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9600. } else {
  9601. tr.className = 'mh_tdpage';
  9602. getTrollNomNode(i).title = '';
  9603. }
  9604. }
  9605. // Diplo Monstres
  9606. for(var i=nbMonstres ; i>0 ; i--) {
  9607. var id = getMonstreID(i);
  9608. var nom = getMonstreNom(i).toLowerCase();
  9609. if(aAppliquer.Monstre[id]) {
  9610. tr_monstres[i].className = '';
  9611. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  9612. tr_monstres[i].diploActive = 'oui';
  9613. var descr = aAppliquer.Monstre[id].titre;
  9614. if(descr) {
  9615. getMonstreNomNode(i).title = descr;
  9616. }
  9617. } else if(aAppliquer.mythiques &&
  9618. (nom.indexOf('liche')==0 ||
  9619. nom.indexOf('hydre')==0 ||
  9620. nom.indexOf('balrog')==0 ||
  9621. nom.indexOf('beholder')==0)) {
  9622. tr_monstres[i].className = '';
  9623. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  9624. tr_monstres[i].diploActive = 'oui';
  9625. getMonstreNomNode(i).title = 'Monstre Mythique';
  9626. } else {
  9627. tr_monstres[i].className = 'mh_tdpage';
  9628. tr_monstres[i].diploActive = '';
  9629. }
  9630. }
  9631. }
  9632.  
  9633.  
  9634. /*-[functions]---------------- Actions à distance ----------------------------*/
  9635.  
  9636. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  9637. var monN = parseInt(getPosition()[2]);
  9638. for(var type in keltypes) {
  9639. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  9640. for(var i=this['nb'+type] ; i>0 ; i--) {
  9641. var tr = this['tr_'+type.toLowerCase()][i];
  9642. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  9643. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  9644. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  9645. var sonN = getXxxPosition(type, i)[2];
  9646. var d = getXxxDistance(type, i);
  9647. if(sonN==monN && d>=dmin && d<=dmax) {
  9648. var iconeAction = document.evaluate(
  9649. "./descendant::img[@alt='"+alt+"']",
  9650. tr, null, 9, null
  9651. ).singleNodeValue;
  9652. if(iconeAction) {
  9653. if(iconeAction.title) {
  9654. iconeAction.title += "\n"+message;
  9655. } else {
  9656. iconeAction.title = message;
  9657. }
  9658. iconeAction.src = urlIcon;
  9659. } else {
  9660. var tdAction = tr.getElementsByTagName('td')[1];
  9661. var icon = document.createElement('img');
  9662. icon.src = urlIcon;
  9663. icon.height = 20;
  9664. icon.alt = alt;
  9665. icon.title = message;
  9666. tdAction.appendChild(icon);
  9667. }
  9668. }
  9669. }
  9670. }
  9671. }
  9672.  
  9673. function computeCharge() {
  9674. computeActionDistante(1,
  9675. getPortee__Vue(
  9676. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  9677. MY_getValue(numTroll+".caracs.regeneration")
  9678. ),
  9679. {'Monstres':1, 'Trolls':1},
  9680. 'Attaquer',
  9681. MHicons+'E_Metal09.png',
  9682. 'Cible à portée de Charge'
  9683. );
  9684. }
  9685.  
  9686. function computeProjo() {
  9687. computeActionDistante(0,
  9688. getPortee__Vue(
  9689. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9690. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9691. ),
  9692. {'Monstres':1, 'Trolls':1},
  9693. 'Attaquer',
  9694. MHicons+'S_Fire05.png',
  9695. 'Cible à portée de Projo'
  9696. );
  9697. }
  9698.  
  9699. function computeTelek() {
  9700. computeActionDistante(0,
  9701. Math.floor((
  9702. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9703. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9704. )/2),
  9705. {'Tresors':1},
  9706. 'Telek',
  9707. MHicons+'S_Magic04.png',
  9708. 'Trésor à portée de Télékinésie'
  9709. );
  9710. }
  9711.  
  9712. function computeLdP() {
  9713. computeActionDistante(0,
  9714. 2+Math.floor((
  9715. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9716. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9717. )/5),
  9718. {'Monstres':1, 'Trolls':1},
  9719. 'self',
  9720. MHicons+'P_Red01.png',
  9721. 'Cible à portée de Lancer de Potions'
  9722. );
  9723. }
  9724.  
  9725.  
  9726. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  9727.  
  9728. function putScriptExterne() {
  9729. var infoit = MY_getValue(numTroll+'.INFOSIT');
  9730. if(!infoit || infoit=='') return;
  9731.  
  9732. var nomit = infoit.slice(0,infoit.indexOf('$'));
  9733. if(nomit=='bricol') {
  9734. var data = infoit.split('$');
  9735. try {
  9736. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  9737. // appendNewScript(URL_bricol+data[1]
  9738. // +'/mz.php?login='+data[2]
  9739. // +'&password='+data[3]
  9740. // );
  9741. FF_XMLHttpRequest({
  9742. method: 'GET',
  9743. url: URL_bricol+data[1]
  9744. +'/mz_json.php?login='+data[2]
  9745. +'&password='+data[3],
  9746. onload: function(responseDetails) {
  9747. try {
  9748. if (responseDetails.status == 0) {
  9749. window.console.log('status=0 à l\'appel bricol\'troll');
  9750. if (isHTTPS) {
  9751. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  9752. } else {
  9753. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  9754. }
  9755. return;
  9756. }
  9757. var ratibusData;
  9758. try {
  9759. ratibusData = JSON.parse(responseDetails.responseText);
  9760. } catch(e) {}
  9761. if (ratibusData === undefined) {
  9762. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  9763. return;
  9764. }
  9765. if (ratibusData.error) {
  9766. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  9767. } else {
  9768. putInfosTrolls(ratibusData.data.trolls);
  9769. }
  9770. } catch(e) {
  9771. window.console.log(traceStack(e, 'retour bricol\'troll'));
  9772. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  9773. }
  9774. }
  9775. });
  9776. } catch(e) {
  9777. if (isHTTPS) {
  9778. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  9779. } else {
  9780. window.console.log(traceStack(e, 'appel bricol\'troll'));
  9781. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  9782. }
  9783. }
  9784. }
  9785. }
  9786.  
  9787. /* Le script mz.php de Ratibus renvoie :
  9788. + infosTrolls = new Array();
  9789. + infosTrolls[numdutroll] =
  9790. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  9791. + etc ...
  9792. + putInfosTrolls();
  9793. *
  9794. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  9795. * Roule 07/11/2016, on utilise mz_json qui envoie
  9796. {
  9797. "data": {
  9798. "trolls": {
  9799. "59424": {
  9800. "id": 59424,
  9801. "pv": xx,
  9802. "pv_max": xx,
  9803. "updated_at": "2016-10-31 07:28:40",
  9804. "dla": "2016-10-05 07:28:04",
  9805. "pa": 0
  9806. },
  9807. }
  9808. }
  9809. }
  9810. */
  9811.  
  9812. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  9813. function corrigeBricolTrolls(infosTrolls) {
  9814. for(var i in infosTrolls) {
  9815. var pv = infosTrolls[i][0];
  9816. var pvmax = infosTrolls[i][1];
  9817. var pvmem = MY_getValue(i+'.caracs.pv.max');
  9818. if(pvmem && pvmem>pvmax) {
  9819. infosTrolls[i][1] = pvmem;
  9820. pvmax = pvmem;
  9821. }
  9822. if(pv>pvmax) {
  9823. var newpvmax = 5*Math.ceil(pv/5);
  9824. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9825. infosTrolls[i][1] = newpvmax;
  9826. }
  9827. }
  9828. }
  9829.  
  9830. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9831. function addTdInfosTroll(infos, nextTD) {
  9832. /* cadre barre PV */
  9833. var tab = document.createElement('div');
  9834. /* ancienne méthode par img, à supprimer
  9835. tab.width = 100;
  9836. tab.style.width = 100;
  9837. tab.height = 10;
  9838. tab.style.background = '#FFFFFF';
  9839. tab.style.border = 1;
  9840. */
  9841. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9842. /* barre PV */
  9843. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9844. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9845. .vieContainer {
  9846. background-color: #CCC;
  9847. width: 50px;
  9848. height: 6px;
  9849. border: 1px solid #000;
  9850. text-align: left;
  9851. }
  9852. */
  9853. tab.style.width = '100px';
  9854. tab.style.height = '10px';
  9855. tab.style.border = '1px solid #000';
  9856. tab.style.textAlign = 'left';
  9857. var div2 = document.createElement('div');
  9858. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9859. var dateLimite = new Date();
  9860. dateLimite.setDate(dateLimite.getDate() - 7);
  9861. if (infos.oUpdatedAt < dateLimite) {
  9862. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9863. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9864. } else if (pourcentVie > 66) {
  9865. div2.style.backgroundColor = '#77EE77';
  9866. } else if (pourcentVie > 33) {
  9867. div2.style.backgroundColor = '#EEEE77';
  9868. } else {
  9869. div2.style.backgroundColor = '#FF0000';
  9870. }
  9871. div2.style.width = pourcentVie + '%';
  9872. div2.style.height = '10px';
  9873. tab.appendChild(div2);
  9874. /* ancienne méthode par img, à supprimer
  9875. var img = document.createElement('img');
  9876. img.src = '../Images/Interface/milieu.gif';
  9877. img.height = 10;
  9878. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9879. tab.appendChild(img);
  9880. */
  9881.  
  9882. /* lien vers l'IT */
  9883. var lien = document.createElement('a');
  9884. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9885. lien.href = URL_bricol+nomit+'/index.php';
  9886. lien.target = '_blank';
  9887. lien.appendChild(tab);
  9888. insertTdElement(nextTD,lien);
  9889. /* PAs dispos */
  9890. var span = document.createElement('span');
  9891. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9892. appendText(span, infos.pa +' PA' );
  9893. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9894. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9895. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9896. span.style.backgroundColor = 'B8EEB8';
  9897. }
  9898. insertTdElement(nextTD, span);
  9899. }
  9900.  
  9901. function putInfosTrolls(infosTrolls) {
  9902. try {
  9903. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9904. // supression des infos trop vieilles (un mois)
  9905. var IDs = Object.keys(infosTrolls);
  9906. var dateLimite = new Date();
  9907. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9908. for (var i = 0; i < IDs.length; i++) {
  9909. var idTroll = IDs[i];
  9910. var infos = infosTrolls[idTroll];
  9911. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9912. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9913. }
  9914. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9915. td.width = 40;
  9916. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9917. td.width = 105;
  9918.  
  9919. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9920. //corrigeBricolTrolls(infosTrolls);
  9921.  
  9922. for(i=nbTrolls ; i>0 ; i--) {
  9923. var infos = infosTrolls[getTrollID(i)];
  9924. if(infos && (!infos.bIgnore)) {
  9925. addTdInfosTroll(infos, tr_trolls[i].childNodes[6]);
  9926. infos.done = true;
  9927. } else {
  9928. insertTd(tr_trolls[i].childNodes[6]);
  9929. insertTd(tr_trolls[i].childNodes[6]);
  9930. }
  9931. }
  9932. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9933. var str = MY_getValue(numTroll+'.INFOSIT');
  9934. if(!str) return;
  9935. var arr = str.split('$');
  9936. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9937.  
  9938. //window.console.log('nb Troll IT : ' + IDs.length);
  9939. var tBody = tr_trolls[0].parentNode;
  9940. if (tr_trolls[1] === undefined)
  9941. tBody = tr_trolls[0].parentNode;
  9942. else
  9943. tBody = tr_trolls[1].parentNode;
  9944. var pos = getPosition();
  9945. for (i = 0; i < IDs.length; i++) {
  9946. var idTroll = IDs[i];
  9947. infos = infosTrolls[idTroll];
  9948. if (infos.done) continue; // déjà vu
  9949. if (infos.bIgnore) continue; // trop vieux
  9950. if (idTroll == numTroll) continue; // pas nous-même
  9951. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9952. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9953. // trouver où insérer ce Troll
  9954. var next = undefined;
  9955. for(var j=0 ; j<tr_trolls.length ; j++) {
  9956. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9957. if (thisDist > distance) {
  9958. next = tr_trolls[j]
  9959. break;
  9960. }
  9961. }
  9962. var tr;
  9963. if (next !== undefined) {
  9964. tr = insertTr(next,'mh_tdpage')
  9965. } else {
  9966. tr = appendTr(tBody,'mh_tdpage');
  9967. }
  9968. tr.style.color = 'orange';
  9969. var td = appendTd(tr); // distance
  9970. appendText(td, distance);
  9971. td = appendTd(tr); // actions
  9972. td = appendTd(tr); // ID
  9973. appendText(td, idTroll);
  9974. td = appendTd(tr); // Nom
  9975. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  9976. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  9977. if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  9978. if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  9979. td = appendTd(tr); // Niveau
  9980. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  9981. td.align = 'center';
  9982. td = appendTd(tr); // Race
  9983. if (infos.race) appendText(td, infos.race);
  9984. // PV et PA ajoutés par addTdInfosTroll
  9985. td = appendTd(tr); // Guilde
  9986. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  9987. td = appendTd(tr); // X
  9988. td.align = 'center';
  9989. if (infos.x !== undefined) appendText(td, infos.x);
  9990. td = appendTd(tr); // Y
  9991. td.align = 'center';
  9992. if (infos.y !== undefined) appendText(td, infos.y);
  9993. td = appendTd(tr); // N
  9994. td.align = 'center';
  9995. if (infos.n !== undefined) appendText(td, infos.n);
  9996. addTdInfosTroll(infos, tr.childNodes[6]);
  9997. }
  9998. } catch(e) {
  9999. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  10000. }
  10001. }
  10002.  
  10003.  
  10004. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10005.  
  10006. function calculeDistance(maPos,posArr) {
  10007. return Math.max(
  10008. Math.abs(maPos[0]-posArr[0]),
  10009. Math.abs(maPos[1]-posArr[1]),
  10010. Math.abs(maPos[2]-posArr[2])
  10011. );
  10012. }
  10013.  
  10014. function inversionCoord() {
  10015. var maPos = getPosition();
  10016. var listeOffsets = {
  10017. 'monstres':checkBoxLevels.checked?4:3,
  10018. 'trolls':6,
  10019. };
  10020. for(var type in listeOffsets) {
  10021. var trList = this['tr_'+type];
  10022. var offset = listeOffsets[type];
  10023. for(var i=trList.length-1 ; i>0 ; i--) {
  10024. var oldX = parseInt(trList[i].cells[offset].textContent);
  10025. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10026. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10027. trList[i].cells[offset].innerHTML = oldY;
  10028. trList[i].cells[offset+1].innerHTML = oldX;
  10029. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10030. }
  10031. }
  10032. }
  10033.  
  10034.  
  10035. /* Partie principale */
  10036. function do_vue() {
  10037. for(var type in typesAFetcher) {
  10038. fetchData(type);
  10039. }
  10040.  
  10041. // roule' 11/03/2016
  10042. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10043. // je fais une recopie :(
  10044. tr_monstres = this['tr_monstres'];
  10045. tr_trolls = this['tr_trolls'];
  10046. tr_tresors = this['tr_tresors'];
  10047. tr_champignons = this['tr_champignons'];
  10048. tr_lieux = this['tr_lieux'];
  10049.  
  10050. nbMonstres = this['nbMonstres'];
  10051. nbTrolls = this['nbTrolls'];
  10052. nbTresors = this['nbTresors'];
  10053. nbChampignons = this['nbChampignons'];
  10054. nbLieux = this['nbLieux'];
  10055.  
  10056. try {
  10057. start_script(31);
  10058. initialiseInfos();
  10059. savePosition();
  10060.  
  10061. // Fonctionnalité "Têtalenvert" cachée, en test :
  10062. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10063. inversionCoord();
  10064. }
  10065. ajoutDesFiltres();
  10066. set2DViewSystem();
  10067. //putBoutonTroogle();
  10068. putBoutonPXMP();
  10069. synchroniseFiltres();
  10070. toggleLevelColumn();
  10071.  
  10072. refreshDiplo();
  10073. //400 ms
  10074. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10075. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10076. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10077. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10078. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10079. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10080. var noTresorsEngages =
  10081. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10082. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10083. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10084. filtreMonstres();
  10085. if(noIntangibles) {
  10086. filtreTrolls();
  10087. }
  10088. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10089. filtreTresors();
  10090. }
  10091. if(noTrou) {
  10092. filtreLieux();
  10093. }
  10094.  
  10095. initPopupVue();
  10096. initPXTroll();
  10097.  
  10098. if(getTalent("Projectile Magique")!=0) {
  10099. computeProjo();
  10100. }
  10101. if(getTalent("Charger")!=0) {
  10102. computeCharge();
  10103. }
  10104. if(getTalent("Télékinésie")!=0) {
  10105. computeTelek();
  10106. }
  10107. if(getTalent("Lancer de Potions")!=0) {
  10108. computeLdP();
  10109. }
  10110. putScriptExterne();
  10111. displayScriptTime();
  10112. } catch(e) {
  10113. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10114. window.console.error(traceStack(e, 'vue'));
  10115. }
  10116. }
  10117.  
  10118.  
  10119.  
  10120. /*******************************************************************************
  10121. * This file is part of Mountyzilla. *
  10122. * *
  10123. * Mountyzilla is free software; you can redistribute it and/or modify *
  10124. * it under the terms of the GNU General Public License as published by *
  10125. * the Free Software Foundation; either version 2 of the License, or *
  10126. * (at your option) any later version. *
  10127. * *
  10128. * Mountyzilla is distributed in the hope that it will be useful, *
  10129. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10130. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10131. * GNU General Public License for more details. *
  10132. * *
  10133. * You should have received a copy of the GNU General Public License *
  10134. * along with Mountyzilla; if not, write to the Free Software *
  10135. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10136. *******************************************************************************/
  10137.  
  10138. // x~x profil2
  10139.  
  10140. /*---------------------------- Variables globales ----------------------------*/
  10141.  
  10142. var
  10143. // Anatrolliseur
  10144. urlAnatrolliseur,
  10145. // Infobulles talents
  10146. hauteur = 50, bulleStyle = null,
  10147. // Caracteristiques
  10148. // Infos troll
  10149. race, niv, idtroll, datecrea,
  10150. idguilde, nomguilde,
  10151. // Etats du troll
  10152. fatigue, bmfatigue,
  10153.  
  10154. // Experience, Pi, ...
  10155. pxdistribuables, pxperso,
  10156. piutilisable, pitotal,
  10157. nbmeurtres, nbmorts,
  10158. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10159. NBjours,
  10160. // calcul des DLA suivantes
  10161. DLA, DLAsuiv, HeureServeur,
  10162. // details duree du tour (calcul pvdispo) :
  10163. dtb, pdm, bmt, adb, dpt,
  10164. //posale
  10165. posX, posY, posN,
  10166. // caracs physiques
  10167. vue, vuebp, vuebm, vuetotale,
  10168. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10169. reg, regbp, regbm, regmoy,
  10170. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10171. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10172. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10173. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10174. rm, rmbp, rmbm, rmtotale,
  10175. mm, mmbp, mmbm, mmtotale,
  10176.  
  10177. // Variables speciales Kastars
  10178. pvActuelKastar, minParPV, overDLA,
  10179. // id pour edition manuelle de lastDLA :
  10180. inJour, inMois, inAn, inHr, inMin, inSec,
  10181. // id pour auto-refresh lastDLA :
  10182. lastDLAZone, maxAMZone, cumulZone,
  10183. lastDLA, DLAaccel;
  10184.  
  10185.  
  10186. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10187.  
  10188. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10189. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10190. function getUniqueValueBySelector(selector, defaultValue){
  10191. var valNode = document.querySelector(selector);
  10192. if(valNode!=null){
  10193. if(valNode.hasChildNodes()) {
  10194. return valNode.childNodes[0].nodeValue;
  10195. }else{
  10196. return defaultValue;
  10197. }
  10198. } else{
  10199. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10200. return defaultValue;
  10201. }
  10202. }
  10203. function getUniqueStringValueBySelector(selector){
  10204. return getUniqueValueBySelector(selector,"");
  10205. }
  10206. function getUniqueIntValueBySelector(selector){
  10207. var ret = getUniqueValueBySelector(selector,0);
  10208. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10209. ret = 0;
  10210. }
  10211. return parseInt(ret);
  10212. }
  10213. function getUniqueFloatValueBySelector(selector){
  10214. var ret = getUniqueValueBySelector(selector,0.0);
  10215. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10216. ret = 0.0;
  10217. }
  10218. return parseFloat(ret);
  10219. }
  10220.  
  10221.  
  10222. function resiste(Ddeg,bm) {
  10223. // version naive mais compréhensible ^^
  10224. // DEBUG: à revoir
  10225. if(!bm) {
  10226. return 2*Math.floor(Ddeg/2);
  10227. }
  10228. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10229. }
  10230.  
  10231. function retourAZero(fatig) {
  10232. var fat = fatig, raz = 0;
  10233. while(fat>0) {
  10234. raz++;
  10235. fat = Math.floor(fat/1.25);
  10236. }
  10237. return raz;
  10238. }
  10239.  
  10240. function decumulPumPrem(bonus) {
  10241. switch(bonus) {
  10242. case 20: return 33;
  10243. case 33: return 41;
  10244. case 41: return 46;
  10245. case 46: return 49;
  10246. case 49: return 51;
  10247. default: return 20;
  10248. }
  10249. }
  10250.  
  10251. function coefDecumul(i) {
  10252. switch(i) {
  10253. case 2: return 0.67;
  10254. case 3: return 0.4;
  10255. case 4: return 0.25;
  10256. case 5: return 0.15;
  10257. default: return 0.1;
  10258. }
  10259. }
  10260.  
  10261. function dureeHM(dmin) {
  10262. var ret = "";
  10263. dmin = Math.floor(dmin);
  10264. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  10265. var mins = dmin%60;
  10266. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  10267. return (ret) ? ret : "-";
  10268. }
  10269.  
  10270. // extraction d'une durée
  10271. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  10272. // c'est protégé (rend 0 si l'élément est absent)
  10273. // Roule' 24/12/2016
  10274. function extractionDuree(selecteur) {
  10275. var s = getUniqueStringValueBySelector(selecteur);
  10276. if (!s) return 0;
  10277. var tabN = getNumbers(s);
  10278. if (tabN.length < 2) return 0;
  10279. return tabN[0] * 60 + tabN[1];
  10280. }
  10281.  
  10282. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  10283.  
  10284. function extractionDonnees() {
  10285. // Variables temporaires
  10286. var Nbrs = {};
  10287.  
  10288. // *********************
  10289. // Cadre "Description"
  10290. // *********************
  10291. race = getUniqueStringValueBySelector('#descr #race');
  10292. debugMZ("Race : " + race);
  10293. idtroll = getUniqueStringValueBySelector('#descr #id');
  10294. debugMZ("Id troll : " + idtroll);
  10295. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  10296. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  10297. datecrea = new Date(StringToDate(strDateCrea));
  10298. debugMZ("Date creation : " + datecrea);
  10299. // Guilde
  10300. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  10301. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  10302. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  10303.  
  10304. // *******************
  10305. // Cadre "Experience"
  10306. // *******************
  10307. // Niveau de troll
  10308. niv = getUniqueIntValueBySelector('#exp #niv');
  10309. nivTroll = niv;
  10310. debugMZ("Niveau : " + niv);
  10311. // PX
  10312. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  10313. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  10314. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  10315. // PI
  10316. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  10317. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  10318. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  10319. // Meutres/Morts
  10320. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  10321. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  10322. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  10323.  
  10324. // *********************
  10325. // Cadre "Tour de Jeu"
  10326. // *********************
  10327. // DLA
  10328. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  10329. DLA = new Date(StringToDate(Nbrs["dla"]));
  10330. debugMZ("DLA: " + DLA);
  10331. // DLA suivante
  10332. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  10333. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  10334. debugMZ("DLAsuiv: " + DLAsuiv);
  10335. // Duree normale de mon Tour
  10336. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  10337. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  10338. dtb = extractionDuree("#dla #tour");
  10339. debugMZ("Duree normale de mon Tour : " + dtb);
  10340. // Bonus/Malus sur la duree
  10341. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  10342. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  10343. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  10344. debugMZ("Bonus/Malus sur la duree : " + bmt);
  10345. // Augmentation due aux blessures
  10346. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  10347. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  10348. adb = extractionDuree("#dla #blessure");
  10349. debugMZ("Augmentation due aux blessures : " + adb);
  10350. // Poids de l'equipement
  10351. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  10352. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  10353. pdm = extractionDuree("#dla #poids");
  10354. debugMZ("Poids de l'equipement : " + pdm);
  10355. // Duree de mon prochain Tour
  10356. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  10357. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  10358. dpt = extractionDuree("#dla #duree>b");
  10359. debugMZ('Duree de mon prochain Tour : ' + dpt);
  10360.  
  10361. // ****************
  10362. // Cadre "Etats"
  10363. // ****************
  10364. // Position du troll :
  10365. posX = getUniqueIntValueBySelector('#pos #x');
  10366. posY = getUniqueIntValueBySelector('#pos #y');
  10367. posN = getUniqueIntValueBySelector('#pos #n');
  10368. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  10369. // PV actuel
  10370. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  10371. pvActuelKastar = pvcourant;
  10372. debugMZ("PV actuel : " + pvcourant)
  10373. // Fatigue
  10374. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  10375. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  10376. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  10377.  
  10378. // **************************
  10379. // Cadre "Caracteristiques"
  10380. // **************************
  10381. // Attaque
  10382. att = getUniqueIntValueBySelector('#carac #att');
  10383. attbp = getUniqueIntValueBySelector('#carac #att_p');
  10384. attbm = getUniqueIntValueBySelector('#carac #att_m');
  10385. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  10386. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  10387. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  10388. attmoy = 3.5*att + attbp + attbm;
  10389. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10390. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  10391. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  10392. // Esquive
  10393. esq = getUniqueIntValueBySelector('#carac #esq');
  10394. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  10395. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  10396. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  10397. esqmoy = 3.5*esq + esqbp+esqbm;
  10398. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  10399. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  10400. // Degat
  10401. deg = getUniqueIntValueBySelector('#carac #deg');
  10402. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  10403. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  10404. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  10405. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  10406. degmoy = 2*deg + degbp+degbm;
  10407. degmoycrit = 3*deg + degbp+degbm;
  10408. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10409. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  10410. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  10411. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  10412. // PV
  10413. pvbase = getUniqueIntValueBySelector('#carac #pv');
  10414. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  10415. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  10416. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  10417. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  10418. // Regeneration
  10419. reg = getUniqueIntValueBySelector('#carac #reg');
  10420. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  10421. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  10422. regmoy = 2 * reg + regbp + regbm; // D3
  10423. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  10424. // Armure
  10425. arm = getUniqueIntValueBySelector('#carac #arm');
  10426. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  10427. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  10428. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  10429. armmoy = 2*arm + armbp+armbm;
  10430. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  10431. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  10432. // TODO : D d'armure non active
  10433. // Vue
  10434. vue = getUniqueIntValueBySelector('#carac #vue');
  10435. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10436. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10437. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10438. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10439. // RM
  10440. rm = getUniqueIntValueBySelector('#carac #rm');
  10441. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10442. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10443. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10444. rmTroll = rmtotale;
  10445. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10446. // MM
  10447. mm = getUniqueIntValueBySelector('#carac #mm');
  10448. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10449. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10450. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10451. mmTroll = mmtotale;
  10452. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10453.  
  10454. // Heure Serveur
  10455. try {
  10456. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10457. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10458. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10459. } catch (e) {
  10460. window.console.warn(
  10461. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10462. );
  10463. HeureServeur = new Date();
  10464. }
  10465. debugMZ("HeureServeur: " + HeureServeur);
  10466.  
  10467. // ***INIT GLOBALE*** NBjours
  10468. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10469.  
  10470. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10471. var amelio_dtb = function(dtb) {
  10472. if(dtb>555) {
  10473. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10474. }
  10475. return 10+Math.ceil((555-dtb)/2.5);
  10476. },
  10477. amelio_pv = Math.floor(pvbase/10)-3,
  10478. amelio_vue = vue-3,
  10479. amelio_att = att-3,
  10480. amelio_esq = esq-3,
  10481. amelio_deg = deg-3,
  10482. amelio_reg = reg-1,
  10483. amelio_arm = arm-1;
  10484. if(race==="Darkling"){amelio_reg--; }
  10485. if(race==="Durakuir"){amelio_pv-- ; }
  10486. if(race==="Kastar") {amelio_deg--; }
  10487. if(race==="Skrim") {amelio_att--; }
  10488. if(race==="Tomawak") {amelio_vue--; }
  10489.  
  10490. urlAnatrolliseur = URL_AnatrolDispas
  10491. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10492. +"|r="+race.toLowerCase()
  10493. +"|dla="+amelio_dtb(dtb)
  10494. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10495. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10496. +"|att="+amelio_att+","+attbp+","+attbm
  10497. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10498. +"|deg="+amelio_deg+","+degbp+","+degbm
  10499. +"|reg="+amelio_reg+","+regbp+","+regbm
  10500. +"|arm="+amelio_arm+","+armbp+","+armbm
  10501. +"|mm="+mmtotale
  10502. +"|rm="+rmtotale+"|";
  10503. }
  10504.  
  10505. function saveProfil() {
  10506. MY_setValue(idtroll+'.caracs.attaque',att);
  10507. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10508. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10509. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10510. if(atttourD||atttourP||atttourM) {
  10511. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10512. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10513. }
  10514. MY_setValue(idtroll+'.caracs.esquive',esq);
  10515. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10516. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10517. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10518. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10519. MY_setValue(idtroll+'.caracs.degats',deg);
  10520. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10521. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10522. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10523. if(degtourP||degtourM){
  10524. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10525. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10526. }
  10527. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10528. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10529. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10530. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10531. MY_setValue(idtroll+'.caracs.vue',vue);
  10532. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10533. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10534. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10535. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10536. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10537. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10538. MY_setValue(idtroll+'.caracs.rm',rm);
  10539. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10540. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10541. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10542. MY_setValue(idtroll+'.caracs.mm',mm);
  10543. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10544. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10545. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10546. MY_setValue(idtroll+'.caracs.armure',arm);
  10547. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10548. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10549. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10550. MY_setValue(idtroll+'.position.X',posX);
  10551. MY_setValue(idtroll+'.position.Y',posY);
  10552. MY_setValue(idtroll+'.position.N',posN);
  10553. MY_setValue(idtroll+'.race',race);
  10554. MY_setValue(idtroll+'.niveau',niv);
  10555. MY_setValue(idtroll+'.idguilde',idguilde);
  10556. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10557. }
  10558.  
  10559.  
  10560. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10561.  
  10562. function setInfosCaracteristiques() {
  10563. // Modification de l'entete
  10564. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10565. thTotal.innerHTML+='|<i>Moyenne</i>';
  10566. thTotal.title="Moyenne (Moyenne ce tour)";
  10567.  
  10568. // Ajout des informations calculees
  10569. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10570. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10571. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10572.  
  10573. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10574. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10575. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10576.  
  10577. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10578. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10579. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10580.  
  10581. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10582. var tdRegTotal = trRegeneration.children[5];
  10583. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10584. // Temps recupere par reg (propale R')
  10585. var regmoyTemp = Math.max(0, regmoy);
  10586. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10587. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10588. if (sec != 0) {
  10589. regTitle += " " + sec + " sec";
  10590. }
  10591. trRegeneration.title = regTitle;
  10592.  
  10593. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  10594. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  10595. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  10596.  
  10597. var trRM=document.querySelector("table#caracs #rm").parentElement;
  10598. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  10599. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  10600.  
  10601.  
  10602. var trMM=document.querySelector("table#caracs #mm").parentElement;
  10603. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  10604. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  10605.  
  10606. var tdRefl=document.querySelector("#refl");
  10607. // TODO : prendre en compte bonus/malus D esq du tour ?
  10608. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  10609. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  10610. }
  10611.  
  10612. function setLienAnatrolliseur(){
  10613. var pTableAmelio = document.querySelector("#carac>div>p");
  10614. pTableAmelio.innerHTML+=" - ";
  10615. var aElt = document.createElement("a");
  10616. aElt.setAttribute("href",urlAnatrolliseur);
  10617. aElt.setAttribute("target","_blank");
  10618. aElt.className="AllLinks";
  10619. aElt.innerHTML="Anatrolliser";
  10620. pTableAmelio.appendChild(aElt);
  10621. }
  10622. function setInfoDescription() {
  10623. var txtDateCrea = (NBjours!=1) ?
  10624. " ("+NBjours+" jours dans le hall)" :
  10625. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  10626. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  10627. }
  10628.  
  10629. function setInfosEtatLieux() {
  10630. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  10631. '?search=position&orderBy=distance&posx='+
  10632. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  10633. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  10634. appendBr(tdPosition);
  10635. var aElt = document.createElement("a");
  10636. aElt.setAttribute("href",urlBricol);
  10637. aElt.setAttribute("target","_blank");
  10638. aElt.className="AllLinks";
  10639. aElt.innerHTML="Lieux à proximité";
  10640. tdPosition.appendChild(aElt);
  10641. }
  10642.  
  10643. function setInfosEtatPV() { // pour AM et Sacro
  10644. var
  10645. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  10646. sec = Math.floor(15000/pvtotal)%60,
  10647. lifebar = document.querySelector("#pos .barre-vie");
  10648. if(sec!=0) { txt += " "+sec+" sec"; }
  10649. if(lifebar) { lifebar.title = txt; }
  10650. if(pvcourant<=0) { return; }
  10651. // Difference PV p/r a equilibre de temps (propale R')
  10652. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  10653. // ***INIT GLOBALE*** pvdispo
  10654. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10655. var span = document.createElement("span");
  10656. span.title = txt;
  10657. span.style.fontStyle = "italic";
  10658. if(bmt+pdm>=0) {
  10659. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  10660. } else if(pvdispo>0) {
  10661. txt = "Vous pouvez encore perdre "+
  10662. Math.min(pvdispo,pvcourant)+
  10663. " PV sans malus de temps.";
  10664. } else if(pvdispo<0) {
  10665. txt = "Il vous manque "
  10666. +(-pvdispo)
  10667. +" PV pour ne plus avoir de malus de temps.";
  10668. } else {
  10669. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  10670. }
  10671. appendText(span,txt);
  10672. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  10673. }
  10674.  
  10675. // Complete le cadre "Experience"
  10676. function setInfosExp() {
  10677. var tdNiv = document.querySelector("#exp #niv");
  10678.  
  10679. // Calcul niveau monstre/troll min pour gain PX
  10680. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  10681. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  10682.  
  10683. // Calcul PX restant
  10684. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  10685. if (pxRestant >= 0) {
  10686. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  10687. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  10688. }
  10689.  
  10690. // Calul pi/jour
  10691. var
  10692. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  10693. tdPi = document.querySelector("#exp #pi").parentElement;
  10694. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  10695. tdPi.title = tdPiTotal.title;
  10696.  
  10697. // Rapports meurtres,morts
  10698. var tdKill = document.querySelector("#exp #kill");
  10699. tdKill.setAttribute("colspan", 1);
  10700. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  10701.  
  10702. var tdMort = document.querySelector("#exp #mort");
  10703. tdMort.setAttribute("colspan", 1);
  10704. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  10705.  
  10706. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  10707. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  10708. }
  10709.  
  10710.  
  10711. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  10712.  
  10713. function minParPVsac(fat,bm) {
  10714. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  10715. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  10716. var out = [];
  10717. out[0] = (fat>4) ?
  10718. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  10719. 30;
  10720. if(bm && bm>0) {
  10721. var totalfat=fat+bm;
  10722. out[1] = (totalfat>4) ?
  10723. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  10724. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  10725. }
  10726. return out;
  10727. }
  10728.  
  10729. function toInt(str) {
  10730. str = parseInt(str);
  10731. return (str) ? str : 0;
  10732. }
  10733.  
  10734. function saveLastDLA() {
  10735. // pour les calculs d'AM max
  10736. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  10737. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  10738. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  10739. lastDLA = new Date( StringToDate(str) );
  10740. MY_setValue(numTroll+'.DLA.ancienne',str);
  10741. lastDLAZone.innerHTML = '';
  10742. var b = document.createElement('b');
  10743. b.addEventListener('click',inputMode,false);
  10744. appendText(b,str);
  10745. lastDLAZone.appendChild(b);
  10746. refreshAccel();
  10747. }
  10748.  
  10749. function inputMode() {
  10750. // Edition manuelle lastDLA
  10751. var date;
  10752. if(lastDLA)
  10753. date = new Date( lastDLA );
  10754. else
  10755. date = new Date( DLAaccel );
  10756. lastDLAZone.innerHTML = '';
  10757. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  10758. appendText(lastDLAZone,'/');
  10759. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  10760. appendText(lastDLAZone,'/');
  10761. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  10762. appendText(lastDLAZone,' - ');
  10763. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  10764. appendText(lastDLAZone,':');
  10765. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  10766. appendText(lastDLAZone,':');
  10767. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  10768. appendText(lastDLAZone,' - ');
  10769. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  10770. }
  10771.  
  10772. function setAccel() {
  10773. var
  10774. BMfrais=false,
  10775. fat=fatigue, listeBmFat=[],
  10776. tr, th, insertPt;
  10777.  
  10778. // Creation ligne speciale pour AM dans le cadre "Etat"
  10779. tr = document.createElement('tr');
  10780. th = document.createElement('th');
  10781. appendText(th,'Fatigue et AM',true);
  10782. tr.appendChild(th);
  10783. insertPt = document.createElement('td');
  10784. tr.appendChild(insertPt);
  10785. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  10786.  
  10787. // Est-on en over-DLA ?
  10788. // ***INIT GLOBALE*** overDLA
  10789. overDLA = (HeureServeur>DLA.getTime()+3e5);
  10790. if(overDLA) {
  10791. fat=Math.floor(fatigue/1.25);
  10792. }
  10793.  
  10794. // Gestion des BM de fatigue
  10795. if(bmfatigue>0) {
  10796. // On tente de recuperer les BM de fatigue de la page des BM
  10797. if(MY_getValue(numTroll+'.bm.fatigue')) {
  10798. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  10799. BMmemoire.pop();
  10800. var tour = 0;
  10801. for(var i=0 ; i<BMmemoire.length ; i++) {
  10802. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  10803. while(tour<=parseInt(nbrs[0])) {
  10804. listeBmFat[tour]=parseInt(nbrs[1]);
  10805. tour++;
  10806. }
  10807. }
  10808. }
  10809. if(listeBmFat[0]==bmfatigue) {
  10810. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  10811. BMfrais = true;
  10812. MY_removeValue(numTroll+".bm.fatigue");
  10813. }
  10814. } else {
  10815. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  10816. BMfrais = true;
  10817. }
  10818. if(!BMfrais && bmfatigue>0) {
  10819. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  10820. if(bmfatigue==15) {
  10821. listeBmFat = [15,15,15];
  10822. } else {
  10823. listeBmFat = [30,30,15];
  10824. }
  10825. }
  10826. if(overDLA) {
  10827. // Si on est en over-DLA, on decale les bm d'un tour
  10828. listeBmFat.shift();
  10829. }
  10830. // Tableau des fatigues et accel futures
  10831. var
  10832. minppv = minParPVsac(fat,listeBmFat[0]),
  10833. table, tbody,
  10834. ligneTour, ligneFat, ligneMin,
  10835. col;
  10836. // ***INIT GLOBALE*** minParPV
  10837. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10838. if(fat>0 || listeBmFat[0]>0) {
  10839. table = document.createElement('table');
  10840. table.className = 'mh_tdborder';
  10841. table.border = 0;
  10842. table.cellSpacing = 1;
  10843. table.cellPadding = 1;
  10844. table.style.textAlign = "center";
  10845. tbody = document.createElement('tbody');
  10846. table.appendChild(tbody);
  10847. insertPt.appendChild(table);
  10848. ligneTour = appendTr(tbody,'mh_tdtitre');
  10849. ligneTour.style.fontWeight = "bold";
  10850. var td = appendTdText(ligneTour,'Tour :',true);
  10851. td.align = 'left';
  10852. ligneFat = appendTr(tbody,'mh_tdpage');
  10853. td = appendTdText(ligneFat,'Fatigue :',true);
  10854. td.className = 'mh_tdtitre';
  10855. td.align = 'left';
  10856. ligneMin = appendTr(tbody,'mh_tdpage');
  10857. td = appendTdText(ligneMin,'1 PV =',true);
  10858. td.className = 'mh_tdtitre';
  10859. td.align = 'left';
  10860. col=0;
  10861. while(col<9 && (fat>0 || listeBmFat[col])) {
  10862. if(col==0) {
  10863. if(overDLA) {
  10864. var i = document.createElement('i');
  10865. appendText(i,'A activer');
  10866. ligneTour.appendChild(i);
  10867. } else {
  10868. appendTdText(ligneTour,'En cours');
  10869. }
  10870. } else {
  10871. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10872. }
  10873. if(listeBmFat[col]) {
  10874. if(BMfrais || (!overDLA && col==0)) {
  10875. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10876. appendTdText(ligneMin,minppv[1]+'\'');
  10877. } else {
  10878. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10879. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10880. }
  10881. } else {
  10882. appendTdText(ligneFat,fat);
  10883. appendTdText(ligneMin,minppv[0]+'\'');
  10884. }
  10885. col++;
  10886. fat = Math.floor(fat / 1.25);
  10887. minppv = minParPVsac(fat,listeBmFat[col]);
  10888. }
  10889. if(fat>1 || (fat==1 && !overDLA)) {
  10890. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10891. appendTdText(ligneFat,'-');
  10892. appendTdText(ligneMin,'-');
  10893. }
  10894. col = (overDLA) ?
  10895. Math.max(retourAZero(fatigue)-1,col) :
  10896. Math.max(retourAZero(fatigue),col);
  10897. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10898. appendTdText(ligneFat,'0');
  10899. appendTdText(ligneMin,'30\'');
  10900. if(!BMfrais && bmfatigue) {
  10901. // si les BM n'ont pas ete rafraichis, on signale:
  10902. appendText(
  10903. insertPt,
  10904. '/!\\ Visitez la page des Bonus/Malus '+
  10905. 'pour mettre à jour votre fatigue. /!\\',
  10906. true
  10907. );
  10908. appendBr(insertPt);
  10909. }
  10910. appendBr(insertPt);
  10911. }
  10912. if(pvcourant<=0) {
  10913. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10914. return;
  10915. }
  10916. if(fatigue>30) {
  10917. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10918. return;
  10919. }
  10920. // Setup lastDLAZone
  10921. if(overDLA) {
  10922. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10923. DLAaccel = new Date( DLAsuiv );
  10924. lastDLA = new Date( DLA );
  10925. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10926. // ***INIT GLOBALE*** pvActuelKastar
  10927. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10928. appendText(
  10929. insertPt,
  10930. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10931. true
  10932. );
  10933. appendBr(insertPt);
  10934. } else {
  10935. DLAaccel = new Date( DLA );
  10936. pvActuelKastar = pvcourant;
  10937. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10938. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10939. } else {
  10940. lastDLA = false;
  10941. }
  10942. }
  10943. appendText(insertPt,'Dernière DLA enregistrée : ');
  10944. lastDLAZone = document.createElement('span');
  10945. lastDLAZone.style.cursor = 'pointer';
  10946. var b = document.createElement('b');
  10947. b.onclick = inputMode;
  10948. lastDLAZone.appendChild(b);
  10949. insertPt.appendChild(lastDLAZone);
  10950. if(lastDLA) {
  10951. appendText(b,DateToString(lastDLA));
  10952. } else {
  10953. appendText(b,'aucune');
  10954. }
  10955. appendBr(insertPt);
  10956. // Setup maxAMZone et cumulZone
  10957. appendText(insertPt,'Accélération maximale possible : ');
  10958. maxAMZone = document.createElement('b');
  10959. insertPt.appendChild(maxAMZone);
  10960. appendBr(insertPt);
  10961. cumulZone = document.createElement('span');
  10962. insertPt.appendChild(cumulZone);
  10963. refreshAccel();
  10964. }
  10965.  
  10966. function refreshAccel() {
  10967. var pvs, pvsmax;
  10968. // Acceleration pour cumul instantane
  10969. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10970. if(lastDLA) {
  10971. pvsmax = Math.min(
  10972. pvActuelKastar-1,
  10973. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  10974. );
  10975. maxAMZone.innerHTML = pvsmax+" PV";
  10976. } else {
  10977. pvsmax = pvActuelKastar-1;
  10978. maxAMZone.innerHTML = "inconnue";
  10979. }
  10980. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  10981. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  10982. cumulZone.innerHTML = '';
  10983. if(pvs<=pvsmax) {
  10984. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  10985. appendText(cumulZone,pvs+' PV', true);
  10986. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  10987. if(pvs!=1) {
  10988. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  10989. -(pvs-1)*60*minParPV;
  10990. appendText(
  10991. cumulZone,
  10992. ' ('+(pvs-1)+' PV dans '+
  10993. Math.floor(gainSec/60)+'min'+
  10994. addZero(gainSec%60)+'s)'
  10995. );
  10996. }
  10997. } else {
  10998. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  10999. appendText(
  11000. cumulZone,
  11001. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11002. dureeHM(avantDLA/6e4)+
  11003. ' avant de réactiver.'
  11004. );
  11005. }
  11006. }
  11007.  
  11008.  
  11009. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11010.  
  11011. function traitementTalents() {
  11012. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11013. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11014. removeAllTalents();
  11015. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11016. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11017. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11018. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11019. }
  11020.  
  11021. function injecteInfosBulles(liste,fonction) {
  11022. var totalpc = 0;
  11023. // on parse la liste des talents du type 'fonction'
  11024. for(var i=0 ; i<liste.length ; i++) {
  11025. var
  11026. trTalent=liste[i],
  11027. node=trTalent.cells[1].querySelector('a'),
  11028. nomTalent=epure(trim(node.textContent)),
  11029. indiceTDniveaux=7,
  11030. indiceTDSousCompetence=2,
  11031. sousCompetences=undefined;
  11032. if(fonction=="competences"){
  11033. // un TD en plus pour des information complementaire liees a la comp
  11034. indiceTDniveaux++;
  11035. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11036. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11037. for (var j=0; j < sousCompetences.length; j++) {
  11038. sousCompetences[j] = sousCompetences[j].epure().trim();
  11039. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11040. }
  11041. }
  11042. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11043. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11044. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11045. totalpc += niveauxMaitrisesTalentArray[1];
  11046.  
  11047. // stockage des niveaux inferieurs du talent si presents
  11048. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11049. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11050. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11051. }
  11052. }
  11053. return totalpc;
  11054. }
  11055.  
  11056. function setInfos(node,nom,fonction,niveau) {
  11057. node.nom = nom;
  11058. node.fonction = fonction;
  11059. node.niveau = niveau;
  11060. node.onmouseover = setBulle;
  11061. node.onmouseout = cacherBulle;
  11062. }
  11063.  
  11064. var arrayModifAnatroll = {
  11065. 'Glue':'Glu',
  11066. 'PuM':'PuiM',
  11067. 'HE':'Hurlement',
  11068. //'Insultes':'Insu',
  11069. 'Pistage':'Pist',
  11070. 'PuC':'Planter'
  11071. }
  11072.  
  11073. function setTalent(nom,pc,niveau,sousCompetences) {
  11074. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11075. // (et pas les % dont osf) ne serait pas plus rentable
  11076. var nomEnBase = arrayTalents[epure(nom)];
  11077. if(!nomEnBase) { return; }
  11078. if(!niveau) { niveau = 1; }
  11079. switch(nomEnBase) {
  11080. case 'Insultes':
  11081. urlAnatrolliseur += 'Insu'+niveau+'|';
  11082. case 'IdT':
  11083. nomEnBase += niveau;
  11084. break;
  11085. case 'Golemo':
  11086. case 'Piege':
  11087. for (var i=0 ; i < sousCompetences.length ; i++) {
  11088. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11089. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11090. }
  11091. break;
  11092. case 'AP':
  11093. case 'Baroufle':
  11094. case 'CdB':
  11095. case 'CdM':
  11096. case 'Parer':
  11097. case 'Retraite':
  11098. case 'RB':
  11099. case 'SInterposer':
  11100. nomEnBase += niveau;
  11101. default:
  11102. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11103. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11104. }
  11105. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11106. }
  11107.  
  11108. function creerBulleVide() {
  11109. var table = document.createElement('table');
  11110. table.id = 'bulle';
  11111. table.className = 'mh_tdborder';
  11112. table.width = 300;
  11113. table.border = 0;
  11114. table.cellPadding = 5;
  11115. table.cellSpacing = 1;
  11116. table.style =
  11117. 'position:absolute;'
  11118. +'visibility:hidden;'
  11119. +'z-index:800;'
  11120. +'height:auto;';
  11121. var tr = appendTr(table,'mh_tdtitre');
  11122. appendTdText(tr,'Titre');
  11123. tr = appendTr(table,'mh_tdpage');
  11124. appendTdText(tr,'Contenu');
  11125. var aList = document.getElementsByTagName('a');
  11126. aList[aList.length-1].parentNode.appendChild(table);
  11127. }
  11128.  
  11129. function cacherBulle() {
  11130. if(bulleStyle)
  11131. bulleStyle.visibility = 'hidden';
  11132. }
  11133.  
  11134. function setBulle(evt) {
  11135. var nom = this.nom;
  11136. var fonction = this.fonction;
  11137. var niveau = parseInt(this.niveau);
  11138. var str='';
  11139. if(fonction=='competences'){
  11140. str=competences(nom,niveau);
  11141. } else if(fonction=='sortileges') {
  11142. str=sortileges(nom,true);
  11143. }
  11144. if(str=='') return;
  11145. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11146. var xfenetre, yfenetre, xpage, ypage, element = null;
  11147. var offset = 15;
  11148. var bulleWidth = 300;
  11149. if(!hauteur) hauteur = 50;
  11150. element = document.getElementById('bulle');
  11151. xfenetre = evt.clientX;
  11152. yfenetre = evt.clientY;
  11153. xpage = xfenetre;
  11154. ypage = yfenetre;
  11155. if(evt.pageX) xpage = evt.pageX;
  11156. if(evt.pageY) ypage = evt.pageY;
  11157. if(element) {
  11158. bulleStyle = element.style;
  11159. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11160. element.childNodes[1].firstChild.innerHTML = str;
  11161. }
  11162. if(bulleStyle) {
  11163. if(xfenetre>bulleWidth+offset)
  11164. xpage -= bulleWidth+offset;
  11165. else
  11166. xpage += offset;
  11167. if(yfenetre>hauteur+offset)
  11168. ypage -= hauteur + offset;
  11169. bulleStyle.width = bulleWidth;
  11170. bulleStyle.left = xpage + 'px';
  11171. bulleStyle.top = ypage + 'px';
  11172. bulleStyle.visibility = 'visible';
  11173. }
  11174. }
  11175.  
  11176.  
  11177. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11178.  
  11179. function competences(comp,niveau) {
  11180. var texte = '';
  11181. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11182. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11183. if(minParPV>1) texte += 's';
  11184. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11185. }
  11186. else if(comp.indexOf('Attaque Precise')!=-1) {
  11187. var pc, lastmax=0, espatt=0;
  11188. var notMaxedOut = false;
  11189. for(var i=niveau ; i>0 ; i--) {
  11190. pc = getTalent(comp,i);
  11191. if(lastmax!=0 && pc<=lastmax) continue;
  11192. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11193. attbp+attbm;
  11194. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11195. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11196. ' => <b>'+jetatt+'</b><br/>';
  11197. espatt += (pc-lastmax)*jetatt;
  11198. lastmax = pc;
  11199. if(i<niveau) notMaxedOut = true;
  11200. }
  11201. if(notMaxedOut) {
  11202. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11203. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11204. }
  11205. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11206. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11207. }
  11208. else if(comp.indexOf('Balayage')!=-1)
  11209. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11210. +' => <b>'+attmoy+'</b><br/>'
  11211. +'Effet : <b>Met à terre l\'adversaire</b>';
  11212. else if(comp.indexOf('Bidouille')!=-1)
  11213. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11214. +'de votre inventaire avec le texte de votre choix.';
  11215. else if(comp.indexOf('Baroufle')!=-1){
  11216. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11217. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11218. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11219. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11220. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11221. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11222. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11223. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11224. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11225. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11226. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11227. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11228. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11229. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11230. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11231. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11232. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11233. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11234. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11235. '</tbody></table>';
  11236. }
  11237. else if(comp.indexOf('Botte Secrete')!=-1){
  11238. texte = 'Attaque : <b>'
  11239. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11240. +' => <b>'
  11241. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  11242. +'</b><br/>Dégâts : <b>'
  11243. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  11244. +' => <b>'
  11245. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  11246. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  11247. +'</b>';
  11248. }
  11249. else if(comp.indexOf('Camouflage')!=-1) {
  11250. var camou = getTalent('Camouflage');
  11251. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  11252. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  11253. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  11254. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  11255. }
  11256. else if(comp.indexOf('Charger')!=-1) {
  11257. if(pvcourant<=0)
  11258. return '<i>On ne peut charger personne quand on est mort !</i>';
  11259. var portee = Math.min(
  11260. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  11261. vuetotale);
  11262. if(portee<1)
  11263. return '<b>Impossible de charger</b>';
  11264. else {
  11265. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11266. +' => <b>'+attmoy+'</b><br/>'
  11267. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11268. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  11269. +'<br/>Portée : <b>'+portee+'</b> case';
  11270. if(portee>1) texte += 's';
  11271. }
  11272. }
  11273. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  11274. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  11275. if(vuetotale>1) texte += 's';
  11276. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11277. if(vuetotale>2) texte += 's';
  11278. }
  11279. else if(comp.indexOf('Piege')!=-1) {
  11280. if(comp.indexOf('Glue')!=-1)
  11281. texte = 'Et si vous colliez vos adversaires au sol ?';
  11282. if(comp.indexOf('Feu')!=-1) {
  11283. if(texte){
  11284. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  11285. }
  11286. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  11287. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  11288. }
  11289. }
  11290. else if(comp.indexOf('Contre-Attaquer')!=-1){
  11291. texte = 'Attaque : <b>'
  11292. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11293. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11294. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11295. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11296. }
  11297. else if(comp.indexOf('Coup de Butoir')!=-1) {
  11298. var pc, lastmax=0, espdeg=0;
  11299. var notMaxedOut = false;
  11300. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11301. +' => <b>'+attmoy+'</b>';
  11302. for(var i=niveau ; i>0 ; i--) {
  11303. pc = getTalent(comp,i);
  11304. if(lastmax!=0 && pc<=lastmax) continue;
  11305. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  11306. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11307. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  11308. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  11309. espdeg += (pc-lastmax)*jetdeg;
  11310. lastmax = pc;
  11311. if(i<niveau) notMaxedOut = true;
  11312. }
  11313. if(notMaxedOut) {
  11314. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  11315. Math.floor(10*espdeg/lastmax)/10+'/'+
  11316. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  11317. }
  11318. }
  11319. else if(comp.indexOf('Course')!=-1)
  11320. texte = 'Déplacement gratuit : <b>'
  11321. +Math.floor(getTalent('Course')/2)
  11322. +' %</b> de chance';
  11323. else if(comp.indexOf('Deplacement Eclair')!=-1)
  11324. texte = 'Permet d\'économiser <b>1</b> PA '
  11325. +'par rapport au déplacement classique';
  11326. else if(comp.indexOf('Dressage')!=-1)
  11327. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  11328. +'ou un gnu sauvage.';
  11329. else if(comp.indexOf('Ecriture Magique')!=-1)
  11330. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  11331. +'la formule nécessite de réunir les composants de cette formule, '
  11332. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  11333. +'un champignon adéquat pour confectionner l\'encre.';
  11334. else if(comp.indexOf('Frenesie')!=-1) {
  11335. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11336. +' => <b>'+attmoy+'</b><br/>'
  11337. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11338. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11339. }
  11340. else if(comp.indexOf('Golem')!=-1)
  11341. texte = 'Animez votre golem en assemblant divers matériaux '
  11342. +'autour d\'un cerveau minéral.'
  11343. else if(comp.indexOf('Grattage')!=-1) {
  11344. texte = 'Permet de confectionner un Parchemin Vierge '
  11345. +'à partir de composants et de Gigots de Gob\'.';
  11346. }
  11347. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  11348. texte = 'Fait fuir un monstre si tout se passe bien.'
  11349. +'<br/>Lui donne de gros bonus sinon...';
  11350. else if(comp.indexOf('Identification des Champignons')!=-1) {
  11351. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11352. if(vuetotale>2) texte += 's';
  11353. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  11354. if(vuetotale>4) texte += 's';
  11355. }
  11356. else if(comp.indexOf('Insultes')!=-1)
  11357. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  11358. else if(comp.indexOf('interposer')!=-1)
  11359. texte = 'Jet de réflexe : <b>'
  11360. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  11361. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  11362. else if(comp.indexOf('Lancer de Potions') != -1)
  11363. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  11364. else if(comp.indexOf('Marquage')!=-1)
  11365. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  11366. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  11367. +'se trouver dans la même caverne que le monstre pour le marquer.';
  11368. else if(comp.indexOf('Melange Magique')!=-1)
  11369. texte = 'Cette Compétence permet de combiner deux Potions pour '
  11370. +'en réaliser une nouvelle dont l\'effet est la somme '
  11371. +'des effets des potions initiales.';
  11372. else if(comp.indexOf('Miner')!=-1)
  11373. texte = 'Portée horizontale (officieuse) : <b>'
  11374. +2*vuetotale+'</b> cases<br/>'
  11375. +'Portée verticale (officieuse) : <b>'
  11376. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11377. else if(comp.indexOf('Necromancie')!=-1)
  11378. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  11379. +'de faire "revivre" ce monstre.';
  11380. else if(comp.indexOf('Painthure de Guerre')!=-1)
  11381. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  11382. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  11383. +'pour s\'inspirer, et laissez parler votre créativité.'
  11384. else if(comp.indexOf('Parer')!=-1)
  11385. texte = 'Jet de parade : <b>'
  11386. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  11387. +' => <b>'
  11388. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11389. +'</b><hr><i>Equivalent esquive : <b>'
  11390. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  11391. +' => <b>'
  11392. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  11393. +'</b></i>';
  11394. else if(comp.indexOf('Pistage')!=-1)
  11395. texte = 'Portée horizontale : <b>'
  11396. +2*vuetotale+'</b> cases<br/>'
  11397. +'Portée verticale : <b>'
  11398. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11399. else if(comp.indexOf('Planter un Champignon')!=-1)
  11400. texte = 'Planter un Champignon est une compétence qui vous permet de '
  11401. +'créer des colonies d\'une variété donnée de champignon à partir de '
  11402. +'quelques exemplaires préalablement enterrés.';
  11403. else if(comp.indexOf('Regeneration Accrue')!=-1)
  11404. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  11405. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  11406. else if(comp.indexOf('Reparation')!=-1)
  11407. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  11408. +'et réparez vous-même votre matériel !';
  11409. else if(comp.indexOf('Retraite')!=-1)
  11410. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  11411. +'préférable de préparer un repli stratégique pour déconcerter '
  11412. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  11413. +'Quelle intelligence démoniaque.';
  11414. else if(comp.indexOf('Rotobaffe')!=-1) {
  11415. var Datt = att, vattbm = attbp+attbm;
  11416. var Ddeg = deg, vdegbm = degbp+degbm;
  11417. for(var i=1 ; i<niveau+2 ; i++) {
  11418. texte += '<b>Attaque n°'+i+' :</b><br/>'
  11419. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  11420. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  11421. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  11422. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  11423. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  11424. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  11425. if(i<niveau+1) texte += '<hr>';
  11426. }
  11427. }
  11428. else if(comp.indexOf('Shamaner')!=-1)
  11429. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  11430. +'des monstres en utilisant des champignons (de 1 à 3).';
  11431. else if(comp.indexOf('Tailler')!=-1){
  11432. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11433. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11434. }
  11435. return texte;
  11436. }
  11437.  
  11438. function decumul_buff(nom,str,buff) {
  11439. // Decumul des sorts de buff
  11440. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11441. var dec = buff, total = buff, i=1;
  11442. while(i<6) {
  11443. i++;
  11444. dec = Math.floor(coefDecumul(i)*buff);
  11445. if(dec<=1 || i==6) break;
  11446. total += dec;
  11447. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11448. +str+' +'+dec+' (+'+total+')</i>';
  11449. }
  11450. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11451. return ret;
  11452. }
  11453.  
  11454.  
  11455. function sortileges(sort,mainCall,pcA,pcD) {
  11456. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11457. var texte = '';
  11458. if (mainCall) {
  11459. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11460. pcA = (atttourP+atttourM);
  11461. pcD = (degtourP+degtourM);
  11462. }
  11463. if (sort.indexOf('Analyse Anatomique') != -1) {
  11464. texte = 'Portée horizontale : <b>'
  11465. + Math.floor(vuetotale / 2) + '</b> case';
  11466. if (vuetotale > 3){ texte += 's'; }
  11467. texte += '<br/>Portée verticale : <b>'
  11468. + Math.floor((vuetotale+1)/4)+'</b> case';
  11469. if (vuetotale > 7){ texte += 's'; }
  11470. }
  11471. else if (sort.indexOf('Armure Etheree') != -1){
  11472. texte = decumul_buff('AE', 'Armure magique', reg);
  11473. }
  11474. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11475. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11476. }
  11477. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11478. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11479. }
  11480. else if (sort.indexOf('Augmentation des Degats') != -1){
  11481. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11482. }
  11483. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11484. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11485. }
  11486. else if(sort.indexOf('Bulle Magique')!=-1){
  11487. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11488. }
  11489. else if(sort.indexOf('Explosion')!=-1){
  11490. texte = 'Dégâts : <b>'
  11491. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11492. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11493. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11494. }
  11495. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11496. if(pvcourant<=0)
  11497. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11498. texte = 'Portée horizontale : <b>'
  11499. +Math.min(1,vuetotale)+'</b> case<br/>'
  11500. +'Dégâts physiques : <b>-'
  11501. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11502. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11503. +'Dégâts magiques : <b>-'
  11504. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11505. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11506. }
  11507. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11508. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11509. }
  11510. else if(sort.indexOf('Glue')!=-1) {
  11511. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11512. if(vuetotale>2) texte += 's';
  11513. }
  11514. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11515. /* Frappe */
  11516. var modD = 0;
  11517. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11518. if(pcA!=0){
  11519. modD = parseInt(att*pcA/100);
  11520. texte += '<i>'+aff(modD)+'D6</i> ';
  11521. }
  11522. texte += aff(attbm)
  11523. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11524. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11525. if(pcD!=0) {
  11526. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11527. texte += '<i>'+aff(modD)+'D3</i> ';
  11528. }else
  11529. modD = 0;
  11530. texte += aff(degbm)+' => <b>'
  11531. +(2*(Math.floor(deg/2)+modD)+degbm)
  11532. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11533. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11534. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11535. +')</b>';
  11536. if(!mainCall) return texte;
  11537. /* Venins */
  11538. function addVenin(type,effet,duree) {
  11539. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11540. +' pendant <b>'+duree+'</b> tour';
  11541. if(duree>1) ret += 's';
  11542. var dred = Math.max(Math.floor(duree/2),1);
  11543. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11544. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11545. }
  11546. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11547. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11548. effet = Math.floor(1.5*effet);
  11549. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11550. }
  11551. else if(sort.indexOf('Hypnotisme')!=-1)
  11552. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11553. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11554. else if(sort.indexOf('Identification des tresors')!=-1)
  11555. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11556. +'d\'un trésor.';
  11557. else if(sort.indexOf('Invisibilite')!=-1)
  11558. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11559. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11560. +'fait disparaître l\'invisibilité.';
  11561. else if(sort.indexOf('Levitation')!=-1)
  11562. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11563. +'Comme les pièges ou les trous par exemple...';
  11564. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11565. var eps = 1,
  11566. pc = 20;
  11567. var str = 'PréM';
  11568. var newSort;
  11569. var sortAtt = [
  11570. 'Projectile Magique',
  11571. 'Rafale Psychique',
  11572. 'Siphon des Ames',
  11573. 'Vampirisme',
  11574. 'Griffe du Sorcier'
  11575. ];
  11576. if(sort.indexOf('Puissance')!=-1) {
  11577. eps = -1; str='PuM';
  11578. }
  11579. for(var i=1 ; i<4 ; i++) {
  11580. if(texte) { texte += '<hr>'; }
  11581. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11582. newSort = false;
  11583. for(var j=0 ; j<sortAtt.length ; j++) {
  11584. if(getTalent(sortAtt[j])) {
  11585. if(newSort) { texte += '<br/><br/>'; }
  11586. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  11587. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  11588. newSort = true;
  11589. }
  11590. }
  11591. pc = decumulPumPrem(pc);
  11592. }
  11593. }
  11594. else if(sort.indexOf('Projectile Magique')!=-1) {
  11595. var modD = 0;
  11596. var portee = getPortee__Profil(vuetotale);
  11597. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  11598. if(pcA!=0) {
  11599. modD = parseInt(vue*pcA/100);
  11600. texte += '<i>'+aff(modD)+'D6</i> ';
  11601. }
  11602. texte += aff(attbm)
  11603. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  11604. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  11605. if(pcD!=0) {
  11606. modD = parseInt(Math.floor(vue/2)+pcD);
  11607. texte += '<i>'+aff(modD)+'D3</i> ';
  11608. }else
  11609. modD = 0;
  11610. texte += aff(degbm)
  11611. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  11612. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  11613. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  11614. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  11615. if(!mainCall) return texte;
  11616. texte += '<br/>Portée : <b>'+portee+'</b> case';
  11617. if(portee>1) texte += 's';
  11618. }
  11619. else if(sort.indexOf('Projection')!=-1) {
  11620. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  11621. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  11622. +'Si le jet de résistance de la victime est réussi:<br/>'
  11623. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  11624. }
  11625. else if(sort.indexOf('Rafale Psychique')!=-1) {
  11626. var modD = 0;
  11627. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  11628. if(pcD!=0) {
  11629. modD = parseInt(deg*pcD/100);
  11630. texte += '<i>'+aff(modD)+'D3</i> ';
  11631. }
  11632. texte += aff(degbm)
  11633. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  11634. if(!mainCall) return texte;
  11635. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  11636. }
  11637. else if(sort.indexOf('Sacrifice')!=-1) {
  11638. if(pvcourant<=0)
  11639. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  11640.  
  11641. function perteSacro(sac) {
  11642. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  11643. }
  11644.  
  11645. var sac = Math.floor((pvcourant-1)/2);
  11646. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11647. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  11648. /* Sacros max et optimal sans malus (propale R') */
  11649. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11650. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  11651. if(sac>0)
  11652. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  11653. else
  11654. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  11655. /*if(sac>3) {
  11656. sac = 5*Math.floor((sac+1)/5)-1;
  11657. texte += '<br/>Soin optimal sans malus de temps : <b>'
  11658. +sac+'</b> PV'+perteSacro(sac);
  11659. }*/
  11660. }
  11661. else if(sort.indexOf('Siphon')!=-1) {
  11662. var modD = 0;
  11663. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11664. if(pcA!=0) {
  11665. modD = parseInt(att*pcA/100);
  11666. texte += '<i>'+aff(modD)+'D6</i> ';
  11667. }
  11668. texte += aff(attbm)
  11669. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  11670. +'Dégâts : <b>'+reg+'</b> D3 ';
  11671. if(pcD!=0) {
  11672. modD = parseInt(reg*pcD/100);
  11673. texte += '<i>'+aff(modD)+'D3</i> ';
  11674. }else
  11675. modD = 0;
  11676. texte += aff(degbm)
  11677. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  11678. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  11679. if(!mainCall) return texte;
  11680. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  11681. }
  11682. else if(sort.indexOf('Telekinesie')!=-1) {
  11683. texte = 'Portée horizontale :';
  11684. var vt = Math.floor(vuetotale/2)+2;
  11685. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  11686. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  11687. for(var i=0 ; i<5 ; i++) {
  11688. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  11689. if(vt>1) texte += 's';
  11690. vt=Math.max(0,vt-1);
  11691. }
  11692. }
  11693. else if(sort.indexOf('Teleportation')!=-1) {
  11694. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  11695. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  11696. var pmh = (20+vue+portee);
  11697. var pmv = 3+Math.floor(portee/3);
  11698. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  11699. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  11700. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  11701. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  11702. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  11703. }
  11704. else if(sort.indexOf('Vampirisme')!=-1) {
  11705. var modD = 0;
  11706. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  11707. if(pcA!=0) {
  11708. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  11709. texte += '<i>'+aff(modD)+'D6</i> ';
  11710. }
  11711. texte += aff(attbm)
  11712. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  11713. +'Dégâts : <b>'+deg+'</b> D3 ';
  11714. if(pcD!=0) {
  11715. modD = parseInt(deg*pcD/100);
  11716. texte += '<i>'+aff(modD)+'D3</i> ';
  11717. }else
  11718. modD = 0;
  11719. texte += aff(degbm)
  11720. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  11721. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  11722. }
  11723. else if(sort.indexOf('Vision Accrue')!=-1)
  11724. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  11725. else if(sort.indexOf('Vision lointaine')!=-1)
  11726. texte = 'En ciblant une zone située n\'importe où dans le '
  11727. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  11728. else if(sort.indexOf('Voir le Cache')!=-1)
  11729. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  11730. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  11731. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  11732. +getPortee__Profil(vuetotale)+'</b> cases';
  11733. else if(sort.indexOf('Vue Troublee')!=-1)
  11734. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11735. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  11736. return texte;
  11737. }
  11738.  
  11739.  
  11740. /*---------------------------------- Main ------------------------------------*/
  11741.  
  11742. function do_profil2()
  11743. {
  11744. try {
  11745. start_script(31);
  11746.  
  11747. extractionDonnees();
  11748. setInfosCaracteristiques();
  11749. setInfoDescription();
  11750. setInfosEtatLieux();
  11751. setInfosEtatPV();
  11752. setInfosExp();
  11753.  
  11754. creerBulleVide();
  11755. traitementTalents();
  11756. setLienAnatrolliseur();
  11757.  
  11758. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  11759. if(race=='Kastar'){ setAccel(); }
  11760. saveProfil();
  11761. displayScriptTime();
  11762. } catch(e) {
  11763. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  11764. window.console.error(traceStack(e, 'profil2'));
  11765. }
  11766. }
  11767.  
  11768. /*******************************************************************************
  11769. * This file is part of Mountyzilla. *
  11770. * *
  11771. * Mountyzilla is free software; you can redistribute it and/or modify *
  11772. * it under the terms of the GNU General Public License as published by *
  11773. * the Free Software Foundation; either version 2 of the License, or *
  11774. * (at your option) any later version. *
  11775. * *
  11776. * Mountyzilla is distributed in the hope that it will be useful, *
  11777. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11778. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11779. * GNU General Public License for more details. *
  11780. * *
  11781. * You should have received a copy of the GNU General Public License *
  11782. * along with Mountyzilla; if not, write to the Free Software *
  11783. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11784. *******************************************************************************/
  11785.  
  11786. // x~x script_principal
  11787.  
  11788. function isPage(url) {
  11789. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11790. }
  11791.  
  11792. // x~x md5.js
  11793. /*
  11794. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11795. * Digest Algorithm, as defined in RFC 1321.
  11796. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11797. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11798. * Distributed under the BSD License
  11799. * See http://pajhome.org.uk/crypt/md5 for more info.
  11800. */
  11801.  
  11802. /*
  11803. * Configurable variables. You may need to tweak these to be compatible with
  11804. * the server-side, but the defaults work in most cases.
  11805. */
  11806. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11807. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11808. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11809.  
  11810. /*
  11811. * These are the functions you'll usually want to call
  11812. * They take string arguments and return either hex or base-64 encoded strings
  11813. */
  11814. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11815. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11816. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11817. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11818. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11819. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11820.  
  11821. /*
  11822. * Perform a simple self-test to see if the VM is working
  11823. */
  11824. function md5_vm_test()
  11825. {
  11826. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11827. }
  11828.  
  11829. /*
  11830. * Calculate the MD5 of an array of little-endian words, and a bit length
  11831. */
  11832. function core_md5(x, len)
  11833. {
  11834. /* append padding */
  11835. x[len >> 5] |= 0x80 << ((len) % 32);
  11836. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11837.  
  11838. var a = 1732584193;
  11839. var b = -271733879;
  11840. var c = -1732584194;
  11841. var d = 271733878;
  11842.  
  11843. for(var i = 0; i < x.length; i += 16)
  11844. {
  11845. var olda = a;
  11846. var oldb = b;
  11847. var oldc = c;
  11848. var oldd = d;
  11849.  
  11850. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11851. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11852. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11853. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11854. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11855. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11856. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11857. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11858. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11859. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11860. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11861. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11862. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11863. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11864. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11865. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11866.  
  11867. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11868. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11869. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11870. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11871. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11872. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11873. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11874. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11875. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11876. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11877. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11878. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11879. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11880. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11881. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11882. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11883.  
  11884. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11885. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11886. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11887. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11888. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11889. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11890. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11891. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11892. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11893. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11894. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11895. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11896. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11897. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11898. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11899. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11900.  
  11901. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11902. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11903. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11904. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11905. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11906. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11907. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11908. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11909. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11910. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11911. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11912. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11913. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11914. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11915. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11916. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11917.  
  11918. a = safe_add(a, olda);
  11919. b = safe_add(b, oldb);
  11920. c = safe_add(c, oldc);
  11921. d = safe_add(d, oldd);
  11922. }
  11923. return Array(a, b, c, d);
  11924.  
  11925. }
  11926.  
  11927. /*
  11928. * These functions implement the four basic operations the algorithm uses.
  11929. */
  11930. function md5_cmn(q, a, b, x, s, t)
  11931. {
  11932. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11933. }
  11934. function md5_ff(a, b, c, d, x, s, t)
  11935. {
  11936. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11937. }
  11938. function md5_gg(a, b, c, d, x, s, t)
  11939. {
  11940. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11941. }
  11942. function md5_hh(a, b, c, d, x, s, t)
  11943. {
  11944. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11945. }
  11946. function md5_ii(a, b, c, d, x, s, t)
  11947. {
  11948. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11949. }
  11950.  
  11951. /*
  11952. * Calculate the HMAC-MD5, of a key and some data
  11953. */
  11954. function core_hmac_md5(key, data)
  11955. {
  11956. var bkey = str2binl(key);
  11957. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11958.  
  11959. var ipad = Array(16), opad = Array(16);
  11960. for(var i = 0; i < 16; i++)
  11961. {
  11962. ipad[i] = bkey[i] ^ 0x36363636;
  11963. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11964. }
  11965.  
  11966. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11967. return core_md5(opad.concat(hash), 512 + 128);
  11968. }
  11969.  
  11970. /*
  11971. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  11972. * to work around bugs in some JS interpreters.
  11973. */
  11974. function safe_add(x, y)
  11975. {
  11976. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  11977. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  11978. return (msw << 16) | (lsw & 0xFFFF);
  11979. }
  11980.  
  11981. /*
  11982. * Bitwise rotate a 32-bit number to the left.
  11983. */
  11984. function bit_rol(num, cnt)
  11985. {
  11986. return (num << cnt) | (num >>> (32 - cnt));
  11987. }
  11988.  
  11989. /*
  11990. * Convert a string to an array of little-endian words
  11991. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  11992. */
  11993. function str2binl(str)
  11994. {
  11995. var bin = Array();
  11996. var mask = (1 << chrsz) - 1;
  11997. for(var i = 0; i < str.length * chrsz; i += chrsz)
  11998. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  11999. return bin;
  12000. }
  12001.  
  12002. /*
  12003. * Convert an array of little-endian words to a string
  12004. */
  12005. function binl2str(bin)
  12006. {
  12007. var str = "";
  12008. var mask = (1 << chrsz) - 1;
  12009. for(var i = 0; i < bin.length * 32; i += chrsz)
  12010. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12011. return str;
  12012. }
  12013.  
  12014. /*
  12015. * Convert an array of little-endian words to a hex string.
  12016. */
  12017. function binl2hex(binarray)
  12018. {
  12019. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12020. var str = "";
  12021. for(var i = 0; i < binarray.length * 4; i++)
  12022. {
  12023. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12024. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12025. }
  12026. return str;
  12027. }
  12028.  
  12029. /*
  12030. * Convert an array of little-endian words to a base-64 string
  12031. */
  12032. function binl2b64(binarray)
  12033. {
  12034. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12035. var str = "";
  12036. for(var i = 0; i < binarray.length * 4; i += 3)
  12037. {
  12038. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12039. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12040. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12041. for(var j = 0; j < 4; j++)
  12042. {
  12043. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12044. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12045. }
  12046. }
  12047. return str;
  12048. }
  12049.  
  12050. ///////////////////////////////////////////
  12051. // debug cartes capitan Roule 07/12/2016
  12052. ///////////////////////////////////
  12053. // essais : objet
  12054. // .mode : description
  12055. // .essais : tableau d'objets essai
  12056. // .mode : description
  12057. // .essais : tableau de cartes
  12058. // .noCarte : id de la carte
  12059. // .essais : tableau d'essais, [x, y, n, nb]
  12060. function AfficheEssais(essais, sMode) {
  12061. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12062. if (!eBigDiv) {
  12063. var insertPoint = document.getElementById('footer1');
  12064. eBigDiv = document.createElement('table');
  12065. eBigDiv.id = 'ListeEssaiCapitan';
  12066. insertBefore(insertPoint, document.createElement('p'));
  12067. insertTitle(insertPoint,'Capitan : Liste des essais');
  12068. insertBefore(insertPoint, eBigDiv);
  12069. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12070. }
  12071. if (!essais) {
  12072. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12073. return;
  12074. }
  12075. var carte;
  12076. for (carte in essais) {
  12077. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12078. }
  12079. if (carte === undefined) {
  12080. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12081. }
  12082. }
  12083.  
  12084. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12085. var tr = appendTr(eTable);
  12086. var td = appendTd(tr);
  12087. appendText(td, sMode, bBold);
  12088. td = appendTd(tr);
  12089. appendText(td, sCarte, bBold);
  12090. td = appendTd(tr);
  12091. appendText(td, sText, bBold);
  12092. }
  12093.  
  12094. function getEssaiV1_0() {
  12095. try {
  12096. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12097. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12098. var tabK, nK;
  12099. prefs.getChildList('', nK, tabK);
  12100. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12101. //window.console.log('getEssaiV1_0, ' + nK);
  12102. return;
  12103. //return r;
  12104. } catch (e) {
  12105. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12106. }
  12107. }
  12108.  
  12109. function getEssaiV1_1() {
  12110. var locSto = window.localStorage;
  12111. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12112. var r = [];
  12113. for (var i = 0; i < locSto.length; i++) {
  12114. var k = locSto.key(i);
  12115. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12116. var t = k.split(/\./);
  12117. if (t[0] !== 'capitan') continue;
  12118. if (t[2] !== 'essai') continue;
  12119. var carte = 'carte n°' + t[1];
  12120. if (r[carte]) r[carte]++;
  12121. else r[carte] = 1;
  12122. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12123. }
  12124. return r;
  12125. }
  12126.  
  12127. function showEssaiCartes() {
  12128. window.console.log('début showEssai Tout_MZ');
  12129. var essais = getEssaiV1_0();
  12130. AfficheEssais(essais, 'V1.0');
  12131. essais = getEssaiV1_1();
  12132. AfficheEssais(essais, 'V1.1');
  12133. window.console.log('fin showEssai Tout_MZ');
  12134. }
  12135.  
  12136. function testBoolLocalStorage() {
  12137. var b = true;
  12138. var key = 'MZ_essai_bool';
  12139. GM_setValue(key, b);
  12140. window.localStorage[key] = b;
  12141. var v = GM_getValue(key);
  12142. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12143. var v = window.localStorage.getItem(key);
  12144. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12145.  
  12146. var b = false;
  12147. GM_setValue(key, b);
  12148. window.localStorage[key] = b;
  12149. var v = GM_getValue(key);
  12150. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12151. var v = window.localStorage.getItem(key);
  12152. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12153.  
  12154. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12155. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12156. var y = GM_getValue('654654897894654654');
  12157. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12158. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12159. }
  12160.  
  12161. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12162. function export_trolligion() {
  12163. try {
  12164. var tabDl = document.getElementsByTagName('dl');
  12165. if ((!tabDl) || !tabDl[0]) {
  12166. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12167. return;
  12168. }
  12169. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12170. // nom : string
  12171. // rayonnement : entier
  12172. // grades : table d'objets (une occurence par grade)
  12173. // nom : string
  12174. // trolls : table d'objets (un par Trõll)
  12175. // id
  12176. // nom
  12177. // idguilde
  12178. // guilde
  12179. // race
  12180. // niveau
  12181. // ferveur
  12182. var currentDieu;
  12183. var currentGrade;
  12184. for (var iChild1 in tabDl[0].children) {
  12185. var eChild1 = tabDl[0].children[iChild1];
  12186. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12187. case 'dd': // Trõll
  12188. var oTroll = {};
  12189. var tabFigcaption = eChild1.getElementsByTagName('figcaption');
  12190. if ((!tabFigcaption) || !tabFigcaption[0]) {
  12191. window.console.log('[MZ ' + GM_info.script.version + '] ignore dd sans figcaption ' + eChild1.innerHTML);
  12192. break;
  12193. }
  12194. for (var iChild2 in tabFigcaption[0].childNodes) { // childNodes pour obtenir les éléments texte aussi
  12195. var eChild2 = tabFigcaption[0].childNodes[iChild2];
  12196. if (eChild2.nodeType === undefined) continue; // properties
  12197. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  12198. switch (eChild2.nodeType) {
  12199. case 1: //ELEMENT_NODE:
  12200. switch (eChild2.nodeName.toLowerCase()) {
  12201. case 'a':
  12202. var m;
  12203. if (!eChild2.href) {
  12204. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  12205. break;
  12206. }
  12207. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  12208. if (m) {
  12209. oTroll.id = parseInt(m[1]);
  12210. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  12211. break;
  12212. }
  12213. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  12214. if (m) {
  12215. var idGuilde = parseInt(m[1]);
  12216. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  12217. oTroll.idguilde = parseInt(m[1]);
  12218. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  12219. }
  12220. break;
  12221. }
  12222. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  12223. break;
  12224. case 'br': // ignore
  12225. case 'style': // ignore
  12226. break;
  12227. case 'div': // barre de vie
  12228. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  12229. eChild3 = eChild2.children[0];
  12230. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  12231. var eChild4 = eChild3.children[0];
  12232. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  12233. break;
  12234. }
  12235. }
  12236. // pas de break pour bénéficier du log ci-dessous
  12237. default:
  12238. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  12239. break;
  12240. }
  12241. break;
  12242. case 3: //TEXT_NODE:
  12243. var txt = eChild2.nodeValue.trim();
  12244. if (txt === '') break;
  12245. var m = txt.match(/(.*) *\((\d+)\)/);
  12246. if (m) {
  12247. oTroll.race = m[1].trim();
  12248. oTroll.niveau = parseInt(m[2]);
  12249. } else {
  12250. oTroll.race = txt;
  12251. }
  12252. break;
  12253. default: // ne devrait pas arriver
  12254. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  12255. break;
  12256. }
  12257. }
  12258. currentGrade.trolls.push(oTroll);
  12259. break;
  12260. case 'dt':
  12261. var tabH3 = eChild1.getElementsByTagName('h3');
  12262. if (tabH3 && tabH3[0]) { // changement de dieu
  12263. currentDieu = {
  12264. nom: tabH3[0].innerText || tabH3[0].textContent
  12265. , grades: []};
  12266. var txt = eChild1.innerText || eChild1.textContent;
  12267. var m = txt.match(/yon*ement *:* *(\d+)/);
  12268. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12269. currentGrade = undefined;
  12270. tabDieux.push(currentDieu);
  12271. break;
  12272. }
  12273. var tabH4 = eChild1.getElementsByTagName('h4');
  12274. if (tabH4 && tabH4[0]) { // changement de grade
  12275. var grade;
  12276. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12277. tabI = tabH4[0].getElementsByTagName('i');
  12278. if (tabI && tabI[0]) {
  12279. grade = tabI[0].innerText || tabI[0].textContent;
  12280. grade = grade.replace(/"/g, '');
  12281. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12282. if (m) grade += ' (' + m[1] + ')';
  12283. } else {
  12284. grade = txt.replace(/"/g, '');
  12285. }
  12286. currentGrade = {nom: grade, trolls: []};
  12287. currentDieu.grades.push(currentGrade);
  12288. break;
  12289. }
  12290. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12291. break;
  12292. default:
  12293. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12294. }
  12295. }
  12296.  
  12297. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12298. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12299. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12300. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12301. for (var iDieu in tabDieux) {
  12302. var oDieu = tabDieux[iDieu];
  12303. for (var iGrade in oDieu.grades) {
  12304. var oGrade = oDieu.grades[iGrade];
  12305. for (var iTroll in oGrade.trolls) {
  12306. var oTroll = oGrade.trolls[iTroll];
  12307. var t = [oDieu.nom, oDieu.rayonnement
  12308. , oGrade.nom
  12309. , oTroll.id, oTroll.nom
  12310. , oTroll.idguilde, oTroll.guilde
  12311. , oTroll.race, oTroll.niveau
  12312. , oTroll.ferveur];
  12313. for (var iParam in t) {
  12314. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12315. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12316. }
  12317. txt += t.join("\t") + "\n";
  12318. }
  12319. }
  12320. var t = [oDieu.nom, oDieu.rayonnement];
  12321. for (var iParam in t) {
  12322. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12323. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12324. }
  12325. txt2 += t.join("\t") + "\n";
  12326. }
  12327. txt += "\n" + txt2;
  12328. } catch (e) {
  12329. window.alert("Échec à l'extraction\n" + e);
  12330. }
  12331. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  12332. try {
  12333. if (copyTextToClipboard(txt)) {
  12334. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  12335. + "Collez dans Calc\n"
  12336. + "ou, au pire, dans EXCEL®");
  12337. } else {
  12338. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  12339. }
  12340. } catch(e) {
  12341. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  12342. }
  12343. }
  12344.  
  12345. function do_trolligion() {
  12346. var divpopup = document.createElement('div');
  12347. divpopup.id = 'MZ_divCopier';
  12348. divpopup.style.position = 'fixed';
  12349. divpopup.style.top = '2px';
  12350. divpopup.style.left = '2px;';
  12351. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  12352. divpopup.style.cursor = 'pointer';
  12353. divpopup.style.zIndex = 200;
  12354. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  12355. divpopup.onclick = export_trolligion;
  12356. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  12357. divpopup.appendChild(img);
  12358. document.body.appendChild(divpopup);
  12359. }
  12360.  
  12361. /*--------------------------------- Dispatch ---------------------------------*/
  12362.  
  12363. //chargerScriptDev("libs");
  12364. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  12365. //if (isDEV) testBoolLocalStorage();
  12366.  
  12367. // Détection de la page à traiter
  12368. if(isPage("Messagerie/ViewMessageBot")) {
  12369. do_cdmbot();
  12370. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  12371. do_cdmcomp();
  12372. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  12373. do_cdmcomp();
  12374. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  12375. do_cdmcomp();
  12376. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  12377. do_diplo();
  12378. } else if(isPage("MH_Play/Play_equipement")) {
  12379. do_equip();
  12380. } else if(isPage("MH_Play/Play_menu")) {
  12381. do_menu();
  12382. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  12383. do_option();
  12384. //showEssaiCartes();
  12385. } else if(isPage("View/PJView")) {
  12386. do_pjview();
  12387. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  12388. do_profil();
  12389. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  12390. do_tancompo();
  12391. } else if(isPage("MH_Play/Play_vue")) {
  12392. do_vue();
  12393. } else if(isPage("MH_Play/Play_news")) {
  12394. do_news();
  12395. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  12396. do_move();
  12397. } else if(isPage("MH_Missions/Mission_Etape")) {
  12398. do_mission();
  12399. } else if(isPage("View/MonsterView")) {
  12400. do_infomonstre();
  12401. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  12402. do_attaque();
  12403. } else if(isPage("MH_Play/Play_e_follo.php")) {
  12404. do_listegowap();
  12405. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  12406. do_lieuDescription();
  12407. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  12408. do_lieuTeleport();
  12409. } else if(isPage("MH_Follower/FO_Ordres")) {
  12410. do_ordresgowap();
  12411. } else if(isPage("MH_Follower/FO_Equipement")) {
  12412. do_equipgowap();
  12413. } else if(isPage("MH_Play/Play_mouche")) {
  12414. do_mouches();
  12415. } else if(isPage("MH_Play/Play_BM")) {
  12416. do_malus();
  12417. } else if(isPage("MH_Play/Play_evenement")) {
  12418. do_myevent();
  12419. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  12420. do_enchant();
  12421. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  12422. do_pre_enchant();
  12423. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  12424. do_actions();
  12425. } 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')) {
  12426. do_mission_liste();
  12427. } else if(isPage('MH_Play/Play_action')) {
  12428. do_actions();
  12429. } else if(isPage('MH_Play/Play_profil2')) {
  12430. do_profil2();
  12431. } else if(isPage('View/TrolligionView.php')) {
  12432. do_trolligion();
  12433. }
  12434. } catch(e) {
  12435. try {
  12436. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  12437. } catch(e2) {
  12438. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  12439. }
  12440. }