Tout_MZ

Client MountyZilla

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

  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.7
  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.7 26/04/2017",
  37. " Version compatible hors GreaseMonkey",
  38. "V1.2.17.6 23/04/2017",
  39. " Correction gestion des missions en cas de réinstallation",
  40. "V1.2.17.5 20/04/2017",
  41. " Correction de la récupération du niveau du Trõll pour le calcul des PX",
  42. "V1.2.17.4 08/04/2017",
  43. " Affichage triangle camou/invi pour les Trõlls de l'IT vus (sous VlC)",
  44. " Adaptation de la diplomacie à une modification de la page MH",
  45. "V1.2.17.3 04/04/2017",
  46. " Messages console en cas de cadre d'erreur",
  47. " Trolls de l'IT mais pas dans le vue en orange",
  48. "V1.2.17.2 20/03/2017",
  49. " Correction des PV restants",
  50. "V1.2.17.1 20/03/2017",
  51. " Blocage des PV restants en attendant résolution de bug",
  52. "V1.2.17 19/03/2017",
  53. " Refonte de l'envoi des CdM",
  54. " Modification de l'analyse de la frame de gauche (suite modification MH)",
  55. "V1.2.16.4 08/03/2017",
  56. " correction ID de troll en envoi de PX/MP",
  57. "V1.2.16.3 27/02/2017",
  58. " correction bonus/malus FP",
  59. "V1.2.16.2 24/02/2017",
  60. " corrige bug des cases à cocher qui n'étaient plus mémorisées",
  61. "V1.2.16.1 21/02/2017",
  62. " corrige bug sur Fx 38.8 ESR",
  63. "V1.2.16 21/02/2017",
  64. " double stockage GM + localStorage version Vapulabehemot en préparation du passage HTTPS",
  65. " possibilité de masquer les Gowaps Sauvages dans la vue",
  66. " calcul des caractéristiques du siphon des âmes",
  67. "V1.2.15.2 02/02/2017",
  68. " adaptation décumul VlC (page des bonus/malus)",
  69. "V1.2.15.1 29/01/2017",
  70. " carte sur la page de description du lieu TP",
  71. "V1.2.15 25/01/2017",
  72. " mise en place des nouvelles cartes (suivants, TP)",
  73. "V1.2.14.3 25/01/2017",
  74. " résumé dans l'export des données Trõlligion",
  75. "V1.2.14.2 20/01/2017",
  76. " forcer filtrage après le chargement des niveaux des monstres dans la vue",
  77. "V1.2.14.1 20/01/2017",
  78. " réécriture filtrage des monstres par niveau dans la vue",
  79. " Changelog dans la page des news MZ",
  80. "V1.2.14 20/01/2017",
  81. " Ajout de l'export des données Trõlligion",
  82. "V1.2.13.7 10/01/2017",
  83. " Exclusion Bricoll'troll dans l'entête GM",
  84. "V1.2.13.6 08/01/2017",
  85. " Réécriture analyse des étapes de mission sur monstre de niveau...",
  86. "V1.2.13.5 07/01/2017",
  87. " Correction bug qui se manisfestait sous LINUX",
  88. "V1.2.13.4 07/01/2017",
  89. " Plus de traces en mode debug pour l'analyse des étapes de mission",
  90. "V1.2.13.3 07/01/2017",
  91. " Correction erreur sur un commentaire qui bloquait la compilation javascript",
  92. "V1.2.13.2 07/01/2017",
  93. " Correction missions, recherche troogle (familles et types de monstres)",
  94. "V1.2.13.1 06/01/2017",
  95. " Suppression oldSchoolProfile qui n'existe plus",
  96. " Ajout du 'refresh' du cadre de gauche",
  97. "V1.2.13 01/01/2017",
  98. " homogénéisation des messages d'erreur",
  99. " Ajout du lien Troogle sur les étapes de mission monstre",
  100. "V1.2.12.2 30/12/2016",
  101. " retour en mode normal (http si jeu en http)",
  102. "V1.2.12.1 27/12/2016",
  103. " Correction mode IP",
  104. " Version patch pour forcer https sur /mz.mh.raistlin.fr (http en panne)",
  105. "V1.2.12 24/12/2016",
  106. " Nettoyage des URL",
  107. " Mode dev (Shift+Click sur le mot 'Crédits' dans Options/Pack Graphique) qui se branche sur le site de dev",
  108. " Interface bricoll'Troll en https",
  109. " Remise en marche des cartes des trajets des gowaps",
  110. "V1.2.11.5 à 7 20 & 21/12/2016",
  111. " Trace et protection sur plantage remonté par Marsak (lié à la diplo dans la vue)",
  112. "V1.2.11.4 19/12/2016",
  113. " Changement des couleurs de la barre de vie Interface Bricol'Troll",
  114. "V1.2.11.3 19/12/2016",
  115. " Correction de la récupération des PI totaux (du coup la portée de TP était NaN)",
  116. " Interface Bricol'Troll : suppression Trõlls pas mis à jour depuis plus d'un mois et grisé ceux depuis plus de 7 jours",
  117. "V1.2.11.2 18/12/2016",
  118. " Correction bug interface Bricoll'Troll, n n'était pas affiché pour les Potrolls au soleil",
  119. "V1.2.11.1 17/12/2016",
  120. " Correction bug interface Bricoll'Troll, les potrolls n'étaient pas affichés s'il n'y en avait pas au moins un",
  121. "V1.2.11 13/12/2016",
  122. " Passage sur BdD Raistlin \\o/",
  123. "V1.2.10.4 12/12/2016",
  124. " Correction bug à la récupération d'une erreur interface Bricoll'Troll",
  125. "V1.2.10.3 09/12/2016",
  126. " Adaptation à une modification du HTML MH (voir set2DViewSystem)",
  127. "V1.2.10.2 09/12/2016",
  128. " positionnement des Trõlls camou/invi à la bonne position par rapport à la distance",
  129. "V1.2.10.1 08/12/2016",
  130. " option pour affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll + peaufinage affichage",
  131. "V1.2.10 07/12/2016",
  132. " correction décumul des bonus/malus",
  133. " affichage des Trõlls {invi/camou/hors vue} avec Bricol'Troll",
  134. "V1.2.9 16/11/2016",
  135. " adaptation Firefox 50 (comportement différent sur échec Ajax https)",
  136. "V1.2.8 10/11/2016",
  137. " gestion des messages d'erreur de l'interface avec l'IT bricol'Troll",
  138. " déplacement des images sur l'infra raistlin + meilleure gestion HTTPS",
  139. "V1.2.7 07/11/2016",
  140. " remise en route de l'interface avec l'IT bricol'Troll",
  141. "V1.2.6 19/10/2016",
  142. " affichage d'un message en cas de certificat raistlin non accepté pour la vue sous https",
  143. " stockage idguilde et nomguilde",
  144. "V1.2.5 17/10/2016",
  145. " correction doublon do_cdm qui bloquait l'envoi des CdMs lors de la compétence",
  146. " remise en route de la gestion des options avec intégration md5 dans ce script",
  147. "V1.2.4 14/10/2016",
  148. " utilisation du relai raistlin pour l'envoi des CdM",
  149. "V1.2.3 :",
  150. " suppression ancien profil",
  151. " nettoyage doublon sur getPortee",
  152. " adaptation portee TP basée sur les PI",
  153. " repository sur greasyfork.org (pour être en https et avoir la mise à jour automatique active par défaut)",
  154. "V1.2.2 : correction bug sur les 2 URL raistlin qui avaient été confondues",
  155. "V1.2.1 :",
  156. " include des URLs MH alternatives",
  157. " regroupement des URLs externes en tête de fichier pour pouvoir contempler l'horreur de la diversité de la chose",
  158. " Ajout d'un message d'alerte en cas de HTTPS sans avoir débloqué le contenu mixte",
  159. "V1.2 : toujours un gros paquet sale, passage sous Greasemonkey",
  160. "V1.1 : regroupement en un gros paquet sale",
  161. ];
  162.  
  163. /**********************************************************
  164. À faire / propositions d'évolutions
  165.  
  166. breizhou13 20/12/2016
  167. envoyer les données à l'IT (Bricol'Trolls) aussi
  168. (Roule') Ça me semble diffile vis à vis de Bricol'Troll. Un bouton pour demander le rafraichissement ?
  169. partage de l'identification des tresors au sol. Ca c'etait cool mais ca implique une BDD
  170. partage des CDM avec seulement son groupe. Perso je prefere le partage general
  171. Akkila le boeuf le 26-03-2017 à 15:56
  172. - bouton pour rafraîchir les infos des trolls de son groupe
  173. Roule'
  174. Vérifier bonus double AE
  175. *urgent* corriger la façon dont les cibles de mission sont stockées (JSON très grosse table)
  176. Réactiver les jubilaires
  177. À supprimer : traces marquées [MZd] (mises pour analyser pb Tcherno Bill)
  178. 06/01/2017 toute la partie tabcompo ne fonctionne plus (sans doute suite à la modification de l'affichage des objets en tanière)
  179. - voir l'intérêt de refaire fonctionner
  180. - gestion des compos d'enchantement, EM (!), mois des champignons, autre (?)
  181. Prévision des DLA de monstre
  182. Niveau des monstres à la méthode Roule'
  183. Raistlin
  184. pages des Bonus/malus, erreur sur l'effet total, tours suivants, attaque
  185. Les cibles de mission ont disparu dans la vue (remonté par Hera)
  186. 80117 - Héra
  187. Ajout dans le vue d'un pseudo-lieu pour la caverne où le meneur d'un mission doit se rendre
  188. 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)
  189. **********************************************************/
  190.  
  191. /**********************************************************
  192. **** Début de zone à déplacer dans une bibli commune ******
  193. **********************************************************/
  194.  
  195. // URL de base serveur MZ
  196. var URL_MZ = 'http://mz.mh.raistlin.fr/mz';
  197. // pour passer en mode IP, commenter la ligne précédente et décommenter la suivante
  198. //var URL_MZ = 'http://192.99.225.92/mz';
  199.  
  200. // URLs externes images (pas de souci CORS mais pas de HTTPS)
  201. // à supprimer
  202. const newCarte = true;
  203. const URL_MZscriptCarte = "http://mountyzilla.tilk.info/scripts_0.8/carte_trajet2.php";
  204.  
  205. // URLs externes redirection (pas de souci CORS)
  206. const URL_pageNiv = 'http://mountypedia.ratibus.net/mz/niveau_monstre_combat.php';
  207. const URL_AnatrolDispas = 'http://mountyhall.dispas.net/dynamic/';
  208. const URL_vue_CCM = 'http://clancentremonde.free.fr/Vue2/RecupVue.php';
  209. const URL_vue_Gloumfs2D = 'http://gloumf.free.fr/vue2d.php';
  210. const URL_vue_Gloumfs3D = 'http://gloumf.free.fr/vue3d.php';
  211. const URL_vue_Grouky= 'http://mh.ythogtha.org/grouky.py/grouky';
  212. const URL_troc_mh = 'http://troc.mountyhall.com/search.php';
  213. const URL_cyclotrolls = 'http://www.cyclotrolls.be/';
  214. const URL_troogle = 'http://troogle.iktomi.eu/entities/';
  215.  
  216. // URLs de test HTTPS
  217. var URL_CertifRaistlin1 = URL_MZ.replace(/http:\/\//, 'https://') + '/img/1.gif'; // s'adapte si mode IP
  218. const URL_CertifRaistlin2 = 'https://it.mh.raistlin.fr/vilya/mz_json.php';
  219.  
  220. // ceux-ci rendent bien les 2 entêtes CORS (mais pas de HTTPS)
  221. var URL_bricol = 'http://trolls.ratibus.net/'; // recupération des infos des trolls dans l'IT bricol'troll
  222. const URL_bricol_https = 'https://it.mh.raistlin.fr/' // IT bricol'troll en https via relai Raistlin
  223.  
  224. // x~x Libs
  225.  
  226. /* ancien TODO
  227. * - revoir la gestion des CdM --> nott armure magique
  228. * - revoir tout ce qui est lié à la vue (estimateurs dég nott)
  229. * - vérfier la gestion des enchants
  230. */
  231.  
  232. // Roule 04/09/2016 switch extern URLs to https if available
  233. var isHTTPS = false;
  234. if (window.location.protocol.indexOf('https') === 0) {
  235. URL_MZ = URL_MZ.replace(/http:\/\//, 'https://');
  236. URL_bricol = URL_bricol_https;
  237. isHTTPS = true;
  238. }
  239.  
  240. // Roule 23/12/2016 mode dev
  241. var isDEV = false;
  242. if (window.localStorage.getItem('MZ_dev') || window.location.href.indexOf('rouletabille.mh.free.fr') > 0) {
  243. URL_MZ = URL_MZ.replace(/$/, 'dev');
  244. isDEV = true;
  245. }
  246.  
  247. // Images (pas de souci CORS)
  248. var URL_MZimg = URL_MZ + '/img/';
  249. // URLs externes ajax (CORS OK)
  250. var URL_MZinfoMonstre = URL_MZ + '/monstres_0.9_FF.php';
  251. var URL_pageDispatcherV2 = URL_MZ + '/cdmdispatcherV2.php';
  252.  
  253. // liens externes déduits
  254. var URL_bricol_mountyhall = URL_bricol + 'mountyhall/';
  255. var MHicons = '/mountyhall/Images/Icones/';
  256. // Active l'affichage des log de DEBUG (fonction debugMZ(str))
  257. var MY_DEBUG = false;
  258.  
  259. if (GM_getValue === undefined) { // éviter le blocage si pas sous GM
  260. window.console.log('*** warning *** GM_getValue n\'est pas défini (c\'est normal en test de compilation)');
  261. var GM_getValue = function(key) {};
  262. var GM_setValue = function(key, val) {};
  263. var GM_deleteValue = function(key) {};
  264. var GM_info = {script: {version: 'sans GM'}} // GM_info.script.version
  265. }
  266.  
  267. /* Utilisation de la gestion de l'enregistrement des données de
  268. GreaseMonkey, avec partage entre scripts via le localStorage, par
  269. Vapulabehemot (82169) 07/02/2017 */
  270. // Correction Roule' pour les boolean, le JSON decode pose problème car MZ utilise JSON
  271. // Nécessite la présence de @grant GM_getValue, @grant GM_deleteValue et @grant GM_setValue
  272. function MY_getValue(key) {
  273. var v = window.localStorage.getItem(key);
  274. vGM = GM_getValue(key);
  275. if ((vGM == null)
  276. || (v != null && v != vGM)){
  277. GM_setValue(key, v);
  278. } else if (v == null && vGM != null) {
  279. v = vGM;
  280. window.localStorage[key] = vGM;
  281. }
  282. return v;
  283. }
  284. function MY_removeValue(key) {
  285. GM_deleteValue(key);
  286. window.localStorage.removeItem(key);
  287. }
  288. function MY_setValue(key, val) {
  289. if (val === true) // conversion des booléens en 0 ou 1 à cause du localStorage infoutu de gérer les booléens
  290. val = 1;
  291. else if (val === false)
  292. val = 0;
  293. GM_setValue(key, val);
  294. window.localStorage[key] = val;
  295. }
  296.  
  297. /*---------------- mise à jour de variables globales utiles ------------------*/
  298. // utilisé pour accès bdd (un peu partout) :
  299. var numTroll = MY_getValue('NUM_TROLL');
  300. // utilisé dans vue pour PX :
  301. var nivTroll = MY_getValue('NIV_TROLL');
  302. // Roule 20/04/2017 le niveau n'est plus dans la frame de gauche, on récupère dans <numtroll>.niveau
  303. if (nivTroll == undefined) nivTroll = MY_getValue(numTroll + '.niveau');
  304. // utilisés dans actions et vue (calculs SR) :
  305. var mmTroll = MY_getValue(numTroll+'.caracs.mm');
  306. var rmTroll = MY_getValue(numTroll+'.caracs.rm');
  307. var currentURL = window.location.href;
  308.  
  309. /*-[functions]------------ Fonctions durée de script -------------------------*/
  310. var date_debut = null;
  311.  
  312. function start_script(nbJours_exp) {
  313. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] début sur ' + window.location.pathname);
  314. if(date_debut) return;
  315. date_debut = new Date();
  316. // Créé la variable expdate si demandé
  317. if(nbJours_exp) {
  318. expdate = new Date();
  319. expdate.setTime(expdate.getTime()+nbJours_exp*864e5);
  320. }
  321. }
  322.  
  323. function displayScriptTime() {
  324. var footerNode = document.getElementById('footer2');
  325. if(!footerNode) return;
  326. try{
  327. var node = document.evaluate(
  328. ".//text()[contains(.,'Page générée en')]/../br",
  329. footerNode,null,9,null).singleNodeValue;
  330. }
  331. catch(e){return;}
  332. insertText(node,
  333. ' - [Script exécuté en '
  334. +(new Date().getTime()-date_debut.getTime())/1000+' sec.]');
  335. if(MY_DEBUG) window.console.log('[MZ ' + GM_info.script.version + '] fin sur ' + window.location.pathname);
  336. }
  337.  
  338. function traceStack(e, sModule) {
  339. var version = '';
  340. if (GM_info && GM_info.script && GM_info.script.version)
  341. version = ' ' + GM_info.script.version;
  342. sRet = '[MZ' + version + ']'
  343. if (sModule) sRet += ' {' + sModule + '}';
  344. if (e.message) sRet += ' ' + e.message;
  345. if (e.stack) {
  346. var sStack = e.stack;
  347. // enlever les infos confidentielles
  348. sRet += "\n" + sStack.replace(/file\:\/\/.*gm_scripts/ig, '...');
  349. }
  350. return sRet;
  351. }
  352.  
  353. /*-[functions]---------- DEBUG: Communication serveurs -----------------------*/
  354.  
  355. function debugMZ(str){
  356. if(MY_DEBUG){
  357. window.console.debug('[MY_DEBUG] '+str);
  358. if(typeof str === "object"){
  359. window.console.debug(str);
  360. }
  361. }
  362. }
  363.  
  364. function FF_XMLHttpRequest(MY_XHR_Ob) {
  365. var request = new XMLHttpRequest();
  366. request.open(MY_XHR_Ob.method,MY_XHR_Ob.url);
  367. for(var head in MY_XHR_Ob.headers) {
  368. request.setRequestHeader(head,MY_XHR_Ob.headers[head]);
  369. }
  370. request.onreadystatechange = function() {
  371. //window.console.log('XMLHttp readystatechange url=' + MY_XHR_Ob.url + ', readyState=' + request.readyState + ', error=' + request.error + ', status=' + request.status);
  372. if(request.readyState!=4) { return; }
  373. if(request.error) {
  374. if(MY_XHR_Ob.onerror) {
  375. MY_XHR_Ob.onerror(request);
  376. }
  377. }
  378. else if(MY_XHR_Ob.onload) {
  379. /* DEBUG: Ajouter à request les pptés de MY_XHR_Ob à transmettre */
  380. MY_XHR_Ob.onload(request);
  381. }
  382. };
  383. request.send(MY_XHR_Ob.data);
  384. }
  385.  
  386.  
  387. /*-[functions]-------------- Interface utilisateur ---------------------------*/
  388.  
  389. // http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
  390. function copyTextToClipboard(text) {
  391. var textArea = document.createElement("textarea");
  392.  
  393. //
  394. // *** This styling is an extra step which is likely not required. ***
  395. //
  396. // Why is it here? To ensure:
  397. // 1. the element is able to have focus and selection.
  398. // 2. if element was to flash render it has minimal visual impact.
  399. // 3. less flakyness with selection and copying which **might** occur if
  400. // the textarea element is not visible.
  401. //
  402. // The likelihood is the element won't even render, not even a flash,
  403. // so some of these are just precautions. However in IE the element
  404. // is visible whilst the popup box asking the user for permission for
  405. // the web page to copy to the clipboard.
  406. //
  407.  
  408. // Place in top-left corner of screen regardless of scroll position.
  409. textArea.style.position = 'fixed';
  410. textArea.style.top = 0;
  411. textArea.style.left = 0;
  412.  
  413. // Ensure it has a small width and height. Setting to 1px / 1em
  414. // doesn't work as this gives a negative w/h on some browsers.
  415. textArea.style.width = '2em';
  416. textArea.style.height = '2em';
  417.  
  418. // We don't need padding, reducing the size if it does flash render.
  419. textArea.style.padding = 0;
  420.  
  421. // Clean up any borders.
  422. textArea.style.border = 'none';
  423. textArea.style.outline = 'none';
  424. textArea.style.boxShadow = 'none';
  425.  
  426. // Avoid flash of white box if rendered for any reason.
  427. textArea.style.background = 'transparent';
  428.  
  429. textArea.value = text;
  430.  
  431. document.body.appendChild(textArea);
  432.  
  433. textArea.select();
  434.  
  435. var successful = document.execCommand('copy');
  436.  
  437. document.body.removeChild(textArea);
  438. return successful;
  439. }
  440.  
  441. function avertissement(txt,duree) {
  442. window.console.log('[MZ] affichage avertissement ' + txt + (duree ? ' pour (' + duree + ' ms)' : ''));
  443. if(!duree) duree = 15000;
  444. var div = document.createElement('div');
  445. // On numérote les avertissements pour destruction sélective
  446. var num = document.getElementsByName('avertissement').length;
  447. div.num = num;
  448. // Numéro enregistré dans le DOM pour récupération sur getElementsByName()
  449. div.setAttribute('name','avertissement');
  450. div.className = 'mh_textbox';
  451. div.style.position = 'fixed';
  452. div.style.top = (10+15*num)+'px';
  453. div.style.left = (10+5*num)+'px';
  454. div.style.border = '5px solid red';
  455. div.style.zIndex = 2+num;
  456. div.style.cursor = 'pointer';
  457. div.style.fontSize = 'large';
  458. div.innerHTML = txt;
  459. div.onclick=function(){ tueAvertissement(this.num) };
  460.  
  461. // un croix en haut à droite pour signifier à l'utilisateur qu'il peut cliquer pour fermer ce popup
  462. var divcroix = document.createElement('div');
  463. divcroix.style.position = 'absolute';
  464. divcroix.style.top = 0;
  465. divcroix.style.right = 0;
  466. divcroix.style.color = 'black';
  467. divcroix.style.fontSize = 'inherit';
  468. divcroix.style.cursor = 'pointer'
  469. divcroix.style.zIndex = 2+num;
  470. divcroix.innerHTML = "X";
  471. div.appendChild(divcroix);
  472.  
  473. document.body.appendChild(div);
  474. // Destruction automatique de l'avertissement après "un certain temps"
  475. window.setTimeout(function(){ tueAvertissement(num) },duree);
  476. }
  477.  
  478. function tueAvertissement(num) {
  479. var divs = document.getElementsByName('avertissement');
  480. if(divs.length==0) { return; }
  481. for(var i=0 ; i<divs.length ; i++) {
  482. if(divs[i].num==num) {
  483. divs[i].parentNode.removeChild(divs[i]);
  484. return;
  485. }
  486. }
  487. }
  488.  
  489.  
  490. /*-[functions]-------------- Modifications du DOM ----------------------------*/
  491.  
  492. function insertBefore(next,el) {
  493. next.parentNode.insertBefore(el,next);
  494. }
  495.  
  496. function appendTr(tbody,clas) {
  497. var tr = document.createElement('tr');
  498. if(clas) tr.className = clas;
  499. tbody.appendChild(tr);
  500. return tr;
  501. }
  502.  
  503. function insertTr(next,clas) {
  504. var tr = document.createElement('tr');
  505. if(clas) tr.className = clas;
  506. insertBefore(next,tr);
  507. return tr;
  508. }
  509.  
  510. function appendTd(tr) {
  511. var td = document.createElement('td');
  512. if(tr) tr.appendChild(td);
  513. return td;
  514. }
  515.  
  516. function insertTd(next) {
  517. var td = document.createElement('td');
  518. insertBefore(next,td);
  519. return td;
  520. }
  521.  
  522. function appendTdCenter(tr,colspan) {
  523. var td = appendTd(tr);
  524. td.align = 'center'; // WARNING - Obsolete
  525. if(colspan) td.colSpan = colspan;
  526. return td;
  527. }
  528.  
  529. function insertTdElement(next,el) {
  530. var td = insertTd(next);
  531. if(el) td.appendChild(el);
  532. return td;
  533. }
  534.  
  535. function appendA(paren,href,cssClass,text) {
  536. var a = document.createElement('a');
  537. if (href) a.href = href;
  538. if (cssClass) a.className = cssClass;
  539. if (text) a.appendChild(document.createTextNode(text));
  540. paren.appendChild(a);
  541. }
  542.  
  543. function appendText(paren,text,bold) {
  544. if(bold) {
  545. var b = document.createElement('b');
  546. b.appendChild(document.createTextNode(text));
  547. paren.appendChild(b);
  548. }
  549. else
  550. paren.appendChild(document.createTextNode(text));
  551. }
  552.  
  553. function insertText(next,text,bold) {
  554. if(bold) {
  555. var b = document.createElement('b');
  556. appendText(b,text);
  557. insertBefore(next,b);
  558. }
  559. else
  560. insertBefore(next,document.createTextNode(text));
  561. }
  562.  
  563. function appendTdText(tr,text,bold) {
  564. var td = appendTd(tr);
  565. appendText(td,text,bold);
  566. return td;
  567. }
  568.  
  569. function insertTdText(next,text,bold) {
  570. var td = insertTd(next);
  571. appendText(td,text,bold);
  572. return td;
  573. }
  574.  
  575. function appendBr(paren) {
  576. paren.appendChild(document.createElement('br'));
  577. }
  578.  
  579. function insertBr(next) {
  580. insertBefore(next,document.createElement('br'));
  581. }
  582.  
  583. function appendLI(ul,text) {
  584. // uniquement utilisé dans les options (crédits)
  585. var li = document.createElement('li');
  586. appendText(li,text);
  587. ul.appendChild(li);
  588. return li;
  589. }
  590.  
  591. function appendTextbox(paren,type,nam,size,maxlength,value) {
  592. var input = document.createElement('input');
  593. input.className = 'TextboxV2';
  594. input.type = type;
  595. input.name = nam;
  596. input.id = nam;
  597. input.size = size;
  598. input.maxLength = maxlength;
  599. if(value) input.value = value;
  600. paren.appendChild(input);
  601. return input;
  602. }
  603.  
  604. function appendCheckBox(paren,nam,checked,onClick) {
  605. var input = document.createElement('input');
  606. input.type = 'checkbox';
  607. input.name = nam;
  608. input.id = nam;
  609. if(checked) input.checked = true;
  610. if(onClick) input.onclick = onClick;
  611. paren.appendChild(input);
  612. return input;
  613. }
  614.  
  615. function appendNobr(paren,id,delgg,text) {
  616. var nobr = document.createElement('nobr');
  617. appendCheckBox(nobr,id,null,delgg);
  618. appendText(nobr,text);
  619. paren.appendChild(nobr);
  620. appendText(paren,' ');
  621. return nobr;
  622. }
  623.  
  624. function appendCheckBoxSpan(paren,id,onClick,text) {
  625. var span = document.createElement('span');
  626. span.style.whiteSpace = 'nowrap';
  627. appendCheckBox(span,id,false,onClick);
  628. var label = document.createElement('label');
  629. appendText(label,text);
  630. label.htmlFor = id;
  631. label.style.marginLeft = '-5px';
  632. span.appendChild(label);
  633. span.style.marginRight = '3px';
  634. paren.appendChild(span);
  635. appendText(paren, ' ');
  636. return span;
  637. }
  638.  
  639. function appendOption(select,value,text) {
  640. var option = document.createElement('option');
  641. option.value = value;
  642. appendText(option,text);
  643. select.appendChild(option);
  644. return option;
  645. }
  646.  
  647. function appendHidden(form,nam,value) {
  648. var input = document.createElement('input');
  649. input.type = 'hidden';
  650. input.name = nam;
  651. input.id = nam;
  652. input.value = value;
  653. form.appendChild(input);
  654. }
  655.  
  656. function appendButton(paren,value,onClick) {
  657. var input = document.createElement('input');
  658. input.type = 'button';
  659. input.className = 'mh_form_submit';
  660. input.value = value;
  661. input.onmouseover = function(){this.style.cursor='pointer';};
  662. if(onClick) input.onclick = onClick;
  663. paren.appendChild(input);
  664. return input;
  665. }
  666.  
  667. function insertButton(next,value,onClick) {
  668. var input = document.createElement('input');
  669. input.type = 'button';
  670. input.className = 'mh_form_submit';
  671. input.value = value;
  672. input.onmouseover = function(){this.style.cursor='pointer';};
  673. input.onclick = onClick;
  674. insertBefore(next,input);
  675. return input;
  676. }
  677.  
  678. function appendSubmit(paren,value,onClick) {
  679. var input = document.createElement('input');
  680. input.type = 'submit';
  681. input.className = 'mh_form_submit';
  682. input.value = value;
  683. input.onmouseover = function(){this.style.cursor='pointer';};
  684. if(onClick) input.onclick = onClick;
  685. paren.appendChild(input);
  686. return input;
  687. }
  688.  
  689. function createImage(url,title,style) {
  690. var img = document.createElement('img');
  691. img.src = url;
  692. img.title = title;
  693. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  694. if (style) img.style = style;
  695. return img;
  696. }
  697.  
  698. function createAltImage(url,alt,title) {
  699. var img = document.createElement('img');
  700. img.src = url;
  701. img.alt = alt;
  702. if (title) img.title = title;
  703. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  704. return img;
  705. }
  706.  
  707. function createImageSpan(url,alt,title,text,bold) {
  708. var span = document.createElement('span');
  709. span.title = title;
  710. var img = document.createElement('img');
  711. img.src = url;
  712. img.alt = alt;
  713. img.align = 'absmiddle'; // WARNING - Obsolete in HTML5.0
  714. span.appendChild(img);
  715. appendText(span,text,bold);
  716. return span;
  717. }
  718.  
  719. function createCase(titre,table,width) {
  720. if(!width) width=120;
  721. var tr = appendTr(table,'mh_tdpage');
  722. var td = appendTdText(tr,titre,true);
  723. td.className = 'mh_tdtitre';
  724. td.width = width;
  725. td = appendTdText(tr,'');
  726. td.className = 'mh_tdpage';
  727. return td;
  728. }
  729.  
  730. function getMyID(e) {
  731. var parent = e.parentNode;
  732. for(var i=0 ; i<parent.childNodes.length ; i++) {
  733. if(e==parent.childNodes[i])
  734. return i;
  735. }
  736. return -1;
  737. }
  738.  
  739. function insertAfter(elt,newElt) {
  740. var id = getMyID(elt);
  741. if(id==-1) return;
  742. if(id<elt.parentNode.childNodes.length-1)
  743. insertBefore(elt.nextSibling,newElt);
  744. else
  745. elt.parentNode.appendChild(newElt);
  746. }
  747.  
  748.  
  749. /*-[functions]------- Fonctions de mise en forme du texte --------------------*/
  750.  
  751. function aff(nb) {
  752. return (nb>=0) ? '+'+nb : nb;
  753. }
  754.  
  755. function getNumber(str) {
  756. var nbr = str.match(/\d+/);
  757. return nbr ? Number(nbr[0]) : Number.NaN;
  758. }
  759.  
  760. function getNumbers(str) {
  761. var nbrs = str.match(/-?\d+/g);
  762. if (!nbrs) return [];
  763. for(var i=0 ; i<nbrs.length ; i++)
  764. nbrs[i] = Number(nbrs[i]);
  765. return nbrs;
  766. }
  767.  
  768. function trim(str) {
  769. return str.replace(/(^\s*)|(\s*$)/g,'');
  770. }
  771.  
  772. String.prototype.trim = function() {
  773. return this.replace(/^\s+/,'').replace(/\s+$/,'');
  774. }
  775.  
  776. function epure(texte) {
  777. return texte.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  778. .replace(/[ç]/g,'c')
  779. .replace(/[éêèë]/g,'e')
  780. .replace(/[ïî]/g,'i')
  781. .replace(/[ôöõ]/g,'o')
  782. .replace(/[ùûü]/g,'u');
  783. }
  784.  
  785. String.prototype.epure = function () {
  786. return this.replace(/[àâä]/g,'a').replace(/Â/g,'A')
  787. .replace(/[ç]/g,'c')
  788. .replace(/[éêèë]/g,'e')
  789. .replace(/[ïî]/g,'i')
  790. .replace(/[ôöõ]/g,'o')
  791. .replace(/[ùûü]/g,'u');
  792. }
  793.  
  794. function bbcode(texte) {
  795. return texte.replace(/&/g,'&amp;')
  796. .replace(/"/g,'&quot;')
  797. .replace(/</g,'&lt;')
  798. .replace(/>/g,'&gt;')
  799. .replace(/'/g,'&#146;')
  800. .replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>')
  801. .replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>')
  802. .replace(/\[img\]([^"]*?)\[\/img\]/g,'<img src="$1" />');
  803. }
  804.  
  805.  
  806. /*-[functions]------- Gestion / Transformation des Dates ---------------------*/
  807.  
  808. function addZero(i) {
  809. return (i<10) ? '0'+i : i;
  810. }
  811.  
  812. function DateToString(date) {
  813. return addZero(date.getDate())+'/'+addZero(date.getMonth()+1)
  814. +'/'+date.getFullYear()+' '+addZero(date.getHours())
  815. +':'+addZero(date.getMinutes())+':'+addZero(date.getSeconds());
  816. }
  817.  
  818. function StringToDate(str) {
  819. return str.replace(/([0-9]+)\/([0-9]+)/,"$2/$1");
  820. }
  821.  
  822. // fonctionne aussi avec datetime
  823. function SQLDateToFrench(str) {
  824. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+)/,"$3/$2/$1");
  825. }
  826.  
  827. // ... et ajoute un "à" du plus bel effet
  828. function SQLDateToFrenchTime(str) {
  829. return str.replace(/([0-9]+)\-([0-9]+)\-([0-9]+) /,"$3/$2/$1 à ");
  830. }
  831.  
  832. // SQLDate vers objet date Javascript
  833. function SQLDateToObject(str) {
  834. var t = str.split(/[- :]/);
  835. return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
  836. }
  837.  
  838. var mz_ie = (window.attachEvent)? true:false;
  839. if ("function" !== typeof addEvent) {
  840. if (mz_ie) {
  841. function addEvent(obj, typ, fn, sens) {
  842. obj["e"+typ+fn] = fn; obj[typ+fn] = function() {
  843. obj["e"+typ+fn]( window.event );
  844. }
  845. obj.attachEvent("on"+typ, obj[typ+fn] );
  846. }
  847. }
  848. else {
  849. function addEvent(obj, typ, fn, sens) {
  850. obj.addEventListener(typ, fn, sens);
  851. }
  852. }
  853. }
  854.  
  855. /**********************
  856. * glissière en mode objet
  857. * Roule 29/12/2016 à partir du code des trajets gowap doCallback_glissiere et Vapulabehemot
  858. * Une glissière est un curseur permettant, par exemple de changer le zoom des cartes
  859. *
  860. * Usage:
  861. * gliss = new glissiere_MZ(ref, labelHTML, target, bDynamic);
  862. * ref : utilisé pour diversifier les IDs HTML
  863. * labelHTML : le label qui apparaît devant la glissière (peut contenir des balises HTML)
  864. * target : peut être de 3 types
  865. * - élément HTML : l'élément HTML à zoomer
  866. * - string : l'ID de l'élément à zoomer (qui doit exister au moment de la création de la glissière
  867. * - function : callback quand le curseur bouge
  868. * bDynamic : par défaut, le fonctionnement n'est pas dynamique (la callback est appellé au click)
  869. * dans le mode dynamique, la callback est appelée sur mouseMove
  870. * valDef : valeur par défaut si l'outil n'a jamais été utilisé
  871. * valMin, valMax : les valeurs entre lesquelles le curseur varie
  872. * autres méthodes
  873. * gliss.getElt(); // rend la div de la glissière (par exemple pour la positionner)
  874. **********************/
  875.  
  876. function glissiere_MZ(ref, labelHTML, paramTarget, bDynamic, valDef, valMin, valMax) {
  877. try {
  878. var mouseDown = false;
  879. var div_gliss = document.createElement("div"); // la DIV mère
  880. div_gliss.id = "MZ_gliss_"+ref;
  881. var div_label = document.createElement("span"); // le label
  882. div_label.innerHTML = labelHTML;
  883. div_gliss.appendChild(div_label);
  884. div_gliss.className = "choix_zoom";
  885. var dessin = document.createElement("canvas"); // le dessin lui-même
  886. dessin.id = "MZ_gliss_dessin_"+ref;
  887. dessin.style.cursor = "pointer";
  888. dessin.width = 104;
  889. dessin.height = 12;
  890. dessin.style.marginLeft = '2px';
  891. dessin.style.marginRight = '2px';
  892. div_gliss.appendChild(dessin);
  893. var pourcent = document.createElement("span"); // le pourcentage
  894. pourcent.id = "MZ_gliss_pourcent_"+ref;
  895. var pourcent_text = document.createTextNode('');
  896. var previousVal;
  897. var flouPourCurseurDoubleFleche = (valMax - valMin) / 40;
  898.  
  899. // alignement vertical
  900. dessin.style.verticalAlign = 'middle';
  901. div_label.style.verticalAlign = 'middle';
  902. pourcent.style.verticalAlign = 'middle';
  903.  
  904. pourcent.appendChild(pourcent_text);
  905. div_gliss.appendChild(pourcent);
  906.  
  907. var bulle_pourcent = document.createElement("div"); // la bulle
  908. bulle_pourcent.id = "MZ_gliss_bulle_"+ref;
  909. bulle_pourcent.style.display = 'block';
  910. bulle_pourcent.style.visibility = 'hidden';
  911. bulle_pourcent.style.position = 'absolute';
  912. bulle_pourcent.style.zIndex = 3500;
  913. bulle_pourcent.style.border = '1px solid #a1927f';
  914. var bulle_pourcent_text = document.createTextNode('');
  915. bulle_pourcent.appendChild(bulle_pourcent_text);
  916. document.body.appendChild(bulle_pourcent);
  917.  
  918. this.getElt = function() {return div_gliss;};
  919.  
  920. ////////////////////////////////////
  921. // dessine et redessine le curseur
  922. ////////////////////////////////////
  923. var dessine_glissiere = function(val) {
  924. pos_0_100 = ((val - valMin) * 100) / (valMax - valMin);
  925. var ctx = dessin.getContext('2d');
  926. ctx.clearRect(0, 0,104, 12);
  927. ctx.fillStyle = "rgb(0,0,0)";
  928. ctx.fillRect(0,0,2,12);
  929. ctx.fillRect(102,0,2,12);
  930. ctx.fillRect(0,5,104,2);
  931.  
  932. ctx.fillStyle = "rgb(80,80,80)";
  933. ctx.fillRect(pos_0_100,0,5,12);
  934. ctx.fillStyle = "rgb(200,200,200)";
  935. ctx.fillRect(pos_0_100+1,1,3,10);
  936. pourcent_text.nodeValue = val+'%';
  937. previousVal = parseInt(val);
  938. };
  939.  
  940. ////////////////////////////////////
  941. // action sur mousedown et mousemove
  942. // stocker la nouvelle valeur
  943. // redessiner
  944. // afficher la nouvelle valeur
  945. // action selon ce qui a été demandé
  946. ////////////////////////////////////
  947. var doCallback_glissiere = function (evt) {
  948. try {
  949. if (evt.type === 'mousedown') mouseDown = true;
  950. if (evt.offsetX) {
  951. var xsouris = evt.offsetX;
  952. var xpos = evt.clientX;
  953. var ypos = evt.clientY + document.body.scrollTop;
  954. }
  955. else {
  956. var xsouris = evt.layerX;
  957. var xpos = evt.pageX;
  958. var ypos = evt.pageY;
  959. }
  960. var val = Math.floor(Math.min(valMax,Math.max(valMin,((xsouris-1) * (valMax - valMin) / 100)+valMin)));
  961. dessin.style.cursor = (val <= (previousVal+flouPourCurseurDoubleFleche) && val >= (previousVal-flouPourCurseurDoubleFleche)) ? "e-resize":"pointer";
  962. // afficher la nouvelle valeur dans la bulle
  963. bulle_pourcent_text.nodeValue = val + '%';
  964. bulle_pourcent.style.top = (ypos+3)+'px';
  965. bulle_pourcent.style.left = (xpos+16)+'px';
  966. if (evt.buttons === undefined) {
  967. // mode utilisant les evt mouseup/down (mauvaise méthode, utilisé si on ne peut pas faire autrement)
  968. if (!mouseDown) return; // simple survol, on ne fait rien de plus
  969. } else {
  970. if (!(evt.buttons & 1)) return; // simple survol, on ne fait rien de plus
  971. }
  972. // stocker la nouvelle valeur
  973. MY_setValue("MZ_glissiere_" + ref, val);
  974. // redessiner la glissière avec le curseur où il faut
  975. dessine_glissiere(val);
  976. // action selon ce qui a été demandé
  977. //for(var key in evt) window.console.log('evt key ' + key + ' => ' + evt[key]);
  978. if ((!bDynamic) && (evt.type !== 'mousedown')) return;
  979. if (typeof paramTarget === 'object') {
  980. var elt = paramTarget;
  981. } else if (typeof paramTarget === 'string') {
  982. var elt = document.getElementById(paramTarget);
  983. } else if (typeof paramTarget === 'function') {
  984. paramTarget(val);
  985. return;
  986. }
  987. if (elt.setZoom != undefined) elt.setZoom(val);
  988. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ.doCallback'))}
  989. };
  990.  
  991. ////////////////////////////////////
  992. // event mousedown et mousemove : redessiner et callback
  993. ////////////////////////////////////
  994. addEvent(dessin, "mousedown", doCallback_glissiere, true);
  995. addEvent(dessin, "mousemove", doCallback_glissiere, true);
  996. ////////////////////////////////////
  997. // event mouseup : mémoriser mouseup (utile seulement si le navigateur ne supporte pas evt.buttons
  998. ////////////////////////////////////
  999. addEvent(dessin, "mouseup", function() {mouseDown = false;}, true);
  1000. ////////////////////////////////////
  1001. // event mouseout & mouseover : afficher/cacher la bulle
  1002. ////////////////////////////////////
  1003. addEvent(dessin, "mouseout", function() {bulle_pourcent.style.visibility="hidden";}, true);
  1004. addEvent(dessin, "mouseover", function() {bulle_pourcent.style.visibility="visible";}, true);
  1005.  
  1006. ////////////////////////////////////
  1007. // dessiner la première fois
  1008. ////////////////////////////////////
  1009. var val_init = MY_getValue("MZ_glissiere_" + ref);
  1010. if (val_init === undefined) val_init = valDef;
  1011. dessine_glissiere(val_init);
  1012. } catch (e) {window.console.log(traceStack(e, 'glissiere_MZ'))}
  1013. }
  1014.  
  1015. // calcul du point intermédiaire de déplacement gowap (x et y uniquement)
  1016. // reçoit 2 objets avec des propriétés x et y
  1017. // rend un objet avec x et y (rend undefined si le trajet est direct)
  1018. function pointIntermediaireMonstre2D(locDepart, locArrivee) {
  1019. var deltaX = locArrivee.x - locDepart.x;
  1020. if (deltaX == 0) return; // pas de point intermédiaire
  1021. var deltaY = locArrivee.y - locDepart.y;
  1022. if (deltaY == 0) return; // pas de point intermédiaire
  1023. var absDeltaX = Math.abs(deltaX);
  1024. var absDeltaY = Math.abs(deltaY);
  1025. if (absDeltaX > absDeltaY) {
  1026. return {x: locDepart.x + Math.sign(deltaX) * Math.sign(deltaY) * deltaY, y: locArrivee.y};
  1027. } else if (absDeltaY > absDeltaX) {
  1028. return {x: locArrivee.x, y: locDepart.y + Math.sign(deltaX) * Math.sign(deltaY) * deltaX};
  1029. } else {
  1030. return; // égalité, pas de point intermédiaire
  1031. }
  1032. }
  1033.  
  1034. /**********************
  1035. * carte en mode objet
  1036. * Roule 14/01/2017 à partir du code des trajets gowap de Vapulabehemot
  1037. *
  1038. * Usage:
  1039. * carte = new carte_MZ(ref, tabDepl);
  1040. * ref : utilisé pour diversifier les IDs HTML
  1041. * tabDepl : table de tables d'objets contenant x, y et n (positions successives des différents suivants)
  1042. * pour l'affichage, le premier objet doit contenir nom et id (et typ pour des cibles particulières)
  1043. * autres méthodes
  1044. * carte.getElt(); // rend la div de la carte (par exemple pour la positioner dans la page)
  1045. **********************/
  1046.  
  1047. function carte_MZ(ref, tabDepl) {
  1048. try {
  1049. var div1_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1050. div1_carte.id = "MZ_carte_"+ref;
  1051. div1_carte.className = "mh_tdpage"; // le mh_tdpage sert à faire cacher la carte par les scripts trajet_gowap
  1052. div1_carte.style.backgroundImage = 'none';
  1053. div1_carte.style.backgroundColor = 'transparent';
  1054. var div2_carte = document.createElement("div"); // la DIV mère. Elle prend toute la largeur
  1055. div2_carte.className = "carte_MZ";
  1056. div2_carte.style.display = 'inline-block'; // pour que la div ait la taille du contenu
  1057. var dessin = document.createElement("canvas"); // le dessin lui-même
  1058. dessin.id = "MZ_carte_dessin_"+ref;
  1059. dessin.style.backgroundImage = 'url("/mountyhall/MH_Packs/packMH_parchemin/tableau/tableau1.jpg")';
  1060. div1_carte.appendChild(div2_carte);
  1061. div2_carte.appendChild(dessin);
  1062.  
  1063. var position_trous_MZ = [[-70.5, -7.5, 2, 1.5, -69] // x, y, ?, rayon du cercle, profondeur
  1064. , [-66.5, -37.5, 2, 1.5, -69]
  1065. , [-63.5, 8.5, 2, 1.5, -69]
  1066. , [-59.5, -32.5, 2, 1.5, -69]
  1067. , [-52, 57, 0.25, 0.8, -59]
  1068. , [-50.5, -22.5, 2, 1.5, -69]
  1069. , [-35.5, -51.5, 2, 1.5, -69]
  1070. , [-34.5, 14.5, 2, 1.5, -69]
  1071. , [-34.5, 64.5, 2, 1.5, -69]
  1072. , [-11.5, 72.5, 2, 1.5, -69]
  1073. , [5.5, -49.5, 2, 1.5, -69]
  1074. , [5.5, 31.5, 2, 1.5, -69]
  1075. , [10.5, 63.5, 2, 1.5, -69]
  1076. , [12, -15, 0.25, 0.8, -59]
  1077. , [21.5, 35.5, 2, 1.5, -69]
  1078. , [30, -52, 0.25, 0.8, -59]
  1079. , [46.5, 51.5, 2, 1.5, -69]
  1080. , [48, -39, 0.25, 0.8, -59]
  1081. , [55, 70, 0.25, 0.8, -59] // correction Roule 10/10/2016 -59 au lieu de -69
  1082. , [56.5, 23.5, 75, 8.7, -99]
  1083. , [64, 70, 0.25, 0.8, -59]
  1084. , [74.5, 31.5, 2, 1.5, -69]];
  1085.  
  1086. var couleur_depl_normal = 'rgba(0,0,200,0.5)';
  1087. var couleur_cible = 'rgba(0,0,0,0.5)';
  1088. var couleur_depl_collision_trou = 'rgba(150,0,0, 0.5)';
  1089. var couleur_trou = 'rgb(200,0,0)';
  1090.  
  1091. var coord_x = function(val) {
  1092. return decalh+coeff*(val+100);
  1093. };
  1094. var coord_y = function(val) {
  1095. return decalv+coeff*(100-val);
  1096. };
  1097.  
  1098. var ctx = dessin.getContext('2d');
  1099. var coeff = MY_getValue("MZ_glissiere_" + ref); // ce qui a été sauvé précédement par la glissiere
  1100. if (coeff) coeff /= 50;
  1101. else coeff = 2;
  1102. var decalv=30, decalh=30;
  1103.  
  1104. var detecteCollisionTrou = function (pos0, pos1) { // fonction volée à feldspath et Vapulabehemot, merci à eux (voir calc_inter dans Trajet_Gowap)
  1105. //var res = false
  1106. var x0 = pos0.x;
  1107. var y0 = pos0.x;
  1108. var tmax = Math.max(Math.abs(pos1.x - pos0.x), Math.abs(pos1.y - pos0.y));
  1109. var px = Math.sign(pos1.x - pos0.x);
  1110. var py = Math.sign(pos1.y - pos0.y);
  1111. var a = 0, b = 0, c = 0, delta = 0, t0 = 0, t1 = 0;
  1112. //window.console.log('verif collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1113.  
  1114. for(var k in position_trous_MZ) {
  1115. a = parseFloat(px*px+py*py);
  1116. b = parseFloat((x0-position_trous_MZ[k][0])*px+(y0-position_trous_MZ[k][1])*py);
  1117. 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]);
  1118. delta = b*b-a*c
  1119. if(delta >= 0) {
  1120. t0 = Math.ceil(-b/a-Math.sqrt(delta)/a);
  1121. t1 = Math.floor(-b/a+Math.sqrt(delta)/a);
  1122. if(t0 <= tmax && t1 >= 0) {
  1123. // 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
  1124. //res = true;
  1125. //window.console.log('***** collision gowap-trou [x0=' + x0 + ',y0=' + y0 + ', px=' + px + ', py=' + py + ', tmax=' + tmax + ']');
  1126. for(var l=Math.max(0,t0); l<=Math.min(tmax,t1); l++) {
  1127. //window.console.log('***** collision gowap-trou en ' + (x0+l*px) + ', ' + (y0+l*py));
  1128. // Roule : pas utile pour nous
  1129. //res = true;
  1130. //chute.push([x0+l*px, y0+l*py]);
  1131. return true;
  1132. }
  1133. }
  1134. }
  1135. }
  1136. //return res;
  1137. return false;
  1138. };
  1139.  
  1140. var dessine_carte = function () {
  1141. dessin.width = 200*coeff+2*decalh;
  1142. dessin.height = 200*coeff+2*decalv;
  1143.  
  1144. //repere
  1145. ctx.beginPath();
  1146. ctx.moveTo(coord_x(0), coord_y(100));
  1147. ctx.lineTo(coord_x(0), coord_y(-100));
  1148. ctx.moveTo(coord_x(-100), coord_y(0));
  1149. ctx.lineTo(coord_x(100), coord_y(0));
  1150. ctx.stroke();
  1151. ctx.strokeRect(coord_x(-100), coord_y(100), coord_x(100) - coord_x(-100), coord_y(-100) - coord_y(100));
  1152.  
  1153. //trous
  1154. ctx.fillStyle = couleur_trou;
  1155. for(var i in position_trous_MZ) {
  1156. ctx.beginPath();
  1157. 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);
  1158. ctx.fill();
  1159. }
  1160. // trajets
  1161. ctx.lineCap = "round";
  1162. ctx.lineJoin = "round";
  1163. for (var iSuivant in tabDepl) {
  1164. //window.console.log('carte_MZ, suivant n°' + iSuivant);
  1165. var tabDeplOneSuivant = tabDepl[iSuivant];
  1166. var x0 = coord_x(tabDeplOneSuivant[0].x);
  1167. var y0 = coord_y(tabDeplOneSuivant[0].y);
  1168. // La "cible" au départ
  1169. var typeDepart = tabDeplOneSuivant[0].typ;
  1170. switch (typeDepart) {
  1171. case 'tp':
  1172. ctx.beginPath();
  1173. ctx.lineWidth = 2;
  1174. ctx.strokeStyle = couleur_cible;
  1175. ctx.fillStyle = couleur_cible;
  1176. ctx.moveTo(x0 + coeff * 3, y0 + coeff * 3);
  1177. ctx.lineTo(x0 + coeff * 3, y0 - coeff * 3);
  1178. ctx.lineTo(x0 - coeff * 3, y0 - coeff * 3);
  1179. ctx.lineTo(x0 - coeff * 3, y0 + coeff * 3);
  1180. ctx.lineTo(x0 + coeff * 3, y0 + coeff * 3);
  1181. ctx.moveTo(x0 + coeff * 3, y0);
  1182. ctx.lineTo(x0 - coeff * 3, y0);
  1183. ctx.moveTo(x0, y0 + coeff * 3);
  1184. ctx.lineTo(x0, y0 - coeff * 3);
  1185. ctx.stroke();
  1186. break;
  1187. default:
  1188. ctx.beginPath();
  1189. ctx.lineWidth = 1;
  1190. ctx.strokeStyle = couleur_cible;
  1191. ctx.fillStyle = couleur_cible;
  1192. ctx.arc(x0, y0, coeff * 4, 0, Math.PI*2, true);
  1193. ctx.moveTo(x0 + coeff * 4, y0);
  1194. ctx.lineTo(x0 - coeff * 4, y0);
  1195. ctx.moveTo(x0, y0 + coeff * 4);
  1196. ctx.lineTo(x0, y0 - coeff * 4);
  1197. ctx.stroke();
  1198. break;
  1199. }
  1200. // les segments
  1201. var nb_pts = tabDeplOneSuivant.length;
  1202. var pointPrecedent = tabDeplOneSuivant[0];
  1203. for (var i=1; i<nb_pts; i++) {
  1204. ctx.beginPath();
  1205. ctx.lineWidth = coeff;
  1206. ctx.moveTo(coord_x(pointPrecedent.x), coord_y(pointPrecedent.y));
  1207. ctx.strokeStyle = couleur_depl_normal;
  1208. var pointIntermediaire = pointIntermediaireMonstre2D(pointPrecedent, tabDeplOneSuivant[i]);
  1209. if (pointIntermediaire === undefined) {
  1210. if (detecteCollisionTrou(pointPrecedent, tabDeplOneSuivant[i]))
  1211. ctx.strokeStyle = couleur_depl_collision_trou;
  1212. else
  1213. ctx.strokeStyle = couleur_depl_normal;
  1214. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1215. } else {
  1216. if (detecteCollisionTrou(pointPrecedent, pointIntermediaire)
  1217. || detecteCollisionTrou(pointIntermediaire, tabDeplOneSuivant[i]))
  1218. ctx.strokeStyle = couleur_depl_collision_trou;
  1219. else
  1220. ctx.strokeStyle = couleur_depl_normal;
  1221. ctx.lineTo(coord_x(pointIntermediaire.x), coord_y(pointIntermediaire.y));
  1222. ctx.lineTo(coord_x(tabDeplOneSuivant[i].x), coord_y(tabDeplOneSuivant[i].y));
  1223. }
  1224. pointPrecedent = tabDeplOneSuivant[i];
  1225. ctx.stroke();
  1226. }
  1227. // Les points à chaque étape
  1228. ctx.fillStyle = couleur_depl_normal;
  1229. for (var i=1; i<nb_pts; i++) {
  1230. ctx.beginPath();
  1231. var x = coord_x(tabDeplOneSuivant[i].x);
  1232. var y = coord_y(tabDeplOneSuivant[i].y);
  1233. ctx.arc(x, y, coeff, 0, Math.PI*2, true);
  1234. ctx.fill();
  1235. }
  1236. }
  1237. }
  1238.  
  1239. this.setZoom = function (val) {
  1240. ctx.clearRect(0, 0, dessin.width, dessin.height);
  1241. coeff = val / 50;
  1242. dessine_carte();
  1243. }
  1244.  
  1245. // glissiere
  1246. var gliss = new glissiere_MZ(ref, "Zoom\u00A0:", this, true, 100, 50, 200);
  1247. var eGliss = gliss.getElt();
  1248. eGliss.style.position = 'absolute';
  1249. eGliss.style.top = (coeff * 2) + 'px';
  1250. eGliss.style.left = decalh + 'px';
  1251. dessin.style.position = 'relative';
  1252. div2_carte.style.position = 'relative';
  1253. eGliss.style.zIndex = 9000;
  1254. div2_carte.appendChild(eGliss);
  1255.  
  1256. // affichage au survol de la souris
  1257. var bulle = document.createElement('div');
  1258. bulle.style.visibility = 'hidden';
  1259. bulle.style.position = 'absolute';
  1260. bulle.style.zIndex = 3100;
  1261. bulle.style.border = 'solid 1px #a1927f';
  1262. bulle.className = 'mh_tdpage';
  1263. bulle.style.display = 'block'; // ATTENTION, display doit être après className pour forcer le display
  1264. var bulleHaut = document.createElement('div');
  1265. bulleHaut.style.display = 'block';
  1266. bulleHaut.style.paddingRight = '3px';
  1267. bulleHaut.className = 'mh_tdtitre';
  1268. bulleHaut.appendChild(document.createTextNode(' ')); // prépare texte
  1269. bulle.appendChild(bulleHaut);
  1270. var bulleBas = document.createElement('div');
  1271. bulleBas.style.display = 'block';
  1272. bulleBas.style.whiteSpace = "nowrap";
  1273. bulleBas.style.paddingRight = '3px';
  1274.  
  1275. //bulleBas.appendChild(document.createTextNode(' ')); // prépare texte
  1276. bulle.appendChild(bulleBas);
  1277. div2_carte.appendChild(bulle);
  1278. var affichePosition = function(evt) {
  1279. if (evt.offsetX) {
  1280. var xsouris = evt.offsetX;
  1281. var ysouris = evt.offsetY;
  1282. var xpos = evt.clientX;
  1283. var ypos = evt.clientY + document.body.scrollTop;
  1284. }
  1285. else {
  1286. var xsouris = evt.layerX;
  1287. var ysouris = evt.layerY;
  1288. var xpos = evt.pageX;
  1289. var ypos = evt.pageY;
  1290. }
  1291. var xUser = Math.round(((xsouris - decalh) / coeff) - 100);// l'inverse de decalh+coeff*(val+100);
  1292. var yUser = Math.round(100-((ysouris - decalv) / coeff));// l'inverse de decalv+coeff*(100-val);
  1293. bulleHaut.firstChild.nodeValue = 'x=' + xUser + ', y=' + yUser;
  1294. var tabHTMLbas = [];
  1295. // message pour les trous
  1296. for (var i in position_trous_MZ) {
  1297. var ceTrou = position_trous_MZ[i];
  1298. var dist = (xUser-ceTrou[0])*(xUser-ceTrou[0])+(yUser-ceTrou[1])*(yUser-ceTrou[1])-ceTrou[2];
  1299. if(dist <= 0) {
  1300. tabHTMLbas.push("Trous de Météorite : n=-1 -> n="+ceTrou[4]);
  1301. break;
  1302. }
  1303. }
  1304. // messages pour les suivants
  1305. for (var i in tabDepl) {
  1306. var ceGowap = tabDepl[i][0]; // position courante du suivant
  1307. if (Math.abs(xUser - ceGowap.x) < 3 && Math.abs(yUser - ceGowap.y) < 3)
  1308. tabHTMLbas.push('(' + ceGowap.x + ', ' + ceGowap.y + ', ' + ceGowap.n + ') ' + ceGowap.id + ' ' + ceGowap.nom);
  1309. }
  1310. bulleBas.innerHTML = tabHTMLbas.join('<br />');
  1311. bulle.style.top = (ysouris+8) + 'px';
  1312. bulle.style.left = (xsouris+16) + 'px';
  1313. };
  1314. addEvent(dessin, "mousemove", affichePosition, true);
  1315. addEvent(dessin, "mouseout", function() { bulle.style.visibility = 'hidden' }, true);
  1316. addEvent(dessin, "mouseover", function() { bulle.style.visibility = 'visible' }, true);
  1317.  
  1318. // dessin initial
  1319. dessine_carte();
  1320.  
  1321. this.getElt = function() {return div1_carte;};
  1322.  
  1323. } catch (e) {window.console.log(traceStack(e, 'carte_MZ'))}
  1324. }
  1325.  
  1326.  
  1327. /**********************************************************
  1328. **** Fin de zone à déplacer dans une bibli commune ********
  1329. **********************************************************/
  1330.  
  1331. /* DEBUG: NETTOYAGE TAGS */
  1332. if(MY_getValue(numTroll+'.TAGSURL')) {
  1333. MY_removeValue(numTroll+'.TAGSURL');
  1334. }
  1335.  
  1336. // Alerte si mode dev
  1337. if (isDEV) {
  1338. var divpopup = document.createElement('div');
  1339. divpopup.id = 'divDEV';
  1340. divpopup.style =
  1341. 'position: fixed;'+
  1342. 'border: 15px solid red;'+
  1343. 'top: 10px;right: 10px;'+
  1344. 'background-color: white;'+
  1345. 'color: black;'+
  1346. 'font-size: large;'+
  1347. 'padding: 5px'+
  1348. 'z-index: 200;';
  1349. appendText(divpopup, '[MZ] Mode DEV');
  1350. divpopup.title = 'Pour revenir en mode normal, \nshift-click sur le mot "Crédits" dans Options/Pack Graphique';
  1351. document.body.appendChild(divpopup);
  1352. }
  1353.  
  1354. /*---------- regroupement des getPortee() ------------------------------------*/
  1355. // issu des script profil et profil2
  1356. function getPortee__Profil(param) {
  1357. param = Math.max(0,Number(param));
  1358. return Math.ceil( Math.sqrt( 2*param+10.75 )-3.5 );
  1359. // ça devrait être floor, +10.25, -2.5
  1360. }
  1361.  
  1362. // issu du script vue
  1363. function getPortee__Vue(param) {
  1364. return Math.ceil((Math.sqrt(19 + 8 * (param + 3)) - 7) / 2);
  1365. }
  1366.  
  1367.  
  1368. /*-[functions]----------- Calculs expérience / niveau ------------------------*/
  1369.  
  1370. function getPXKill(niv) {
  1371. return Math.max(0,10+3*niv-2*nivTroll);
  1372. }
  1373.  
  1374. function getPXDeath(niv) {
  1375. return Math.max(0,10+3*nivTroll-2*niv);
  1376. }
  1377.  
  1378. function analysePX(niv) {
  1379. niv = niv+'';
  1380. var i = niv.indexOf('+');
  1381. if(i!=-1) // si niv = 'XX+' ??
  1382. return ' --> \u2265 <b>'+getPXKill(niv.slice(0,i))+'</b> PX';
  1383. i = niv.slice(1).indexOf('-'); // si niv = 'XX-YY' ??
  1384. if(i!=-1) {
  1385. var max = getPXKill(niv.slice(i+2));
  1386. if(max==0)
  1387. return ' --> <b>0</b> PX';
  1388. return ' --> <b>'+getPXKill(niv.slice(0,i+1))
  1389. +'</b> \u2264 PX \u2264 <b>'+max+'</b>';
  1390. }
  1391. i = niv.indexOf('='); // ???
  1392. if(i!=-1) {
  1393. var max = getPXKill(niv.slice(i+1));
  1394. return max==0 ? ' --> <b>0</b> PX' : ' --> \u2264 <b>'+max+'</b> PX';
  1395. }
  1396. return ' --> <b>'+getPXKill(niv)+'</b> PX';
  1397. }
  1398.  
  1399. function analysePXTroll(niv) {
  1400. var str = analysePX(niv);
  1401. str += '<br/>Vous lui rapportez <b>'+getPXDeath(niv)+'</b> PX.';
  1402. return str;
  1403. }
  1404.  
  1405.  
  1406. /*-[functions]------------- Gestion Compos / Champis -------------------------*/
  1407. // Refonte totale du code de Zorya
  1408.  
  1409. // Elements à implémenter en dur dans MZ2.0
  1410. var numQualite = {
  1411. 'Très Mauvaise':1,
  1412. 'Mauvaise':2,
  1413. 'Moyenne':3,
  1414. 'Bonne':4,
  1415. 'Très Bonne':5
  1416. };
  1417.  
  1418. var qualiteNum = [
  1419. '_dummy_',
  1420. 'Très Mauvaise',
  1421. 'Mauvaise',
  1422. 'Moyenne',
  1423. 'Bonne',
  1424. 'Très Bonne'
  1425. ];
  1426.  
  1427. var nival = {
  1428. 'Abishaii Bleu':19,
  1429. 'Abishaii Noir':10,
  1430. 'Abishaii Rouge':23,
  1431. 'Abishaii Vert':15,
  1432. 'Ame-en-peine':8,
  1433. 'Amibe Geante':9,
  1434. 'Anaconda des Catacombes':8,
  1435. 'Ankheg':10,
  1436. 'Anoploure Purpurin':36,
  1437. 'Araignee Geante':2,
  1438. 'Ashashin':35,
  1439. 'Balrog':50,
  1440. 'Banshee':16,
  1441. 'Barghest':36,
  1442. 'Basilisk':11,
  1443. 'Behemoth':34,
  1444. 'Behir':14,
  1445. 'Beholder':50,
  1446. 'Boggart':3,
  1447. 'Bondin':9,
  1448. "Bouj'Dla Placide":37,
  1449. "Bouj'Dla":19,
  1450. 'Bulette':19,
  1451. 'Caillouteux':1,
  1452. 'Capitan':35,
  1453. 'Carnosaure':25,
  1454. 'Champi-Glouton':3,
  1455. 'Chauve-Souris Geante':4,
  1456. 'Cheval a Dents de Sabre':23,
  1457. 'Chevalier du Chaos':20,
  1458. 'Chimere':13,
  1459. 'Chonchon':24,
  1460. 'Coccicruelle':22,
  1461. 'Cockatrice':5,
  1462. 'Crasc Medius':17,
  1463. 'Crasc Maexus':25,
  1464. 'Crasc':10,
  1465. 'Croquemitaine':6,
  1466. 'Cube Gelatineux':32,
  1467. 'Daemonite':27,
  1468. 'Diablotin':5,
  1469. 'Dindon du Chaos':1,
  1470. 'Djinn':29,
  1471. 'Ectoplasme':18,
  1472. 'Effrit':27,
  1473. "Elementaire d'Air":23,
  1474. "Elementaire d'Eau":17,
  1475. 'Elementaire de Feu':21,
  1476. 'Elementaire de Terre':21,
  1477. 'Elementaire du Chaos':26,
  1478. 'Erinyes':7,
  1479. 'Esprit-Follet':16,
  1480. 'Essaim Craterien':30,
  1481. 'Essaim Sanguinaire':25,
  1482. 'Ettin':8,
  1483. 'Familier':1,
  1484. 'Fantome':24,
  1485. 'Feu Follet':20,
  1486. 'Flagelleur Mental':33,
  1487. 'Foudroyeur':38,
  1488. 'Fumeux':22,
  1489. 'Fungus Geant':9,
  1490. 'Fungus Violet':4,
  1491. 'Furgolin':10,
  1492. 'Gargouille':3,
  1493. 'Geant de Pierre':13,
  1494. 'Geant des Gouffres':22,
  1495. "Geck'oo Majestueux":40,
  1496. "Geck'oo":15,
  1497. 'Glouton':20,
  1498. 'Gnoll':5,
  1499. 'Gnu Domestique':1,
  1500. 'Gnu Sauvage':1,
  1501. 'Goblin':4,
  1502. 'Goblours':4,
  1503. "Golem d'Argile":15,
  1504. 'Golem de cuir':1,
  1505. 'Golem de Chair':8,
  1506. 'Golem de Fer':31,
  1507. 'Golem de mithril':1,
  1508. 'Golem de metal':1,
  1509. 'Golem de papier':1,
  1510. 'Golem de Pierre':23,
  1511. 'Gorgone':11,
  1512. 'Goule':4,
  1513. 'Gowap Apprivoise':1,
  1514. 'Gowap Sauvage':1,
  1515. 'Gremlins':3,
  1516. 'Gritche':39,
  1517. 'Grouilleux':4,
  1518. 'Grylle':31,
  1519. 'Harpie':4,
  1520. 'Hellrot':18,
  1521. 'Homme-Lezard':4,
  1522. 'Hurleur':8,
  1523. 'Hydre':50,
  1524. 'Incube':13,
  1525. 'Kobold':2,
  1526. 'Labeilleux':26,
  1527. 'Lezard Geant':5,
  1528. 'Liche':50,
  1529. 'Limace Geante':10,
  1530. 'Loup-Garou':8,
  1531. 'Lutin':4,
  1532. 'Mante Fulcreuse':30,
  1533. 'Manticore':9,
  1534. 'Marilith':33,
  1535. 'Meduse':6,
  1536. 'Megacephale':38,
  1537. 'Mille-Pattes Geant':14,
  1538. 'Mimique':6,
  1539. 'Minotaure':7,
  1540. 'Molosse Satanique':8,
  1541. 'Momie':4,
  1542. 'Monstre Rouilleur':3,
  1543. "Mouch'oo Domestique":14,
  1544. "Mouch'oo Majestueux Sauvage":33,
  1545. "Mouch'oo Sauvage":14,
  1546. 'Na-Haniym-Heee':0,
  1547. 'Necrochore':37,
  1548. 'Necromant':39,
  1549. 'Necrophage':8,
  1550. 'Naga':10,
  1551. 'Nuee de Vermine':13,
  1552. "Nuage d'Insectes":7,
  1553. 'Ogre':7,
  1554. 'Ombre de Roches':13,
  1555. 'Ombre':2,
  1556. 'Orque':3,
  1557. 'Ours-Garou':18,
  1558. 'Palefroi Infernal':29,
  1559. 'Phoenix':32,
  1560. 'Pititabeille':0,
  1561. 'Plante Carnivore':4,
  1562. 'Pseudo-Dragon':5,
  1563. 'Rat Geant':2,
  1564. 'Rat-Garou':3,
  1565. 'Rocketeux':5,
  1566. 'Sagouin':3,
  1567. 'Scarabee Geant':4,
  1568. 'Scorpion Geant':10,
  1569. 'Shai':28,
  1570. 'Sirene':8,
  1571. 'Slaad':5,
  1572. 'Sorciere':17,
  1573. 'Spectre':14,
  1574. 'Sphinx':30,
  1575. 'Squelette':1,
  1576. 'Strige':2,
  1577. 'Succube':13,
  1578. 'Tertre Errant':20,
  1579. 'Thri-kreen':10,
  1580. 'Tigre-Garou':12,
  1581. 'Titan':26,
  1582. 'Trancheur':35,
  1583. 'Tubercule Tueur':14,
  1584. 'Tutoki':4,
  1585. 'Vampire':29,
  1586. 'Ver Carnivore Geant':12,
  1587. 'Ver Carnivore':11,
  1588. 'Veskan Du Chaos':14,
  1589. 'Vouivre':33,
  1590. 'Worg':5,
  1591. 'Xorn':14,
  1592. 'Yeti':8,
  1593. 'Yuan-ti':15,
  1594. 'Zombie':2
  1595. }
  1596.  
  1597. var tabEM = {
  1598. //Monstre: [Compo exact, Sort, Position, Localisation]
  1599. // AA
  1600. 'Basilisk':["Œil d'un ","Analyse Anatomique",3,"Tête"],
  1601. // AE
  1602. 'Ankheg':["Carapace d'un","Armure Ethérée",3,"Spécial"],
  1603. 'Rocketeux':["Tripes d'un","Armure Ethérée",4,"Corps"],
  1604. // AdA
  1605. 'Loup-Garou':["Bras d'un","Augmentation de l'Attaque",3,"Membre"],
  1606. 'Titan':["Griffe d'un","Augmentation de l'Attaque",4,"Membre"],
  1607. // AdE
  1608. 'Erinyes':["Plume d'une","Augmentation de l'Esquive",3,"Membre"],
  1609. 'Palefroi Infernal':["Sabot d'un","Augmentation de l'Esquive",4,"Membre"],
  1610. // AdD
  1611. 'Manticore':["Patte d'une","Augmentation des Dégâts",3,"Membre"],
  1612. 'Trancheur':["Griffe d'un","Augmentation des Dégâts",4,"Membre"],
  1613. // BAM
  1614. 'Banshee':["Peau d'une","Bulle Anti-Magie",3,"Corps"],
  1615. // BuM
  1616. 'Essaim Sanguinaire':["Pattes d'un","Bulle Magique",3,"Membre"],
  1617. 'Sagouin':["Patte d'un","Bulle Magique",4,"Membre"],
  1618. 'Effrit':["Cervelle d'un","Bulle Magique",5,"Tête"],
  1619. // Explo
  1620. 'Diablotin':["Cœur d'un","Explosion",3,"Corps"],
  1621. 'Chimère':["Sang d'une","Explosion",4,"Corps"],
  1622. 'Barghest':["Bave d'un","Explosion",5,"Spécial"],
  1623. // FP
  1624. 'Nécrophage':["Tête d'un","Faiblesse Passagère",3,"Tête"],
  1625. 'Vampire':["Canine d'un","Faiblesse Passagère",4,"Spécial"],
  1626. // FA
  1627. 'Gorgone':["Chevelure d'une","Flash Aveuglant",3,"Tête"],
  1628. 'Géant des Gouffres':["Cervelle d'un","Flash Aveuglant",4,"Tête"],
  1629. // Glue
  1630. 'Limace Géante':["Mucus d'une","Glue",3,"Spécial"],
  1631. 'Grylle':["Gueule d'un","Glue",4,"Tête"],
  1632. // GdS
  1633. 'Abishaii Noir':["Serre d'un","Griffe du Sorcier",3,"Membre"],
  1634. 'Vouivre':["Venin d'une","Griffe du Sorcier",4,"Spécial"],
  1635. 'Araignée Géante':["Mandibule d'une","Griffe du Sorcier",5,"Spécial"],
  1636. // Invi
  1637. "Nuage d'Insectes":["Chitine d'un","Invisibilité",3,"Spécial"],
  1638. 'Yuan-ti':["Cervelle d'un","Invisibilité",4,"Tête"],
  1639. 'Gritche':["Epine d'un","Invisibilité",5,"Spécial"],
  1640. // Lévitation
  1641. // ???
  1642. // PréM :
  1643. 'Ashashin':["Œil d'un ","Précision Magique",3,"Tête"],
  1644. 'Crasc':["Œil Rougeoyant d'un ","Précision Magique",4,"Tête"],
  1645. // Proj
  1646. 'Yéti':["Jambe d'un","Projection",3,"Membre"],
  1647. 'Djinn':["Tête d'un","Projection",4,"Tête"],
  1648. // PuM :
  1649. 'Incube':["Épaule musclée d'un","Puissance Magique",3,"Membre"],
  1650. 'Capitan':["Tripes Puantes d'un","Puissance Magique",4,"Corps"],
  1651. // Sacro
  1652. 'Sorcière':["Verrue d'une","Sacrifice",3,"Spécial"],
  1653. // Télék
  1654. 'Plante Carnivore':["Racine d'une","Télékinésie",3,"Spécial"],
  1655. 'Tertre Errant':["Cervelle d'un","Télékinésie",4,"Tête"],
  1656. // TP
  1657. 'Boggart':["Main d'un","Téléportation",3,"Membre"],
  1658. 'Succube':["Téton Aguicheur d'une","Téléportation",4,"Corps"],
  1659. 'Nécrochore':["Os d'un","Téléportation",5,"Corps"],
  1660. // VA
  1661. 'Abishaii Vert':["Œil d'un","Vision Accrue",3,"Tête"],
  1662. // VL
  1663. 'Fungus Géant':["Spore d'un","Vision Lointaine",3,"Spécial"],
  1664. 'Abishaii Rouge':["Aile d'un","Vision Lointaine",4,"Membre"],
  1665. // VlC
  1666. 'Zombie':["Cervelle Putréfiée d'un","Voir le Caché",3,"Tête"],
  1667. 'Shai':["Tripes d'un","Voir le Caché",4,"Corps"],
  1668. 'Phoenix':["Œil d'un","Voir le Caché",5,"Tête"],
  1669. // VT
  1670. 'Naga':["Ecaille d'un","Vue Troublée",3,"Corps"],
  1671. 'Marilith':["Ecaille d'une","Vue Troublée",4,"Membre"],
  1672. // Variables
  1673. 'Rat':["d'un"],
  1674. 'Rat Géant':["d'un"],
  1675. 'Dindon':["d'un"],
  1676. 'Goblin':["d'un"],
  1677. 'Limace':["d'une"],
  1678. 'Limace Géante':["d'une"],
  1679. 'Ver':["d'un"],
  1680. 'Ver Carnivore':["d'un"],
  1681. 'Ver Carnivore Géant':["d'un"],
  1682. 'Fungus':["d'un"],
  1683. 'Vouivre':["d'une"],
  1684. 'Gnu':["d'un"],
  1685. 'Scarabée':["d'un"]
  1686. };
  1687.  
  1688. var mundiChampi = {
  1689. 'Préscientus Reguis':'du Phoenix',
  1690. 'Amanite Trolloïde':'de la Mouche',
  1691. 'Girolle Sanglante':'du Dindon',
  1692. 'Horreur Des Prés':'du Gobelin',
  1693. 'Bolet Péteur':'du Démon',
  1694. 'Pied Jaune':'de la Limace',
  1695. 'Agaric Sous-Terrain':'du Rat',
  1696. 'Suinte Cadavre':"de l'Hydre",
  1697. 'Cèpe Lumineux':'du Ver',
  1698. 'Fungus Rampant':'du Fungus',
  1699. 'Nez Noir':'de la Vouivre',
  1700. 'Pleurote Pleureuse':'du Gnu',
  1701. 'Phytomassus Xilénique':'du Scarabée'
  1702. };
  1703.  
  1704. function addInfoMM(node,mob,niv,qualite,effetQ) {
  1705. appendText(node,' ');
  1706. var urlImg = URL_MZimg
  1707. +'Competences/melangeMagique.png';
  1708. var text = ' [-'+(niv+effetQ)+' %]';
  1709. var str = '';
  1710. switch(mob[0]) {
  1711. case 'A':
  1712. case 'E':
  1713. case 'I':
  1714. case 'O':
  1715. case 'U':
  1716. str = "Compo d'";
  1717. break;
  1718. default:
  1719. str = 'Compo de ';
  1720. }
  1721. var title = str+mob+' : -'+niv+'\nQualité '+qualite+' : -'+effetQ;
  1722. var span = createImageSpan(urlImg,'MM:',title,text);
  1723. node.appendChild(span);
  1724. }
  1725. function addInfoEM(node,mob,compo,qualite,localisation) {
  1726. if(!tabEM[mob]) return;
  1727. var title = 'Composant variable', texte = 'Variable';
  1728. var bold = false;
  1729. if(tabEM[mob].length>1) {
  1730. var pc = 5*(numQualite[qualite]-tabEM[mob][2]);
  1731. if(tabEM[mob][0].indexOf(compo)==-1) pc -= 20;
  1732. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1733. if(pc<-20) return;
  1734. if(pc>=0) bold = true;
  1735. texte = aff(pc)+'%';
  1736. title = texte+" pour l'écriture de "+tabEM[mob][1];
  1737. }
  1738. var urlImg = URL_MZimg
  1739. +'Competences/ecritureMagique.png';
  1740. var span = createImageSpan(urlImg,'EM:',title,' ['+texte+']',bold);
  1741. node.appendChild(span);
  1742. }
  1743.  
  1744. function insererInfosEM(tbody) {
  1745. // lancé par equip, equipgowap
  1746. var trCompos = document.evaluate(
  1747. "./tr[not(starts-with(td[2]/img/@alt,'Pas'))]",
  1748. tbody,null,7,null);
  1749. var strCompos = '';
  1750. for(var i=0 ; i<trCompos.snapshotLength ; i++) {
  1751. var node = trCompos.snapshotItem(i).childNodes[7];
  1752. var str = node.firstChild.textContent;
  1753. var compo = trim(str.slice(0,str.indexOf(" d'un")));
  1754. var mob = trim(str.slice(str.indexOf("d'un")+5));
  1755. // Si non-EM on stoppe le traitement
  1756. if(!tabEM[mob]) continue;
  1757. str = trCompos.snapshotItem(i).childNodes[9].textContent;
  1758. var qualite = trim(str.slice(str.indexOf('Qualit')+9));
  1759. var localisation = trim(str.slice(0,str.indexOf(' |')));
  1760. addInfoEM(node,mob,compo,qualite,localisation);
  1761. }
  1762. }
  1763.  
  1764. function getQualite(qualite) {
  1765. var nb = numQualite[qualite];
  1766. return nb ? nb-1 : -1;
  1767. }
  1768.  
  1769. function getEM(nom) {
  1770. if(nom.indexOf('[')!=-1)
  1771. nom = trim(nom.substring(0,nom.indexOf('[')));
  1772. if(tabEM[nom]) return nom;
  1773. return '';
  1774. }
  1775.  
  1776. // DEBUG ex-fonction composantEM
  1777. function compoMobEM(mob) {
  1778. if(!tabEM[mob]) return '';
  1779. if(tabEM[mob].length==1)
  1780. return 'Divers composants '+tabEM[mob][0]+' '+mob+' (Composant Variable)';
  1781. return tabEM[mob][0]+' '+mob+" (Qualité "+qualiteNum[tabEM[mob][2]]
  1782. +") pour l'écriture de "+tabEM[mob][1];
  1783. }
  1784.  
  1785. // DEBUG ex-fonction compoEM
  1786. function titreCompoEM(mob,compo,localisation,qualite) {
  1787. if(!tabEM[mob]) return '';
  1788. if(tabEM[mob].length==1) return 'Composant variable';
  1789. var pc = 5*(tabEM[mob][2]-numQualite[qualite]);
  1790. if(compo.indexOf(tabEM[mob][0])==-1) pc -= 20;
  1791. if(localisation.indexOf(tabEM[mob][3])==-1) pc -= 5;
  1792. if(pc>=-20) return pc+"% pour l'écriture de "+tabEM[mob][2];
  1793. return '';
  1794. }
  1795.  
  1796. // DEBUG - rétrocompatibilité
  1797. function compoEM(mob) {
  1798. // appelé dans libs, vue
  1799. return compoMobEM(mob);
  1800. }
  1801. function composantEM(mob,compo,localisation,qualite) {
  1802. // appelé dans libs, tancompo
  1803. return titreCompoEM(mob,compo,localisation,qualite);
  1804. }
  1805. //
  1806.  
  1807.  
  1808. /*-[functions]-------------- Stockage des Talents ----------------------------*/
  1809.  
  1810. arrayTalents = {
  1811. /* Compétences */
  1812. 'Acceleration du Metabolisme':'AM',
  1813. 'Attaque Precise':'AP',
  1814. 'Balayage':'Balayage',
  1815. //'Balluchonnage':'Ballu',
  1816. 'Baroufle':'Baroufle',
  1817. 'Bidouille':'Bidouille',
  1818. 'Botte Secrete':'BS',
  1819. 'Camouflage':'Camou',
  1820. 'Charger':'Charger',
  1821. 'Connaissance des Monstres':'CdM',
  1822. 'Construire un Piege':'Piege',
  1823. 'Piege a Feu':'PiegeFeu',
  1824. 'Piege a Glue':'PiegeGlue',
  1825. 'Contre-Attaquer':'CA',
  1826. 'Coup de Butoir':'CdB',
  1827. 'Course':'Course',
  1828. 'Deplacement Eclair':'DE',
  1829. 'Dressage':'Dressage',
  1830. 'Ecriture Magique':'EM',
  1831. 'Frenesie':'Frenesie',
  1832. 'Golemologie':'Golemo',
  1833. 'Golem de cuir':'GolemCuir',
  1834. 'Golem de metal':'GolemMetal',
  1835. 'Golem de mithril':'GolemMithril',
  1836. 'Golem de papier':'GolemPapier',
  1837. 'Grattage':'Grattage',
  1838. 'Hurlement Effrayant':'HE',
  1839. 'Identification des Champignons':'IdC',
  1840. 'Insultes':'Insultes',
  1841. 'Lancer de Potions':'LdP',
  1842. 'Marquage':'Marquage',
  1843. 'Melange Magique':'Melange',
  1844. 'Miner':'Miner',
  1845. 'Necromancie':'Necro',
  1846. 'Painthure de Guerre':'PG',
  1847. 'Parer':'Parer',
  1848. 'Pistage':'Pistage',
  1849. 'Planter un Champignon':'PuC',
  1850. 'Regeneration Accrue':'RA',
  1851. 'Reparation':'Reparation',
  1852. 'Retraite':'Retraite',
  1853. 'Rotobaffe':'RB',
  1854. 'Shamaner':'Shamaner',
  1855. "S'interposer":'SInterposer',
  1856. 'Tailler':'Tailler',
  1857. //'Vol':'Vol',
  1858. /* Sortilèges */
  1859. 'Analyse Anatomique':'AA',
  1860. 'Armure Etheree':'AE',
  1861. 'Augmentation de l´Attaque':'AdA',
  1862. 'Augmentation de l´Esquive':'AdE',
  1863. 'Augmentation des Degats':'AdD',
  1864. 'Bulle Anti-Magie':'BAM',
  1865. 'Bulle Magique':'BuM',
  1866. 'Explosion':'Explo',
  1867. 'Faiblesse Passagere':'FP',
  1868. 'Flash Aveuglant':'FA',
  1869. 'Glue':'Glue',
  1870. 'Griffe du Sorcier':'GdS',
  1871. 'Hypnotisme':'Hypno',
  1872. 'Identification des tresors':'IdT',
  1873. 'Invisibilite':'Invi',
  1874. 'Levitation':'Levitation',
  1875. 'Precision Magique':'PreM',
  1876. 'Projectile Magique':'Projo',
  1877. 'Projection':'Proj',
  1878. 'Puissance Magique':'PuM',
  1879. 'Rafale Psychique':'Rafale',
  1880. 'Sacrifice':'Sacro',
  1881. 'Siphon des ames':'Siphon',
  1882. 'Telekinesie':'Telek',
  1883. 'Teleportation':'TP',
  1884. 'Vampirisme':'Vampi',
  1885. 'Vision Accrue':'VA',
  1886. 'Vision lointaine':'VL',
  1887. 'Voir le Cache':'VlC',
  1888. 'Vue Troublee':'VT'
  1889. //'':''
  1890. }
  1891.  
  1892. // DEBUG - Pour rétrocompatibilité
  1893. function getSortComp(nom,niveau) {
  1894. return getTalent(nom,niveau);
  1895. }
  1896. //
  1897.  
  1898. function getTalent(nom,niveau) {
  1899. var nomEnBase = arrayTalents[epure(nom)];
  1900. if(!nomEnBase) return 0;
  1901. if(!niveau) var niveau = '';
  1902. if(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau))
  1903. return MY_getValue(numTroll+'.talent.'+nomEnBase+niveau);
  1904. return 0;
  1905. }
  1906.  
  1907. function removeAllTalents() {
  1908. for(var talent in arrayTalents) {
  1909. var nomEnBase = arrayTalents[talent];
  1910. if(MY_getValue(numTroll+'.talent.'+nomEnBase)) {
  1911. MY_removeValue(numTroll+'.talent.'+nomEnBase);
  1912. continue;
  1913. }
  1914. var niveau = 1;
  1915. while(MY_getValue(numTroll+'.talent.'+nomEnBase+niveau)) {
  1916. MY_removeValue(numTroll+'.talent.'+nomEnBase+niveau);
  1917. niveau++;
  1918. }
  1919. }
  1920. }
  1921.  
  1922. function isProfilActif() { // DEBUG: Réfléchir à l'utilité de cette fonction
  1923. var att = MY_getValue(numTroll+'.caracs.attaque');
  1924. var attbmp = MY_getValue(numTroll+'.caracs.attaque.bmp');
  1925. var attbmm = MY_getValue(numTroll+'.caracs.attaque.bmm');
  1926. var mm = MY_getValue(numTroll+'.caracs.mm');
  1927. var deg = MY_getValue(numTroll+'.caracs.degats');
  1928. var degbmp = MY_getValue(numTroll+'.caracs.degats.bmp');
  1929. var degbmm = MY_getValue(numTroll+'.caracs.degats.bmm');
  1930. var vue = parseInt(MY_getValue(numTroll+'.caracs.vue'));
  1931. var bmvue = parseInt(MY_getValue(numTroll+'.caracs.vue.bm'));
  1932. if(att==null || attbmp==null || attbmm==null || mm==null || deg==null
  1933. || degbmp==null || degbmm==null || vue==null || bmvue==null)
  1934. return false;
  1935. return true;
  1936. }
  1937.  
  1938.  
  1939. /*-[functions]---------------- Gestion des CDMs ------------------------------*/
  1940.  
  1941. function getPVsRestants(pv,bless,vue) {
  1942. bless = Number(bless.match(/\d+/)[0]);
  1943. if(bless==0) return null;
  1944. var pvminmax = pv.match(/\d+/g);
  1945. if(bless==95) {
  1946. var pvb = 1;
  1947. var pvh = Math.floor( pvminmax[1]/20 );
  1948. }
  1949. else if(bless==5) {
  1950. var pvb = Math.floor( pvminmax[0]*19/20 );
  1951. var pvh = pvminmax[1];
  1952. }
  1953. else {
  1954. var pvb = Math.ceil( pvminmax[0]*(95-bless) / 100 );
  1955. var pvh = Math.floor( pvminmax[1]*(105-bless) / 100 );
  1956. }
  1957. return vue ? ' ('+pvb+'-'+pvh+')' :
  1958. ['Points de Vie restants : ','Entre '+pvb+' et '+pvh];
  1959. }
  1960.  
  1961. function insertButtonCdm(nextName,onClick,texte) {
  1962. if(texte==null) texte = 'Participer au bestiaire';
  1963. var nextNode = document.getElementsByName(nextName)[0];
  1964.  
  1965. var espace = document.createTextNode('\t');
  1966. insertBefore(nextNode,espace);
  1967.  
  1968. var button = document.createElement('input');
  1969. button.type = 'button';
  1970. button.className = 'mh_form_submit';
  1971. button.value = texte;
  1972. button.onmouseover = function(){this.style.cursor='pointer';};
  1973. if(onClick) button.onclick = onClick;
  1974. insertBefore(espace,button);
  1975. return button;
  1976. }
  1977.  
  1978. var listeTitres = ['Niveau','Famille','Points de Vie','Blessure',
  1979. 'Attaque','Esquive','Dégâts','Régénération','Armure','Vue',
  1980. 'Capacité spéciale','Résistance Magique','Autres'];
  1981.  
  1982. function createImageTactique(url,id,nom) {
  1983. var img = document.createElement('img');
  1984. img.src = url;
  1985. img.align = 'ABSMIDDLE'; // DEBUG: OBSOLÈTE
  1986. img.id = id;
  1987. img.nom = nom;
  1988. img.onmouseover = showPopupTactique;
  1989. img.onmouseout = hidePopup;
  1990. return img;
  1991. }
  1992.  
  1993. function createCDMTable(id,nom,donneesMonstre) {
  1994. try {
  1995. var urlImg = URL_MZimg;
  1996. var table = document.createElement('table');
  1997. var profilActif = isProfilActif();
  1998. table.className = 'mh_tdborder';
  1999. table.border = 0;
  2000. table.cellSpacing = 1;
  2001. table.cellPadding = 4;
  2002. var thead = document.createElement('thead');
  2003. var tr = appendTr(thead,'mh_tdtitre');
  2004. var td = appendTdText(tr,
  2005. 'CDM de '+nom+ (donneesMonstre[11]!='???' ? ' (N° '+id+')' : ''),
  2006. true
  2007. );
  2008. td.colSpan = 2;
  2009. table.appendChild(thead);
  2010. var tbody = document.createElement('tbody');
  2011. table.appendChild(tbody);
  2012. for(var i=0 ; i<listeTitres.length-3 ; i++) {
  2013. createCase(listeTitres[i],tbody,80);
  2014. }
  2015. var TypeMonstre = getEM(nom);
  2016. var infosCompo='';
  2017. if(TypeMonstre!='') {
  2018. infosCompo = compoEM(TypeMonstre);
  2019. }
  2020. var nodes = tbody.childNodes;
  2021. nodes[0].childNodes[1].innerHTML =
  2022. bbcode(donneesMonstre[0])+analysePX(bbcode(donneesMonstre[0]));
  2023. nodes[1].childNodes[1].firstChild.nodeValue = bbcode(donneesMonstre[1]);
  2024. nodes[2].childNodes[1].innerHTML = bbcode(donneesMonstre[2]);
  2025. nodes[3].childNodes[1].innerHTML = bbcode(donneesMonstre[11]);
  2026. nodes[4].childNodes[1].innerHTML = bbcode(donneesMonstre[3]);
  2027. nodes[5].childNodes[1].innerHTML = bbcode(donneesMonstre[4]);
  2028. nodes[6].childNodes[1].innerHTML = bbcode(donneesMonstre[5]);
  2029. nodes[7].childNodes[1].innerHTML = bbcode(donneesMonstre[6]);
  2030. nodes[8].childNodes[1].innerHTML = bbcode(donneesMonstre[7]);
  2031. nodes[9].childNodes[1].innerHTML = bbcode(donneesMonstre[8]);
  2032. if(donneesMonstre[10] && donneesMonstre[10].length>0) {
  2033. td = createCase(listeTitres[10],tbody);
  2034. td.innerHTML = bbcode(donneesMonstre[10]);
  2035. if(donneesMonstre[16] && donneesMonstre[16].length>0) {
  2036. td.appendChild(document.createTextNode(" "));
  2037. if(donneesMonstre[16] == "De zone")
  2038. td.appendChild(createImage(urlImg+"zone.gif","Portée : Zone"));
  2039. else if(donneesMonstre[16] == "Automatique")
  2040. td.appendChild(createImage(urlImg+"automatique.gif","Toucher automatique"));
  2041. else if(donneesMonstre[16] == "Au toucher")
  2042. td.appendChild(createImage(urlImg+"toucher.gif","Pouvoir au toucher"));
  2043. }
  2044. }
  2045. if(donneesMonstre[9] && donneesMonstre[9].length>0)
  2046. {
  2047. td = createCase(listeTitres[11],tbody);
  2048. td.innerHTML = bbcode(donneesMonstre[9]);
  2049. // seuil de résistance du monstre
  2050. var lb = td.getElementsByTagName('b');
  2051. if(lb.length == 1) {
  2052. var mrm = lb[0].firstChild.nodeValue * 1;
  2053. var v = (mrm / mmTroll);
  2054. lb[0].firstChild.nodeValue += " ("
  2055. + (mrm < mmTroll ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v))) + " %)";
  2056. }
  2057. }
  2058. if(donneesMonstre[12]>0 || donneesMonstre[13]>=0 || donneesMonstre[14]>0 || donneesMonstre[15].length>0
  2059. || (donneesMonstre[17] && donneesMonstre[17].length>0)
  2060. || infosCompo.length>0 || nom.indexOf("Gowap Apprivoisé")==-1)
  2061. {
  2062. td = createCase(listeTitres[12],tbody);
  2063. if(donneesMonstre[12]==1)
  2064. {
  2065. td.appendChild(createImage(urlImg+"oeil.gif","Voit le caché"));
  2066. }
  2067. if(donneesMonstre[13]==1)
  2068. {
  2069. td.appendChild(createImage(urlImg+"distance.gif","Attaque à distance"));
  2070. }
  2071. else if(donneesMonstre[13]==0)
  2072. {
  2073. td.appendChild(createImage(urlImg+"cac.gif","Corps à corps"));
  2074. }
  2075. if(donneesMonstre[14]==1)
  2076. {
  2077. td.appendChild(createImage(urlImg+"1.gif","1 attaque par tour"));
  2078. }
  2079. if(donneesMonstre[14]>1 && donneesMonstre[14]<=6)
  2080. {
  2081. td.appendChild(createImage(urlImg+donneesMonstre[14]+".gif",donneesMonstre[14]+" attaque(s) par tour"));
  2082. }
  2083. else if(donneesMonstre[14]>6)
  2084. {
  2085. td.appendChild(createImage(urlImg+"plus.gif","Beaucoup d'attaques par tour"));
  2086. }
  2087. if(donneesMonstre[15]=="Lente")
  2088. {
  2089. td.appendChild(createImage(urlImg+"lent.gif","Lent à se déplacer"));
  2090. }
  2091. else if(donneesMonstre[15]=="Normale")
  2092. {
  2093. td.appendChild(createImage(urlImg+"normal.gif","Vitesse normale de déplacement"));
  2094. }
  2095. else if(donneesMonstre[15]=="Rapide")
  2096. {
  2097. td.appendChild(createImage(urlImg+"rapide.gif","Déplacement rapide"));
  2098. }
  2099. if(donneesMonstre[17] && donneesMonstre[17].length>0 && donneesMonstre[17]!="Vide")
  2100. {
  2101. td.appendChild(createImage(urlImg+"charge2.gif","Possède de l'équipement ("+donneesMonstre[17]+")"));
  2102. }
  2103. if(infosCompo.length>0)
  2104. {
  2105. td.appendChild(createImage(urlImg+"Competences/ecritureMagique.png",infosCompo));
  2106. }
  2107. if(profilActif && nom.indexOf("Gowap Apprivoisé")==-1 && nom.indexOf("Gowap Sauvage")==-1)
  2108. {
  2109. td.appendChild(createImageTactique(urlImg+"calc.png",id,nom));
  2110. }
  2111. }
  2112. // pourcentage de blessure
  2113. lb = nodes[3].childNodes[1].getElementsByTagName('b');
  2114. if(lb.length == 1 && donneesMonstre[2].indexOf("-") != -1) {
  2115. var pvs = getPVsRestants(donneesMonstre[2],lb[0].firstChild.nodeValue,true);
  2116. if(pvs)
  2117. lb[0].firstChild.nodeValue += pvs;
  2118. }
  2119. return table;
  2120. }
  2121. catch(e){window.alert('Erreur createCDMTable() :\n'+e);}
  2122. }
  2123.  
  2124.  
  2125. /*-[functions]------------ Gestion des enchantements -------------------------*/
  2126.  
  2127. var listeMonstreEnchantement = null,
  2128. listeEquipementEnchantement = null,
  2129. listeInfoEnchantement = null;
  2130.  
  2131. function computeCompoEnchantement()
  2132. {
  2133. listeMonstreEnchantement = new Array();
  2134. listeInfoEnchantement = new Array();
  2135. listeEquipementEnchantement = new Array();
  2136. var liste = MY_getValue(numTroll+'.enchantement.liste').split(';');
  2137. for(var i=0;i<liste.length;i++)
  2138. {
  2139. var idEquipement = liste[i]*1;
  2140. if(MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet')==null || MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur')==null)
  2141. continue;
  2142. var nomEquipement = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.objet');
  2143. var infoEnchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur').split(';');
  2144. var texteGlobal='';
  2145. for(var j=0;j<3;j++)
  2146. {
  2147. var infoComposant = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.composant.'+j).split(';');
  2148. listeMonstreEnchantement[infoComposant[2]] = 1;
  2149. var array = new Array();
  2150. array[0]=infoComposant[0].replace("Ril","Œil");
  2151. array[1]=infoComposant[1];
  2152. array[2]=infoComposant[2];
  2153. array[3]=getQualite(infoComposant[3]);
  2154. var texte = infoComposant[4].replace("Ril","Œil");
  2155. for(var k=5;k<infoComposant.length;k++)
  2156. {
  2157. texte += ";"+infoComposant[k].replace("Ril","Œil");
  2158. }
  2159. texteGlobal+=texte+'\n';
  2160. texte += " pour l'enchantement d'un(e) "+nomEquipement+" chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2161. array[4]=texte;
  2162. listeInfoEnchantement.push(array);
  2163. }
  2164. texteGlobal += "chez l'enchanteur n°"+infoEnchanteur[0]+' ('+infoEnchanteur[1]+'|'+infoEnchanteur[2]+'|'+infoEnchanteur[3]+')';
  2165. listeEquipementEnchantement[idEquipement] = texteGlobal;
  2166. }
  2167. }
  2168.  
  2169. function isEnchant(nom) {
  2170. var monstreEnchant = '';
  2171. for(j in listeInfoEnchantement) {
  2172. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2173. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2174. monstreEnchant=monstre;
  2175. break; // ça permet d'arreter de chercher dans le tableau des EM -> on gagne du temps
  2176. }
  2177. }
  2178. return trim(monstreEnchant);
  2179. }
  2180.  
  2181. function getInfoEnchantementFromMonstre(nom)
  2182. {
  2183. try
  2184. {
  2185. if(!listeMonstreEnchantement)
  2186. {
  2187. computeCompoEnchantement();
  2188. }
  2189. var infosEnchant = '';
  2190. for(j in listeInfoEnchantement) {
  2191. monstre = listeInfoEnchantement[j][2].toLowerCase();
  2192. if((nom+' ').toLowerCase().indexOf(monstre+' ')>=0){
  2193. if(infosEnchant=='')
  2194. infosEnchant=listeInfoEnchantement[j][4];
  2195. else
  2196. infosEnchant+='\n'+listeInfoEnchantement[j][4];
  2197. }
  2198. }
  2199. return trim(infosEnchant);
  2200. }
  2201. catch(e)
  2202. {
  2203. window.alert(e);
  2204. }
  2205. }
  2206.  
  2207. function composantEnchant(Monstre,composant,localisation,qualite) {
  2208. var compo='';
  2209. for(var i=0; i<listeInfoEnchantement.length; i++) {
  2210. if(listeInfoEnchantement[i][2].toLowerCase()==Monstre.toLowerCase() &&
  2211. listeInfoEnchantement[i][0].toLowerCase()==composant.toLowerCase() &&
  2212. listeInfoEnchantement[i][1].toLowerCase()==localisation.toLowerCase() &&
  2213. listeInfoEnchantement[i][3]<=qualite
  2214. ) {
  2215. return listeInfoEnchantement[i][4];
  2216. }
  2217. }
  2218. return compo;
  2219. }
  2220.  
  2221. function insertEnchantInfos(tbody) {
  2222. try
  2223. {
  2224. if(!listeMonstreEnchantement)
  2225. computeCompoEnchantement();
  2226. var nodes = document.evaluate("descendant::img[@alt = 'Composant - Spécial']",
  2227. tbody,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2228. if(nodes.snapshotLength == 0)
  2229. return false;
  2230. var urlImg = URL_MZimg + 'enchant.png';
  2231. for(var i = 0; i < nodes.snapshotLength; i++) {
  2232. var link = nodes.snapshotItem(i).nextSibling.nextSibling;
  2233. var nomCompoTotal = link.firstChild.nodeValue.replace(/\240/g,' ');
  2234. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  2235. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  2236. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf(' ')+1,nomCompoTotal.length);
  2237. var nomMonstre = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" de Qualité"));
  2238. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(' ['));
  2239. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf('[')+1,nomCompoTotal.indexOf(']'));
  2240. if(isEnchant(nomMonstre).length>0)
  2241. {
  2242. var infos = composantEnchant(nomMonstre,nomCompo,localisation,getQualite(qualite));
  2243. if(infos.length>0)
  2244. {
  2245. if(link.parentNode == link.nextSibling.parentNode)
  2246. {
  2247. var tmp = link.nextSibling;
  2248. link.parentNode.insertBefore(createImage(urlImg,infos),link.nextSibling);
  2249. }
  2250. else
  2251. {
  2252. link.parentNode.appendChild(createImage(urlImg,infos));
  2253. }
  2254. }
  2255. }
  2256. }
  2257. }
  2258. catch(e)
  2259. {
  2260. window.alert(e);
  2261. }
  2262. }
  2263.  
  2264. function computeEnchantementEquipement(fontionTexte,formateTexte)
  2265. {
  2266. try
  2267. {
  2268. if(!listeMonstreEnchantement)
  2269. computeCompoEnchantement();
  2270. var nodes = document.evaluate("//a[@class='AllLinks' and contains(@href,'TresorHistory.php')]",
  2271. document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  2272. if(nodes.snapshotLength == 0)
  2273. return false;
  2274. var urlImg = URL_MZimg + 'enchant.png';
  2275. for(var i = 0; i < nodes.snapshotLength; i++)
  2276. {
  2277. var link = nodes.snapshotItem(i);
  2278. var idEquipement = link.getAttribute('href');
  2279. idEquipement = idEquipement.substring(idEquipement.indexOf('ai_IDTresor=')+12);
  2280. idEquipement = parseInt(idEquipement.substring(0,idEquipement.indexOf("'")));
  2281. var nomEquipement = trim(link.firstChild.nodeValue);
  2282. var enchanteur = MY_getValue(numTroll+'.enchantement.'+idEquipement+'.enchanteur');
  2283. if(!enchanteur || enchanteur == '')
  2284. continue;
  2285. var infos = listeEquipementEnchantement[idEquipement];
  2286. infos=formateTexte(infos);
  2287. if(infos.length>0)
  2288. {
  2289. if(link.parentNode == link.nextSibling.parentNode)
  2290. {
  2291. var tmp = link.nextSibling;
  2292. link.parentNode.insertBefore(fontionTexte(urlImg,infos),link.nextSibling);
  2293. }
  2294. else
  2295. {
  2296. link.parentNode.appendChild(fontionTexte(urlImg,infos));
  2297. }
  2298. }
  2299. MY_setValue(numTroll+'.enchantement.'+idEquipement+'.objet',nomEquipement+' ('+idEquipement+')');
  2300. }
  2301. }
  2302. catch(e)
  2303. {
  2304. window.alert(e);
  2305. }
  2306. }
  2307.  
  2308. /*-[functions]---------------- Analyse Tactique ------------------------------*/
  2309.  
  2310.  
  2311. // Les % de toucher
  2312. var c = new Array();
  2313.  
  2314. // coefficients binomiaux
  2315. function cnp(n,k)
  2316. {
  2317. if(c[n] != null && c[n][k] != null)
  2318. return c[n][k];
  2319. if(c[n] == null)
  2320. c[n] = new Array();
  2321. if(k==0)
  2322. {
  2323. c[n][k] = 1;
  2324. return 1;
  2325. }
  2326. var result = cnp(n-1,k-1)*n/k; // mouais... k mul+k div
  2327. c[n][k] = result;
  2328. // Roule debug
  2329. //window.console.log('cnp(' + n + ',' + k + ')=' + result);
  2330. return result;
  2331. }
  2332.  
  2333. // by Dab, à comparer
  2334. function binom(n,p) {
  2335. if(p<0 || p>n) return 0;
  2336. if(c[n])
  2337. if(c[n][p]) return c[n][p];
  2338. else {
  2339. c[n]=[1];
  2340. c[n][n]=1;
  2341. if(p==0 || p==n) return 1;
  2342. }
  2343. if(2*p>n)
  2344. c[n][p]=binom(n,n-p);
  2345. else
  2346. c[n][p]=binom(n-1,p-1)+binom(n-1,p); // k(k-1)/2 additions
  2347. return c[n][p];
  2348. }
  2349.  
  2350. var coeff = new Array();
  2351.  
  2352. function coef(n,p)
  2353. {
  2354. if(n==0 && p==0)
  2355. return 1;
  2356. if(p>n*3.5)
  2357. p = 7*n-p
  2358. // roule désactive cache
  2359. if(coeff[n] != null && coeff[n][p] !=null)
  2360. return coeff[n][p];
  2361. if(coeff[n] == null)
  2362. coeff[n] = new Array();
  2363. var kmax = Math.floor((p-n)/6);
  2364. var x=0;
  2365. for(var k=0;k<=kmax;k++)
  2366. {
  2367. x+=(1-2*(k%2)) * cnp(n,k) * cnp(p-6*k-1,n-1);
  2368. }
  2369. coeff[n][p] = x;
  2370. // Roule debug
  2371. //window.console.log('cnk(' + n + ',' + p + ')=' + x);
  2372. return x;
  2373. }
  2374.  
  2375. function chanceEsquiveParfaite(a,d,ba,bd)
  2376. {
  2377. var win = 0;
  2378. var los = 0;
  2379. if(ba==null)
  2380. ba=0;
  2381. if(bd==null)
  2382. bd=0;
  2383. /* if(6*a+ba<2*(d+bd))
  2384. return 100;
  2385. if(a+ba>2*(6*d+bd))
  2386. return 0;*/
  2387. for(var ds=d;ds<=6*d;ds++)
  2388. {
  2389. var cd = coef(d,ds);
  2390. for(var as=a;as<=6*a;as++)
  2391. {
  2392. if(2*Math.max(as+ba,0) < Math.max(ds+bd,0))
  2393. win += cd * coef(a,as);
  2394. else
  2395. los += cd * coef(a,as);
  2396. }
  2397. }
  2398. // roule debug
  2399. //window.console.log('chanceEsquiveParfaite, att=' + a + ', esq=' + d + ', ba=' + ba + ', bd=' + bd + ', win=' + win + ', los=' + los);
  2400. return Math.round(100*win/(win+los));
  2401. }
  2402.  
  2403. function chanceTouche(a,d,ba,bd)
  2404. {
  2405. var win = 0;
  2406. var los = 0;
  2407. if(ba==null)
  2408. ba=0;
  2409. if(bd==null)
  2410. bd=0;
  2411. if(a+ba>6*d+bd)
  2412. return 100;
  2413. if(6*a+ba<d+bd)
  2414. return 0;
  2415. for(var ds=d;ds<=6*d;ds++)
  2416. {
  2417. var cd = coef(d,ds);
  2418. for(var as=a;as<=6*a;as++)
  2419. {
  2420. if(Math.max(as+ba,0) > Math.max(ds+bd,0))
  2421. win += cd * coef(a,as);
  2422. else
  2423. los += cd * coef(a,as);
  2424. }
  2425. }
  2426. return Math.round(100*win/(win+los));
  2427. }
  2428.  
  2429. function chanceCritique(a,d,ba,bd)
  2430. {
  2431. var win = 0;
  2432. var los = 0;
  2433. if(ba==null)
  2434. ba=0;
  2435. if(bd==null)
  2436. bd=0;
  2437. if(a+ba>2*(6*d+bd))
  2438. return 100;
  2439. if(6*a+ba<2*(d+bd))
  2440. return 0;
  2441. for(var ds=d;ds<=6*d;ds++)
  2442. {
  2443. var cd = coef(d,ds);
  2444. for(var as=a;as<=6*a;as++)
  2445. {
  2446. if(Math.max(as+ba,0) > 2*Math.max(ds+bd,0))
  2447. win += cd * coef(a,as);
  2448. else
  2449. los += cd * coef(a,as);
  2450. }
  2451. }
  2452. return Math.round(100*win/(win+los));
  2453. }
  2454.  
  2455. /***********************************************
  2456. Analyse tactique
  2457. ***********************************************/
  2458.  
  2459. function getTexteAnalyse(modificateur,chiffre)
  2460. {
  2461. if(chiffre==0)
  2462. return chiffre;
  2463. return modificateur+chiffre;
  2464. }
  2465.  
  2466. // rend le HTML pour le tableau de la "calculette"
  2467. function getAnalyseTactique(id,nom)
  2468. {
  2469. var donneesMonstre = listeCDM[id];
  2470. var needAutres=false;
  2471. var i;
  2472. if(donneesMonstre == null)
  2473. return;
  2474. var array = analyseTactique(donneesMonstre,nom); // rend tableau de tableaux avec NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2475. //window.console.log('getAnalyseTactique ' + JSON.stringify(array));
  2476. if(array==null)
  2477. return "";
  2478. 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>";
  2479. for(i=0;i<array.length;i++)
  2480. {
  2481. if(array[i][1]==100 && i>0) // si esquive parfaite du Trõll sur le Monstre est assurée pour cette frappe
  2482. {
  2483. needAutres=true;
  2484. break;
  2485. }
  2486. if(i==1 && array[i][4]>0) // l'attaque normale du Trõll sur le monstre fait des dégâts => gras
  2487. 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>";
  2488. else if(i==0) // attaque du monstre sur le Trõll => italique
  2489. 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>";
  2490. else // autre, pas de décoration
  2491. 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>";
  2492. }
  2493. if(needAutres)
  2494. {
  2495. if(i==array.length-1)
  2496. 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>";
  2497. else if(i==1)
  2498. str+= "<tr class=mh_tdpage><td><b>Toutes attaques</b></td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2499. else
  2500. str+= "<tr class=mh_tdpage><td>Autres attaques</td><td>100%</td><td>0%</td><td>0%</td><td>0</td></tr>";
  2501. }
  2502. return str+"</table>";
  2503. }
  2504.  
  2505. // rend un tableau (un par attaque du Trõll ou du monstre) de tableaux contenant:
  2506. // NomAttaque,chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure
  2507. function analyseTactique(donneesMonstre,nom) {
  2508. try
  2509. {
  2510. var listeAttaques = [];
  2511. // Roule 16/03/2016 ajout des ParseInt car je récupérais parfois une chaine non numérique :(
  2512. var att = parseInt(MY_getValue(numTroll+".caracs.attaque"), 10);
  2513. var reg = parseInt(MY_getValue(numTroll+".caracs.regeneration"), 10);
  2514. var attbmp = parseInt(MY_getValue(numTroll+".caracs.attaque.bmp"), 10);
  2515. var attbmm = parseInt(MY_getValue(numTroll+".caracs.attaque.bmm"), 10);
  2516. var mm = parseInt(MY_getValue(numTroll+".caracs.mm"), 10);
  2517. var deg = parseInt(MY_getValue(numTroll+".caracs.degats"), 10);
  2518. var degbmp = parseInt(MY_getValue(numTroll+".caracs.degats.bmp"), 10);
  2519. var degbmm = parseInt(MY_getValue(numTroll+".caracs.degats.bmm"), 10);
  2520. var vue = parseInt(MY_getValue(numTroll+".caracs.vue"), 10);
  2521. var pv = parseInt(MY_getValue(numTroll+".caracs.pv"), 10);
  2522. var esq = parseInt(Math.max(MY_getValue(numTroll+".caracs.esquive"), 10)-parseInt(MY_getValue(numTroll+".caracs.esquive.nbattaques"),0), 10);
  2523. var esqbonus = parseInt(MY_getValue(numTroll+".caracs.esquive.bm"), 10);
  2524. var arm = parseInt(MY_getValue(numTroll+".caracs.armure"), 10);
  2525. var armbmp = parseInt(MY_getValue(numTroll+".caracs.armure.bmp"), 10);
  2526. var armbmm = parseInt(MY_getValue(numTroll+".caracs.armure.bmm"), 10);
  2527. var modificateurEsquive = '';
  2528. var modificateurArmure = '';
  2529. var modificateurMagie = '';
  2530. var modificateurEsquiveM = '';
  2531. var modificateurArmureM = '';
  2532. var pasDeSR=false;
  2533. var esqM,attM,armM,degM;
  2534. 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)
  2535. return null;
  2536. var td = document.createElement('td')
  2537. td.innerHTML = bbcode(donneesMonstre[4]); // sans déconner ? C'est quoi cette histoire ?
  2538. var esqM = 0;
  2539. try
  2540. {
  2541. esqM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2542. }
  2543. catch(e)
  2544. {
  2545. esqM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2546. modificateurEsquive = '<';
  2547. modificateurArmure = '<';
  2548. modificateurMagie = '<';
  2549. }
  2550. td.innerHTML = bbcode(donneesMonstre[3]);
  2551. var attM = 0;
  2552. try
  2553. {
  2554. attM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2555. }
  2556. catch(e)
  2557. {
  2558. attM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2559. modificateurEsquiveM = '>';
  2560. modificateurArmureM = '>';
  2561. }
  2562. td.innerHTML = bbcode(donneesMonstre[5]);
  2563. var degM = 0;
  2564. try
  2565. {
  2566. degM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2567. }
  2568. catch(e)
  2569. {
  2570. degM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2571. modificateurArmureM = '>';
  2572. }
  2573. td.innerHTML = bbcode(donneesMonstre[7]);
  2574. var armM = 0;
  2575. try
  2576. {
  2577. armM=Math.ceil(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2578. }
  2579. catch(e)
  2580. {
  2581. armM=Math.ceil(parseInt(td.firstChild.nodeValue));
  2582. modificateurArmure = '<';
  2583. }
  2584. var coeffSeuil = 0.95;
  2585. try
  2586. {
  2587. td.innerHTML = bbcode(donneesMonstre[9]);
  2588. var rm = parseInt(td.getElementsByTagName('b')[0].firstChild.nodeValue);
  2589. var v = (rm / mm);
  2590. var seuil = (rm < mm ? Math.max(10,Math.floor(v*50)) : Math.min(90,Math.floor(100 - 50/v)));
  2591. coeffSeuil = (200-seuil)/200;
  2592. }
  2593. catch(e)
  2594. {
  2595. modificateurMagie = '<';
  2596. pasDeSR = true;
  2597. }
  2598. var chanceDEsquiveParfaite = chanceEsquiveParfaite(att,esqM,attbmp+attbmm,0);
  2599. var chanceDeTouche = chanceTouche(att,esqM,attbmp+attbmm,0);
  2600. var chanceDeCritique = chanceCritique(att,esqM,attbmp+attbmm,0);
  2601. // roule debug
  2602. //window.console.log('Attaque normale troll sur monstre, att=' + att + ', esqM=' + esqM + ', attbmp=' + attbmp + ', attbmm=' + attbmm
  2603. // + ', chanceDEsquiveParfaite=' + chanceDEsquiveParfaite + ', chanceDeTouche=' + chanceDeTouche + ', chanceDeCritique=' + chanceDeCritique);
  2604. 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);
  2605. //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);
  2606. listeAttaques.push(new Array("Attaque normale",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2607. if(getSortComp("Vampirisme")>0)
  2608. {
  2609. var pour = getSortComp("Vampirisme");
  2610. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2611. chanceDeTouche = Math.round(chanceTouche(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2612. chanceDeCritique = Math.round(chanceCritique(Math.floor(deg*2/3),esqM,attbmm,0)*pour/100);
  2613. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2614. //str += "\nVampirisme : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2615. listeAttaques.push(new Array("Vampirisme",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2616. }
  2617. if(getSortComp("Siphon des âmes")>0)
  2618. {
  2619. var pour = getSortComp("Siphon des âmes");
  2620. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2621. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2622. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2623. degats = (((chanceDeTouche-chanceDeCritique)*Math.max(reg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(reg*1.5)*2+degbmm,1))/100);
  2624. listeAttaques.push(new Array("Siphon des âmes",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2625. }
  2626. if(getSortComp("Botte Secrète")>0)
  2627. {
  2628. var pour = getSortComp("Botte Secrète");
  2629. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2630. chanceDeTouche = Math.round(chanceTouche(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2631. chanceDeCritique = Math.round(chanceCritique(Math.floor(2*att/3),esqM,Math.floor((attbmp+attbmm)/2),0)*pour/100);
  2632. 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;
  2633. //str += "\nBotte Secrète : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2634. listeAttaques.push(new Array("Botte Secrète",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2635. }
  2636. if(getSortComp("Rafale Psychique")>0)
  2637. {
  2638. var pour = getSortComp("Rafale Psychique");
  2639. chanceDEsquiveParfaite = 0;
  2640. chanceDeTouche = Math.round(100*pour/100);
  2641. chanceDeCritique = Math.round(0*pour/100);
  2642. degats = Math.round(coeffSeuil*((chanceDeTouche-chanceDeCritique)*Math.max(deg*2+degbmm,1)+chanceDeCritique*Math.max(Math.floor(deg*1.5)*2+degbmm,1)))/100;
  2643. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2644. listeAttaques.push(new Array("Rafale Psychique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2645. }
  2646. if(getSortComp("Explosion")>0)
  2647. {
  2648. var pour = getSortComp("Explosion");
  2649. chanceDEsquiveParfaite = 0;
  2650. chanceDeTouche = Math.round(100*pour/100);
  2651. chanceDeCritique = Math.round(0*pour/100);
  2652. 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;
  2653. //str += "\nRafale Psychique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2654. listeAttaques.push(new Array("Explosion",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,'',pasDeSR?modificateurMagie:''));
  2655. }
  2656. if(getSortComp("Projectile Magique")>0)
  2657. {
  2658. var pour = getSortComp("Projectile Magique");
  2659. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(vue,esqM,attbmm,0)*pour/100);
  2660. chanceDeTouche = Math.round(chanceTouche(vue,esqM,attbmm,0)*pour/100);
  2661. chanceDeCritique = Math.round(chanceCritique(vue,esqM,attbmm,0)*pour/100);
  2662. 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;
  2663. //str += "\nProjectile Magique : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2664. listeAttaques.push(new Array("Projectile Magique",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2665. }
  2666. if(getSortComp("Frénésie")>0)
  2667. {
  2668. var pour = getSortComp("Frénésie");
  2669. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2670. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2671. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2672. 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;
  2673. //str += "\nFrénésie : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2674. listeAttaques.push(new Array("Frénésie",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2675. }
  2676. if(getSortComp("Charger")>0)
  2677. {
  2678. var pour = getSortComp("Charger");
  2679. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*pour/100);
  2680. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm+attbmp,0)*pour/100);
  2681. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm+attbmp,0)*pour/100);
  2682. 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;
  2683. //str += "\nCharge : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2684. listeAttaques.push(new Array("Charger",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurArmure));
  2685. }
  2686. if(getSortComp("Griffe du Sorcier")>0)
  2687. {
  2688. var pour = getSortComp("Griffe du Sorcier");
  2689. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(att,esqM,attbmm,0)*pour/100);
  2690. chanceDeTouche = Math.round(chanceTouche(att,esqM,attbmm,0)*pour/100);
  2691. chanceDeCritique = Math.round(chanceCritique(att,esqM,attbmm,0)*pour/100);
  2692. 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;
  2693. //str += "\nGriffe du Sorcier : Touché "+chanceDeTouche+"% Critique "+chanceDeCritique+"% Dégâts "+(degats);
  2694. listeAttaques.push(new Array("Griffe du Sorcier",chanceDEsquiveParfaite,chanceDeTouche,chanceDeCritique,degats,modificateurEsquive,modificateurMagie));
  2695. }
  2696. if(getSortComp("Attaque Précise",1)>0)
  2697. {
  2698. var niveau = 5;
  2699. var oldPour = 0;
  2700. var chanceDEsquiveParfaite = 0;
  2701. var chanceDeTouche = 0;
  2702. var chanceDeCritique = 0;
  2703. degats = 0;
  2704. while(niveau>0)
  2705. {
  2706. var pour = getSortComp("Attaque Précise",niveau);
  2707. if(pour>oldPour)
  2708. {
  2709. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2710. var chanceDeToucheNiveau = chanceTouche(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2711. var chanceDeCritiqueNiveau = chanceCritique(Math.min(att+3*niveau,Math.floor(att*1.5)),esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2712. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2713. chanceDeTouche += chanceDeToucheNiveau;
  2714. chanceDeCritique += chanceDeCritiqueNiveau;
  2715. 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);
  2716. oldPour = pour;
  2717. }
  2718. niveau--;
  2719. }
  2720. //str += "\nAttaque Précise : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2721. 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));
  2722. }
  2723. if(getSortComp("Coup de Butoir",1)>0)
  2724. {
  2725. var niveau = 5;
  2726. var oldPour =0;
  2727. var chanceDEsquiveParfaite = 0;
  2728. var chanceDeTouche=0;
  2729. var chanceDeCritique=0;
  2730. degats=0;
  2731. while(niveau>0)
  2732. {
  2733. var pour = getSortComp("Coup de Butoir",niveau);
  2734. if(pour>oldPour)
  2735. {
  2736. var chanceDEsquiveParfaiteNiveau = chanceEsquiveParfaite(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2737. var chanceDeToucheNiveau = chanceTouche(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2738. var chanceDeCritiqueNiveau = chanceCritique(att,esqM,attbmm+attbmp,0)*(pour-oldPour)/100;
  2739. chanceDEsquiveParfaite += chanceDEsquiveParfaiteNiveau;
  2740. chanceDeTouche += chanceDeToucheNiveau;
  2741. chanceDeCritique += chanceDeCritiqueNiveau;
  2742. 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);
  2743. oldPour = pour;
  2744. }
  2745. niveau--;
  2746. }
  2747. //str += "\nCoup de Butoir : Touché "+(Math.round(chanceDeTouche*100)/100)+"% Critique "+(Math.round(chanceDeCritique*100)/100)+"% Dégâts "+Math.round(degats*100)/100;
  2748. 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));
  2749. }
  2750. 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;});
  2751. if(nom.toLowerCase().indexOf("mégacéphale")==-1)
  2752. {
  2753. chanceDEsquiveParfaite = Math.round(chanceEsquiveParfaite(attM,esq,0,esqbonus));
  2754. chanceDeTouche = Math.round(chanceTouche(attM,esq,0,esqbonus));
  2755. chanceDeCritique = Math.round(chanceCritique(attM,esq,0,esqbonus));
  2756. }
  2757. else
  2758. {
  2759. chanceDEsquiveParfaite = 0;
  2760. chanceDeTouche = 100;
  2761. chanceDeCritique = 0;
  2762. }
  2763. 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;
  2764.  
  2765. 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));
  2766. return listeAttaques;
  2767. }
  2768. catch(e) { window.alert(e);}
  2769. }
  2770.  
  2771. // x~~x marque pour s'y retrouver sous l'éditeur
  2772.  
  2773. /*
  2774. * This file is part of MountyZilla (http://mountyzilla.tilk.info/),
  2775. * published under GNU License v2.
  2776. *
  2777. * Patch :
  2778. * gestion des missions terminées
  2779. */
  2780. // x~x mission_liste
  2781.  
  2782. function checkLesMimis() { // supprimer les missions finie de numTroll.MISSIONS
  2783. try {
  2784. var titresMimis = document.evaluate(
  2785. "//div[@class='mh_titre3']/b/a[contains(@href,'Mission_')]",
  2786. document, null, 7, null
  2787. );
  2788. var obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  2789. } catch(e) {
  2790. window.console.error(traceStack(e, 'mission_liste initialisation'));
  2791. return;
  2792. }
  2793. var enCours = {};
  2794. for(var i=0 ; i<titresMimis.snapshotLength ; i++) {
  2795. var num = titresMimis.snapshotItem(i).textContent.match(/\d+/)[0];
  2796. enCours[num] = true;
  2797. }
  2798. for(var numMimi in obMissions) {
  2799. if(!enCours[numMimi]) {
  2800. delete obMissions[numMimi];
  2801. }
  2802. }
  2803. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  2804. }
  2805.  
  2806. function do_mission_liste() {
  2807. checkLesMimis();
  2808. }
  2809.  
  2810. /*******************************************************************************
  2811. * This file is part of Mountyzilla. *
  2812. * *
  2813. * Mountyzilla is free software; you can redistribute it and/or modify *
  2814. * it under the terms of the GNU General Public License as published by *
  2815. * the Free Software Foundation; either version 2 of the License, or *
  2816. * (at your option) any later version. *
  2817. * *
  2818. * Mountyzilla is distributed in the hope that it will be useful, *
  2819. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  2820. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  2821. * GNU General Public License for more details. *
  2822. * *
  2823. * You should have received a copy of the GNU General Public License *
  2824. * along with Mountyzilla; if not, write to the Free Software *
  2825. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  2826. *******************************************************************************/
  2827.  
  2828. // x~x actions
  2829.  
  2830. /* TODO
  2831. * getLvl pour Explo, Rotobaffe et cie
  2832. */
  2833.  
  2834.  
  2835.  
  2836. /* Page de combat */
  2837.  
  2838. function getLevel() {
  2839. var divList = document.getElementsByTagName('div');
  2840. if(divList.length <= 2)
  2841. return;
  2842. // On essaie de voir si cette action était une attaque
  2843. var pList = document.getElementsByTagName('p');
  2844. var nomM = '';
  2845. // Modification pour Frénésie by TetDure
  2846. var numAtt = 0;
  2847. for (var i = 0; i < pList.length; i++) {
  2848. if(pList[i].firstChild) {
  2849. nomM = pList[i].firstChild.nodeValue;
  2850. if(nomM && nomM.indexOf('Vous avez attaqué un') == 0)
  2851. numAtt++;
  2852. }
  2853. }
  2854. if(nomM == '')
  2855. return;
  2856. // Si c'est une attaque normale, un seul PX
  2857. var comPX = 1;
  2858. if(divList[2].firstChild.nodeValue.indexOf('Attaque Normale') == -1 && numAtt != 2)
  2859. comPX++;
  2860.  
  2861. // Extraction des infos du monstre attaqué
  2862. var idM;
  2863. var male;
  2864. if(nomM.slice(20, 21) == 'e') {
  2865. male = false;
  2866. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2867. nomM = nomM.slice(22, nomM.indexOf('(') - 1);
  2868. }
  2869. else {
  2870. male = true;
  2871. idM = nomM.substring(nomM.indexOf('(') + 1, nomM.indexOf(')'));
  2872. nomM = nomM.slice(21, nomM.indexOf('(') - 1);
  2873. }
  2874. if(idM == '')
  2875. return;
  2876. var bList = document.getElementsByTagName('b');
  2877. var niveau = '';
  2878. for (var i = 0; i < bList.length; i++) {
  2879. var b = bList[i];
  2880. if(b.childNodes[0].nodeValue != "TUÉ")
  2881. continue;
  2882. var nbPX = "";
  2883. for (i++; i < bList.length; i++) {
  2884. // Si plusieurs monstres ont été tués (par ex. explo), on ne peut pas déduire leurs niveaux
  2885. if(bList[i].childNodes[0].nodeValue == "TUÉ")
  2886. return;
  2887. if(bList[i].childNodes[0].nodeValue.indexOf("PX") != -1) {
  2888. nbPX = bList[i].childNodes[0].nodeValue;
  2889. break;
  2890. }
  2891. }
  2892. if(nbPX == '')
  2893. return;
  2894. // Si on arrive ici c'est qu'on a trouvé un (et un seul) monstre tué et les PX gagnés
  2895. nbPX = parseInt(nbPX.slice(0, nbPX.indexOf("P") - 1));
  2896. if(!nbPX)
  2897. nbPX = 0;
  2898. chaine = (male ? "Il" : "Elle") + " était de niveau ";
  2899. niveau = (nbPX * 1 + 2 * nivTroll - 10 - comPX) / 3;
  2900. if(comPX > nbPX) {
  2901. chaine += "inférieur ou égal à " + Math.floor(niveau) + ".";
  2902. niveau = "";
  2903. } else if(Math.floor(niveau) == niveau) {
  2904. chaine += niveau + ".";
  2905. } else {
  2906. chaine = "Mountyzilla n'est pas arrivé à calculer le niveau du monstre.";
  2907. niveau = "";
  2908. }
  2909. insertBr(b.nextSibling.nextSibling.nextSibling);
  2910. insertText(b.nextSibling.nextSibling.nextSibling, chaine);
  2911. }
  2912.  
  2913. if(niveau != '') {
  2914. var button = insertButtonCdm('as_Action');
  2915. button.setAttribute("onClick","window.open('" + URL_pageNiv + "?id=" + (idM * 1) + "&monstre="
  2916. + escape(nomM) + "&niveau=" + escape(niveau)
  2917. + "', 'popupCdm', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  2918. + "this.value = 'Merci de votre participation'; this.disabled = true;");
  2919. }
  2920. }
  2921.  
  2922.  
  2923. /*-[functions]------------- Messages du bot : MM/RM --------------------------*/
  2924.  
  2925. function insertInfoMagie(node, intitule, magie) {
  2926. if(node.nextSibling) {
  2927. node = node.nextSibling;
  2928. insertBr(node);
  2929. insertText(node, intitule);
  2930. insertText(node, magie, true);
  2931. } else {
  2932. node = node.parentNode;
  2933. appendBr(node);
  2934. appendText(node, intitule);
  2935. appendText(node, magie, true);
  2936. }
  2937. }
  2938.  
  2939. function getMM(sr) {
  2940. if(rmTroll<=0) {
  2941. return 'Inconnue (quelle idée d\'avoir une RM valant'+rmTroll+' !)';
  2942. }
  2943. sr = Number(sr.match(/\d+/)[0]);
  2944. if(sr==10) {
  2945. return '\u2265 '+5*rmTroll;
  2946. }
  2947. if(sr<=50) {
  2948. return Math.round(50*rmTroll/sr);
  2949. }
  2950. if(sr<90) {
  2951. return Math.round((100-sr)*rmTroll/50);
  2952. }
  2953. return '\u2264 '+Math.round(rmTroll/5);
  2954. }
  2955.  
  2956. function traiteMM() {
  2957. var node = document.evaluate(
  2958. "//b[contains(preceding::text()[1], 'Seuil de Résistance')]/text()[1]",
  2959. document, null, 9, null).singleNodeValue;
  2960. if(node) {
  2961. var mm = getMM(node.nodeValue);
  2962. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  2963. } else {
  2964. var node = document.evaluate(
  2965. "//p/text()[contains(., 'Seuil de Résistance')]",
  2966. document, null, 9, null).singleNodeValue;
  2967. if(!node) {
  2968. return;
  2969. }
  2970. var mm = getMM(node.nodeValue);
  2971. node = node.nextSibling.nextSibling;
  2972. }
  2973. insertInfoMagie(node,'MM approximative de l\'Attaquant...: ',mm);
  2974. }
  2975.  
  2976. function getRM(sr) {
  2977. if(mmTroll<=0) {
  2978. return 'Inconnue (quelle idée d\'avoir une MM valant'+mmTroll+' !)';
  2979. }
  2980. sr = Number(sr.match(/\d+/)[0]);
  2981. if(sr==10) {
  2982. return '\u2264 '+Math.round(mmTroll/5);
  2983. }
  2984. if(sr<=50) {
  2985. return Math.round(sr*mmTroll/50);
  2986. }
  2987. if(sr<90) {
  2988. return Math.round(50*mmTroll/(100-sr));
  2989. }
  2990. return '\u2265 '+5*mmTroll;
  2991. }
  2992.  
  2993. function traiteRM() {
  2994. var nodes = document.evaluate(
  2995. "//b[contains(preceding::text()[1],'Seuil de Résistance')]/text()[1]",
  2996. document, null, 7, null);
  2997. if(nodes.snapshotLength==0) {
  2998. return;
  2999. }
  3000. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  3001. var node = nodes.snapshotItem(i);
  3002. var rm = getRM(node.nodeValue);
  3003. node = node.parentNode.nextSibling.nextSibling.nextSibling;
  3004. insertInfoMagie(node, 'RM approximative de la Cible.......: ', rm);
  3005. }
  3006. }
  3007.  
  3008.  
  3009. /* Fonction stats IdT par Raistlin */
  3010. /*function getIdt() {
  3011. if(MY_getValue("SEND_IDT") == "non")
  3012. return false;
  3013. var regExpBeginning = /^\s+/;
  3014. var regExpEnd = /\s+$/;
  3015.  
  3016. var nomIdt = document.evaluate(
  3017. "//tr/td[contains(p/text(),'identification a donné le résultat suivant : ')]/b/text()",
  3018. document, null, XPathResult.STRING_TYPE, null).stringValue;
  3019. if(!nomIdt)
  3020. return false;
  3021.  
  3022. var caracIdt;
  3023. if(nomIdt.indexOf("Malédiction !") != -1) {
  3024. caracIdt = "";
  3025. nomIdt = "Mission maudite";
  3026. } else {
  3027. caracIdt = nomIdt.slice(nomIdt.indexOf("(") + 1, nomIdt.indexOf(")"));
  3028. nomIdt = nomIdt.slice(nomIdt.indexOf(" - ")+3);
  3029. nomIdt = nomIdt.slice(0, nomIdt.indexOf("(") - 1);
  3030. nomIdt = nomIdt.replace(regExpBeginning, "").replace(regExpEnd, "");
  3031. }
  3032. FF_XMLHttpRequest({
  3033. method: 'GET',
  3034. url: idtURL + "?item=" + escape(nomIdt) + "&descr=" + escape(caracIdt),
  3035. headers : {
  3036. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  3037. 'Accept': 'application/atom+xml,application/xml,text/xml',
  3038. }
  3039. });
  3040. return true;
  3041. }*/
  3042.  
  3043.  
  3044. /*-[functions]------------------- Décalage DLA -------------------------------*/
  3045.  
  3046. function confirmeDecalage() {
  3047. // On vérifie que MH n'excluera pas déjà la demande (validNumeric)
  3048. var nbMinutes = document.getElementById('ai_NbMinutes').value;
  3049. if(!nbMinutes || isNaN(nbMinutes) || nbMinutes<1) { return false; }
  3050. var newDLA = new Date( oldDLA );
  3051. newDLA.setMinutes( newDLA.getMinutes()+Number(nbMinutes) );
  3052. return window.confirm(
  3053. 'Votre DLA sera décalée au : '+newDLA.toLocaleString()
  3054. +'\nConfirmez-vous ce décalage ?'
  3055. );
  3056. }
  3057.  
  3058. function newsubmitDLA(evt) {
  3059. evt.stopPropagation();
  3060. evt.preventDefault();
  3061. if(confirmeDecalage()) {
  3062. this.submit();
  3063. }
  3064. }
  3065.  
  3066. function changeActionDecalage() {
  3067. if(MY_getValue('CONFIRMEDECALAGE')!='true') {
  3068. return;
  3069. }
  3070. try {
  3071. // On récupère le contenu du script JS MH de calcul du décalage
  3072. var scriptTxt = document.evaluate(
  3073. ".//script[ not(@src) ]",
  3074. document, null, 9, null
  3075. ).singleNodeValue.textContent;
  3076. // On en extrait la DLA courante
  3077. scriptTxt = scriptTxt.slice(scriptTxt.indexOf('new Date(')+9);
  3078. scriptTxt = scriptTxt.split('\n')[0];
  3079. var nbs = scriptTxt.match(/\d+/g);
  3080. oldDLA = new Date( nbs[0],nbs[1],nbs[2],nbs[3],nbs[4],nbs[5] );
  3081. } catch(e) {
  3082. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3083. window.console.error(traceStack(e, 'changeActionDecalage DLA non trouvée'));
  3084. return;
  3085. }
  3086. var form = document.getElementsByName('ActionForm')[0];
  3087. if(form) {
  3088. form.addEventListener('submit', newsubmitDLA, true);
  3089. } else {
  3090. avertissement('Erreur de parsage : confirmation de décalage impossible');
  3091. window.console.error('[changeActionDecalage] ActionForm non trouvé');
  3092. }
  3093. }
  3094.  
  3095. /*-[functions]------------------- Alerte Mundi -------------------------------*/
  3096.  
  3097. function prochainMundi() {
  3098. try {
  3099. var node = document.evaluate(
  3100. "//div[@class='dateAction']/b",
  3101. document, null, 9, null
  3102. ).singleNodeValue;
  3103. } catch(e) {
  3104. window.console.error(traceStack(e, 'prochainMundi Date introuvable'));
  3105. return;
  3106. }
  3107. if(!node) { return; }
  3108.  
  3109. var longueurMois = node.textContent.indexOf('Saison du Hum')==-1?28:14;
  3110. var jour = longueurMois+1-getNumber(node.textContent);
  3111. if(node.textContent.indexOf('Mundidey')!=-1) { jour=longueurMois; }
  3112. var txt = '[Prochain Mundidey ';
  3113. if(jour>1) {
  3114. txt += 'dans '+jour+' jours]';
  3115. } else {
  3116. txt += 'demain]';
  3117. }
  3118. insertText(node.parentNode.nextSibling,txt,true);
  3119. }
  3120.  
  3121.  
  3122. /* Fonction principale */
  3123.  
  3124. function dispatch() {
  3125. if(isPage('MH_Play/Play_action')) {
  3126. prochainMundi();
  3127. } else if(isPage('MH_Play/Actions/Play_a_Decaler.php')) {
  3128. var oldDLA;
  3129. changeActionDecalage();
  3130. } else if(isPage('MH_Play/Actions')) {
  3131. if(document.evaluate(
  3132. "//form/descendant::p/text()[contains(., 'Zone Piégée')]",
  3133. document, null, 2, null
  3134. ).stringValue) {
  3135. traiteMM();
  3136. } else if(document.evaluate(
  3137. "//tr/td/descendant::p/text()[contains(., 'identification a donné')]",
  3138. document, null, 2, null
  3139. ).stringValue) {
  3140. //getIdt();
  3141. traiteRM();
  3142. } /*else {
  3143. // Est censé se lancer sur quoi *précisément* ?
  3144. traiteRM();
  3145. getLevel();
  3146. }*/
  3147. } else {
  3148. /* Traitement des messages du bot */
  3149. var messageTitle = document.evaluate(
  3150. "//form/table/tbody/tr[1]/td[1]/"
  3151. +"descendant::text()[contains(.,'[MountyHall]')]",
  3152. document, null, 2, null
  3153. ).stringValue;
  3154. if(messageTitle.indexOf('Attaquant') != -1 &&
  3155. messageTitle.indexOf('sur') != -1) {
  3156. getLevel();
  3157. traiteRM();
  3158. } else if(messageTitle.indexOf('Résultat du pouvoir') != -1 ||
  3159. messageTitle.indexOf('Défenseur') != -1) {
  3160. traiteMM();
  3161. } else if(messageTitle.indexOf('Identification des trésors') != -1 ||
  3162. // à replacer avec Attaque après révision getLvl :
  3163. messageTitle.indexOf('Explosion') != -1 ||
  3164. messageTitle.indexOf('Insulte') != -1) {
  3165. traiteRM();
  3166. }
  3167. }
  3168. }
  3169.  
  3170. function do_actions() {
  3171. start_script(31);
  3172. dispatch();
  3173. displayScriptTime();
  3174. }
  3175.  
  3176. /*********************************************************************************
  3177. * This file is part of Mountyzilla. *
  3178. * *
  3179. * Mountyzilla is free software; you can redistribute it and/or modify *
  3180. * it under the terms of the GNU General Public License as published by *
  3181. * the Free Software Foundation; either version 2 of the License, or *
  3182. * (at your option) any later version. *
  3183. * *
  3184. * Mountyzilla is distributed in the hope that it will be useful, *
  3185. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3186. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3187. * GNU General Public License for more details. *
  3188. * *
  3189. * You should have received a copy of the GNU General Public License *
  3190. * along with Mountyzilla; if not, write to the Free Software *
  3191. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3192. *********************************************************************************/
  3193.  
  3194. // x~x pre-enchant
  3195.  
  3196. /* 2013-08-19 : correction auto syntaxe alert */
  3197.  
  3198. var combobox=null;
  3199.  
  3200. function changeObject()
  3201. {
  3202. if(!combobox)
  3203. return ;
  3204. var id = combobox.options[combobox.selectedIndex].value;
  3205. var texte = combobox.options[combobox.selectedIndex].firstChild.nodeValue;
  3206. if(!id || id=="")
  3207. {
  3208. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3209. return;
  3210. }
  3211. MY_setValue(numTroll+".enchantement.lastEquipement",id+";"+texte);
  3212. }
  3213.  
  3214. function treatePreEnchantement() {
  3215. var input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3216. if(!input || input.getAttribute("type")=="hidden")
  3217. {
  3218. return false;
  3219. }
  3220. MY_setValue(numTroll+".enchantement.lastEnchanteur",input.getAttribute("value"));
  3221. combobox = document.evaluate("//select[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3222. if(!combobox)
  3223. {
  3224. return true;
  3225. }
  3226. combobox.addEventListener('change', changeObject, true);
  3227. return true;
  3228. }
  3229.  
  3230. function treateEnchantement() {
  3231. var input = document.evaluate("//input[@name='ai_IDTE']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3232. if(!input || input.getAttribute("type")!="hidden")
  3233. {
  3234. return false;
  3235. }
  3236. var idEquipement = input.getAttribute("value");
  3237. var nomEquipement = "Equipement inconnu ("+idEquipement+")";
  3238. var enchanteur = MY_getValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  3239. if(enchanteur && enchanteur != null)
  3240. return true;
  3241. input = document.evaluate("//input[@name='ai_IDLI']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  3242. if(!input || input.getAttribute("type")!="hidden")
  3243. {
  3244. return false;
  3245. }
  3246. var idEnchanteur = input.getAttribute("value");
  3247. var nodes = document.evaluate(
  3248. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3249. if (nodes.snapshotLength != 3)
  3250. return;
  3251. for(var i=0;i<3;i++)
  3252. {
  3253. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3254. texte = texte.replace(" d'une "," d'un ");
  3255. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3256. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3257. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3258. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3259. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3260. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3261. }
  3262. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3263. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3264. var liste = MY_getValue(numTroll+".enchantement.liste");
  3265. if(!liste || liste=="")
  3266. {
  3267. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3268. }
  3269. else
  3270. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3271. }
  3272.  
  3273. function do_pre_enchant() {
  3274. start_script(60);
  3275. if(!treatePreEnchantement())
  3276. treateEnchantement();
  3277. displayScriptTime();
  3278. }
  3279.  
  3280. /*********************************************************************************
  3281. * This file is part of Mountyzilla. *
  3282. * *
  3283. * Mountyzilla is free software; you can redistribute it and/or modify *
  3284. * it under the terms of the GNU General Public License as published by *
  3285. * the Free Software Foundation; either version 2 of the License, or *
  3286. * (at your option) any later version. *
  3287. * *
  3288. * Mountyzilla is distributed in the hope that it will be useful, *
  3289. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3290. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3291. * GNU General Public License for more details. *
  3292. * *
  3293. * You should have received a copy of the GNU General Public License *
  3294. * along with Mountyzilla; if not, write to the Free Software *
  3295. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3296. *********************************************************************************/
  3297.  
  3298. // x~x enchant
  3299.  
  3300. /* 2013-08-19 : correction auto syntaxe alert */
  3301.  
  3302. function treateEnchantement() {
  3303. var idEnchanteur = MY_getValue(numTroll+".enchantement.lastEnchanteur");
  3304. var infoEquipement = MY_getValue(numTroll+".enchantement.lastEquipement");
  3305. if(!idEnchanteur || idEnchanteur=="" || !infoEquipement || infoEquipement=="")
  3306. return;
  3307. var tab = infoEquipement.split(";");
  3308. if(tab.length<2)
  3309. return;
  3310. var idEquipement = tab[0];
  3311. var nomEquipement = tab[1];
  3312. for(var i=2;i<tab.length;i++)
  3313. nomEquipement += ";"+tab[i];
  3314. var nodes = document.evaluate(
  3315. "//p/img[@src='../Images/greenball.gif']/following-sibling::text()", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  3316. if (nodes.snapshotLength != 3)
  3317. return;
  3318. for(var i=0;i<3;i++)
  3319. {
  3320. var texte = trim(nodes.snapshotItem(i).nodeValue);
  3321. texte = texte.replace(" d'une "," d'un ");
  3322. var compo = texte.substring(0,texte.indexOf(" d'un "));
  3323. var monstre = texte.substring(texte.indexOf(" d'un ")+6,texte.indexOf(" d'au minimum"));
  3324. monstre = monstre.replace(/ Géante?/,"");
  3325. var qualite = texte.substring(texte.indexOf("Qualité ")+8,texte.indexOf(" ["));
  3326. var localisation = texte.substring(texte.indexOf("[")+1,texte.indexOf("]"));
  3327. //window.alert(compo+" ["+localisation+"] "+monstre+" "+qualite);
  3328. MY_setValue(numTroll+".enchantement."+idEquipement+".composant."+i,compo+";"+localisation+";"+monstre.replace(/ Géante?/,"")+";"+qualite+";"+trim(nodes.snapshotItem(i).nodeValue));
  3329. }
  3330. MY_setValue(numTroll+".enchantement."+idEquipement+".enchanteur",idEnchanteur+";"+MY_getValue(numTroll+".position.X")+";"+MY_getValue(numTroll+".position.Y")+";"+MY_getValue(numTroll+".position.N"));
  3331. MY_setValue(numTroll+".enchantement."+idEquipement+".objet",nomEquipement);
  3332. var liste = MY_getValue(numTroll+".enchantement.liste");
  3333. if(!liste || liste=="")
  3334. {
  3335. MY_setValue(numTroll+".enchantement.liste",idEquipement);
  3336. }
  3337. else
  3338. MY_setValue(numTroll+".enchantement.liste",liste+";"+idEquipement);
  3339. }
  3340.  
  3341. function do_enchant() {
  3342. start_script(60);
  3343.  
  3344. treateEnchantement();
  3345. MY_removeValue(numTroll+".enchantement.lastEquipement");
  3346. MY_removeValue(numTroll+".enchantement.lastEnchanteur");
  3347. displayScriptTime();
  3348. }
  3349.  
  3350. /*********************************************************************************
  3351. * This file is part of Mountyzilla. *
  3352. * *
  3353. * Mountyzilla is free software; you can redistribute it and/or modify *
  3354. * it under the terms of the GNU General Public License as published by *
  3355. * the Free Software Foundation; either version 2 of the License, or *
  3356. * (at your option) any later version. *
  3357. * *
  3358. * Mountyzilla is distributed in the hope that it will be useful, *
  3359. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3360. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3361. * GNU General Public License for more details. *
  3362. * *
  3363. * You should have received a copy of the GNU General Public License *
  3364. * along with Mountyzilla; if not, write to the Free Software *
  3365. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3366. *********************************************************************************/
  3367.  
  3368. // x~x myevent
  3369.  
  3370. // Script désactivé en attendant la màj vers le nouveau système de missions.
  3371. function do_myevent() {
  3372. }
  3373.  
  3374. /*********************************************************************************
  3375. * This file is part of Mountyzilla. *
  3376. * *
  3377. * Mountyzilla is free software; you can redistribute it and/or modify *
  3378. * it under the terms of the GNU General Public License as published by *
  3379. * the Free Software Foundation; either version 2 of the License, or *
  3380. * (at your option) any later version. *
  3381. * *
  3382. * Mountyzilla is distributed in the hope that it will be useful, *
  3383. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3384. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3385. * GNU General Public License for more details. *
  3386. * *
  3387. * You should have received a copy of the GNU General Public License *
  3388. * along with Mountyzilla; if not, write to the Free Software *
  3389. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3390. *********************************************************************************/
  3391.  
  3392. // x~x malus
  3393.  
  3394. /* v1.4 - 2014-01-06
  3395. * - Gestion des sorts double composante
  3396. * v1.4.1 - 2014-01-22
  3397. * - Correction décumul
  3398. * TODO
  3399. * - Identifier la position de "PV" dans l'ordre MH
  3400. */
  3401.  
  3402. var listeBM;
  3403.  
  3404.  
  3405. /* [functions] Utilitaires */
  3406.  
  3407. function decumul(bmt,nbr) {
  3408. var bmr;
  3409. if(!nbr || nbr<2) bmr = bmt;
  3410. else if(nbr==2) bmr = parseInt(0.67*bmt);
  3411. else if(nbr==3) bmr = parseInt(0.40*bmt);
  3412. else if(nbr==4) bmr = parseInt(0.25*bmt);
  3413. else if(nbr==5) bmr = parseInt(0.15*bmt);
  3414. else bmr = parseInt(0.1*bmt);
  3415. if(bmt<0) return Math.min(-1,bmr);
  3416. return Math.max(1,bmr);
  3417. }
  3418.  
  3419. function triecaracs(a,b) { // version Yoyor, mod by Dab
  3420. // Roule 23/11/2016 ajout PV
  3421. switch( a ) {
  3422. case 'ATT':
  3423. return -1;
  3424. case 'ESQ':
  3425. if(b=='ATT') return 1;
  3426. return -1;
  3427. case 'DEG':
  3428. switch( b ) {
  3429. case 'ATT':
  3430. case 'ESQ':
  3431. return 1;
  3432. default:
  3433. return -1;
  3434. }
  3435. case 'REG':
  3436. switch( b ) {
  3437. case 'ATT':
  3438. case 'ESQ':
  3439. case 'DEG':
  3440. return 1;
  3441. default:
  3442. return -1;
  3443. }
  3444. case 'Vue':
  3445. switch( b ) {
  3446. case 'ATT':
  3447. case 'ESQ':
  3448. case 'DEG':
  3449. case 'REG':
  3450. return 1;
  3451. default:
  3452. return -1;
  3453. }
  3454. case 'TOUR':
  3455. switch( b ) {
  3456. case 'ATT':
  3457. case 'ESQ':
  3458. case 'DEG':
  3459. case 'REG':
  3460. case 'Vue':
  3461. return 1;
  3462. default:
  3463. return -1;
  3464. }
  3465. case 'PV':
  3466. switch( b ) {
  3467. case 'ATT':
  3468. case 'ESQ':
  3469. case 'DEG':
  3470. case 'REG':
  3471. case 'Vue':
  3472. case 'TOUR':
  3473. return 1;
  3474. default:
  3475. return -1;
  3476. }
  3477. case 'Armure':
  3478. switch( b ) {
  3479. case 'ATT':
  3480. case 'ESQ':
  3481. case 'DEG':
  3482. case 'REG':
  3483. case 'Vue':
  3484. case 'TOUR':
  3485. case 'PV':
  3486. return 1;
  3487. default:
  3488. return -1;
  3489. }
  3490. case 'RM':
  3491. switch( b ) {
  3492. case 'ATT':
  3493. case 'ESQ':
  3494. case 'DEG':
  3495. case 'REG':
  3496. case 'Vue':
  3497. case 'TOUR':
  3498. case 'PV':
  3499. case 'Armure':
  3500. return 1;
  3501. default:
  3502. return -1;
  3503. }
  3504. case 'MM':
  3505. switch( b ) {
  3506. case 'ATT':
  3507. case 'ESQ':
  3508. case 'DEG':
  3509. case 'REG':
  3510. case 'Vue':
  3511. case 'TOUR':
  3512. case 'PV':
  3513. case 'Armure':
  3514. case 'RM':
  3515. return 1;
  3516. default:
  3517. return -1;
  3518. }
  3519. case 'Concentration':
  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. return 1;
  3532. default:
  3533. return -1;
  3534. }
  3535. case 'Fatigue':
  3536. switch( b ) {
  3537. case 'ATT':
  3538. case 'ESQ':
  3539. case 'DEG':
  3540. case 'REG':
  3541. case 'Vue':
  3542. case 'TOUR':
  3543. case 'PV':
  3544. case 'Armure':
  3545. case 'RM':
  3546. case 'MM':
  3547. case 'Concentration':
  3548. return 1;
  3549. default:
  3550. return -1;
  3551. }
  3552. case "Dés d'attaque":
  3553. switch( b ) {
  3554. case 'ATT':
  3555. case 'ESQ':
  3556. case 'DEG':
  3557. case 'REG':
  3558. case 'Vue':
  3559. case 'TOUR':
  3560. case 'PV':
  3561. case 'Armure':
  3562. case 'RM':
  3563. case 'MM':
  3564. case 'Concentration':
  3565. case 'Fatigue':
  3566. return 1;
  3567. default:
  3568. return -1;
  3569. }
  3570. case 'Dés de dégâts':
  3571. switch( b ) {
  3572. case 'ATT':
  3573. case 'ESQ':
  3574. case 'DEG':
  3575. case 'REG':
  3576. case 'Vue':
  3577. case 'TOUR':
  3578. case 'PV':
  3579. case 'Armure':
  3580. case 'RM':
  3581. case 'MM':
  3582. case 'Concentration':
  3583. case 'Fatigue':
  3584. case "Dés d'attaque":
  3585. return 1;
  3586. default:
  3587. return -1;
  3588. }
  3589. default :
  3590. switch( b ) {
  3591. case 'ATT':
  3592. case 'ESQ':
  3593. case 'DEG':
  3594. case 'REG':
  3595. case 'Vue':
  3596. case 'TOUR':
  3597. case 'PV':
  3598. case 'Armure':
  3599. case 'RM':
  3600. case 'MM':
  3601. case 'Concentration':
  3602. case 'Fatigue':
  3603. case "Dés d'attaque":
  3604. case 'Dés de dégâts':
  3605. return 1;
  3606. default:
  3607. return -1;
  3608. }
  3609. }
  3610. }
  3611.  
  3612.  
  3613. /* [functions] Fonctions hide / display */
  3614.  
  3615. function toggleDetailsBM() {
  3616. if(MY_getValue('BMDETAIL')!='false') {
  3617. MY_setValue('BMDETAIL','false');
  3618. var trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3619. for(var i=0 ; i<trlist.length ; i++)
  3620. trlist[i].style.display = 'none';
  3621. trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3622. for(var i=0 ; i<trlist.length ; i++)
  3623. trlist[i].style = '';
  3624. }
  3625. else {
  3626. MY_setValue('BMDETAIL','true');
  3627. var trlist = document.getElementsByClassName('mh_tdpage BilanSomme');
  3628. for(var i=0 ; i<trlist.length ; i++)
  3629. trlist[i].style.display = 'none';
  3630. trlist = document.getElementsByClassName('mh_tdpage BilanDetail');
  3631. for(var i=0 ; i<trlist.length ; i++)
  3632. trlist[i].style = '';
  3633. }
  3634. }
  3635.  
  3636. function toggleBMList() {
  3637. if(MY_getValue('BMHIDELIST')=='true') {
  3638. MY_setValue('BMHIDELIST','false');
  3639. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3640. listeBM.snapshotItem(i).style = '';
  3641. document.getElementsByTagName('thead')[0].style = '';
  3642. document.getElementById('trhelp').style = '';
  3643. }
  3644. else {
  3645. MY_setValue('BMHIDELIST','true');
  3646. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3647. listeBM.snapshotItem(i).style.display = 'none';
  3648. document.getElementsByTagName('thead')[0].style.display = 'none';
  3649. document.getElementById('trhelp').style.display = 'none';
  3650. }
  3651. }
  3652.  
  3653. function setDisplayBM() {
  3654. if(!listeBM) return;
  3655. var titre = document.getElementById('titre2');
  3656. if(titre) {
  3657. titre.style.cursor = 'pointer';
  3658. titre.onclick = toggleBMList;
  3659. }
  3660. var tfoot = document.getElementsByTagName('tfoot')[0];
  3661. var tr = document.evaluate("./tr/td/text()[contains(.,'décumul')]/../..",
  3662. tfoot, null, 9, null).singleNodeValue;
  3663. tr.id = 'trhelp';
  3664. if(MY_getValue('BMHIDELIST')=='true') {
  3665. for(var i=0 ; i<listeBM.snapshotLength ; i++)
  3666. listeBM.snapshotItem(i).style.display = 'none';
  3667. document.getElementsByTagName('thead')[0].style.display = 'none';
  3668. tr.style.display = 'none';
  3669. }
  3670. }
  3671.  
  3672.  
  3673. /* [functions] Fonction principale */
  3674.  
  3675. function traiteMalus() {
  3676. var mainTab = document.getElementsByTagName('table')[0];
  3677. listeBM = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3678. if(listeBM.snapshotLength==0) return;
  3679. /* Suppression des BM de fatigue stockés */
  3680. if(MY_getValue(numTroll+'.bm.fatigue'))
  3681. MY_removeValue(numTroll+'.bm.fatigue');
  3682. /* Extraction des données */
  3683. var uniListe = [], listeDurees = {}, listeDecumuls = {};
  3684. var nb = 0;
  3685. while(nb<listeBM.snapshotLength) {
  3686. tr = listeBM.snapshotItem(nb); nb++;
  3687. var effetsT = tr.childNodes[5].textContent.split(' | ');
  3688. var phymag = tr.childNodes[9].textContent;
  3689. var duree = Number(tr.childNodes[11].textContent.match(/\d+/)[0]);
  3690. var type = tr.childNodes[3].textContent, nom;
  3691. // si c'est un type à décumul
  3692. /*
  3693. // Roule 23/11/2016 tout semble être soumis à décumul (vérifié pour Charme, Drain de vie)
  3694. switch(type) {
  3695. case 'Potion':
  3696. case 'Parchemin':
  3697. case 'Sortilège':
  3698. case 'Capacité Spéciale':
  3699. nom = tr.childNodes[1].textContent+phymag;
  3700. break;
  3701. default:
  3702. nom = 'pasdedecumul';
  3703. }
  3704. */
  3705. nom = tr.childNodes[1].textContent+phymag;
  3706. if(nom.indexOf('Amnésie')!=-1) // !! Amnésie = Capa, mais pas décumulée
  3707. nom = 'pasdedecumul';
  3708. uniListe[nb] = {
  3709. 'duree':duree,
  3710. 'nom':nom, // permet de gérer le non décumul des sorts à double composante
  3711. 'caracs':{}
  3712. }
  3713. for(var i=0 ; i<effetsT.length ; i++) {
  3714. if(effetsT[i].indexOf(':')==-1) continue;
  3715. // structure : liste[nb]=[duree , nom , [type ,] Array[caracs] ]
  3716. // nom = 'pasdedecumul' si pas de décumul
  3717. var carac = trim( effetsT[i].substring(0,effetsT[i].indexOf(':')) ) ;
  3718. if(carac=='ATT' || carac=='DEG' || carac=='Armure')
  3719. uniListe[nb]['type'] = phymag;
  3720. //var bm = Number(effetsT[i].match(/-?\d+/)[0]);
  3721. var tmatch = effetsT[i].match(/(-?\d+)(\\(-?\d+))?/); // un numérique et optionellement un autre numérique précédé d'un antislash
  3722. if (tmatch[2] == undefined) var bm = Number(tmatch[1]); // cas DEG : -6
  3723. else var bm = Number(tmatch[3]); // cas DEG : +0\-5
  3724. uniListe[nb]['caracs'][carac] = bm;
  3725. if (MY_DEBUG) window.console.log('[MZ debug] effetsT[' + i + ']=' + effetsT[i] + ', uniListe[' + nb + '][\'caracs\'][' + carac + '] = ' + bm + ', durée=' + duree + ' tmatch=' + JSON.stringify(tmatch));
  3726. listeDurees[duree] = true;
  3727. }
  3728. } // fin boucle sur les lignes de bonus/malus
  3729. /* Gestion des décumuls et cumuls des durées */
  3730. var toursGeres = [];
  3731. for(var d in listeDurees) toursGeres.push(d);
  3732. toursGeres.sort( function (a,b){return b-a;} );
  3733. if (MY_DEBUG) window.console.log('[MZ debug] toursGeres=' + JSON.stringify(toursGeres) + "\nuniListe=" + JSON.stringify(uniListe));
  3734. // pour sauvegarder les bm de fatigue
  3735. var strfat = '';
  3736. // Pour affichage & adpatation à footable.js (statique)
  3737. var thead = document.getElementsByTagName('thead')[0];
  3738. var nbHidden = document.evaluate("./tr/th[@style='display: none;']",
  3739. thead, null, 7, null).snapshotLength;
  3740. var tfoot = document.getElementsByTagName('tfoot')[0];
  3741. for(var i=0 ; i<toursGeres.length ; i++) {
  3742. var tour = toursGeres[i];
  3743. var effetsCeTour = {}; decumulsCeTour = {};
  3744. for(var nb=1 ; nb<uniListe.length ; nb++) {
  3745. if(uniListe[nb]['duree']<toursGeres[i]) // si durée pvr < durée analysée, on passe
  3746. continue;
  3747. var nom = uniListe[nb]['nom'];
  3748. if(nom!='pasdedecumul') {
  3749. if(decumulsCeTour[nom]==null) decumulsCeTour[nom] = 0;
  3750. decumulsCeTour[nom]++;
  3751. }
  3752. for(var carac in uniListe[nb]['caracs']) {
  3753. var bm = uniListe[nb]['caracs'][carac];
  3754. if(carac=='ATT' || carac=='DEG' || carac=='Armure') {
  3755. var type = uniListe[nb]['type'];
  3756. if(!effetsCeTour[carac])
  3757. effetsCeTour[carac] = {'Physique':0, 'Magie':0};
  3758. var thisBm;
  3759. if(nom=='pasdedecumul')
  3760. thisBm = bm;
  3761. else
  3762. thisBm = decumul(bm,decumulsCeTour[nom]);
  3763. effetsCeTour[carac][type] += thisBm;
  3764. 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]);
  3765. } else {
  3766. if(!effetsCeTour[carac]) effetsCeTour[carac]=0;
  3767. var thisBm;
  3768. if(nom=='pasdedecumul' || carac=='Fatigue')
  3769. thisBm = bm;
  3770. else if(carac=='TOUR') // les durees se comptent en demi-minutes dans MH
  3771. thisBm = decumul(2*bm,decumulsCeTour[nom])/2;
  3772. else
  3773. thisBm = decumul(bm,decumulsCeTour[nom]);
  3774. effetsCeTour[carac] += thisBm;
  3775. if (MY_DEBUG) window.console.log('calcul décumul tour=' + tour + ', nom=' + nom + ', carac=' + carac + ', bm=' + bm + ', decumulsCeTour[nom]=' + decumulsCeTour[nom] + ' : ' + thisBm + ' => ' + effetsCeTour[carac]);
  3776. }
  3777. } // fin boucle sur les caractéristiques
  3778. } // fin boucle sur les bonus/malus
  3779. /* Création du bilan du tour */
  3780. var texteD = '', texteS = '';
  3781. var caracGerees = [];
  3782. for(var k in effetsCeTour) caracGerees.push(k);
  3783. caracGerees.sort( triecaracs );
  3784. for(var j=0 ; j<caracGerees.length ; j++) {
  3785. var carac = caracGerees[j], str = '';
  3786. switch( carac ) {
  3787. case 'ATT':
  3788. case 'DEG':
  3789. case 'Armure':
  3790. var phy = effetsCeTour[carac]['Physique'];
  3791. var mag = effetsCeTour[carac]['Magie'];
  3792. texteD += (phy || mag)? ' | '+carac+' : '+aff(phy)+'/'+aff(mag) : '';
  3793. texteS += (phy+mag) ? ' | '+carac+' : '+aff(phy+mag) : '';
  3794. break;
  3795. case 'TOUR':
  3796. str = effetsCeTour[carac]? ' | TOUR : '+aff( effetsCeTour[carac] )+' min' : '';
  3797. break;
  3798. case 'Fatigue':
  3799. strfat += toursGeres[i]+'-'+effetsCeTour[carac]+';';
  3800. case 'PV':
  3801. case 'ESQ':
  3802. case 'REG':
  3803. case 'Vue':
  3804. case 'Voir le Caché':
  3805. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] ) : '';
  3806. break;
  3807. default:
  3808. str = effetsCeTour[carac]? ' | '+carac+' : '+aff( effetsCeTour[carac] )+' %' : '';
  3809. }
  3810. if(str) {
  3811. texteD += str;
  3812. texteS += str;
  3813. }
  3814. } // fin boucle sur les caractéristiques
  3815. /* Affichage */
  3816. // Si rien à afficher on passe
  3817. if(!texteD) continue;
  3818. // Si BMM+BMP=0
  3819. texteS = texteS ? texteS.substring(3) : 'Aucun effet';
  3820. var tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanDetail');
  3821. if(MY_getValue('BMDETAIL')=='false')
  3822. tr.style.display = 'none';
  3823. var td = appendTdText(tr,texteD.substring(3));
  3824. td.colSpan = 5-nbHidden;
  3825. var txttour = toursGeres[i]+' Tour';
  3826. if(toursGeres[i]>1) txttour += 's';
  3827. appendTdText(tr,txttour);
  3828. tr = insertTr(tfoot.childNodes[2],'mh_tdpage BilanSomme');
  3829. if(MY_getValue('BMDETAIL')!='false')
  3830. tr.style.display = 'none';
  3831. td = appendTdText(tr,texteS);
  3832. td.colSpan = 5-nbHidden;
  3833. appendTdText(tr,txttour);
  3834. } // fin boucle sur les tours générés
  3835. /* mise en place toggleDetails */
  3836. tfoot.style.cursor = 'pointer';
  3837. tfoot.onclick = toggleDetailsBM;
  3838. /* Stockage fatigue : tour-fatigue;tour-fatigue;... */
  3839. if(strfat)
  3840. MY_setValue(numTroll+'.bm.fatigue',strfat);
  3841. }
  3842.  
  3843. function do_malus() {
  3844. try {
  3845. start_script();
  3846. traiteMalus();
  3847. setDisplayBM();
  3848. displayScriptTime();
  3849. }
  3850. catch(e) {window.alert(e)};
  3851. }
  3852.  
  3853. /*******************************************************************************
  3854. * This file is part of Mountyzilla. *
  3855. * *
  3856. * Mountyzilla is free software; you can redistribute it and/or modify *
  3857. * it under the terms of the GNU General Public License as published by *
  3858. * the Free Software Foundation; either version 2 of the License, or *
  3859. * (at your option) any later version. *
  3860. * *
  3861. * Mountyzilla is distributed in the hope that it will be useful, *
  3862. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  3863. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  3864. * GNU General Public License for more details. *
  3865. * *
  3866. * You should have received a copy of the GNU General Public License *
  3867. * along with Mountyzilla; if not, write to the Free Software *
  3868. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  3869. *******************************************************************************/
  3870.  
  3871. // x~x mouches
  3872.  
  3873. var mainTab, tr_mouches;
  3874.  
  3875. function initialiseMouches() {
  3876. // Lanceur global
  3877. try {
  3878. mainTab = document.getElementById('mouches');
  3879. tr_mouches = document.evaluate('./tbody/tr', mainTab, null, 7, null);
  3880. } catch(e) {
  3881. avertissement('Erreur MZ:<br />Consulter la console.');
  3882. window.console.error(traceStack(e, 'mouches'));
  3883. return;
  3884. }
  3885. if(mainTab===void(0) || tr_mouches.snapshotLength==0) { return; }
  3886. setDisplayMouches();
  3887. traiteMouches();
  3888. }
  3889.  
  3890. function setDisplayMouches() {
  3891. // Initialise l'affichage / l'effacement du détail des mouches
  3892. var titre = document.getElementById('titre2');
  3893. if(titre) {
  3894. titre.style.cursor = 'pointer';
  3895. titre.onclick = toggleMouches;
  3896. }
  3897. var tfoot = document.getElementsByTagName('tfoot')[0];
  3898. if(tfoot) {
  3899. tfoot.style.cursor = 'pointer';
  3900. tfoot.onclick = toggleMouches;
  3901. }
  3902. if(MY_getValue('HIDEMOUCHES')=='true') {
  3903. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3904. tr_mouches.snapshotItem(i).style.display = 'none';
  3905. }
  3906. document.getElementsByTagName('thead')[0].style.display = 'none';
  3907. }
  3908. }
  3909.  
  3910. function toggleMouches() {
  3911. // Handler pour afficher / masquer les détasil
  3912. if(MY_getValue('HIDEMOUCHES')=='true') {
  3913. MY_setValue('HIDEMOUCHES','false');
  3914. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3915. tr_mouches.snapshotItem(i).style.display = '';
  3916. }
  3917. document.getElementsByTagName('thead')[0].style.display = '';
  3918. } else {
  3919. MY_setValue('HIDEMOUCHES','true');
  3920. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3921. tr_mouches.snapshotItem(i).style.display = 'none';
  3922. }
  3923. document.getElementsByTagName('thead')[0].style.display = 'none';
  3924. }
  3925. }
  3926.  
  3927. function traiteMouches() {
  3928. // Traitement complet: présence et effets des mouches
  3929. var listeTypes = {}, effetsActifs = {};
  3930. for(var i=0 ; i<tr_mouches.snapshotLength ; i++) {
  3931. var tr = tr_mouches.snapshotItem(i);
  3932. // La mouche est-elle présente?
  3933. var etat = document.evaluate(
  3934. './img',
  3935. tr.cells[6], null, 9, null
  3936. ).singleNodeValue.alt;
  3937. if(etat!='La Mouche est là') { continue; }
  3938. // Extraction du type de mouche
  3939. var type = trim(tr.cells[3].textContent);
  3940. if(!listeTypes[type]) {
  3941. listeTypes[type] = 1;
  3942. } else {
  3943. listeTypes[type]++;
  3944. }
  3945. // La mouche a-t-elle un effet?
  3946. var effet = trim(tr.cells[2].textContent);
  3947. if(etat!='La Mouche est là' || !effet) { continue; }
  3948. // Si oui, extraction des effets (multiples pour pogées)
  3949. var caracs = effet.split(' | ');
  3950. for(var j=0 ; j<caracs.length ; j++) {
  3951. var carac = caracs[j].substring(0,caracs[j].indexOf(':')-1);
  3952. var valeur = Number(caracs[j].match(/-?\d+/)[0]);
  3953. if(effetsActifs[carac]===void(0)) {
  3954. effetsActifs[carac] = valeur;
  3955. } else {
  3956. effetsActifs[carac] += valeur;
  3957. }
  3958. }
  3959. }
  3960. // Extraction Effet total et affichage des différences à la normale
  3961. var tfoot = document.getElementsByTagName('tfoot')[0];
  3962. if(!tfoot) { return; }
  3963. var nodeTotal = document.evaluate(
  3964. ".//b[contains(./text(),'Effet total')]",
  3965. tfoot, null, 9, null
  3966. ).singleNodeValue.nextSibling;
  3967. var effetsTheoriques = nodeTotal.nodeValue.split('|');
  3968. var texte = ' ';
  3969. for(var i=0 ; i<effetsTheoriques.length ; i++) {
  3970. if(texte.length>1) { texte += ' | '; }
  3971. var carac = trim(
  3972. effetsTheoriques[i].substring(0,effetsTheoriques[i].indexOf(':')-1)
  3973. );
  3974. var valeur = effetsTheoriques[i].match(/-?\d+/)[0];
  3975. if(effetsActifs[carac]!==void(0) && effetsActifs[carac]==valeur) {
  3976. texte += effetsTheoriques[i];
  3977. } else {
  3978. texte += '<b>'+carac+' : '+aff(effetsActifs[carac]);
  3979. if(carac=='TOUR') { texte += ' min'; }
  3980. texte += '</b>';
  3981. }
  3982. }
  3983. var span = document.createElement('span');
  3984. span.innerHTML = texte;
  3985. nodeTotal.parentNode.replaceChild(span,nodeTotal);
  3986. // Affichage des différences du nombre de mouches de chaque type
  3987. var mouchesParType = document.evaluate(
  3988. "./tr/td/ul/li/text()",
  3989. tfoot, null, 7, null
  3990. );
  3991. for(var i=0 ; i<mouchesParType.snapshotLength ; i++) {
  3992. var node = mouchesParType.snapshotItem(i);
  3993. var mots = node.nodeValue.split(' ');
  3994. var type = mots.pop();
  3995. if(!listeTypes[type]) {
  3996. node.nodeValue += ' (0 présente)';
  3997. } else if(mots[0]!=listeTypes[type]) {
  3998. if(listeTypes[type]==1) {
  3999. node.nodeValue += ' (1 présente)';
  4000. } else {
  4001. node.nodeValue += ' ('+listeTypes[type]+' présentes)';
  4002. }
  4003. }
  4004. }
  4005. }
  4006.  
  4007. function do_mouches() {
  4008. start_script();
  4009. initialiseMouches();
  4010. displayScriptTime();
  4011. }
  4012.  
  4013. /*********************************************************************************
  4014. * This file is part of Mountyzilla. *
  4015. * *
  4016. * Mountyzilla is free software; you can redistribute it and/or modify *
  4017. * it under the terms of the GNU General Public License as published by *
  4018. * the Free Software Foundation; either version 2 of the License, or *
  4019. * (at your option) any later version. *
  4020. * *
  4021. * Mountyzilla is distributed in the hope that it will be useful, *
  4022. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4023. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4024. * GNU General Public License for more details. *
  4025. * *
  4026. * You should have received a copy of the GNU General Public License *
  4027. * along with Mountyzilla; if not, write to the Free Software *
  4028. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4029. *********************************************************************************/
  4030.  
  4031. // x~x equipgowap
  4032.  
  4033. var popup;
  4034.  
  4035. function initPopupEquipgowap() {
  4036. popup = document.createElement('div');
  4037. popup.setAttribute('id', 'popup');
  4038. popup.setAttribute('class', 'mh_textbox');
  4039. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;' +
  4040. 'display: inline; z-index: 3; max-width: 400px;');
  4041. document.body.appendChild(popup);
  4042. }
  4043.  
  4044. function showPopupEquipgowap(evt) {
  4045. var texte = this.getAttribute("texteinfo");
  4046. popup.innerHTML = texte;
  4047. popup.style.left = evt.pageX + 15 + 'px';
  4048. popup.style.top = evt.pageY + 'px';
  4049. popup.style.visibility = "visible";
  4050. }
  4051.  
  4052. function hidePopup() {
  4053. popup.style.visibility = "hidden";
  4054. }
  4055.  
  4056. function createPopupImage(url, text)
  4057. {
  4058. var img = document.createElement('img');
  4059. img.setAttribute('src',url);
  4060. img.setAttribute('align','ABSMIDDLE');
  4061. img.setAttribute("texteinfo",text);
  4062. img.addEventListener("mouseover", showPopupEquipgowap,true);
  4063. img.addEventListener("mouseout", hidePopup,true);
  4064. return img;
  4065. }
  4066.  
  4067. function formateTexte(texte)
  4068. {
  4069. texte = texte.replace(/\n/g,"<br/>");
  4070. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  4071. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  4072. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  4073. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  4074. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  4075. return texte;
  4076. }
  4077.  
  4078.  
  4079. function treateGowaps() {
  4080. //On récupère les gowaps possédants des composants
  4081. var tbodys = document.evaluate(
  4082. "//tr[@class='mh_tdpage_fo']/descendant::img[@alt = 'Composant - Spécial']/../../..",
  4083. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4084. for (var j = 0; j < tbodys.snapshotLength; j++) {
  4085. var tbody = tbodys.snapshotItem(j);
  4086. var id_gowap = currentURL.substring(currentURL.indexOf("?ai_IdFollower=")+15)*1;
  4087. //insertButtonComboDB(tbody, 'gowap', id_gowap,'mh_tdpage_fo');
  4088. if(MY_getValue("NOINFOEM") != "true")
  4089. insertEMInfos(tbody);
  4090. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4091. insertEnchantInfos(tbody);
  4092. }
  4093. }
  4094.  
  4095. function treateChampi() {
  4096. if(MY_getValue("NOINFOEM") == "true")
  4097. return false;
  4098. var nodes = document.evaluate("//img[@alt = 'Champignon - Spécial']/../a/text()",
  4099. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  4100. if (nodes.snapshotLength == 0)
  4101. return false;
  4102.  
  4103. for (var i = 0; i < nodes.snapshotLength; i++) {
  4104. var node = nodes.snapshotItem(i);
  4105. var texte = trim(node.nodeValue.replace(/\240/g, " "));
  4106. if(texte.indexOf("*")!=-1)
  4107. texte = texte.substring(0,texte.lastIndexOf(" "));
  4108. var nomChampi = texte.substring(0,texte.lastIndexOf(" "));
  4109. if(moisChampi[nomChampi])
  4110. {
  4111. appendText(node.parentNode.parentNode," [Mois "+moisChampi[nomChampi]+"]");
  4112. }
  4113. }
  4114. }
  4115.  
  4116. function do_equipgowap() {
  4117. start_script();
  4118.  
  4119. treateGowaps();
  4120. treateChampi();
  4121. if(MY_getValue(numTroll+".enchantement.liste") && MY_getValue(numTroll+".enchantement.liste")!="" )
  4122. {
  4123. initPopupEquipgowap();
  4124. computeEnchantementEquipement(createPopupImage,formateTexte);
  4125. }
  4126.  
  4127. displayScriptTime();
  4128. }
  4129.  
  4130. /*********************************************************************************
  4131. * This file is part of zoryazilla & mountyzilla, published under GNU License *
  4132. *********************************************************************************/
  4133.  
  4134. // x~x ordresgowap
  4135.  
  4136. // version Roule' janvier 2017
  4137. function MZ_setCarteUnGogoHTML5() {
  4138. // fabriquer la liste des positions successives
  4139. var listeDepl = []; // ce sera un tableau d'objets
  4140. // position courrante
  4141. var eTitle = document.getElementById('titre2');
  4142. var tabNomID = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'[')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/(\d+)\.(.*)/);
  4143. var tabPos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4144. listeDepl.push({x: parseInt(tabPos[0]) // ParseInt obligatoire, javascript language de m*rd*
  4145. , y: parseInt(tabPos[1])
  4146. , n: parseInt(tabPos[2])
  4147. , nom: tabNomID[2]
  4148. , id: tabNomID[1]});
  4149. // déplacements
  4150. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4151. for(var i=0 ; i<lignes.length ; i++) {
  4152. if(lignes[i].className == 'mh_tdpage_fo') {
  4153. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4154. var point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(/X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/i);
  4155. if(point) listeDepl.push({x: parseInt(point[1]), y: parseInt(point[2]), n: parseInt(point[3])});
  4156. }
  4157. }
  4158. MZ_showCarteBottom([listeDepl]); // L'arg est un tableau de tableaux d'objets
  4159. }
  4160.  
  4161. // L'arg est un tableau de tableaux d'objets (trajets des suivants)
  4162. function MZ_showCarteBottom(listeSuiv) {
  4163. // générer la carte
  4164. var carte = new carte_MZ('cartegogo', listeSuiv);
  4165. // positionner la carte
  4166. var eCarte = carte.getElt();
  4167. eCarte.style.textAlign = 'left';
  4168. eCarte.style.marginTop = '2px';
  4169. var footer = document.getElementById('footer1');
  4170. // Lieu_Teleport.php n'a pas de footer1 :(
  4171. if (!footer) footer = document.getElementById('footer2');
  4172. if (footer) footer.parentNode.insertBefore(eCarte, footer);
  4173. else document.body.appendChild(eCarte);
  4174. }
  4175.  
  4176. function MZ_setCarteTousGogoHTML5() {
  4177. // partie récupérée de "trajet gowaps" de feldspath et Vapulabehemot
  4178. var ligne = document.getElementsByTagName("form")[0].getElementsByTagName("tbody")[0].childNodes;
  4179. var suivants = [];
  4180. for (var i=0;i<ligne.length;i++) {
  4181. if(ligne[i].nodeName != "TR" || !ligne[i].getElementsByTagName('a')[0]) continue;
  4182. var cas = ligne[i].getElementsByTagName("td")[0];
  4183. //if (cas.className == "mh_tdtitre") {
  4184. if (cas.className == "mh_tdtitre_fo") {// correction par Vapulabehemot (82169) le 10/07/2015
  4185. var oGogo = {};
  4186. oGogo.id = parseInt(cas.getElementsByTagName('a')[0].href.split("=")[1]);
  4187. oGogo.nom = trim(cas.getElementsByTagName('a')[0].firstChild.nodeValue);
  4188. var point = cas.innerHTML.match(/X = (-?\d+) \| Y = (-?\d+) \| N = (-?\d+)/);
  4189. oGogo.x = parseInt(point[1]);
  4190. oGogo.y = parseInt(point[2]);
  4191. oGogo.n = parseInt(point[3]);
  4192. suivants.push([oGogo]); // un suivant ayant un trajet d'une seule étape
  4193. }
  4194. }
  4195. if (suivants.length == 0) return;
  4196. MZ_showCarteBottom(suivants); // L'arg est un tableau de tableaux d'objets
  4197. }
  4198.  
  4199. function MZ_setCarteTP() {
  4200. // regexp compliquée par le fait que MH met une rupture de ligne dans les coord dans la page Lieu_Description.php
  4201. 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);
  4202. var sortie = {x:parseInt(pos[1]), y:parseInt(pos[2]), n:parseInt(pos[2]), id:'', nom:'Sortie TP', typ:'tp'};
  4203. MZ_showCarteBottom([[sortie]]); // L'arg est un tableau de tableaux d'objets
  4204. }
  4205.  
  4206. /* v0.2 by Dab - 2013-08-31
  4207. * - correction acquisition posale initiale
  4208. * - correction tare et affichage mire
  4209. */
  4210.  
  4211. function setCarteGogo() {
  4212. try {
  4213. //var pars = document.getElementsByTagName('p');
  4214. //var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", pars[0], null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4215. var eTitle = document.getElementById('titre2');
  4216. var pos = document.evaluate(".//table/descendant::table/tbody/tr/td/text()[contains(.,'X =')]", eTitle.parentNode, null, 9, null).singleNodeValue.nodeValue.match(/-?\d+/g);
  4217. var serv_img_trou = URL_MZimg + "carte_trou.png";
  4218. var serv_img_cible = URL_MZimg + "rep.png";
  4219.  
  4220. var expreg = /X=(-?\d+) \| Y=(-?\d+) \| N=(-?\d+)/;
  4221. //var lignes = pars[0].getElementsByTagName('tr');
  4222. var lignes = eTitle.parentNode.getElementsByTagName('tr');
  4223. var nbpt = 0;
  4224. var trajet = pos[0]+','+pos[1]+','+pos[2]+',';
  4225. for(var i=0 ; i<lignes.length ; i++) {
  4226. if(lignes[i].className == 'mh_tdpage_fo') {
  4227. if (lignes[i].getElementsByTagName('td')[2] === undefined) return; // cas des Golems
  4228. point = lignes[i].getElementsByTagName('td')[2].firstChild.nodeValue.match(expreg);
  4229. if(point) {
  4230. nbpt++;
  4231. trajet += point[1]+','+point[2]+','+point[3]+',';
  4232. }
  4233. }
  4234. }
  4235. }
  4236. catch(e) {window.console.log(traceStack(e, 'setCarteGogo() impossible de trouver les ordres')); return;}
  4237. 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'/>";
  4238. var base = [-229,-5];
  4239. if (nbpt>0) {
  4240. base = [-684,-5];
  4241. nvdiv += "<img src='"+URL_MZscriptCarte+"?trajet="+trajet+"' style='position:relative;top:-455px;left:0px;z-index:500;border-width:0px' usemap='#coord_trou'/>";
  4242. }
  4243. 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;'/>";
  4244.  
  4245. 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>';
  4246.  
  4247. var nvspan = document.createElement('div');
  4248. nvspan.align = 'center';
  4249. nvspan.id = 'mz_mapdiv';
  4250. nvspan.valign = 'top';
  4251. nvspan.innerHTML = nvdiv;
  4252. //pars[1].insertBefore(nvspan,pars[1].firstChild);
  4253. var footer = document.getElementById('footer1');
  4254. footer.parentNode.insertBefore(nvspan,footer);
  4255. }
  4256.  
  4257. function testeGlissiere() {
  4258. try {
  4259. var gliss = new glissiere_MZ('test', 'Test glissière', 'xxx', false, 100, 50, 250);
  4260. var footer = document.getElementById('footer1');
  4261. footer.parentNode.insertBefore(gliss.getElt(), footer);
  4262. } catch (e) {window.console.log(traceStack(e, 'testeGlissiere'))};
  4263. }
  4264.  
  4265. function MZ_testsUnitairesCalculIntermediaire(x0, y0, x1, y1) {
  4266. if (x0 !== undefined) {
  4267. // ouais, récursif une fois
  4268. var PtInterm = pointIntermediaireMonstre2D({x:x0, y:y0}, {x:x1, y:y1});
  4269. if (PtInterm === undefined)
  4270. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => rien');
  4271. else
  4272. window.console.log('pt interm(' + x0 + ',' + y0 + ')(' + x1 + ',' + y1 + ') => (' + PtInterm.x + ',' + PtInterm.y +')');
  4273. return;
  4274. }
  4275. // MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 100);
  4276. // MZ_testsUnitairesCalculIntermediaire(10, 100, 100, 10);
  4277. // MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 100);
  4278. // MZ_testsUnitairesCalculIntermediaire(100, 100, 10, 10);
  4279. MZ_testsUnitairesCalculIntermediaire(10, 10, 100, 80);
  4280. MZ_testsUnitairesCalculIntermediaire(10, 10, 80, 100);
  4281. MZ_testsUnitairesCalculIntermediaire(10, 100, 80, 10);
  4282. MZ_testsUnitairesCalculIntermediaire(10, 80, 100, 10);
  4283. MZ_testsUnitairesCalculIntermediaire(100, 10, 10, 80);
  4284. MZ_testsUnitairesCalculIntermediaire(80, 10, 10, 100);
  4285. MZ_testsUnitairesCalculIntermediaire(100, 80, 10, 10);
  4286. MZ_testsUnitairesCalculIntermediaire(80, 100, 10, 10);
  4287. MZ_testsUnitairesCalculIntermediaire(-80, 100, -10, 10);
  4288. MZ_testsUnitairesCalculIntermediaire(80, -100, 10, -10);
  4289. MZ_testsUnitairesCalculIntermediaire(-80, -100, -10, -10);
  4290. MZ_testsUnitairesCalculIntermediaire(35, -87, 45, -87);
  4291. MZ_testsUnitairesCalculIntermediaire(45, -87, 45, -77);
  4292. }
  4293.  
  4294. function do_ordresgowap() {
  4295. if (newCarte) {
  4296. MZ_setCarteUnGogoHTML5(); // Version Roule janvier 2017
  4297. //testeGlissiere();
  4298. //MZ_testsUnitairesCalculIntermediaire();
  4299. } else {
  4300. setCarteGogo(); // Via script des trouillots
  4301. }
  4302. }
  4303.  
  4304. function do_listegowap() {
  4305. if (!newCarte) return;
  4306. MZ_setCarteTousGogoHTML5();
  4307. }
  4308.  
  4309. function do_lieuDescription() {
  4310. if (!newCarte) return;
  4311. if (window.document.getElementsByTagName("body")[0].innerHTML.indexOf("Portail : Portail de T") != -1)
  4312. MZ_setCarteTP();
  4313. }
  4314.  
  4315. function do_lieuTeleport() {
  4316. changeButtonValidate();
  4317. if (!newCarte) return;
  4318. MZ_setCarteTP();
  4319. }
  4320.  
  4321. /*********************************************************************************
  4322. * This file is part of Mountyzilla. *
  4323. * *
  4324. * Mountyzilla is free software; you can redistribute it and/or modify *
  4325. * it under the terms of the GNU General Public License as published by *
  4326. * the Free Software Foundation; either version 2 of the License, or *
  4327. * (at your option) any later version. *
  4328. * *
  4329. * Mountyzilla is distributed in the hope that it will be useful, *
  4330. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4331. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4332. * GNU General Public License for more details. *
  4333. * *
  4334. * You should have received a copy of the GNU General Public License *
  4335. * along with Mountyzilla; if not, write to the Free Software *
  4336. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4337. *********************************************************************************/
  4338.  
  4339. // x~x attaque
  4340.  
  4341. // Script désactivé en attendant la màj vers le nouveau système de missions.
  4342.  
  4343. function do_attaque() {
  4344. }
  4345.  
  4346. /*******************************************************************************
  4347. * This file is part of Mountyzilla. *
  4348. * *
  4349. * Mountyzilla is free software; you can redistribute it and/or modify *
  4350. * it under the terms of the GNU General Public License as published by *
  4351. * the Free Software Foundation; either version 2 of the License, or *
  4352. * (at your option) any later version. *
  4353. * *
  4354. * Mountyzilla is distributed in the hope that it will be useful, *
  4355. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4356. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4357. * GNU General Public License for more details. *
  4358. * *
  4359. * You should have received a copy of the GNU General Public License *
  4360. * along with Mountyzilla; if not, write to the Free Software *
  4361. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4362. *******************************************************************************/
  4363.  
  4364. // x~x infomonstre
  4365.  
  4366. // DEBUG
  4367. // Utilisation obligatoire de listeCDM à cause de getAnalyseTactique()
  4368. // À corriger, évidemment.
  4369. var listeCDM = {};
  4370. var nomMonstre='';
  4371. var idMonstre=-1;
  4372. var tbody;
  4373. var popup;
  4374.  
  4375. function traiteMonstre() {
  4376. try {
  4377. var nodeTitre = document.evaluate(
  4378. "//div[@class='titre2' and contains(text(),'(')]",
  4379. document, null, 9, null
  4380. ).singleNodeValue;
  4381. var texte = nodeTitre.firstChild.nodeValue;
  4382. } catch(e) {
  4383. window.console.log(traceStack(e, 'traiteMonstre'));
  4384. return;
  4385. }
  4386. nomMonstre = texte.slice(0,texte.indexOf('(')-1);
  4387. if(nomMonstre.indexOf(']')!=-1) {
  4388. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  4389. }
  4390. idMonstre = texte.match(/\d+/)[0];
  4391. FF_XMLHttpRequest({
  4392. method: 'GET',
  4393. url: URL_MZinfoMonstre + '?begin=-1&idcdm='
  4394. +MY_getValue('CDMID')
  4395. +'&nom[]='+escape(nomMonstre)+'$'+idMonstre,
  4396. headers : {
  4397. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  4398. 'Accept': 'application/atom+xml,application/xml,text/xml'
  4399. },
  4400. onload: function(responseDetails) {
  4401. try {
  4402. var texte = responseDetails.responseText;
  4403. var lines = texte.split("\n");
  4404. if(lines.length>=1) {
  4405. var infos = lines[0].split(";");
  4406. if(infos.length<4) { return; }
  4407. var idMonstre = infos[0];
  4408. infos=infos.slice(3);
  4409. listeCDM[idMonstre]=infos;
  4410. computeMissionInfomonstre();
  4411. }
  4412. } catch(e) {
  4413. window.alert(e);
  4414. }
  4415. }
  4416. });
  4417. }
  4418.  
  4419. function initPopupInfomonstre() {
  4420. // Initialise le popup tactique (calculs att/deg)
  4421. popup = document.createElement('div');
  4422. popup.id = 'popup';
  4423. popup.className = 'mh_textbox';
  4424. popup.style =
  4425. 'position: absolute;'+
  4426. 'border: 1px solid #000000;'+
  4427. 'visibility: hidden;'+
  4428. 'display: inline;'+
  4429. 'z-index: 3;'+
  4430. 'max-width: 400px;';
  4431. document.body.appendChild(popup);
  4432. }
  4433.  
  4434. function showPopupTactique(evt) {
  4435. try {
  4436. var id = this.id;
  4437. var nom = this.nom;
  4438. var texte = getAnalyseTactique(id,nom);
  4439. if(texte=='') { return; }
  4440. popup.innerHTML = texte;
  4441. // roule 16/03/2016 déclage horizontal différent suivant la page qu'on traite
  4442. if(isPage("View/MonsterView")) {
  4443. popup.style.left = Math.min(evt.pageX-120,window.innerWidth-300)+'px';
  4444. } else {
  4445. popup.style.left = Math.min(evt.pageX+15,window.innerWidth-400)+'px';
  4446. }
  4447. popup.style.top = evt.pageY+15+'px';
  4448. popup.style.visibility = 'visible';
  4449. } catch(e) {
  4450. window.alert(e);
  4451. }
  4452. }
  4453.  
  4454. // roule 16/03/2016, existe déjà ailleurs
  4455. // function hidePopup() {
  4456. // popup.style.visibility = 'hidden';
  4457. // }
  4458.  
  4459. function toggleTableau() {
  4460. tbody.style.display = tbody.style.display=='none' ? '' : 'none';
  4461. }
  4462.  
  4463. function computeMissionInfomonstre() {
  4464. // C'est quoi ce titre de fonction ? (O_o)
  4465. try {
  4466. var nodeInsert = document.evaluate(
  4467. "//div[@class = 'titre3']",
  4468. document, null, 9, null
  4469. ).singleNodeValue;
  4470. } catch(e) {
  4471. window.console.log(traceStack(e, 'computeMissionInfomonstre'));
  4472. return;
  4473. }
  4474. var table = createCDMTable(idMonstre,nomMonstre,listeCDM[idMonstre]);
  4475. table.align = 'center';
  4476. tbody = table.childNodes[1];
  4477. table.firstChild.firstChild.firstChild.onclick = toggleTableau;
  4478. table.firstChild.firstChild.onmouseover = function() {
  4479. this.style.cursor = 'pointer';
  4480. this.className = 'mh_tdpage';
  4481. };
  4482. table.firstChild.firstChild.onmouseout = function() {
  4483. this.className = 'mh_tdtitre';
  4484. };
  4485. tbody.style.display = 'none';
  4486. table.style.width = '350px';
  4487. insertBefore(nodeInsert,table);
  4488. }
  4489.  
  4490. function do_infomonstre() {
  4491. start_script();
  4492. try {
  4493. initPopupInfomonstre();
  4494. traiteMonstre();
  4495. } catch(e) {
  4496. window.alert('Erreur infoMonstre:\n'+e);
  4497. }
  4498. displayScriptTime();
  4499. }
  4500.  
  4501. /*******************************************************************************
  4502. * This file is part of Mountyzilla. *
  4503. * *
  4504. * Mountyzilla is free software; you can redistribute it and/or modify *
  4505. * it under the terms of the GNU General Public License as published by *
  4506. * the Free Software Foundation; either version 2 of the License, or *
  4507. * (at your option) any later version. *
  4508. * *
  4509. * Mountyzilla is distributed in the hope that it will be useful, *
  4510. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4511. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4512. * GNU General Public License for more details. *
  4513. * *
  4514. * You should have received a copy of the GNU General Public License *
  4515. * along with Mountyzilla; if not, write to the Free Software *
  4516. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4517. *******************************************************************************/
  4518.  
  4519. // x~x mission
  4520.  
  4521. /* TODO
  4522. * MZ2.0 : gérer le nettoyage des missions terminées via script principal
  4523. * Roule 01/01/2017 : c'est fait dans do_mission_liste
  4524. *
  4525. * Note: nbKills n'est pas géré pour l'instant (voir avec Actions?)
  4526. */
  4527.  
  4528. function saveMission(num,obEtape) {
  4529. var obMissions = [];
  4530. if(MY_getValue(numTroll+'.MISSIONS')) {
  4531. try {
  4532. window.console.log('JSON MISSION = ' + MY_getValue(numTroll+'.MISSIONS'));
  4533. obMissions = JSON.parse(MY_getValue(numTroll+'.MISSIONS'));
  4534. } catch(e) {
  4535. window.console.error(traceStack(e, 'Mission parsage'));
  4536. return;
  4537. }
  4538. }
  4539. if (obMissions == undefined) obMissions = []; // protection
  4540. //window.console.log('saveMission, obEtape=' + obEtape); // debug roule
  4541. if(obEtape) {
  4542. obMissions[num] = obEtape;
  4543. } else if(obMissions[num]) {
  4544. delete obMissions[num];
  4545. }
  4546. MY_setValue(numTroll+'.MISSIONS',JSON.stringify(obMissions));
  4547. }
  4548.  
  4549. function addtroogle(tdLibelle, sRestrict) {
  4550. var img = document.createElement('img');
  4551. img.src = URL_MZimg + 'troogle.ico';
  4552. img.alt = 'Troogle logo';
  4553. var a = document.createElement('a');
  4554. var url = URL_troogle + '?utf8=' + encodeURIComponent('✓'); // hé oui, ce source est unicode
  4555. url += '&entity_search[search]=' + encodeURIComponent(sRestrict);
  4556. url += '&entity_search[position_x]=' + MY_getValue(numTroll+".position.X");
  4557. url += '&entity_search[position_y]=' + MY_getValue(numTroll+".position.Y");
  4558. url += '&entity_search[position_z]=' + MY_getValue(numTroll+".position.N");
  4559. a.href = url;
  4560. a.title = 'Chercher sur Troogle';
  4561. a.target = 'troogle';
  4562. a.appendChild(img);
  4563. tdLibelle.appendChild(a);
  4564. tdLibelle.parentNode.style.verticalAlign = 'bottom';
  4565. }
  4566.  
  4567. function traiteMission() {
  4568. try {
  4569. var titreMission = document.getElementsByClassName('titre2')[0];
  4570. var numMission = titreMission.textContent.match(/\d+/)[0];
  4571. var missionForm = document.getElementsByName('ActionForm')[0];
  4572. var tdLibelle = document.evaluate(
  4573. "./table/tbody/tr/td/input[starts-with(@value,'Valider')]/../../td[2]",
  4574. missionForm, null, 9, null).singleNodeValue;
  4575. } catch(e) {
  4576. window.console.error(traceStack(e, 'récupération mission'));
  4577. return;
  4578. }
  4579. if (!numMission) { debugMZ('traiteMission pas de numMission, titreMission=' . titreMission.outerHTML.replace(/</g, '‹')); return; }
  4580. try {
  4581. if(!tdLibelle) {
  4582. // S'il n'y a plus d'étape en cours (=mission finie), on supprime
  4583. debugMZ('traiteMission, la mission semble terminée');
  4584. saveMission(numMission,false);
  4585. return;
  4586. }
  4587.  
  4588. var libelle = trim(tdLibelle.textContent.replace(/\n/g,''));
  4589. var siMundidey = libelle.indexOf('Mundidey')!=-1;
  4590. // debug Roule'
  4591. if (MY_DEBUG) {
  4592. for (var i =0; i < tdLibelle.childNodes.length; i++)
  4593. window.console.log('traiteMission, tdLibelle.childNodes[' + i + ']=' + tdLibelle.childNodes[i].textContent);
  4594. }
  4595. if(libelle.indexOf('niveau égal à')!=-1) {
  4596. var nbKills = 1, niveau, mod;
  4597. // exemples :
  4598. // L'équipe doit tuer 3 petits monstres (d'un niveau égal à 27 + ou - 1)
  4599. // L'équipe doit tuer 2 gros monstres (chaque monstre devant être d'un niveau égal à 44 au moins)
  4600. // L'équipe doit tuer un petit monstre (chaque monstre devant être d'un niveau égal à 29 + ou - 1) un Mundidey
  4601. // L'équipe doit tuer un monstre (ce monstre doit être d'un niveau égal à 44 au moins) un Mundidey
  4602. if (tdLibelle.childNodes.length == 1) {
  4603. // Roule' 08/01/52017 il n'y a plus de mise en forme. Un seul childNode
  4604. var m = libelle.match(/niveau égal à *(\d+) * au moins/);
  4605. if (m) {
  4606. niveau = Number(m[1]);
  4607. mod = 'plus'
  4608. } else {
  4609. var m = libelle.match(/niveau égal à *(\d+) *\+.*- *(\d+)/);
  4610. if (m) {
  4611. niveau = Number(m[1]);
  4612. mod = Number(m[2]);
  4613. } else {
  4614. window.console.log('[MZ ' + GM_info.script.version + '] traiteMission, échec analyse de ' + libelle);
  4615. return;
  4616. }
  4617. }
  4618. } else {
  4619. // ancienne méthode (multi childnode)
  4620. // à supprimer un jour peut-être
  4621. if(tdLibelle.firstChild.nodeValue.indexOf('niveau égal à')==-1) {
  4622. // Étape de kill multiple de niveau donné
  4623. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4624. if (tdLibelle.childNodes.length <= 3) { // Roule' 14/07/2016 le niveau n'est plus en gras, on n'a que 3 zones de texte
  4625. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4626. niveau = Number(mod[0]);
  4627. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4628. mod = mod.length > 1 ? Number(mod[1]) : 'plus';
  4629. } else {
  4630. niveau = Number(tdLibelle.childNodes[3].firstChild.nodeValue);
  4631. // Modificateur de niveau : "niv +/- mod" ou bien "niv +"
  4632. mod = tdLibelle.childNodes[4].nodeValue.match(/\d+/);
  4633. mod = mod ? Number(mod[0]) : 'plus';
  4634. }
  4635. } else {
  4636. // Étape de kill unique de niveau donné
  4637. niveau = Number(tdLibelle.childNodes[1].firstChild.nodeValue);
  4638. mod = tdLibelle.childNodes[2].nodeValue.match(/\d+/);
  4639. mod = mod ? Number(mod[0]) : 'plus';
  4640. }
  4641. }
  4642. // debug Roule'
  4643. if (MY_DEBUG) {
  4644. window.console.log('traiteMission, save niveau=' + niveau + ', mod=' + mod + ', siMundidey=' + siMundidey + ', libelle=' + libelle);
  4645. }
  4646. saveMission(numMission,{
  4647. type: 'Niveau',
  4648. niveau: niveau,
  4649. mod: mod,
  4650. mundidey: siMundidey,
  4651. libelle: libelle
  4652. });
  4653. if (mod == 'plus')
  4654. addtroogle(tdLibelle, '@monstre level:' + niveau + '..' + (niveau+99));
  4655. else
  4656. addtroogle(tdLibelle, '@monstre level:' + (niveau-mod) + '..' + (niveau+mod));
  4657. } else if(libelle.indexOf('de la race')!=-1) {
  4658. var nbKills = 1, race;
  4659. if(tdLibelle.firstChild.nodeValue.indexOf('de la race')==-1) {
  4660. // Étape de kill multiple de race donnée
  4661. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4662. race = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4663. } else {
  4664. // Étape de kill unique de race donnée
  4665. race = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4666. }
  4667. race = race.replace(/\"/g,'');
  4668. saveMission(numMission,{
  4669. type: 'Race',
  4670. race: race,
  4671. mundidey: siMundidey,
  4672. libelle: libelle
  4673. });
  4674. addtroogle(tdLibelle, '@monstre ' + race);
  4675. } else if(libelle.indexOf('de la famille')!=-1) {
  4676. var nbKills = 1, famille;
  4677. if(tdLibelle.firstChild.nodeValue.indexOf('de la famille')==-1) {
  4678. // Étape de kill multiple de famille donnée
  4679. //nbKills = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4680. famille = trim(tdLibelle.childNodes[3].firstChild.nodeValue);
  4681. } else {
  4682. // Étape de kill unique de famille donnée
  4683. famille = trim(tdLibelle.childNodes[1].firstChild.nodeValue);
  4684. }
  4685. famille = famille.replace(/\"/g,'');
  4686. saveMission(numMission,{
  4687. type: 'Famille',
  4688. famille: famille,
  4689. mundidey: siMundidey,
  4690. libelle: libelle
  4691. });
  4692. //Roule' 07/01/2017 À ce jour, pour les familles, Troogle a besoin de minuscules sans accent
  4693. addtroogle(tdLibelle, '@monstre:' + famille.toLowerCase().replace(/é/g, 'e').replace(/ï/g, 'i'));
  4694. } else if(libelle.indexOf('capacité spéciale')!=-1) {
  4695. var pouvoir = epure(trim(tdLibelle.childNodes[1].firstChild.nodeValue));
  4696. debugMZ('traiteMission étape capacité spéciale');
  4697. saveMission(numMission,{
  4698. type: 'Pouvoir',
  4699. pouvoir: pouvoir,
  4700. libelle: libelle
  4701. });
  4702. } else {
  4703. debugMZ('traiteMission étape pas pour troogle');
  4704. saveMission(numMission,false);
  4705. }
  4706. } catch(e) {
  4707. window.console.error(traceStack(e, 'récupération étape mission'));
  4708. return;
  4709. }
  4710. }
  4711.  
  4712. function do_mission() {
  4713. start_script(60);
  4714.  
  4715. traiteMission();
  4716.  
  4717. displayScriptTime();
  4718. }
  4719.  
  4720. /*******************************************************************************
  4721. * This file is part of Mountyzilla. *
  4722. * *
  4723. * Mountyzilla is free software; you can redistribute it and/or modify *
  4724. * it under the terms of the GNU General Public License as published by *
  4725. * the Free Software Foundation; either version 2 of the License, or *
  4726. * (at your option) any later version. *
  4727. * *
  4728. * Mountyzilla is distributed in the hope that it will be useful, *
  4729. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  4730. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  4731. * GNU General Public License for more details. *
  4732. * *
  4733. * You should have received a copy of the GNU General Public License *
  4734. * along with Mountyzilla; if not, write to the Free Software *
  4735. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  4736. *******************************************************************************/
  4737.  
  4738. // x~x move
  4739.  
  4740. /*-[variables+function]- Données sur les trous de météorites -----------------*/
  4741.  
  4742. var petitsTrous = {
  4743. '-52;57': true,
  4744. '55;70': true,
  4745. '64;70': true,
  4746. '12;-15': true,
  4747. '30;-52': true,
  4748. '48;-39': true
  4749. };
  4750.  
  4751. var grosTrous = {
  4752. '-35;65': true,
  4753. '-13;73': true,
  4754. '-64;9': true,
  4755. '-35;15': true,
  4756. '5;32': true,
  4757. '10;64': true,
  4758. '21;36': true,
  4759. '46;52': true,
  4760. '74;32': true,
  4761. '-71;-7': true,
  4762. '-67;-37': true,
  4763. '-60;-32': true,
  4764. '-51;-22': true,
  4765. '-36;-51': true,
  4766. '5;-49': true
  4767. };
  4768.  
  4769. var centreCarmine_X = 56.5;
  4770. var centreCarmine_Y = 23.5;
  4771. var rayonCarmine = 8.7;
  4772.  
  4773. function isTrou(x,y,n) {
  4774. if(petitsTrous[x+';'+y]) {
  4775. return n<0 && n>-60;
  4776. }
  4777. if(grosTrous[x+';'+y]
  4778. || grosTrous[x-1+';'+y]
  4779. || grosTrous[x+';'+y+1]
  4780. || grosTrous[x-1+';'+y+1]) {
  4781. return n<0 && n>-70;
  4782. }
  4783. if(Math.sqrt(
  4784. Math.pow(x-centreCarmine_X,2)+Math.pow(y-centreCarmine_Y,2)
  4785. )<=rayonCarmine) {
  4786. return n<0 && n>-100;
  4787. }
  4788. return false;
  4789. }
  4790.  
  4791. /*-[functions]----------------- Gestion des DEs ------------------------------*/
  4792.  
  4793. function validateDestination() {
  4794. var x = Number(document.getElementsByName('ai_XDepart')[0].value);
  4795. var y = Number(document.getElementsByName('ai_YDepart')[0].value);
  4796. var n = Number(document.getElementsByName('ai_NDepart')[0].value);
  4797. var form = document.getElementsByName('ActionForm')[0];
  4798. if(form) {
  4799. for(var i=0 ; i<document.getElementsByName('ai_DeplX').length ; i++) {
  4800. if(document.getElementsByName('ai_DeplX')[i].checked) {
  4801. x += Number(document.getElementsByName('ai_DeplX')[i].value);
  4802. }
  4803. }
  4804. for(var i=0 ; i<document.getElementsByName('ai_DeplY').length ; i++) {
  4805. if(document.getElementsByName('ai_DeplY')[i].checked) {
  4806. y += Number(document.getElementsByName('ai_DeplY')[i].value);
  4807. }
  4808. }
  4809. for(var i=0 ; i<document.getElementsByName('ai_DeplN').length ; i++) {
  4810. if(document.getElementsByName('ai_DeplN')[i].checked) {
  4811. n += Number(document.getElementsByName('ai_DeplN')[i].value);
  4812. }
  4813. }
  4814. if(isTrou(x,y,n)) {
  4815. return window.confirm(
  4816. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4817. +'Vous allez tomber dans un trou de météorite.\n'
  4818. +'Êtes vous sûr de vouloir effectuer ce déplacement ?'
  4819. );
  4820. }
  4821. }
  4822. return true;
  4823. }
  4824.  
  4825. function newsubmitDE(event) {
  4826. event.stopPropagation();
  4827. event.preventDefault();
  4828. if(validateDestination()) {
  4829. this.submit();
  4830. }
  4831. }
  4832.  
  4833. function changeValidation() {
  4834. var form = document.getElementsByName('ActionForm')[0];
  4835. if(form) {
  4836. form.addEventListener('submit', newsubmitDE, true);
  4837. }
  4838. }
  4839.  
  4840.  
  4841. /*-[functions]----------------- Gestion des TPs ------------------------------*/
  4842.  
  4843. function validateTPDestination() {
  4844. try {
  4845. var text = document.getElementsByTagName('B')[0];
  4846. var a = text.firstChild.nodeValue.split('|');
  4847. var pos_x = a[0].substring(4, a[0].length - 1) * 1;
  4848. var pos_y = a[1].substring(5, a[1].length - 1) * 1;
  4849. var pos_n = a[2].substring(5, a[2].length) * 1;
  4850.  
  4851. var nbtrous = 0;
  4852. for(var signX=-1 ; signX<=1 ; signX+=2) {
  4853. for(var x=0 ; x<=2 ; x++) {
  4854. for(var signY=-1 ; signY<=1 ; signY+=2) {
  4855. for(var y=0 ; y<=2 ; y++) {
  4856. for(var signN = -1 ; signN <= 1 ; signN+=2) {
  4857. for(var n = 0 ; n <= 1 ; n++) {
  4858. if(isTrou(
  4859. pos_x+signX*x,pos_y+signY*y,Math.min(-1,pos_n+signN*n)
  4860. )) {
  4861. nbtrous++;
  4862. }
  4863. }
  4864. }
  4865. }
  4866. }
  4867. }
  4868. }
  4869. if(nbtrous>0 && nbtrous<72) {
  4870. return window.confirm(
  4871. 'La voix de mini TilK (n°36216) résonne dans votre tête :\n'
  4872. +'Vous avez '+Math.floor((100*nbtrous)/144)
  4873. +'% de risque de tomber dans un trou de météorite.\n'
  4874. +'Êtes-vous sûr de vouloir prendre ce portail ?'
  4875. );
  4876. }
  4877. else if(nbtrous>=72) {
  4878. return window.confirm(
  4879. 'La voix de mini TilK (n°36216) tonne dans votre tête :\n'
  4880. +'Malheureux, vous avez '+Math.floor((100*nbtrous)/144)
  4881. +'% de risque de tomber dans un trou de météorite !\n'
  4882. +'Êtes-vous bien certain de vouloir prendre ce portail ?'
  4883. );
  4884. }
  4885. return true;
  4886. }
  4887. catch(e) {
  4888. window.alert(e)
  4889. }
  4890. }
  4891.  
  4892. function newsubmitTP(event) {
  4893. event.stopPropagation();
  4894. event.preventDefault();
  4895. if(validateTPDestination()) {
  4896. this.submit();
  4897. }
  4898. }
  4899.  
  4900. function changeButtonValidate() {
  4901. var form = document.getElementsByName('Formulaire')[0];
  4902. if(form) {
  4903. if(!form.getAttribute('onsubmit')) {
  4904. form.setAttribute('onsubmit','return true;');
  4905. }
  4906. form.addEventListener('submit', newsubmitTP, true);
  4907. }
  4908. }
  4909.  
  4910.  
  4911. /*-[functions]---------------- Partie Principale -----------------------------*/
  4912.  
  4913. function do_move() {
  4914. // Roule', vérification du risque de tomber dans un trou déplacée dans do_lieuTeleport pour le cas des TP
  4915. //if(isPage('MH_Play/Actions/Play_a_Move.php')) {
  4916. changeValidation();
  4917. //}
  4918. //else if(isPage('MH_Lieux/Lieu_Teleport.php')) {
  4919. // changeButtonValidate();
  4920. //}
  4921. }
  4922.  
  4923. /*******************************************************************************
  4924. * This file is part of Mountyzilla (http://mountyzilla.tilk.info/) *
  4925. * Mountyzilla is free software; provided under the GNU General Public License *
  4926. *******************************************************************************/
  4927.  
  4928. // x~x news
  4929.  
  4930. // Nombre de news à afficher & nb max de caractères par news:
  4931. const nbItems = 5;
  4932. const maxCarDescription = 300;
  4933.  
  4934. /*-[functions]------------------- Utilitaires --------------------------------*/
  4935.  
  4936. // Ne semble avoir strictement aucun effet:
  4937. String.prototype.epureDescription = function() {
  4938. return this.replace(/\\(.)/g,"$1");
  4939. }
  4940.  
  4941. function appendTitledTable(node,titre,description) {
  4942. // Crée les tables contenant les infos (avec titre)
  4943. var table = document.createElement('table');
  4944. table.border = 0;
  4945. table.className = 'mh_tdborder';
  4946. table.cellSpacing = 1;
  4947. table.cellPadding = 1;
  4948. table.style.maxWidth = '98%';
  4949. table.style.marginLeft = 'auto';
  4950. table.style.marginRight = 'auto';
  4951. var tbody = document.createElement('tbody');
  4952. table.appendChild(tbody);
  4953. var tr = appendTr(tbody,'mh_tdtitre');
  4954. var td = appendTdCenter(tr,2);
  4955. var span = document.createElement('span');
  4956. appendText(span,titre,true);
  4957. if(description) {
  4958. span.title = description;
  4959. }
  4960. td.appendChild(span);
  4961. node.appendChild(table);
  4962. return tbody;
  4963. }
  4964.  
  4965. function testCertif(paramURL, callbackOnError) {
  4966. try {
  4967. FF_XMLHttpRequest({
  4968. method: 'GET',
  4969. url: paramURL,
  4970. onload: function(responseDetails) {
  4971. //window.console.log('testCertif(' + paramURL + '), callback, status=' + responseDetails.status);
  4972. if (responseDetails.status == 0) callbackOnError(); // FAIL si status == 0
  4973. }
  4974. });
  4975. } catch(e) {
  4976. window.console.log('[MZ] erreur testCertif(' + paramURL + ')' + traceStack(e, 'testCertif'));
  4977. callbackOnError();
  4978. }
  4979. }
  4980.  
  4981. function createOrGetGrandCadre() {
  4982. var grandCadre = document.getElementById('grandCadre');
  4983. if (grandCadre) return grandCadre;
  4984. try {
  4985. var rappels = document.evaluate(
  4986. "//p[contains(a/text(),'messagerie')]",
  4987. document, null, 9, null).singleNodeValue;
  4988. }
  4989. catch(e) {
  4990. window.alert('Tu es en HTTPS. Pour bénéficier de MoutyZilla, tu devrais débloquer le contenu mixte');
  4991. grandCadre = document.createElement('div');
  4992. return grandCadre;
  4993. }
  4994. grandCadre = document.createElement('div');
  4995. grandCadre.id = 'grandCadre';
  4996. var sousCadre = document.createElement('div');
  4997. sousCadre.innerHTML = 'Tu es en <span style="color:blue">HTTPS</span>.';
  4998. sousCadre.style.textAlign = 'center';
  4999. sousCadre.style.fontSize = 'xx-large';
  5000. grandCadre.appendChild(sousCadre);
  5001.  
  5002. grandCadre.style.border = 'solid 5px red';
  5003. grandCadre.style.width = 'auto';
  5004. insertBefore(rappels,grandCadre);
  5005. return grandCadre;
  5006. }
  5007.  
  5008. function showHttpsErrorCadre1() {
  5009. window.console.log('[MZ] showHttpsErrorCadre1');
  5010. var grandCadre = createOrGetGrandCadre();
  5011. var sousCadre = document.createElement('div');
  5012. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat1 de Raistlin.</b>'
  5013. + '<br />Cela empêchera Moutyzilla de fonctionner'
  5014. + '<br /><a style="color:blue;font-size: inherits;" href="'
  5015. + URL_CertifRaistlin1
  5016. + '" target="raistlin">clique ici</a>'
  5017. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5018. + ' « Confirmer l\'exception de sécurité »'
  5019. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5020. sousCadre.style.width = 'auto';
  5021. sousCadre.style.fontSize = 'large';
  5022. sousCadre.style.border = 'solid 1px black';
  5023. sousCadre.style.backgroundColor = 'red';
  5024. grandCadre.appendChild(sousCadre);
  5025. }
  5026.  
  5027. function showHttpsErrorCadre2() {
  5028. window.console.log('[MZ] showHttpsErrorCadre2');
  5029. var grandCadre = createOrGetGrandCadre();
  5030. var sousCadre = document.createElement('div');
  5031. sousCadre.innerHTML = '<b>Tu n\'as pas accepté le certificat2 de Raistlin.</b>'
  5032. + '<br />Cela empêchera le fonctionnement de l\'affichage des Potrõlls dans la vue<br />'
  5033. + '<a style="color:blue;font-size: inherits;" href="'
  5034. + URL_CertifRaistlin2
  5035. + '" target="raistlin">clique ici</a>'
  5036. + '<br />puis « Avancé » ... « Ajouter une exception » ...'
  5037. + ' « Confirmer l\'exception de sécurité »'
  5038. + '<br />(Ignorer ensuite le message sur l\'erreur de mot de passe)'
  5039. + '<br /><i>Il suffit de faire ceci une seule fois jusqu\'à ce que Raistlin change son certificat</i>';
  5040. sousCadre.style.width = 'auto';
  5041. sousCadre.style.fontSize = 'large';
  5042. sousCadre.style.border = 'solid 1px black';
  5043. sousCadre.style.backgroundColor = 'red';
  5044. grandCadre.appendChild(sousCadre);
  5045. }
  5046.  
  5047. function showHttpsErrorContenuMixte() {
  5048. window.console.log('[MZ] showHttpsErrorContenuMixte');
  5049. var grandCadre = createOrGetGrandCadre();
  5050. var sousCadre = document.createElement('div');
  5051. sousCadre.innerHTML = '<b>Tu n\'as pas autorisé le contenu mixte.</b><br />'
  5052. + '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)'
  5053. + '<ul>'
  5054. + '<li>Interface Bricol\'Troll</li>'
  5055. + '<li>Nouveautés de Mountyzilla</li>'
  5056. + '</ul>'
  5057. + '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 />'
  5058. + '<i>Il faudra malheureusement le faire à chaque nouvelle connexion</i>';
  5059. sousCadre.style.width = 'auto';
  5060. sousCadre.style.fontSize = 'large';
  5061. sousCadre.style.border = 'solid 1px black';
  5062. grandCadre.appendChild(sousCadre);
  5063. }
  5064.  
  5065. /*-[functions]------------------- Jubilaires ---------------------------------*/
  5066.  
  5067. function traiterJubilaires() {
  5068. // à faire
  5069. }
  5070.  
  5071. function traiterJubilaires_a_supprimer() { // ancienne méthode
  5072. try {
  5073. FF_XMLHttpRequest({
  5074. method: 'GET',
  5075. url: URL_anniv,
  5076. headers: {
  5077. 'User-agent': 'Mozilla/4.0 (compatible) Mountyzilla',
  5078. 'Accept': 'application/xml,text/xml',
  5079. },
  5080. onload: function(responseDetails) {
  5081. if ((responseDetails.status == 0) && isHTTPS) {
  5082. //window.console.log('status=0 à l\'appel jubilaires, réponse=' + responseDetails.responseText);
  5083. showHttpsErrorContenuMixte();
  5084. return;
  5085. }
  5086. var listeTrolls = responseDetails.responseText.split('\n');
  5087. if(!listeTrolls || listeTrolls.length==0) {
  5088. return;
  5089. }
  5090. afficherJubilaires(listeTrolls);
  5091. },
  5092. });
  5093. }
  5094. catch(e) {
  5095. if (isHTTPS) {
  5096. window.console.log(traceStack(e, 'appel jubilaires'));
  5097. showHttpsErrorContenuMixte();
  5098. } else {
  5099. window.alert('Erreur Jubilaires:\n'+e);
  5100. }
  5101. }
  5102. }
  5103.  
  5104. function afficherJubilaires(listeTrolls) {
  5105. try {
  5106. var rappels = document.evaluate(
  5107. "//p[contains(a/text(),'messagerie')]",
  5108. document, null, 9, null).singleNodeValue;
  5109. }
  5110. catch(e) {
  5111. return;
  5112. }
  5113. var p = document.createElement('p');
  5114. var tbody = appendTitledTable(p,
  5115. "Les Trõlls qui fêtent leur anniversaire aujourd'hui:",
  5116. 'Envoyez leur un message ou un cadeau !'
  5117. );
  5118. tr = appendTr(tbody,'mh_tdpage');
  5119. td = appendTdCenter(tr);
  5120. var small = document.createElement('small');
  5121. td.appendChild(small);
  5122. var first = true;
  5123. for(var i=0 ; i<listeTrolls.length ; i++) {
  5124. var infos = listeTrolls[i].split(';');
  5125. if(infos.length!=3 || infos[2]==='0') {
  5126. continue;
  5127. }
  5128. if(first) {
  5129. first = false;
  5130. }
  5131. else {
  5132. appendText(small,', ');
  5133. }
  5134. var a = document.createElement('a');
  5135. a.href = 'javascript:EPV('+infos[0]+')';
  5136. appendText(a,infos[1]);
  5137. small.appendChild(a);
  5138. appendText(small, ' ('+infos[2]+(infos[2]==='1' ? ' an)' : ' ans)') );
  5139. }
  5140. insertBefore(rappels,p);
  5141. }
  5142.  
  5143.  
  5144. /*-[functions]--------------------- News MZ ----------------------------------*/
  5145.  
  5146. function traiterNouvelles() {
  5147. var news = new Array;
  5148. 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 ;).']);
  5149. news.push(['01/01/2017', 'Lien vers Troogle pour les missions dans les étapes monstre']);
  5150. news.push(['06/01/2017', 'Petite icône dans le cadre de gauche pour rafraîchir les coordonnées']);
  5151. 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']);
  5152. news.push(['25/01/2017', 'Cartes pour l\'ensemble des suivants et pour visualiser l\'arrivée du TP']);
  5153. afficherNouvelles(news);
  5154. }
  5155.  
  5156. function afficherNouvelles(items) {
  5157. var footer = document.getElementById('footer1');
  5158. if(!footer) {
  5159. window.console.log('[MZ ' + GM_info.script.version + '] afficherNouvelles, impossible de retrouver le footer par getElementById(\'footer1\')');
  5160. return;
  5161. }
  5162. var p = document.createElement('p');
  5163. var tbody = appendTitledTable(p, 'Les nouvelles de Mountyzilla');
  5164. var div = document.createElement('div');
  5165. div.style.position = 'absolute';
  5166. div.style.right = 0;
  5167. div.style.top = 0;
  5168. div.style.paddingRight = '3px';
  5169. div.style.whiteSpace = 'nowrap';
  5170. appendText(div, '(version ' + GM_info.script.version + ')');
  5171. tbody.rows[0].cells[0].style.position = 'relative';
  5172. tbody.rows[0].cells[0].appendChild(div);
  5173. for(var i=0 ; i<items.length ; i++) {
  5174. var tr = appendTr(tbody,'mh_tdpage');
  5175. var td = appendTdCenter(tr);
  5176. td.style.verticalAlign = 'top'; // semble sans effet
  5177. appendText(td,items[i][0],true);
  5178. td = appendTd(tr);
  5179. td.innerHTML = items[i][1];
  5180. }
  5181. insertBefore(footer,p);
  5182.  
  5183. // changelog
  5184. var p = document.createElement('p');
  5185. var tbody = appendTitledTable(p, 'Changelog de Mountyzilla');
  5186. tbody.rows[0].cells[0].style.cursor = 'pointer';
  5187. tbody.rows[0].cells[0].onclick = function() {
  5188. try {
  5189. tbody.rows[0].cells[0].onclick = undefined;
  5190. tbody.rows[0].cells[0].style.cursor = '';
  5191. var tr = appendTr(tbody,'mh_tdpage');
  5192. var td = appendTd(tr);
  5193. td.colSpan = 2;
  5194. var pre = document.createElement('pre');
  5195. appendText(pre,MZ_changeLog.join("\n"));
  5196. td.appendChild(pre);
  5197. } catch (e) {
  5198. window.console.log('[MZ] affichage changeLog', e);
  5199. }
  5200. };
  5201. insertBefore(footer,p);
  5202.  
  5203. if (isDEV) { // Roule 02/02/2017 copie de la conf vers https
  5204. if (false) { // essai avorté via sessionStorage (ne fonctionne pas)
  5205. if (isHTTPS) {
  5206. window.console.log('[MZ test] sessionStorage.getItem(xxx)=' + window.sessionStorage.getItem('xxx'));
  5207. window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5208. } else {
  5209. window.console.log('[MZ test] début switch to https');
  5210. window.sessionStorage.setItem('xxx', "test session trans https");
  5211. window.parent.xxx = "autre test";
  5212. var url = document.location.href;
  5213. window.console.log('[MZ test] url=' + url);
  5214. url = url.replace(/http:\/\//i, 'https://')
  5215. window.console.log('[MZ test] switched url=' + url);
  5216. document.location.href = url;
  5217. }
  5218. }
  5219. if (false) { // version par utilisation d'un IFrame en https
  5220. if (isHTTPS) {
  5221. //window.console.log('[MZ test] window.xxx=' + window.xxx);
  5222. //window.console.log('[MZ test] window.name=' + window.name);
  5223. //window.console.log('[MZ test] window.document.xxx=' + window.document.xxx);
  5224. //window.console.log('[MZ test] window.parent.xxx=' + window.parent.xxx);
  5225. var txt = window.name;
  5226. var tabtxt = txt.split(/µ/);
  5227. for (var i = 0; i < tabtxt.length; i++) {
  5228. window.console.log('[MZ test]config https ' + tabtxt[i]);
  5229. }
  5230. } else {
  5231. var txt = '';
  5232. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  5233. var k = localStorage.key(i);
  5234. //if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  5235. txt += k + "£" + localStorage.getItem(k) + "µ";
  5236. }
  5237. var iframe = document.createElement('iframe');
  5238. var url = document.location.href;
  5239. //window.console.log('[MZ test] url=' + url);
  5240. url = url.replace(/http:\/\//i, 'https://')
  5241. //window.console.log('[MZ test] switched url=' + url);
  5242. //iframe.xxx = "truc en plume";
  5243. iframe.name = txt;
  5244. //window.xxx = "machin";
  5245. iframe.src = url;
  5246. //iframe.document.xxx = "truc en plume";
  5247. document.body.appendChild(iframe);
  5248. iframe.style.display = 'none';
  5249. }
  5250. }
  5251. }
  5252. }
  5253.  
  5254.  
  5255. /*---------------------------------- Main ------------------------------------*/
  5256.  
  5257. function do_news() {
  5258. start_script();
  5259.  
  5260. traiterJubilaires();
  5261. traiterNouvelles();
  5262.  
  5263. if (isHTTPS) {
  5264. // test si les certificats raistlin ont été acceptés
  5265. testCertif(URL_CertifRaistlin1, showHttpsErrorCadre1); // l'infra raislin
  5266. var infoit = MY_getValue(numTroll+'.INFOSIT');
  5267. if(infoit && infoit!=='') { // seulement pour les joueurs utilisant l'interface avec Bricol'Troll
  5268. testCertif(URL_CertifRaistlin2, showHttpsErrorCadre2); // le relai raistlin vers Bricol'Troll
  5269. }
  5270. }
  5271.  
  5272. displayScriptTime();
  5273. }
  5274.  
  5275. /*********************************************************************************
  5276. * This file is part of Mountyzilla. *
  5277. * *
  5278. * Mountyzilla is free software; you can redistribute it and/or modify *
  5279. * it under the terms of the GNU General Public License as published by *
  5280. * the Free Software Foundation; either version 2 of the License, or *
  5281. * (at your option) any later version. *
  5282. * *
  5283. * Mountyzilla is distributed in the hope that it will be useful, *
  5284. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5285. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5286. * GNU General Public License for more details. *
  5287. * *
  5288. * You should have received a copy of the GNU General Public License *
  5289. * along with Mountyzilla; if not, write to the Free Software *
  5290. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5291. *********************************************************************************/
  5292.  
  5293. // x~x tabcompo
  5294.  
  5295. var popup;
  5296.  
  5297. function initPopupTabcompo() {
  5298. popup = document.createElement('div');
  5299. popup.setAttribute('id', 'popup');
  5300. popup.setAttribute('class', 'mh_textbox');
  5301. popup.setAttribute('style', 'position: absolute; border: 1px solid #000000; visibility: hidden;'
  5302. + 'display: inline; z-index: 3; max-width: 400px;');
  5303. document.body.appendChild(popup);
  5304. }
  5305.  
  5306. function showPopup(evt) {
  5307. var texte = this.getAttribute("texteinfo");
  5308. popup.innerHTML = texte;
  5309. popup.style.left = evt.pageX + 15 + 'px';
  5310. popup.style.top = evt.pageY + 'px';
  5311. popup.style.visibility = "visible";
  5312. }
  5313.  
  5314. // roule 16/03/2016, existe déjà ailleurs
  5315. // function hidePopup() {
  5316. // popup.style.visibility = 'hidden';
  5317. // }
  5318.  
  5319. function createPopupImage(url, text)
  5320. {
  5321. var img = document.createElement('img');
  5322. img.setAttribute('src',url);
  5323. img.setAttribute('align','ABSMIDDLE');
  5324. img.setAttribute("texteinfo",text);
  5325. img.addEventListener("mouseover", showPopup,true);
  5326. img.addEventListener("mouseout", hidePopup,true);
  5327. return img;
  5328. }
  5329.  
  5330. function formateTexte(texte)
  5331. {
  5332. texte = texte.replace(/\n/g,"<br/>");
  5333. texte = texte.replace(/^([^<]*) d'un/g,"<b>$1</b> d'un");
  5334. texte = texte.replace(/<br\/>([^<]*) d'un/g,"<br/><b>$1</b> d'un");
  5335. texte = texte.replace(/(d'une? )([^<]*) d'au/g,"$1<b>$2</b> d'au");
  5336. texte = texte.replace(/(Qualité )([^<]*) \[/g,"$1<b>$2</b> [");
  5337. texte = texte.replace(/\[([^<]*)\]/g,"[<b>$1</b>]");
  5338. return texte;
  5339. }
  5340.  
  5341. function arrondi(x) {
  5342. return Math.ceil(x-0.5); // arrondi à l'entier le plus proche, valeurs inf
  5343. }
  5344.  
  5345. function traiteMinerai() {
  5346. if (currentURL.indexOf("as_type=Divers")==-1) return;
  5347. try {
  5348. var node = document.evaluate("//form/table/tbody[@class='tablesorter-no-sort'"
  5349. +" and contains(./tr/th/text(),'Minerai')]",
  5350. document, null, 9, null).singleNodeValue;
  5351. node = node.nextSibling.nextSibling;
  5352. }
  5353. catch(e) {return;}
  5354. var trlist = document.evaluate('./tr', node, null, 7, null);
  5355. for (var i=0 ; i<trlist.snapshotLength ; i++) {
  5356. var node = trlist.snapshotItem(i);
  5357. var nature = node.childNodes[5].textContent;
  5358. var caracs = node.childNodes[7].textContent;
  5359. var taille = caracs.match(/\d+/)[0];
  5360. var coef = 1;
  5361. if (caracs.indexOf('Moyen')!=-1) coef = 2;
  5362. else if (caracs.indexOf('Normale')!=-1) coef = 3;
  5363. else if (caracs.indexOf('Bonne')!=-1) coef = 4;
  5364. else if (caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  5365. if (nature.indexOf('Mithril')!=-1) {
  5366. coef = 0.2*coef;
  5367. appendText(node.childNodes[7], ' | UM: '+arrondi(taille*coef) );
  5368. }
  5369. else {
  5370. coef = 0.75*coef+1.25;
  5371. if (nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  5372. appendText(node.childNodes[7], ' | Carats: '+arrondi(taille*coef) );
  5373. }
  5374. }
  5375. }
  5376.  
  5377. // Roule' 06/01/2017 ne fonctionne plus, la récupération des nodes ne donne rien
  5378. function treateComposants() {
  5379. if (currentURL.indexOf("as_type=Compo")==-1) return;
  5380. //On récupère les composants
  5381. var nodes = document.evaluate(
  5382. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5383. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5384. + "and (contains(td[3]/text()[2],'Tous les trolls') or contains(td[3]/text()[1],'Tous les trolls') ) "
  5385. + "and td[1]/img/@alt = 'Identifié']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5386. if (nodes.snapshotLength == 0) {
  5387. //window.console.log('[MZ] treateComposants DOWN');
  5388. return;
  5389. }
  5390. //window.console.log('[MZ] treateComposants nbnodes=' + nodes.snapshotLength);
  5391.  
  5392. var texte = "";
  5393. for (var i = 0; i < nodes.snapshotLength; i++) {
  5394. var n1 = nodes.snapshotItem(i).childNodes[1];
  5395. var n3 = nodes.snapshotItem(i).childNodes[3];
  5396. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5397. var prix = n3.childNodes[0].nodeValue;
  5398. if (!prix)
  5399. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5400. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5401. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5402. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5403. + prix.replace(/\n/g, '') + "\n";
  5404. }
  5405.  
  5406. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5407. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5408. var id_taniere = c.snapshotItem(0).nodeValue;
  5409. id_taniere = id_taniere.substring(id_taniere.lastIndexOf('(') + 1, id_taniere.lastIndexOf(')'));
  5410.  
  5411. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5412. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"));
  5413. if (form)
  5414. {
  5415. if(document.getElementsByTagName('form').length>0)
  5416. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5417. else
  5418. {
  5419. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5420. insertBefore(thisP, form);
  5421. }
  5422. }
  5423. }
  5424.  
  5425. function treateAllComposants() {
  5426. if(currentURL.indexOf("as_type=Compo")==-1) return;
  5427. //On récupère les composants
  5428. var categ = document.evaluate( "count(//table/descendant::text()[contains(.,'Sans catégorie')])",
  5429. document, null, 0, null ).numberValue;
  5430. var c = (categ == 0 ? 3 : 4);
  5431. var nodes = document.evaluate("//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') "
  5432. + "or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]/following::table[@width = '100%']"
  5433. + "/descendant::tr[contains(td[1]/a/b/text(),']') and ("
  5434. + "td["+c+"]/text()[1] = '\240-\240' "
  5435. + "or contains(td["+c+"]/text()[2],'Tous les trolls') "
  5436. + "or contains(td["+c+"]/text()[1],'Tous les trolls') "
  5437. + "or (count(td["+c+"]/text()) = 1 and td["+c+"]/text()[1]='n°') ) "
  5438. + "and td[1]/img/@alt = 'Identifié']",
  5439. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5440. if (nodes.snapshotLength == 0) {
  5441. // window.alert('treateAllComposants DOWN');
  5442. return;
  5443. }
  5444.  
  5445. var texte = "";
  5446. for (var i = 0; i < nodes.snapshotLength; i++) {
  5447. var n1 = nodes.snapshotItem(i).childNodes[1];
  5448. var n3 = nodes.snapshotItem(i).childNodes[3];
  5449. var debut = n1.childNodes[2].nodeValue.replace(/\n/g, '');
  5450. var prix = n3.childNodes[0].nodeValue;
  5451. if (!prix)
  5452. {
  5453. if(n3.childNodes[3].getAttribute('value') && n3.childNodes[3].getAttribute('value')!="")
  5454. prix = n3.childNodes[3].getAttribute('value') + " GG'";
  5455. }
  5456. else
  5457. {
  5458. prix= prix.replace(/[\240 ]/g, "");
  5459. if(prix=="-")
  5460. prix=null;
  5461. }
  5462. if(prix)
  5463. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5464. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5465. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";"
  5466. + prix.replace(/\n/g, '') + "\n";
  5467. else
  5468. texte += debut.substring(debut.indexOf('[') + 1, debut.indexOf(']')) + ";"
  5469. + n1.childNodes[3].firstChild.nodeValue.replace(/\n/g, '')
  5470. + n1.childNodes[3].childNodes[1].firstChild.nodeValue.replace(/\n/g, '') + ";pas défini\n";
  5471. }
  5472.  
  5473. var c = document.evaluate("//div[@class = 'titre2']/text()",
  5474. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5475. var id_taniere = c.snapshotItem(0).nodeValue;
  5476. id_taniere = id_taniere.substring(id_taniere.indexOf('(') + 1, id_taniere.indexOf(')'));
  5477.  
  5478. var form = getFormComboDB(currentURL.indexOf('MH_Taniere') != -1 ? 'taniere' : 'grande_taniere', id_taniere,
  5479. texte.replace(/\240/g, " ").replace(/d'un/g, "d un"),"Vendre tous les composants non réservés sur le Troc de l\'Hydre");
  5480. if (form)
  5481. {
  5482. if(document.getElementsByTagName('form').length>0)
  5483. insertBefore(document.getElementsByTagName('form')[0].nextSibling, form);
  5484. else
  5485. {
  5486. var thisP = document.evaluate("//p/table/descendant::text()[contains(.,'Heure Serveur')]/../../../../..", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  5487. insertBefore(thisP, form);
  5488. }
  5489. }
  5490. }
  5491.  
  5492. function treateEM()
  5493. {
  5494. if (1) return; // Roule' 06/01/2017 ne fonctionne plus depuis.... longtemps
  5495. if(currentURL.indexOf("as_type=Compo")==-1)
  5496. return false;
  5497. var urlImg = URL_MZimg + "Competences/ecritureMagique.png";
  5498. var nodes = document.evaluate("//tr[@class='mh_tdpage']"
  5499. , document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5500. if (nodes.snapshotLength == 0)
  5501. return false;
  5502. for (var i = 0; i < nodes.snapshotLength; i++) {
  5503. var desc = nodes.snapshotItem(i).getElementsByTagName('td') ;
  5504. var link = desc[2].firstChild ;
  5505. var nomCompoTotal = desc[2].textContent ;
  5506. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5507. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5508. var nomMonstre = trim(nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length-1)) ;
  5509. var locqual = desc[3].textContent ;
  5510. var qualite = trim(locqual.substring(locqual.indexOf("Qualité:")+9)) ;
  5511. var localisation = trim(locqual.substring(0,locqual.indexOf("|")-1)) ;
  5512. if(isEM(nomMonstre).length>0)
  5513. {
  5514. var infos = composantEM(nomMonstre, trim(nomCompo), localisation,getQualite(qualite));
  5515. if(infos.length>0)
  5516. {
  5517. var shortDescr = "Variable";
  5518. var bold = 0;
  5519. if(infos != "Composant variable")
  5520. {
  5521. shortDescr = infos.substring(0,infos.indexOf(" "));
  5522. if(parseInt(shortDescr)>=0)
  5523. bold=1;
  5524. }
  5525. link.parentNode.appendChild(createImage(urlImg,infos)) ;
  5526. appendText(link.parentNode," ["+shortDescr+"]",bold) ;
  5527. }
  5528. }
  5529. }
  5530. }
  5531.  
  5532. function treateChampi() {
  5533. if (currentURL.indexOf('as_type=Champi')==-1)
  5534. return false;
  5535. var nodes = document.evaluate("//img[@alt = 'Identifié']/../a/text()[1]",
  5536. document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5537. if (nodes.snapshotLength == 0)
  5538. return false;
  5539.  
  5540. for (var i = 0; i < nodes.snapshotLength; i++) {
  5541. var node = nodes.snapshotItem(i);
  5542. var nomChampi = trim(node.nodeValue.replace(/\240/g, ' '));
  5543. if (moisChampi[nomChampi])
  5544. appendText(node.parentNode.parentNode,' [Mois '+moisChampi[nomChampi]+']');
  5545. }
  5546. }
  5547.  
  5548. function treateEnchant()
  5549. {
  5550. if(currentURL.indexOf("as_type=Compo")==-1)
  5551. return false;
  5552. try
  5553. {
  5554. if(!listeMonstreEnchantement)
  5555. computeCompoEnchantement();
  5556. var nodes = document.evaluate(
  5557. "//a[starts-with(@href,'TanierePJ_o_Stock.php?IDLieu=') or starts-with(@href,'Comptoir_o_Stock.php?IDLieu=')]"
  5558. + "/following::table[@width = '100%']/descendant::tr[contains(td[1]/a/b/text(),']') "
  5559. + "and td[1]/img/@alt = 'Identifié']/td[1]/a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  5560. if (nodes.snapshotLength == 0)
  5561. return false;
  5562. var urlImg = URL_MZimg + "enchant.png";
  5563. for (var i = 0; i < nodes.snapshotLength; i++) {
  5564. var link = nodes.snapshotItem(i);
  5565. var nomCompoTotal = link.firstChild.nodeValue;
  5566. var nomCompo = nomCompoTotal.substring(0,nomCompoTotal.indexOf(" d'un"));
  5567. nomCompoTotal = nomCompoTotal.substring(nomCompoTotal.indexOf("d'un"),nomCompoTotal.length);
  5568. var nomMonstre = nomCompoTotal.substring(nomCompoTotal.indexOf(" ")+1,nomCompoTotal.length);
  5569. nomCompoTotal = link.childNodes[1].childNodes[0].nodeValue;
  5570. var qualite = nomCompoTotal.substring(nomCompoTotal.indexOf("de Qualité")+11,nomCompoTotal.indexOf(" ["));
  5571. var localisation = nomCompoTotal.substring(nomCompoTotal.indexOf("[")+1,nomCompoTotal.indexOf("]"));
  5572. if(isEnchant(nomMonstre).length>0)
  5573. {
  5574. var infos = composantEnchant(nomMonstre, nomCompo, localisation,getQualite(qualite));
  5575. if(infos.length>0)
  5576. {
  5577. link.parentNode.appendChild(createImage(urlImg,infos));
  5578. }
  5579. }
  5580. }
  5581. }
  5582. catch(e)
  5583. {
  5584. window.alert(e);
  5585. }
  5586. }
  5587.  
  5588. function treateEquipEnchant()
  5589. {
  5590. if(currentURL.indexOf('as_type=Arme')==-1 && currentURL.indexOf('as_type=Armure')==-1)
  5591. return false;
  5592. initPopupTabcompo();
  5593. computeEnchantementEquipement(createPopupImage,formateTexte);
  5594. }
  5595.  
  5596. function do_tancompo() {
  5597. start_script();
  5598.  
  5599. treateAllComposants();
  5600. treateComposants();
  5601. traiteMinerai();
  5602. if (MY_getValue('NOINFOEM')!='true') {
  5603. treateChampi();
  5604. treateEM();
  5605. }
  5606. if (MY_getValue(numTroll+'.enchantement.liste') && MY_getValue(numTroll+'.enchantement.liste')!='') {
  5607. treateEnchant();
  5608. treateEquipEnchant();
  5609. }
  5610.  
  5611. displayScriptTime();
  5612. }
  5613.  
  5614. /*******************************************************************************
  5615. * This file is part of Mountyzilla. *
  5616. * *
  5617. * Mountyzilla is free software; you can redistribute it and/or modify *
  5618. * it under the terms of the GNU General Public License as published by *
  5619. * the Free Software Foundation; either version 2 of the License, or *
  5620. * (at your option) any later version. *
  5621. * *
  5622. * Mountyzilla is distributed in the hope that it will be useful, *
  5623. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  5624. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  5625. * GNU General Public License for more details. *
  5626. * *
  5627. * You should have received a copy of the GNU General Public License *
  5628. * along with Mountyzilla; if not, write to the Free Software *
  5629. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  5630. *******************************************************************************/
  5631.  
  5632. // x~x pjview
  5633.  
  5634. /* TODO
  5635. * - MZ2.0 : Implémenter les BDD en dur dans le module interne
  5636. */
  5637.  
  5638. // Bulle d'infos
  5639. var DivInfo;
  5640. // Booléen stockant l'état de freezing de la bulle
  5641. var freezed = false;
  5642.  
  5643. // liste du matos
  5644. // mh_caracs ['Nom'] = [ 'Type', 'AttP', 'AttM', 'DegP','DegM', 'Esq',
  5645. // 'ArmP','ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5646. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max' ];
  5647. var mh_caracs = {
  5648. 'anneau de protection':
  5649. ['anneau',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00,3.00,13.00],
  5650. "armure d'anneaux":
  5651. ['armure',0,0,0,0,-8,8,0,0,0,90,180,0,0,0,0.00,80.00,80.00],
  5652. 'armure de bois':
  5653. ['armure',0,0,0,0,-3,5,0,0,0,20,50,0,0,0,0.00,50.00,50.00],
  5654. 'armure de cuir':
  5655. ['armure',0,0,0,0,0,2,0,0,0,10,20,0,0,0,0.00,10.00,10.00],
  5656. 'armure de peaux':
  5657. ['armure',0,0,0,0,-2,4,0,0,0,20,60,0,0,0,0.00,45.00,45.00],
  5658. 'armure de pierre':
  5659. ['armure',0,0,0,0,-6,12,0,0,0,60,150,0,0,0,0.00,120.00,120.00],
  5660. 'armure de plates':
  5661. ['armure',0,0,0,0,-5,10,0,0,0,50,100,0,0,0,0.00,100.00,100.00],
  5662. 'baton lesté':
  5663. ['arme',2,0,-1,0,0,0,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5664. 'bâtons de parade':
  5665. ['arme',-4,0,0,0,2,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5666. 'bottes':
  5667. ['bottes',0,0,0,0,2,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5668. 'bouclier à pointes':
  5669. ['bouclier',1,0,1,0,-1,4,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5670. 'boulet et chaîne':
  5671. ['arme',-3,0,5,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5672. 'cagoule':
  5673. ['casque',0,0,0,0,1,0,0,-1,0,0,0,5,10,0,0.00,2.50,2.50],
  5674. 'casque à cornes':
  5675. ['casque',0,0,1,0,-1,3,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5676. 'casque à pointes':
  5677. ['casque',1,0,1,0,0,3,0,-1,0,0,0,0,0,0,0.00,12.50,12.50],
  5678. 'casque en cuir':
  5679. ['casque',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,5.00,5.00],
  5680. 'casque en métal':
  5681. ['casque',0,0,0,0,0,2,0,-1,0,5,10,0,0,0,0.00,10.00,10.00],
  5682. 'chaîne cloutée':
  5683. ['arme',-2,0,4,0,1,0,0,0,0,0,0,0,0,0,0.00,35.00,35.00],
  5684. 'chapeau pointu':
  5685. ['casque',0,0,0,0,0,1,0,0,0,0,0,5,10,0,0.00,5.00,5.00],
  5686. 'collier de dents':
  5687. ['talisman',0,0,1,0,0,0,0,0,0,0,0,0,0,0,5.00,1.00,1.00],
  5688. 'collier de pierre':
  5689. ['talisman',0,0,0,0,0,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5690. 'collier à pointes':
  5691. ['talisman',0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5692. 'cotte de mailles':
  5693. ['armure',0,0,0,0,-3,7,0,0,0,30,60,0,0,0,0.00,70.00,70.00],
  5694. 'couronne de cristal':
  5695. ['casque',0,0,0,1,-1,0,-1,3,0,0,0,0,0,0,0.00,10.00,10.00],
  5696. "couronne d'obsidienne":
  5697. ['casque',0,0,0,-1,0,1,2,0,-1,0,0,0,0,0,0.00,10.00,10.00],
  5698. "coutelas d'obsidienne":
  5699. ['arme',2,0,2,0,0,0,0,0,-2,-10,-5,-30,-15,0,0.00,5.00,5.00],
  5700. 'coutelas en os':
  5701. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,4.00,4.00],
  5702. 'crochet':
  5703. ['arme',-2,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5704. 'cuir bouilli':
  5705. ['armure',0,0,0,0,-1,3,0,0,0,20,40,0,0,0,0.00,18.00,18.00],
  5706. "cuirasse d'ossements":
  5707. ['armure',0,0,0,0,-3,5,0,0,0,15,30,15,30,0,0.00,67.50,67.50],
  5708. "cuirasse d'écailles":
  5709. ['armure',0,0,0,0,-3,6,0,0,0,30,70,0,0,0,0.00,60.00,60.00],
  5710. 'culotte en cuir':
  5711. ['armure',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5712. 'dague':
  5713. ['arme',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5714. 'epée courte':
  5715. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5716. 'epée longue':
  5717. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5718. 'espadon':
  5719. ['arme',-6,0,8,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5720. 'fouet':
  5721. ['arme',4,0,-2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5722. 'fourrures':
  5723. ['armure',0,0,0,0,0,2,0,0,0,15,30,0,0,0,0.00,10.00,10.00],
  5724. 'gantelet':
  5725. ['arme',-2,0,1,0,1,2,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5726. 'gorgeron en cuir':
  5727. ['talisman',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5728. 'gorgeron en métal':
  5729. ['talisman',0,0,0,0,0,2,0,0,-1,0,0,0,0,0,0.00,5.00,5.00],
  5730. 'gourdin':
  5731. ['arme',-1,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,12.50,12.50],
  5732. 'gourdin clouté':
  5733. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5734. 'grimoire':
  5735. ['bouclier',-2,2,-1,1,0,0,0,0,0,0,0,5,10,0,10.00,25.00,25.00],
  5736. "gros'porte":
  5737. ['bouclier',0,0,0,0,-1,5,0,0,0,10,20,0,0,0,0.00,50.00,50.00],
  5738. 'grosse racine':
  5739. ['arme',-1,0,3,0,0,0,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5740. 'grosse stalagmite':
  5741. ['arme',-20,0,28,0,-15,0,0,-4,0,0,0,0,0,0,0.00,125.00,125.00],
  5742. 'hache de bataille':
  5743. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,40.00,40.00],
  5744. 'hache de guerre en os':
  5745. ['arme',-4,0,6,0,0,0,0,0,0,0,0,0,0,0,0.00,25.00,25.00],
  5746. 'hache de guerre en pierre':
  5747. ['arme',-10,0,14,0,0,0,0,0,0,5,10,0,0,0,0.00,75.00,75.00],
  5748. "hache à deux mains d'obsidienne":
  5749. ['arme',-8,0,16,0,0,0,0,0,-4,-90,-50,-30,-15,0,0.00,75.00,75.00],
  5750. 'hallebarde':
  5751. ['arme',-10,0,12,0,0,0,0,0,0,0,0,0,0,0,0.00,60.00,60.00],
  5752. "haubert d'écailles":
  5753. ['armure',0,0,0,0,-4,8,0,0,0,40,80,0,0,0,0.00,80.00,80.00],
  5754. 'haubert de mailles':
  5755. ['armure',0,0,0,0,-4,9,0,0,0,40,90,0,0,0,0.00,90.00,90.00],
  5756. 'heaume':
  5757. ['casque',-1,0,0,0,0,4,0,-2,0,10,20,0,0,0,0.00,20.00,20.00],
  5758. 'jambières en cuir':
  5759. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5760. 'jambières en fourrure':
  5761. ['bottes',0,0,0,0,0,1,0,0,0,5,10,0,0,0,0.00,2.50,2.50],
  5762. 'jambières en maille':
  5763. ['bottes',0,0,0,0,-1,3,0,0,0,5,10,0,0,0,0.00,20.00,20.00],
  5764. 'jambières en métal':
  5765. ['bottes',0,0,0,0,-2,4,0,0,0,5,10,0,0,0,0.00,25.00,25.00],
  5766. 'jambières en os':
  5767. ['bottes',0,0,0,0,-1,2,0,0,0,5,10,0,0,0,0.00,10.00,10.00],
  5768. "lame d'obsidienne":
  5769. ['arme',2,0,6,0,0,0,0,0,-3,-60,-30,-20,-10,0,0.00,20.00,20.00],
  5770. 'lame en os':
  5771. ['arme',0,0,2,0,0,0,0,0,0,0,0,0,0,0,0.00,7.00,7.00],
  5772. 'lame en pierre':
  5773. ['arme',-2,0,4,0,0,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5774. 'lorgnons':
  5775. ['casque',0,0,0,0,-1,0,0,1,0,0,0,5,10,0,0.00,2.50,2.50],
  5776. 'machette':
  5777. ['arme',1,0,2,0,-1,0,0,0,0,0,0,0,0,0,0.00,20.00,20.00],
  5778. "masse d'arme":
  5779. ['arme',-1,0,3,0,0,0,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5780. 'pagne de mailles':
  5781. ['armure',0,0,0,0,2,1,0,0,0,0,0,0,0,0,0.00,7.50,7.50],
  5782. 'pagne en cuir':
  5783. ['armure',0,0,0,0,2,-1,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5784. 'robe de mage':
  5785. ['armure',0,0,0,0,-1,2,1,0,0,10,20,10,20,0,0.00,20.00,20.00],
  5786. 'rondache en bois':
  5787. ['bouclier',0,0,0,0,1,1,0,0,0,0,0,0,0,0,0.00,15.00,15.00],
  5788. 'rondache en métal':
  5789. ['bouclier',0,0,0,0,1,2,0,0,0,0,0,0,0,0,0.00,30.00,30.00],
  5790. 'sandales':
  5791. ['bottes',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,2.50,2.50],
  5792. 'souliers dorés':
  5793. ['bottes',0,0,0,0,-1,1,1,0,0,0,0,0,0,0,0.00,10.00,10.00],
  5794. "talisman d'obsidienne":
  5795. ['talisman',1,0,2,0,0,0,0,0,-4,20,40,20,40,0,0.00,2.50,2.50],
  5796. 'talisman de pierre':
  5797. ['talisman',0,0,0,0,0,0,0,0,-1,10,20,10,20,0,0.00,2.50,2.50],
  5798. 'targe':
  5799. ['bouclier',0,0,0,0,1,0,0,0,0,0,0,0,0,0,0.00,5.00,5.00],
  5800. 'torche':
  5801. ['arme',1,0,1,0,0,0,0,1,0,0,0,0,0,0,0.00,5.00,5.00],
  5802. 'torque de pierre':
  5803. ['talisman',0,0,0,0,0,0,0,0,-2,20,40,20,40,0,0.00,2.50,2.50],
  5804. 'tunique':
  5805. ['armure',0,0,0,0,1,0,0,0,0,5,10,5,10,0,0.00,2.50,2.50],
  5806. "tunique d'écailles":
  5807. ['armure',0,0,0,0,-1,3,0,0,0,15,30,0,0,0,0.00,30.00,30.00],
  5808. 'turban':
  5809. ['casque',0,0,0,0,0,0,0,0,0,10,20,0,0,0,0.00,2.50,2.50]
  5810. }
  5811.  
  5812. // liste des templates
  5813. // mh_templates['Nom'] = [ 'AttP', 'AttM', 'DegP', 'DegM', 'Esq',
  5814. // 'ArmP', 'ArmM', 'Vue', 'Reg', 'RM_Min', 'RM_Max', 'MM_Min', 'MM_Max',
  5815. // 'PV', 'DLA', 'Poids_Min', 'Poids_Max');
  5816. var mh_templates = {
  5817. 'de Feu':
  5818. [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5819. 'de Résistance':
  5820. [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
  5821. "de l'Aigle":
  5822. [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
  5823. 'de la Salamandre':
  5824. [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5825. 'des Cyclopes':
  5826. [0,1,0,1,0,0,0,-1,0,0,0,0,0,0,0,0,0],
  5827. 'des Enragés':
  5828. [0,1,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0],
  5829. 'des Tortues':
  5830. [0,0,0,0,0,0,2,0,0,0,0,0,0,0,30,0,0],
  5831. 'des Vampires':
  5832. [0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
  5833. 'du Glacier':
  5834. [0,1,0,0,0,0,1,0,0,5,5,0,0,0,0,0,0],
  5835. 'du Rat':
  5836. [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5837. 'du Roc':
  5838. [0,0,0,0,-1,0,1,0,0,0,0,0,0,0,0,0,0],
  5839. 'du Temps':
  5840. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,0],
  5841. 'du Vent':
  5842. [0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0],
  5843. 'en Mithril':
  5844. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5845. 'des Anciens':
  5846. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5847. 'des Champions':
  5848. [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5849. 'des Duellistes':
  5850. [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5851. 'de la Terre':
  5852. [0,0,0,0,0,0,0,0,2,0,0,0,0,5,30,0,0],
  5853. "de l'Orage":
  5854. [0,0,0,-1,2,0,0,0,0,0,0,0,0,0,0,0,0],
  5855. "de l'Ours":
  5856. [0,0,0,2,0,0,0,0,0,0,0,0,0,5,30,0,0],
  5857. 'des Béhémoths':
  5858. [0,0,0,0,0,0,3,0,0,0,0,0,0,0,30,0,0],
  5859. 'des Mages':
  5860. [0,0,0,0,0,0,0,0,0,5,5,5,5,0,0,0,0],
  5861. 'du Pic':
  5862. [0,0,0,0,-1,0,2,0,0,0,0,0,0,0,0,0,0],
  5863. 'du Sable':
  5864. [0,0,0,0,3,0,-1,-1,0,0,0,0,0,0,0,0,0],
  5865. 'acéré':
  5866. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5867. 'acérée':
  5868. [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5869. 'équilibré':
  5870. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5871. 'équilibrée':
  5872. [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  5873. 'léger':
  5874. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5875. 'légère':
  5876. [0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0],
  5877. 'renforcé':
  5878. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5879. 'renforcée':
  5880. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
  5881. 'robuste':
  5882. [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]
  5883. }
  5884.  
  5885. function clone(arr) {
  5886. // Clonage rapide
  5887. return arr.slice(0);
  5888. }
  5889.  
  5890. function addArray(arr1,arr2) {
  5891. // Somme matricielle
  5892. var res = clone(arr1);
  5893. for(i=res.length-1 ; i>=0 ; i--) {
  5894. res[i] += arr2[i];
  5895. }
  5896. return res;
  5897. }
  5898.  
  5899. function getTemplates(nomItem) {
  5900. // Déstructure le nom de l'item en array [nom, template1, ...]
  5901. var tempFound = true;
  5902. var str = nomItem.trim();
  5903. var arr = [];
  5904. while(tempFound) {
  5905. tempFound = false;
  5906. for(var temp in mh_templates) {
  5907. // on teste la fin du nom contre chaque template
  5908. if(str.slice(-temp.length)!=temp) { continue; }
  5909. tempFound = true;
  5910. str = str.slice(0,-temp.length-1);
  5911. arr.unshift(temp);
  5912. if(str.slice(-3)==' et') {
  5913. str = str.slice(0,-3);
  5914. }
  5915. }
  5916. }
  5917. arr.unshift(str);
  5918. return arr;
  5919. }
  5920.  
  5921. function addMithril(arrayCaracs,typeItem) {
  5922. // Ajoute l'effet du Mithril sur les caracs
  5923. if(typeItem=='arme') {
  5924. if(arrayCaracs[0]<0) {
  5925. arrayCaracs[0] = Math.ceil(arrayCaracs[0]/2);
  5926. }
  5927. }
  5928. else {
  5929. if(arrayCaracs[4]<0) {
  5930. arrayCaracs[4] = Math.ceil(arrayCaracs[4]/2);
  5931. }
  5932. }
  5933. arrayCaracs[15] /= 2;
  5934. arrayCaracs[16] /= 2;
  5935. return arrayCaracs;
  5936. }
  5937.  
  5938. function addRenfort(arrayCaracs,template) {
  5939. // Ajoute l'effet des pseudo-templates sur les caracs
  5940. // S'applique APRÈS le mithril
  5941. // WARNING - Cette formule n'a rien d'officiel, gare !
  5942. var coef = 0;
  5943. if(/^lég[e,è]re?$/.test(template)) {
  5944. coef = -1;
  5945. }
  5946. else if(/^renforcée?$/.test(template)
  5947. || template==='robuste') {
  5948. coef = 1;
  5949. }
  5950. if(coef) {
  5951. arrayCaracs[15] = arrayCaracs[15]+coef*Math.floor(arrayCaracs[15]/10);
  5952. arrayCaracs[16] = arrayCaracs[16]+coef*Math.floor(arrayCaracs[16]/10);
  5953. }
  5954. arrayCaracs = addArray(arrayCaracs,mh_templates[template]);
  5955. return arrayCaracs;
  5956. }
  5957.  
  5958. function getCaracs(item) {
  5959. // Calcule les caractéristiques de l'item
  5960. var templates = getTemplates(item);
  5961. if(!mh_caracs[templates[0]]) {
  5962. // Si l'item est inconnu
  5963. return [];
  5964. }
  5965. var caracs = clone(mh_caracs[templates[0]]);
  5966. var typeItem = caracs[0];
  5967. caracs.shift();
  5968. templates.shift();
  5969. if(templates[templates.length-1]=='en Mithril') {
  5970. caracs = addMithril(caracs,typeItem);
  5971. templates.pop();
  5972. }
  5973. if(/^acérée?$/.test(templates[0])
  5974. || /^équilibrée?$/.test(templates[0])
  5975. || /^lég[e,è]re?$/.test(templates[0])
  5976. || /^renforcée?$/.test(templates[0])
  5977. || templates[0]=='robuste') {
  5978. caracs = addRenfort(caracs,templates[0]);
  5979. templates.shift();
  5980. }
  5981. for(var i=templates.length-1 ; i>=0 ; i--) {
  5982. caracs = addArray(caracs,mh_templates[templates[i]]);
  5983. }
  5984. return caracs;
  5985. }
  5986.  
  5987. function getLine(tab) {
  5988. // Préparation de la ligne à afficher lors d'un mouseover
  5989. var str = '';
  5990. if(tab[0]!=0 || tab[1]!=0) {
  5991. str += '<b>Att : </b>'+aff(tab[0]);
  5992. if(tab[1]!=0) { str += '/'+aff(tab[1]); }
  5993. str += ' | ';
  5994. }
  5995. if(tab[4]!=0) {
  5996. str += '<b>Esq : </b>'+aff(tab[4])+' | ';
  5997. }
  5998. if(tab[2]!=0 || tab[3]!=0) {
  5999. str += '<b>Deg : </b>'+aff(tab[2]);
  6000. if(tab[3]!=0) { str += '/'+aff(tab[3]); }
  6001. str += ' | ';
  6002. }
  6003. if(tab[8]!=0) {
  6004. str += '<b>Reg : </b>'+aff(tab[8])+' | ';
  6005. }
  6006. if(tab[7]!=0) {
  6007. str += '<b>Vue : </b>'+aff(tab[7])+' | ';
  6008. }
  6009. if(tab[5]!=0 || tab[6]!=0) {
  6010. str += '<b>Arm : </b>'+aff(tab[5]);
  6011. if(tab[6]!=0) { str += '/'+aff(tab[6]); }
  6012. str += ' | ';
  6013. }
  6014. if(tab[9]!=0 || tab[10]!=0) {
  6015. str += '<b>RM : </b>'+aff(tab[9])+'%';
  6016. if(tab[9]!=tab[10]) {
  6017. str += '/'+aff(tab[10])+'%';
  6018. }
  6019. str += ' | ';
  6020. }
  6021. if(tab[11]!=0 || tab[12]!=0) {
  6022. str += '<b>MM : </b>'+aff(tab[11])+'%';
  6023. if(tab[11]!=tab[12]) { str += '/'+aff(tab[12])+'%'; }
  6024. str += ' | ';
  6025. }
  6026. if(tab[13]!=0) {
  6027. str += '<b>PV : </b>'+aff(tab[13])+' | ';
  6028. }
  6029. if(tab[14]!=0) {
  6030. str += '<b>DLA : </b>'+aff(tab[14])+' min | ';
  6031. }
  6032. str += '<b>Poids : </b>'+tab[15]+' min';
  6033. if(tab[15]!=tab[16]) {
  6034. str += ' / '+tab[16]+' min';
  6035. }
  6036. return str;
  6037. }
  6038.  
  6039. function toolTipInit() {
  6040. DivInfo = document.createElement('div');
  6041. DivInfo.id = 'infosVue';
  6042. DivInfo.className = 'mh_textbox';
  6043. DivInfo.style =
  6044. 'position: absolute;'
  6045. +'border: 1px solid #000000;'
  6046. +'visibility:hidden;'
  6047. +'display:inline;'
  6048. +'z-index:99;';
  6049. document.body.appendChild(DivInfo);
  6050. document.onmousemove = getXY;
  6051. document.onclick = changeFreezeStatus;
  6052. }
  6053.  
  6054. function getXY(evt) {
  6055. if(!freezed && DivInfo.style.visibility=='visible') {
  6056. DivInfo.style.left = evt.pageX+'px';
  6057. DivInfo.style.top = evt.pageY+10+'px';
  6058. }
  6059. }
  6060.  
  6061. function changeFreezeStatus() {
  6062. if(DivInfo.style.visibility=='visible') {
  6063. freezed = !freezed;
  6064. if(!freezed) { hideInfos(); }
  6065. }
  6066. }
  6067.  
  6068. function showInfos() {
  6069. if(freezed) { return; }
  6070. var currentInfos = this.infos;
  6071. DivInfo.innerHTML = currentInfos;
  6072. DivInfo.style.visibility = 'visible';
  6073. }
  6074.  
  6075. function hideInfos() {
  6076. if(!freezed) { DivInfo.style.visibility = 'hidden'; }
  6077. }
  6078.  
  6079. function treateEquipement() {
  6080. // Extrait les données du matos et réinjecte les infos déduites
  6081. if(MY_getValue('INFOCARAC')=='false') { return; }
  6082. var faireLigne = false;
  6083. var caracs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  6084. var nodes = document.evaluate(
  6085. "//td/b[text()='Equipement Utilisé']/../../"
  6086. +"td[2]/img[contains(@src,bullet)]",
  6087. document, null, 7, null);
  6088. if(nodes.snapshotLength>0) {
  6089. // Si CSS de base
  6090. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6091. var node = nodes.snapshotItem(i);
  6092. var next = node.nextSibling;
  6093. var nnext = next.nextSibling;
  6094. var nom = next.nodeValue.toLowerCase();
  6095. if(nnext.childNodes.length==1) {
  6096. nom += nnext.firstChild.nodeValue;
  6097. }
  6098. nom = nom.trim();
  6099. // gestion winpostrophe
  6100. var c = String.fromCharCode(180);
  6101. while(nom.indexOf(c)!=-1) {
  6102. nom = nom.replace(c,"'");
  6103. }
  6104. var arr = getCaracs(nom);
  6105. if(arr.length>0) {
  6106. faireLigne = true;
  6107. caracs = addArray(caracs,arr);
  6108. var span = document.createElement('span');
  6109. span.appendChild(next);
  6110. span.appendChild(nnext);
  6111. span.infos = getLine(arr);
  6112. span.onmouseover = showInfos;
  6113. span.onmouseout = hideInfos;
  6114. insertBefore(node.nextSibling,span);
  6115. }
  6116. }
  6117. if(faireLigne) {
  6118. var node = document.evaluate("//td/b[text()='Equipement Utilisé']",
  6119. document, null, 9, null).singleNodeValue;
  6120. node.infos = getLine(caracs);
  6121. node.onmouseover = showInfos;
  6122. node.onmouseout = hideInfos;
  6123. }
  6124. }
  6125. else {
  6126. // Si CSS avancée
  6127. nodes = document.evaluate("//dd[@class='equipement']/ul/li",
  6128. document, null, 7, null);
  6129. if(nodes.snapshotLength>0) {
  6130. for(var i=0 ; i<nodes.snapshotLength ; i++) {
  6131. var node = nodes.snapshotItem(i);
  6132. var nom = node.firstChild.nodeValue.toLowerCase();
  6133. if(node.childNodes.length>1) {
  6134. nom += node.childNodes[1].firstChild.nodeValue;
  6135. }
  6136. nom = nom.trim();
  6137. // gestion winpostrophe
  6138. var c = String.fromCharCode(180);
  6139. while(nom.indexOf(c)!=-1) {
  6140. nom = nom.replace(c,"'");
  6141. }
  6142. var arr = getCaracs(nom);
  6143. if(arr.length!=0) {
  6144. caracs = addArray(caracs,arr);
  6145. node.infos = getLine(arr);
  6146. node.onmouseover = showInfos;
  6147. node.onmouseout = hideInfos;
  6148. }
  6149. }
  6150. var nodes = document.evaluate("//dt[@class='equipement']",
  6151. document, null, 7, null);
  6152. var node = nodes.snapshotItem(0);
  6153. node.infos = getLine(caracs);
  6154. node.onmouseover = showInfos;
  6155. node.onmouseout = hideInfos;
  6156. }
  6157. }
  6158. }
  6159.  
  6160. function do_pjview() {
  6161. treateEquipement();
  6162. toolTipInit();
  6163. }
  6164.  
  6165. /*******************************************************************************
  6166. * This file is part of Mountyzilla. *
  6167. * *
  6168. * Mountyzilla is free software; you can redistribute it and/or modify *
  6169. * it under the terms of the GNU General Public License as published by *
  6170. * the Free Software Foundation; either version 2 of the License, or *
  6171. * (at your option) any later version. *
  6172. * *
  6173. * Mountyzilla is distributed in the hope that it will be useful, *
  6174. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6175. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6176. * GNU General Public License for more details. *
  6177. * *
  6178. * You should have received a copy of the GNU General Public License *
  6179. * along with Mountyzilla; if not, write to the Free Software *
  6180. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6181. *******************************************************************************/
  6182.  
  6183. // x~x option
  6184.  
  6185. /* TODO
  6186. * Passer le HTML injecté aux conventions HTML5
  6187. */
  6188.  
  6189.  
  6190. /*-[functions]------------- Fonctions de sauvegarde --------------------------*/
  6191.  
  6192. function saveITData() {
  6193. var IT = document.getElementById('itSelect').value;
  6194. if(IT=='bricol') {
  6195. var system = document.getElementById('urlbricol').value;
  6196. var login = document.getElementById('loginbricol').value;
  6197. var pass = document.getElementById('passbricol').value;
  6198. var affhv = document.getElementById('affhvbricol').checked ? 1 : 0;
  6199. if(system && login) {
  6200. if (pass) {
  6201. var v = 'bricol$'+system+'$'+login+'$'+hex_md5(pass)+'$'+affhv;
  6202. MY_setValue(numTroll+'.INFOSIT', v);
  6203. //window.console.log('v=' + v);
  6204. } else {
  6205. // vérif que rien n'a changé
  6206. var str = MY_getValue(numTroll+'.INFOSIT');
  6207. if(str) {
  6208. var arr = str.split('$');
  6209. if (system != arr[1] || login != arr[2] || affhv != arr[4]) {
  6210. alert('Attention, système tactique Bricol\'Trolls sans mot de passe => non modifié');
  6211. }
  6212. }
  6213. }
  6214. }
  6215. }
  6216. else {
  6217. MY_removeValue(numTroll+'.INFOSIT');
  6218. }
  6219. }
  6220.  
  6221. function saveLinks() {
  6222. var numLinks = document.getElementById('linksBody').childNodes.length;
  6223. var data=[ [] ];
  6224. /* Récupération et tri des liens */
  6225. for(var i=1 ; i<=numLinks ; i++) {
  6226. MY_removeValue('URL'+i);
  6227. MY_removeValue('URL'+i+'.nom');
  6228. MY_removeValue('URL'+i+'.ico');
  6229. var url = document.getElementById('url'+i).value;
  6230. var nom = document.getElementById('nom'+i).value;
  6231. var ico = document.getElementById('ico'+i).value;
  6232. if(url && (nom || ico) ) {
  6233. data.push( [url, nom ? nom : '', ico ? ico : ''] );
  6234. }
  6235. }
  6236. /* Sauvegarde */
  6237. for(var i=1 ; i<data.length ; i++) {
  6238. MY_setValue('URL'+i,data[i][0]);
  6239. MY_setValue('URL'+i+'.nom',data[i][1]);
  6240. MY_setValue('URL'+i+'.ico',data[i][2]);
  6241. }
  6242. }
  6243.  
  6244. function saveAll() {
  6245. var urlIco = document.getElementById('icoMenuIco').value;
  6246. if(urlIco) {
  6247. MY_setValue(numTroll+'.ICOMENU', urlIco );
  6248. }
  6249. else {
  6250. MY_removeValue(numTroll+'.ICOMENU', urlIco );
  6251. document.getElementById('icoMenuIco').value = '';
  6252. }
  6253. saveLinks();
  6254. refreshLinks();
  6255. MY_setValue('VUEEXT',document.getElementById('vueext').value);
  6256. var maxcdm = parseInt(document.getElementById('maxcdm').value);
  6257. if(maxcdm) {
  6258. MY_setValue(numTroll+'.MAXCDM', maxcdm );
  6259. }
  6260. else {
  6261. MY_removeValue(numTroll+'.MAXCDM');
  6262. document.getElementById('maxcdm').value = '';
  6263. }
  6264.  
  6265. MY_setValue('NOINFOEM',
  6266. document.getElementById('noInfoEM').checked ? 'true' : 'false');
  6267. // Pourquoi Tilk stockait-il tout en str ?
  6268. // -> parce que les booléens c'est foireux (vérifié)
  6269. MY_setValue(numTroll+'.USECSS',
  6270. document.getElementById('usecss').checked ? 'true':'false');
  6271. MY_setValue('INFOCARAC',
  6272. document.getElementById('infocarac').checked ? 'true' : 'false');
  6273. //MY_setValue(numTroll+'.SEND_IDT',
  6274. // document.getElementById('send_idt').checked ? 'oui' : 'non');
  6275. // Fonctionnalité désactivée
  6276.  
  6277. MY_setValue(numTroll+'.AUTOCDM',
  6278. document.getElementById('autoCdM').checked ? 'true' : 'false');
  6279. MY_setValue('VUECARAC',
  6280. document.getElementById('vueCarac').checked ? 'true' : 'false');
  6281. MY_setValue('CONFIRMEDECALAGE',
  6282. document.getElementById('confirmeDecalage').checked ? 'true' : 'false');
  6283.  
  6284. saveITData();
  6285. var bouton = document.getElementById('saveAll');
  6286. bouton.value = (bouton.value=='Sauvegardé !') ?
  6287. 'Re-sauvegardé !' : 'Sauvegardé !';
  6288. }
  6289.  
  6290.  
  6291. /*-[functions]----------------- EventListeners -------------------------------*/
  6292.  
  6293. function onChangeIT() {
  6294. var IT = document.getElementById('itSelect').value;
  6295. var itBody = document.getElementById('itBody');
  6296. itBody.innerHTML = '';
  6297. if(IT=='bricol') {
  6298. var tr = appendTr(itBody,'mh_tdpage')
  6299. var td = appendTd(tr);
  6300. var str = MY_getValue(numTroll+'.INFOSIT');
  6301. //window.console.log('onChangeIT str=' + str);
  6302. if(str) {
  6303. var arr = str.split('$');
  6304. var system = arr[1];
  6305. var login = arr[2];
  6306. var affhv = arr[4];
  6307. }
  6308. appendText(td,'Nom du système : ');
  6309. appendTextbox(td,'text','urlbricol',20,50,system);
  6310. td = appendTd(tr);
  6311. appendText(td,'Login du compte : ');
  6312. appendTextbox(td,'text','loginbricol',20,50,login);
  6313. td = appendTd(tr);
  6314. appendText(td,'Mot de passe du compte : ');
  6315. appendTextbox(td,'password','passbricol',20,50);
  6316. td = appendTd(tr);
  6317. appendText(td,'Affichage des Trõlls hors vue : ');
  6318. //window.console.log('onChangeIT affhv=' + affhv + ', bool=' + (affhv>0));
  6319. appendCheckBox(td,'affhvbricol', (affhv>0));
  6320. }
  6321. }
  6322.  
  6323. function refreshLinks() {
  6324. document.getElementById('linksBody').innerHTML = '';
  6325. var anotherURL = MY_getValue('URL1');
  6326. if(!anotherURL) { addLinkField(); }
  6327. var i=1;
  6328. while(anotherURL && i<99) {
  6329. addLinkField(i,anotherURL,
  6330. MY_getValue('URL'+i+'.nom'),MY_getValue('URL'+i+'.ico') );
  6331. i++;
  6332. anotherURL = MY_getValue('URL'+i);
  6333. }
  6334. }
  6335.  
  6336. function addLinkField(i,url,nom,ico) {
  6337. var linksBody = document.getElementById('linksBody');
  6338. if(!(i>0)) { i = linksBody.childNodes.length+1; }
  6339. var tr = appendTr(linksBody);
  6340. var td = appendTdCenter(tr);
  6341. appendText(td,'Lien '+i+' : ');
  6342. appendTextbox(td,'text','url'+i,40,150,url);
  6343. td = appendTdCenter(tr);
  6344. appendText(td,'Nom : ');
  6345. appendTextbox(td,'text','nom'+i,20,150,nom);
  6346. td = appendTdCenter(tr);
  6347. appendText(td,'Icône : ');
  6348. appendTextbox(td,'text','ico'+i,40,150,ico);
  6349. }
  6350.  
  6351. function removeLinkField() {
  6352. var linksBody = document.getElementById('linksBody');
  6353. var i = linksBody.childNodes.length;
  6354. MY_removeValue('URL'+i);
  6355. MY_removeValue('URL'+i+'.nom');
  6356. MY_removeValue('URL'+i+'.ico');
  6357. linksBody.removeChild(linksBody.lastChild);
  6358. if(linksBody.childNodes.length==0) { addLinkField(); }
  6359. }
  6360.  
  6361. function resetMainIco() {
  6362. document.getElementById('icoMenuIco').value=
  6363. URL_MZimg + 'mz_logo_small.png';
  6364. }
  6365.  
  6366.  
  6367. /*-[functions]-------------- Fonctions d'insertion ---------------------------*/
  6368.  
  6369. function insertTitle(next,txt) {
  6370. var div = document.createElement('div');
  6371. div.className = 'titre2';
  6372. appendText(div,txt);
  6373. insertBefore(next,div);
  6374. return div;
  6375. }
  6376.  
  6377. function insertMainTable(next) {
  6378. var table = document.createElement('table');
  6379. table.width = '98%';
  6380. table.border = 0;
  6381. table.align = 'center';
  6382. table.cellPadding = 2;
  6383. table.cellSpacing = 1;
  6384. table.className = 'mh_tdborder';
  6385. var tbody = document.createElement('tbody');
  6386. table.appendChild(tbody);
  6387. insertBefore(next,table);
  6388. return tbody;
  6389. }
  6390.  
  6391. function appendSubTable(node) {
  6392. var table = document.createElement('table');
  6393. table.width = '100%';
  6394. var tbody = document.createElement('tbody');
  6395. table.appendChild(tbody);
  6396. node.appendChild(table);
  6397. return tbody;
  6398. }
  6399.  
  6400. function insertOptionTable(insertPt) {
  6401. var mainBody = insertMainTable(insertPt);
  6402. /* Liens dans le Menu */
  6403. var tr = appendTr(mainBody,'mh_tdtitre');
  6404. var td = appendTdText(tr,'Hyperliens ajoutés dans le Menu :',true);
  6405. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6406. appendText(td,'Icône du Menu: ');
  6407. var url = MY_getValue(numTroll+'.ICOMENU');
  6408. if((!url) || (url.indexOf('mountyzilla.tilk.info/scripts_0.9/images/MY_logo_small')>0)) {
  6409. url = URL_MZimg + 'mz_logo_small.png';
  6410. }
  6411. appendTextbox(td,'text','icoMenuIco',50,200,url);
  6412. appendButton(td,'Réinitialiser',resetMainIco);
  6413. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6414. var tbody = appendSubTable(td);
  6415. tbody.id = 'linksBody';
  6416. refreshLinks();
  6417. td = appendTdCenter(appendTr(mainBody,'mh_tdpage'));
  6418. appendButton(td,'Ajouter',addLinkField);
  6419. appendButton(td,'Supprimer',removeLinkField);
  6420. /* Options de la Vue : vue externe, nb de CdM, etc */
  6421. tr = appendTr(mainBody,'mh_tdtitre');
  6422. appendTdText(tr,'Options de la Vue :',true);
  6423. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6424. tbody = appendSubTable(td);
  6425. tr = appendTr(tbody);
  6426. td = appendTdText(tr,'Vue externe : ');
  6427. var select = document.createElement('select');
  6428. select.id = 'vueext';
  6429. td.appendChild(select);
  6430. var listeVues2D = [
  6431. 'Bricol\' Vue',
  6432. 'Vue du CCM',
  6433. 'Vue Gloumfs 2D',
  6434. 'Vue Gloumfs 3D',
  6435. 'Grouky Vue!'
  6436. ];
  6437. for(var i=0 ; i<listeVues2D.length ; i++) {
  6438. appendOption(select,listeVues2D[i],listeVues2D[i]);
  6439. }
  6440. if(MY_getValue('VUEEXT')) {
  6441. select.value = MY_getValue('VUEEXT');
  6442. }
  6443. td = appendTd(tr);
  6444. appendCheckBox(td,'noInfoEM',MY_getValue('NOINFOEM')=='true');
  6445. appendText(td,' Masquer les informations à propos de l\'écriture magique');
  6446. tr = appendTr(tbody);
  6447. td = appendTdText(tr,'Nombre de CdM automatiquement récupérées : ');
  6448. appendTextbox(td,'text','maxcdm',5,10,MY_getValue(numTroll+'.MAXCDM'));
  6449. td = appendTd(tr);
  6450. appendCheckBox(td,'usecss',MY_getValue(numTroll+'.USECSS')=='true');
  6451. appendText(td,' Utiliser la CSS pour les couleurs de la diplomatie');
  6452. /* Interface Tactique */
  6453. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6454. appendText(td,'Interface Tactique : ',true);
  6455. select = document.createElement('select');
  6456. select.id = 'itSelect';
  6457. appendOption(select,'none','Aucune');
  6458. appendOption(select,'bricol','Système Tactique des Bricol\'Trolls');
  6459. // seule interface supportée !
  6460. td.appendChild(select);
  6461. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6462. tbody = appendSubTable(td);
  6463. tbody.id = 'itBody';
  6464. select.onchange = onChangeIT;
  6465. var str = MY_getValue(numTroll+'.INFOSIT');
  6466. if(str) {
  6467. select.value = str.slice(0,str.indexOf('$'));
  6468. onChangeIT();
  6469. }
  6470. /* Options diverses */
  6471. td = appendTd(appendTr(mainBody,'mh_tdtitre'));
  6472. appendText(td,'Options diverses :',true);
  6473. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6474. appendCheckBox(td,'infocarac',MY_getValue('INFOCARAC')!='false');
  6475. appendText(td,
  6476. ' Afficher les caractéristiques des équipements des autres Trõlls');
  6477. /*td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6478. appendCheckBox(td,'send_idt',MY_getValue(numTroll+'.SEND_IDT') != 'non')
  6479. appendText(td,' Envoyer les objets identifiés au système de stats');*/
  6480. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6481. appendCheckBox(td,'autoCdM',MY_getValue(numTroll+'.AUTOCDM')=='true');
  6482. appendText(td,' Envoyer automatiquement les CdM vers la base MountyZilla');
  6483. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6484. appendCheckBox(td,'vueCarac',MY_getValue('VUECARAC')=='true');
  6485. appendText(td,' Afficher la Vue avec les caractéristique dans le Profil');
  6486. td = appendTd(appendTr(mainBody,'mh_tdpage'));
  6487. appendCheckBox(td,'confirmeDecalage',MY_getValue('CONFIRMEDECALAGE')=='true');
  6488. appendText(td,' Demander confirmation lors d\'un décalage de DLA');
  6489. /* Bouton SaveAll */
  6490. td = appendTdCenter(appendTr(mainBody,'mh_tdtitre'));
  6491. input = appendButton(td,'Sauvegarder',saveAll);
  6492. input.id = 'saveAll';
  6493. }
  6494.  
  6495. function insertCreditsTable(insertPt) {
  6496. var tbody = insertMainTable(insertPt);
  6497. var td = appendTdText( appendTr(tbody,'mh_tdtitre'),
  6498. 'Depuis son origine, nombreux sont ceux qui ont contribué à faire '
  6499. +'de MountyZilla ce qu\'il est aujourd\'hui. Merci à eux !' );
  6500.  
  6501. var ul = document.createElement('ul');
  6502. td.appendChild(ul);
  6503. appendLI(ul,'Tilk (36216), puis Dabihul (79738) pour avoir créé puis maintenu à bout de bras MZ pendant des années');
  6504. appendLI(ul,'Fine fille (6465) pour les popup javascript');
  6505. appendLI(ul,'Reivax (4234) pour les infos bulles');
  6506. appendLI(ul,'Noc (2770) pour les moyennes des caracs');
  6507. appendLI(ul,'Endymion (12820) pour les infos sur les comp/sorts');
  6508. appendLI(ul,'Ratibus (15916) pour l\'envoi de CdM');
  6509. appendLI(ul,'TetDure (41931) pour les PVs restants dans les CdM');
  6510. appendLI(ul,'Les Teubreux pour leur bestiaire !');
  6511. appendLI(ul,'Les développeurs de vue qui font des efforts pour s\'intégrer à Mountyzilla');
  6512. appendLI(ul,'Gros Kéké (233) qui permet de tester le script aux limites du raisonnable avec sa vue de barbare');
  6513. appendLI(ul,'Ashitaka (9485) pour le gros nettoyage de l\'extension, des scripts, et beaucoup de choses à venir');
  6514. appendLI(ul,'Tous ceux de l\'ancienne génération oubliés par Tilk');
  6515. appendLI(ul,'Zorya (28468), Vapulabehemot (82169), Breizhou13 (50233) et tous les participants au projet ZoryaZilla');
  6516. appendLI(ul,'Yoyor (87818) pour diverses améliorations de code');
  6517. appendLI(ul,'Rokü Menton-brûlant (108387) pour avoir incité à passer sur GitHub');
  6518. appendLI(ul,'Marmotte (93138) pour son support technique récurrent');
  6519. appendLI(ul,'Hennet (74092) pour le script du nouveau profil');
  6520. appendLI(ul,'Raistlin (61214, 109327) pour le script sur les caracs de l\'équipement et maintenant pour l\'hébergement');
  6521. appendLI(ul,'Markotroll (27637) pour les tests sous LINUX');
  6522. appendLI(ul,'Tous les testeurs de la nouvelle génération oubliés par Dabihul puis Rouletabille');
  6523. }
  6524.  
  6525.  
  6526. /* [functions] Obsolètes */
  6527. function deleteEnchantement()
  6528. {
  6529. try
  6530. {
  6531. var idEquipement = this.getAttribute('name');
  6532. MY_removeValue(numTroll+".enchantement."+idEquipement+".objet");
  6533. MY_removeValue(numTroll+".enchantement."+idEquipement+".enchanteur");
  6534. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.0");
  6535. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.1");
  6536. MY_removeValue(numTroll+".enchantement."+idEquipement+".composant.2");
  6537. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6538. var string = "";
  6539. for(var i=0;i<listeEquipement.length;i++)
  6540. {
  6541. if(listeEquipement[i]!=idEquipement)
  6542. if(string=="")
  6543. string = listeEquipement[i];
  6544. else
  6545. string += ";"+listeEquipement[i];
  6546. }
  6547. if(string=="")
  6548. {
  6549. MY_removeValue(numTroll+".enchantement.liste");
  6550. var table = this.parentNode.parentNode.parentNode.parentNode;
  6551. var parent = table.parentNode;
  6552. for(var i=0;i<parent.childNodes.length;i++)
  6553. {
  6554. if(parent.childNodes[i]==table)
  6555. {
  6556. parent.removeChild(parent.childNodes[i-1]);
  6557. parent.removeChild(parent.childNodes[i-1]);
  6558. parent.removeChild(parent.childNodes[i-1]);
  6559. break;
  6560. }
  6561. }
  6562. }
  6563. else
  6564. {
  6565. MY_getValue(numTroll+".enchantement.liste",string);
  6566. this.parentNode.parentNode.parentNode
  6567. .removeChild(this.parentNode.parentNode);
  6568. }
  6569. }
  6570. catch(e)
  6571. {
  6572. window.alert(e);
  6573. }
  6574. }
  6575. /* [functions] fin Obsolètes */
  6576.  
  6577. /*-[functions]---------------- Partie principale -----------------------------*/
  6578.  
  6579. function do_option() {
  6580. start_script(712);
  6581. var insertPoint = document.getElementById('footer1');
  6582. insertBefore(insertPoint,document.createElement('p'));
  6583. var ti = insertTitle(insertPoint,'Mountyzilla : Options'); // 02/02/2017 SHIFT-Click pour copier la conf
  6584. ti.onclick = function (e) {
  6585. var evt = e || window.event;
  6586. if (!evt.shiftKey) return;
  6587. var txt = '';
  6588. for ( var i = 0, len = localStorage.length; i < len; ++i ) {
  6589. var k = localStorage.key(i);
  6590. if (k.match(/INFOSIT$/i)) continue; // masquer le mdp Bricol'Troll
  6591. txt += k + "\t" + localStorage.getItem(k) + "\n";
  6592. }
  6593. copyTextToClipboard(txt);
  6594. window.alert('La configuration MZ a été copiée dans le presse-papier (sauf le mot de passe Bricol\'Trõll)');
  6595. }
  6596. ti.title = 'Version ' + GM_info.script.version;
  6597. insertOptionTable(insertPoint);
  6598. /* insertion enchantements ici
  6599. if(...)
  6600. insertEnchantementTable();
  6601. */
  6602. insertBefore(insertPoint,document.createElement('p'));
  6603. var ti = insertTitle(insertPoint,'Mountyzilla : Crédits'); // 23/12/2016 SHIFT-Click pour passer en mode dev
  6604. ti.onclick = function (e) {
  6605. var evt = e || window.event;
  6606. if (!evt.shiftKey) return;
  6607. var oldDev = MY_getValue('MZ_dev');
  6608. if (oldDev) {
  6609. MY_removeValue('MZ_dev');
  6610. } else {
  6611. alert('passage en mode DEV, shift-click sur le mot "Crédits" pour revenir en mode normal');
  6612. MY_setValue('MZ_dev', 1);
  6613. }
  6614. document.location.href = document.location.href;
  6615. }
  6616. insertCreditsTable(insertPoint);
  6617. insertBefore(insertPoint,document.createElement('p'));
  6618.  
  6619. /* [zone] Obsolète ?? */
  6620. if(MY_getValue(numTroll+".enchantement.liste")
  6621. && MY_getValue(numTroll+".enchantement.liste")!="" )
  6622. {
  6623. insertTitle(insertPoint, 'Les Enchantements en cours');
  6624. table = document.createElement('table');
  6625. table.setAttribute('width', '98%');
  6626. table.setAttribute('border', '0');
  6627. table.setAttribute('align', 'center');
  6628. table.setAttribute('cellpadding', '2');
  6629. table.setAttribute('cellspacing', '1');
  6630. table.setAttribute('class', 'mh_tdborder');
  6631.  
  6632. tbody = document.createElement('tbody');
  6633. table.appendChild(tbody);
  6634. tr = appendTr(tbody, 'mh_tdtitre');
  6635. appendTdText(tr, 'Equipement',1);
  6636. appendTdText(tr, 'Composants',1);
  6637. appendTdText(tr, 'Enchanteur',1);
  6638. appendTdText(tr, 'Action',1);
  6639. var listeEquipement = MY_getValue(numTroll+".enchantement.liste").split(";");
  6640. for(var i=0;i<listeEquipement.length;i++)
  6641. {
  6642. try
  6643. {
  6644. var idEquipement = listeEquipement[i];
  6645. var nomEquipement = MY_getValue(numTroll+".enchantement."
  6646. +idEquipement+".objet");
  6647. var infoEnchanteur = MY_getValue(numTroll+".enchantement."
  6648. +idEquipement+".enchanteur").split(";");
  6649. var ul = document.createElement('UL');
  6650. for(var j=0;j<3;j++)
  6651. {
  6652. var infoComposant = MY_getValue(numTroll+".enchantement."
  6653. +idEquipement+".composant."+j).split(";");
  6654. var texte = infoComposant[4].replace("Ril ","Œil ");
  6655. for(var k=5;k<infoComposant.length;k++)
  6656. {
  6657. texte += ";"+infoComposant[k].replace("Ril ","Œil ");
  6658. }
  6659. li = appendLI(ul,texte);
  6660. var string = '<form action="' + URL_troc_mh + '" method="post" TARGET = "_blank">';
  6661. string+= '<input type="hidden" name="monster" value="'+infoComposant[2]+'" />';
  6662. string+= '<input type="hidden" name="part" value="'+infoComposant[0]+'" />';
  6663. string+= '<input type="hidden" name="qualite" value="'+(getQualite(infoComposant[3])+1)+'" />';
  6664. string+= '<input type="hidden" name="q" value="min" />';
  6665. string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Rechercher sur le Troc de l\'Hydre" />';
  6666. 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>';
  6667.  
  6668. string+= '</form>';
  6669. // string += '<form action="http://www.cyclotrolls.be/wakka.php" method="get" TARGET = "_blank">';
  6670. // string+= '<input type="hidden" name="wiki" value="TroOGle" />';
  6671. // string+= '<input type="hidden" name="trooglephr" value="base:monstres tag:nom &quot;'+infoComposant[2]+'&quot;" />';
  6672. // string+= '<input type="submit" class="mh_form_submit" onMouseOver="this.style.cursor=\'hand\';" name="enter" value="Localiser grâce à Troogle" /></form>';
  6673. li.innerHTML += string;
  6674. }
  6675. tr = appendTr(tbody, 'mh_tdpage');
  6676. td = appendTdText(tr, nomEquipement);
  6677. td.setAttribute('valign', 'center');
  6678. td = document.createElement('td');
  6679. td.appendChild(ul);
  6680. tr.appendChild(td);
  6681. td.setAttribute('valign', 'center');
  6682. td = appendTdText(tr, "Enchanteur n°"+infoEnchanteur[0]+" ("+infoEnchanteur[1]+"|"+infoEnchanteur[2]+"|"+infoEnchanteur[3]+")");
  6683. td.setAttribute('valign', 'center');
  6684. td = document.createElement('td');
  6685. input = appendButton(td, 'Supprimer l\'enchantement', deleteEnchantement);
  6686. input.setAttribute('name', idEquipement);
  6687. tr.appendChild(td);
  6688. td.setAttribute('valign', 'center');
  6689. }
  6690. catch(e)
  6691. {
  6692. }
  6693. }
  6694. insertBefore(insertPoint, table);
  6695. insertBefore(insertPoint, document.createElement('p'));
  6696. }
  6697. /* [zone] fin Obsolète ?? */
  6698.  
  6699.  
  6700. displayScriptTime();
  6701. }
  6702.  
  6703. /*******************************************************************************
  6704. * This file is part of Mountyzilla. *
  6705. * *
  6706. * Mountyzilla is free software; you can redistribute it and/or modify *
  6707. * it under the terms of the GNU General Public License as published by *
  6708. * the Free Software Foundation; either version 2 of the License, or *
  6709. * (at your option) any later version. *
  6710. * *
  6711. * Mountyzilla is distributed in the hope that it will be useful, *
  6712. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6713. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6714. * GNU General Public License for more details. *
  6715. * *
  6716. * You should have received a copy of the GNU General Public License *
  6717. * along with Mountyzilla; if not, write to the Free Software *
  6718. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6719. *******************************************************************************/
  6720.  
  6721. // x~x equip
  6722.  
  6723. /**
  6724. * 2014-02-08 - v2.0a (from scratch)
  6725. * 2014-02-18 - v2.0a0
  6726. * - ajout calcul Carats / UM des minerais + totaux
  6727. * 2014-03-06 - v2.0a1
  6728. * - retour Infos EM des Champis
  6729. * TODO
  6730. * Ces fonctions sont dev ici en test, à terme elles seront à intégrer dans libs
  6731. */
  6732.  
  6733. function traiteChampis() {
  6734. try{
  6735. var tr = document.getElementById('mh_objet_hidden_Champignon');
  6736. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6737. }
  6738. catch(e){return;}
  6739. if(trlist.length<=0) return;
  6740. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6741. var node = trlist.snapshotItem(i).childNodes[7];
  6742. var str = node.textContent.trim();
  6743. var type = str.slice(0,str.lastIndexOf(' '));
  6744. var mundi = mundiChampi[type];
  6745. if(!mundi) continue;
  6746. var urlImg = URL_MZimg
  6747. +'Competences/ecritureMagique.png';
  6748. var img = createAltImage(urlImg,'EM','Mundidey '+mundi);
  6749. appendText(node,' ');
  6750. node.appendChild(img);
  6751. }
  6752. }
  6753.  
  6754. function traiteCompos() {
  6755. try {
  6756. var tr = document.getElementById('mh_objet_hidden_Composant');
  6757. var tbody = document.evaluate("./td/table/tbody",
  6758. tr, null, 9, null).singleNodeValue;
  6759. }
  6760. catch(e) {return;}
  6761. insererInfosEM(tbody);
  6762. }
  6763.  
  6764. function traiteMinerai() {
  6765. try{
  6766. var tr = document.getElementById('mh_objet_hidden_Minerai');
  6767. var trlist = document.evaluate('./td/table/tbody/tr', tr, null, 7, null);
  6768. }
  6769. catch(e){return;}
  6770. if(trlist.length<=0) return;
  6771. var totaux = {};
  6772. var str;
  6773. for(var i=0 ; i<trlist.snapshotLength ; i++) {
  6774. var node = trlist.snapshotItem(i);
  6775. var nature = node.childNodes[7].textContent,
  6776. caracs = node.childNodes[9].textContent;
  6777. var taille = Number(caracs.match(/\d+/)[0]);
  6778. var coef = 1;
  6779. if(caracs.indexOf('Moyen')!=-1) coef = 2;
  6780. else if(caracs.indexOf('Normale')!=-1) coef = 3;
  6781. else if(caracs.indexOf('Bonne')!=-1) coef = 4;
  6782. else if(caracs.indexOf('Exceptionnelle')!=-1) coef = 5;
  6783. if(nature.indexOf('Mithril')!=-1) {
  6784. coef = 0.2*coef;
  6785. str = ' | UM: ';
  6786. }
  6787. else {
  6788. coef = 0.75*coef+1.25;
  6789. if(nature.indexOf('Taill')!=-1) coef = 1.15*coef;
  6790. str = ' | Carats: ';
  6791. }
  6792. var carats = Math.round(taille*coef)
  6793. appendText(node.childNodes[9], str+carats );
  6794. if(!totaux[nature]) {
  6795. totaux[nature] = [taille,carats];
  6796. }
  6797. else {
  6798. totaux[nature][0] += taille;
  6799. totaux[nature][1] += carats;
  6800. }
  6801. }
  6802. str = 'Total : ';
  6803. for(var nature in totaux) {
  6804. if(str.length>8) str += ', ';
  6805. if(nature.indexOf('Mithril')!=-1) {
  6806. str += nature+totaux[nature][1]+' UM';
  6807. }
  6808. else {
  6809. str += nature+totaux[nature][0]+'U/'
  6810. +totaux[nature][1]+'c';
  6811. }
  6812. }
  6813. /*var node = document.getElementById('mh_plus_Minerai');
  6814. var titre = document.evaluate("./td[contains(./b/text(),'Minerai')]",
  6815. node.parentNode.parentNode.parentNode, null, 9, null).singleNodeValue;
  6816. if(!titre) return;*/
  6817. // Il faut préalablement injecter du CSS pour ne pas hériter de 'mh_titre3'
  6818. var td = appendTdText(trlist.snapshotItem(0).parentNode, '('+str+')');
  6819. td.colSpan = 7;
  6820. }
  6821.  
  6822. function do_equip() {
  6823. start_script();
  6824.  
  6825. traiteChampis();
  6826. traiteCompos();
  6827. traiteMinerai();
  6828.  
  6829. displayScriptTime();
  6830. }
  6831.  
  6832. /*******************************************************************************
  6833. * This file is part of Mountyzilla. *
  6834. * *
  6835. * Mountyzilla is free software; you can redistribute it and/or modify *
  6836. * it under the terms of the GNU General Public License as published by *
  6837. * the Free Software Foundation; either version 2 of the License, or *
  6838. * (at your option) any later version. *
  6839. * *
  6840. * Mountyzilla is distributed in the hope that it will be useful, *
  6841. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  6842. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  6843. * GNU General Public License for more details. *
  6844. * *
  6845. * You should have received a copy of the GNU General Public License *
  6846. * along with Mountyzilla; if not, write to the Free Software *
  6847. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  6848. *******************************************************************************/
  6849.  
  6850. // x~x diplo
  6851.  
  6852. /*
  6853. TODO:
  6854. V Étape 1: Gestion comme actuellement, avec 2 couleurs (amis/ennemis)
  6855. V Étape 2: Gestion couleurs par catégorie (10 couleurs)
  6856. V Étape 3: Ajout de la diplo perso
  6857. X Étape 4: Gestion distante (sécurisée par mdp) de cette option
  6858. V Étape 5: Ajout des fioritures (preview de la couleur...)
  6859. Options Globales:
  6860. Actuelles:
  6861. numTroll.USECSS,
  6862. numTroll.NODIPLO
  6863. NOMYTH
  6864. Nouvelles:
  6865. TODO numTroll.USECSS
  6866. numTroll.diplo.off (remplace NODIPLO)
  6867. numTroll.diplo.guilde
  6868. numTroll.diplo.perso
  6869. Structure de diplo.guilde:
  6870. isOn: 'true' ou 'false'
  6871. isDetailOn: 'true' ou 'false'
  6872. guilde
  6873. > id
  6874. > couleur
  6875. AllAmis,AllEnnemis: couleur
  6876. Amis0,...,Ennemis5
  6877. > Troll: idTroll1;...;
  6878. > Guilde: idGuilde1;...;
  6879. > titre
  6880. > couleur
  6881. Structure de diplo.perso:
  6882. isOn: 'true' ou 'false'
  6883. mythiques: couleur
  6884. Troll,Guilde,Monstre:
  6885. > id
  6886. > couleur
  6887. > description
  6888. */
  6889.  
  6890. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  6891.  
  6892. function couleurAleatoire() {
  6893. var alph = '0123456789ABCDEF'.split('');
  6894. var clr = '#';
  6895. for (var i=0; i<6; i++) {
  6896. clr+=alph[ Math.floor(16*Math.random()) ];
  6897. }
  6898. return clr;
  6899. }
  6900.  
  6901. function isCouleur(str) {
  6902. return /^#[0-9A-F]{6}$/i.test(str);
  6903. }
  6904.  
  6905. /*-[functions]---------------- Analyse de la page ----------------------------*/
  6906.  
  6907. function appendChoixCouleur(node,id) {
  6908. var span = document.createElement('span');
  6909. span.id = 'span'+id;
  6910. if(isDetailOn) {
  6911. span.style.display = 'none';
  6912. }
  6913. var couleur = id=='AllAmis'?'#AAFFAA':'#FFAAAA';
  6914. if(diploGuilde[id]) {
  6915. couleur = diploGuilde[id];
  6916. }
  6917. appendText(span,' - Couleur HTML: ');
  6918. var input = appendTextbox(span,'text',id,7,7,couleur);
  6919. input.onkeyup = previewCouleur;
  6920. input.onchange = previewCouleur;
  6921. input.onkeyup();
  6922. node.appendChild(span);
  6923. }
  6924.  
  6925. function insertChoixCouleur(node,id) {
  6926. var span = document.createElement('span');
  6927. span.id = 'span'+id;
  6928. // La couleur détaillée passera à une valeur aléatoire
  6929. // si toggle vers isDetailOn
  6930. var couleur = couleurAleatoire();
  6931. if(!isDetailOn) {
  6932. span.style.display = 'none';
  6933. } else if(diploGuilde[id]) {
  6934. couleur = diploGuilde[id].couleur;
  6935. }
  6936. appendText(span,' - Couleur HTML: ');
  6937. var input = appendTextbox(span,'text',id,7,7,couleur);
  6938. input.onkeyup = previewCouleur;
  6939. input.onchange = previewCouleur;
  6940. input.onkeyup();
  6941. insertBefore(node,span);
  6942. }
  6943.  
  6944. function setChoixCouleurs() {
  6945. try {
  6946. //var form = document.getElementsByName('ActionForm')[0];
  6947. var form = document.getElementById('mhPlay');
  6948. var nodesAE = document.evaluate(
  6949. //"./table/tbody/tr/td[@class='mh_tdtitre']",
  6950. "./table/tbody/tr/th[@class='mh_tdtitre']",
  6951. //"./table/tbody/tr[@class='mh_tdtitre']/th",
  6952. form, null, 7, null
  6953. );
  6954. var nodes = document.evaluate(
  6955. //"./table/tbody/tr/td[not(@class='mh_tdtitre')]",
  6956. "./table/tbody/tr[not(@class='mh_tdtitre')]/td",
  6957. form, null, 7, null
  6958. );
  6959. } catch(e) {
  6960. window.console.error(traceStack(e, 'Diplomatie Structure de la page non reconnue'));
  6961. return false;
  6962. };
  6963. nodesAE.snapshotItem(0).parentNode.id = 'insertPt';
  6964. appendChoixCouleur(nodesAE.snapshotItem(0),'AllAmis');
  6965. appendChoixCouleur(nodesAE.snapshotItem(1),'AllEnnemis');
  6966. for(var i=0 ; i<5 ; i++) {
  6967. nodes.snapshotItem(i).id = 'tdAmis'+i;
  6968. insertChoixCouleur(nodes.snapshotItem(i).childNodes[1],'Amis'+i);
  6969. nodes.snapshotItem(i+5).id = 'tdEnnemis'+i;
  6970. insertChoixCouleur(nodes.snapshotItem(i+5).childNodes[1],'Ennemis'+i);
  6971. }
  6972. return true;
  6973. }
  6974.  
  6975. function fetchDiploGuilde() {
  6976. try {
  6977. for(var AE in {Amis:0,Ennemis:0}) {
  6978. for(var i=0 ; i<5 ; i++) {
  6979. /* Récup des A/E de rang i */
  6980. var td = document.getElementById('td'+AE+i);
  6981. var ligne = td.getElementsByTagName('table')[0].rows;
  6982. var titre = trim(td.firstChild.textContent);
  6983. // On laisse la gestion des couleurs à setChoixCouleurs:
  6984. var couleur = document.getElementById(AE+i).value;
  6985. diploGuilde[AE+i] = {
  6986. Troll:'',
  6987. Guilde:'',
  6988. titre: titre,
  6989. couleur: couleur
  6990. };
  6991. for(var j=1 ; j<ligne.length ; j++) {
  6992. var str = trim(ligne[j].cells[0].textContent);
  6993. var idx = str.lastIndexOf('(');
  6994. var num = str.slice(idx+1,-1);
  6995. var type = trim(ligne[j].cells[1].textContent);
  6996. diploGuilde[AE+i][type] += num+';';
  6997. }
  6998. }
  6999. }
  7000. } catch(e) {
  7001. window.console.error(traceStack(e, 'Diplomatie récupération de la diplo'));
  7002. return false;
  7003. }
  7004. return true;
  7005. }
  7006.  
  7007.  
  7008. /*-[functions]--------------------- Handlers ---------------------------------*/
  7009.  
  7010. function toggleDetails() {
  7011. isDetailOn = !isDetailOn;
  7012. for(var AE in {Amis:0,Ennemis:0}) {
  7013. document.getElementById('spanAll'+AE).style.display =
  7014. (isDetailOn?'none':'');
  7015. for(var i=0 ; i<5 ; i++) {
  7016. document.getElementById('span'+AE+i).style.display =
  7017. (isDetailOn?'':'none');
  7018. }
  7019. }
  7020. }
  7021.  
  7022. function toggleMythiques() {
  7023. isMythiquesOn = !isMythiquesOn;
  7024. document.getElementById('spanMythiques').style.display =
  7025. (isMythiquesOn?'':'none');
  7026. }
  7027.  
  7028. function previewCouleur() {
  7029. var value = this.value;
  7030. if(isCouleur(value)) {
  7031. this.style.backgroundColor = value;
  7032. this.title = '';
  7033. } else {
  7034. this.style.backgroundColor = '';
  7035. this.title = 'Entrez une couleur au format #789ABC pour prévisualiser';
  7036. }
  7037. }
  7038.  
  7039. function appendMenuType(node,duType) {
  7040. var select = document.createElement('select');
  7041. select.className = 'SelectboxV2';
  7042. var type = ['Guilde','Troll','Monstre'];
  7043. for(var i=0 ; i<3 ; i++) {
  7044. appendOption(select,type[i],type[i]);
  7045. if(type[i]==duType) { select.selectedIndex=i; }
  7046. }
  7047. node.appendChild(select);
  7048. }
  7049.  
  7050. function ajouteChamp(type,num,couleur,descr) {
  7051. var champs = document.getElementById('diploPerso');
  7052. var nb = champs.rows.length;
  7053. var tr = champs.insertRow(-1);
  7054. var td = appendTd(tr);
  7055. appendMenuType(td,type);
  7056. td = appendTd(tr);
  7057. appendText(td,' n°');
  7058. appendTextbox(td,'text','num'+nb,6,15,num);
  7059. td = appendTd(tr);
  7060. appendText(td,' couleur HTML:');
  7061. var input = appendTextbox(td,'text','couleur'+nb,7,7,couleur);
  7062. input.onkeyup = previewCouleur;
  7063. input.onchange = previewCouleur;
  7064. input.onkeyup();
  7065. td = appendTd(tr);
  7066. appendText(td,' Description:');
  7067. appendTextbox(td,'text','descr'+nb,30,150,descr);
  7068. td = appendTd(tr);
  7069. var span = document.createElement('span');
  7070. appendText(span,'[ok!]',true);
  7071. span.style.visibility = 'hidden';
  7072. td.appendChild(span);
  7073. td = appendTd(tr);
  7074. var bouton = appendButton(td,'Suppr.',retireCeChamp);
  7075. }
  7076.  
  7077. function retireCeChamp() {
  7078. var thisTr = this.parentNode.parentNode;
  7079. thisTr.parentNode.removeChild(thisTr);
  7080. var champs = document.getElementById('diploPerso');
  7081. if(champs.rows.length==0) { ajouteChamp(); }
  7082. }
  7083.  
  7084. function valideChamp(champ) {
  7085. var isValide = /^\d+$/.test(champ.cells[1].childNodes[1].value) &&
  7086. isCouleur(champ.cells[2].childNodes[1].value);
  7087. if(isValide) {
  7088. champ.cells[4].firstChild.style.visibility = 'visible';
  7089. } else {
  7090. champ.cells[4].firstChild.style.visibility = 'hidden';
  7091. }
  7092. return isValide;
  7093. }
  7094.  
  7095. function sauvegarderTout() {
  7096. /* Diplo de guilde */
  7097. diploGuilde.isOn =
  7098. document.getElementById('isGuildeOn').checked?'true':'false';
  7099. diploGuilde.isDetailOn = (isDetailOn?'true':'false');
  7100. var numGuilde = Number(document.getElementById('numGuilde').value);
  7101. var couleur = document.getElementById('couleurGuilde').value;
  7102. if(numGuilde) {
  7103. diploGuilde.guilde = {
  7104. id: numGuilde,
  7105. couleur: couleur
  7106. };
  7107. } else {
  7108. delete diploGuilde.guilde;
  7109. }
  7110. for(var AE in {Amis:0,Ennemis:0}) {
  7111. diploGuilde['All'+AE] = document.getElementById('All'+AE).value;
  7112. for(var i=0 ; i<5 ; i++) {
  7113. if(isDetailOn) {
  7114. diploGuilde[AE+i].couleur = document.getElementById(AE+i).value;
  7115. } else {
  7116. diploGuilde[AE+i].couleur = diploGuilde['All'+AE];
  7117. }
  7118. }
  7119. }
  7120. MY_setValue(numTroll+'.diplo.guilde',JSON.stringify(diploGuilde));
  7121. /* Diplo personnelle (ex-fonction saveChamps) */
  7122. var champs = document.getElementById('diploPerso');
  7123. diploPerso = {
  7124. isOn: document.getElementById('isPersoOn').checked?'true':'false',
  7125. Guilde: {},
  7126. Troll: {},
  7127. Monstre: {}
  7128. };
  7129. if(isMythiquesOn &&
  7130. isCouleur(document.getElementById('couleurMythiques').value)) {
  7131. diploPerso.mythiques = document.getElementById('couleurMythiques').value;
  7132. }
  7133. for(var i=0 ; i<champs.rows.length ; i++) {
  7134. if(valideChamp(champs.rows[i])) {
  7135. var type = champs.rows[i].cells[0].firstChild.value;
  7136. var num = champs.rows[i].cells[1].childNodes[1].value;
  7137. var couleur = champs.rows[i].cells[2].childNodes[1].value;
  7138. var descr = champs.rows[i].cells[3].childNodes[1].value;
  7139. diploPerso[type][num] = {
  7140. couleur: couleur
  7141. };
  7142. if(descr) {
  7143. diploPerso[type][num].titre = descr;
  7144. }
  7145. }
  7146. }
  7147. MY_setValue(numTroll+'.diplo.perso',JSON.stringify(diploPerso));
  7148.  
  7149. avertissement('Données sauvegardées');
  7150. }
  7151.  
  7152.  
  7153. /*-[functions]------------- Modifications de la page -------------------------*/
  7154.  
  7155. function creeTablePrincipale() {
  7156. var insertPt = document.getElementById('insertPt');
  7157. /* Titre + bouton de Sauvegarde */
  7158. var tr = insertTr(insertPt,'mh_tdtitre');
  7159. var td = appendTdText(tr,'[Mountyzilla] Options de Diplomatie ',true);
  7160. appendButton(td,'Sauvegarder',sauvegarderTout);
  7161. /* Options fixes */
  7162. tr = insertTr(insertPt,'mh_tdpage');
  7163. td = appendTdText(tr,'Diplomatie de guilde:',true);
  7164. appendBr(td);
  7165. appendCheckBox(td,'isGuildeOn',diploGuilde.isOn!='false');
  7166. appendText(td,'Afficher la diplomatie de guilde dans la Vue');
  7167. appendBr(td);
  7168. appendCheckBox(td,'detailOn',isDetailOn,toggleDetails);
  7169. appendText(td,'Utiliser des couleurs détaillées (10)');
  7170. /* Diplo personnelle */
  7171. tr = insertTr(insertPt,'mh_tdpage');
  7172. td = appendTdText(tr,'Diplomatie personnelle:',true);
  7173. appendBr(td);
  7174. // Diplo Mythiques
  7175. appendCheckBox(td,'isMythiquesOn',isMythiquesOn,toggleMythiques);
  7176. appendText(td,'Ajouter les monstres Mythiques à la Diplomatie');
  7177. var span = document.createElement('span');
  7178. span.id = 'spanMythiques';
  7179. if(!isMythiquesOn) {
  7180. span.style.display = 'none';
  7181. }
  7182. var couleur = '#FFAAAA';
  7183. if(diploPerso.mythiques) {
  7184. couleur = diploPerso.mythiques;
  7185. }
  7186. appendText(span,' - couleur HTML:');
  7187. var input = appendTextbox(span,'text','couleurMythiques',7,7,couleur);
  7188. input.onkeyup = previewCouleur;
  7189. input.onchange = previewCouleur;
  7190. input.onkeyup();
  7191. td.appendChild(span);
  7192. appendBr(td);
  7193. // Diplo éditable
  7194. appendCheckBox(td,'isPersoOn',diploPerso.isOn!='false');
  7195. appendText(td,'Afficher la diplomatie personnelle dans la Vue:');
  7196. appendBr(td);
  7197. var table = document.createElement('table');
  7198. table.id = 'diploPerso'
  7199. td.appendChild(table);
  7200. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  7201. for(var num in diploPerso[type]) {
  7202. ajouteChamp(
  7203. type,
  7204. num,
  7205. diploPerso[type][num].couleur,
  7206. diploPerso[type][num].titre
  7207. );
  7208. }
  7209. }
  7210. if(table.rows.length==0) {
  7211. ajouteChamp();
  7212. }
  7213. appendButton(td,'Ajouter',ajouteChamp)
  7214. // Prévisualisation couleurs (merci à Vys d'avoir implémenté ça xD)
  7215. appendText(td,' ');
  7216. appendButton(td,
  7217. 'Exemples de couleur',
  7218. function() {
  7219. var fenetre = window.open(
  7220. '/mountyhall/MH_Play/Options/Play_o_Color.php',
  7221. 'Divers',
  7222. 'width=500,height=550,toolbar=0,location=0,directories=0,'+
  7223. 'status=0,menubar=0,resizable=1,scrollbars=1'
  7224. );
  7225. fenetre.focus();
  7226. }
  7227. );
  7228. /* Couleur de Guilde */
  7229. tr = insertTr(insertPt,'mh_tdtitre');
  7230. td = appendTdText(tr,'GUILDE',true);
  7231. appendText(td,' - n°');
  7232. appendTextbox(td,'text','numGuilde',5,10,
  7233. diploGuilde.guilde && diploGuilde.guilde.id ?
  7234. diploGuilde.guilde.id : ''
  7235. );
  7236. appendText(td,' - Couleur HTML: ');
  7237. var input = appendTextbox(td,'text','couleurGuilde',7,7,
  7238. diploGuilde.guilde && diploGuilde.guilde.couleur ?
  7239. diploGuilde.guilde.couleur : '#BBBBFF'
  7240. );
  7241. input.onkeyup = previewCouleur;
  7242. input.onchange = previewCouleur;
  7243. input.onkeyup();
  7244. }
  7245.  
  7246.  
  7247. /*-[functions]----------------------- Main -----------------------------------*/
  7248.  
  7249. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  7250. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  7251. var isDetailOn = diploGuilde.isDetailOn=='true';
  7252. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  7253. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  7254. var isMythiquesOn = diploPerso.mythiques!=undefined;
  7255.  
  7256. function do_diplo() {
  7257. if(setChoixCouleurs() && fetchDiploGuilde()) {
  7258. creeTablePrincipale();
  7259. }
  7260. }
  7261.  
  7262. /*******************************************************************************
  7263. * This file is part of Mountyzilla. *
  7264. * *
  7265. * Mountyzilla is free software; you can redistribute it and/or modify *
  7266. * it under the terms of the GNU General Public License as published by *
  7267. * the Free Software Foundation; either version 2 of the License, or *
  7268. * (at your option) any later version. *
  7269. * *
  7270. * Mountyzilla is distributed in the hope that it will be useful, *
  7271. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7272. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7273. * GNU General Public License for more details. *
  7274. * *
  7275. * You should have received a copy of the GNU General Public License *
  7276. * along with Mountyzilla; if not, write to the Free Software *
  7277. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7278. *******************************************************************************/
  7279.  
  7280. // x~x cdmcomp
  7281.  
  7282. //var cdm = ''; // Roule 11/03/2017 une variable globale de moins \o/
  7283.  
  7284. function getNonNegInts(str) {
  7285. var nbrs = str.match(/\d+/g);
  7286. for(var i=0 ; i<nbrs.length ; i++) {
  7287. nbrs[i] = Number(nbrs[i]);
  7288. }
  7289. return nbrs;
  7290. }
  7291.  
  7292. function traiteCdMcomp() {
  7293. try {
  7294. var msgEffet = document.getElementById('msgEffet');
  7295. } catch(e) {
  7296. window.console.log('[MZ traiteCdMcomp] msgEffet non trouvé');
  7297. return;
  7298. }
  7299.  
  7300. // Teste si ce message du bot est un message de CdM
  7301. if(!document.evaluate(
  7302. "./p/text()[contains(.,'fait partie')]",
  7303. msgEffet, null, 9, null
  7304. ).singleNodeValue) {
  7305. if (MY_DEBUG) window.console.log('[MZ traiteCdMcomp] ce n\'est pas une CdM');
  7306. return;
  7307. }
  7308. // Début de récupération de la CdM
  7309. /*
  7310. Roule 10/03/2017 j'ai grandement simplifié ☺ ☺ ☺
  7311. zone à supprimer
  7312. traitement Armure Physique/Magique reporté en php
  7313.  
  7314. cdm = document.evaluate(
  7315. "./p/text()[contains(.,'fait partie')]",
  7316. msgEffet, null, 9, null
  7317. ).singleNodeValue.nodeValue+'\n';
  7318. var tbody = document.evaluate(
  7319. "descendant::table/tbody",
  7320. msgEffet, null, 9, null
  7321. ).singleNodeValue;
  7322. var nomStat = document.evaluate(
  7323. "./tr/td[1]/b/text()",
  7324. tbody, null, 7, null
  7325. );
  7326. var valStat = document.evaluate(
  7327. "./tr/td[2]/descendant::text()",
  7328. tbody, null, 7, null
  7329. );
  7330. var i=0;
  7331. while(i<nomStat.snapshotLength) {
  7332. if(nomStat.snapshotItem(i).nodeValue.indexOf('Armure Physique')!=-1) {
  7333. cdm += 'Armure : ';
  7334. var armp = getNonNegInts(valStat.snapshotItem(i).nodeValue);
  7335. var armm = getNonNegInts(valStat.snapshotItem(i+1).nodeValue);
  7336. if(valStat.snapshotItem(i).nodeValue.indexOf('(inf')!=-1) {
  7337. armp = [0,armp[0]];
  7338. }
  7339. if(valStat.snapshotItem(i+1).nodeValue.indexOf('(inf')!=-1) {
  7340. armm = [0,armm[0]];
  7341. }
  7342. if(valStat.snapshotItem(i).nodeValue.indexOf('(sup')!=-1 ||
  7343. valStat.snapshotItem(i+1).nodeValue.indexOf('(sup')!=-1) {
  7344. cdm += 'adj (supérieur à '+(armp[0]+armm[0]);
  7345. } else {
  7346. cdm += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7347. }
  7348. cdm += ')\n';
  7349. i++;
  7350. } else {
  7351. cdm += nomStat.snapshotItem(i).nodeValue+
  7352. ' '+valStat.snapshotItem(i).nodeValue+'\n';
  7353. }
  7354. i++;
  7355. }
  7356. */
  7357. //cdm = msgEffet.innerText || msgEffet.textContent; // récupération du contenu texte d'un élément HTML
  7358. //if (MY_DEBUG) window.console.log('cmd=' + cdm);
  7359.  
  7360. // envoi au serveur (PHP) d'un objet avec
  7361. // cmd: un tableau de chaines (éléments HTML <p>) ou de tableaux (les <TD> des lignes des tableaux HTML)
  7362. // tstamp: l'horodatage
  7363. var tabCdM = new Array();
  7364. var etimestamp = document.getElementById('hserveur');
  7365. if (etimestamp != undefined) {var tstamp = etimestamp.innerText || etimestamp.textContent;}
  7366. var txtBlessure;
  7367. var txtPv;
  7368. for (var eHTML of msgEffet.childNodes) {
  7369. switch (eHTML.nodeName) {
  7370. case '#text':
  7371. var s = eHTML.nodeValue.trim();
  7372. if (s != '') tabCdM.push(s);
  7373. break;
  7374. case 'P':
  7375. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7376. s = s.trim();
  7377. if (s != '') tabCdM.push(s);
  7378. break;
  7379. case 'TABLE':
  7380. var s = 'table';
  7381. for (var eTr of eHTML.rows) {
  7382. var tabTd = new Array();
  7383. for (var eTd of eTr.cells) {
  7384. var s = eTd.innerText || eTd.textContent; // récupération du contenu texte d'un élément HTML
  7385. s = s.trim();
  7386. tabTd.push(s);
  7387. }
  7388. if (tabTd.length >= 2) {
  7389. if (tabTd[0].match(/Blessure/i)) {
  7390. txtBlessure = tabTd[1]
  7391. } else if (tabTd[0].match(/Points* *de *Vie/i)) {
  7392. txtPv = tabTd[1]
  7393. }
  7394. }
  7395. tabCdM.push(tabTd);
  7396. }
  7397. break;
  7398. default:
  7399. window.console.log('[MZ ' + GM_info.script.version + '] traiteCdMcomp, type d\'élément non traité : ' + eHTML.nodeName);
  7400. var s = eHTML.innerText || eHTML.textContent; // récupération du contenu texte d'un élément HTML
  7401. if (s != '') tabCdM.push(s);
  7402. break;
  7403. }
  7404. }
  7405. var oData = {};
  7406. if (tstamp != undefined) oData.tstamp = tstamp.replace(/\]/, '').trim();
  7407. oData.idTroll = numTroll;
  7408. oData.tabCdM = tabCdM;
  7409. if (MY_DEBUG) window.console.log('oData=' + JSON.stringify(oData));
  7410.  
  7411. // envoi d'une CdM issue de compte-rendu de compétence
  7412. // fonction définie ici pour avoir vue sur la variable tabCdM
  7413. var sendInfoCDM = function () {
  7414. MY_setValue('CDMID', 1+parseInt(MY_getValue('CDMID')) );
  7415. var buttonCDM = this;
  7416. var texte = '';
  7417. FF_XMLHttpRequest({
  7418. method: 'POST',
  7419. url: URL_pageDispatcherV2,
  7420. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7421. headers : {
  7422. /* inutile, à supprimer
  7423. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7424. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7425. */
  7426. 'Content-type':'application/x-www-form-urlencoded',
  7427. },
  7428. onload: function(responseDetails) {
  7429. texte = responseDetails.responseText;
  7430. buttonCDM.value = texte;
  7431. if (!isDEV) buttonCDM.disabled = true;
  7432. }
  7433. });
  7434. }
  7435.  
  7436. // Envoi auto ou insertion bouton envoi (suivant option)
  7437. if(MY_getValue(numTroll+'.AUTOCDM')=='true') {
  7438. sendInfoCDM();
  7439. var p = document.createElement('p');
  7440. p.style.color = 'green';
  7441. appendText(p,'CdM envoyée vers la base MountyZilla !');
  7442. insertBefore(document.getElementsByName('as_Action')[0].parentNode,p);
  7443. } else {
  7444. insertButtonCdm('as_Action', sendInfoCDM);
  7445. }
  7446.  
  7447. // Insertion de l'estimation des PV restants
  7448. /*
  7449. var pv = valStat.snapshotItem(1).nodeValue;
  7450. if(pv.indexOf("entre")==-1) {
  7451. return;
  7452. }
  7453. var trPv = document.evaluate(
  7454. "//tr[contains(td/b/text(),'Points de Vie')]",
  7455. msgEffet, null, 9, null).singleNodeValue;
  7456. tdPv = trPv.cells[1];
  7457. txtPv = tdPv.innerText || tdPv.textContent;
  7458. if (MY_DEBUG) window.console.log('txtPv=' + txtPv);
  7459. if(0) { //pv) { // bloqué en attendant correction
  7460. */
  7461. if (MY_DEBUG) window.console.log('txtBlessure=' + txtBlessure + ', txtPv=' + txtPv);
  7462. if (txtBlessure !== undefined && txtPv !== undefined) {
  7463. var pv = getPVsRestants(txtPv,txtBlessure);
  7464. if (MY_DEBUG) window.console.log('pv=' + pv);
  7465. if (pv) { // pv null si le monstre n'est pas blessé
  7466. var trBless = document.evaluate(
  7467. "//tr[contains(td/b/text(),'Blessure')]",
  7468. msgEffet, null, 9, null).singleNodeValue;
  7469. var tr = document.createElement('tr');
  7470. trBless.parentNode.insertBefore(tr, trBless.nextSibling);
  7471. appendTr(trBless);
  7472. appendTdText(tr, pv[0], true);
  7473. appendTdText(tr, pv[1], true);
  7474. }
  7475. }
  7476. }
  7477.  
  7478. function do_cdmcomp() {
  7479. start_script(31);
  7480. traiteCdMcomp();
  7481. displayScriptTime();
  7482. }
  7483.  
  7484. /*********************************************************************************
  7485. * This file is part of Mountyzilla. *
  7486. * *
  7487. * Mountyzilla is free software; you can redistribute it and/or modify *
  7488. * it under the terms of the GNU General Public License as published by *
  7489. * the Free Software Foundation; either version 2 of the License, or *
  7490. * (at your option) any later version. *
  7491. * *
  7492. * Mountyzilla is distributed in the hope that it will be useful, *
  7493. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7494. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7495. * GNU General Public License for more details. *
  7496. * *
  7497. * You should have received a copy of the GNU General Public License *
  7498. * along with Mountyzilla; if not, write to the Free Software *
  7499. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7500. *********************************************************************************/
  7501.  
  7502. // x~x cmdbot
  7503.  
  7504. /* v0.2 by Dab - 2013-08-20
  7505. * - patch dégueu pour gérer la décomposition P/M de l'armure
  7506. */
  7507.  
  7508. var buttonCDM;
  7509.  
  7510. /*******************************************************************************************
  7511. CDM :
  7512. Vous avez RÉUSSI à utiliser cette compétence au niveau 5 : jet de 34 sur 95 %.
  7513.  
  7514. Il ne vous est pas possible d'améliorer cette compétence.
  7515.  
  7516. Le Monstre Ciblé fait partie des : Mort-Vivant (Archi-Nécromant [Antique] - N°4571589)
  7517. Niveau : Inimaginable (entre 49 et 51)
  7518. Points de Vie : Surtrollesque (entre 450 et 470)
  7519. Blessure (Approximatif) : 0 %
  7520. Dés d'Attaque : Impressionnant (entre 30 et 32)
  7521. Dés d'Esquive : Impressionnant (entre 28 et 30)
  7522. Dés de Dégat : Très Fort (entre 18 et 20)
  7523. Dés de Régénération : Excellent (égal à 13)
  7524. Armure Physique : Moyen (entre 10 et 12)
  7525. Armure Magique : Faible (inférieur à 6)
  7526. Vue : Moyen (entre 9 et 11)
  7527. Maitrise Magique : Inimaginable (supérieur à 6000)
  7528. Résistance Magique : Inimaginable (supérieur à 6000)
  7529. Nombre d'attaques : 1
  7530. Vitesse de Déplacement : Normale
  7531. Voir le Caché : Oui
  7532. Attaque à distance : Non
  7533. Attaque magique : Oui
  7534. Vole : Non
  7535. Sang froid : Inexistant
  7536. DLA : Milieu
  7537. Durée Tour : Remarquable (entre 9 et 11)
  7538. Chargement : Vide
  7539. Bonus Malus : Aucun
  7540.  
  7541. Vous avez également gagné 1 PX pour la réussite.
  7542. *******************************************************************************************
  7543. BOT :
  7544. Vous avez utilisé CONNAISSANCE DES MONSTRES sur un Capitan Ronfleur [Naissant] (4768960)
  7545.  
  7546. Le Monstre ciblé fait partie des : Mort-Vivant
  7547.  
  7548. Niveau : Incroyable (entre 36 et 38)
  7549. *******************************************************************************************/
  7550.  
  7551. function getNNInt(str) {
  7552. var nbrs = str.match(/\d+/g);
  7553. for (var i=0 ; i<nbrs.length ; i++)
  7554. nbrs[i] = parseInt(nbrs[i]);
  7555. return nbrs;
  7556. }
  7557.  
  7558. // envoi d'une CdM issue d'un message du BOT
  7559. function sendCDM() {
  7560. var td = document.evaluate("//td/text()[contains(.,'CONNAISSANCE DES MONSTRES')]/..",
  7561. document, null, 9, null).singleNodeValue;
  7562. /* ancienne version à supprimer
  7563. cdm = td.innerHTML;
  7564. cdm = cdm.replace(/.* MONSTRES sur une? ([^(]+) \(([0-9]+)\)(.*partie des : )([^<]+)<br>/,
  7565. "$3$4 ($1 - N°$2)<br>");
  7566. cdm = cdm.replace(/Blessure :[\s]*[0-9]+ % \(approximativement\)/,
  7567. 'Blessure : XX % (approximativement)');
  7568. // Supprime la décomposition P/M de l'Armure
  7569. var bgn = cdm.indexOf('Armure Physique');
  7570. if (bgn!=-1) {
  7571. var end = cdm.indexOf('Vue')-2;
  7572. var lines = cdm.substring(bgn,end).split('<br>');
  7573. var armp = getNNInt(lines[0]);
  7574. var armm = getNNInt(lines[1]);
  7575. if (lines[0].indexOf('(inf')!=-1)
  7576. armp = [0,armp[0]];
  7577. if (lines[1].indexOf('(inf')!=-1)
  7578. armm = [0,armm[0]];
  7579. var insrt = 'Armure : ';
  7580. if (lines[0].indexOf('(sup')!=-1 || lines[1].indexOf('(sup')!=-1)
  7581. insrt += 'adj (supérieur à '+(armp[0]+armm[0]);
  7582. else
  7583. insrt += 'adj (entre '+(armp[0]+armm[0])+' et '+(armp[1]+armm[1]);
  7584. cdm = cdm.replace(cdm.substring(bgn,end),insrt+')<br>');
  7585. }
  7586. cdm = cdm.replace(/<br>/g,'\n');
  7587. */
  7588.  
  7589. var tdTxt = td.innerText || td.textContent; // récupération du contenu texte d'un élément HTML
  7590. //window.console.log(tdTxt);
  7591. var oData = {};
  7592. oData.tabCdM = tdTxt.split(/\n/);
  7593. // nettoyage entête : enlève le premier élément tant que
  7594. // - suite de *
  7595. // - "MOUNTYHALL - La Terre des Trõlls"
  7596. // - ligne vide (la première expression régulière matche les lignes vides)
  7597. while (oData.tabCdM[0].match(/^=*$/) || oData.tabCdM[0].match(/^MOUNTYHALL/i)) oData.tabCdM.shift();
  7598. // 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
  7599. var iLigneNonVide;
  7600. for (var i = 0; i < oData.tabCdM.length; i++) {
  7601. if (oData.tabCdM[i].match(/^\*+$/) && oData.tabCdM[i+1].match(/^Vous avez configuré/i)) {
  7602. if (iLigneNonVide === undefined)
  7603. oData.tabCdM.splice(i);
  7604. else
  7605. oData.tabCdM.splice(iLigneNonVide+1);
  7606. break;
  7607. }
  7608. if (!oData.tabCdM[i].match(/^$/)) iLigneNonVide = i;
  7609. }
  7610. //window.console.log(JSON.stringify(oData));
  7611.  
  7612. FF_XMLHttpRequest({
  7613. method: 'POST',
  7614. url: URL_pageDispatcherV2,
  7615. data: 'cdm_json=' + encodeURIComponent(JSON.stringify(oData)),
  7616. headers : {
  7617. /* inutile, à supprimer
  7618. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7619. 'Accept': 'application/atom+xml,application/xml,text/xml',
  7620. */
  7621. 'Content-type':'application/x-www-form-urlencoded',
  7622. },
  7623. onload: function(responseDetails) {
  7624. buttonCDM.value=responseDetails.responseText;
  7625. buttonCDM.disabled = true;
  7626. }
  7627. });
  7628. }
  7629.  
  7630. function traiteCdMmsg() {
  7631. // Teste si ce message du bot est un message de CdM
  7632. var td = document.evaluate("//td/text()[contains(.,'fait partie')]/..",
  7633. document, null, 9, null).singleNodeValue;
  7634. if (!td) return false;
  7635. cdm = td.innerHTML;
  7636. // Insertion de l'estimation des PV restants
  7637. var des = cdm.indexOf('Dés');
  7638. var pv = cdm.slice(cdm.indexOf('Points de Vie'),cdm.indexOf('Blessure'));
  7639. pv = getPVsRestants(pv, cdm.slice(cdm.indexOf('Blessure :'),des) );
  7640. if(pv)
  7641. td.innerHTML = cdm.slice(0,des-4)+'<br />'+(pv[0]+pv[1]) + cdm.substring(des-4);
  7642.  
  7643. // Insertion bouton envoi + espace
  7644. buttonCDM = insertButtonCdm('bClose',sendCDM);
  7645. }
  7646.  
  7647. /*function traitePouvoir() {
  7648. // Teste si ce message du bot est un message de CdM
  7649. // le test "capa" évite les pouvoirs type Chonchon (pas de SR)
  7650. var td = document.evaluate("//td/text()[contains(.,'POUVOIR')]/../text()[contains(.,'capacité spéciale')]/..",
  7651. document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7652. if (!td)
  7653. return false;
  7654. var infos = td.innerHTML;
  7655. var id = /monstre n°([0-9]+) /.exec(infos)[1];
  7656. var nomMonstre = /\(une? ([^)]+)\)/.exec(infos)[1];
  7657. var nomPouvoir = /spéciale : ([^<]+)/.exec(infos)[1];
  7658. var date = /alors : ([^<]+)\./.exec(infos)[1];
  7659. date = new Date(date.replace(/([0-9]+)\/([0-9]+)\//,"$2/$1/"));
  7660. var effetPouvoir="";
  7661. var full=false;
  7662. if(infos.indexOf("REDUIT")!=-1) {
  7663. effetPouvoir = /effet REDUIT : ([^<]+)/.exec(infos)[1];
  7664. }
  7665. else {
  7666. effetPouvoir = /effet : ([^<]+)/.exec(infos)[1];
  7667. full=true;
  7668. }
  7669. var dureePouvoir = /durée de ([0-9]+)/.exec(infos)[1];
  7670. // On insère le bouton et un espace
  7671. //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));
  7672. // ce type d'URL est obsolète (se fait par msgId dorénavant)
  7673. if(!MY_getValue('AUTOSENDPOUV'))
  7674. {
  7675. var button = insertButtonCdm('bClose',null,"Collecter les infos du pouvoir");
  7676. button.setAttribute("onClick", "window.open('" + url
  7677. + "', 'popupEffet', 'width=400, height=240, toolbar=no, status=no, location=no, resizable=yes'); "
  7678. + "this.value='Merci de votre participation'; this.disabled = true;");
  7679. }
  7680. else
  7681. {
  7682. FF_XMLHttpRequest({
  7683. method: 'GET',
  7684. url: url,
  7685. headers : {
  7686. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  7687. 'Accept': 'application/atom+xml,application/xml,text/xml'
  7688. }});
  7689. }
  7690. }*/
  7691.  
  7692. function do_cdmbot() { // Roule 17/10/2016, restreint à la page des message du bot
  7693. traiteCdMmsg();
  7694. }
  7695. //traitePouvoir(); méthode d'envoi obsolète et gestion inconnue niveau DB
  7696.  
  7697. /*******************************************************************************
  7698. * This file is part of Mountyzilla. *
  7699. * *
  7700. * Mountyzilla is free software; you can redistribute it and/or modify *
  7701. * it under the terms of the GNU General Public License as published by *
  7702. * the Free Software Foundation; either version 2 of the License, or *
  7703. * (at your option) any later version. *
  7704. * *
  7705. * Mountyzilla is distributed in the hope that it will be useful, *
  7706. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7707. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7708. * GNU General Public License for more details. *
  7709. * *
  7710. * You should have received a copy of the GNU General Public License *
  7711. * along with Mountyzilla; if not, write to the Free Software *
  7712. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7713. *******************************************************************************/
  7714.  
  7715. // x~x menu
  7716. // n'est lancé que sur refresh du volet de menu (activation ou [Refresh])
  7717.  
  7718. var menuRac, mainIco;
  7719.  
  7720. // met à jour les carac sauvegardées (position, DLA, etc.)
  7721. function updateData() {
  7722. var inputs = document.getElementsByTagName('input');
  7723. var divs = document.getElementsByTagName('div');
  7724.  
  7725. //window.console.log('inputs=' + JSON.stringify(inputs));
  7726. if (inputs && inputs.length > 0) {
  7727. // Roule, 14/03/2017, ancienne version, il n'y a plus de <input>
  7728. numTroll = inputs[0].value;
  7729. MY_setValue('NUM_TROLL', numTroll);
  7730. MY_setValue('NIV_TROLL',inputs[1].value);
  7731. if(!MY_getValue(numTroll+'.caracs.rm')) {
  7732. MY_setValue(numTroll+'.caracs.rm',0);
  7733. // assure l'init des 4 var de libs
  7734. }
  7735. MY_setValue(numTroll+'.caracs.mm',inputs[2].value);
  7736. } else {
  7737. // onclick="EnterPJView(91305,750,550)"
  7738. var tabA = document.getElementsByTagName('a');
  7739. if (tabA.length > 0 && tabA[0].onclick !== undefined) {
  7740. var s = tabA[0].onclick.toString();;
  7741. //window.console.log('s=' + JSON.stringify(s) + ' ' + typeof(s) + ' ' + s.toString());
  7742. var m = s.match(/\((\d+) *,/);
  7743. //window.console.log('m=' + JSON.stringify(m));
  7744. numTroll = parseInt(m[1]);
  7745. MY_setValue('NUM_TROLL', numTroll);
  7746. }
  7747. }
  7748.  
  7749. var DLA = new Date(
  7750. StringToDate(divs[1].firstChild.nodeValue.slice(5))
  7751. );
  7752. if(MY_getValue(numTroll+'.DLA.encours')) {
  7753. var DLAstockee = new Date(
  7754. StringToDate(MY_getValue(numTroll+'.DLA.encours'))
  7755. );
  7756. if(DLA>DLAstockee) {
  7757. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLAstockee));
  7758. // Pose un pb en cas de décalage de DLA
  7759. }
  7760. }
  7761. MY_setValue(numTroll+'.DLA.encours',DateToString(DLA));
  7762.  
  7763. var listePos = divs[1].childNodes[2].nodeValue.split('=');
  7764. MY_setValue(numTroll+'.position.X',parseInt(listePos[1]));
  7765. MY_setValue(numTroll+'.position.Y',parseInt(listePos[2]));
  7766. MY_setValue(numTroll+'.position.N',parseInt(listePos[3]));
  7767. if (MY_DEBUG) window.console.log('numTroll=' + numTroll + ',DLA =' + DLA + ', x= ' + parseInt(listePos[1]) + ', y= ' + parseInt(listePos[2]) + ', n= ' + parseInt(listePos[3]));
  7768. }
  7769.  
  7770. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7771. function initRaccourcis() {
  7772. var anotherURL = MY_getValue('URL1');
  7773. if(!anotherURL) { return; }
  7774. /* Création de l'icône faisant apparaître le menu */
  7775. mainIco = document.createElement('img');
  7776. var urlIco = MY_getValue(numTroll+'.ICOMENU');
  7777. if(!urlIco) {
  7778. urlIco =
  7779. URL_MZimg + 'mz_logo_small.png';
  7780. }
  7781. mainIco.src = urlIco;
  7782. mainIco.alt = 'MZ';
  7783. mainIco.style = 'position:fixed; top:0px; left:0px';
  7784. mainIco.onmouseover = afficheMenu;
  7785. document.body.appendChild(mainIco);
  7786. /* Création du menu des Raccourcis */
  7787. menuRac = document.createElement('div');
  7788. menuRac.className = 'mh_textbox';
  7789. menuRac.style =
  7790. 'position:fixed; top:10px; left:10px;'+
  7791. 'max-width:190px;'+
  7792. 'border-radius: 4px; padding: 4px;'+
  7793. 'z-index: 500;'+
  7794. 'visibility: hidden;';
  7795. document.body.appendChild(menuRac);
  7796. document.addEventListener('mousemove',cacheMenu,false);
  7797. var i=1;
  7798. while(anotherURL) {
  7799. var a = document.createElement('a');
  7800. var url = MY_getValue('URL'+i);
  7801. var nom = MY_getValue('URL'+i+'.nom');
  7802. var ico = MY_getValue('URL'+i+'.ico');
  7803. a.href = url;
  7804. a.target = '_blank';
  7805. if(ico) {
  7806. var txt = nom ? nom : '';
  7807. var img = createImage(ico,txt);
  7808. a.appendChild(img);
  7809. }
  7810. else {
  7811. appendText(a,'['+nom+']');
  7812. }
  7813. menuRac.appendChild(a);
  7814. appendBr(menuRac);
  7815. i++;
  7816. anotherURL = MY_getValue('URL'+i);
  7817. }
  7818. }
  7819.  
  7820. function afficheMenu() {
  7821. menuRac.style.visibility = 'visible';
  7822. }
  7823.  
  7824. function cacheMenu(e) {
  7825. if(menuRac.style.visibility=='hidden') { return; }
  7826. // Position souris
  7827. var ptX = e.clientX;
  7828. var ptY = e.clientY;
  7829. // On recalcule en live les BoundingBox pour mainIco et menuRac
  7830. // Moins optimal, mais évite des erreurs (d'originie inconnue)
  7831. var menuRect = menuRac.getBoundingClientRect();
  7832. var icoRect = mainIco.getBoundingClientRect();
  7833. if((ptX>icoRect.width || ptY>icoRect.height) &&
  7834. (ptX<10 || ptX>10+menuRect.width || ptY<10 || ptY>10+menuRect.height)) {
  7835. menuRac.style.visibility = 'hidden';
  7836. }
  7837. }
  7838.  
  7839. // ajout de l'icône, branchée sur un refresh
  7840. function initUpdateCoordGauche() {
  7841. var div = document.evaluate("//div[@class='infoMenu']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  7842. //window.console.log('initUpdateCoordGauche ' + div.innerHTML);
  7843. var img = document.createElement('img');
  7844. img.src = URL_MZimg + 'recycl.png'
  7845. img.onclick = function(evt) {
  7846. document.location.href = document.location.href;
  7847. };
  7848. img.title = 'Mise à jour de la localisation';
  7849. img.style.cursor = 'pointer';
  7850. img.style.position = 'absolute';
  7851. img.style.bottom = 0;
  7852. img.style.left = 0;
  7853. div.appendChild(img);
  7854. }
  7855.  
  7856. function do_menu() {
  7857. // met à jour les carac sauvegardées (position, DLA, etc.)
  7858. updateData();
  7859. // ajoute les raccourcis (paramétrables dans Options/Pack Graphique)
  7860. initRaccourcis();
  7861. // Ajout bouton de mise à jour coordonnées
  7862. initUpdateCoordGauche();
  7863. }
  7864.  
  7865. /*******************************************************************************
  7866. * This file is part of Mountyzilla. *
  7867. * *
  7868. * Mountyzilla is free software; you can redistribute it and/or modify *
  7869. * it under the terms of the GNU General Public License as published by *
  7870. * the Free Software Foundation; either version 2 of the License, or *
  7871. * (at your option) any later version. *
  7872. * *
  7873. * Mountyzilla is distributed in the hope that it will be useful, *
  7874. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  7875. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  7876. * GNU General Public License for more details. *
  7877. * *
  7878. * You should have received a copy of the GNU General Public License *
  7879. * along with Mountyzilla; if not, write to the Free Software *
  7880. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  7881. *******************************************************************************/
  7882.  
  7883. // x~x vue
  7884.  
  7885. /* TODO
  7886. * /!\ bug latent sur diminution bonusPV (perte Telaite / template Ours),
  7887. * prévoir fix ("delete infos")
  7888. */
  7889.  
  7890. /*--------------------------- Variables Globales -----------------------------*/
  7891.  
  7892. // Infos remplies par des scripts extérieurs
  7893. var listeCDM = [], listeLevels = [];
  7894.  
  7895. // Position actuelle
  7896. var currentPosition=[0,0,0];
  7897.  
  7898. // Portées de la vue : [vueHpure, vueVpure, vueHlimitée, vueVlimitée]
  7899. var porteeVue=[0,0,0,0];
  7900.  
  7901. // Fenêtres déplaçables
  7902. var winCurr = null;
  7903. var offsetX, offsetY;
  7904.  
  7905. // Diplomatie
  7906. var Diplo = {
  7907. Guilde: {},
  7908. Troll: {},
  7909. Monstre: {}
  7910. // .mythiques: uniquement si option activée
  7911. };
  7912. var isDiploRaw = true; // = si la Diplo n'a pas encore été analysée
  7913.  
  7914. // Infos tactiques
  7915. var popup;
  7916.  
  7917. // Gère l'affichage en cascade des popups de CdM
  7918. var nbCDM = 0;
  7919.  
  7920. var isCDMsRetrieved = false; // = si les CdM ont déjà été DL
  7921.  
  7922. // Utilisé pour supprimer les monstres "engagés"
  7923. var listeEngages = {};
  7924. var isEngagesComputed = false;
  7925. var cursorOnLink = false; // DEBUG: wtf ?
  7926.  
  7927. var needComputeEnchantement = MY_getValue(numTroll+'.enchantement.liste')
  7928. && MY_getValue(numTroll+'.enchantement.liste')!='';
  7929.  
  7930. // Checkboxes de filtrage
  7931. var checkBoxGG, checkBoxCompos, checkBoxBidouilles, checkBoxIntangibles,
  7932. checkBoxDiplo, checkBoxTrou, checkBoxEM, checkBoxTresorsNonLibres,
  7933. checkBoxTactique, checkBoxLevels, checkBoxGowapsS, checkBoxGowapsA, checkBoxEngages,
  7934. comboBoxNiveauMin, comboBoxNiveauMax;
  7935.  
  7936. /* Acquisition & Stockage des données de DB */
  7937. const typesAFetcher = {
  7938. 'monstres':1,
  7939. 'trolls':1,
  7940. 'tresors':1,
  7941. 'champignons':1,
  7942. 'lieux':1
  7943. }
  7944. var tr_monstres = {}, tr_trolls = {}, tr_tresors = {},
  7945. tr_champignons = {}, tr_lieux = {};
  7946. var nbMonstres = 0, nbTrolls = 0, nbTresors = 0,
  7947. nbChampignons = 0, nbLieux = 0;
  7948.  
  7949. function fetchData(type) {
  7950. try {
  7951. var node = document.getElementById('mh_vue_hidden_'+type);
  7952. // this = MZ.global = sandBox de travail de MZ
  7953. // On définit donc des variables MZ-globales
  7954. this['tr_'+type] = node.getElementsByTagName('tr');
  7955. this['nb'+type[0].toUpperCase()+type.slice(1)] = this['tr_'+type].length-1;
  7956. } catch(e) {
  7957. window.console.warn('[MZ Vue] Erreur acquisition type '+type+'\n'+e);
  7958. }
  7959. }
  7960.  
  7961.  
  7962. /*---------------------------------- DEBUG -----------------------------------*/
  7963. var mainTabs = document.getElementsByClassName('mh_tdborder');
  7964. var x_monstres = tr_monstres;
  7965. var x_trolls = tr_trolls;
  7966. var x_tresors = tr_tresors;
  7967. var x_champis = tr_champignons;
  7968. var x_lieux = tr_lieux;
  7969. /*-------------------------------- FIN DEBUG ---------------------------------*/
  7970.  
  7971.  
  7972. /*-[functions]-------------- Fonctions utilitaires ---------------------------*/
  7973.  
  7974. function positionToString(arr) {
  7975. return arr.join(';');
  7976. }
  7977.  
  7978. function savePosition() {
  7979. // Stocke la position (à jour) de la vue pour les autres scripts
  7980. // DEBUG: Lesquels et pourquoi?
  7981. var pos = getPosition();
  7982. MY_setValue(numTroll+'.position.X',pos[0]);
  7983. MY_setValue(numTroll+'.position.Y',pos[1]);
  7984. MY_setValue(numTroll+'.position.N',pos[2]);
  7985. }
  7986.  
  7987.  
  7988. /*-[functions]--- Fonctions de récupération de données (DOM) -----------------*/
  7989. /* INFOS :
  7990. * les champs-titres (table>tbody>tr>td>table>tbody>tr>td>a)
  7991. * sont identifiables via leur Name
  7992. * les tables-listings sont identifiables via l'ID du tr conteneur
  7993. * (mh_vue_hidden_XXX, XXX=trolls, champignons, etc)
  7994. */
  7995.  
  7996. /* [functions] Récup données Utilisateur */
  7997. function getPosition() {
  7998. // Pour rétrocompatibilité
  7999. return currentPosition;
  8000. }
  8001.  
  8002. function getPorteVue() {
  8003. // Pour rétrocompatibilité
  8004. return porteeVue;
  8005. }
  8006.  
  8007. function getVue() {
  8008. // Retourne [vueHpure, vueVpure]
  8009. var vues = getPorteVue();
  8010. return [ vues[0], vues[1] ];
  8011. }
  8012.  
  8013. // Roule 11/03/2016
  8014. /* [functions] Récup données monstres, trolls, etc. */
  8015. function getXxxDistance(xxx, i) {
  8016. return parseInt(this['tr_' + xxx.toLowerCase()][i].cells[0].textContent);
  8017. }
  8018. function getXxxPosition(xxx, i) {
  8019. var tds = this['tr_' + xxx.toLowerCase()][i].childNodes;
  8020. var l = tds.length;
  8021. return [
  8022. parseInt(tds[l-3].textContent),
  8023. parseInt(tds[l-2].textContent),
  8024. parseInt(tds[l-1].textContent)
  8025. ];
  8026. }
  8027.  
  8028.  
  8029. /* [functions] Récup données monstres */
  8030. function getMonstreDistance(i) {
  8031. return parseInt(tr_monstres[i].cells[0].textContent);
  8032. }
  8033.  
  8034. function getMonstreID(i) {
  8035. return tr_monstres[i].cells[2].firstChild.nodeValue;
  8036. }
  8037.  
  8038. function getMonstreIDByTR(tr) {
  8039. return tr.cells[2].firstChild.nodeValue;
  8040. }
  8041.  
  8042. function getMonstreLevelNode(i) {
  8043. return tr_monstres[i].cells[3];
  8044. }
  8045.  
  8046. // Roule 20/01/2017, à supprimer, remplacé par isMonstreLevelOutLimit
  8047. // function getMonstreLevel(i) {
  8048. // if(!isCDMsRetrieved) return -1;
  8049. // var donneesMonstre = listeCDM[getMonstreID(i)];
  8050. // return donneesMonstre ? parseInt(donneesMonstre[0]) : -1;
  8051. // }
  8052.  
  8053. function isMonstreLevelOutLimit(i, limitMin, limitMax) {
  8054. if(!isCDMsRetrieved) return false;
  8055. var donneesMonstre = listeCDM[getMonstreID(i)];
  8056. if (!donneesMonstre) return false;
  8057. var nivTxt = donneesMonstre[0];
  8058. // calcul min/max du monstre
  8059. var monstreMin, monstreMax, iPos;
  8060. if (nivTxt.substring(0, 2) == '<=') {
  8061. monstreMin = 0;
  8062. monstreMax = parseInt(nivTxt.substring(2, 99));
  8063. } else if ((iPos = nivTxt.indexOf('-')) > 0) {
  8064. monstreMin = parseInt(nivTxt.substring(0, iPos));
  8065. monstreMax = parseInt(nivTxt.substring(iPos+1, 99));
  8066. } else {
  8067. monstreMin = monstreMax = parseInt(nivTxt);
  8068. }
  8069. if (limitMin > 0 && monstreMax < limitMin) return true;
  8070. if (limitMax > 0 && monstreMin > limitMax) return true;
  8071. return false;
  8072. }
  8073.  
  8074. function getMonstreNomNode(i) {
  8075. try {
  8076. var td = document.evaluate(
  8077. "./td/a[starts-with(@href, 'javascript:EMV')]/..",
  8078. tr_monstres[i], null, 9, null
  8079. ).singleNodeValue;
  8080. return td;
  8081. } catch(e) {
  8082. avertissement('[getMonstreNomNode] Impossible de trouver le monstre '+i);
  8083. window.console.error(traceStack(e, 'getMonstreNomNode Impossible de trouver le monstre'+i));
  8084. }
  8085. }
  8086.  
  8087. function getMonstreNom(i) {
  8088. return getMonstreNomByTR(tr_monstres[i]);
  8089. }
  8090.  
  8091. function getMonstreNomByTR(tr) {
  8092. try {
  8093. var nom = document.evaluate(
  8094. "./td/a[starts-with(@href, 'javascript:EMV')]/text()",
  8095. tr, null, 2, null
  8096. ).stringValue;
  8097. return nom;
  8098. } catch(e) {
  8099. avertissement('[getMonstreNom] Impossible de trouver le monstre '+i);
  8100. window.console.error(traceStack(e, 'getMonstreNom Impossible de trouver le monstre '+i));
  8101. }
  8102. }
  8103.  
  8104. function getMonstrePosition(i) {
  8105. var tds = tr_monstres[i].childNodes;
  8106. var l = tds.length;
  8107. return [
  8108. parseInt(tds[l-3].textContent),
  8109. parseInt(tds[l-2].textContent),
  8110. parseInt(tds[l-1].textContent)
  8111. ];
  8112. }
  8113.  
  8114. function appendMonstres(txt) {
  8115. for(var i=1; i<=nbMonstres ; i++)
  8116. txt += getMonstreID(i)+';'+getMonstreNom(i)+';'+positionToString(getMonstrePosition(i))+'\n';
  8117. return txt;
  8118. }
  8119.  
  8120. function getMonstres() {
  8121. var vue = getVue();
  8122. return appendMonstres(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8123. }
  8124.  
  8125. function bddMonstres(start,stop) {
  8126. if(!start) { var start = 1; }
  8127. if(!stop) { var stop = nbMonstres; }
  8128. stop = Math.min(nbMonstres,stop);
  8129. var txt='';
  8130. for(var i=start ; i<=stop ; i++) {
  8131. txt += getMonstreID(i)+';'+
  8132. getMonstreNom(i)+';'+
  8133. positionToString(getMonstrePosition(i))+'\n';
  8134. }
  8135. return txt ? '#DEBUT MONSTRES\n'+txt+'#FIN MONSTRES\n' : '';
  8136. }
  8137.  
  8138. /* [functions] Récup données Trolls */
  8139. function getTrollDistance(i) {
  8140. return parseInt(tr_trolls[i].cells[0].textContent);
  8141. }
  8142.  
  8143. var MZ_cache_col_TrollID;
  8144. function getTrollID(i) {
  8145. // 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
  8146. if (MZ_cache_col_TrollID === undefined) {
  8147. if (tr_trolls[0].cells[1].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8148. MZ_cache_col_TrollID = 1;
  8149. } else if (tr_trolls[0].cells[2].textContent.toLowerCase().substring(0, 3) == 'réf') {
  8150. MZ_cache_col_TrollID = 2;
  8151. } else {
  8152. 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);
  8153. MZ_cache_col_TrollID = 2;
  8154. }
  8155. }
  8156. // Roule 08/03/2017 protection
  8157. var iTroll = parseInt(tr_trolls[i].cells[MZ_cache_col_TrollID].textContent)
  8158. if (isNaN(iTroll)) return;
  8159. if (iTroll == 0) return;
  8160. return iTroll;
  8161. }
  8162.  
  8163. function getTrollNomNode(i) {
  8164. var isEnvoiOn =
  8165. document.getElementById('btnEnvoi').parentNode.childNodes.length>1;
  8166. return tr_trolls[i].cells[ isEnvoiOn ? 4 : 3 ];
  8167. }
  8168.  
  8169. function getTrollNivNode(i) {
  8170. // Pas de test sur isEnvoiOn, n'est appelé qu'au pageload
  8171. return tr_trolls[i].cells[4];
  8172. }
  8173.  
  8174. function getTrollGuilde(i) {
  8175. return trim(tr_trolls[i].cells[6].textContent);
  8176. }
  8177.  
  8178. function getTrollGuildeID(i) {
  8179. if(tr_trolls[i].childNodes[6].childNodes.length>0) {
  8180. var href;
  8181. try {
  8182. 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"
  8183. href = tr_trolls[i].childNodes[6].firstChild.getAttribute('href');
  8184. } catch(e) { // debug pb remonté par Marsak
  8185. window.console.error(traceStack(e, 'getTrollGuildeID')
  8186. ,'nb child=' + tr_trolls[i].childNodes[6].childNodes.length
  8187. ,tr_trolls[i].innerHTML.replace(/</g, '‹'));
  8188. return -1;
  8189. }
  8190. return href.substring(href.indexOf('(')+1,href.indexOf(','));
  8191. }
  8192. return -1;
  8193. }
  8194.  
  8195. function getTrollPosition(i) {
  8196. var tds = tr_trolls[i].childNodes;
  8197. var l = tds.length;
  8198. return [
  8199. parseInt(tds[l-3].textContent),
  8200. parseInt(tds[l-2].textContent),
  8201. parseInt(tds[l-1].textContent)
  8202. ];
  8203. }
  8204.  
  8205. function bddTrolls() {
  8206. var txt='#DEBUT TROLLS\n'+
  8207. numTroll+';'+positionToString(getPosition())+'\n';
  8208. for(var i=1 ; i<=nbTrolls ; i++) {
  8209. txt += getTrollID(i)+';'+
  8210. positionToString(getTrollPosition(i))+'\n';
  8211. }
  8212. return txt+'#FIN TROLLS';
  8213. }
  8214.  
  8215. /* [functions] Récup données Trésors */
  8216. function getTresorDistance(i) {
  8217. return tr_tresors[i].cells[0].firstChild.nodeValue;
  8218. }
  8219.  
  8220. function getTresorID(i) {
  8221. return trim(tr_tresors[i].cells[2].textContent);
  8222. }
  8223.  
  8224. function getTresorNom(i) {
  8225. // Utilisation de textContent pour régler le "bug de Pollux"
  8226. return trim(tr_tresors[i].cells[3].textContent);
  8227. }
  8228.  
  8229. function getTresorPosition(i) {
  8230. var tds = tr_tresors[i].childNodes;
  8231. var l = tds.length;
  8232. return [
  8233. parseInt(tds[l-3].textContent),
  8234. parseInt(tds[l-2].textContent),
  8235. parseInt(tds[l-1].textContent),
  8236. ];
  8237. }
  8238.  
  8239. function bddTresors(dmin,start,stop) {
  8240. // On retire les trésors proches (dmin) pour Troogle à cause de leur description
  8241. if(!dmin) { var dmin = 0; }
  8242. if(!start) { var start = 1; }
  8243. if(!stop) { var stop = nbTresors; }
  8244. stop = Math.min(nbTresors,stop);
  8245. var txt='';
  8246. for(var i=start ; i<=stop ; i++) {
  8247. if(getTresorDistance(i)>=dmin) {
  8248. txt += getTresorID(i)+';'+
  8249. getTresorNom(i)+';'+
  8250. positionToString(getTresorPosition(i))+'\n';
  8251. }
  8252. }
  8253. return txt ? '#DEBUT TRESORS\n'+txt+'#FIN TRESORS\n' : '';
  8254. }
  8255.  
  8256. /* [functions] Récup données Champignons */
  8257. // DEBUG: Pas de colonne "Référence" sur serveur de test
  8258. function getChampignonNom(i) {
  8259. return trim(tr_champignons[i].cells[2].textContent);
  8260. }
  8261.  
  8262. function getChampignonPosition(i) {
  8263. var tds = tr_champignons[i].childNodes;
  8264. var l = tds.length;
  8265. return [
  8266. parseInt(tds[l-3].textContent),
  8267. parseInt(tds[l-2].textContent),
  8268. parseInt(tds[l-1].textContent)
  8269. ];
  8270. }
  8271.  
  8272. function bddChampignons() {
  8273. var txt='';
  8274. for(var i=1 ; i<=nbChampignons ; i++) {
  8275. txt += ';'+ // Les champis n'ont pas de Référence
  8276. getChampignonNom(i)+';'+
  8277. positionToString(getChampignonPosition(i))+'\n';
  8278. }
  8279. return txt ? '#DEBUT CHAMPIGNONS\n'+txt+'#FIN CHAMPIGNONS\n' : '';
  8280. }
  8281.  
  8282. /* [functions] Récup données Lieux */
  8283. function getLieuDistance(i) {
  8284. return parseInt(tr_lieux[i].cells[0].textContent);
  8285. }
  8286.  
  8287. function getLieuID(i) {
  8288. return parseInt(tr_lieux[i].cells[2].textContent);
  8289. }
  8290.  
  8291. function getLieuNom(i) {
  8292. // Conversion ASCII pour éviter les bugs des Vues externes
  8293. return trim(tr_lieux[i].cells[3].textContent);
  8294. }
  8295.  
  8296. function getLieuPosition(i) {
  8297. var tds = tr_lieux[i].childNodes;
  8298. var l = tds.length;
  8299. return [
  8300. parseInt(tds[l-3].textContent),
  8301. parseInt(tds[l-2].textContent),
  8302. parseInt(tds[l-1].textContent)
  8303. ];
  8304. }
  8305.  
  8306. function appendLieux(txt) {
  8307. for(var i = 1; i < nbLieux+1; i++) {
  8308. var tds = x_lieux[i].childNodes;
  8309. txt += tds[1].firstChild.nodeValue + ";" + getLieuNom(i) + ";" + tds[3].firstChild.nodeValue + ";"
  8310. + tds[4].firstChild.nodeValue + ";" + tds[5].firstChild.nodeValue + "\n";
  8311. }
  8312. return txt;
  8313. }
  8314.  
  8315. function getLieux() {
  8316. var vue = getVue();
  8317. return appendLieux(positionToString(getPosition()) + ";" + vue[0] + ";" + vue[1] + "\n");
  8318. }
  8319.  
  8320. function bddLieux(start,stop) {
  8321. if(!start) { var start = 1; }
  8322. if(!stop) { var stop = nbLieux; }
  8323. stop = Math.min(nbLieux,stop);
  8324. var txt='';
  8325. for(var i=start ; i<=stop ; i++) {
  8326. txt += getLieuID(i)+';'+
  8327. epure(getLieuNom(i))+';'+
  8328. positionToString(getLieuPosition(i))+'\n';
  8329. }
  8330. return txt ? '#DEBUT LIEUX\n'+txt+'#FIN LIEUX\n' : '';
  8331. }
  8332.  
  8333.  
  8334. /*-[functions]--------- Gestion Préférences Utilisateur ----------------------*/
  8335.  
  8336. function saveCheckBox(chkbo, pref) {
  8337. // Enregistre et retourne l'état d'une CheckBox
  8338. var etat = chkbo.checked;
  8339. MY_setValue(pref, etat ? 'true' : 'false' );
  8340. return etat;
  8341. }
  8342.  
  8343. function recallCheckBox(chkbox, pref) {
  8344. // Restitue l'état d'une CheckBox
  8345. chkbox.checked = (MY_getValue(pref)=='true');
  8346. }
  8347.  
  8348. function saveComboBox(cbb, pref) {
  8349. // Enregistre et retourne l'état d'une ComboBox
  8350. var etat = cbb.selectedIndex;
  8351. MY_setValue(pref, etat);
  8352. return etat;
  8353. }
  8354.  
  8355. function recallComboBox(cbb, pref) {
  8356. // Restitue l'état d'une ComboBox
  8357. var nb = MY_getValue(pref);
  8358. if(nb) cbb.value = nb;
  8359. return nb;
  8360. }
  8361.  
  8362. function synchroniseFiltres() {
  8363. // Récupération de toutes les options de la vue
  8364. var numBool = recallComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  8365. numBool = recallComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE') || numBool;
  8366. if(numBool) {
  8367. debutFiltrage('Monstres');
  8368. }
  8369. recallCheckBox(checkBoxGowapsS,'NOGOWAPS');
  8370. recallCheckBox(checkBoxGowapsA,'NOGOWAPA');
  8371. recallCheckBox(checkBoxMythiques,'NOMYTH');
  8372. recallCheckBox(checkBoxEngages,'NOENGAGE');
  8373. recallCheckBox(checkBoxLevels,'NOLEVEL');
  8374. recallCheckBox(checkBoxIntangibles,'NOINT');
  8375. recallCheckBox(checkBoxGG,'NOGG');
  8376. recallCheckBox(checkBoxCompos,'NOCOMP');
  8377. recallCheckBox(checkBoxBidouilles,'NOBID');
  8378. recallCheckBox(checkBoxDiplo,numTroll+'.diplo.off');
  8379. recallCheckBox(checkBoxTrou,'NOTROU');
  8380. recallCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  8381. recallCheckBox(checkBoxTactique,'NOTACTIQUE');
  8382. if(MY_getValue('NOINFOEM')!='true')
  8383. recallCheckBox(checkBoxEM,'NOEM');
  8384. }
  8385.  
  8386.  
  8387. /*-[functions]-------- Initialisation: Ajout des Boutons ---------------------*/
  8388.  
  8389. function getVueScript() {
  8390. try {
  8391. var txt = bddTrolls()+
  8392. bddMonstres()+
  8393. bddChampignons()+
  8394. bddTresors()+
  8395. bddLieux()+
  8396. '#DEBUT ORIGINE\n'+
  8397. getPorteVue()[2]+';'+positionToString(getPosition())+
  8398. '\n#FIN ORIGINE\n';
  8399. window.console.log('[MZd ' + GM_info.script.version + '] fin getVueScript');
  8400. return txt;
  8401. } catch(e) {
  8402. avertissement("[getVueScript] Erreur d'export vers Vue externe");
  8403. window.console.error(traceStack(e, 'getVueScript'))
  8404. }
  8405. }
  8406.  
  8407. /* [functions] Menu Vue 2D */
  8408. var vue2Ddata = {
  8409. 'Bricol\' Vue': {
  8410. url: URL_bricol_mountyhall + 'vue_form.php',
  8411. paramid: 'vue',
  8412. func: getVueScript,
  8413. extra_params: {
  8414. 'mode': 'vue_SP_Vue2',
  8415. 'screen_width': window.screen.width
  8416. }
  8417. },
  8418. 'Vue du CCM': {
  8419. url: URL_vue_CCM,
  8420. paramid: 'vue',
  8421. func: getVueScript,
  8422. extra_params: {
  8423. 'id': numTroll+';'+positionToString(getPosition())
  8424. }
  8425. },
  8426. 'Vue Gloumfs 2D': {
  8427. url: URL_vue_Gloumfs2D,
  8428. paramid: 'vue_mountyzilla',
  8429. func: getVueScript,
  8430. extra_params: {}
  8431. },
  8432. 'Vue Gloumfs 3D': {
  8433. url: URL_vue_Gloumfs3D,
  8434. paramid: 'vue_mountyzilla',
  8435. func: getVueScript,
  8436. extra_params: {}
  8437. },
  8438. 'Grouky Vue!': {
  8439. url: URL_vue_Grouky,
  8440. paramid: 'vue',
  8441. func: getVueScript,
  8442. extra_params: {
  8443. 'type_vue': 'V5b1'
  8444. }
  8445. },
  8446. /*'DEBUG': {
  8447. url: 'http://weblocal/testeur.php',
  8448. paramid: 'vue',
  8449. func: getVueScript,
  8450. extra_params: {}
  8451. }*/
  8452. };
  8453.  
  8454. function refresh2DViewButton() {
  8455. // = EventListener menu+bouton vue 2D
  8456. var vueext = document.getElementById('selectVue2D').value;
  8457. MY_setValue('VUEEXT',vueext);
  8458. var form = document.getElementById('viewForm');
  8459. form.innerHTML = '';
  8460. form.method = 'post';
  8461. form.action = vue2Ddata[vueext].url;
  8462. form.target = '_blank';
  8463. appendHidden(form, vue2Ddata[vueext].paramid, '');
  8464. for(var key in vue2Ddata[vueext].extra_params) {
  8465. appendHidden(form, key, vue2Ddata[vueext].extra_params[key]);
  8466. }
  8467. appendSubmit(form, 'Voir',
  8468. function() {
  8469. window.console.log('[MZd ' + GM_info.script.version + '] click voir vue externe');
  8470. document.getElementsByName(vue2Ddata[vueext].paramid)[0].value =
  8471. vue2Ddata[vueext].func();
  8472. }
  8473. );
  8474. }
  8475.  
  8476. function set2DViewSystem() {
  8477. // Initialise le système de vue 2D
  8478. // Recherche du point d'insertion
  8479. try {
  8480. var center = document.evaluate(
  8481. "//h2[@id='titre2']/following-sibling::center",
  8482. document, null, 9, null
  8483. ).singleNodeValue;
  8484. // Roule 09/12/2016 J'ai remplacé following-sibling::center par following-sibling::div suite à une modification MH
  8485. if (!center) center = document.evaluate(
  8486. "//h2[@id='titre2']/following-sibling::div",
  8487. document, null, 9, null
  8488. ).singleNodeValue;
  8489. } catch(e) {
  8490. avertissement("Erreur d'initialisation du système de vue 2D");
  8491. window.console.error(traceStack(e, 'set2DViewSystem'));
  8492. return;
  8493. }
  8494. // Récupération de la dernière vue utilisée
  8495. var vueext = MY_getValue('VUEEXT');
  8496. if(!vueext || !vue2Ddata[vueext]) {
  8497. // sinon, la vue Bricol'Trolls est employée par défaut
  8498. vueext = 'Bricol\' Vue';
  8499. }
  8500. try {
  8501. // Création du sélecteur de vue externe
  8502. selectVue2D = document.createElement('select');
  8503. selectVue2D.id = 'selectVue2D';
  8504. selectVue2D.className = 'SelectboxV2';
  8505. window.console.log('[MZd ' + GM_info.script.version + '] préparation ' + Object.keys(vue2Ddata).length + ' types de vue');
  8506. for(var view in vue2Ddata) {
  8507. appendOption(selectVue2D, view, view);
  8508. }
  8509. selectVue2D.value = vueext;
  8510. selectVue2D.onchange = refresh2DViewButton;
  8511. // Création du formulaire d'envoi (vide, le submit est géré via handler)
  8512. var form = document.createElement('form');
  8513. form.id = 'viewForm';
  8514. // Insertion du système de vue
  8515. var table = document.createElement('table');
  8516. var tr = appendTr(table);
  8517. var td = appendTd(tr);
  8518. td.appendChild(selectVue2D);
  8519. td = appendTd(tr);
  8520. td.style.fontSize = '0px'; // gère le bug de l'extra character
  8521. td.appendChild(form);
  8522. center.insertBefore(table,center.firstChild);
  8523. insertBr(center.childNodes[1]);
  8524. // Appelle le handler pour initialiser le bouton de submit
  8525. refresh2DViewButton();
  8526. window.console.log('[MZd ' + GM_info.script.version + '] fin préparation des vues externes');
  8527. } catch(e) {
  8528. avertissement("Erreur de traitement du système de vue 2D");
  8529. window.console.error(traceStack(e, 'set2DViewSystem'));
  8530. }
  8531. }
  8532.  
  8533. /* [functions] Tableau d'Infos */
  8534. function initialiseInfos() {
  8535. // DEBUG: prévoir désactivation complète du script si infoTab non trouvé
  8536. var
  8537. infoTab = document.getElementsByName('LimitViewForm')[0].
  8538. getElementsByTagName('table')[0],
  8539. tbody = infoTab.tBodies[0],
  8540. thead = infoTab.createTHead(),
  8541. tr = appendTr(thead,'mh_tdtitre'),
  8542. td = appendTdText(tr,'INFORMATIONS',true),
  8543. span = document.createElement('span');
  8544. // Récupération de la position du joueur
  8545. try {
  8546. var strPos = document.evaluate(
  8547. ".//li/b/text()[contains(.,'X = ')]",
  8548. infoTab, null, 9, null
  8549. ).singleNodeValue.nodeValue;
  8550. // ***INIT GLOBALE*** currentPosition
  8551. currentPosition = getNumbers(strPos);
  8552. debugMZ("retrievePosition(): "+currentPosition);
  8553. } catch(e) {
  8554. // Si on ne trouve pas le "X ="
  8555. window.console.error(traceStack(e, 'Vue Position joueur non trouvée'));
  8556. }
  8557. // Récupération des portées (max et limitée) de la vue
  8558. try {
  8559. var
  8560. nodes = document.evaluate(
  8561. ".//li/b/text()[contains(.,'horizontalement') "+
  8562. "or contains(.,'verticalement')]",
  8563. infoTab, null, 7, null
  8564. ),
  8565. array = [];
  8566. for(var i=0 ; i<4 ; i++) {
  8567. array.push(parseInt(nodes.snapshotItem(i).nodeValue));
  8568. }
  8569. // ***INIT GLOBALE*** porteeVue
  8570. porteeVue = array;
  8571. } catch(e) {
  8572. window.console.error(traceStack(e, 'Vue Portées Vue non trouvée'));
  8573. }
  8574.  
  8575. infoTab.id = 'infoTab'; // Pour scripts externes
  8576. tbody.id = 'corpsInfoTab';
  8577. tbody.rows[0].cells[0].colSpan = 2;
  8578. td.colSpan = 3;
  8579. td.onmouseover = function() {
  8580. this.style.cursor = 'pointer';
  8581. this.className = 'mh_tdpage';
  8582. };
  8583. td.onmouseout = function() {
  8584. this.className = 'mh_tdtitre';
  8585. };
  8586. td.onclick = function() {
  8587. toggleTableauInfos(false);
  8588. };
  8589. span.id = 'msgInfoTab';
  8590. span.style.display = 'none';
  8591. appendText(
  8592. span,
  8593. ' => Position : X = '+currentPosition[0]+
  8594. ', Y = '+currentPosition[1]+
  8595. ', N = '+currentPosition[2]+
  8596. ' --- Vue : '+porteeVue[0]+'/'+porteeVue[1]+
  8597. ' ('+porteeVue[2]+'/'+porteeVue[3]+')',
  8598. true
  8599. );
  8600. td.appendChild(span);
  8601. tr = appendTr(tbody,'mh_tdpage');
  8602. td = appendTdText(tr,'EFFACER : ',true);
  8603. td.align = 'center';
  8604. td.className = 'mh_tdtitre';
  8605. td.width = 100;
  8606. td = appendTdCenter(tr,2);
  8607. // DEBUG : à quoi servent les ids si on utilise des var globales ?
  8608. checkBoxGG = appendCheckBoxSpan(
  8609. td,'delgg',filtreTresors," Les GG'"
  8610. ).firstChild;
  8611. checkBoxCompos = appendCheckBoxSpan(
  8612. td,'delcomp',filtreTresors,' Les Compos'
  8613. ).firstChild;
  8614. checkBoxBidouilles = appendCheckBoxSpan(
  8615. td,'delbid',filtreTresors,' Les Bidouilles'
  8616. ).firstChild;
  8617. checkBoxIntangibles = appendCheckBoxSpan(
  8618. td,'delint',filtreTrolls,' Les Intangibles'
  8619. ).firstChild;
  8620. checkBoxGowapsA = appendCheckBoxSpan(
  8621. td,'delgowapA',filtreMonstres,' Les Gowaps Apprivoisés'
  8622. ).firstChild;
  8623. checkBoxGowapsS = appendCheckBoxSpan(
  8624. td,'delgowapS',filtreMonstres,' Les Gowaps Sauvages'
  8625. ).firstChild;
  8626. checkBoxEngages = appendCheckBoxSpan(
  8627. td,'delengage',filtreMonstres,' Les Engagés'
  8628. ).firstChild;
  8629. checkBoxLevels = appendCheckBoxSpan(
  8630. td,'delniveau',toggleLevelColumn,' Les Niveaux'
  8631. ).firstChild;
  8632. checkBoxDiplo = appendCheckBoxSpan(
  8633. td,'delDiplo',refreshDiplo,' La Diplomatie'
  8634. ).firstChild;
  8635. checkBoxTrou = appendCheckBoxSpan(
  8636. td,'deltrou',filtreLieux,' Les Trous'
  8637. ).firstChild;
  8638. checkBoxMythiques = appendCheckBoxSpan(
  8639. td,'delmyth',filtreMonstres,' Les Mythiques'
  8640. ).firstChild;
  8641. if(MY_getValue('NOINFOEM')!='true') {
  8642. checkBoxEM = appendCheckBoxSpan(
  8643. td,'delem',filtreMonstres,' Les Composants EM'
  8644. ).firstChild;
  8645. }
  8646. checkBoxTresorsNonLibres = appendCheckBoxSpan(
  8647. td,'deltres',filtreTresors,' Les Trésors non libres'
  8648. ).firstChild;
  8649. checkBoxTactique = appendCheckBoxSpan(
  8650. td,'deltactique',updateTactique,' Les Infos tactiques'
  8651. ).firstChild;
  8652. if(MY_getValue('INFOPLIE')) {
  8653. toggleTableauInfos(true);
  8654. }
  8655. }
  8656.  
  8657. function toggleTableauInfos(firstRun) {
  8658. var
  8659. msg = document.getElementById('msgInfoTab'),
  8660. corps = document.getElementById('corpsInfoTab'),
  8661. infoplie = parseInt(MY_getValue('INFOPLIE')); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8662. //window.console.log('toggleTableauInfos(' + firstRun + '), début, INFOPLIE=' + MY_getValue('INFOPLIE') + ', !INFOPLIE=' + !MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // debug Roule
  8663. if(!firstRun) {
  8664. infoplie = !infoplie;
  8665. MY_setValue('INFOPLIE', infoplie ? 1 : 0); // 27/032016 Roule, pb sur récupération booléen, force numérique
  8666. //window.console.log('toggleTableauInfos(' + firstRun + '), après toggle et set, INFOPLIE=' + MY_getValue('INFOPLIE') + ', infoplie=' + infoplie); // Debug Roule
  8667. }
  8668. if(infoplie) {
  8669. msg.style.display = '';
  8670. corps.style.display = 'none';
  8671. } else {
  8672. msg.style.display = 'none';
  8673. corps.style.display = '';
  8674. }
  8675. }
  8676.  
  8677. /* [functions] Filtres */
  8678. function prepareFiltrage(ref,width) {
  8679. // = Initialise le filtre 'ref'
  8680. try {
  8681. var tdTitre = document.getElementsByName(ref.toLowerCase())[0].parentNode;
  8682. } catch(e) {
  8683. window.console.warn('[prepareFiltrage] Référence filtrage '+ref+' non trouvée\n'+e);
  8684. return false;
  8685. }
  8686. if(width) { tdTitre.width = width; }
  8687. // Ajout du tr de Filtrage (masqué)
  8688. var tbody = tdTitre.parentNode.parentNode;
  8689. var tr = appendTr(tbody,'mh_tdpage');
  8690. tr.style.display = 'none';
  8691. tr.id = 'trFiltre'+ref;
  8692. var td = appendTd(tr);
  8693. td.colSpan = 5;
  8694. // Ajout du bouton de gestion de Filtrage
  8695. var tdBtn = insertTd(tdTitre.nextSibling);
  8696. tdBtn.id = 'tdInsert'+ref;
  8697. var btn = appendButton(tdBtn,'Filtrer');
  8698. btn.id = 'btnFiltre'+ref;
  8699. btn.onclick = function() {
  8700. debutFiltrage(ref)
  8701. };
  8702. return td;
  8703. }
  8704.  
  8705. function debutFiltrage(ref) {
  8706. // = Handler de début de filtrage (filtre 'ref')
  8707. document.getElementById('trFiltre'+ref).style.display = '';
  8708. var btn = document.getElementById('btnFiltre'+ref);
  8709. btn.value = 'Annuler Filtre';
  8710. btn.onclick = function() {
  8711. finFiltrage(ref);
  8712. };
  8713. }
  8714.  
  8715. function finFiltrage(ref) {
  8716. // = Handler de fin de filtrage (filtre 'ref')
  8717. /* On réassigne le bouton 'Filtrer' */
  8718. document.getElementById('trFiltre'+ref).style.display = 'none';
  8719. var btn = document.getElementById('btnFiltre'+ref);
  8720. btn.value = 'Filtrer';
  8721. btn.onclick = function() {
  8722. debutFiltrage(ref);
  8723. };
  8724. /* Réinitialisation filtres */
  8725. document.getElementById('str'+ref).value = '';
  8726. switch(ref) {
  8727. case 'Monstres':
  8728. document.getElementById('nivMinMonstres').value = 0;
  8729. document.getElementById('nivMaxMonstres').value = 0;
  8730. break;
  8731. case 'Trolls':
  8732. document.getElementById('strGuildes').value = '';
  8733. }
  8734. /* Nettoyage (=lance le filtre) */
  8735. // Ici this = MZ.global = sandBox de travail de MZ
  8736. // Roule 11/03/2016, ne fonctionne plus, il faut traiter les cas
  8737. //this['filtre'+ref]();
  8738. switch (ref) {
  8739. case 'Monstres':
  8740. filtreMonstres();
  8741. break;
  8742. case 'Trolls':
  8743. filtreTrolls();
  8744. break;
  8745. case 'Tresors':
  8746. filtreTresors();
  8747. break;
  8748. case 'Lieux':
  8749. filtreLieux();
  8750. break;
  8751. default:
  8752. window.console.log('cas incongru dans finFiltrage : ' + ref);
  8753. break;
  8754. }
  8755. }
  8756.  
  8757. function ajoutFiltreStr(td,nomBouton,id,onClick) {
  8758. var bouton = appendButton(td,nomBouton,onClick);
  8759. appendText(td,'\u00a0');
  8760. var textbox = appendTextbox(td,'text',id,15,30);
  8761. textbox.onkeypress = function(event) {
  8762. try {
  8763. if(event.keyCode==13) {
  8764. event.preventDefault();
  8765. bouton.click();
  8766. }
  8767. }
  8768. catch(e){
  8769. window.alert(e)
  8770. }
  8771. };
  8772. }
  8773.  
  8774. function ajoutFiltreMenu(tr,id,onChange) {
  8775. var select = document.createElement('select');
  8776. select.id = id;
  8777. select.onchange = onChange;
  8778. appendOption(select,0,'Aucun');
  8779. for(var i=1 ; i<=60 ; i++) {
  8780. appendOption(select,i,i);
  8781. }
  8782. tr.appendChild(select);
  8783. return select;
  8784. }
  8785.  
  8786. function ajoutDesFiltres() {
  8787. /* Monstres */
  8788. var td = prepareFiltrage('Monstres',120);
  8789. if(td) {
  8790. ajoutFiltreStr(td,'Nom du monstre:','strMonstres',filtreMonstres);
  8791. appendText(td,'\u00a0\u00a0\u00a0');
  8792. appendText(td,'Niveau Min: ');
  8793. comboBoxNiveauMin = ajoutFiltreMenu(td,'nivMinMonstres',filtreMonstres);
  8794. appendText(td,'\u00a0');
  8795. appendText(td,'Niveau Max: ');
  8796. comboBoxNiveauMax = ajoutFiltreMenu(td,'nivMaxMonstres',filtreMonstres);
  8797. }
  8798. /* Trõlls */
  8799. td = prepareFiltrage('Trolls',50);
  8800. if(td) {
  8801. ajoutFiltreStr(td,'Nom du trõll:','strTrolls',filtreTrolls);
  8802. appendText(td,'\u00a0\u00a0\u00a0');
  8803. ajoutFiltreStr(td,'Nom de guilde:','strGuildes',filtreTrolls);
  8804. }
  8805. /* Trésors */
  8806. td = prepareFiltrage('Tresors',55);
  8807. if(td) {
  8808. ajoutFiltreStr(td,'Nom du trésor:','strTresors',filtreTresors);
  8809. }
  8810. /* Lieux */
  8811. td = prepareFiltrage('Lieux',40);
  8812. if(td) {
  8813. ajoutFiltreStr(td,'Nom du lieu:','strLieux',filtreLieux);
  8814. }
  8815. }
  8816.  
  8817. /*-[functions]--------------- Fonctions Monstres -----------------------------*/
  8818.  
  8819. /* [functions] Affichage de la colonne des niveaux */
  8820. function insertLevelColumn() {
  8821. // Déclenché si bascule vers affichage des niveaux des mobs
  8822. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8823. var td = insertTdText(getMonstreLevelNode(0),'Niveau',true);
  8824. td.width = 25;
  8825. for(var i=1 ; i<=nbMonstres ; i++) {
  8826. //window.console.log('nbMonstres=' + nbMonstres + ', tr_monstres.length=' + tr_monstres.length); // debug Roule
  8827. td = insertTdText(getMonstreLevelNode(i), '-');
  8828. td.onclick = function() {
  8829. basculeCDM(
  8830. getMonstreNomByTR(this.parentNode),
  8831. getMonstreIDByTR(this.parentNode)
  8832. );
  8833. };
  8834. td.onmouseover = function() {
  8835. this.style.cursor = 'pointer';
  8836. this.className = 'mh_tdtitre';
  8837. };
  8838. td.onmouseout = function() {
  8839. if(this.parentNode.diploActive=='oui') {
  8840. this.className = '';
  8841. } else {
  8842. this.className = 'mh_tdpage';
  8843. }
  8844. };
  8845. td.style = 'font-weight:bold;text-align:center;';
  8846. if(isCDMsRetrieved) {
  8847. // Rappel des niveaux si mémorisés
  8848. td.innerHTML = listeLevels[i];
  8849. }
  8850. }
  8851. }
  8852.  
  8853. function toggleLevelColumn() {
  8854. // = Handler checkBox noLevel
  8855. if(!saveCheckBox(checkBoxLevels,'NOLEVEL')) {
  8856. insertLevelColumn();
  8857. if(!isCDMsRetrieved) { retrieveCDMs(); }
  8858. } else if(getMonstreLevelNode(0).textContent=='Niveau') {
  8859. for(var i=0 ; i<=nbMonstres ; i++) {
  8860. if(isCDMsRetrieved) {
  8861. // Mémorisation des niveaux pour rappel éventuel
  8862. listeLevels[i] = getMonstreLevelNode(i).innerHTML;
  8863. }
  8864. // Suppression du td Niveau
  8865. tr_monstres[i].removeChild(getMonstreLevelNode(i));
  8866. }
  8867. }
  8868. }
  8869.  
  8870. /* [functions] Gestion de l'AFFICHAGE des CdMs */
  8871. function basculeCDM(nom,id) {
  8872. // = Bascule l'affichage des popups CdM
  8873. if(listeCDM[id]) {
  8874. if(!document.getElementById('popupCDM'+id)) {
  8875. afficherCDM(nom, id);
  8876. } else {
  8877. cacherPopupCDM('popupCDM'+id);
  8878. }
  8879. }
  8880. // DEBUG: prévoir un "else" ou désactiver l'effet onmouseover si pas de CdM
  8881. }
  8882.  
  8883. function cacherPopupCDM(titre) {
  8884. var popup = document.getElementById(titre);
  8885. popup.parentNode.removeChild(popup);
  8886. }
  8887.  
  8888. /* DEBUG: Section à mettre à jour */
  8889. var selectionFunction;
  8890.  
  8891. function startDrag(evt) {
  8892. winCurr = this.parentNode;
  8893. evt = evt || window.event; // est-ce utile sous FF ? sous FF24+ ?
  8894. offsetX = evt.pageX - parseInt( winCurr.style.left );
  8895. offsetY = evt.pageY - parseInt( winCurr.style.top );
  8896. selectionFunction = document.body.style.MozUserSelect;
  8897. document.body.style.MozUserSelect = 'none';
  8898. winCurr.style.MozUserSelect = 'none';
  8899. return false;
  8900. }
  8901.  
  8902. function stopDrag(evt) {
  8903. winCurr.style.MozUserSelect = selectionFunction;
  8904. document.body.style.MozUserSelect = selectionFunction;
  8905. winCurr = null;
  8906. }
  8907.  
  8908. function drag(evt) {
  8909. if(winCurr==null) { return; }
  8910. evt = evt || window.event;
  8911. winCurr.style.left = (evt.pageX - offsetX)+'px';
  8912. winCurr.style.top = (evt.pageY - offsetY)+'px';
  8913. return false;
  8914. }
  8915. /* FIN DEBUG */
  8916. document.onmousemove = drag;
  8917.  
  8918. function afficherCDM(nom,id) {
  8919. // Crée la table de CdM du mob n° id
  8920. var donneesMonstre = listeCDM[id];
  8921. /* Début création table */
  8922. var table = createCDMTable(id,nom,donneesMonstre); // voir Libs
  8923. table.id = 'popupCDM'+id;
  8924. table.style =
  8925. 'position:fixed;'+
  8926. 'z-index:1;'+
  8927. 'top:'+(300+(30*nbCDM))%(30*Math.floor((window.innerHeight-400)/30))+'px;'+
  8928. 'left:'+(window.innerWidth-365)+'px;'+
  8929. 'width:300px;'+
  8930. 'height:200px;';
  8931. /* Ajout du titre avec gestion Drag & Drop */
  8932. var tr = table.firstChild;
  8933. tr.style.cursor = 'move';
  8934. tr.onmousedown = startDrag;
  8935. tr.onmouseup = stopDrag;
  8936. /* Ajout du bouton "Fermer" */
  8937. tr = appendTr(table.childNodes[1], 'mh_tdtitre');
  8938. tr.onmouseover = function() {
  8939. this.style.cursor = 'pointer';
  8940. this.className = 'mh_tdpage';
  8941. };
  8942. tr.onmouseout = function() {
  8943. this.className = 'mh_tdtitre';
  8944. };
  8945. tr.idcdm = id;
  8946. tr.onclick = function() {
  8947. cacherPopupCDM('popupCDM'+this.idcdm);
  8948. this.className = 'mh_tdtitre';
  8949. };
  8950. td = appendTdText(tr,'Fermer',true);
  8951. td.colSpan = 2;
  8952. td.style = 'text-align:center;';
  8953. nbCDM++;
  8954. /* Fin création table & Affichage */
  8955. document.body.appendChild(table);
  8956. }
  8957.  
  8958. /* [functions] Gestion de l'AFFICHAGE des Infos de combat */
  8959. function initPopupVue() {
  8960. popup = document.createElement('div');
  8961. popup.id = 'popup';
  8962. popup.className = 'mh_textbox';
  8963. popup.style =
  8964. 'position: absolute;'+
  8965. 'border: 1px solid #000000;'+
  8966. 'visibility: hidden;'+
  8967. 'display: inline;'+
  8968. 'z-index: 3;'+
  8969. 'max-width: 400px;';
  8970. document.body.appendChild(popup);
  8971. }
  8972.  
  8973. /* [functions] Récupération / Computation des Infos Tactiques */
  8974. // TODO à revoir
  8975. function retireMarquage(nom) {
  8976. var i = nom.indexOf(']');
  8977. switch(i) {
  8978. case -1:
  8979. case nom.length-1:
  8980. return nom;
  8981. default:
  8982. return nom.slice(0,i+1);
  8983. }
  8984. }
  8985.  
  8986. function showPopupError(sHTML) {
  8987. window.console.log('[MZ] affichage PopupError ' + sHTML);
  8988. var divpopup = document.createElement('div');
  8989. divpopup.id = 'divpopup';
  8990. divpopup.style =
  8991. 'position: fixed;'+
  8992. 'border: 3px solid #000000;'+
  8993. 'top: 300px;left: 10px;'+
  8994. 'background-color: red;'+
  8995. 'color: white;'+
  8996. 'font-size: xx-large;'+
  8997. 'z-index: 200;';
  8998. divpopup.innerHTML = sHTML;
  8999. var divcroix = document.createElement('div');
  9000. divcroix.style =
  9001. 'position: absolute;'+
  9002. 'top: 0;right: 0;'+
  9003. 'color: inherit;'+
  9004. 'font-size: inherit;'+
  9005. 'cursor: pointer;'+
  9006. 'z-index: 201;';
  9007. divcroix.innerHTML = "X";
  9008. divcroix.onclick = function () {document.getElementById('divpopup').style.display = 'none';};
  9009. document.body.appendChild(divpopup);
  9010. divpopup.appendChild(divcroix);
  9011. }
  9012.  
  9013. function retrieveCDMs() {
  9014. // Récupère les CdM disponibles dans la BDD
  9015. // Lancé uniquement sur toggleLevelColumn
  9016. if(checkBoxLevels.checked) { return; }
  9017. var str = '';
  9018. var begin = 1; // num de début de lot si plusieurs lots de CdM (501+ CdM)
  9019. var cdmMax = MY_getValue(numTroll+'.MAXCDM');
  9020. cdmMax = Math.min(nbMonstres, cdmMax ? cdmMax : 500);
  9021. if(MY_getValue('CDMID')==null) MY_setValue('CDMID',1); // à quoi sert CDMID ??
  9022. for(var i=1 ; i<=cdmMax ; i++) {
  9023. var nomMonstre = retireMarquage(getMonstreNom(i));
  9024. if(nomMonstre.indexOf(']') != -1) {
  9025. nomMonstre = nomMonstre.slice(0,nomMonstre.indexOf(']')+1);
  9026. }
  9027. // *** WARNING : PROXY RATIBUS ***
  9028. // *** NE PAS CHANGER la fonction obsolète 'escape' ***
  9029. str += 'nom[]='+escape(nomMonstre)+'$'+(
  9030. getMonstreDistance(i)<=5 ? getMonstreID(i) : -getMonstreID(i)
  9031. )+'&';
  9032. if(i%500==0 || i==cdmMax) { // demandes de CdM par lots de 500 max
  9033. FF_XMLHttpRequest({
  9034. method: 'POST',
  9035. url: URL_MZinfoMonstre,
  9036. headers : {
  9037. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  9038. 'Accept': 'application/atom+xml,application/xml,text/xml',
  9039. 'Content-type':'application/x-www-form-urlencoded'
  9040. },
  9041. data: 'begin='+begin+'&idcdm='+MY_getValue('CDMID')+'&'+str,
  9042. onload: function(responseDetails) {
  9043. try {
  9044. //window.console.log('retrieveCDMs readyState=' + responseDetails.readyState + ', error=' + responseDetails.error + ', status=' + responseDetails.status);
  9045. if (responseDetails.status == 0 && isHTTPS) { // ça donne ça sur une erreur de certificat HTTPS
  9046. showPopupError('<a style="color:inherit;font-size: inherits;" href="' + URL_CertifRaistlin1 +
  9047. '" target="raistlin">Mountyzilla - https<br />'+
  9048. 'Tu dois accepter le certificat de Raistlin<br />'+
  9049. 'clique ici<br />puis « Avancé » ... « Ajouter une exception » ...'+
  9050. ' « Confirmer l\'exception de sécurité »</a>');
  9051. return;
  9052. }
  9053. var texte = responseDetails.responseText;
  9054. var lines = texte.split('\n');
  9055. if(lines.length==0) { return; }
  9056. var begin2, end2, index;
  9057. for(var j=0 ; j<lines.length ; j++) {
  9058. var infos = lines[j].split(';');
  9059. if(infos.length<4) { continue; }
  9060. var idMonstre=infos[0];
  9061. var isCDM = infos[1];
  9062. index = parseInt(infos[2]);
  9063. var level = infos[3];
  9064. infos = infos.slice(3);
  9065. if(begin2==null) { begin2 = index; }
  9066. end2 = index;
  9067. listeCDM[idMonstre] = infos;
  9068. if(isCDM==1) {
  9069. getMonstreLevelNode(index).innerHTML = '<i>'+level+'</i>';
  9070. } else {
  9071. getMonstreLevelNode(index).innerHTML = level;
  9072. }
  9073. }
  9074. computeMission(begin2,end2);
  9075. filtreMonstres(); // ajout Roule' 20/01/2017 car il y a des cas où les données arrivent après le filtrage
  9076. } catch(e) {
  9077. window.console.error(traceStack(e, 'retrieveCDMs')+'\n'+URL_MZinfoMonstre+'\n'+texte);
  9078. }
  9079. }
  9080. });
  9081. str = '';
  9082. begin = i+1;
  9083. }
  9084. }
  9085. isCDMsRetrieved=true;
  9086. }
  9087.  
  9088. function computeMission(begin,end) {
  9089. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance
  9090. computeVLC(begin,end);
  9091. if(!begin) begin=1;
  9092. if(!end) end=nbMonstres;
  9093. var str = MY_getValue(numTroll+'.MISSIONS');
  9094. if(!str) { return; }
  9095. var urlImg = URL_MZimg+'mission.png';
  9096. var obMissions = JSON.parse(str);
  9097. for(var i=end ; i>=begin ; i--) {
  9098. var mess = '';
  9099. for(var num in obMissions) {
  9100. var mobMission = false;
  9101. switch(obMissions[num].type) {
  9102. case 'Race':
  9103. var race = epure(obMissions[num].race.toLowerCase());
  9104. var nom = epure(getMonstreNom(i).toLowerCase());
  9105. if(nom.indexOf(race)!=-1) {
  9106. mobMission = true;
  9107. }
  9108. break;
  9109. case 'Niveau':
  9110. var donneesMonstre = listeCDM[getMonstreID(i)];
  9111. if(donneesMonstre) {
  9112. var nivMob = Number(donneesMonstre[0]);
  9113. var nivMimi = Number(obMissions[num].niveau),
  9114. mod = obMissions[num].mod;
  9115. if((!isNaN(mod) && Math.abs(nivMimi-nivMob)<=Number(mod))
  9116. || (isNaN(mod) && nivMob>=nivMimi)) {
  9117. mobMission = true;
  9118. }
  9119. }
  9120. break;
  9121. case 'Famille':
  9122. var donneesMonstre = listeCDM[getMonstreID(i)];
  9123. if(donneesMonstre) {
  9124. var familleMimi = epure(obMissions[num].famille.toLowerCase());
  9125. var familleMob = epure(donneesMonstre[1].toLowerCase());
  9126. if(familleMob.indexOf(familleMimi)!=-1) {
  9127. mobMission = true;
  9128. }
  9129. }
  9130. break;
  9131. case 'Pouvoir':
  9132. var donneesMonstre = listeCDM[getMonstreID(i)];
  9133. if(donneesMonstre) {
  9134. var pvrMimi = epure(obMissions[num].pouvoir.toLowerCase());
  9135. var pvrMob = epure(donneesMonstre[10].toLowerCase());
  9136. if(pvrMob.indexOf(pvrMimi)!=-1) {
  9137. mobMission = true;
  9138. }
  9139. }
  9140. }
  9141. if(mobMission) {
  9142. mess += mess ? '\n\n' : '';
  9143. mess += 'Mission '+num+' :\n'+obMissions[num].libelle;
  9144. }
  9145. }
  9146. if(mess) {
  9147. var td = getMonstreNomNode(i);
  9148. appendText(td,' ');
  9149. td.appendChild(createImage(urlImg,mess));
  9150. }
  9151. }
  9152. }
  9153.  
  9154. function computeVLC(begin,end) {
  9155. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeMission
  9156. computeTactique(begin,end);
  9157. if(!begin) begin=1;
  9158. if(!end) end=nbMonstres;
  9159. var cache = getSortComp("Invisibilité")>0 || getSortComp("Camouflage")>0;
  9160. if(!cache)
  9161. return false;
  9162. var urlImg = URL_MZimg + "oeil.png";
  9163. for(var i = end; i >= begin;i--)
  9164. {
  9165. var id = getMonstreID(i);
  9166. var donneesMonstre = listeCDM[id];
  9167. if(donneesMonstre && donneesMonstre.length>12)
  9168. {
  9169. if(donneesMonstre[12]==1)
  9170. {
  9171. var td = getMonstreNomNode(i);
  9172. td.appendChild(document.createTextNode(" "));
  9173. td.appendChild(createImage(urlImg, "Voit le caché"));
  9174. }
  9175. }
  9176. }
  9177. }
  9178.  
  9179. function computeTactique(begin, end) {
  9180. // pk begin/end ? --> parce qu'au chargement c'est RetrieveCdMs qui le lance via computeVLC
  9181. try {
  9182. if(!begin) begin = 1;
  9183. if(!end) end = nbMonstres;
  9184. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9185. if(noTactique || !isProfilActif()) return;
  9186. for(var j=end ; j>=begin ; j--) {
  9187. var id = getMonstreID(j);
  9188. var nom = getMonstreNom(j);
  9189. var donneesMonstre = listeCDM[id];
  9190. if(donneesMonstre && nom.indexOf('Gowap')==-1) {
  9191. var td = getMonstreNomNode(j);
  9192. appendText(td,' ');
  9193. td.appendChild(
  9194. createImageTactique(URL_MZimg+'calc2.png', id, nom)
  9195. );
  9196. }
  9197. }
  9198. }
  9199. catch(e) {
  9200. window.alert('Erreur computeTactique mob num : '+j+' :\n'+e)
  9201. }
  9202. filtreMonstres();
  9203. }
  9204.  
  9205. function updateTactique() {
  9206. // = Handler checkBox noTactique
  9207. var noTactique = saveCheckBox(checkBoxTactique,'NOTACTIQUE');
  9208. if(!isCDMsRetrieved) return;
  9209. if(noTactique) {
  9210. for(var i=nbMonstres ; i>0 ; i--) {
  9211. var tr = getMonstreNomNode(i);
  9212. var img = document.evaluate("img[@src='"+URL_MZimg+"calc2.png']",
  9213. tr, null, 9, null).singleNodeValue;
  9214. if(img) {
  9215. img.parentNode.removeChild(img.previousSibling);
  9216. img.parentNode.removeChild(img);
  9217. }
  9218. }
  9219. }
  9220. else
  9221. computeTactique();
  9222. }
  9223.  
  9224. function filtreMonstres() {
  9225. // = Handler universel pour les fonctions liées aux monstres
  9226. var urlImg = URL_MZimg+'Competences/ecritureMagique.png',
  9227. urlEnchantImg = URL_MZimg+'images/enchant.png';
  9228. /* Vérification/Sauvegarde de tout ce qu'il faudra traiter */
  9229. var useCss = MY_getValue(numTroll+'.USECSS')=='true';
  9230. var noGowapsS = saveCheckBox(checkBoxGowapsS,'NOGOWAPS');
  9231. var noGowapsA = saveCheckBox(checkBoxGowapsA,'NOGOWAPA');
  9232. var noEngages = saveCheckBox(checkBoxEngages,'NOENGAGE');
  9233. var nivMin = saveComboBox(comboBoxNiveauMin,'NIVEAUMINMONSTRE');
  9234. var nivMax = saveComboBox(comboBoxNiveauMax,'NIVEAUMAXMONSTRE');
  9235. // old/new : détermine s'il faut ou non nettoyer les tr
  9236. var oldNOEM = true, noEM = true;
  9237. if(MY_getValue('NOINFOEM')!='true') {
  9238. noEM = saveCheckBox(checkBoxEM, 'NOEM');
  9239. }
  9240. // Filtrage par nom
  9241. var strMonstre = document.getElementById('strMonstres').value.toLowerCase();
  9242. // Génère la liste des mobs engagés (si filtrés)
  9243. if(noEngages && !isEngagesComputed) {
  9244. for(var i=nbTrolls ; i>0 ; i--) {
  9245. var pos = getTrollPosition(i);
  9246. if(!listeEngages[pos[0]]) { listeEngages[pos[0]]={}; }
  9247. if(!listeEngages[pos[0]][pos[1]]) { listeEngages[pos[0]][pos[1]]={}; }
  9248. listeEngages[pos[0]][pos[1]][pos[2]] = 1;
  9249. }
  9250. isEngagesComputed = true;
  9251. }
  9252. /*** FILTRAGE ***/
  9253. /* À computer :
  9254. * - EM (nom suffit)
  9255. * - Enchant (nom suffit)
  9256. * - Mission (nécessite CdM)
  9257. * - mob VlC (nécessite CdM)
  9258. * Sans computation :
  9259. * - Gowap ? engagé ?
  9260. */
  9261. for(var i=nbMonstres ; i>0 ; i--) {
  9262. var pos = getMonstrePosition(i);
  9263. var nom = getMonstreNom(i).toLowerCase();
  9264. if(noEM!=oldNOEM) {
  9265. if(noEM) {
  9266. // Si noEM passe de false à true, on nettoie les td "Nom"
  9267. // DEBUG: Sauf que ce serait carrément mieux avec des id...
  9268. var tr = getMonstreNomNode(i);
  9269. while(tr.childNodes.length>1) {
  9270. tr.removeChild(tr.childNodes[1]);
  9271. }
  9272. } else {
  9273. var tr = getMonstreNomNode(i);
  9274. var TypeMonstre=getEM(nom);
  9275. if(TypeMonstre!='') {
  9276. var infosCompo=compoMobEM(TypeMonstre);
  9277. if(infosCompo.length>0) {
  9278. tr.appendChild(document.createTextNode(' '));
  9279. tr.appendChild(createImage(urlImg, infosCompo));
  9280. }
  9281. }
  9282. }
  9283. }
  9284. if(needComputeEnchantement || (noEM!=oldNOEM && noEM)) {
  9285. var texte = getInfoEnchantementFromMonstre(nom);
  9286. if(texte!='') {
  9287. var td = getMonstreNomNode(i);
  9288. td.appendChild(document.createTextNode(' '));
  9289. td.appendChild(createImage(urlEnchantImg, texte));
  9290. }
  9291. }
  9292. tr_monstres[i].style.display = (
  9293. noGowapsS &&
  9294. nom.indexOf('gowap sauvage')!=-1 &&
  9295. getMonstreDistance(i)>1
  9296. ) || (
  9297. noGowapsA &&
  9298. nom.indexOf('gowap apprivoisé')!=-1 &&
  9299. getMonstreDistance(i)>1
  9300. ) || (
  9301. noEngages &&
  9302. getMonstreDistance(i)!=0 &&
  9303. listeEngages[pos[0]] &&
  9304. listeEngages[pos[0]][pos[1]] &&
  9305. listeEngages[pos[0]][pos[1]][pos[2]]
  9306. ) || (
  9307. strMonstre!='' &&
  9308. nom.indexOf(strMonstre)==-1
  9309. ) || (
  9310. isMonstreLevelOutLimit(i, nivMin, nivMax) &&
  9311. getMonstreDistance(i)>1 &&
  9312. nom.toLowerCase().indexOf("kilamo")==-1
  9313. ) ? 'none' : '';
  9314. }
  9315. if(MY_getValue('NOINFOEM')!='true') {
  9316. if(noEM != oldNOEM) {
  9317. if(noEM && isCDMsRetrieved) computeMission();
  9318. }
  9319. oldNOEM = noEM;
  9320. }
  9321. needComputeEnchantement = false;
  9322. }
  9323.  
  9324.  
  9325. /*-[functions]---------------- Fonctions Trõlls ------------------------------*/
  9326.  
  9327. function filtreTrolls() {
  9328. var noIntangibles = saveCheckBox(checkBoxIntangibles,'NOINT');
  9329. var strTroll = document.getElementById('strTrolls').value.toLowerCase();
  9330. var strGuilde = document.getElementById('strGuildes').value.toLowerCase();
  9331. for(var i=1 ; i<=nbTrolls ; i++) {
  9332. tr_trolls[i].style.display = (
  9333. noIntangibles &&
  9334. getTrollNomNode(i).firstChild.className=='mh_trolls_0'
  9335. ) || (
  9336. strTroll!='' &&
  9337. getTrollNomNode(i).textContent.toLowerCase().indexOf(strTroll)==-1
  9338. ) || (
  9339. strGuilde!='' &&
  9340. getTrollGuilde(i).toLowerCase().indexOf(strGuilde)==-1
  9341. ) ? 'none' : '';
  9342. }
  9343. }
  9344.  
  9345. /* [functions] Bulle PX Trolls */
  9346. var bulle;
  9347.  
  9348. function initPXTroll() {
  9349. bulle = document.createElement('div');
  9350. bulle.id = 'bulle';
  9351. bulle.className = 'mh_textbox';
  9352. bulle.style =
  9353. 'position: absolute;'+
  9354. 'border: 1px solid #000000;'+
  9355. 'visibility: hidden;'+
  9356. 'display: inline;'+
  9357. 'z-index: 2;';
  9358. document.body.appendChild(bulle);
  9359.  
  9360. for(var i=nbTrolls ; i>0 ; i--) {
  9361. var td_niv = getTrollNivNode(i);
  9362. td_niv.onmouseover = showPXTroll;
  9363. td_niv.onmouseout = hidePXTroll;
  9364. }
  9365. }
  9366.  
  9367. function showPXTroll(evt) {
  9368. var lvl = this.firstChild.nodeValue;
  9369. bulle.innerHTML = 'Niveau '+lvl+analysePXTroll(lvl);
  9370. bulle.style.left = evt.pageX+15+'px';
  9371. bulle.style.top = evt.pageY+'px';
  9372. bulle.style.visibility = 'visible';
  9373. }
  9374.  
  9375. function hidePXTroll() {
  9376. bulle.style.visibility = 'hidden';
  9377. }
  9378.  
  9379. /* [functions] Envoi PX / MP */
  9380. function putBoutonPXMP() {
  9381. // Bouton d'initialisation du mode Envoi
  9382. // WARNING - Nécessite que le Filtre Trõll ait été mis en place
  9383. var td = document.getElementById('tdInsertTrolls');
  9384. if(!td) { return; }
  9385. td.width = 100;
  9386. td = insertTd(td.nextSibling);
  9387. td.style.verticalAlign = 'top';
  9388. var bouton = appendButton(td,'Envoyer...',prepareEnvoi);
  9389. bouton.id = 'btnEnvoi';
  9390. }
  9391.  
  9392. function prepareEnvoi() {
  9393. // = 1er Handler du bouton d'envoi
  9394. /* Ajout de la colonne des CheckBoxes */
  9395. var td = insertTdText(getTrollNomNode(0),'');
  9396. td.width = 5;
  9397. for(var i=nbTrolls ; i>0 ; i--) {
  9398. td = insertTd(getTrollNomNode(i));
  9399. appendCheckBox(td,'envoi'+i);
  9400. }
  9401. /* Ajout du radio de choix PX ou MP */
  9402. var btnEnvoi = document.getElementById('btnEnvoi');
  9403. if(!btnEnvoi) { return; }
  9404. var tdEnvoi = btnEnvoi.parentNode;
  9405. appendText(tdEnvoi,' ');
  9406. var span = document.createElement('span');
  9407. span.style.whiteSpace = 'nowrap';
  9408. var radioElt = document.createElement('input');
  9409. radioElt.type = 'radio';
  9410. radioElt.name = 'envoiPXMP';
  9411. radioElt.id = 'radioPX';
  9412. span.appendChild(radioElt);
  9413. appendText(span,' des PX ');
  9414. radioElt = document.createElement('input');
  9415. radioElt.type = 'radio';
  9416. radioElt.name = 'envoiPXMP';
  9417. radioElt.checked = true;
  9418. span.appendChild(radioElt);
  9419. appendText(span,' un MP');
  9420. tdEnvoi.appendChild(span);
  9421. /* Insertion du bouton Annuler */
  9422. insertButton(btnEnvoi,'Annuler',annuleEnvoi);
  9423. /* Modification de l'effet du bouton Envoi */
  9424. document.getElementById('btnEnvoi').onclick = effectueEnvoi;
  9425. }
  9426.  
  9427. function annuleEnvoi() {
  9428. // = Handler bouton Annuler
  9429. /* Nettoyage du td du bouton Envoi */
  9430. var btnEnvoi = document.getElementById('btnEnvoi');
  9431. var tdEnvoi = btnEnvoi.parentNode;
  9432. while(tdEnvoi.firstChild) {
  9433. tdEnvoi.removeChild(tdEnvoi.firstChild);
  9434. }
  9435. /* Retour à l'effet de base du bouton Envoi */
  9436. btnEnvoi.onclick = prepareEnvoi;
  9437. tdEnvoi.appendChild(btnEnvoi);
  9438. /* Suppression CheckBoxes */
  9439. for(var i=nbTrolls ; i>=0 ; i--) {
  9440. var td = getTrollNomNode(i);
  9441. td.parentNode.removeChild(td);
  9442. }
  9443. }
  9444.  
  9445. function effectueEnvoi() {
  9446. // = 2e Handler du bouton d'envoi (charge un nouveau frame)
  9447. var str='';
  9448. var errID = false;
  9449. for(var i=nbTrolls ; i>0 ; i--) {
  9450. var chb = document.getElementById('envoi'+i);
  9451. if(chb.checked) {
  9452. var idTroll = getTrollID(i);
  9453. if (idTroll == undefined) {
  9454. errID = true;
  9455. } else {
  9456. str += (str ? ',' : '') + idTroll;
  9457. }
  9458. }
  9459. }
  9460. if (errID) window.alert('MZ : il y a eu une erreur dans la liste, vérifiez à qui vous faites l\'envoi');
  9461. var PXchecked = document.getElementById('radioPX').checked;
  9462. if(PXchecked) {
  9463. window.open('./Actions/Play_a_DonPX.php?cat=8&dest='+str,'Contenu');
  9464. } else {
  9465. window.open('../Messagerie/MH_Messagerie.php?cat=3&dest='+str,'Contenu');
  9466. }
  9467. }
  9468.  
  9469. /*-[functions]---------------- Fonctions Trésors -----------------------------*/
  9470.  
  9471. function filtreTresors() {
  9472. // += Handler checkboxes : gg, compos, bidouilles, non libres
  9473. var noGG = saveCheckBox(checkBoxGG,'NOGG');
  9474. var noCompos = saveCheckBox(checkBoxCompos,'NOCOMP');
  9475. var noBidouilles = saveCheckBox(checkBoxBidouilles,'NOBID');
  9476. var noEngages = saveCheckBox(checkBoxTresorsNonLibres,'NOTRESORSNONLIBRES');
  9477. if(noEngages && !isEngagesComputed) {
  9478. for(var i=nbTrolls ; i>0 ; i--) {
  9479. var pos = getTrollPosition(i);
  9480. if(!listeEngages[pos[2]]) listeEngages[pos[2]] = [];
  9481. if(!listeEngages[pos[2]][pos[1]]) listeEngages[pos[2]][pos[1]] = [];
  9482. listeEngages[pos[2]][pos[1]][pos[0]] = 1;
  9483. }
  9484. isEngagesComputed = true;
  9485. }
  9486. var strTresor = document.getElementById('strTresors').value.toLowerCase();
  9487. for(var i=nbTresors ; i>0 ; i--) {
  9488. var nom = getTresorNom(i);
  9489. var pos = getTresorPosition(i);
  9490. tr_tresors[i].style.display = (
  9491. noGG &&
  9492. nom.indexOf('Gigots de Gob')!=-1
  9493. ) || (
  9494. noCompos &&
  9495. nom.indexOf('Composant')!=-1
  9496. ) || (
  9497. noEngages &&
  9498. listeEngages[pos[2]] &&
  9499. listeEngages[pos[2]][pos[1]] &&
  9500. listeEngages[pos[2]][pos[1]][pos[0]] &&
  9501. getTresorDistance(i)>0
  9502. ) || (
  9503. strTresor!='' &&
  9504. nom.toLowerCase().indexOf(strTresor)==-1
  9505. ) || (
  9506. noBidouilles &&
  9507. nom.indexOf('Bidouille')!=-1
  9508. ) ? 'none' : '';
  9509. }
  9510. }
  9511.  
  9512.  
  9513. /*-[functions]----------------- Fonctions Lieux ------------------------------*/
  9514.  
  9515. function filtreLieux() {
  9516. // += Handler checkbox trous
  9517. var noTrou = saveCheckBox(checkBoxTrou,'NOTROU');
  9518. var strLieu = document.getElementById('strLieux').value.toLowerCase();
  9519. for(var i=nbLieux ; i>0 ; i--) {
  9520. tr_lieux[i].style.display = (
  9521. strLieu &&
  9522. getLieuNom(i).toLowerCase().indexOf(strLieu)==-1
  9523. ) || (
  9524. noTrou &&
  9525. getLieuNom(i).toLowerCase().indexOf("trou de météorite")!=-1 &&
  9526. getLieuDistance(i)>1
  9527. ) ? 'none' : '';
  9528. }
  9529. }
  9530.  
  9531.  
  9532. /*-[functions]-------------------- Diplomatie --------------------------------*/
  9533.  
  9534. function refreshDiplo() {
  9535. MY_setValue(numTroll+'.diplo.off',
  9536. checkBoxDiplo.checked?'true':'false'
  9537. );
  9538. if(isDiploRaw) { computeDiplo(); }
  9539. appliqueDiplo();
  9540. }
  9541.  
  9542. function computeDiplo() {
  9543. // On extrait les données de couleur et on les stocke par id
  9544. // Ordre de préséance :
  9545. // source Guilde < source Perso
  9546. // guilde cible < troll cible
  9547. /* Diplo de Guilde */
  9548. var diploGuilde = MY_getValue(numTroll+'.diplo.guilde') ?
  9549. JSON.parse(MY_getValue(numTroll+'.diplo.guilde')) : {};
  9550. if(diploGuilde && diploGuilde.isOn=='true') {
  9551. // Guilde perso
  9552. if(diploGuilde.guilde) {
  9553. Diplo.Guilde[diploGuilde.guilde.id] = {
  9554. couleur: diploGuilde.guilde.couleur,
  9555. titre: 'Ma Guilde'
  9556. };
  9557. }
  9558. // Guildes/Trolls A/E
  9559. for(var AE in {Amis:0,Ennemis:0}) {
  9560. for(var i=0 ; i<5 ; i++) {
  9561. if(diploGuilde[AE+i]) {
  9562. for(var type in {Guilde:0,Troll:0}) {
  9563. var liste = diploGuilde[AE+i][type].split(';');
  9564. for(var j=liste.length-2 ; j>=0 ; j--) {
  9565. Diplo[type][liste[j]] = {
  9566. couleur: diploGuilde[AE+i].couleur,
  9567. titre: diploGuilde[AE+i].titre
  9568. };
  9569. }
  9570. }
  9571. }
  9572. }
  9573. }
  9574. }
  9575. /* Diplo Perso */
  9576. var diploPerso = MY_getValue(numTroll+'.diplo.perso') ?
  9577. JSON.parse(MY_getValue(numTroll+'.diplo.perso')) : {};
  9578. if(diploPerso && diploPerso.isOn=='true') {
  9579. for(var type in {Guilde:0,Troll:0,Monstre:0}) {
  9580. for(var id in diploPerso[type]) {
  9581. Diplo[type][id] = diploPerso[type][id];
  9582. }
  9583. }
  9584. }
  9585. if(diploPerso.mythiques) {
  9586. Diplo.mythiques = diploPerso.mythiques;
  9587. }
  9588. isDiploRaw = false;
  9589. }
  9590.  
  9591. function appliqueDiplo() {
  9592. var aAppliquer = Diplo;
  9593. if(checkBoxDiplo.checked) {
  9594. // Pour retour à l'affichage basique sur désactivation de la diplo
  9595. aAppliquer = {
  9596. Guilde: {},
  9597. Troll: {},
  9598. Monstre: {}
  9599. };
  9600. }
  9601. /* On applique "aAppliquer" */
  9602. // Diplo Trõlls
  9603. for(var i=nbTrolls ; i>0 ; i--) {
  9604. var idG = getTrollGuildeID(i);
  9605. var idT = getTrollID(i);
  9606. var tr = tr_trolls[i];
  9607. //window.console.log('diplo i=' + i + ', troll=' + idT + ', guilde=' + idG + ', HTML=' + tr.innerHTML);
  9608. if(aAppliquer.Troll[idT]) {
  9609. tr.className = '';
  9610. var descr = aAppliquer.Troll[idT].titre;
  9611. if(descr) {
  9612. getTrollNomNode(i).title = descr
  9613. }
  9614. tr.style.backgroundColor = aAppliquer.Troll[idT].couleur;
  9615. } else if(aAppliquer.Guilde[idG]) {
  9616. tr.className = '';
  9617. var descr = aAppliquer.Guilde[idG].titre;
  9618. if(descr) {
  9619. getTrollNomNode(i).title = descr
  9620. }
  9621. tr.style.backgroundColor = aAppliquer.Guilde[idG].couleur;
  9622. } else {
  9623. tr.className = 'mh_tdpage';
  9624. getTrollNomNode(i).title = '';
  9625. }
  9626. }
  9627. // Diplo Monstres
  9628. for(var i=nbMonstres ; i>0 ; i--) {
  9629. var id = getMonstreID(i);
  9630. var nom = getMonstreNom(i).toLowerCase();
  9631. if(aAppliquer.Monstre[id]) {
  9632. tr_monstres[i].className = '';
  9633. tr_monstres[i].style.backgroundColor = aAppliquer.Monstre[id].couleur;
  9634. tr_monstres[i].diploActive = 'oui';
  9635. var descr = aAppliquer.Monstre[id].titre;
  9636. if(descr) {
  9637. getMonstreNomNode(i).title = descr;
  9638. }
  9639. } else if(aAppliquer.mythiques &&
  9640. (nom.indexOf('liche')==0 ||
  9641. nom.indexOf('hydre')==0 ||
  9642. nom.indexOf('balrog')==0 ||
  9643. nom.indexOf('beholder')==0)) {
  9644. tr_monstres[i].className = '';
  9645. tr_monstres[i].style.backgroundColor = aAppliquer.mythiques;
  9646. tr_monstres[i].diploActive = 'oui';
  9647. getMonstreNomNode(i).title = 'Monstre Mythique';
  9648. } else {
  9649. tr_monstres[i].className = 'mh_tdpage';
  9650. tr_monstres[i].diploActive = '';
  9651. }
  9652. }
  9653. }
  9654.  
  9655.  
  9656. /*-[functions]---------------- Actions à distance ----------------------------*/
  9657.  
  9658. function computeActionDistante(dmin,dmax,keltypes,oussa,urlIcon,message) {
  9659. var monN = parseInt(getPosition()[2]);
  9660. for(var type in keltypes) {
  9661. alt = oussa=='self' ? type.slice(0,-1) : oussa;
  9662. for(var i=this['nb'+type] ; i>0 ; i--) {
  9663. var tr = this['tr_'+type.toLowerCase()][i];
  9664. // Roule 11/03/2016, on passe par les nouvelles fonctions getXxxPosition et getXxxDistance
  9665. //var sonN = this['get'+type.slice(0,-1)+'Position'](i)[2];
  9666. //var d = this['get'+type.slice(0,-1)+'Distance'](i);
  9667. var sonN = getXxxPosition(type, i)[2];
  9668. var d = getXxxDistance(type, i);
  9669. if(sonN==monN && d>=dmin && d<=dmax) {
  9670. var iconeAction = document.evaluate(
  9671. "./descendant::img[@alt='"+alt+"']",
  9672. tr, null, 9, null
  9673. ).singleNodeValue;
  9674. if(iconeAction) {
  9675. if(iconeAction.title) {
  9676. iconeAction.title += "\n"+message;
  9677. } else {
  9678. iconeAction.title = message;
  9679. }
  9680. iconeAction.src = urlIcon;
  9681. } else {
  9682. var tdAction = tr.getElementsByTagName('td')[1];
  9683. var icon = document.createElement('img');
  9684. icon.src = urlIcon;
  9685. icon.height = 20;
  9686. icon.alt = alt;
  9687. icon.title = message;
  9688. tdAction.appendChild(icon);
  9689. }
  9690. }
  9691. }
  9692. }
  9693. }
  9694.  
  9695. function computeCharge() {
  9696. computeActionDistante(1,
  9697. getPortee__Vue(
  9698. Math.ceil(MY_getValue(numTroll+".caracs.pv")/10)+
  9699. MY_getValue(numTroll+".caracs.regeneration")
  9700. ),
  9701. {'Monstres':1, 'Trolls':1},
  9702. 'Attaquer',
  9703. MHicons+'E_Metal09.png',
  9704. 'Cible à portée de Charge'
  9705. );
  9706. }
  9707.  
  9708. function computeProjo() {
  9709. computeActionDistante(0,
  9710. getPortee__Vue(
  9711. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9712. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9713. ),
  9714. {'Monstres':1, 'Trolls':1},
  9715. 'Attaquer',
  9716. MHicons+'S_Fire05.png',
  9717. 'Cible à portée de Projo'
  9718. );
  9719. }
  9720.  
  9721. function computeTelek() {
  9722. computeActionDistante(0,
  9723. Math.floor((
  9724. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9725. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9726. )/2),
  9727. {'Tresors':1},
  9728. 'Telek',
  9729. MHicons+'S_Magic04.png',
  9730. 'Trésor à portée de Télékinésie'
  9731. );
  9732. }
  9733.  
  9734. function computeLdP() {
  9735. computeActionDistante(0,
  9736. 2+Math.floor((
  9737. parseInt(MY_getValue(numTroll+".caracs.vue"))+
  9738. parseInt(MY_getValue(numTroll+".caracs.vue.bm"))
  9739. )/5),
  9740. {'Monstres':1, 'Trolls':1},
  9741. 'self',
  9742. MHicons+'P_Red01.png',
  9743. 'Cible à portée de Lancer de Potions'
  9744. );
  9745. }
  9746.  
  9747.  
  9748. /*-[functions]--------------- Systèmes Tactiques -----------------------------*/
  9749.  
  9750. function putScriptExterne() {
  9751. var infoit = MY_getValue(numTroll+'.INFOSIT');
  9752. if(!infoit || infoit=='') return;
  9753.  
  9754. var nomit = infoit.slice(0,infoit.indexOf('$'));
  9755. if(nomit=='bricol') {
  9756. var data = infoit.split('$');
  9757. try {
  9758. // Roule' 07/11/2016. Travail avec Ratibus, remplacement du script par l'envoi de JSON
  9759. // appendNewScript(URL_bricol+data[1]
  9760. // +'/mz.php?login='+data[2]
  9761. // +'&password='+data[3]
  9762. // );
  9763. FF_XMLHttpRequest({
  9764. method: 'GET',
  9765. url: URL_bricol+data[1]
  9766. +'/mz_json.php?login='+data[2]
  9767. +'&password='+data[3],
  9768. onload: function(responseDetails) {
  9769. try {
  9770. if (responseDetails.status == 0) {
  9771. window.console.log('status=0 à l\'appel bricol\'troll');
  9772. if (isHTTPS) {
  9773. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut accepter le certificat2 de Raistlin (voir page d\'accueil)');
  9774. } else {
  9775. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<');
  9776. }
  9777. return;
  9778. }
  9779. var ratibusData;
  9780. try {
  9781. ratibusData = JSON.parse(responseDetails.responseText);
  9782. } catch(e) {}
  9783. if (ratibusData === undefined) {
  9784. avertissement('<br />Erreur à l\'appel de l\'interface Bricol\'Troll. Code HTTP=' + responseDetails.status + '. Pas de JSON');
  9785. return;
  9786. }
  9787. if (ratibusData.error) {
  9788. avertissement('<br />Bricol\'Troll a répondu :<br />' + ratibusData.error);
  9789. } else {
  9790. putInfosTrolls(ratibusData.data.trolls);
  9791. }
  9792. } catch(e) {
  9793. window.console.log(traceStack(e, 'retour bricol\'troll'));
  9794. avertissement('<br />Erreur dans la réponse de Bricol\'Troll<br />' + e + '<br />' + responseDetails.responseText);
  9795. }
  9796. }
  9797. });
  9798. } catch(e) {
  9799. if (isHTTPS) {
  9800. avertissement('<br />Pour utiliser l\'interface Bricol\'Troll en HTTPS, il faut autoriser le contenu mixte (voir page d\'accueil)');
  9801. } else {
  9802. window.console.log(traceStack(e, 'appel bricol\'troll'));
  9803. avertissement('<br />Erreur générale avec l\'interface Bricol\'Troll<br />' + e);
  9804. }
  9805. }
  9806. }
  9807. }
  9808.  
  9809. /* Le script mz.php de Ratibus renvoie :
  9810. + infosTrolls = new Array();
  9811. + infosTrolls[numdutroll] =
  9812. new Array(PV,PVbase,date màj: "le JJ/MM/AAAA à hh:mm:ss",date pDLA,PA dispos);
  9813. + etc ...
  9814. + putInfosTrolls();
  9815. *
  9816. * Il est donc impossible d'afficher les invis d'une IT Bricol'Trolls.
  9817. * Roule 07/11/2016, on utilise mz_json qui envoie
  9818. {
  9819. "data": {
  9820. "trolls": {
  9821. "59424": {
  9822. "id": 59424,
  9823. "pv": xx,
  9824. "pv_max": xx,
  9825. "updated_at": "2016-10-31 07:28:40",
  9826. "dla": "2016-10-05 07:28:04",
  9827. "pa": 0
  9828. },
  9829. }
  9830. }
  9831. }
  9832. */
  9833.  
  9834. // Roule 07/11/2016 ATTENTION, il faudrait modifier ici (remplacer [0] par .pa, etc.)
  9835. function corrigeBricolTrolls(infosTrolls) {
  9836. for(var i in infosTrolls) {
  9837. var pv = infosTrolls[i][0];
  9838. var pvmax = infosTrolls[i][1];
  9839. var pvmem = MY_getValue(i+'.caracs.pv.max');
  9840. if(pvmem && pvmem>pvmax) {
  9841. infosTrolls[i][1] = pvmem;
  9842. pvmax = pvmem;
  9843. }
  9844. if(pv>pvmax) {
  9845. var newpvmax = 5*Math.ceil(pv/5);
  9846. MY_setValue(i+'.caracs.pv.max',newpvmax);
  9847. infosTrolls[i][1] = newpvmax;
  9848. }
  9849. }
  9850. }
  9851.  
  9852. // insère 2 TD avant nextTD avec les infos venant de l'IT
  9853. function addTdInfosTroll(infos, TR) {
  9854. /* cadre barre PV */
  9855. var tab = document.createElement('div');
  9856. /* ancienne méthode par img, à supprimer
  9857. tab.width = 100;
  9858. tab.style.width = 100;
  9859. tab.height = 10;
  9860. tab.style.background = '#FFFFFF';
  9861. tab.style.border = 1;
  9862. */
  9863. tab.title = infos.pv+'/'+infos.pv_max+' le '+ SQLDateToFrenchTime(infos.updated_at);
  9864. /* barre PV */
  9865. /* Roule' : sans aucune honte, j'ai copié la méthode de Bricol'Troll
  9866. <div class="vieContainer"><div style="background-color: #77EE77; width: 90%">&nbsp;</div></div>
  9867. .vieContainer {
  9868. background-color: #CCC;
  9869. width: 50px;
  9870. height: 6px;
  9871. border: 1px solid #000;
  9872. text-align: left;
  9873. }
  9874. */
  9875. tab.style.width = '100px';
  9876. tab.style.height = '10px';
  9877. tab.style.border = '1px solid #000';
  9878. tab.style.textAlign = 'left';
  9879. var div2 = document.createElement('div');
  9880. var pourcentVie = Math.floor( (100*infos.pv)/infos.pv_max );
  9881. var dateLimite = new Date();
  9882. dateLimite.setDate(dateLimite.getDate() - 7);
  9883. if (infos.oUpdatedAt < dateLimite) {
  9884. div2.style.backgroundColor = '#888888'; // infos de plus de 7 jours => grisé
  9885. tab.title += "\nLes informations sont trop vieilles pour être fiables";
  9886. } else if (pourcentVie > 66) {
  9887. div2.style.backgroundColor = '#77EE77';
  9888. } else if (pourcentVie > 33) {
  9889. div2.style.backgroundColor = '#EEEE77';
  9890. } else {
  9891. div2.style.backgroundColor = '#FF0000';
  9892. }
  9893. div2.style.width = pourcentVie + '%';
  9894. div2.style.height = '10px';
  9895. tab.appendChild(div2);
  9896. /* ancienne méthode par img, à supprimer
  9897. var img = document.createElement('img');
  9898. img.src = '../Images/Interface/milieu.gif';
  9899. img.height = 10;
  9900. img.width = Math.floor( (100*infos.pv)/infos.pv_max );
  9901. tab.appendChild(img);
  9902. */
  9903.  
  9904. var tdNom = TR.childNodes[3]
  9905. if (infos.camoufle) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé","padding-left:2px"));
  9906. if (infos.invisible) tdNom.appendChild(createImage(URL_MZimg+"warning.gif","Invisible","padding-left:2px"));
  9907.  
  9908. /* lien vers l'IT */
  9909. var lien = document.createElement('a');
  9910. var nomit = MY_getValue(numTroll+'.INFOSIT').split('$')[1];
  9911. lien.href = URL_bricol+nomit+'/index.php';
  9912. lien.target = '_blank';
  9913. lien.appendChild(tab);
  9914. var tdGuilde = TR.childNodes[6];
  9915. insertTdElement(tdGuilde,lien);
  9916. /* PAs dispos */
  9917. var span = document.createElement('span');
  9918. span.title = 'DLA : ' + SQLDateToFrenchTime(infos.dla);
  9919. appendText(span, infos.pa +' PA' );
  9920. //window.console.log('dla=' + infos.dla + ', SQLDateToObject(infos.dla)=' + SQLDateToObject(infos.dla) + ', now=' + Date.now());
  9921. if (infos.pa > 0 || SQLDateToObject(infos.dla) < Date.now()) {
  9922. // surligner en verdâtre pour exprimer que ce Trõll peut jouer maintenant
  9923. span.style.backgroundColor = 'B8EEB8';
  9924. }
  9925. insertTdElement(tdGuilde, span);
  9926. }
  9927.  
  9928. function putInfosTrolls(infosTrolls) {
  9929. try {
  9930. // conversion de la date de mise à jour en objet date (on en a besoin 2 fois)
  9931. // supression des infos trop vieilles (un mois)
  9932. var IDs = Object.keys(infosTrolls);
  9933. var dateLimite = new Date();
  9934. dateLimite.setMonth(dateLimite.getMonth() - 1);
  9935. for (var i = 0; i < IDs.length; i++) {
  9936. var idTroll = IDs[i];
  9937. var infos = infosTrolls[idTroll];
  9938. infos.oUpdatedAt = SQLDateToObject(infos.updated_at);
  9939. if (infos.oUpdatedAt < dateLimite) infos.bIgnore = true;
  9940. }
  9941. var td = insertTdText(tr_trolls[0].childNodes[6],'PA',true);
  9942. td.width = 40;
  9943. td = insertTdText(tr_trolls[0].childNodes[6],'PV',true);
  9944. td.width = 105;
  9945.  
  9946. // Roule 07/11/2016 je ne suis pas trop fana de corriger les données de Bricol'Troll
  9947. //corrigeBricolTrolls(infosTrolls);
  9948.  
  9949. for(i=nbTrolls ; i>0 ; i--) {
  9950. var infos = infosTrolls[getTrollID(i)];
  9951. if(infos && (!infos.bIgnore)) {
  9952. addTdInfosTroll(infos, tr_trolls[i]);
  9953. infos.done = true;
  9954. } else {
  9955. insertTd(tr_trolls[i].childNodes[6]);
  9956. insertTd(tr_trolls[i].childNodes[6]);
  9957. }
  9958. }
  9959. // Roule 07/12/2016 ajout des Trolls invi/camou/hors de portée
  9960. var str = MY_getValue(numTroll+'.INFOSIT');
  9961. if(!str) return;
  9962. var arr = str.split('$');
  9963. if (!(arr[4]>0)) return; // pas si le joueur n'en veut pas
  9964.  
  9965. //window.console.log('nb Troll IT : ' + IDs.length);
  9966. var tBody = tr_trolls[0].parentNode;
  9967. if (tr_trolls[1] === undefined)
  9968. tBody = tr_trolls[0].parentNode;
  9969. else
  9970. tBody = tr_trolls[1].parentNode;
  9971. var pos = getPosition();
  9972. for (i = 0; i < IDs.length; i++) {
  9973. var idTroll = IDs[i];
  9974. infos = infosTrolls[idTroll];
  9975. if (infos.done) continue; // déjà vu
  9976. if (infos.bIgnore) continue; // trop vieux
  9977. if (idTroll == numTroll) continue; // pas nous-même
  9978. //window.console.log('Troll surnuméraire ' + JSON.stringify(infos));
  9979. var distance = Math.max(Math.abs(pos[0]-infos.x), Math.abs(pos[1]-infos.y), Math.abs(pos[2]-infos.n));
  9980. // trouver où insérer ce Troll
  9981. var next = undefined;
  9982. for(var j=0 ; j<tr_trolls.length ; j++) {
  9983. var thisDist = parseInt(tr_trolls[j].cells[0].textContent);
  9984. if (thisDist > distance) {
  9985. next = tr_trolls[j]
  9986. break;
  9987. }
  9988. }
  9989. var tr;
  9990. if (next !== undefined) {
  9991. tr = insertTr(next,'mh_tdpage')
  9992. } else {
  9993. tr = appendTr(tBody,'mh_tdpage');
  9994. }
  9995. tr.style.color = 'orange';
  9996. var td = appendTd(tr); // distance
  9997. appendText(td, distance);
  9998. td = appendTd(tr); // actions
  9999. td = appendTd(tr); // ID
  10000. appendText(td, idTroll);
  10001. td = appendTd(tr); // Nom
  10002. // <A HREF="javascript:EPV(1649)" CLASS='mh_trolls_1'>Krounch</A>
  10003. appendA(td, 'javascript:EPV(' + idTroll + ')', 'mh_trolls_1', infos.nom);
  10004. // info camou/invi transféré dans addTdInfosTroll
  10005. // if (infos.camoufle) td.appendChild(createImage(URL_MZimg+"warning.gif","Camouflé"));
  10006. // if (infos.invisible) td.appendChild(createImage(URL_MZimg+"warning.gif","Invisible"));
  10007. td = appendTd(tr); // Niveau
  10008. if (infos.niveau !== undefined) appendText(td, infos.niveau);
  10009. td.align = 'center';
  10010. td = appendTd(tr); // Race
  10011. if (infos.race) appendText(td, infos.race);
  10012. // PV et PA ajoutés par addTdInfosTroll
  10013. td = appendTd(tr); // Guilde
  10014. if (infos.guilde !== undefined) appendText(td, infos.guilde);
  10015. td = appendTd(tr); // X
  10016. td.align = 'center';
  10017. if (infos.x !== undefined) appendText(td, infos.x);
  10018. td = appendTd(tr); // Y
  10019. td.align = 'center';
  10020. if (infos.y !== undefined) appendText(td, infos.y);
  10021. td = appendTd(tr); // N
  10022. td.align = 'center';
  10023. if (infos.n !== undefined) appendText(td, infos.n);
  10024. addTdInfosTroll(infos, tr);
  10025. }
  10026. } catch(e) {
  10027. window.alert('Erreur troll='+i+'\n'+e+'\n'+tr_trolls[i].innerHTML);
  10028. }
  10029. }
  10030.  
  10031.  
  10032. /* Mode Tétalanvert! ---------------------------------------------------------*/
  10033.  
  10034. function calculeDistance(maPos,posArr) {
  10035. return Math.max(
  10036. Math.abs(maPos[0]-posArr[0]),
  10037. Math.abs(maPos[1]-posArr[1]),
  10038. Math.abs(maPos[2]-posArr[2])
  10039. );
  10040. }
  10041.  
  10042. function inversionCoord() {
  10043. var maPos = getPosition();
  10044. var listeOffsets = {
  10045. 'monstres':checkBoxLevels.checked?4:3,
  10046. 'trolls':6,
  10047. };
  10048. for(var type in listeOffsets) {
  10049. var trList = this['tr_'+type];
  10050. var offset = listeOffsets[type];
  10051. for(var i=trList.length-1 ; i>0 ; i--) {
  10052. var oldX = parseInt(trList[i].cells[offset].textContent);
  10053. var oldY = parseInt(trList[i].cells[offset+1].textContent);
  10054. var oldN = parseInt(trList[i].cells[offset+2].textContent);
  10055. trList[i].cells[offset].innerHTML = oldY;
  10056. trList[i].cells[offset+1].innerHTML = oldX;
  10057. trList[i].cells[0].innerHTML = calculeDistance(maPos,[oldY,oldX,oldN]);
  10058. }
  10059. }
  10060. }
  10061.  
  10062.  
  10063. /* Partie principale */
  10064. function do_vue() {
  10065. for(var type in typesAFetcher) {
  10066. fetchData(type);
  10067. }
  10068.  
  10069. // roule' 11/03/2016
  10070. // maintenant, tr_monstres et this['tr_monstres'], ce n'est plus la même chose
  10071. // je fais une recopie :(
  10072. tr_monstres = this['tr_monstres'];
  10073. tr_trolls = this['tr_trolls'];
  10074. tr_tresors = this['tr_tresors'];
  10075. tr_champignons = this['tr_champignons'];
  10076. tr_lieux = this['tr_lieux'];
  10077.  
  10078. nbMonstres = this['nbMonstres'];
  10079. nbTrolls = this['nbTrolls'];
  10080. nbTresors = this['nbTresors'];
  10081. nbChampignons = this['nbChampignons'];
  10082. nbLieux = this['nbLieux'];
  10083.  
  10084. try {
  10085. start_script(31);
  10086. initialiseInfos();
  10087. savePosition();
  10088.  
  10089. // Fonctionnalité "Têtalenvert" cachée, en test :
  10090. if(MY_getValue(numTroll+'.VERLAN')=='true') {
  10091. inversionCoord();
  10092. }
  10093. ajoutDesFiltres();
  10094. set2DViewSystem();
  10095. //putBoutonTroogle();
  10096. putBoutonPXMP();
  10097. synchroniseFiltres();
  10098. toggleLevelColumn();
  10099.  
  10100. refreshDiplo();
  10101. //400 ms
  10102. var noGG = saveCheckBox(checkBoxGG, "NOGG");
  10103. var noCompos = saveCheckBox(checkBoxCompos, "NOCOMP");
  10104. var noBidouilles = saveCheckBox(checkBoxBidouilles, "NOBID");
  10105. var noGowapsS = saveCheckBox(checkBoxGowapsS, "NOGOWAPS");
  10106. var noGowapsA = saveCheckBox(checkBoxGowapsA, "NOGOWAPA");
  10107. var noEngages = saveCheckBox(checkBoxEngages, "NOENGAGE");
  10108. var noTresorsEngages =
  10109. saveCheckBox(checkBoxTresorsNonLibres, "NOTRESORSNONLIBRES");
  10110. var noTrou = saveCheckBox(checkBoxTrou, "NOTROU");
  10111. var noIntangibles = saveCheckBox(checkBoxIntangibles, "NOINT");
  10112. filtreMonstres();
  10113. if(noIntangibles) {
  10114. filtreTrolls();
  10115. }
  10116. if(noGG || noCompos || noBidouilles || noTresorsEngages) {
  10117. filtreTresors();
  10118. }
  10119. if(noTrou) {
  10120. filtreLieux();
  10121. }
  10122.  
  10123. initPopupVue();
  10124. initPXTroll();
  10125.  
  10126. if(getTalent("Projectile Magique")!=0) {
  10127. computeProjo();
  10128. }
  10129. if(getTalent("Charger")!=0) {
  10130. computeCharge();
  10131. }
  10132. if(getTalent("Télékinésie")!=0) {
  10133. computeTelek();
  10134. }
  10135. if(getTalent("Lancer de Potions")!=0) {
  10136. computeLdP();
  10137. }
  10138. putScriptExterne();
  10139. displayScriptTime();
  10140. } catch(e) {
  10141. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  10142. window.console.error(traceStack(e, 'vue'));
  10143. }
  10144. }
  10145.  
  10146.  
  10147.  
  10148. /*******************************************************************************
  10149. * This file is part of Mountyzilla. *
  10150. * *
  10151. * Mountyzilla is free software; you can redistribute it and/or modify *
  10152. * it under the terms of the GNU General Public License as published by *
  10153. * the Free Software Foundation; either version 2 of the License, or *
  10154. * (at your option) any later version. *
  10155. * *
  10156. * Mountyzilla is distributed in the hope that it will be useful, *
  10157. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  10158. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  10159. * GNU General Public License for more details. *
  10160. * *
  10161. * You should have received a copy of the GNU General Public License *
  10162. * along with Mountyzilla; if not, write to the Free Software *
  10163. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  10164. *******************************************************************************/
  10165.  
  10166. // x~x profil2
  10167.  
  10168. /*---------------------------- Variables globales ----------------------------*/
  10169.  
  10170. var
  10171. // Anatrolliseur
  10172. urlAnatrolliseur,
  10173. // Infobulles talents
  10174. hauteur = 50, bulleStyle = null,
  10175. // Caracteristiques
  10176. // Infos troll
  10177. race, niv, idtroll, datecrea,
  10178. idguilde, nomguilde,
  10179. // Etats du troll
  10180. fatigue, bmfatigue,
  10181.  
  10182. // Experience, Pi, ...
  10183. pxdistribuables, pxperso,
  10184. piutilisable, pitotal,
  10185. nbmeurtres, nbmorts,
  10186. // utilisee pour les moyennes MM/jour, kill/jour, etc
  10187. NBjours,
  10188. // calcul des DLA suivantes
  10189. DLA, DLAsuiv, HeureServeur,
  10190. // details duree du tour (calcul pvdispo) :
  10191. dtb, pdm, bmt, adb, dpt,
  10192. //posale
  10193. posX, posY, posN,
  10194. // caracs physiques
  10195. vue, vuebp, vuebm, vuetotale,
  10196. pvbase, pvbp, pvbm, pvtotal, pvcourant,
  10197. reg, regbp, regbm, regmoy,
  10198. att, attbp, attbm, attmoy, atttourD,atttourP,atttourM, attmoytour,
  10199. esq, esqbp, esqbm, esqmoy, esqtourD, esqmoytour,
  10200. deg, degbp, degbm, degmoy, degmoycrit, degtourP,degtourM, degmoytour, degmoycrittour,
  10201. arm, armbp, armbm, armmoy, armtourD, armmoytour,
  10202. rm, rmbp, rmbm, rmtotale,
  10203. mm, mmbp, mmbm, mmtotale,
  10204.  
  10205. // Variables speciales Kastars
  10206. pvActuelKastar, minParPV, overDLA,
  10207. // id pour edition manuelle de lastDLA :
  10208. inJour, inMois, inAn, inHr, inMin, inSec,
  10209. // id pour auto-refresh lastDLA :
  10210. lastDLAZone, maxAMZone, cumulZone,
  10211. lastDLA, DLAaccel;
  10212.  
  10213.  
  10214. /*-[functions]----------------- Fonctions utiles -----------------------------*/
  10215.  
  10216. // Retourne la valeur de l'element unique et identifie par son "selector" (cf querySelector())
  10217. // http://www.w3schools.com/jsref/met_document_queryselector.asp
  10218. function getUniqueValueBySelector(selector, defaultValue){
  10219. var valNode = document.querySelector(selector);
  10220. if(valNode!=null){
  10221. if(valNode.hasChildNodes()) {
  10222. return valNode.childNodes[0].nodeValue;
  10223. }else{
  10224. return defaultValue;
  10225. }
  10226. } else{
  10227. debugMZ("Pas d'element trouve correspondant au selecteur : " + selector);
  10228. return defaultValue;
  10229. }
  10230. }
  10231. function getUniqueStringValueBySelector(selector){
  10232. return getUniqueValueBySelector(selector,"");
  10233. }
  10234. function getUniqueIntValueBySelector(selector){
  10235. var ret = getUniqueValueBySelector(selector,0);
  10236. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10237. ret = 0;
  10238. }
  10239. return parseInt(ret);
  10240. }
  10241. function getUniqueFloatValueBySelector(selector){
  10242. var ret = getUniqueValueBySelector(selector,0.0);
  10243. if(ret==null || /^\s*$/.test(ret)){ // test si chaine de caracteres composee de " "
  10244. ret = 0.0;
  10245. }
  10246. return parseFloat(ret);
  10247. }
  10248.  
  10249.  
  10250. function resiste(Ddeg,bm) {
  10251. // version naive mais compréhensible ^^
  10252. // DEBUG: à revoir
  10253. if(!bm) {
  10254. return 2*Math.floor(Ddeg/2);
  10255. }
  10256. return 2*Math.floor(Ddeg/2)+Math.round(bm/2);
  10257. }
  10258.  
  10259. function retourAZero(fatig) {
  10260. var fat = fatig, raz = 0;
  10261. while(fat>0) {
  10262. raz++;
  10263. fat = Math.floor(fat/1.25);
  10264. }
  10265. return raz;
  10266. }
  10267.  
  10268. function decumulPumPrem(bonus) {
  10269. switch(bonus) {
  10270. case 20: return 33;
  10271. case 33: return 41;
  10272. case 41: return 46;
  10273. case 46: return 49;
  10274. case 49: return 51;
  10275. default: return 20;
  10276. }
  10277. }
  10278.  
  10279. function coefDecumul(i) {
  10280. switch(i) {
  10281. case 2: return 0.67;
  10282. case 3: return 0.4;
  10283. case 4: return 0.25;
  10284. case 5: return 0.15;
  10285. default: return 0.1;
  10286. }
  10287. }
  10288.  
  10289. function dureeHM(dmin) {
  10290. var ret = "";
  10291. dmin = Math.floor(dmin);
  10292. if(dmin>59) { ret = Math.floor(dmin/60)+"h"; }
  10293. var mins = dmin%60;
  10294. if(mins!=0) { ret += (ret) ? addZero(mins)+"min" : mins+"min"; }
  10295. return (ret) ? ret : "-";
  10296. }
  10297.  
  10298. // extraction d'une durée
  10299. // l'élément pointé par le sélecteur contient "9 h 33 m" ou "-2 h -30 m"
  10300. // c'est protégé (rend 0 si l'élément est absent)
  10301. // Roule' 24/12/2016
  10302. function extractionDuree(selecteur) {
  10303. var s = getUniqueStringValueBySelector(selecteur);
  10304. if (!s) return 0;
  10305. var tabN = getNumbers(s);
  10306. if (tabN.length < 2) return 0;
  10307. return tabN[0] * 60 + tabN[1];
  10308. }
  10309.  
  10310. /*-[functions]------- Extraction / Sauvegarde des donnees --------------------*/
  10311.  
  10312. function extractionDonnees() {
  10313. // Variables temporaires
  10314. var Nbrs = {};
  10315.  
  10316. // *********************
  10317. // Cadre "Description"
  10318. // *********************
  10319. race = getUniqueStringValueBySelector('#descr #race');
  10320. debugMZ("Race : " + race);
  10321. idtroll = getUniqueStringValueBySelector('#descr #id');
  10322. debugMZ("Id troll : " + idtroll);
  10323. var strDateCrea = getUniqueStringValueBySelector('#descr td#crea>span');
  10324. strDateCrea = strDateCrea.slice(strDateCrea.indexOf("(") + 1, strDateCrea.indexOf(")"));
  10325. datecrea = new Date(StringToDate(strDateCrea));
  10326. debugMZ("Date creation : " + datecrea);
  10327. // Guilde
  10328. idguilde = getUniqueIntValueBySelector('#descr #idguilde');
  10329. nomguilde = getUniqueStringValueBySelector('#descr #nomguilde');
  10330. debugMZ("Guilde: " + idguilde + ' ' + nomguilde);
  10331.  
  10332. // *******************
  10333. // Cadre "Experience"
  10334. // *******************
  10335. // Niveau de troll
  10336. niv = getUniqueIntValueBySelector('#exp #niv');
  10337. nivTroll = niv;
  10338. debugMZ("Niveau : " + niv);
  10339. // PX
  10340. pxdistribuables = getUniqueIntValueBySelector('#exp #px');
  10341. pxperso = getUniqueIntValueBySelector('#exp #px_perso');
  10342. debugMZ("Px Distrib/Perso: "+pxdistribuables+" / "+pxperso);
  10343. // PI
  10344. piutilisable = getUniqueIntValueBySelector('#exp #pi');
  10345. pitotal = getUniqueIntValueBySelector('#exp #pitot');
  10346. debugMZ("PI utilisables/total: "+piutilisable+" / "+pitotal);
  10347. // Meutres/Morts
  10348. nbmeurtres = getUniqueIntValueBySelector('#exp #kill');
  10349. nbmorts = getUniqueIntValueBySelector('#exp #mort');
  10350. debugMZ("Nb Meutres/Morts: "+nbmeurtres+" / "+nbmorts);
  10351.  
  10352. // *********************
  10353. // Cadre "Tour de Jeu"
  10354. // *********************
  10355. // DLA
  10356. Nbrs["dla"] = getUniqueStringValueBySelector("#dla #dla>b");
  10357. DLA = new Date(StringToDate(Nbrs["dla"]));
  10358. debugMZ("DLA: " + DLA);
  10359. // DLA suivante
  10360. Nbrs["dlasuiv"] = getUniqueStringValueBySelector("#dla #dla_next");
  10361. DLAsuiv = new Date(StringToDate(Nbrs["dlasuiv"]));
  10362. debugMZ("DLAsuiv: " + DLAsuiv);
  10363. // Duree normale de mon Tour
  10364. //Nbrs["dtb"] = getNumbers(getUniqueStringValueBySelector("#dla #tour"));
  10365. //dtb = Nbrs["dtb"][0] * 60 + Nbrs["dtb"][1];
  10366. dtb = extractionDuree("#dla #tour");
  10367. debugMZ("Duree normale de mon Tour : " + dtb);
  10368. // Bonus/Malus sur la duree
  10369. //Nbrs["bmt"] = getNumbers(getUniqueStringValueBySelector("#dla #bm"));
  10370. //bmt = Nbrs["bmt"][0] * 60 + Nbrs["bmt"][1];
  10371. bmt = extractionDuree("#dla #bm"); // Roule' 24/12/2016 on a trouvé un Troll qui n'a pas de bmt !
  10372. debugMZ("Bonus/Malus sur la duree : " + bmt);
  10373. // Augmentation due aux blessures
  10374. //Nbrs["adb"] = getNumbers(getUniqueStringValueBySelector("#dla #blessure"));
  10375. //adb = Nbrs["adb"][0] * 60 + Nbrs["adb"][1];
  10376. adb = extractionDuree("#dla #blessure");
  10377. debugMZ("Augmentation due aux blessures : " + adb);
  10378. // Poids de l'equipement
  10379. //Nbrs["pdm"] = getNumbers(getUniqueStringValueBySelector("#dla #poids"));
  10380. //pdm = Nbrs["pdm"][0] * 60 + Nbrs["pdm"][1];
  10381. pdm = extractionDuree("#dla #poids");
  10382. debugMZ("Poids de l'equipement : " + pdm);
  10383. // Duree de mon prochain Tour
  10384. //Nbrs["dpt"] = getNumbers(getUniqueStringValueBySelector("#dla #duree>b"));
  10385. //dpt = Nbrs["dpt"][0] * 60 + Nbrs["dpt"][1];
  10386. dpt = extractionDuree("#dla #duree>b");
  10387. debugMZ('Duree de mon prochain Tour : ' + dpt);
  10388.  
  10389. // ****************
  10390. // Cadre "Etats"
  10391. // ****************
  10392. // Position du troll :
  10393. posX = getUniqueIntValueBySelector('#pos #x');
  10394. posY = getUniqueIntValueBySelector('#pos #y');
  10395. posN = getUniqueIntValueBySelector('#pos #n');
  10396. debugMZ("(X Y Z) : " + posX + " " + posY + " " + posN);
  10397. // PV actuel
  10398. pvcourant = getUniqueIntValueBySelector('#pos #pv_courant');
  10399. pvActuelKastar = pvcourant;
  10400. debugMZ("PV actuel : " + pvcourant)
  10401. // Fatigue
  10402. fatigue = getUniqueIntValueBySelector('#pos #fatigue');
  10403. bmfatigue = getUniqueIntValueBySelector('#pos #fatiguebm');
  10404. debugMZ('Fatigue : '+fatigue+" + "+bmfatigue);
  10405.  
  10406. // **************************
  10407. // Cadre "Caracteristiques"
  10408. // **************************
  10409. // Attaque
  10410. att = getUniqueIntValueBySelector('#carac #att');
  10411. attbp = getUniqueIntValueBySelector('#carac #att_p');
  10412. attbm = getUniqueIntValueBySelector('#carac #att_m');
  10413. atttourD = getUniqueIntValueBySelector('#carac #att_tour_d');
  10414. atttourP = getUniqueIntValueBySelector('#carac #att_tour_p');
  10415. atttourM = getUniqueIntValueBySelector('#carac #att_tour_m');
  10416. attmoy = 3.5*att + attbp + attbm;
  10417. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10418. attmoytour = 3.5*(att+bmDAttTotalTour) + attbp + attbm;
  10419. debugMZ("ATT: "+att+"+("+attbp+")+("+attbm+") ;AttMoy:"+attmoy+"; BM Dé att/tour:("+atttourD+"D;"+atttourP+"%;"+atttourM+"%)"+bmDAttTotalTour+" ;AttMoyTour:"+attmoytour);
  10420. // Esquive
  10421. esq = getUniqueIntValueBySelector('#carac #esq');
  10422. esqbp = getUniqueIntValueBySelector('#carac #esq_p');
  10423. esqbm = getUniqueIntValueBySelector('#carac #esq_m');
  10424. esqtourD = getUniqueIntValueBySelector('#carac #esq_tour_d');
  10425. esqmoy = 3.5*esq + esqbp+esqbm;
  10426. esqmoytour = 3.5*(esq+esqtourD) + esqbp+esqbm;
  10427. debugMZ("ESQ: "+esq+"+("+esqbp+")+("+esqbm+") ;EsqMoy:"+esqmoy+"; esq/tour:"+esqtourD+" ;EsqMoyTour:"+esqmoytour);
  10428. // Degat
  10429. deg = getUniqueIntValueBySelector('#carac #deg');
  10430. degbp = getUniqueIntValueBySelector('#carac #deg_p');
  10431. degbm = getUniqueIntValueBySelector('#carac #deg_m');
  10432. degtourP = getUniqueIntValueBySelector('#carac #deg_tour_p');
  10433. degtourM = getUniqueIntValueBySelector('#carac #deg_tour_m');
  10434. degmoy = 2*deg + degbp+degbm;
  10435. degmoycrit = 3*deg + degbp+degbm;
  10436. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10437. degmoytour = 2*(deg + bmDDegTotalTour) + degbp + degbm;
  10438. degmoycrittour = 3 * (deg + bmDDegTotalTour) + degbp + degbm;
  10439. debugMZ("DEG: "+deg+"+("+degbp+")+("+degbm+") ;DegMoy:"+degmoy+"/"+degmoycrit+" ;deg/tour:("+degtourP+"%;"+degtourM+"%)"+bmDDegTotalTour+"; DegMoyTour:"+degmoytour+"/"+degmoycrittour);
  10440. // PV
  10441. pvbase = getUniqueIntValueBySelector('#carac #pv');
  10442. pvbp = getUniqueIntValueBySelector('#carac #pv_p');
  10443. pvbm = getUniqueIntValueBySelector('#carac #pv_m');
  10444. pvtotal = getUniqueIntValueBySelector('#carac #pv_tot');
  10445. debugMZ("PV: " + pvbase + " + (" + pvbp + ") + (" + pvbm + ") = " + pvtotal);
  10446. // Regeneration
  10447. reg = getUniqueIntValueBySelector('#carac #reg');
  10448. regbp = getUniqueIntValueBySelector('#carac #reg_p');
  10449. regbm = getUniqueIntValueBySelector('#carac #reg_m');
  10450. regmoy = 2 * reg + regbp + regbm; // D3
  10451. debugMZ("REG: "+reg+"+("+regbp+")+("+regbm+") ;RegMoy:" + regmoy);
  10452. // Armure
  10453. arm = getUniqueIntValueBySelector('#carac #arm');
  10454. armbp = getUniqueIntValueBySelector('#carac #arm_p');
  10455. armbm = getUniqueIntValueBySelector('#carac #arm_m');
  10456. armtourD = getUniqueIntValueBySelector('#carac #arm_tour_d');
  10457. armmoy = 2*arm + armbp+armbm;
  10458. armmoytour = 2*(arm+armtourD) + armbp+armbm;
  10459. debugMZ("ARM: "+arm+"+("+armbp+")+("+armbm+"); ArmMoy:"+armmoy+"; arm/tour:"+armtourD+"; ArmMoyTour:"+armmoytour);
  10460. // TODO : D d'armure non active
  10461. // Vue
  10462. vue = getUniqueIntValueBySelector('#carac #vue');
  10463. vuebp = getUniqueIntValueBySelector('#carac #vue_p');
  10464. vuebm = getUniqueIntValueBySelector('#carac #vue_m');
  10465. vuetotale = getUniqueIntValueBySelector('#carac #vue_tot');
  10466. debugMZ("Vue: " + vue + " + (" + vuebp + ") + (" + vuebm + ") = " + vuetotale);
  10467. // RM
  10468. rm = getUniqueIntValueBySelector('#carac #rm');
  10469. rmbp = getUniqueIntValueBySelector('#carac #rm_p');
  10470. rmbm = getUniqueIntValueBySelector('#carac #rm_m');
  10471. rmtotale = getUniqueIntValueBySelector('#carac #rm_tot');
  10472. rmTroll = rmtotale;
  10473. debugMZ("RM: " + rm + " + (" + rmbp + ") + (" + rmbm + ") = " + rmtotale);
  10474. // MM
  10475. mm = getUniqueIntValueBySelector('#carac #mm');
  10476. mmbp = getUniqueIntValueBySelector('#carac #mm_p');
  10477. mmbm = getUniqueIntValueBySelector('#carac #mm_m');
  10478. mmtotale = getUniqueIntValueBySelector('#carac #mm_tot');
  10479. mmTroll = mmtotale;
  10480. debugMZ("MM: " + mm + " + (" + mmbp + ") + (" + mmbm + ") = " + mmtotale);
  10481.  
  10482. // Heure Serveur
  10483. try {
  10484. var heureServeurSTR = document.querySelector("#hserveur").innerHTML;
  10485. heureServeurSTR = heureServeurSTR.slice(heureServeurSTR.indexOf("/") - 2, heureServeurSTR.lastIndexOf(":") + 3);
  10486. HeureServeur = new Date(StringToDate(heureServeurSTR));
  10487. } catch (e) {
  10488. window.console.warn(
  10489. "[MZ " + GM_info.script.version + "] Heure Serveur introuvable, utilisation de l'heure actuelle", e
  10490. );
  10491. HeureServeur = new Date();
  10492. }
  10493. debugMZ("HeureServeur: " + HeureServeur);
  10494.  
  10495. // ***INIT GLOBALE*** NBjours
  10496. NBjours = Math.floor((HeureServeur-datecrea)/864e5)+1;
  10497.  
  10498. // Calcul debut lien anatroliseur avec les caracteristiques connues
  10499. var amelio_dtb = function(dtb) {
  10500. if(dtb>555) {
  10501. return Math.floor((21-Math.sqrt(8*dtb/3-1479))/2);
  10502. }
  10503. return 10+Math.ceil((555-dtb)/2.5);
  10504. },
  10505. amelio_pv = Math.floor(pvbase/10)-3,
  10506. amelio_vue = vue-3,
  10507. amelio_att = att-3,
  10508. amelio_esq = esq-3,
  10509. amelio_deg = deg-3,
  10510. amelio_reg = reg-1,
  10511. amelio_arm = arm-1;
  10512. if(race==="Darkling"){amelio_reg--; }
  10513. if(race==="Durakuir"){amelio_pv-- ; }
  10514. if(race==="Kastar") {amelio_deg--; }
  10515. if(race==="Skrim") {amelio_att--; }
  10516. if(race==="Tomawak") {amelio_vue--; }
  10517.  
  10518. urlAnatrolliseur = URL_AnatrolDispas
  10519. +"outils_anatrolliseur.php?anatrolliseur=v8"
  10520. +"|r="+race.toLowerCase()
  10521. +"|dla="+amelio_dtb(dtb)
  10522. +"|pv="+amelio_pv+","+pvbp+","+pvbm
  10523. +"|vue="+amelio_vue+","+vuebp+","+vuebm
  10524. +"|att="+amelio_att+","+attbp+","+attbm
  10525. +"|esq="+amelio_esq+","+esqbp+","+esqbm
  10526. +"|deg="+amelio_deg+","+degbp+","+degbm
  10527. +"|reg="+amelio_reg+","+regbp+","+regbm
  10528. +"|arm="+amelio_arm+","+armbp+","+armbm
  10529. +"|mm="+mmtotale
  10530. +"|rm="+rmtotale+"|";
  10531. }
  10532.  
  10533. function saveProfil() {
  10534. MY_setValue(idtroll+'.caracs.attaque',att);
  10535. MY_setValue(idtroll+'.caracs.attaque.bm',(attbp+attbm));
  10536. MY_setValue(idtroll+'.caracs.attaque.bmp',attbp);
  10537. MY_setValue(idtroll+'.caracs.attaque.bmm',attbm);
  10538. if(atttourD||atttourP||atttourM) {
  10539. var bmDAttTotalTour = atttourD + Math.floor(((att+atttourD)*(atttourP+atttourM)/100));
  10540. MY_setValue(idtroll+'.bonus.DAttM',bmDAttTotalTour);
  10541. }
  10542. MY_setValue(idtroll+'.caracs.esquive',esq);
  10543. MY_setValue(idtroll+'.caracs.esquive.bm',(esqbp+esqbm));
  10544. MY_setValue(idtroll+'.caracs.esquive.bmp',esqbp);
  10545. MY_setValue(idtroll+'.caracs.esquive.bmm',esqbm);
  10546. MY_setValue(idtroll+'.caracs.esquive.nbattaques',esqtourD);
  10547. MY_setValue(idtroll+'.caracs.degats',deg);
  10548. MY_setValue(idtroll+'.caracs.degats.bm',(degbp+degbm));
  10549. MY_setValue(idtroll+'.caracs.degats.bmp',degbp);
  10550. MY_setValue(idtroll+'.caracs.degats.bmm',degbm);
  10551. if(degtourP||degtourM){
  10552. var bmDDegTotalTour = Math.floor(deg*(degtourP+degtourM)/100);
  10553. MY_setValue(idtroll+'.bonus.DDegM',bmDDegTotalTour);
  10554. }
  10555. MY_setValue(idtroll+'.caracs.regeneration',reg);
  10556. MY_setValue(idtroll+'.caracs.regeneration.bm',(regbp+regbm));
  10557. MY_setValue(idtroll+'.caracs.regeneration.bmp',regbp);
  10558. MY_setValue(idtroll+'.caracs.regeneration.bmm',regbm);
  10559. MY_setValue(idtroll+'.caracs.vue',vue);
  10560. MY_setValue(idtroll+'.caracs.vue.bm',(vuebp+vuebm));
  10561. MY_setValue(idtroll+'.caracs.vue.bmp',vuebp);
  10562. MY_setValue(idtroll+'.caracs.vue.bmm',vuebm);
  10563. MY_setValue(idtroll+'.caracs.pv',pvcourant);
  10564. MY_setValue(idtroll+'.caracs.pv.base',pvbase);
  10565. MY_setValue(idtroll+'.caracs.pv.max',pvtotal);
  10566. MY_setValue(idtroll+'.caracs.rm',rm);
  10567. MY_setValue(idtroll+'.caracs.rm.bm',(rm+rmbp+rmbm));
  10568. MY_setValue(idtroll+'.caracs.rm.bmp',rmbp);
  10569. MY_setValue(idtroll+'.caracs.rm.bmm',rmbm);
  10570. MY_setValue(idtroll+'.caracs.mm',mm);
  10571. MY_setValue(idtroll+'.caracs.mm.bm',(mm+mmbp+mmbm));
  10572. MY_setValue(idtroll+'.caracs.mm.bmp',mmbp);
  10573. MY_setValue(idtroll+'.caracs.mm.bmm',mmbm);
  10574. MY_setValue(idtroll+'.caracs.armure',arm);
  10575. MY_setValue(idtroll+'.caracs.armure.bm',(armbp+armbm));
  10576. MY_setValue(idtroll+'.caracs.armure.bmp',armbp);
  10577. MY_setValue(idtroll+'.caracs.armure.bmm',armbm);
  10578. MY_setValue(idtroll+'.position.X',posX);
  10579. MY_setValue(idtroll+'.position.Y',posY);
  10580. MY_setValue(idtroll+'.position.N',posN);
  10581. MY_setValue(idtroll+'.race',race);
  10582. MY_setValue(idtroll+'.niveau',niv);
  10583. MY_setValue(idtroll+'.idguilde',idguilde);
  10584. MY_setValue(idtroll+'.nomguilde',nomguilde);
  10585. }
  10586.  
  10587.  
  10588. /*-[functions]----------- Fonctions modifiant la page ------------------------*/
  10589.  
  10590. function setInfosCaracteristiques() {
  10591. // Modification de l'entete
  10592. var thTotal = document.querySelector("table#caracs>thead>tr>th:nth-child(6)");
  10593. thTotal.innerHTML+='|<i>Moyenne</i>';
  10594. thTotal.title="Moyenne (Moyenne ce tour)";
  10595.  
  10596. // Ajout des informations calculees
  10597. var tdAttTotal = document.querySelector("table#caracs td#att").parentElement.children[5];
  10598. tdAttTotal.innerHTML="<i>"+attmoy+"</i>";
  10599. if(attmoy!=attmoytour){tdAttTotal.innerHTML+=" ("+attmoytour+")";}
  10600.  
  10601. var tdEsqTotal = document.querySelector("table#caracs td#esq").parentElement.children[5];
  10602. tdEsqTotal.innerHTML="<i>"+esqmoy+"</i>";
  10603. if(esqmoy!=esqmoytour){tdEsqTotal.innerHTML+=" ("+esqmoytour+")";}
  10604.  
  10605. var tdDegTotal = document.querySelector("table#caracs td#deg").parentElement.children[5];
  10606. tdDegTotal.innerHTML="<i>"+degmoy+"/"+degmoycrit+"</i>";
  10607. if(degmoy!=degmoytour){tdDegTotal.innerHTML+=" ("+degmoytour+"/"+degmoycrittour+")";}
  10608.  
  10609. var trRegeneration = document.querySelector("table#caracs td#reg").parentElement;
  10610. var tdRegTotal = trRegeneration.children[5];
  10611. tdRegTotal.innerHTML = "<i>"+regmoy+"</i>";
  10612. // Temps recupere par reg (propale R')
  10613. var regmoyTemp = Math.max(0, regmoy);
  10614. var regTitle = "Temps moyen récupéré par régénération: " + Math.floor(250 * regmoyTemp / pvtotal) + " min";
  10615. var sec = Math.floor(15000 * regmoyTemp / pvtotal) % 60;
  10616. if (sec != 0) {
  10617. regTitle += " " + sec + " sec";
  10618. }
  10619. trRegeneration.title = regTitle;
  10620.  
  10621. var tdArmTotal = document.querySelector("table#caracs td#arm").parentElement.children[5];
  10622. tdArmTotal.innerHTML= "<i>"+armmoy+"</i>";
  10623. if(armmoy!=armmoytour){tdArmTotal.innerHTML+=" ("+armmoytour+")";}
  10624.  
  10625. var trRM=document.querySelector("table#caracs #rm").parentElement;
  10626. trRM.title = (Math.round(10*rm/NBjours)/10)+' ('+(Math.round(10*rmTroll/NBjours)/10)+') points de RM par jour | '
  10627. +(Math.round(10*rm/niv)/10)+' ('+(Math.round(10*rmtotale/niv)/10)+') points de RM par niveau';
  10628.  
  10629.  
  10630. var trMM=document.querySelector("table#caracs #mm").parentElement;
  10631. trMM.title = (Math.round(10*mm/NBjours)/10)+' ('+(Math.round(10*mmTroll/NBjours)/10)+') points de MM par jour | '
  10632. +(Math.round(10*mm/niv)/10)+' ('+(Math.round(10*mmtotale/niv)/10)+') points de MM par niveau';
  10633.  
  10634. var tdRefl=document.querySelector("#refl");
  10635. // TODO : prendre en compte bonus/malus D esq du tour ?
  10636. var refMoy = Math.floor(2*(reg+esq)/3)*3.5 + (esqbp);
  10637. tdRefl.innerHTML+=" <i>(moyenne : "+refMoy+")</i>";
  10638. }
  10639.  
  10640. function setLienAnatrolliseur(){
  10641. var pTableAmelio = document.querySelector("#carac>div>p");
  10642. pTableAmelio.innerHTML+=" - ";
  10643. var aElt = document.createElement("a");
  10644. aElt.setAttribute("href",urlAnatrolliseur);
  10645. aElt.setAttribute("target","_blank");
  10646. aElt.className="AllLinks";
  10647. aElt.innerHTML="Anatrolliser";
  10648. pTableAmelio.appendChild(aElt);
  10649. }
  10650. function setInfoDescription() {
  10651. var txtDateCrea = (NBjours!=1) ?
  10652. " ("+NBjours+" jours dans le hall)" :
  10653. " (Bienvenue à toi pour ton premier jour dans le hall)" ;
  10654. appendText(document.querySelector("#descr td#crea"), txtDateCrea, false);
  10655. }
  10656.  
  10657. function setInfosEtatLieux() {
  10658. var urlBricol = URL_bricol_mountyhall + 'lieux.php'+
  10659. '?search=position&orderBy=distance&posx='+
  10660. posX+'&posy='+posY+'&posn='+posN+'&typeLieu=3';
  10661. var tdPosition = document.querySelector("#pos td span#x").parentElement;
  10662. appendBr(tdPosition);
  10663. var aElt = document.createElement("a");
  10664. aElt.setAttribute("href",urlBricol);
  10665. aElt.setAttribute("target","_blank");
  10666. aElt.className="AllLinks";
  10667. aElt.innerHTML="Lieux à proximité";
  10668. tdPosition.appendChild(aElt);
  10669. }
  10670.  
  10671. function setInfosEtatPV() { // pour AM et Sacro
  10672. var
  10673. txt = "1 PV de perdu = +"+Math.floor(250/pvtotal)+" min",
  10674. sec = Math.floor(15000/pvtotal)%60,
  10675. lifebar = document.querySelector("#pos .barre-vie");
  10676. if(sec!=0) { txt += " "+sec+" sec"; }
  10677. if(lifebar) { lifebar.title = txt; }
  10678. if(pvcourant<=0) { return; }
  10679. // Difference PV p/r a equilibre de temps (propale R')
  10680. // Note : pvmin pour 0 malus = pvtotal + ceiling(pvtotal/250*(bmt+pdm))
  10681. // ***INIT GLOBALE*** pvdispo
  10682. var pvdispo = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  10683. var span = document.createElement("span");
  10684. span.title = txt;
  10685. span.style.fontStyle = "italic";
  10686. if(bmt+pdm>=0) {
  10687. txt = "Vous ne pouvez compenser aucune blessure actuellement.";
  10688. } else if(pvdispo>0) {
  10689. txt = "Vous pouvez encore perdre "+
  10690. Math.min(pvdispo,pvcourant)+
  10691. " PV sans malus de temps.";
  10692. } else if(pvdispo<0) {
  10693. txt = "Il vous manque "
  10694. +(-pvdispo)
  10695. +" PV pour ne plus avoir de malus de temps.";
  10696. } else {
  10697. txt = "Vous êtes à l'équilibre en temps (+/- 30sec).";
  10698. }
  10699. appendText(span,txt);
  10700. document.querySelector("#pos #pv_courant").parentElement.parentElement.appendChild(span);
  10701. }
  10702.  
  10703. // Complete le cadre "Experience"
  10704. function setInfosExp() {
  10705. var tdNiv = document.querySelector("#exp #niv");
  10706.  
  10707. // Calcul niveau monstre/troll min pour gain PX
  10708. var nivCibleMin = Math.ceil((2 * nivTroll - 10) / 3);
  10709. tdNiv.parentElement.title = "Vos cibles doivent être au minim de niveau " + nivCibleMin + " pour qu'elles vous rapportent des PX";
  10710.  
  10711. // Calcul PX restant
  10712. var pxRestant = (pxdistribuables + pxperso) - 2 * nivTroll;
  10713. if (pxRestant >= 0) {
  10714. var tdinfoEntrainement = document.querySelector("#exp table tr:nth-child(4) td span");
  10715. tdinfoEntrainement.innerHTML += " <i>Il vous restera " + pxRestant + " PX</i>";
  10716. }
  10717.  
  10718. // Calul pi/jour
  10719. var
  10720. tdPiTotal=document.querySelector("#exp #pitot").parentElement,
  10721. tdPi = document.querySelector("#exp #pi").parentElement;
  10722. tdPiTotal.title=(Math.round(10 * (pitotal + pxperso + pxdistribuables) / NBjours) / 10) + ' PI par jour'
  10723. tdPi.title = tdPiTotal.title;
  10724.  
  10725. // Rapports meurtres,morts
  10726. var tdKill = document.querySelector("#exp #kill");
  10727. tdKill.setAttribute("colspan", 1);
  10728. appendTdText(tdKill.parentElement, (Math.round(10 * NBjours / nbmeurtres) / 10) + ' jours/kill', false);
  10729.  
  10730. var tdMort = document.querySelector("#exp #mort");
  10731. tdMort.setAttribute("colspan", 1);
  10732. appendTdText(tdMort.parentElement, (Math.round(10 * NBjours / nbmorts) / 10) + ' jours/mort', false);
  10733.  
  10734. tdKill.parentElement.title = 'Rapport meurtres/décès: ' + Math.floor((nbmeurtres / nbmorts) * 100) / 100;
  10735. tdMort.parentElement.title = 'Rapport décès/meurtres: ' + Math.floor((nbmorts / nbmeurtres) * 100) / 100;
  10736. }
  10737.  
  10738.  
  10739. /*-[functions]----------- Fonctions speciales Kastars ------------------------*/
  10740.  
  10741. function minParPVsac(fat,bm) {
  10742. // Calcule le nombre de min gagnees / PV sacrifies pour une AM realisee sous
  10743. // fatigue = 'fat', sans et avec un bm de fatigue = 'bm'
  10744. var out = [];
  10745. out[0] = (fat>4) ?
  10746. Math.floor(120/( fat*(1+Math.floor(fat/10)) )) :
  10747. 30;
  10748. if(bm && bm>0) {
  10749. var totalfat=fat+bm;
  10750. out[1] = (totalfat>4) ?
  10751. Math.floor(120/( totalfat*(1+Math.floor(totalfat/10)) )) :
  10752. 30; // en principe inutile pour des bm fat >= 15 mais bon...
  10753. }
  10754. return out;
  10755. }
  10756.  
  10757. function toInt(str) {
  10758. str = parseInt(str);
  10759. return (str) ? str : 0;
  10760. }
  10761.  
  10762. function saveLastDLA() {
  10763. // pour les calculs d'AM max
  10764. var str = addZero(toInt(inJour.value))+'/'+addZero(toInt(inMois.value))
  10765. +'/'+toInt(inAn.value)+' '+addZero(toInt(inHr.value))
  10766. +':'+addZero(toInt(inMin.value))+':'+addZero(toInt(inSec.value));
  10767. lastDLA = new Date( StringToDate(str) );
  10768. MY_setValue(numTroll+'.DLA.ancienne',str);
  10769. lastDLAZone.innerHTML = '';
  10770. var b = document.createElement('b');
  10771. b.addEventListener('click',inputMode,false);
  10772. appendText(b,str);
  10773. lastDLAZone.appendChild(b);
  10774. refreshAccel();
  10775. }
  10776.  
  10777. function inputMode() {
  10778. // Edition manuelle lastDLA
  10779. var date;
  10780. if(lastDLA)
  10781. date = new Date( lastDLA );
  10782. else
  10783. date = new Date( DLAaccel );
  10784. lastDLAZone.innerHTML = '';
  10785. inJour = appendTextbox(lastDLAZone,'text','inJour',1,2,date.getDate());
  10786. appendText(lastDLAZone,'/');
  10787. inMois = appendTextbox(lastDLAZone,'text','inMois',1,2,1+date.getMonth());
  10788. appendText(lastDLAZone,'/');
  10789. inAn = appendTextbox(lastDLAZone,'text','inAn',3,4,date.getFullYear());
  10790. appendText(lastDLAZone,' - ');
  10791. inHr = appendTextbox(lastDLAZone,'text','inHr',1,2,date.getHours()+'');
  10792. appendText(lastDLAZone,':');
  10793. inMin = appendTextbox(lastDLAZone,'text','inMin',1,2,date.getMinutes()+'');
  10794. appendText(lastDLAZone,':');
  10795. inSec = appendTextbox(lastDLAZone,'text','inSec',1,2,date.getSeconds()+'');
  10796. appendText(lastDLAZone,' - ');
  10797. appendButton(lastDLAZone,'Enregistrer',saveLastDLA);
  10798. }
  10799.  
  10800. function setAccel() {
  10801. var
  10802. BMfrais=false,
  10803. fat=fatigue, listeBmFat=[],
  10804. tr, th, insertPt;
  10805.  
  10806. // Creation ligne speciale pour AM dans le cadre "Etat"
  10807. tr = document.createElement('tr');
  10808. th = document.createElement('th');
  10809. appendText(th,'Fatigue et AM',true);
  10810. tr.appendChild(th);
  10811. insertPt = document.createElement('td');
  10812. tr.appendChild(insertPt);
  10813. document.querySelector('#pos table>tbody').insertBefore(tr,null);
  10814.  
  10815. // Est-on en over-DLA ?
  10816. // ***INIT GLOBALE*** overDLA
  10817. overDLA = (HeureServeur>DLA.getTime()+3e5);
  10818. if(overDLA) {
  10819. fat=Math.floor(fatigue/1.25);
  10820. }
  10821.  
  10822. // Gestion des BM de fatigue
  10823. if(bmfatigue>0) {
  10824. // On tente de recuperer les BM de fatigue de la page des BM
  10825. if(MY_getValue(numTroll+'.bm.fatigue')) {
  10826. var BMmemoire = MY_getValue(numTroll+'.bm.fatigue').split(';');
  10827. BMmemoire.pop();
  10828. var tour = 0;
  10829. for(var i=0 ; i<BMmemoire.length ; i++) {
  10830. var nbrs = BMmemoire[i].match(/\d+/g); // [tour,fatigue]
  10831. while(tour<=parseInt(nbrs[0])) {
  10832. listeBmFat[tour]=parseInt(nbrs[1]);
  10833. tour++;
  10834. }
  10835. }
  10836. }
  10837. if(listeBmFat[0]==bmfatigue) {
  10838. // Si (bm profil=1er bm stocke), on suppose que les bm stockes sont a jour
  10839. BMfrais = true;
  10840. MY_removeValue(numTroll+".bm.fatigue");
  10841. }
  10842. } else {
  10843. // S'il n'y a pas de bm de fatigue sur le profil, on est a jour
  10844. BMfrais = true;
  10845. }
  10846. if(!BMfrais && bmfatigue>0) {
  10847. // si les BM n'ont pas ete rafraichis, on conjecture le pire:
  10848. if(bmfatigue==15) {
  10849. listeBmFat = [15,15,15];
  10850. } else {
  10851. listeBmFat = [30,30,15];
  10852. }
  10853. }
  10854. if(overDLA) {
  10855. // Si on est en over-DLA, on decale les bm d'un tour
  10856. listeBmFat.shift();
  10857. }
  10858. // Tableau des fatigues et accel futures
  10859. var
  10860. minppv = minParPVsac(fat,listeBmFat[0]),
  10861. table, tbody,
  10862. ligneTour, ligneFat, ligneMin,
  10863. col;
  10864. // ***INIT GLOBALE*** minParPV
  10865. minParPV = (listeBmFat[0]==void(0)) ? minppv[0] : minppv[1];
  10866. if(fat>0 || listeBmFat[0]>0) {
  10867. table = document.createElement('table');
  10868. table.className = 'mh_tdborder';
  10869. table.border = 0;
  10870. table.cellSpacing = 1;
  10871. table.cellPadding = 1;
  10872. table.style.textAlign = "center";
  10873. tbody = document.createElement('tbody');
  10874. table.appendChild(tbody);
  10875. insertPt.appendChild(table);
  10876. ligneTour = appendTr(tbody,'mh_tdtitre');
  10877. ligneTour.style.fontWeight = "bold";
  10878. var td = appendTdText(ligneTour,'Tour :',true);
  10879. td.align = 'left';
  10880. ligneFat = appendTr(tbody,'mh_tdpage');
  10881. td = appendTdText(ligneFat,'Fatigue :',true);
  10882. td.className = 'mh_tdtitre';
  10883. td.align = 'left';
  10884. ligneMin = appendTr(tbody,'mh_tdpage');
  10885. td = appendTdText(ligneMin,'1 PV =',true);
  10886. td.className = 'mh_tdtitre';
  10887. td.align = 'left';
  10888. col=0;
  10889. while(col<9 && (fat>0 || listeBmFat[col])) {
  10890. if(col==0) {
  10891. if(overDLA) {
  10892. var i = document.createElement('i');
  10893. appendText(i,'A activer');
  10894. ligneTour.appendChild(i);
  10895. } else {
  10896. appendTdText(ligneTour,'En cours');
  10897. }
  10898. } else {
  10899. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10900. }
  10901. if(listeBmFat[col]) {
  10902. if(BMfrais || (!overDLA && col==0)) {
  10903. appendTdText(ligneFat,fat+'+'+listeBmFat[col]);
  10904. appendTdText(ligneMin,minppv[1]+'\'');
  10905. } else {
  10906. appendTdText(ligneFat,fat+'+'+listeBmFat[col]+' (?)');
  10907. appendTdText(ligneMin,minppv[1]+'\' ('+minppv[0]+'\')');
  10908. }
  10909. } else {
  10910. appendTdText(ligneFat,fat);
  10911. appendTdText(ligneMin,minppv[0]+'\'');
  10912. }
  10913. col++;
  10914. fat = Math.floor(fat / 1.25);
  10915. minppv = minParPVsac(fat,listeBmFat[col]);
  10916. }
  10917. if(fat>1 || (fat==1 && !overDLA)) {
  10918. appendTdText(ligneTour,'\u00A0 ... \u00A0',true);
  10919. appendTdText(ligneFat,'-');
  10920. appendTdText(ligneMin,'-');
  10921. }
  10922. col = (overDLA) ?
  10923. Math.max(retourAZero(fatigue)-1,col) :
  10924. Math.max(retourAZero(fatigue),col);
  10925. appendTdText(ligneTour,'\u00A0\u00A0+'+col+'\u00A0\u00A0');
  10926. appendTdText(ligneFat,'0');
  10927. appendTdText(ligneMin,'30\'');
  10928. if(!BMfrais && bmfatigue) {
  10929. // si les BM n'ont pas ete rafraichis, on signale:
  10930. appendText(
  10931. insertPt,
  10932. '/!\\ Visitez la page des Bonus/Malus '+
  10933. 'pour mettre à jour votre fatigue. /!\\',
  10934. true
  10935. );
  10936. appendBr(insertPt);
  10937. }
  10938. appendBr(insertPt);
  10939. }
  10940. if(pvcourant<=0) {
  10941. appendText(insertPt,'Aucun calcul possible : vous êtes mort voyons !');
  10942. return;
  10943. }
  10944. if(fatigue>30) {
  10945. appendText(insertPt,'Vous êtes trop fatigué pour accélérer.');
  10946. return;
  10947. }
  10948. // Setup lastDLAZone
  10949. if(overDLA) {
  10950. // bypass des infos de "menu_FF.js" en cas d'overDLA
  10951. DLAaccel = new Date( DLAsuiv );
  10952. lastDLA = new Date( DLA );
  10953. MY_setValue(numTroll+'.DLA.ancienne',DateToString(DLA));
  10954. // ***INIT GLOBALE*** pvActuelKastar
  10955. pvActuelKastar = Math.min(pvcourant+regmoy,pvtotal);
  10956. appendText(
  10957. insertPt,
  10958. '/!\\ Votre DLA est dépassée, calculs basés sur des estimations. /!\\',
  10959. true
  10960. );
  10961. appendBr(insertPt);
  10962. } else {
  10963. DLAaccel = new Date( DLA );
  10964. pvActuelKastar = pvcourant;
  10965. if(MY_getValue(numTroll+'.DLA.ancienne')) {
  10966. lastDLA = new Date(StringToDate(MY_getValue(numTroll+'.DLA.ancienne')));
  10967. } else {
  10968. lastDLA = false;
  10969. }
  10970. }
  10971. appendText(insertPt,'Dernière DLA enregistrée : ');
  10972. lastDLAZone = document.createElement('span');
  10973. lastDLAZone.style.cursor = 'pointer';
  10974. var b = document.createElement('b');
  10975. b.onclick = inputMode;
  10976. lastDLAZone.appendChild(b);
  10977. insertPt.appendChild(lastDLAZone);
  10978. if(lastDLA) {
  10979. appendText(b,DateToString(lastDLA));
  10980. } else {
  10981. appendText(b,'aucune');
  10982. }
  10983. appendBr(insertPt);
  10984. // Setup maxAMZone et cumulZone
  10985. appendText(insertPt,'Accélération maximale possible : ');
  10986. maxAMZone = document.createElement('b');
  10987. insertPt.appendChild(maxAMZone);
  10988. appendBr(insertPt);
  10989. cumulZone = document.createElement('span');
  10990. insertPt.appendChild(cumulZone);
  10991. refreshAccel();
  10992. }
  10993.  
  10994. function refreshAccel() {
  10995. var pvs, pvsmax;
  10996. // Acceleration pour cumul instantane
  10997. //window.console.debug('refreshAccel',pvActuelKastar,DLAaccel,lastDLA,minParPV);
  10998. if(lastDLA) {
  10999. pvsmax = Math.min(
  11000. pvActuelKastar-1,
  11001. Math.ceil( Math.floor((DLAaccel-lastDLA)/6e4)/minParPV )
  11002. );
  11003. maxAMZone.innerHTML = pvsmax+" PV";
  11004. } else {
  11005. pvsmax = pvActuelKastar-1;
  11006. maxAMZone.innerHTML = "inconnue";
  11007. }
  11008. // pvAccel = (nb min avant DLA (arr. sup) / nb min p/ PVsac) (arrondi sup)
  11009. pvs = Math.ceil( Math.ceil((DLAaccel-HeureServeur)/6e4) / minParPV );
  11010. cumulZone.innerHTML = '';
  11011. if(pvs<=pvsmax) {
  11012. appendText(cumulZone,'Vous devez accélérer d\'au moins ');
  11013. appendText(cumulZone,pvs+' PV', true);
  11014. appendText(cumulZone,' pour activer immédiatement un nouveau tour.');
  11015. if(pvs!=1) {
  11016. var gainSec = Math.floor((DLAaccel-HeureServeur)/1e3)
  11017. -(pvs-1)*60*minParPV;
  11018. appendText(
  11019. cumulZone,
  11020. ' ('+(pvs-1)+' PV dans '+
  11021. Math.floor(gainSec/60)+'min'+
  11022. addZero(gainSec%60)+'s)'
  11023. );
  11024. }
  11025. } else {
  11026. var avantDLA = new Date( DLAaccel-HeureServeur-pvsmax*minParPV*6e4 );
  11027. appendText(
  11028. cumulZone,
  11029. 'Après votre accélération maximale, il vous faudra encore attendre '+
  11030. dureeHM(avantDLA/6e4)+
  11031. ' avant de réactiver.'
  11032. );
  11033. }
  11034. }
  11035.  
  11036.  
  11037. /*-[functions]-------- Fonctions gerant les infos-bulles ---------------------*/
  11038.  
  11039. function traitementTalents() {
  11040. trCompetence = document.querySelectorAll("#comp table#competences>tbody>tr");
  11041. trSorts = document.querySelectorAll("#sort table#sortileges>tbody>tr");
  11042. removeAllTalents();
  11043. var totalComp = injecteInfosBulles(trCompetence,'competences');
  11044. var totalSort = injecteInfosBulles(trSorts,'sortileges');
  11045. document.querySelector('#comp>div>h3.mh_tdtitre').textContent+=' (Total : '+totalComp+'%)';
  11046. document.querySelector('#sort>div>h3.mh_tdtitre').textContent+=' (Total : '+totalSort+'%)';
  11047. }
  11048.  
  11049. function injecteInfosBulles(liste,fonction) {
  11050. var totalpc = 0;
  11051. // on parse la liste des talents du type 'fonction'
  11052. for(var i=0 ; i<liste.length ; i++) {
  11053. var
  11054. trTalent=liste[i],
  11055. node=trTalent.cells[1].querySelector('a'),
  11056. nomTalent=epure(trim(node.textContent)),
  11057. indiceTDniveaux=7,
  11058. indiceTDSousCompetence=2,
  11059. sousCompetences=undefined;
  11060. if(fonction=="competences"){
  11061. // un TD en plus pour des information complementaire liees a la comp
  11062. indiceTDniveaux++;
  11063. // chercher les sous-compétence (type de golem, type de piège) s'il y a
  11064. sousCompetences = trTalent.cells[indiceTDSousCompetence].textContent.split(',');
  11065. for (var j=0; j < sousCompetences.length; j++) {
  11066. sousCompetences[j] = sousCompetences[j].epure().trim();
  11067. if (arrayTalents[sousCompetences[j]]) sousCompetences[j] = arrayTalents[sousCompetences[j]];
  11068. }
  11069. }
  11070. var niveauxMaitrisesTalentArray=getNumbers(trTalent.cells[indiceTDniveaux].textContent);
  11071. setInfos(node,nomTalent,fonction,niveauxMaitrisesTalentArray[0]);
  11072. setTalent(nomTalent,niveauxMaitrisesTalentArray[1],niveauxMaitrisesTalentArray[0],sousCompetences);
  11073. totalpc += niveauxMaitrisesTalentArray[1];
  11074.  
  11075. // stockage des niveaux inferieurs du talent si presents
  11076. for(var j=2 ; j<niveauxMaitrisesTalentArray.length ; j+=2) {
  11077. setTalent(nomTalent,niveauxMaitrisesTalentArray[j+1],niveauxMaitrisesTalentArray[j],sousCompetences);
  11078. totalpc+=niveauxMaitrisesTalentArray[j+1];
  11079. }
  11080. }
  11081. return totalpc;
  11082. }
  11083.  
  11084. function setInfos(node,nom,fonction,niveau) {
  11085. node.nom = nom;
  11086. node.fonction = fonction;
  11087. node.niveau = niveau;
  11088. node.onmouseover = setBulle;
  11089. node.onmouseout = cacherBulle;
  11090. }
  11091.  
  11092. var arrayModifAnatroll = {
  11093. 'Glue':'Glu',
  11094. 'PuM':'PuiM',
  11095. 'HE':'Hurlement',
  11096. //'Insultes':'Insu',
  11097. 'Pistage':'Pist',
  11098. 'PuC':'Planter'
  11099. }
  11100.  
  11101. function setTalent(nom,pc,niveau,sousCompetences) {
  11102. // Nota : voir plus tard si stocker les effets des comps/sorts directement
  11103. // (et pas les % dont osf) ne serait pas plus rentable
  11104. var nomEnBase = arrayTalents[epure(nom)];
  11105. if(!nomEnBase) { return; }
  11106. if(!niveau) { niveau = 1; }
  11107. switch(nomEnBase) {
  11108. case 'Insultes':
  11109. urlAnatrolliseur += 'Insu'+niveau+'|';
  11110. case 'IdT':
  11111. nomEnBase += niveau;
  11112. break;
  11113. case 'Golemo':
  11114. case 'Piege':
  11115. for (var i=0 ; i < sousCompetences.length ; i++) {
  11116. urlAnatrolliseur += (arrayModifAnatroll[sousCompetences[i]] ?
  11117. arrayModifAnatroll[sousCompetences[i]] : sousCompetences[i]) + '|';
  11118. }
  11119. break;
  11120. case 'AP':
  11121. case 'Baroufle':
  11122. case 'CdB':
  11123. case 'CdM':
  11124. case 'Parer':
  11125. case 'Retraite':
  11126. case 'RB':
  11127. case 'SInterposer':
  11128. nomEnBase += niveau;
  11129. default:
  11130. urlAnatrolliseur += (arrayModifAnatroll[nomEnBase] ?
  11131. arrayModifAnatroll[nomEnBase] : nomEnBase) + '|';
  11132. }
  11133. MY_setValue(numTroll+'.talent.'+nomEnBase,pc);
  11134. }
  11135.  
  11136. function creerBulleVide() {
  11137. var table = document.createElement('table');
  11138. table.id = 'bulle';
  11139. table.className = 'mh_tdborder';
  11140. table.width = 300;
  11141. table.border = 0;
  11142. table.cellPadding = 5;
  11143. table.cellSpacing = 1;
  11144. table.style =
  11145. 'position:absolute;'
  11146. +'visibility:hidden;'
  11147. +'z-index:800;'
  11148. +'height:auto;';
  11149. var tr = appendTr(table,'mh_tdtitre');
  11150. appendTdText(tr,'Titre');
  11151. tr = appendTr(table,'mh_tdpage');
  11152. appendTdText(tr,'Contenu');
  11153. var aList = document.getElementsByTagName('a');
  11154. aList[aList.length-1].parentNode.appendChild(table);
  11155. }
  11156.  
  11157. function cacherBulle() {
  11158. if(bulleStyle)
  11159. bulleStyle.visibility = 'hidden';
  11160. }
  11161.  
  11162. function setBulle(evt) {
  11163. var nom = this.nom;
  11164. var fonction = this.fonction;
  11165. var niveau = parseInt(this.niveau);
  11166. var str='';
  11167. if(fonction=='competences'){
  11168. str=competences(nom,niveau);
  11169. } else if(fonction=='sortileges') {
  11170. str=sortileges(nom,true);
  11171. }
  11172. if(str=='') return;
  11173. if(nom.indexOf('Golem')!=-1) nom='Golemologie';
  11174. var xfenetre, yfenetre, xpage, ypage, element = null;
  11175. var offset = 15;
  11176. var bulleWidth = 300;
  11177. if(!hauteur) hauteur = 50;
  11178. element = document.getElementById('bulle');
  11179. xfenetre = evt.clientX;
  11180. yfenetre = evt.clientY;
  11181. xpage = xfenetre;
  11182. ypage = yfenetre;
  11183. if(evt.pageX) xpage = evt.pageX;
  11184. if(evt.pageY) ypage = evt.pageY;
  11185. if(element) {
  11186. bulleStyle = element.style;
  11187. element.firstChild.firstChild.innerHTML = '<b>'+nom+'</b>';
  11188. element.childNodes[1].firstChild.innerHTML = str;
  11189. }
  11190. if(bulleStyle) {
  11191. if(xfenetre>bulleWidth+offset)
  11192. xpage -= bulleWidth+offset;
  11193. else
  11194. xpage += offset;
  11195. if(yfenetre>hauteur+offset)
  11196. ypage -= hauteur + offset;
  11197. bulleStyle.width = bulleWidth;
  11198. bulleStyle.left = xpage + 'px';
  11199. bulleStyle.top = ypage + 'px';
  11200. bulleStyle.visibility = 'visible';
  11201. }
  11202. }
  11203.  
  11204.  
  11205. /*-[functions] Textes des infos-bulles pour les competences et sortileges ----*/
  11206.  
  11207. function competences(comp,niveau) {
  11208. var texte = '';
  11209. if(comp.indexOf('Acceleration du Metabolisme')!=-1 && minParPV!=null) {
  11210. texte = '<b>1</b> PV = <b>'+minParPV+'</b> minute';
  11211. if(minParPV>1) texte += 's';
  11212. if(overDLA) texte += '<br/><i>(Votre DLA est dépassée.)</i>';
  11213. }
  11214. else if(comp.indexOf('Attaque Precise')!=-1) {
  11215. var pc, lastmax=0, espatt=0;
  11216. var notMaxedOut = false;
  11217. for(var i=niveau ; i>0 ; i--) {
  11218. pc = getTalent(comp,i);
  11219. if(lastmax!=0 && pc<=lastmax) continue;
  11220. var jetatt = Math.round(3.5*Math.min(Math.floor(1.5*att),att+3*i))+
  11221. attbp+attbm;
  11222. texte += 'Attaque niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11223. Math.min(Math.floor(att*1.5),att+3*i)+'</b> D6 '+aff(attbp+attbm)+
  11224. ' => <b>'+jetatt+'</b><br/>';
  11225. espatt += (pc-lastmax)*jetatt;
  11226. lastmax = pc;
  11227. if(i<niveau) notMaxedOut = true;
  11228. }
  11229. if(notMaxedOut) {
  11230. texte += '<i>Attaque moyenne (si réussite) : <b>'+
  11231. Math.floor(10*espatt/lastmax)/10+'</b></i><br/>';
  11232. }
  11233. texte += 'Dégâts : <b>'+deg+'</b> D3 '+aff(degbp+degbm)+
  11234. ' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11235. }
  11236. else if(comp.indexOf('Balayage')!=-1)
  11237. texte = 'Déstabilisation : <b>'+att+'</b> D6 '+aff(attbp+attbm)
  11238. +' => <b>'+attmoy+'</b><br/>'
  11239. +'Effet : <b>Met à terre l\'adversaire</b>';
  11240. else if(comp.indexOf('Bidouille')!=-1)
  11241. texte = 'Bidouiller un trésor permet de compléter le nom d\'un objet '
  11242. +'de votre inventaire avec le texte de votre choix.';
  11243. else if(comp.indexOf('Baroufle')!=-1){
  11244. texte = 'Vous voulez encourager vos compagnons de chasse ? '
  11245. +'Ramassez quelques Coquillages, et en avant la musique !<br>';
  11246. texte +='<table class="mh_tdborder" cellspacing="1" cellpadding="1" border="0"><tbody>' +
  11247. '<tr class="mh_tdtitre"><th>Nom</th><th>Effet</th></tr>' +
  11248. '<tr class="mh_tdpage"><td>Booong</td><td>deg +1 / esq -1</td></tr>' +
  11249. '<tr class="mh_tdpage"><td>Badaboum</td><td>att +1</td></tr>' +
  11250. '<tr class="mh_tdpage"><td>Zbouing </td><td>reg +1</td></tr>' +
  11251. '<tr class="mh_tdpage"><td>Whoooom</td><td>concentration +2</td></tr>' +
  11252. '<tr class="mh_tdpage"><td>Krouiiik</td><td>concentration -2</td></tr>' +
  11253. '<tr class="mh_tdpage"><td>Tuutuuuut</td><td>att -1</td></tr>' +
  11254. '<tr class="mh_tdpage"><td>Gaaaw</td><td>Fatigue +1</td></tr>' +
  11255. '<tr class="mh_tdpage"><td>Huitsch</td><td>deg -1</td></tr>' +
  11256. '<tr class="mh_tdpage"><td>Kliketiiik</td><td>esq -1 / concentration -1</td></tr>' +
  11257. '<tr class="mh_tdpage"><td>Kssksss</td><td>esq +1</td></tr>' +
  11258. '<tr class="mh_tdpage"><td>Praaaouuut</td><td>reg-1 </td></tr>'+
  11259. '<tr class="mh_tdpage"><td>Sssrileur</td><td>seuil 6, rend visible</td></tr>' +
  11260. '<tr class="mh_tdpage"><td>Tagadagada</td><td>augmente le nombre de tours (1 tour par tranche de 2)</td></tr>' +
  11261. '<tr class="mh_tdpage"><td>Ytseukayndof</td><td>seuil 2, rend les bonus magiques</td></tr>' +
  11262. '<tr class="mh_tdpage"><td>Whaaag</td><td>augmente la portée horizontale (1 case par tranche de 4)</td></tr>' +
  11263. '</tbody></table>';
  11264. }
  11265. else if(comp.indexOf('Botte Secrete')!=-1){
  11266. texte = 'Attaque : <b>'
  11267. +Math.floor(2*att/3)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11268. +' => <b>'
  11269. +Math.round(3.5*Math.floor(2*att/3)+Math.floor((attbp+attbm)/2))
  11270. +'</b><br/>Dégâts : <b>'
  11271. +Math.floor(att/2)+'</b> D3 '+aff(Math.floor((degbp+degbm)/2))
  11272. +' => <b>'
  11273. +(2*Math.floor(att/2)+Math.floor((degbp+degbm)/2))
  11274. +'/'+(2*Math.floor(1.5*Math.floor(att/2))+Math.floor((degbp+degbm)/2))
  11275. +'</b>';
  11276. }
  11277. else if(comp.indexOf('Camouflage')!=-1) {
  11278. var camou = getTalent('Camouflage');
  11279. texte = 'Pour conserver son camouflage, il faut réussir un jet sous:<br/>'
  11280. +'<i>Déplacement :</i> <b>'+Math.floor(0.75*camou)+'%</b><br/>'
  11281. +'<i>Attaque :</i> <b>perte automatique</b>.<br/>'
  11282. +'<i>Projectile Magique :</i> <b>'+Math.floor(0.25*camou)+'%</b>';
  11283. }
  11284. else if(comp.indexOf('Charger')!=-1) {
  11285. if(pvcourant<=0)
  11286. return '<i>On ne peut charger personne quand on est mort !</i>';
  11287. var portee = Math.min(
  11288. getPortee__Profil(reg+Math.floor(pvcourant/10))-Math.floor((fatigue+bmfatigue)/5),
  11289. vuetotale);
  11290. if(portee<1)
  11291. return '<b>Impossible de charger</b>';
  11292. else {
  11293. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11294. +' => <b>'+attmoy+'</b><br/>'
  11295. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11296. +' => <b>'+degmoy+'/'+degmoycrit+'</b>'
  11297. +'<br/>Portée : <b>'+portee+'</b> case';
  11298. if(portee>1) texte += 's';
  11299. }
  11300. }
  11301. else if(comp.indexOf('Connaissance des Monstres')!=-1) {
  11302. texte = 'Portée horizontale : <b>'+vuetotale+'</b> case';
  11303. if(vuetotale>1) texte += 's';
  11304. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11305. if(vuetotale>2) texte += 's';
  11306. }
  11307. else if(comp.indexOf('Piege')!=-1) {
  11308. if(comp.indexOf('Glue')!=-1)
  11309. texte = 'Et si vous colliez vos adversaires au sol ?';
  11310. if(comp.indexOf('Feu')!=-1) {
  11311. if(texte){
  11312. texte += ' À moins que vous ne préfériez les envoyer en l\'air !<br/>';
  11313. }
  11314. texte += 'Dégats du piège à feu : <b>'+Math.floor((esq+vue)/2)+'</b> D3'
  11315. +' => <b>'+2*Math.floor((esq+vue)/2)+' ('+resiste((esq+vue)/2)+')</b>';
  11316. }
  11317. }
  11318. else if(comp.indexOf('Contre-Attaquer')!=-1){
  11319. texte = 'Attaque : <b>'
  11320. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2))
  11321. +' => <b>'+Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11322. +'</b><br/>Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11323. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11324. }
  11325. else if(comp.indexOf('Coup de Butoir')!=-1) {
  11326. var pc, lastmax=0, espdeg=0;
  11327. var notMaxedOut = false;
  11328. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11329. +' => <b>'+attmoy+'</b>';
  11330. for(var i=niveau ; i>0 ; i--) {
  11331. pc = getTalent(comp,i);
  11332. if(lastmax!=0 && pc<=lastmax) continue;
  11333. var jetdeg = 2*Math.min(Math.floor(1.5*deg),deg+3*i)+(degbp+degbm);
  11334. texte += '<br/>Dégâts niv. '+i+' ('+(pc-lastmax)+'%) : <b>'+
  11335. Math.min(Math.floor(deg*1.5),deg+3*i)+'</b> D6 '+aff((degbp+degbm))+
  11336. ' => <b>'+jetdeg+'/'+(jetdeg+2*Math.floor(deg/2))+'</b>';
  11337. espdeg += (pc-lastmax)*jetdeg;
  11338. lastmax = pc;
  11339. if(i<niveau) notMaxedOut = true;
  11340. }
  11341. if(notMaxedOut) {
  11342. texte += '<br/><i>Dégâts moyens (si réussite) : <b>'+
  11343. Math.floor(10*espdeg/lastmax)/10+'/'+
  11344. (Math.floor(10*espdeg/lastmax)/10+2*Math.floor(deg/2))+'</b></i>';
  11345. }
  11346. }
  11347. else if(comp.indexOf('Course')!=-1)
  11348. texte = 'Déplacement gratuit : <b>'
  11349. +Math.floor(getTalent('Course')/2)
  11350. +' %</b> de chance';
  11351. else if(comp.indexOf('Deplacement Eclair')!=-1)
  11352. texte = 'Permet d\'économiser <b>1</b> PA '
  11353. +'par rapport au déplacement classique';
  11354. else if(comp.indexOf('Dressage')!=-1)
  11355. texte = 'Le dressage permet d\'apprivoiser un gowap redevenu sauvage '
  11356. +'ou un gnu sauvage.';
  11357. else if(comp.indexOf('Ecriture Magique')!=-1)
  11358. texte = 'Réaliser la copie d\'un sortilège après en avoir découvert '
  11359. +'la formule nécessite de réunir les composants de cette formule, '
  11360. +'d\'obtenir un parchemin vierge sur lequel écrire, et de récupérer '
  11361. +'un champignon adéquat pour confectionner l\'encre.';
  11362. else if(comp.indexOf('Frenesie')!=-1) {
  11363. texte = 'Attaque : <b>'+att+'</b> D6 '+aff((attbp+attbm))
  11364. +' => <b>'+attmoy+'</b><br/>'
  11365. +'Dégâts : <b>'+deg+'</b> D3 '+aff((degbp+degbm))
  11366. +' => <b>'+degmoy+'/'+degmoycrit+'</b>';
  11367. }
  11368. else if(comp.indexOf('Golem')!=-1)
  11369. texte = 'Animez votre golem en assemblant divers matériaux '
  11370. +'autour d\'un cerveau minéral.'
  11371. else if(comp.indexOf('Grattage')!=-1) {
  11372. texte = 'Permet de confectionner un Parchemin Vierge '
  11373. +'à partir de composants et de Gigots de Gob\'.';
  11374. }
  11375. else if(comp.indexOf('Hurlement Effrayant')!=-1)
  11376. texte = 'Fait fuir un monstre si tout se passe bien.'
  11377. +'<br/>Lui donne de gros bonus sinon...';
  11378. else if(comp.indexOf('Identification des Champignons')!=-1) {
  11379. texte = 'Portée horizontale : <b>'+Math.ceil(vuetotale/2)+'</b> case';
  11380. if(vuetotale>2) texte += 's';
  11381. texte += '<br/>Portée verticale : <b>'+Math.ceil(vuetotale/4)+'</b> case';
  11382. if(vuetotale>4) texte += 's';
  11383. }
  11384. else if(comp.indexOf('Insultes')!=-1)
  11385. texte = 'Portée horizontale : <b>'+Math.min(vuetotale,1)+'</b> case';
  11386. else if(comp.indexOf('interposer')!=-1)
  11387. texte = 'Jet de réflexe : <b>'
  11388. +Math.floor(2*(esq+reg)/3)+'</b> D6 '+aff((esqbp+esqbm))
  11389. +' => <b>'+Math.round(3.5*Math.floor(2*(esq+reg)/3)+(esqbp+esqbm))+'</b>';
  11390. else if(comp.indexOf('Lancer de Potions') != -1)
  11391. texte = 'Portée : <b>'+(2+Math.floor(vuetotale/5))+'</b> cases';
  11392. else if(comp.indexOf('Marquage')!=-1)
  11393. texte = 'Marquage permet de rajouter un sobriquet à un monstre. Il faut '
  11394. +'bien choisir le nom à ajouter car celui-ci sera définitif. Il faut '
  11395. +'se trouver dans la même caverne que le monstre pour le marquer.';
  11396. else if(comp.indexOf('Melange Magique')!=-1)
  11397. texte = 'Cette Compétence permet de combiner deux Potions pour '
  11398. +'en réaliser une nouvelle dont l\'effet est la somme '
  11399. +'des effets des potions initiales.';
  11400. else if(comp.indexOf('Miner')!=-1)
  11401. texte = 'Portée horizontale (officieuse) : <b>'
  11402. +2*vuetotale+'</b> cases<br/>'
  11403. +'Portée verticale (officieuse) : <b>'
  11404. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11405. else if(comp.indexOf('Necromancie')!=-1)
  11406. texte = 'La Nécromancie permet à partir des composants d\'un monstre '
  11407. +'de faire "revivre" ce monstre.';
  11408. else if(comp.indexOf('Painthure de Guerre')!=-1)
  11409. texte = 'Grimez vos potrõlls et réveillez l\'esprit guerrier '
  11410. +'qui sommeille en eux ! Un peu d\'encre, une Tête Réduite '
  11411. +'pour s\'inspirer, et laissez parler votre créativité.'
  11412. else if(comp.indexOf('Parer')!=-1)
  11413. texte = 'Jet de parade : <b>'
  11414. +Math.floor(att/2)+'</b> D6 '+aff(Math.floor((attbp+attbm))/2)
  11415. +' => <b>'
  11416. +Math.round(3.5*Math.floor(att/2)+Math.floor((attbp+attbm)/2))
  11417. +'</b><hr><i>Equivalent esquive : <b>'
  11418. +(Math.floor(att/2)+esq)+'</b> D6 '+aff(Math.floor((attbp+attbm)/2)+(esqbp+esqbm))
  11419. +' => <b>'
  11420. +(Math.round(3.5*(Math.floor(att/2)+esq)+Math.floor((attbp+attbm)/2))+(esqbp+esqbm))
  11421. +'</b></i>';
  11422. else if(comp.indexOf('Pistage')!=-1)
  11423. texte = 'Portée horizontale : <b>'
  11424. +2*vuetotale+'</b> cases<br/>'
  11425. +'Portée verticale : <b>'
  11426. +2*Math.ceil(vuetotale/2)+'</b> cases';
  11427. else if(comp.indexOf('Planter un Champignon')!=-1)
  11428. texte = 'Planter un Champignon est une compétence qui vous permet de '
  11429. +'créer des colonies d\'une variété donnée de champignon à partir de '
  11430. +'quelques exemplaires préalablement enterrés.';
  11431. else if(comp.indexOf('Regeneration Accrue')!=-1)
  11432. texte = 'Régénération : <b>'+Math.floor(pvtotal/15)+'</b> D3'
  11433. +' => <b>+'+2*Math.floor(pvtotal/15)+'</b> PV';
  11434. else if(comp.indexOf('Reparation')!=-1)
  11435. texte = 'Marre de ces arnaqueurs de forgerons ? Prenez quelques outils, '
  11436. +'et réparez vous-même votre matériel !';
  11437. else if(comp.indexOf('Retraite')!=-1)
  11438. texte = 'Vous jugez la situation avec sagesse et estimez qu\'il serait '
  11439. +'préférable de préparer un repli stratégique pour déconcerter '
  11440. +'l\'ennemi et lui foutre une bonne branlée ... plus tard. MOUAHAHA ! '
  11441. +'Quelle intelligence démoniaque.';
  11442. else if(comp.indexOf('Rotobaffe')!=-1) {
  11443. var Datt = att, vattbm = attbp+attbm;
  11444. var Ddeg = deg, vdegbm = degbp+degbm;
  11445. for(var i=1 ; i<niveau+2 ; i++) {
  11446. texte += '<b>Attaque n°'+i+' :</b><br/>'
  11447. +'Attaque : <b>'+Datt+'</b> D6 '+aff(vattbm)
  11448. +' => <b>'+(Math.round(3.5*Datt)+vattbm)+'</b><br/>'
  11449. +'Dégâts : <b>'+Ddeg+'</b> D3 '+aff(vdegbm)
  11450. +' => <b>'+(2*Ddeg+vdegbm)+'</b>';
  11451. Datt = Math.floor(0.75*Datt); vattbm = Math.floor(0.75*vattbm);
  11452. Ddeg = Math.floor(0.75*Ddeg); vdegbm = Math.floor(0.75*vdegbm);
  11453. if(i<niveau+1) texte += '<hr>';
  11454. }
  11455. }
  11456. else if(comp.indexOf('Shamaner')!=-1)
  11457. texte = 'Permet de contrecarrer certains effets des pouvoirs spéciaux '
  11458. +'des monstres en utilisant des champignons (de 1 à 3).';
  11459. else if(comp.indexOf('Tailler')!=-1){
  11460. texte = 'Permet d\'augmenter sensiblement la valeur marchande de certains '
  11461. +'minerais. Mais cette opération délicate n\'est pas sans risques...';
  11462. }
  11463. return texte;
  11464. }
  11465.  
  11466. function decumul_buff(nom,str,buff) {
  11467. // Decumul des sorts de buff
  11468. var ret = '1<sup>ere</sup>'+nom+' : <b>'+str+' +'+buff+'</b>';
  11469. var dec = buff, total = buff, i=1;
  11470. while(i<6) {
  11471. i++;
  11472. dec = Math.floor(coefDecumul(i)*buff);
  11473. if(dec<=1 || i==6) break;
  11474. total += dec;
  11475. ret += '<br/><i>'+i+'<sup>e</sup> '+nom+' : '
  11476. +str+' +'+dec+' (+'+total+')</i>';
  11477. }
  11478. ret += '<br/><i>'+i+'<sup>e</sup> et + : '+str+' +'+dec+'</i>';
  11479. return ret;
  11480. }
  11481.  
  11482.  
  11483. function sortileges(sort,mainCall,pcA,pcD) {
  11484. // Si mainCall==false, affichage réduit des infos des sorts d'attaque pour PuM/PréM
  11485. var texte = '';
  11486. if (mainCall) {
  11487. /* pourcentages Des bonus/malus du a PuM/PreM : Att et Deg*/
  11488. pcA = (atttourP+atttourM);
  11489. pcD = (degtourP+degtourM);
  11490. }
  11491. if (sort.indexOf('Analyse Anatomique') != -1) {
  11492. texte = 'Portée horizontale : <b>'
  11493. + Math.floor(vuetotale / 2) + '</b> case';
  11494. if (vuetotale > 3){ texte += 's'; }
  11495. texte += '<br/>Portée verticale : <b>'
  11496. + Math.floor((vuetotale+1)/4)+'</b> case';
  11497. if (vuetotale > 7){ texte += 's'; }
  11498. }
  11499. else if (sort.indexOf('Armure Etheree') != -1){
  11500. texte = decumul_buff('AE', 'Armure magique', reg);
  11501. }
  11502. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Attaque') != -1){
  11503. texte = decumul_buff('AdA', 'Attaque physique', 1+Math.floor((att-3)/2));
  11504. }
  11505. else if (sort.indexOf('Augmentation') != -1 && sort.indexOf('Esquive') != -1){
  11506. texte = decumul_buff('AdE', 'Esquive', 1+Math.floor((esq-3)/2));
  11507. }
  11508. else if (sort.indexOf('Augmentation des Degats') != -1){
  11509. texte = decumul_buff('AdD', 'Dégâts physiques', 1 + Math.floor((deg-3)/2));
  11510. }
  11511. else if(sort.indexOf('Bulle Anti-Magie')!=-1){
  11512. texte = 'RM : <b>+'+rm+'</b><br/>MM : <b>-'+mm+'</b>';
  11513. }
  11514. else if(sort.indexOf('Bulle Magique')!=-1){
  11515. texte = 'RM : <b>-'+rm+'</b><br/>MM : <b>+'+mm+'</b>';
  11516. }
  11517. else if(sort.indexOf('Explosion')!=-1){
  11518. texte = 'Dégâts : <b>'
  11519. +Math.floor( 1+(deg+Math.floor(pvtotal/10))/2 )+'</b> D3 '
  11520. +' => <b>'+2*Math.floor(1+(deg+Math.floor(pvtotal/10))/2)
  11521. +' ('+resiste(1+(deg+Math.floor(pvtotal/10))/2 )+')</b>';
  11522. }
  11523. else if(sort.indexOf('Faiblesse Passagere')!=-1){
  11524. if(pvcourant<=0)
  11525. return '<i>Dans votre état, vous n\'affaiblirez personne...</i>';
  11526. texte = 'Portée horizontale : <b>'
  11527. +Math.min(1,vuetotale)+'</b> case<br/>'
  11528. +'Dégâts physiques : <b>-'
  11529. +Math.ceil( (Math.floor(pvcourant/10)+deg-5)/4 )
  11530. +' (-'+Math.ceil( (Math.floor(pvcourant/10)+deg-5)/8 )+')</b><br/>'
  11531. +'Dégâts magiques : <b>-'
  11532. +Math.floor( (Math.floor(pvcourant/10)+deg-4)/4 )
  11533. +' (-'+Math.floor( (Math.floor(pvcourant/10)+deg-2)/8 )+')</b>';
  11534. }
  11535. else if(sort.indexOf('Flash Aveuglant')!=-1){
  11536. texte = 'Vue, Attaque, Esquive : <b>-'+(1+Math.floor(vue/5))+'</b>';
  11537. }
  11538. else if(sort.indexOf('Glue')!=-1) {
  11539. texte = 'Portée : <b>'+(1+Math.floor(vuetotale/3))+'</b> case';
  11540. if(vuetotale>2) texte += 's';
  11541. }
  11542. else if(sort.indexOf('Griffe du Sorcier')!=-1){
  11543. /* Frappe */
  11544. var modD = 0;
  11545. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11546. if(pcA!=0){
  11547. modD = parseInt(att*pcA/100);
  11548. texte += '<i>'+aff(modD)+'D6</i> ';
  11549. }
  11550. texte += aff(attbm)
  11551. +' => <b>'+(Math.round(3.5*(att+modD))+attbm)+'</b><br/>'
  11552. +'Dégâts : <b>'+Math.floor(deg/2)+'</b> D3 ';
  11553. if(pcD!=0) {
  11554. modD = parseInt(Math.floor(deg/2)*pcD/100);
  11555. texte += '<i>'+aff(modD)+'D3</i> ';
  11556. }else
  11557. modD = 0;
  11558. texte += aff(degbm)+' => <b>'
  11559. +(2*(Math.floor(deg/2)+modD)+degbm)
  11560. +'/'+(2*(Math.floor(deg/2)+Math.floor(deg/4)+modD)+degbm)
  11561. +' ('+resiste(Math.floor(deg/2)+modD,degbm)
  11562. +'/'+resiste(Math.floor(deg/2)+Math.floor(deg/4)+modD,degbm)
  11563. +')</b>';
  11564. if(!mainCall) return texte;
  11565. /* Venins */
  11566. function addVenin(type,effet,duree) {
  11567. var ret = '<b>Venin '+type+' : </b><br/><b>'+effet+'</b> D3'
  11568. +' pendant <b>'+duree+'</b> tour';
  11569. if(duree>1) ret += 's';
  11570. var dred = Math.max(Math.floor(duree/2),1);
  11571. return ret+' => <b>'+2*effet+' x '+duree+' = '+2*effet*duree
  11572. +'</b> ('+2*effet+' x '+dred+' = '+2*effet*dred+')';
  11573. }
  11574. var effet = 1+Math.floor((Math.floor(pvbase/10)+reg)/3);
  11575. texte += '<hr>'+addVenin('insidieux',effet,2+Math.floor(vue/5));
  11576. effet = Math.floor(1.5*effet);
  11577. texte += '<hr>'+addVenin('virulent',effet,1+Math.floor(vue/10));
  11578. }
  11579. else if(sort.indexOf('Hypnotisme')!=-1)
  11580. texte = 'Esquive : <b>-'+Math.floor(1.5*esq)+'</b> Dés'
  11581. +' (<b>-'+Math.floor(esq/3)+'</b> Dés)';
  11582. else if(sort.indexOf('Identification des tresors')!=-1)
  11583. texte = 'Permet de connaitre les caractéristiques et effets précis '
  11584. +'d\'un trésor.';
  11585. else if(sort.indexOf('Invisibilite')!=-1)
  11586. texte = 'Un troll invisible est indétectable même quand on se trouve '
  11587. +'sur sa zone. Toute action physique ou sortilège d\'attaque '
  11588. +'fait disparaître l\'invisibilité.';
  11589. else if(sort.indexOf('Levitation')!=-1)
  11590. texte = 'Prendre un peu de hauteur permet parfois d\'éviter les ennuis. '
  11591. +'Comme les pièges ou les trous par exemple...';
  11592. else if(sort.indexOf('Precision')!=-1 || sort.indexOf('Puissance')!=-1) {
  11593. var eps = 1,
  11594. pc = 20;
  11595. var str = 'PréM';
  11596. var newSort;
  11597. var sortAtt = [
  11598. 'Projectile Magique',
  11599. 'Rafale Psychique',
  11600. 'Siphon des Ames',
  11601. 'Vampirisme',
  11602. 'Griffe du Sorcier'
  11603. ];
  11604. if(sort.indexOf('Puissance')!=-1) {
  11605. eps = -1; str='PuM';
  11606. }
  11607. for(var i=1 ; i<4 ; i++) {
  11608. if(texte) { texte += '<hr>'; }
  11609. texte += '<b>'+i+'<sup>e</sup> '+str+' ('+aff(pc)+' %) :</b><br/>';
  11610. newSort = false;
  11611. for(var j=0 ; j<sortAtt.length ; j++) {
  11612. if(getTalent(sortAtt[j])) {
  11613. if(newSort) { texte += '<br/><br/>'; }
  11614. texte += '<i>'+sortAtt[j]+' :</i><br/>'
  11615. +sortileges(sortAtt[j],false,eps*pc,-eps*pc);
  11616. newSort = true;
  11617. }
  11618. }
  11619. pc = decumulPumPrem(pc);
  11620. }
  11621. }
  11622. else if(sort.indexOf('Projectile Magique')!=-1) {
  11623. var modD = 0;
  11624. var portee = getPortee__Profil(vuetotale);
  11625. texte = 'Attaque : <b>'+vue+'</b> D6 ';
  11626. if(pcA!=0) {
  11627. modD = parseInt(vue*pcA/100);
  11628. texte += '<i>'+aff(modD)+'D6</i> ';
  11629. }
  11630. texte += aff(attbm)
  11631. +' => <b>'+(Math.round(3.5*(vue+modD))+attbm)+'</b><br/>'
  11632. +'Dégâts : <b>'+Math.floor(vue/2)+'</b> D3 ';
  11633. if(pcD!=0) {
  11634. modD = parseInt(Math.floor(vue/2)+pcD);
  11635. texte += '<i>'+aff(modD)+'D3</i> ';
  11636. }else
  11637. modD = 0;
  11638. texte += aff(degbm)
  11639. +' => <b>'+(2*(Math.floor(vue/2)+modD)+degbm)
  11640. +'/'+(2*(Math.floor(1.5*Math.floor(vue/2))+modD)+degbm)
  11641. +' ('+resiste(Math.floor(vue/2)+modD,degbm)
  11642. +'/'+resiste(1.5*Math.floor(vue/2)+modD,degbm)+')</b>';
  11643. if(!mainCall) return texte;
  11644. texte += '<br/>Portée : <b>'+portee+'</b> case';
  11645. if(portee>1) texte += 's';
  11646. }
  11647. else if(sort.indexOf('Projection')!=-1) {
  11648. texte = 'Si le jet de résistance de la victime est raté:<br/>'
  11649. +'la victime est <b>déplacée</b> et perd <b>1D6</b> d\'Esquive<hr>'
  11650. +'Si le jet de résistance de la victime est réussi:<br/>'
  11651. +'la victime ne <b>bouge pas</b> mais perd <b>1D6</b> d\'Esquive.';
  11652. }
  11653. else if(sort.indexOf('Rafale Psychique')!=-1) {
  11654. var modD = 0;
  11655. texte = 'Dégâts : <b>'+deg+'</b> D3 ';
  11656. if(pcD!=0) {
  11657. modD = parseInt(deg*pcD/100);
  11658. texte += '<i>'+aff(modD)+'D3</i> ';
  11659. }
  11660. texte += aff(degbm)
  11661. +' => <b>'+(2*(deg+modD)+degbm)+' ('+resiste(deg+modD,degbm)+')</b>';
  11662. if(!mainCall) return texte;
  11663. texte += '<br/>Malus : régénération <b>-'+deg+'</b>';
  11664. }
  11665. else if(sort.indexOf('Sacrifice')!=-1) {
  11666. if(pvcourant<=0)
  11667. return '<i>Qui voulez-vous donc soigner ? Vous êtes mort !</i>';
  11668.  
  11669. function perteSacro(sac) {
  11670. return ' (-'+(sac+2*(1+Math.floor(sac/5)))+' PV)';
  11671. }
  11672.  
  11673. var sac = Math.floor((pvcourant-1)/2);
  11674. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11675. +'Soin maximal : <b>'+sac+'</b> PV'+perteSacro(sac);
  11676. /* Sacros max et optimal sans malus (propale R') */
  11677. var pvdispoSansMalusTemps = pvcourant-pvtotal-Math.ceil((bmt+pdm)*pvtotal/250);
  11678. sac = Math.floor((pvdispoSansMalusTemps-2)*5/7);
  11679. if(sac>0)
  11680. texte += '<hr>Soin maximum limitant les risques de malus de temps : <b>' +sac+'</b> PV'+perteSacro(sac);
  11681. else
  11682. texte += '<hr>Vous ne pouvez pas compenser de blessures dues à un sacrifice';
  11683. /*if(sac>3) {
  11684. sac = 5*Math.floor((sac+1)/5)-1;
  11685. texte += '<br/>Soin optimal sans malus de temps : <b>'
  11686. +sac+'</b> PV'+perteSacro(sac);
  11687. }*/
  11688. }
  11689. else if(sort.indexOf('Siphon')!=-1) {
  11690. var modD = 0;
  11691. texte = 'Attaque : <b>'+att+'</b> D6 ';
  11692. if(pcA!=0) {
  11693. modD = parseInt(att*pcA/100);
  11694. texte += '<i>'+aff(modD)+'D6</i> ';
  11695. }
  11696. texte += aff(attbm)
  11697. +' => <b>'+Math.round(3.5*(att+modD)+attbm)+'</b><br/>'
  11698. +'Dégâts : <b>'+reg+'</b> D3 ';
  11699. if(pcD!=0) {
  11700. modD = parseInt(reg*pcD/100);
  11701. texte += '<i>'+aff(modD)+'D3</i> ';
  11702. }else
  11703. modD = 0;
  11704. texte += aff(degbm)
  11705. +' => <b>'+(2*(reg+modD)+degbm)+'/'+(2*(Math.floor(1.5*reg)+modD)+degbm)
  11706. +' ('+resiste(reg+modD,degbm)+'/'+resiste(1.5*reg+modD,degbm)+')</b>';
  11707. if(!mainCall) return texte;
  11708. texte += '<br/>Nécrose : attaque magique <b>-'+reg+'</b>';
  11709. }
  11710. else if(sort.indexOf('Telekinesie')!=-1) {
  11711. texte = 'Portée horizontale :';
  11712. var vt = Math.floor(vuetotale/2)+2;
  11713. var strList = ['d\'une Plum\' ou Très Léger','Léger',
  11714. 'Moyen','Lourd','Très Lourd ou d\'une Ton\''];
  11715. for(var i=0 ; i<5 ; i++) {
  11716. texte += '<br/><i>Trésor '+strList[i]+' : </i><b>'+vt+'</b> case';
  11717. if(vt>1) texte += 's';
  11718. vt=Math.max(0,vt-1);
  11719. }
  11720. }
  11721. else if(sort.indexOf('Teleportation')!=-1) {
  11722. var portee = getPortee__Profil(pitotal/5); // Roule, 30/09/2016, TP basé sur les PI
  11723. debugMZ('calcul portée Teleportation, pitotal=' + pitotal + ', portée=' + portee);
  11724. var pmh = (20+vue+portee);
  11725. var pmv = 3+Math.floor(portee/3);
  11726. texte = 'Portée horizontale : <b>'+pmh+'</b> cases<br/>'
  11727. +'Portée verticale : <b>'+pmv+'</b> cases<hr>'
  11728. +'X compris entre '+(posX-pmh)+' et '+(posX+pmh)+'<br/>'
  11729. +'Y compris entre '+(posY-pmh)+' et '+(posY+pmh)+'<br/>'
  11730. +'N compris entre '+(posN-pmv)+' et '+Math.min(-1,posN+pmv)+'<br/>';
  11731. }
  11732. else if(sort.indexOf('Vampirisme')!=-1) {
  11733. var modD = 0;
  11734. texte = 'Attaque : <b>'+Math.floor(2*deg/3)+'</b> D6 ';
  11735. if(pcA!=0) {
  11736. modD = parseInt(Math.floor(2*deg/3)*pcA/100);
  11737. texte += '<i>'+aff(modD)+'D6</i> ';
  11738. }
  11739. texte += aff(attbm)
  11740. +' => <b>'+Math.round(3.5*(Math.floor(2*deg/3)+modD)+attbm)+'</b><br/>'
  11741. +'Dégâts : <b>'+deg+'</b> D3 ';
  11742. if(pcD!=0) {
  11743. modD = parseInt(deg*pcD/100);
  11744. texte += '<i>'+aff(modD)+'D3</i> ';
  11745. }else
  11746. modD = 0;
  11747. texte += aff(degbm)
  11748. +' => <b>'+(2*(deg+modD)+degbm)+'/'+(2*(Math.floor(1.5*deg)+modD)+degbm)
  11749. +' ('+resiste(deg+modD,degbm)+'/'+resiste(1.5*deg+modD,degbm)+')</b>';
  11750. }
  11751. else if(sort.indexOf('Vision Accrue')!=-1)
  11752. texte = decumul_buff('VA','Vue',Math.floor(vue/2));
  11753. else if(sort.indexOf('Vision lointaine')!=-1)
  11754. texte = 'En ciblant une zone située n\'importe où dans le '
  11755. +'Monde Souterrain, votre Trõll peut voir comme s\'il s\'y trouvait.';
  11756. else if(sort.indexOf('Voir le Cache')!=-1)
  11757. texte = '<b>Sur soi :</b><br/>Portée horizontale : <b>'
  11758. +Math.min(5,getPortee__Profil(vue))+'</b> cases<hr>'
  11759. +'<b>A distance :</b><br/>Portée horizontale : <b>'
  11760. +getPortee__Profil(vuetotale)+'</b> cases';
  11761. else if(sort.indexOf('Vue Troublee')!=-1)
  11762. texte = 'Portée horizontale : <b>'+Math.min(1,vuetotale)+'</b> case<br/>'
  11763. +'Vue : <b>-'+Math.floor(vue/3)+'</b>';
  11764. return texte;
  11765. }
  11766.  
  11767.  
  11768. /*---------------------------------- Main ------------------------------------*/
  11769.  
  11770. function do_profil2()
  11771. {
  11772. try {
  11773. start_script(31);
  11774.  
  11775. extractionDonnees();
  11776. setInfosCaracteristiques();
  11777. setInfoDescription();
  11778. setInfosEtatLieux();
  11779. setInfosEtatPV();
  11780. setInfosExp();
  11781.  
  11782. creerBulleVide();
  11783. traitementTalents();
  11784. setLienAnatrolliseur();
  11785.  
  11786. // Cette fonction modifie lourdement le DOM, à placer en dernier :
  11787. if(race=='Kastar'){ setAccel(); }
  11788. saveProfil();
  11789. displayScriptTime();
  11790. } catch(e) {
  11791. avertissement("[MZ " + GM_info.script.version + "] Une erreur s'est produite.");
  11792. window.console.error(traceStack(e, 'profil2'));
  11793. }
  11794. }
  11795.  
  11796. /*******************************************************************************
  11797. * This file is part of Mountyzilla. *
  11798. * *
  11799. * Mountyzilla is free software; you can redistribute it and/or modify *
  11800. * it under the terms of the GNU General Public License as published by *
  11801. * the Free Software Foundation; either version 2 of the License, or *
  11802. * (at your option) any later version. *
  11803. * *
  11804. * Mountyzilla is distributed in the hope that it will be useful, *
  11805. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11806. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  11807. * GNU General Public License for more details. *
  11808. * *
  11809. * You should have received a copy of the GNU General Public License *
  11810. * along with Mountyzilla; if not, write to the Free Software *
  11811. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
  11812. *******************************************************************************/
  11813.  
  11814. // x~x script_principal
  11815.  
  11816. function isPage(url) {
  11817. return window.location.pathname.indexOf("/mountyhall/"+url) == 0;
  11818. }
  11819.  
  11820. // x~x md5.js
  11821. /*
  11822. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  11823. * Digest Algorithm, as defined in RFC 1321.
  11824. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  11825. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  11826. * Distributed under the BSD License
  11827. * See http://pajhome.org.uk/crypt/md5 for more info.
  11828. */
  11829.  
  11830. /*
  11831. * Configurable variables. You may need to tweak these to be compatible with
  11832. * the server-side, but the defaults work in most cases.
  11833. */
  11834. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  11835. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  11836. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  11837.  
  11838. /*
  11839. * These are the functions you'll usually want to call
  11840. * They take string arguments and return either hex or base-64 encoded strings
  11841. */
  11842. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  11843. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  11844. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  11845. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  11846. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  11847. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
  11848.  
  11849. /*
  11850. * Perform a simple self-test to see if the VM is working
  11851. */
  11852. function md5_vm_test()
  11853. {
  11854. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  11855. }
  11856.  
  11857. /*
  11858. * Calculate the MD5 of an array of little-endian words, and a bit length
  11859. */
  11860. function core_md5(x, len)
  11861. {
  11862. /* append padding */
  11863. x[len >> 5] |= 0x80 << ((len) % 32);
  11864. x[(((len + 64) >>> 9) << 4) + 14] = len;
  11865.  
  11866. var a = 1732584193;
  11867. var b = -271733879;
  11868. var c = -1732584194;
  11869. var d = 271733878;
  11870.  
  11871. for(var i = 0; i < x.length; i += 16)
  11872. {
  11873. var olda = a;
  11874. var oldb = b;
  11875. var oldc = c;
  11876. var oldd = d;
  11877.  
  11878. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  11879. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  11880. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  11881. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  11882. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  11883. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  11884. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  11885. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  11886. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  11887. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  11888. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  11889. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  11890. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  11891. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  11892. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  11893. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  11894.  
  11895. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  11896. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  11897. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  11898. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  11899. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  11900. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  11901. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  11902. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  11903. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  11904. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  11905. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  11906. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  11907. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  11908. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  11909. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  11910. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  11911.  
  11912. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  11913. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  11914. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  11915. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  11916. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  11917. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  11918. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  11919. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  11920. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  11921. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  11922. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  11923. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  11924. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  11925. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  11926. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  11927. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  11928.  
  11929. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  11930. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  11931. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  11932. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  11933. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  11934. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  11935. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  11936. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  11937. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  11938. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  11939. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  11940. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  11941. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  11942. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  11943. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  11944. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  11945.  
  11946. a = safe_add(a, olda);
  11947. b = safe_add(b, oldb);
  11948. c = safe_add(c, oldc);
  11949. d = safe_add(d, oldd);
  11950. }
  11951. return Array(a, b, c, d);
  11952.  
  11953. }
  11954.  
  11955. /*
  11956. * These functions implement the four basic operations the algorithm uses.
  11957. */
  11958. function md5_cmn(q, a, b, x, s, t)
  11959. {
  11960. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  11961. }
  11962. function md5_ff(a, b, c, d, x, s, t)
  11963. {
  11964. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  11965. }
  11966. function md5_gg(a, b, c, d, x, s, t)
  11967. {
  11968. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  11969. }
  11970. function md5_hh(a, b, c, d, x, s, t)
  11971. {
  11972. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  11973. }
  11974. function md5_ii(a, b, c, d, x, s, t)
  11975. {
  11976. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  11977. }
  11978.  
  11979. /*
  11980. * Calculate the HMAC-MD5, of a key and some data
  11981. */
  11982. function core_hmac_md5(key, data)
  11983. {
  11984. var bkey = str2binl(key);
  11985. if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  11986.  
  11987. var ipad = Array(16), opad = Array(16);
  11988. for(var i = 0; i < 16; i++)
  11989. {
  11990. ipad[i] = bkey[i] ^ 0x36363636;
  11991. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  11992. }
  11993.  
  11994. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  11995. return core_md5(opad.concat(hash), 512 + 128);
  11996. }
  11997.  
  11998. /*
  11999. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  12000. * to work around bugs in some JS interpreters.
  12001. */
  12002. function safe_add(x, y)
  12003. {
  12004. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  12005. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  12006. return (msw << 16) | (lsw & 0xFFFF);
  12007. }
  12008.  
  12009. /*
  12010. * Bitwise rotate a 32-bit number to the left.
  12011. */
  12012. function bit_rol(num, cnt)
  12013. {
  12014. return (num << cnt) | (num >>> (32 - cnt));
  12015. }
  12016.  
  12017. /*
  12018. * Convert a string to an array of little-endian words
  12019. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  12020. */
  12021. function str2binl(str)
  12022. {
  12023. var bin = Array();
  12024. var mask = (1 << chrsz) - 1;
  12025. for(var i = 0; i < str.length * chrsz; i += chrsz)
  12026. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  12027. return bin;
  12028. }
  12029.  
  12030. /*
  12031. * Convert an array of little-endian words to a string
  12032. */
  12033. function binl2str(bin)
  12034. {
  12035. var str = "";
  12036. var mask = (1 << chrsz) - 1;
  12037. for(var i = 0; i < bin.length * 32; i += chrsz)
  12038. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  12039. return str;
  12040. }
  12041.  
  12042. /*
  12043. * Convert an array of little-endian words to a hex string.
  12044. */
  12045. function binl2hex(binarray)
  12046. {
  12047. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  12048. var str = "";
  12049. for(var i = 0; i < binarray.length * 4; i++)
  12050. {
  12051. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  12052. hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  12053. }
  12054. return str;
  12055. }
  12056.  
  12057. /*
  12058. * Convert an array of little-endian words to a base-64 string
  12059. */
  12060. function binl2b64(binarray)
  12061. {
  12062. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12063. var str = "";
  12064. for(var i = 0; i < binarray.length * 4; i += 3)
  12065. {
  12066. var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
  12067. | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  12068. | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  12069. for(var j = 0; j < 4; j++)
  12070. {
  12071. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  12072. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  12073. }
  12074. }
  12075. return str;
  12076. }
  12077.  
  12078. ///////////////////////////////////////////
  12079. // debug cartes capitan Roule 07/12/2016
  12080. ///////////////////////////////////
  12081. // essais : objet
  12082. // .mode : description
  12083. // .essais : tableau d'objets essai
  12084. // .mode : description
  12085. // .essais : tableau de cartes
  12086. // .noCarte : id de la carte
  12087. // .essais : tableau d'essais, [x, y, n, nb]
  12088. function AfficheEssais(essais, sMode) {
  12089. var eBigDiv = document.getElementById('ListeEssaiCapitan');
  12090. if (!eBigDiv) {
  12091. var insertPoint = document.getElementById('footer1');
  12092. eBigDiv = document.createElement('table');
  12093. eBigDiv.id = 'ListeEssaiCapitan';
  12094. insertBefore(insertPoint, document.createElement('p'));
  12095. insertTitle(insertPoint,'Capitan : Liste des essais');
  12096. insertBefore(insertPoint, eBigDiv);
  12097. addTrEssais(eBigDiv, 'mode', 'carte', 'nombre d\'essais', true);
  12098. }
  12099. if (!essais) {
  12100. addTrEssais(eBigDiv, sMode, '', 'pas d\'essai', false);
  12101. return;
  12102. }
  12103. var carte;
  12104. for (carte in essais) {
  12105. addTrEssais(eBigDiv, sMode, carte, essais[carte] + ' essai(s)', false);
  12106. }
  12107. if (carte === undefined) {
  12108. addTrEssais(eBigDiv, sMode, '', '0 essai', false);
  12109. }
  12110. }
  12111.  
  12112. function addTrEssais(eTable, sMode, sCarte, sText, bBold) {
  12113. var tr = appendTr(eTable);
  12114. var td = appendTd(tr);
  12115. appendText(td, sMode, bBold);
  12116. td = appendTd(tr);
  12117. appendText(td, sCarte, bBold);
  12118. td = appendTd(tr);
  12119. appendText(td, sText, bBold);
  12120. }
  12121.  
  12122. function getEssaiV1_0() {
  12123. try {
  12124. var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  12125. prefs = prefs.getBranch("mountyzilla.storage.capitan.");
  12126. var tabK, nK;
  12127. prefs.getChildList('', nK, tabK);
  12128. window.console.log('getEssaiV1_0, nb key : ' + nK);
  12129. //window.console.log('getEssaiV1_0, ' + nK);
  12130. return;
  12131. //return r;
  12132. } catch (e) {
  12133. window.console.log(traceStack(e, 'getEssaiV1_0'));
  12134. }
  12135. }
  12136.  
  12137. function getEssaiV1_1() {
  12138. var locSto = window.localStorage;
  12139. window.console.log('getEssaiV1_1, nb key : ' + locSto.length);
  12140. var r = [];
  12141. for (var i = 0; i < locSto.length; i++) {
  12142. var k = locSto.key(i);
  12143. //window.console.log('getEssaiV1_1 key ' + k + ' => ' + locSto.getItem(k));
  12144. var t = k.split(/\./);
  12145. if (t[0] !== 'capitan') continue;
  12146. if (t[2] !== 'essai') continue;
  12147. var carte = 'carte n°' + t[1];
  12148. if (r[carte]) r[carte]++;
  12149. else r[carte] = 1;
  12150. //window.console.log('getEssaiV1_1 r[' + carte + ']=' + r[carte]);
  12151. }
  12152. return r;
  12153. }
  12154.  
  12155. function showEssaiCartes() {
  12156. window.console.log('début showEssai Tout_MZ');
  12157. var essais = getEssaiV1_0();
  12158. AfficheEssais(essais, 'V1.0');
  12159. essais = getEssaiV1_1();
  12160. AfficheEssais(essais, 'V1.1');
  12161. window.console.log('fin showEssai Tout_MZ');
  12162. }
  12163.  
  12164. function testBoolLocalStorage() {
  12165. var b = true;
  12166. var key = 'MZ_essai_bool';
  12167. GM_setValue(key, b);
  12168. window.localStorage[key] = b;
  12169. var v = GM_getValue(key);
  12170. window.console.log('recup GM true => ' + v + ', ' + typeof v);
  12171. var v = window.localStorage.getItem(key);
  12172. window.console.log('recup localstorage true => ' + v + ', ' + typeof v); // localStorage nous rend une chaine 'true' :(
  12173.  
  12174. var b = false;
  12175. GM_setValue(key, b);
  12176. window.localStorage[key] = b;
  12177. var v = GM_getValue(key);
  12178. window.console.log('recup GM false => ' + v + ', ' + typeof v);
  12179. var v = window.localStorage.getItem(key);
  12180. window.console.log('recup localstorage false => ' + v + ', ' + typeof v);
  12181.  
  12182. var x = window.localStorage.getItem('lkjlkjerziurlijzer');
  12183. window.console.log('recup LocalStorage inconnu => ' + typeof(x)); // object null
  12184. var y = GM_getValue('654654897894654654');
  12185. window.console.log('recup GM inconnu => ' + typeof(y)); // undefined
  12186. window.console.log('égalité ? => ' + (x == y)); // les deux sont "égaux" avec l'opérateur == (pas avec ===, bien sûr)
  12187. }
  12188.  
  12189. /*--------------------------------- Création liste trolligion ---------------------------------*/
  12190. function export_trolligion() {
  12191. try {
  12192. var tabDl = document.getElementsByTagName('dl');
  12193. if ((!tabDl) || !tabDl[0]) {
  12194. window.console.log('[MZ ' + GM_info.script.version + '] pas de dl');
  12195. return;
  12196. }
  12197. var tabDieux = []; // chaque élément est un objet avec les propriétés suivantes
  12198. // nom : string
  12199. // rayonnement : entier
  12200. // grades : table d'objets (une occurence par grade)
  12201. // nom : string
  12202. // trolls : table d'objets (un par Trõll)
  12203. // id
  12204. // nom
  12205. // idguilde
  12206. // guilde
  12207. // race
  12208. // niveau
  12209. // ferveur
  12210. var currentDieu;
  12211. var currentGrade;
  12212. for (var iChild1 in tabDl[0].children) {
  12213. var eChild1 = tabDl[0].children[iChild1];
  12214. if (eChild1.tagName) switch (eChild1.tagName.toLowerCase()) {
  12215. case 'dd': // Trõll
  12216. var oTroll = {};
  12217. var tabFigcaption = eChild1.getElementsByTagName('figcaption');
  12218. if ((!tabFigcaption) || !tabFigcaption[0]) {
  12219. window.console.log('[MZ ' + GM_info.script.version + '] ignore dd sans figcaption ' + eChild1.innerHTML);
  12220. break;
  12221. }
  12222. for (var iChild2 in tabFigcaption[0].childNodes) { // childNodes pour obtenir les éléments texte aussi
  12223. var eChild2 = tabFigcaption[0].childNodes[iChild2];
  12224. if (eChild2.nodeType === undefined) continue; // properties
  12225. //window.console.log('[MZ ' + GM_info.script.version + '] eChild2 ' + iChild2 + ' ' + eChild2.nodeName);
  12226. switch (eChild2.nodeType) {
  12227. case 1: //ELEMENT_NODE:
  12228. switch (eChild2.nodeName.toLowerCase()) {
  12229. case 'a':
  12230. var m;
  12231. if (!eChild2.href) {
  12232. window.console.log('[MZ ' + GM_info.script.version + '] a sans href ' + eChild2.outerHTML);
  12233. break;
  12234. }
  12235. m = eChild2.href.match(/EnterPJView\((\d+) *,/);
  12236. if (m) {
  12237. oTroll.id = parseInt(m[1]);
  12238. oTroll.nom = (eChild2.innerText || eChild2.textContent).trim();
  12239. break;
  12240. }
  12241. m = eChild2.href.match(/EnterAllianceView\((\d+) *,/);
  12242. if (m) {
  12243. var idGuilde = parseInt(m[1]);
  12244. if (idGuilde > 1) { // MH donne 1 comme idGuilde quand le Trõll n'est pas guildé
  12245. oTroll.idguilde = parseInt(m[1]);
  12246. oTroll.guilde = (eChild2.innerText || eChild2.textContent).trim();
  12247. }
  12248. break;
  12249. }
  12250. window.console.log('[MZ ' + GM_info.script.version + '] a non traité ' + eChild2.outerHTML);
  12251. break;
  12252. case 'br': // ignore
  12253. case 'style': // ignore
  12254. break;
  12255. case 'div': // barre de vie
  12256. if (eChild2.children[0] && eChild2.children[0].tagName.toLowerCase() == 'div') {
  12257. eChild3 = eChild2.children[0];
  12258. if (eChild3.children[0] && eChild3.children[0].tagName.toLowerCase() == 'div') {
  12259. var eChild4 = eChild3.children[0];
  12260. if (eChild4.style && eChild4.style.width) oTroll.ferveur = eChild4.style.width;
  12261. break;
  12262. }
  12263. }
  12264. // pas de break pour bénéficier du log ci-dessous
  12265. default:
  12266. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément tag ' + eChild2.nodeName);
  12267. break;
  12268. }
  12269. break;
  12270. case 3: //TEXT_NODE:
  12271. var txt = eChild2.nodeValue.trim();
  12272. if (txt === '') break;
  12273. var m = txt.match(/(.*) *\((\d+)\)/);
  12274. if (m) {
  12275. oTroll.race = m[1].trim();
  12276. oTroll.niveau = parseInt(m[2]);
  12277. } else {
  12278. oTroll.race = txt;
  12279. }
  12280. break;
  12281. default: // ne devrait pas arriver
  12282. window.console.log('[MZ ' + GM_info.script.version + '] ignore élément type ' + eChild2.nodeType);
  12283. break;
  12284. }
  12285. }
  12286. currentGrade.trolls.push(oTroll);
  12287. break;
  12288. case 'dt':
  12289. var tabH3 = eChild1.getElementsByTagName('h3');
  12290. if (tabH3 && tabH3[0]) { // changement de dieu
  12291. currentDieu = {
  12292. nom: tabH3[0].innerText || tabH3[0].textContent
  12293. , grades: []};
  12294. var txt = eChild1.innerText || eChild1.textContent;
  12295. var m = txt.match(/yon*ement *:* *(\d+)/);
  12296. if (m) currentDieu.rayonnement = parseInt(m[1]);
  12297. currentGrade = undefined;
  12298. tabDieux.push(currentDieu);
  12299. break;
  12300. }
  12301. var tabH4 = eChild1.getElementsByTagName('h4');
  12302. if (tabH4 && tabH4[0]) { // changement de grade
  12303. var grade;
  12304. var txt = tabH4[0].innerText || tabH4[0].textContent;
  12305. tabI = tabH4[0].getElementsByTagName('i');
  12306. if (tabI && tabI[0]) {
  12307. grade = tabI[0].innerText || tabI[0].textContent;
  12308. grade = grade.replace(/"/g, '');
  12309. m = txt.match(/\((.*)\)/); // cas particulier Líhã dont les grades ont des catégories
  12310. if (m) grade += ' (' + m[1] + ')';
  12311. } else {
  12312. grade = txt.replace(/"/g, '');
  12313. }
  12314. currentGrade = {nom: grade, trolls: []};
  12315. currentDieu.grades.push(currentGrade);
  12316. break;
  12317. }
  12318. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag dt ' + eChild1.innerHTML);
  12319. break;
  12320. default:
  12321. window.console.log('[MZ ' + GM_info.script.version + '] ignore tag ' + eChild1.tagName); //+ ' ' + eChild1);
  12322. }
  12323. }
  12324.  
  12325. //window.console.log('[MZ ' + GM_info.script.version + '] nb dieux = ' + tabDieux.length);
  12326. //window.console.log('[MZ ' + GM_info.script.version + '] ' + JSON.stringify(tabDieux));
  12327. var txt = "Dieu\tRayonnement\tGrade\tidTroll\tTroll\tidGuilde\tGuilde\tRace\tNiveau\tFerveur\n";
  12328. var txt2 = "Dieu\tRayonnement\n"; // Roule 25/01/2017 ajout d'un tableau résumé par religion
  12329. for (var iDieu in tabDieux) {
  12330. var oDieu = tabDieux[iDieu];
  12331. for (var iGrade in oDieu.grades) {
  12332. var oGrade = oDieu.grades[iGrade];
  12333. for (var iTroll in oGrade.trolls) {
  12334. var oTroll = oGrade.trolls[iTroll];
  12335. var t = [oDieu.nom, oDieu.rayonnement
  12336. , oGrade.nom
  12337. , oTroll.id, oTroll.nom
  12338. , oTroll.idguilde, oTroll.guilde
  12339. , oTroll.race, oTroll.niveau
  12340. , oTroll.ferveur];
  12341. for (var iParam in t) {
  12342. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12343. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12344. }
  12345. txt += t.join("\t") + "\n";
  12346. }
  12347. }
  12348. var t = [oDieu.nom, oDieu.rayonnement];
  12349. for (var iParam in t) {
  12350. if (t[iParam] === undefined) t[iParam] = ''; // protection
  12351. t[iParam] = t[iParam].toString().replace(/[\n\r\t]/g, ' ').trim(); // plus de protection
  12352. }
  12353. txt2 += t.join("\t") + "\n";
  12354. }
  12355. txt += "\n" + txt2;
  12356. } catch (e) {
  12357. window.alert("Échec à l'extraction\n" + e);
  12358. }
  12359. //window.console.log('[MZ ' + GM_info.script.version + '] txt = ' + txt);
  12360. try {
  12361. if (copyTextToClipboard(txt)) {
  12362. window.alert("[MZ] Les données ont été copiées dans le presse-papier\n"
  12363. + "Collez dans Calc\n"
  12364. + "ou, au pire, dans EXCEL®");
  12365. } else {
  12366. window.alert("[MZ] Echec à la copie vers le presse-papier\nVoir la console (F12)");
  12367. }
  12368. } catch(e) {
  12369. window.alert("[MZ] Échec à la copie vers le presse-papier\n" + e);
  12370. }
  12371. }
  12372.  
  12373. function do_trolligion() {
  12374. var divpopup = document.createElement('div');
  12375. divpopup.id = 'MZ_divCopier';
  12376. divpopup.style.position = 'fixed';
  12377. divpopup.style.top = '2px';
  12378. divpopup.style.left = '2px;';
  12379. divpopup.style.backgroundColor = 'rgba(255,255,255,0.5)';
  12380. divpopup.style.cursor = 'pointer';
  12381. divpopup.style.zIndex = 200;
  12382. divpopup.title = '[MZ] Cliquer ici pour copier les données';
  12383. divpopup.onclick = export_trolligion;
  12384. var img = createAltImage(URL_MZimg + 'copy_32.png', 'Cliquer ici pour copier les données');
  12385. divpopup.appendChild(img);
  12386. document.body.appendChild(divpopup);
  12387. }
  12388.  
  12389. /*--------------------------------- Dispatch ---------------------------------*/
  12390.  
  12391. //chargerScriptDev("libs");
  12392. //chargerScriptDev("ALWAYS"); // ALWAYS contient des aides au test (GOD-MODE ;)
  12393. //if (isDEV) testBoolLocalStorage();
  12394.  
  12395. // Détection de la page à traiter
  12396. if(isPage("Messagerie/ViewMessageBot")) {
  12397. do_cdmbot();
  12398. } else if(isPage("MH_Play/Actions/Competences/Play_a_Competence16b")) {
  12399. do_cdmcomp();
  12400. } else if(window.location.pathname.indexOf("/mountyhall/CdM.competence")>=0) { // test Roule 20/03/2017
  12401. do_cdmcomp();
  12402. } else if(isPage('MH_Play/Actions/Competences/Play_a_CompetenceResult.php')) { // ajout Roule 10/03/2017 (modif MH ?)
  12403. do_cdmcomp();
  12404. } else if(isPage("MH_Guildes/Guilde_o_AmiEnnemi")) {
  12405. do_diplo();
  12406. } else if(isPage("MH_Play/Play_equipement")) {
  12407. do_equip();
  12408. } else if(isPage("MH_Play/Play_menu")) {
  12409. do_menu();
  12410. } else if(isPage("MH_Play/Options/Play_o_Interface") || isPage("installPack")) {
  12411. do_option();
  12412. //showEssaiCartes();
  12413. } else if(isPage("View/PJView")) {
  12414. do_pjview();
  12415. } else if(isPage("MH_Play/Play_profil") && !isPage('MH_Play/Play_profil2')) {
  12416. do_profil();
  12417. } else if(isPage("MH_Taniere/TanierePJ_o_Stock") || isPage("MH_Comptoirs/Comptoir_o_Stock")) {
  12418. do_tancompo();
  12419. } else if(isPage("MH_Play/Play_vue")) {
  12420. do_vue();
  12421. } else if(isPage("MH_Play/Play_news")) {
  12422. do_news();
  12423. } else if(isPage("MH_Play/Actions/Play_a_Move")) {
  12424. do_move();
  12425. } else if(isPage("MH_Missions/Mission_Etape")) {
  12426. do_mission();
  12427. } else if(isPage("View/MonsterView")) {
  12428. do_infomonstre();
  12429. } else if(isPage("MH_Play/Actions/Play_a_Attack")) {
  12430. do_attaque();
  12431. } else if(isPage("MH_Play/Play_e_follo.php")) {
  12432. do_listegowap();
  12433. } else if(isPage("MH_Lieux/Lieu_Description.php")) {
  12434. do_lieuDescription();
  12435. } else if(isPage("MH_Lieux/Lieu_Teleport")) {
  12436. do_lieuTeleport();
  12437. } else if(isPage("MH_Follower/FO_Ordres")) {
  12438. do_ordresgowap();
  12439. } else if(isPage("MH_Follower/FO_Equipement")) {
  12440. do_equipgowap();
  12441. } else if(isPage("MH_Play/Play_mouche")) {
  12442. do_mouches();
  12443. } else if(isPage("MH_Play/Play_BM")) {
  12444. do_malus();
  12445. } else if(isPage("MH_Play/Play_evenement")) {
  12446. do_myevent();
  12447. } else if(isPage("MH_Lieux/Lieu_DemanderEnchantement")) {
  12448. do_enchant();
  12449. } else if(isPage("MH_Lieux/Lieu_Enchanteur")) {
  12450. do_pre_enchant();
  12451. } else if(isPage("MH_Play/Actions") || isPage("Messagerie/ViewMessageBot")) {
  12452. do_actions();
  12453. } 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')) {
  12454. do_mission_liste();
  12455. } else if(isPage('MH_Play/Play_action')) {
  12456. do_actions();
  12457. } else if(isPage('MH_Play/Play_profil2')) {
  12458. do_profil2();
  12459. } else if(isPage('View/TrolligionView.php')) {
  12460. do_trolligion();
  12461. }
  12462. } catch(e) {
  12463. try {
  12464. window.console.log(traceStack(e, 'catch général page ' + window.location.pathname));
  12465. } catch(e2) {
  12466. window.console.log('catch général page ' + window.location.pathname + "\n" + e.message);
  12467. }
  12468. }